|
| 1 | +/** |
| 2 | + * @prettier |
| 3 | + */ |
| 4 | +import { EthLikeTokenConfig, coins } from '@bitgo/statics'; |
| 5 | +import { BitGoBase, CoinConstructor, NamedCoinConstructor, common, MPCAlgorithm } from '@bitgo/sdk-core'; |
| 6 | +import { CoinNames, EthLikeToken, recoveryBlockchainExplorerQuery } from '@bitgo/abstract-eth'; |
| 7 | + |
| 8 | +import { TransactionBuilder } from './lib'; |
| 9 | +export { EthLikeTokenConfig }; |
| 10 | + |
| 11 | +export class XdcToken extends EthLikeToken { |
| 12 | + public readonly tokenConfig: EthLikeTokenConfig; |
| 13 | + static coinNames: CoinNames = { |
| 14 | + Mainnet: 'xdc', |
| 15 | + Testnet: 'txdc', |
| 16 | + }; |
| 17 | + constructor(bitgo: BitGoBase, tokenConfig: EthLikeTokenConfig) { |
| 18 | + super(bitgo, tokenConfig, XdcToken.coinNames); |
| 19 | + } |
| 20 | + static createTokenConstructor(config: EthLikeTokenConfig): CoinConstructor { |
| 21 | + return super.createTokenConstructor(config, XdcToken.coinNames); |
| 22 | + } |
| 23 | + |
| 24 | + static createTokenConstructors(): NamedCoinConstructor[] { |
| 25 | + return super.createTokenConstructors(XdcToken.coinNames); |
| 26 | + } |
| 27 | + |
| 28 | + protected getTransactionBuilder(): TransactionBuilder { |
| 29 | + return new TransactionBuilder(coins.get(this.getBaseChain())); |
| 30 | + } |
| 31 | + |
| 32 | + /** |
| 33 | + * Make a query to XDC Etherscan for information such as balance, token balance, solidity calls |
| 34 | + * @param {Object} query key-value pairs of parameters to append after /api |
| 35 | + * @returns {Promise<Object>} response from XDC Etherscan |
| 36 | + */ |
| 37 | + async recoveryBlockchainExplorerQuery(query: Record<string, string>): Promise<Record<string, unknown>> { |
| 38 | + const apiToken = common.Environments[this.bitgo.getEnv()].xdcExplorerApiToken; |
| 39 | + const explorerUrl = common.Environments[this.bitgo.getEnv()].xdcExplorerBaseUrl; |
| 40 | + return await recoveryBlockchainExplorerQuery(query, explorerUrl as string, apiToken); |
| 41 | + } |
| 42 | + |
| 43 | + getFullName(): string { |
| 44 | + return 'XDC Token'; |
| 45 | + } |
| 46 | + |
| 47 | + supportsTss(): boolean { |
| 48 | + return true; |
| 49 | + } |
| 50 | + |
| 51 | + /** @inheritDoc */ |
| 52 | + getMPCAlgorithm(): MPCAlgorithm { |
| 53 | + return 'ecdsa'; |
| 54 | + } |
| 55 | +} |
0 commit comments