npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@collabland/staking-contracts

v1.13.0

Published

Staking contracts supported by Collab.Land

Downloads

1,171

Readme

@collabland/staking-contracts

This project maintains a curated list of stacking contracts for Collab.Land's token gating capabilities.

Get started

  1. Check out the project

    git clone [email protected]:abridged/collabland-staking-contracts.git
  2. Install dependencies

    npm install
  3. Run the build

    npm run build
  4. Run the example

    node dist/__examples__/main

High level architecture

staking-contracts

Add a new staking contract

Please collect the following information for your staking contract:

  • Chain id, contract address, and optional asset names (if multiple asset types can be staked to the contract) for the staking contract
  • Solidity source code and/or ABI for the staking contract
  • Chain id and contract address(es) for the original contract containing tokens to be staked

Contribute extension code for your staking contract

To add a new staking contract, please follow the steps below.

  1. Add the contract ABI json file, go to src/contracts and create a file such as my-abi.json

  2. Run npm run build to generate TypeScript client code for the contract

  3. Add an adapter class to src/adapters:

import {BindingScope, extensionFor, injectable} from '@loopback/core';
import {BigNumber} from 'ethers';
import {STAKING_ADAPTERS_EXTENSION_POINT} from '../keys.js';
import {BaseStakingContractAdapter, StakingAsset} from '../staking.js';
// Use the full path to import instead of `../types`
import {Coco__factory} from '../types/factories/Coco__factory.js';

@injectable(
  {
    scope: BindingScope.SINGLETON, // Mark the adapter as a singleton
  },
  // Mark it as an extension to staking contracts service
  extensionFor(STAKING_ADAPTERS_EXTENSION_POINT),
)
export class CocoStakingContractAdapter extends BaseStakingContractAdapter {
  /**
   * The contract address
   */
  contractAddress = '0x0Df016Fb18ef4195b2CF9d8623E236272ec52e14';

  /**
   * Assets that can be staked to this contract
   */
  supportedAssets: StakingAsset[] = [
    {
      asset: 'ERC721:0x1A331c89898C37300CccE1298c62aefD3dFC016c',
    },
  ];

  /**
   * Get staked token ids for the given owner
   * @param owner - Owner address
   * @returns
   */
  getStakedTokenIds(owner: string): Promise<BigNumber[]> {
    const contract = Coco__factory.connect(this.contractAddress, this.provider);
    return contract.getStakes(owner);
  }
}
  1. Register the adapter class to src/component.ts
// Copyright Abridged, Inc. 2022. All Rights Reserved.
// Node module: @collabland/staking-contracts
// This file is licensed under the MIT License.
// License text available at https://opensource.org/licenses/MIT

import {
  Component,
  ContextTags,
  injectable,
  ServiceOrProviderClass,
} from '@loopback/core';
import {CocoStakingContractAdapter} from './adapters/coco.adapter';
import {MtgStakingContractAdapter} from './adapters/mtg.adapter';
import {RirsuStakingContractAdapter} from './adapters/rirsu.adapter';
import {RoboStakingContractAdapter} from './adapters/robo.adapter';
import {SkyFarmContractAdapter} from './adapters/sky-farm.adapter';
import {STAKING_CONTRACTS_COMPONENT} from './keys';
import {StakingContractsService} from './services/staking-contracts.service';

// Configure the binding for StakingContractsComponent
@injectable({
  tags: {[ContextTags.KEY]: STAKING_CONTRACTS_COMPONENT},
})
export class StakingContractsComponent implements Component {
  services: ServiceOrProviderClass<unknown>[] = [
    StakingContractsService,
    CocoStakingContractAdapter,
    MtgStakingContractAdapter,
    RirsuStakingContractAdapter,
    RoboStakingContractAdapter,
    SkyFarmContractAdapter,
  ];
  constructor() {}
}

Submit a pull request

When you contribute code to this project, please check the following steps before submitting a pull request.

  1. Run the tests

    npm test
  2. Format the code

    npm run lint:fix
  3. Sign off commits

    Add a Signed-off-by trailer by the committer at the end of the commit log message. The sign-off certifies that the committer has the rights to submit the work under the project’s license or agrees to a Developer Certificate of Origin (DCO).

    See instructions at https://git-scm.com/docs/git-commit#Documentation/git-commit.txt--s.

What's Next?

After your pull request is merged, we'll publish a release of this package to npm. The new version will be picked up by Collab.Land servers (QA first, then production). Community admins can then use the newly added staking contract to define token gating rules.

Publish a new release (for maintainers only)

npm run release