diff --git a/commitlint.config.js b/commitlint.config.js index 00876fd8d1..b51e2bd243 100644 --- a/commitlint.config.js +++ b/commitlint.config.js @@ -34,6 +34,7 @@ module.exports = { 'EA-', 'ERC20-', 'FAC-', + 'GNA-', 'GRC-', 'HSM-', 'INC-', diff --git a/modules/bitgo/test/v2/unit/coins/ofcToken.ts b/modules/bitgo/test/v2/unit/coins/ofcToken.ts index 792c8b5636..bf3da45dde 100644 --- a/modules/bitgo/test/v2/unit/coins/ofcToken.ts +++ b/modules/bitgo/test/v2/unit/coins/ofcToken.ts @@ -444,4 +444,25 @@ describe('OFC:', function () { }); }); }); + + describe('check ofc tokens for trx tokens', function () { + const tokenMain = 'ofctrx:usdt'; + const tokenTest = 'ofcttrx:usdt'; + describe('for main network', function () { + it(`should have the correct values for ${tokenMain}`, function () { + const ofcCoin = bitgo.coin(tokenMain); + ofcCoin.getChain().should.equal(tokenMain); + ofcCoin.getFullName().should.equal('Tether USD'); + ofcCoin.getBaseFactor().should.equal(PRECISION_6); + }); + }); + describe('for test network', function () { + it(`should have the correct values for ${tokenTest}`, function () { + const ofcCoin = bitgo.coin(tokenTest); + ofcCoin.getChain().should.equal(tokenTest); + ofcCoin.getFullName().should.equal('Tether USD'); + ofcCoin.getBaseFactor().should.equal(PRECISION_6); + }); + }); + }); }); diff --git a/modules/statics/src/coins.ts b/modules/statics/src/coins.ts index 164f9f6581..e4b0ff7fab 100644 --- a/modules/statics/src/coins.ts +++ b/modules/statics/src/coins.ts @@ -60,6 +60,7 @@ import { ofcPolygonErc20, ofcsolToken, ofcStellarToken, + ofcTronToken, tofc, tofcAlgoToken, tofcArbethErc20, @@ -69,6 +70,7 @@ import { tofcPolygonErc20, tofcsolToken, tofcStellarToken, + tofcTronToken, tofcXrpToken, } from './ofc'; import { utxoCoins } from './utxo'; @@ -1734,6 +1736,8 @@ export const coins = CoinMap.fromCoins([ UnderlyingAsset['sol:hnt'], SOL_TOKEN_FEATURES ), + tofcTronToken('937efe97-a17a-4d2a-aaf2-0ffdb529a943', 'ofcttrx:usdt', 'Tether USD', 6, UnderlyingAsset.USDT), + ofcTronToken('94b00b66-68a4-45ed-b772-77e5bca1e34c', 'ofctrx:usdt', 'Tether USD', 6, UnderlyingAsset.USDT), tofcXrpToken('bd406dab-3b55-4ab5-b0a5-74b9f94268a3', 'ofctxrp:rlusd', 'RLUSD', 96, UnderlyingAsset['txrp:rlusd']), ofc('837f0cab-cad1-4510-a8e4-f2c60e1a8760', 'ofcusd', 'USD', 2, UnderlyingAsset.USD, CoinKind.FIAT), ofc('798f2a7c-23fd-4e16-9fe5-6bf47ca438a0', 'ofceur', 'Euro', 2, UnderlyingAsset.EUR, CoinKind.FIAT), diff --git a/modules/statics/src/ofc.ts b/modules/statics/src/ofc.ts index 22f1fdfaa8..1c0bd222f8 100644 --- a/modules/statics/src/ofc.ts +++ b/modules/statics/src/ofc.ts @@ -1119,3 +1119,105 @@ export function ofcOpethErc20( }) ); } + +/** + * Factory function for ofc tron token instances. + * + * @param id uuid v4 + * @param name unique identifier of the coin + * @param fullName Complete human-readable name of the coin + * @param network Network object for this coin + * @param decimalPlaces Number of decimal places this coin supports (divisibility exponent) + * @param asset Asset which this coin represents. This is the same for both mainnet and testnet variants of a coin. + * @param kind Differentiates coins which represent fiat assets from those which represent crypto assets + * @param prefix? Optional coin prefix. Defaults to empty string + * @param suffix? Optional coin suffix. Defaults to coin name. + * @param isToken? Whether or not this account coin is a token of another coin + * @param features? Features of this coin. Defaults to the DEFAULT_FEATURES defined in `OfcCoin` + * @param primaryKeyCurve The elliptic curve for this chain/token + */ +export function ofcTronToken( + id: string, + name: string, + fullName: string, + decimalPlaces: number, + asset: UnderlyingAsset, + kind: CoinKind = CoinKind.CRYPTO, + features: CoinFeature[] = OfcCoin.DEFAULT_FEATURES, + prefix = '', + suffix: string = name.replace(/^ofc/, '').toUpperCase(), + network: OfcNetwork = Networks.main.ofc, + isToken = true, + addressCoin = 'trx', + primaryKeyCurve: KeyCurve = KeyCurve.Secp256k1 +) { + return Object.freeze( + new OfcCoin({ + id, + name, + fullName, + network, + prefix, + suffix, + features, + decimalPlaces, + isToken, + asset, + kind, + addressCoin, + primaryKeyCurve, + baseUnit: BaseUnit.TRX, + }) + ); +} + +/** + * Factory function for ofc tron token instances. + * + * @param id uuid v4 + * @param name unique identifier of the coin + * @param fullName Complete human-readable name of the coin + * @param network Network object for this coin + * @param decimalPlaces Number of decimal places this coin supports (divisibility exponent) + * @param asset Asset which this coin represents. This is the same for both mainnet and testnet variants of a coin. + * @param kind Differentiates coins which represent fiat assets from those which represent crypto assets + * @param prefix? Optional coin prefix. Defaults to empty string + * @param suffix? Optional coin suffix. Defaults to coin name. + * @param isToken? Whether or not this account coin is a token of another coin + * @param features? Features of this coin. Defaults to the DEFAULT_FEATURES defined in `OfcCoin` + * @param primaryKeyCurve The elliptic curve for this chain/token + */ +export function tofcTronToken( + id: string, + name: string, + fullName: string, + decimalPlaces: number, + asset: UnderlyingAsset, + kind: CoinKind = CoinKind.CRYPTO, + features: CoinFeature[] = OfcCoin.DEFAULT_FEATURES, + prefix = '', + suffix: string = name.replace(/^ofc/, '').toUpperCase(), + network: OfcNetwork = Networks.test.ofc, + isToken = true, + addressCoin = 'ttrx', + primaryKeyCurve: KeyCurve = KeyCurve.Secp256k1 +) { + return Object.freeze( + new OfcCoin({ + id, + name, + fullName, + network, + prefix, + suffix, + features, + decimalPlaces, + isToken, + asset, + kind, + addressCoin, + primaryKeyCurve, + baseUnit: BaseUnit.TRX, + }) + ); +}