Skip to content

Commit e736792

Browse files
committed
feat: ofc tokens for ton
Ticket: [COIN-6043]
1 parent 9919b93 commit e736792

File tree

1 file changed

+110
-0
lines changed

1 file changed

+110
-0
lines changed

modules/statics/src/ofc.ts

Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2286,3 +2286,113 @@ export function tofcHashToken(
22862286
primaryKeyCurve
22872287
);
22882288
}
2289+
2290+
/**
2291+
* Factory function for ofc ton token instances.
2292+
*
2293+
* @param id uuid v4
2294+
* @param name unique identifier of the coin
2295+
* @param fullName Complete human-readable name of the coin
2296+
* @param network Network object for this coin
2297+
* @param decimalPlaces Number of decimal places this coin supports (divisibility exponent)
2298+
* @param asset Asset which this coin represents. This is the same for both mainnet and testnet variants of a coin.
2299+
* @param kind Differentiates coins which represent fiat assets from those which represent crypto assets
2300+
* @param prefix? Optional coin prefix. Defaults to empty string
2301+
* @param suffix? Optional coin suffix. Defaults to coin name.
2302+
* @param isToken? Whether or not this account coin is a token of another coin
2303+
* @param features? Features of this coin. Defaults to the DEFAULT_FEATURES defined in `OfcCoin`
2304+
* @param primaryKeyCurve The elliptic curve for this chain/token
2305+
*/
2306+
export function ofcTonToken(
2307+
id: string,
2308+
name: string,
2309+
fullName: string,
2310+
decimalPlaces: number,
2311+
asset: UnderlyingAsset,
2312+
kind: CoinKind = CoinKind.CRYPTO,
2313+
features: CoinFeature[] = OfcCoin.DEFAULT_FEATURES,
2314+
prefix = '',
2315+
suffix: string = name.replace(/^ofc/, '').toUpperCase(),
2316+
network: OfcNetwork = Networks.main.ofc,
2317+
isToken = true,
2318+
addressCoin = 'ton',
2319+
primaryKeyCurve: KeyCurve = KeyCurve.Secp256k1
2320+
) {
2321+
const filteredFeatures = getFilteredFeatures(suffix);
2322+
if (filteredFeatures.length > 0) {
2323+
features = filteredFeatures;
2324+
}
2325+
return Object.freeze(
2326+
new OfcCoin({
2327+
id,
2328+
name,
2329+
fullName,
2330+
network,
2331+
prefix,
2332+
suffix,
2333+
features,
2334+
decimalPlaces,
2335+
isToken,
2336+
asset,
2337+
kind,
2338+
addressCoin,
2339+
primaryKeyCurve,
2340+
baseUnit: BaseUnit.TON,
2341+
})
2342+
);
2343+
}
2344+
2345+
/**
2346+
* Factory function for testnet ofc ton token instances.
2347+
*
2348+
* @param id uuid v4
2349+
* @param name unique identifier of the coin
2350+
* @param fullName Complete human-readable name of the coin
2351+
* @param network Network object for this coin
2352+
* @param decimalPlaces Number of decimal places this coin supports (divisibility exponent)
2353+
* @param asset Asset which this coin represents. This is the same for both mainnet and testnet variants of a coin.
2354+
* @param kind Differentiates coins which represent fiat assets from those which represent crypto assets
2355+
* @param prefix? Optional coin prefix. Defaults to empty string
2356+
* @param suffix? Optional coin suffix. Defaults to coin name.
2357+
* @param isToken? Whether or not this account coin is a token of another coin
2358+
* @param features? Features of this coin. Defaults to the DEFAULT_FEATURES defined in `OfcCoin`
2359+
* @param primaryKeyCurve The elliptic curve for this chain/token
2360+
*/
2361+
export function tofcTonToken(
2362+
id: string,
2363+
name: string,
2364+
fullName: string,
2365+
decimalPlaces: number,
2366+
asset: UnderlyingAsset,
2367+
kind: CoinKind = CoinKind.CRYPTO,
2368+
features: CoinFeature[] = OfcCoin.DEFAULT_FEATURES,
2369+
prefix = '',
2370+
suffix: string = name.replace(/^ofc/, '').toUpperCase(),
2371+
network: OfcNetwork = Networks.test.ofc,
2372+
isToken = true,
2373+
addressCoin = 'tton',
2374+
primaryKeyCurve: KeyCurve = KeyCurve.Secp256k1
2375+
) {
2376+
const filteredFeatures = getFilteredFeatures(suffix);
2377+
if (filteredFeatures.length > 0) {
2378+
features = filteredFeatures;
2379+
}
2380+
return Object.freeze(
2381+
new OfcCoin({
2382+
id,
2383+
name,
2384+
fullName,
2385+
network,
2386+
prefix,
2387+
suffix,
2388+
features,
2389+
decimalPlaces,
2390+
isToken,
2391+
asset,
2392+
kind,
2393+
addressCoin,
2394+
primaryKeyCurve,
2395+
baseUnit: BaseUnit.TON,
2396+
})
2397+
);
2398+
}

0 commit comments

Comments
 (0)