Skip to content

Commit 12bbfb3

Browse files
authored
Merge pull request #6441 from BitGo/fix-decimalPlaces
chore: fix decimalPlaces value and add test cases
2 parents 66754f5 + 43aab2f commit 12bbfb3

File tree

2 files changed

+36
-2
lines changed

2 files changed

+36
-2
lines changed

modules/statics/src/coins/ofcCoins.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -912,7 +912,7 @@ export const ofcCoins = [
912912
'6fd31137-ab29-441e-9136-8b4bad4f0477',
913913
'ofctsol:usdc',
914914
'testnet USD Coin',
915-
6,
915+
9,
916916
UnderlyingAsset['tsol:usdc'],
917917
SOL_TOKEN_FEATURES
918918
),
@@ -979,7 +979,7 @@ export const ofcCoins = [
979979
ofcTronToken('d953a72b-b7b9-4c8d-97bd-f03394e30608', 'ofctrx:trxs', 'Staked TRX', 18, UnderlyingAsset['trx:trxs']),
980980
ofcXrpToken('6a173023-5faf-4a0a-af38-b8be98abe94f', 'ofcxrp:rlusd', 'Ripple USD', 15, UnderlyingAsset['xrp:rlusd']),
981981
tofcXrpToken('bd406dab-3b55-4ab5-b0a5-74b9f94268a3', 'ofctxrp:rlusd', 'RLUSD', 15, UnderlyingAsset['txrp:rlusd']),
982-
ofcXrpToken('eb3c02de-7221-4fde-9235-5cc576eb7c8b', 'ofcxrp:xsgd', 'XSGD', 6, UnderlyingAsset['xrp:xsgd']),
982+
ofcXrpToken('eb3c02de-7221-4fde-9235-5cc576eb7c8b', 'ofcxrp:xsgd', 'XSGD', 15, UnderlyingAsset['xrp:xsgd']),
983983
ofcXrpToken(
984984
'46c75216-5498-4417-b73c-a08c11d693ad',
985985
'ofcxrp:tbill',

modules/statics/test/unit/ofcCoinParity.ts

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,11 @@ const EXCLUDED_ASSETS = new Set<string>([
1313
'tgbp', // confusion with the fiat version
1414
]);
1515

16+
const EXCLUDED_ASSETS_FOR_DECIMAL_CHECK = new Set<string>([
17+
'ofctusd', // Not sure why decimalPlaces is set to 2 instead of 18.
18+
'ofctgbp', // Not sure why decimalPlaces is set to 2 instead of 18.
19+
]);
20+
1621
describe('OFC Coin parity tests', function () {
1722
it('should have parity with OFC for ERC20 tokens', function () {
1823
const ofcCoinsWithInvalidAssets = ofcErc20Coins
@@ -50,4 +55,33 @@ describe('OFC Coin parity tests', function () {
5055
// should(addedOfcErc20s.length).equal(0, 'Missing OFC ERC20s');
5156
}
5257
});
58+
59+
it('validate the decimalPlaces for ofc token', function () {
60+
const ofcCoins = coins.filter((coin) => coin.family === 'ofc');
61+
ofcCoins.forEach((ofcCoin) => {
62+
const baseTokenName = ofcCoin.name.replace(/^ofc/, '');
63+
const baseCoin = getCoin(baseTokenName);
64+
if (
65+
baseCoin &&
66+
!EXCLUDED_ASSETS_FOR_DECIMAL_CHECK.has(ofcCoin.name) &&
67+
baseCoin.decimalPlaces !== ofcCoin.decimalPlaces
68+
) {
69+
baseCoin.decimalPlaces.should.equal(ofcCoin.decimalPlaces);
70+
}
71+
});
72+
});
73+
74+
function getCoin(coinName: string) {
75+
try {
76+
{
77+
const coin = coins.get(coinName);
78+
if (!coin) {
79+
return undefined;
80+
}
81+
return coin;
82+
}
83+
} catch (e) {
84+
return undefined;
85+
}
86+
}
5387
});

0 commit comments

Comments
 (0)