Skip to content

Commit

Permalink
Merge pull request #5276 from BitGo/GNA-10
Browse files Browse the repository at this point in the history
feat: add ofcxrp mainnet support and update ofcsol tokens
  • Loading branch information
avalon22022002 authored Dec 16, 2024
2 parents 87a80dc + 5eef4a9 commit 489aa32
Show file tree
Hide file tree
Showing 4 changed files with 70 additions and 4 deletions.
9 changes: 9 additions & 0 deletions modules/bitgo/test/v2/unit/coins/ofcToken.ts
Original file line number Diff line number Diff line change
Expand Up @@ -422,7 +422,16 @@ describe('OFC:', function () {
});

describe('check ofc tokens for ripple', function () {
const tokenMain = 'ofcxrp:rlusd';
const tokenTest = 'ofctxrp:rlusd';
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('Ripple USD');
ofcCoin.getBaseFactor().should.equal(PRECISION_96);
});
});
describe('for test network', function () {
it(`should have the correct values for ${tokenTest}`, function () {
const ofcCoin = bitgo.coin(tokenTest);
Expand Down
4 changes: 4 additions & 0 deletions modules/statics/src/base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2307,10 +2307,14 @@ export enum UnderlyingAsset {
'sol:bonk' = 'sol:bonk',
'jto' = 'jto',
'jup' = 'jup',
'sol:jup' = 'sol:jup',
'sol:honey' = 'sol:honey',
'mobile' = 'mobile',
'sol:mobile' = 'sol:mobile',
'wif' = 'wif',
'sol:wif' = 'sol:wif',
'natix' = 'natix',
'sol:natix' = 'sol:natix',
'sol:ks' = 'sol:ks',
'sol:apusdt' = 'sol:apusdt',
'sol:acusd' = 'sol:acusd',
Expand Down
10 changes: 6 additions & 4 deletions modules/statics/src/coins.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ import {
ofcsolToken,
ofcStellarToken,
ofcTronToken,
ofcXrpToken,
tofc,
tofcAlgoToken,
tofcArbethErc20,
Expand Down Expand Up @@ -1638,23 +1639,23 @@ export const coins = CoinMap.fromCoins([
'ofcsol:natix',
'NATIX Network ',
6,
UnderlyingAsset['natix'],
UnderlyingAsset['sol:natix'],
SOL_TOKEN_FEATURES
),
ofcsolToken(
'abbdcf44-ac44-46be-b4e9-8a760d44b79a',
'ofcsol:mobile',
'Helium Mobile',
6,
UnderlyingAsset['mobile'],
UnderlyingAsset['sol:mobile'],
SOL_TOKEN_FEATURES
),
ofcsolToken(
'94e55bde-f57f-4817-9984-b461a5d6bcd0',
'ofcsol:jup',
'Jupiter',
6,
UnderlyingAsset['jup'],
UnderlyingAsset['sol:jup'],
SOL_TOKEN_FEATURES
),
ofcsolToken(
Expand All @@ -1670,7 +1671,7 @@ export const coins = CoinMap.fromCoins([
'ofcsol:wif',
'dogwifhat',
6,
UnderlyingAsset['wif'],
UnderlyingAsset['sol:wif'],
SOL_TOKEN_FEATURES
),
ofcsolToken(
Expand Down Expand Up @@ -1756,6 +1757,7 @@ export const coins = CoinMap.fromCoins([
),
tofcTronToken('937efe97-a17a-4d2a-aaf2-0ffdb529a943', 'ofcttrx:usdt', 'Tether USD', 6, UnderlyingAsset['ttrx:usdt']),
ofcTronToken('94b00b66-68a4-45ed-b772-77e5bca1e34c', 'ofctrx:usdt', 'Tether USD', 6, UnderlyingAsset['trx:usdt']),
ofcXrpToken('6a173023-5faf-4a0a-af38-b8be98abe94f', 'ofcxrp:rlusd', 'Ripple USD', 96, UnderlyingAsset['xrp:rlusd']),
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),
Expand Down
51 changes: 51 additions & 0 deletions modules/statics/src/ofc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1018,6 +1018,57 @@ export function ofcBscToken(
);
}

/**
* Factory function for mainnet ofc xrp 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 ofcXrpToken(
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 = 'xrp',
primaryKeyCurve: KeyCurve = KeyCurve.Secp256k1
) {
return Object.freeze(
new OfcCoin({
id,
name,
fullName,
network,
prefix,
suffix,
features,
decimalPlaces,
isToken,
asset,
kind,
addressCoin,
primaryKeyCurve,
baseUnit: BaseUnit.XRP,
})
);
}

/**
* Factory function for testnet ofc xrp token instances.
*
Expand Down

0 comments on commit 489aa32

Please sign in to comment.