Skip to content

Commit

Permalink
Merge pull request #4434 from BitGo/PX-3568-onboard-arb-go-account
Browse files Browse the repository at this point in the history
feat(statics): add ofc token to represent Erc20 token on Arbitrum chain
  • Loading branch information
subavicky committed Apr 15, 2024
2 parents 094942c + c5356b9 commit 85f8578
Show file tree
Hide file tree
Showing 3 changed files with 148 additions and 5 deletions.
21 changes: 21 additions & 0 deletions modules/bitgo/test/v2/unit/coins/ofcToken.ts
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,27 @@ 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);
});
});
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);
});
});
});

it('can sign payloads', async function () {
const inputParams = {
txPrebuild: {
Expand Down
30 changes: 25 additions & 5 deletions modules/statics/src/coins.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,13 @@ import {
ofcerc20,
ofcHederaToken,
ofcStellarToken,
ofcArbethErc20,
tofc,
tofcAlgoToken,
tofcerc20,
tofcHederaToken,
tofcStellarToken,
tofcArbethErc20,
} from './ofc';
import { utxo, UtxoCoin } from './utxo/utxo';

Expand Down Expand Up @@ -10375,16 +10377,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',
Expand Down Expand Up @@ -11618,7 +11638,7 @@ export const coins = CoinMap.fromCoins([
undefined,
'gteth'
),
tofcerc20(
tofcArbethErc20(
'2489c0e2-c13f-4287-bd1f-03dcd0a8562e',
'ofctarbeth:link',
'Arbitrum Test LINK',
Expand Down
102 changes: 102 additions & 0 deletions modules/statics/src/ofc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
})
);
}

0 comments on commit 85f8578

Please sign in to comment.