Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding W3ABPass #258

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 47 additions & 0 deletions src/adapters/W3ABPass.adapter.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
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 {W3ABPass__factory} from '../types/factories/W3ABPass__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 W3ABPassContractAdapter extends BaseStakingContractAdapter {
/**
* The contract address
*/
contractAddress = '0x45c06D92b9034b98bc458ac378e3DFA50D7aB188';
chainId: number = 8453;

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

/**
* Get staked token ids for the given owner
* @param owner - Owner address
* @returns
*/
getStakedTokenIds(owner: string): Promise<BigNumber[]> {
const contract = W3ABPass__factory.connect(
this.contractAddress,
this.provider,
);
return contract
.getStakeInfo(owner)
.then(([tokensStaked]: [BigNumber[], BigNumber]) => {
return tokensStaked; // Only return the first part of the tuple
});
}
}
2 changes: 2 additions & 0 deletions src/component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ import {SupremeKong2StakingContractAdapter} from './adapters/supreme-kong-2-stak
import {SupremeKongStakingContractAdapter} from './adapters/supreme-kong-staking.adapter.js';
import {TtooStakingContractAdapter} from './adapters/ttoo-staking.adapter.js';
import {UwULendStakingContractAdapter} from './adapters/uwulend-staking.adapter.js';
import {W3ABPassContractAdapter} from './adapters/W3ABPass.adapter.js';
import {WarriorsofankhStakingContractAdapter} from './adapters/warriorsofankh-staking.adapter.js';
import {XenoStakingContractAdapter} from './adapters/xeno-mining.adapter.js';
import {STAKING_CONTRACTS_COMPONENT} from './keys.js';
Expand Down Expand Up @@ -148,6 +149,7 @@ export class StakingContractsComponent implements Component {
RailgunPolygonGovernanceAdapter,
PlanetXStakingV1ContractAdapter,
RevenueCoinStakingContractAdapter,
W3ABPassContractAdapter,
];
constructor() {}
}
Loading