Skip to content

Commit 596a624

Browse files
committed
fix: add xdc token contructor
Ticket: COIN-7060
1 parent cc49225 commit 596a624

File tree

4 files changed

+44
-0
lines changed

4 files changed

+44
-0
lines changed

modules/sdk-coin-xdc/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
"@bitgo/abstract-eth": "^24.19.4",
4444
"@bitgo/sdk-core": "^36.25.0",
4545
"@bitgo/statics": "^58.19.0",
46+
"@bitgo/sdk-coin-evm": "^1.11.0",
4647
"@ethereumjs/common": "^2.6.5",
4748
"@ethereumjs/tx": "^3.3.0"
4849
},
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,15 @@
11
import { BitGoBase } from '@bitgo/sdk-core';
2+
import { EthLikeErc20Token } from '@bitgo/sdk-coin-evm';
23
import { Xdc } from './xdc';
34
import { Txdc } from './txdc';
45

56
export const register = (sdk: BitGoBase): void => {
67
sdk.register('xdc', Xdc.createInstance);
78
sdk.register('txdc', Txdc.createInstance);
9+
EthLikeErc20Token.createTokenConstructors({
10+
Mainnet: 'xdc',
11+
Testnet: 'txdc',
12+
}).forEach(({ name, coinConstructor }) => {
13+
sdk.register(name, coinConstructor);
14+
});
815
};
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import 'should';
2+
import { TestBitGo, TestBitGoAPI } from '@bitgo/sdk-test';
3+
import { BitGoAPI } from '@bitgo/sdk-api';
4+
5+
import { register } from '../../src';
6+
7+
describe('XDC Token:', function () {
8+
let bitgo: TestBitGoAPI;
9+
let xdcTokenCoin;
10+
const tokenName = 'xdc:usdc';
11+
12+
before(function () {
13+
bitgo = TestBitGo.decorate(BitGoAPI, { env: 'prod' });
14+
register(bitgo);
15+
bitgo.initializeTestVars();
16+
xdcTokenCoin = bitgo.coin(tokenName);
17+
});
18+
19+
it('should return constants', function () {
20+
xdcTokenCoin.getChain().should.equal('xdc:usdc');
21+
xdcTokenCoin.getBaseChain().should.equal('xdc');
22+
xdcTokenCoin.getFullName().should.equal('ERC20 Token');
23+
xdcTokenCoin.getBaseFactor().should.equal(1e6);
24+
xdcTokenCoin.type.should.equal(tokenName);
25+
xdcTokenCoin.name.should.equal('USD Coin');
26+
xdcTokenCoin.coin.should.equal('xdc');
27+
xdcTokenCoin.network.should.equal('Mainnet');
28+
xdcTokenCoin.decimalPlaces.should.equal(6);
29+
});
30+
});

modules/sdk-core/src/bitgo/environments.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -303,6 +303,9 @@ const mainnetBase: EnvironmentTemplate = {
303303
arc: {
304304
baseUrl: 'https://testnet.arcscan.app/api/v2', // WIN-8039 => add mainnet url when available
305305
},
306+
xdc: {
307+
baseUrl: 'https://api.etherscan.io/v2',
308+
},
306309
},
307310
icpNodeUrl: 'https://ic0.app',
308311
worldExplorerBaseUrl: 'https://worldscan.org/',
@@ -469,6 +472,9 @@ const testnetBase: EnvironmentTemplate = {
469472
arc: {
470473
baseUrl: 'https://testnet.arcscan.app/api/v2',
471474
},
475+
xdc: {
476+
baseUrl: 'https://api.etherscan.io/v2',
477+
},
472478
},
473479
stxNodeUrl: 'https://api.testnet.hiro.so',
474480
vetNodeUrl: 'https://sync-testnet.vechain.org',

0 commit comments

Comments
 (0)