diff --git a/modules/bitgo/test/v2/unit/coins/ofcToken.ts b/modules/bitgo/test/v2/unit/coins/ofcToken.ts index acd67b5c47..b1fa258424 100644 --- a/modules/bitgo/test/v2/unit/coins/ofcToken.ts +++ b/modules/bitgo/test/v2/unit/coins/ofcToken.ts @@ -284,6 +284,29 @@ describe('OFC:', function () { }); }); + describe('check ofc tokens for arbethErc20', function () { + const tokenMain = 'ofcarbeth:link'; + const tokenTest = 'ofctarbeth:link'; + 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('Chainlink Token'); + ofcCoin.getBaseFactor().should.equal(PRECISION_18); + ofcCoin.addressCoin.should.equal('arbeth'); + }); + }); + 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('Arbitrum Test LINK'); + ofcCoin.getBaseFactor().should.equal(PRECISION_18); + ofcCoin.addressCoin.should.equal('tarbeth'); + }); + }); + }); + it('can sign payloads', async function () { const inputParams = { txPrebuild: { diff --git a/modules/sdk-core/src/coins/ofcToken.ts b/modules/sdk-core/src/coins/ofcToken.ts index 84ffbb4406..df984af0df 100644 --- a/modules/sdk-core/src/coins/ofcToken.ts +++ b/modules/sdk-core/src/coins/ofcToken.ts @@ -24,9 +24,12 @@ const publicIdRegex = /^[a-f\d]{32}$/i; export class OfcToken extends Ofc { public readonly tokenConfig: OfcTokenConfig; + public readonly addressCoin?: string; + constructor(bitgo: BitGoBase, tokenConfig: OfcTokenConfig) { super(bitgo); this.tokenConfig = tokenConfig; + this.addressCoin = tokenConfig.addressCoin; } get coin() { diff --git a/modules/statics/src/coins.ts b/modules/statics/src/coins.ts index 25ba194458..0258179fb8 100644 --- a/modules/statics/src/coins.ts +++ b/modules/statics/src/coins.ts @@ -49,11 +49,13 @@ import { ofcerc20, ofcHederaToken, ofcStellarToken, + ofcArbethErc20, tofc, tofcAlgoToken, tofcerc20, tofcHederaToken, tofcStellarToken, + tofcArbethErc20, } from './ofc'; import { utxo, UtxoCoin } from './utxo'; @@ -10359,16 +10361,34 @@ export const coins = CoinMap.fromCoins([ 6, UnderlyingAsset.BUIDL ), - ofcerc20( + ofcArbethErc20( 'df2296e6-366e-4707-bab0-bf16ce592601', 'ofcarbeth:link', 'Chainlink Token', 18, UnderlyingAsset['arbeth:link'] ), - ofcerc20('59220e6e-d94b-40b7-8e10-2f7c691c2482', 'ofcarbeth:usdc', 'USD Coin', 6, UnderlyingAsset['arbeth:usdc']), - ofcerc20('4834e014-0282-4e27-ad9c-c4a4468ce732', 'ofcarbeth:usdt', 'Tether USD', 6, UnderlyingAsset['arbeth:usdt']), - ofcerc20('e91ce545-8ace-4f12-b6d4-8c5a3e84022f', 'ofcarbeth:arb', 'Arbitrum', 18, UnderlyingAsset['arbeth:arb']), + ofcArbethErc20( + '59220e6e-d94b-40b7-8e10-2f7c691c2482', + 'ofcarbeth:usdc', + 'USD Coin', + 6, + UnderlyingAsset['arbeth:usdc'] + ), + ofcArbethErc20( + '4834e014-0282-4e27-ad9c-c4a4468ce732', + 'ofcarbeth:usdt', + 'Tether USD', + 6, + UnderlyingAsset['arbeth:usdt'] + ), + ofcArbethErc20( + 'e91ce545-8ace-4f12-b6d4-8c5a3e84022f', + 'ofcarbeth:arb', + 'Arbitrum', + 18, + UnderlyingAsset['arbeth:arb'] + ), ofcerc20( 'baded9c2-d530-4188-b35d-2fd00cf6ee2e', 'ofcustb', @@ -11601,7 +11621,7 @@ export const coins = CoinMap.fromCoins([ undefined, 'gteth' ), - tofcerc20( + tofcArbethErc20( '2489c0e2-c13f-4287-bd1f-03dcd0a8562e', 'ofctarbeth:link', 'Arbitrum Test LINK', diff --git a/modules/statics/src/ofc.ts b/modules/statics/src/ofc.ts index 681a2107d3..1f36f1c223 100644 --- a/modules/statics/src/ofc.ts +++ b/modules/statics/src/ofc.ts @@ -554,3 +554,105 @@ export function tofcHederaToken( }) ); } + +/** + * Factory function for ofc arbethErc20 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 ofcArbethErc20( + id: string, + name: string, + fullName: string, + decimalPlaces: number, + asset: UnderlyingAsset, + kind: CoinKind = CoinKind.CRYPTO, + features: CoinFeature[] = OfcCoin.DEFAULT_FEATURES, + prefix = '', + suffix: string = name.toUpperCase(), + network: OfcNetwork = Networks.main.ofc, + isToken = true, + addressCoin = 'arbeth', + primaryKeyCurve: KeyCurve = KeyCurve.Secp256k1 +) { + return Object.freeze( + new OfcCoin({ + id, + name, + fullName, + network, + prefix, + suffix, + features, + decimalPlaces, + isToken, + asset, + kind, + addressCoin, + primaryKeyCurve, + baseUnit: BaseUnit.ETH, + }) + ); +} + +/** + * Factory function for testnet ofc arbethErc20 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 tofcArbethErc20( + id: string, + name: string, + fullName: string, + decimalPlaces: number, + asset: UnderlyingAsset, + kind: CoinKind = CoinKind.CRYPTO, + features: CoinFeature[] = OfcCoin.DEFAULT_FEATURES, + prefix = '', + suffix: string = name.toUpperCase(), + network: OfcNetwork = Networks.test.ofc, + isToken = true, + addressCoin = 'tarbeth', + primaryKeyCurve: KeyCurve = KeyCurve.Secp256k1 +) { + return Object.freeze( + new OfcCoin({ + id, + name, + fullName, + network, + prefix, + suffix, + features, + decimalPlaces, + isToken, + asset, + kind, + addressCoin, + primaryKeyCurve, + baseUnit: BaseUnit.ETH, + }) + ); +} diff --git a/modules/statics/src/tokenConfig.ts b/modules/statics/src/tokenConfig.ts index 19143cdb07..6069b23909 100644 --- a/modules/statics/src/tokenConfig.ts +++ b/modules/statics/src/tokenConfig.ts @@ -62,6 +62,7 @@ export type AlgoTokenConfig = BaseNetworkConfig & { export type OfcTokenConfig = BaseTokenConfig & { backingCoin: string; isFiat: boolean; + addressCoin?: string; }; export type HbarTokenConfig = BaseNetworkConfig; @@ -249,6 +250,7 @@ const formattedOfcCoins = coins.reduce((acc: OfcTokenConfig[], coin) => { name: coin.fullName, decimalPlaces: coin.decimalPlaces, isFiat: coin.kind === CoinKind.FIAT, + addressCoin: coin.addressCoin, }); } return acc;