Skip to content

Commit 7189dcc

Browse files
Merge pull request #6863 from BitGo/COIN-5419-ylds
feat: add ofc tokens for hash
2 parents 700f01a + b16302f commit 7189dcc

File tree

3 files changed

+134
-0
lines changed

3 files changed

+134
-0
lines changed

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

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -474,4 +474,25 @@ describe('OFC:', function () {
474474
});
475475
});
476476
});
477+
478+
describe('check ofc tokens for hash tokens', function () {
479+
const tokenMain = 'ofchash:ylds';
480+
const tokenTest = 'ofcthash:ylds';
481+
describe('for main network', function () {
482+
it(`should have the correct values for ${tokenMain}`, function () {
483+
const ofcCoin = bitgo.coin(tokenMain);
484+
ofcCoin.getChain().should.equal(tokenMain);
485+
ofcCoin.getFullName().should.equal('YLDS Token');
486+
ofcCoin.getBaseFactor().should.equal(PRECISION_6);
487+
});
488+
});
489+
describe('for test network', function () {
490+
it(`should have the correct values for ${tokenTest}`, function () {
491+
const ofcCoin = bitgo.coin(tokenTest);
492+
ofcCoin.getChain().should.equal(tokenTest);
493+
ofcCoin.getFullName().should.equal('Testnet YLDS Token');
494+
ofcCoin.getBaseFactor().should.equal(PRECISION_6);
495+
});
496+
});
497+
});
477498
});

modules/statics/src/coins/ofcCoins.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ import {
3333
tofcCoredaoErc20,
3434
ofcVetToken,
3535
tofcVetToken,
36+
ofcHashToken,
37+
tofcHashToken,
3638
} from '../ofc';
3739
import { UnderlyingAsset, CoinKind } from '../base';
3840

@@ -3086,4 +3088,12 @@ export const ofcCoins = [
30863088
18,
30873089
UnderlyingAsset['tvet:vtho']
30883090
),
3091+
ofcHashToken('705402cb-b92f-4b32-8899-1f3f4dec1406', 'ofchash:ylds', 'YLDS Token', 6, UnderlyingAsset['hash:ylds']),
3092+
tofcHashToken(
3093+
'd2277bf2-0f95-4ede-9b38-aebac7ae9962',
3094+
'ofcthash:ylds',
3095+
'Testnet YLDS Token',
3096+
6,
3097+
UnderlyingAsset['thash:ylds']
3098+
),
30893099
];

modules/statics/src/ofc.ts

Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2183,3 +2183,106 @@ export function tofcVetToken(
21832183
})
21842184
);
21852185
}
2186+
2187+
/**
2188+
* Factory function for ofc hash token instances.
2189+
*
2190+
* @param id uuid v4
2191+
* @param name unique identifier of the coin
2192+
* @param fullName Complete human-readable name of the coin
2193+
* @param network Network object for this coin
2194+
* @param decimalPlaces Number of decimal places this coin supports (divisibility exponent)
2195+
* @param asset Asset which this coin represents. This is the same for both mainnet and testnet variants of a coin.
2196+
* @param kind Differentiates coins which represent fiat assets from those which represent crypto assets
2197+
* @param prefix? Optional coin prefix. Defaults to empty string
2198+
* @param suffix? Optional coin suffix. Defaults to coin name.
2199+
* @param isToken? Whether or not this account coin is a token of another coin
2200+
* @param features? Features of this coin. Defaults to the DEFAULT_FEATURES defined in `OfcCoin`
2201+
* @param primaryKeyCurve The elliptic curve for this chain/token
2202+
*/
2203+
export function ofcHashToken(
2204+
id: string,
2205+
name: string,
2206+
fullName: string,
2207+
decimalPlaces: number,
2208+
asset: UnderlyingAsset,
2209+
kind: CoinKind = CoinKind.CRYPTO,
2210+
features: CoinFeature[] = OfcCoin.DEFAULT_FEATURES,
2211+
prefix = '',
2212+
suffix: string = name.replace(/^ofc/, '').toUpperCase(),
2213+
network: OfcNetwork = Networks.main.ofc,
2214+
isToken = true,
2215+
addressCoin = 'hash',
2216+
primaryKeyCurve: KeyCurve = KeyCurve.Secp256k1
2217+
) {
2218+
const filteredFeatures = getFilteredFeatures(suffix);
2219+
if (filteredFeatures.length > 0) {
2220+
features = filteredFeatures;
2221+
}
2222+
return Object.freeze(
2223+
new OfcCoin({
2224+
id,
2225+
name,
2226+
fullName,
2227+
network,
2228+
prefix,
2229+
suffix,
2230+
features,
2231+
decimalPlaces,
2232+
isToken,
2233+
asset,
2234+
kind,
2235+
addressCoin,
2236+
primaryKeyCurve,
2237+
baseUnit: BaseUnit.HASH,
2238+
})
2239+
);
2240+
}
2241+
2242+
/**
2243+
* Factory function for testnet ofc hash token instances.
2244+
*
2245+
* @param id uuid v4
2246+
* @param name unique identifier of the coin
2247+
* @param fullName Complete human-readable name of the coin
2248+
* @param network Network object for this coin
2249+
* @param decimalPlaces Number of decimal places this coin supports (divisibility exponent)
2250+
* @param asset Asset which this coin represents. This is the same for both mainnet and testnet variants of a coin.
2251+
* @param kind Differentiates coins which represent fiat assets from those which represent crypto assets
2252+
* @param prefix? Optional coin prefix. Defaults to empty string
2253+
* @param suffix? Optional coin suffix. Defaults to coin name.
2254+
* @param isToken? Whether or not this account coin is a token of another coin
2255+
* @param features? Features of this coin. Defaults to the DEFAULT_FEATURES defined in `OfcCoin`
2256+
* @param primaryKeyCurve The elliptic curve for this chain/token
2257+
*/
2258+
export function tofcHashToken(
2259+
id: string,
2260+
name: string,
2261+
fullName: string,
2262+
decimalPlaces: number,
2263+
asset: UnderlyingAsset,
2264+
kind: CoinKind = CoinKind.CRYPTO,
2265+
features: CoinFeature[] = OfcCoin.DEFAULT_FEATURES,
2266+
prefix = '',
2267+
suffix: string = name.replace(/^ofc/, '').toUpperCase(),
2268+
network: OfcNetwork = Networks.test.ofc,
2269+
isToken = true,
2270+
addressCoin = 'thash',
2271+
primaryKeyCurve: KeyCurve = KeyCurve.Secp256k1
2272+
) {
2273+
return ofcHashToken(
2274+
id,
2275+
name,
2276+
fullName,
2277+
decimalPlaces,
2278+
asset,
2279+
kind,
2280+
features,
2281+
prefix,
2282+
suffix,
2283+
network,
2284+
isToken,
2285+
addressCoin,
2286+
primaryKeyCurve
2287+
);
2288+
}

0 commit comments

Comments
 (0)