UNPKG

@collabland/staking-contracts

Version:
52 lines 2.11 kB
import { __decorate } from "tslib"; import { BindingScope, extensionFor, injectable } from '@loopback/core'; import { BigNumber } from 'ethers'; import { STAKING_ADAPTERS_EXTENSION_POINT } from '../keys.js'; import { BaseStakingContractAdapter } from '../staking.js'; // Use the full path to import instead of `../types` import { PrimordiaStaking__factory } from '../types/factories/PrimordiaStaking__factory.js'; let PrimordiaStakingContractAdapter = class PrimordiaStakingContractAdapter extends BaseStakingContractAdapter { constructor() { super(...arguments); /** * The contract address */ this.contractAddress = '0x9972EDCE48d82d16C82326e23f894f9aA0e3bb32'; /** * Assets that can be staked to this contract */ this.supportedAssets = [ { asset: 'ERC721:0xFbB87a6A4876820d996a9bbe106e4f73a5E4A71C', }, ]; } /** * Get staked token ids for the given owner * @param owner - Owner address * @returns all the token ids staked by the user for that asset */ async getStakedTokenIds(owner) { const contract = PrimordiaStaking__factory.connect(this.contractAddress, this.provider); return contract.tokensOfOwner(owner); } /** * Get staked token ids for the given owner * @param owner - Owner address * @returns the balance of that asset staked by the user */ async getStakedTokenBalance(owner) { const contract = PrimordiaStaking__factory.connect(this.contractAddress, this.provider); const allStakedTokens = await contract.tokensOfOwner(owner); return BigNumber.from(allStakedTokens.length); } }; PrimordiaStakingContractAdapter = __decorate([ injectable({ scope: BindingScope.SINGLETON, // Mark the adapter as a singleton }, // Mark it as an extension to staking contracts service extensionFor(STAKING_ADAPTERS_EXTENSION_POINT)) ], PrimordiaStakingContractAdapter); export { PrimordiaStakingContractAdapter }; //# sourceMappingURL=primordia.adapter.js.map