Skip to content

Commit dbb9215

Browse files
rohitsaw115ArunBala-Bitgo
authored andcommitted
Merge pull request #7846 from BitGo/win-8531
fix: update decimal and explorer url for hbarevm
2 parents 9869a7f + 1228951 commit dbb9215

4 files changed

Lines changed: 100 additions & 9 deletions

File tree

modules/sdk-coin-xdc/test/unit/xdcToken.ts

Lines changed: 91 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import 'should';
22
import { TestBitGo, TestBitGoAPI } from '@bitgo/sdk-test';
33
import { BitGoAPI } from '@bitgo/sdk-api';
44

5-
import { register } from '../../src';
5+
import { register, XdcToken } from '../../src';
66

77
describe('XDC Token:', function () {
88
let bitgo: TestBitGoAPI;
@@ -27,4 +27,94 @@ describe('XDC Token:', function () {
2727
xdcTokenCoin.network.should.equal('Mainnet');
2828
xdcTokenCoin.decimalPlaces.should.equal(6);
2929
});
30+
31+
describe('Token Registration and TransactionBuilder', function () {
32+
const mainnetTokens = ['xdc:usdc', 'xdc:lbt', 'xdc:gama', 'xdc:srx', 'xdc:weth'];
33+
const testnetTokens = ['txdc:tmt'];
34+
35+
describe('Mainnet tokens', function () {
36+
mainnetTokens.forEach((tokenName) => {
37+
it(`${tokenName} should be registered as XdcToken`, function () {
38+
const token = bitgo.coin(tokenName);
39+
token.should.be.instanceOf(XdcToken);
40+
});
41+
42+
it(`${tokenName} should create TransactionBuilder without error`, function () {
43+
const token = bitgo.coin(tokenName) as XdcToken;
44+
// @ts-expect-error - accessing protected method for testing
45+
(() => token.getTransactionBuilder()).should.not.throw();
46+
});
47+
48+
it(`${tokenName} should use XDC-specific TransactionBuilder`, function () {
49+
const token = bitgo.coin(tokenName) as XdcToken;
50+
// @ts-expect-error - accessing protected method for testing
51+
const builder = token.getTransactionBuilder();
52+
builder.should.have.property('_common');
53+
// Verify it's using XDC's getCommon, not EVM's
54+
// XDC's TransactionBuilder should create successfully without SHARED_EVM_SDK feature
55+
builder.constructor.name.should.equal('TransactionBuilder');
56+
});
57+
});
58+
});
59+
60+
describe('Testnet tokens', function () {
61+
testnetTokens.forEach((tokenName) => {
62+
it(`${tokenName} should be registered as XdcToken`, function () {
63+
const token = bitgo.coin(tokenName);
64+
token.should.be.instanceOf(XdcToken);
65+
});
66+
67+
it(`${tokenName} should create TransactionBuilder without error`, function () {
68+
const token = bitgo.coin(tokenName) as XdcToken;
69+
// @ts-expect-error - accessing protected method for testing
70+
(() => token.getTransactionBuilder()).should.not.throw();
71+
});
72+
73+
it(`${tokenName} should use XDC-specific TransactionBuilder`, function () {
74+
const token = bitgo.coin(tokenName) as XdcToken;
75+
// @ts-expect-error - accessing protected method for testing
76+
const builder = token.getTransactionBuilder();
77+
builder.should.have.property('_common');
78+
builder.constructor.name.should.equal('TransactionBuilder');
79+
});
80+
81+
it(`${tokenName} should have correct base chain`, function () {
82+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
83+
const token: any = bitgo.coin(tokenName);
84+
token.getBaseChain().should.equal('txdc');
85+
});
86+
87+
it(`${tokenName} should not throw "Cannot use common sdk module" error`, function () {
88+
const token = bitgo.coin(tokenName) as XdcToken;
89+
let errorThrown = false;
90+
let errorMessage = '';
91+
92+
try {
93+
// @ts-expect-error - accessing protected method for testing
94+
const builder = token.getTransactionBuilder();
95+
// Try to use the builder to ensure it's fully functional
96+
// @ts-expect-error - type expects TransactionType enum
97+
builder.type('Send');
98+
} catch (e) {
99+
errorThrown = true;
100+
errorMessage = (e as Error).message;
101+
}
102+
103+
errorThrown.should.equal(false);
104+
errorMessage.should.not.match(/Cannot use common sdk module/);
105+
});
106+
});
107+
});
108+
109+
it('should verify all XDC tokens use XdcToken class, not EthLikeErc20Token', function () {
110+
const allTokens = [...mainnetTokens, ...testnetTokens];
111+
112+
allTokens.forEach((tokenName) => {
113+
const token = bitgo.coin(tokenName);
114+
token.should.be.instanceOf(XdcToken);
115+
token.constructor.name.should.equal('XdcToken');
116+
token.constructor.name.should.not.equal('EthLikeErc20Token');
117+
});
118+
});
119+
});
30120
});

modules/statics/src/account.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2888,7 +2888,7 @@ export function xdcErc20(
28882888
decimalPlaces: number,
28892889
contractAddress: string,
28902890
asset: UnderlyingAsset,
2891-
features: CoinFeature[] = [...AccountCoin.DEFAULT_FEATURES, CoinFeature.EIP1559],
2891+
features: CoinFeature[] = AccountCoin.DEFAULT_FEATURES,
28922892
prefix = '',
28932893
suffix: string = name.toUpperCase(),
28942894
network: AccountNetwork = Networks.main.xdc,

modules/statics/src/allCoinsAndTokens.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2189,7 +2189,7 @@ export const allCoinsAndTokens = [
21892189
'hbarevm',
21902190
'Hedera EVM',
21912191
Networks.main.hederaEVM,
2192-
8,
2192+
18,
21932193
UnderlyingAsset.HBAREVM,
21942194
BaseUnit.HBAR,
21952195
[
@@ -2210,7 +2210,7 @@ export const allCoinsAndTokens = [
22102210
'thbarevm',
22112211
'Testnet Hedera EVM',
22122212
Networks.test.hederaEVM,
2213-
8,
2213+
18,
22142214
UnderlyingAsset.HBAREVM,
22152215
BaseUnit.HBAR,
22162216
[
@@ -2988,7 +2988,8 @@ export const allCoinsAndTokens = [
29882988
'USD Coin',
29892989
6,
29902990
'0xfa2958cb79b0491cc627c1557f441ef849ca8eb1',
2991-
UnderlyingAsset['xdc:usdc']
2991+
UnderlyingAsset['xdc:usdc'],
2992+
[...AccountCoin.DEFAULT_FEATURES, CoinFeature.STABLECOIN]
29922993
),
29932994
xdcErc20(
29942995
'8914a1bd-1495-46df-84da-445c6d49edb2',

modules/statics/src/networks.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2166,17 +2166,17 @@ class Plume extends Mainnet implements EthereumNetwork {
21662166
class HederaEVMTestnet extends Testnet implements EthereumNetwork {
21672167
name = 'Testnet Hedera EVM';
21682168
family = CoinFamily.HBAREVM;
2169-
explorerUrl = 'https://hashscan.io/mainnet/transaction/';
2170-
accountExplorerUrl = 'https://hashscan.io/mainnet/account/';
2169+
explorerUrl = 'https://hashscan.io/testnet/transaction/';
2170+
accountExplorerUrl = 'https://hashscan.io/testnet/account/';
21712171
chainId = 296;
21722172
nativeCoinOperationHashPrefix = '296';
21732173
}
21742174

21752175
class HederaEVM extends Mainnet implements EthereumNetwork {
21762176
name = 'Hedera EVM';
21772177
family = CoinFamily.HBAREVM;
2178-
explorerUrl = 'https://hashscan.io/testnet/transaction/';
2179-
accountExplorerUrl = 'https://hashscan.io/testnet/account/';
2178+
explorerUrl = 'https://hashscan.io/mainnet/transaction/';
2179+
accountExplorerUrl = 'https://hashscan.io/mainnet/account/';
21802180
chainId = 295;
21812181
nativeCoinOperationHashPrefix = '295';
21822182
}

0 commit comments

Comments
 (0)