Skip to content

Commit 09afd0c

Browse files
committed
feat(statics): add support for trx tokens
Ticket: GNA-199
1 parent 05244ac commit 09afd0c

File tree

4 files changed

+128
-0
lines changed

4 files changed

+128
-0
lines changed

commitlint.config.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ module.exports = {
3434
'EA-',
3535
'ERC20-',
3636
'FAC-',
37+
'GNA-',
3738
'GRC-',
3839
'HSM-',
3940
'INC-',

modules/bitgo/test/v2/unit/coins/ofcToken.ts

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -444,4 +444,25 @@ describe('OFC:', function () {
444444
});
445445
});
446446
});
447+
448+
describe('check ofc tokens for trx tokens', function () {
449+
const tokenMain = 'ofctrx:usdt';
450+
const tokenTest = 'ofcttrx:usdt';
451+
describe('for main network', function () {
452+
it(`should have the correct values for ${tokenMain}`, function () {
453+
const ofcCoin = bitgo.coin(tokenMain);
454+
ofcCoin.getChain().should.equal(tokenMain);
455+
ofcCoin.getFullName().should.equal('Tether USD');
456+
ofcCoin.getBaseFactor().should.equal(PRECISION_6);
457+
});
458+
});
459+
describe('for test network', function () {
460+
it(`should have the correct values for ${tokenTest}`, function () {
461+
const ofcCoin = bitgo.coin(tokenTest);
462+
ofcCoin.getChain().should.equal(tokenTest);
463+
ofcCoin.getFullName().should.equal('Tether USD');
464+
ofcCoin.getBaseFactor().should.equal(PRECISION_6);
465+
});
466+
});
467+
});
447468
});

modules/statics/src/coins.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ import {
6060
ofcPolygonErc20,
6161
ofcsolToken,
6262
ofcStellarToken,
63+
ofcTronToken,
6364
tofc,
6465
tofcAlgoToken,
6566
tofcArbethErc20,
@@ -69,6 +70,7 @@ import {
6970
tofcPolygonErc20,
7071
tofcsolToken,
7172
tofcStellarToken,
73+
tofcTronToken,
7274
tofcXrpToken,
7375
} from './ofc';
7476
import { utxoCoins } from './utxo';
@@ -1734,6 +1736,8 @@ export const coins = CoinMap.fromCoins([
17341736
UnderlyingAsset['sol:hnt'],
17351737
SOL_TOKEN_FEATURES
17361738
),
1739+
tofcTronToken('937efe97-a17a-4d2a-aaf2-0ffdb529a943', 'ofcttrx:usdt', 'Tether USD', 6, UnderlyingAsset.USDT),
1740+
ofcTronToken('94b00b66-68a4-45ed-b772-77e5bca1e34c', 'ofctrx:usdt', 'Tether USD', 6, UnderlyingAsset.USDT),
17371741
tofcXrpToken('bd406dab-3b55-4ab5-b0a5-74b9f94268a3', 'ofctxrp:rlusd', 'RLUSD', 96, UnderlyingAsset['txrp:rlusd']),
17381742
ofc('837f0cab-cad1-4510-a8e4-f2c60e1a8760', 'ofcusd', 'USD', 2, UnderlyingAsset.USD, CoinKind.FIAT),
17391743
ofc('798f2a7c-23fd-4e16-9fe5-6bf47ca438a0', 'ofceur', 'Euro', 2, UnderlyingAsset.EUR, CoinKind.FIAT),

modules/statics/src/ofc.ts

Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1119,3 +1119,105 @@ export function ofcOpethErc20(
11191119
})
11201120
);
11211121
}
1122+
1123+
/**
1124+
* Factory function for ofc tron token instances.
1125+
*
1126+
* @param id uuid v4
1127+
* @param name unique identifier of the coin
1128+
* @param fullName Complete human-readable name of the coin
1129+
* @param network Network object for this coin
1130+
* @param decimalPlaces Number of decimal places this coin supports (divisibility exponent)
1131+
* @param asset Asset which this coin represents. This is the same for both mainnet and testnet variants of a coin.
1132+
* @param kind Differentiates coins which represent fiat assets from those which represent crypto assets
1133+
* @param prefix? Optional coin prefix. Defaults to empty string
1134+
* @param suffix? Optional coin suffix. Defaults to coin name.
1135+
* @param isToken? Whether or not this account coin is a token of another coin
1136+
* @param features? Features of this coin. Defaults to the DEFAULT_FEATURES defined in `OfcCoin`
1137+
* @param primaryKeyCurve The elliptic curve for this chain/token
1138+
*/
1139+
export function ofcTronToken(
1140+
id: string,
1141+
name: string,
1142+
fullName: string,
1143+
decimalPlaces: number,
1144+
asset: UnderlyingAsset,
1145+
kind: CoinKind = CoinKind.CRYPTO,
1146+
features: CoinFeature[] = OfcCoin.DEFAULT_FEATURES,
1147+
prefix = '',
1148+
suffix: string = name.replace(/^ofc/, '').toUpperCase(),
1149+
network: OfcNetwork = Networks.main.ofc,
1150+
isToken = true,
1151+
addressCoin = 'trx',
1152+
primaryKeyCurve: KeyCurve = KeyCurve.Secp256k1
1153+
) {
1154+
return Object.freeze(
1155+
new OfcCoin({
1156+
id,
1157+
name,
1158+
fullName,
1159+
network,
1160+
prefix,
1161+
suffix,
1162+
features,
1163+
decimalPlaces,
1164+
isToken,
1165+
asset,
1166+
kind,
1167+
addressCoin,
1168+
primaryKeyCurve,
1169+
baseUnit: BaseUnit.TRX,
1170+
})
1171+
);
1172+
}
1173+
1174+
/**
1175+
* Factory function for ofc tron token instances.
1176+
*
1177+
* @param id uuid v4
1178+
* @param name unique identifier of the coin
1179+
* @param fullName Complete human-readable name of the coin
1180+
* @param network Network object for this coin
1181+
* @param decimalPlaces Number of decimal places this coin supports (divisibility exponent)
1182+
* @param asset Asset which this coin represents. This is the same for both mainnet and testnet variants of a coin.
1183+
* @param kind Differentiates coins which represent fiat assets from those which represent crypto assets
1184+
* @param prefix? Optional coin prefix. Defaults to empty string
1185+
* @param suffix? Optional coin suffix. Defaults to coin name.
1186+
* @param isToken? Whether or not this account coin is a token of another coin
1187+
* @param features? Features of this coin. Defaults to the DEFAULT_FEATURES defined in `OfcCoin`
1188+
* @param primaryKeyCurve The elliptic curve for this chain/token
1189+
*/
1190+
export function tofcTronToken(
1191+
id: string,
1192+
name: string,
1193+
fullName: string,
1194+
decimalPlaces: number,
1195+
asset: UnderlyingAsset,
1196+
kind: CoinKind = CoinKind.CRYPTO,
1197+
features: CoinFeature[] = OfcCoin.DEFAULT_FEATURES,
1198+
prefix = '',
1199+
suffix: string = name.replace(/^ofc/, '').toUpperCase(),
1200+
network: OfcNetwork = Networks.main.ofc,
1201+
isToken = true,
1202+
addressCoin = 'ttrx',
1203+
primaryKeyCurve: KeyCurve = KeyCurve.Secp256k1
1204+
) {
1205+
return Object.freeze(
1206+
new OfcCoin({
1207+
id,
1208+
name,
1209+
fullName,
1210+
network,
1211+
prefix,
1212+
suffix,
1213+
features,
1214+
decimalPlaces,
1215+
isToken,
1216+
asset,
1217+
kind,
1218+
addressCoin,
1219+
primaryKeyCurve,
1220+
baseUnit: BaseUnit.TRX,
1221+
})
1222+
);
1223+
}

0 commit comments

Comments
 (0)