Skip to content

Commit ef31d76

Browse files
authored
Merge pull request #8090 from BitGo/WIN-8887
feat(statics): add testnet tokens
2 parents 147ee61 + 102e529 commit ef31d76

6 files changed

Lines changed: 317 additions & 10 deletions

File tree

modules/statics/src/account.ts

Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import {
88
CANTON_TOKEN_FEATURES,
99
CELO_TOKEN_FEATURES,
1010
COSMOS_SIDECHAIN_FEATURES,
11+
TEMPO_FEATURES,
1112
} from './coinFeatures';
1213

1314
/**
@@ -188,6 +189,10 @@ export interface CantonTokenConstructorOptions extends AccountConstructorOptions
188189
contractAddress: string;
189190
}
190191

192+
export interface Tip20TokenConstructorOptions extends AccountConstructorOptions {
193+
contractAddress: string;
194+
}
195+
191196
export interface ContractAddress extends String {
192197
__contractaddress_phantom__: never;
193198
}
@@ -798,6 +803,20 @@ export class CantonToken extends AccountCoinToken {
798803
}
799804
}
800805

806+
/**
807+
* The Tempo network supports TIP20 tokens
808+
* TIP20 tokens are ERC20-compatible tokens on the Tempo network
809+
*/
810+
export class Tip20Token extends AccountCoinToken {
811+
public contractAddress: string;
812+
constructor(options: Tip20TokenConstructorOptions) {
813+
super({
814+
...options,
815+
});
816+
this.contractAddress = options.contractAddress;
817+
}
818+
}
819+
801820
/**
802821
* Factory function for account coin instances.
803822
*
@@ -4291,3 +4310,93 @@ export function tcantonToken(
42914310
primaryKeyCurve
42924311
);
42934312
}
4313+
4314+
/**
4315+
* Factory function for TIP20 token instances on Tempo network.
4316+
*
4317+
* @param id uuid v4
4318+
* @param name unique identifier of the token
4319+
* @param fullName Complete human-readable name of the token
4320+
* @param decimalPlaces Number of decimal places this token supports (divisibility exponent)
4321+
* @param contractAddress the contract address of the token
4322+
* @param asset Asset which this coin represents. This is the same for both mainnet and testnet variants of a coin.
4323+
* @param features Features of this coin. Defaults to the TEMPO_FEATURES
4324+
* @param prefix Optional token prefix. Defaults to empty string
4325+
* @param suffix Optional token suffix. Defaults to token name.
4326+
* @param network Optional token network. Defaults to the mainnet Tempo network.
4327+
* @param primaryKeyCurve The elliptic curve for this chain/token
4328+
*/
4329+
export function tip20Token(
4330+
id: string,
4331+
name: string,
4332+
fullName: string,
4333+
decimalPlaces: number,
4334+
contractAddress: string,
4335+
asset: UnderlyingAsset,
4336+
features: CoinFeature[] = TEMPO_FEATURES,
4337+
prefix = '',
4338+
suffix: string = name.toUpperCase(),
4339+
network: AccountNetwork = Networks.main.tempo,
4340+
primaryKeyCurve: KeyCurve = KeyCurve.Secp256k1
4341+
) {
4342+
return Object.freeze(
4343+
new Tip20Token({
4344+
id,
4345+
name,
4346+
fullName,
4347+
decimalPlaces,
4348+
network,
4349+
contractAddress,
4350+
asset,
4351+
features,
4352+
prefix,
4353+
suffix,
4354+
isToken: true,
4355+
primaryKeyCurve,
4356+
baseUnit: BaseUnit.ETH,
4357+
})
4358+
);
4359+
}
4360+
4361+
/**
4362+
* Factory function for testnet TIP20 token instances on Tempo network.
4363+
*
4364+
* @param id uuid v4
4365+
* @param name unique identifier of the token
4366+
* @param fullName Complete human-readable name of the token
4367+
* @param decimalPlaces Number of decimal places this token supports (divisibility exponent)
4368+
* @param contractAddress the contract address of the token
4369+
* @param asset Asset which this coin represents. This is the same for both mainnet and testnet variants of a coin.
4370+
* @param features Features of this coin. Defaults to the TEMPO_FEATURES
4371+
* @param prefix Optional token prefix. Defaults to empty string
4372+
* @param suffix Optional token suffix. Defaults to token name.
4373+
* @param network Optional token network. Defaults to the testnet Tempo network.
4374+
* @param primaryKeyCurve The elliptic curve for this chain/token
4375+
*/
4376+
export function ttip20Token(
4377+
id: string,
4378+
name: string,
4379+
fullName: string,
4380+
decimalPlaces: number,
4381+
contractAddress: string,
4382+
asset: UnderlyingAsset,
4383+
features: CoinFeature[] = TEMPO_FEATURES,
4384+
prefix = '',
4385+
suffix: string = name.toUpperCase(),
4386+
network: AccountNetwork = Networks.test.tempo,
4387+
primaryKeyCurve: KeyCurve = KeyCurve.Secp256k1
4388+
) {
4389+
return tip20Token(
4390+
id,
4391+
name,
4392+
fullName,
4393+
decimalPlaces,
4394+
contractAddress,
4395+
asset,
4396+
features,
4397+
prefix,
4398+
suffix,
4399+
network,
4400+
primaryKeyCurve
4401+
);
4402+
}

modules/statics/src/allCoinsAndTokens.ts

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ import {
4343
tstellarToken,
4444
tsuiToken,
4545
ttaoToken,
46+
ttip20Token,
4647
ttronToken,
4748
tvetNFTCollection,
4849
tworldErc20,
@@ -2738,6 +2739,43 @@ export const allCoinsAndTokens = [
27382739
BaseUnit.ETH,
27392740
TEMPO_FEATURES
27402741
),
2742+
// Tempo TIP20 testnet tokens
2743+
ttip20Token(
2744+
'e1872fd8-14ee-4dc9-bc5e-fd52552d9c60',
2745+
'ttempo:pathusd',
2746+
'Testnet pathUSD',
2747+
18,
2748+
'0x20c0000000000000000000000000000000000000',
2749+
UnderlyingAsset['ttempo:pathusd'],
2750+
TEMPO_FEATURES
2751+
),
2752+
ttip20Token(
2753+
'3c67eaa8-f073-4e1a-9d3a-c6756a31bef0',
2754+
'ttempo:alphausd',
2755+
'Testnet AlphaUSD',
2756+
18,
2757+
'0x20c0000000000000000000000000000000000001',
2758+
UnderlyingAsset['ttempo:alphausd'],
2759+
TEMPO_FEATURES
2760+
),
2761+
ttip20Token(
2762+
'da6d27bd-ed3b-4b59-b574-6e013e5eb55d',
2763+
'ttempo:betausd',
2764+
'Testnet BetaUSD',
2765+
18,
2766+
'0x20c0000000000000000000000000000000000002',
2767+
UnderlyingAsset['ttempo:betausd'],
2768+
TEMPO_FEATURES
2769+
),
2770+
ttip20Token(
2771+
'58cbb592-446e-4753-8c2a-c89f662135ba',
2772+
'ttempo:thetausd',
2773+
'Testnet ThetaUSD',
2774+
18,
2775+
'0x20c0000000000000000000000000000000000003',
2776+
UnderlyingAsset['ttempo:thetausd'],
2777+
TEMPO_FEATURES
2778+
),
27412779
canton(
27422780
'07385320-5a4f-48e9-97a5-86d4be9f24b0',
27432781
'canton',

modules/statics/src/base.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3578,6 +3578,12 @@ export enum UnderlyingAsset {
35783578
'canton:usdcx' = 'canton:usdcx',
35793579
'canton:cbtc' = 'canton:cbtc',
35803580

3581+
// Tempo testnet tokens
3582+
'ttempo:pathusd' = 'ttempo:pathusd',
3583+
'ttempo:alphausd' = 'ttempo:alphausd',
3584+
'ttempo:betausd' = 'ttempo:betausd',
3585+
'ttempo:thetausd' = 'ttempo:thetausd',
3586+
35813587
// fiats
35823588
AED = 'aed',
35833589
EUR = 'eur',

modules/statics/src/coins/ofcCoins.ts

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ import {
4040
tofcTonToken,
4141
ofcSuiToken,
4242
tofcSuiToken,
43+
tofcTempoToken,
4344
} from '../ofc';
4445
import { UnderlyingAsset, CoinKind, CoinFeature } from '../base';
4546

@@ -3992,4 +3993,33 @@ export const ofcCoins = [
39923993
),
39933994
// New SUI OFC token
39943995
ofcSuiToken('1e01eb3d-2573-4662-aa5e-4c390e4a9b38', 'ofcsui:dmc', 'DeLorean', 9, UnderlyingAsset['sui:dmc']),
3996+
// Tempo testnet OFC tokens
3997+
tofcTempoToken(
3998+
'7912e76e-5a5c-4f1b-86e9-1fc2a51f5a98',
3999+
'ofcttempo:pathusd',
4000+
'Testnet pathUSD',
4001+
18,
4002+
UnderlyingAsset['ttempo:pathusd']
4003+
),
4004+
tofcTempoToken(
4005+
'349f887a-e764-4640-9ba1-2e29e02d5d65',
4006+
'ofcttempo:alphausd',
4007+
'Testnet AlphaUSD',
4008+
18,
4009+
UnderlyingAsset['ttempo:alphausd']
4010+
),
4011+
tofcTempoToken(
4012+
'dc2b6c3d-b7a4-4940-bee3-32defbeff3bf',
4013+
'ofcttempo:betausd',
4014+
'Testnet BetaUSD',
4015+
18,
4016+
UnderlyingAsset['ttempo:betausd']
4017+
),
4018+
tofcTempoToken(
4019+
'490a65b6-e01f-4fae-9aa5-7528d1848075',
4020+
'ofcttempo:thetausd',
4021+
'Testnet ThetaUSD',
4022+
18,
4023+
UnderlyingAsset['ttempo:thetausd']
4024+
),
39954025
];

modules/statics/src/ofc.ts

Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2508,3 +2508,113 @@ export function tofcSuiToken(
25082508
})
25092509
);
25102510
}
2511+
2512+
/**
2513+
* Factory function for ofc tempo token instances.
2514+
*
2515+
* @param id uuid v4
2516+
* @param name unique identifier of the coin
2517+
* @param fullName Complete human-readable name of the coin
2518+
* @param network Network object for this coin
2519+
* @param decimalPlaces Number of decimal places this coin supports (divisibility exponent)
2520+
* @param asset Asset which this coin represents. This is the same for both mainnet and testnet variants of a coin.
2521+
* @param kind Differentiates coins which represent fiat assets from those which represent crypto assets
2522+
* @param prefix? Optional coin prefix. Defaults to empty string
2523+
* @param suffix? Optional coin suffix. Defaults to coin name.
2524+
* @param isToken? Whether or not this account coin is a token of another coin
2525+
* @param features? Features of this coin. Defaults to the DEFAULT_FEATURES defined in `OfcCoin`
2526+
* @param primaryKeyCurve The elliptic curve for this chain/token
2527+
*/
2528+
export function ofcTempoToken(
2529+
id: string,
2530+
name: string,
2531+
fullName: string,
2532+
decimalPlaces: number,
2533+
asset: UnderlyingAsset,
2534+
kind: CoinKind = CoinKind.CRYPTO,
2535+
features: CoinFeature[] = OfcCoin.DEFAULT_FEATURES,
2536+
prefix = '',
2537+
suffix: string = name.replace(/^ofc/, '').toUpperCase(),
2538+
network: OfcNetwork = Networks.main.ofc,
2539+
isToken = true,
2540+
addressCoin = 'tempo',
2541+
primaryKeyCurve: KeyCurve = KeyCurve.Secp256k1
2542+
) {
2543+
const filteredFeatures = getFilteredFeatures(suffix);
2544+
if (filteredFeatures.length > 0) {
2545+
features = filteredFeatures;
2546+
}
2547+
return Object.freeze(
2548+
new OfcCoin({
2549+
id,
2550+
name,
2551+
fullName,
2552+
network,
2553+
prefix,
2554+
suffix,
2555+
features,
2556+
decimalPlaces,
2557+
isToken,
2558+
asset,
2559+
kind,
2560+
addressCoin,
2561+
primaryKeyCurve,
2562+
baseUnit: BaseUnit.ETH,
2563+
})
2564+
);
2565+
}
2566+
2567+
/**
2568+
* Factory function for testnet ofc tempo token instances.
2569+
*
2570+
* @param id uuid v4
2571+
* @param name unique identifier of the coin
2572+
* @param fullName Complete human-readable name of the coin
2573+
* @param network Network object for this coin
2574+
* @param decimalPlaces Number of decimal places this coin supports (divisibility exponent)
2575+
* @param asset Asset which this coin represents. This is the same for both mainnet and testnet variants of a coin.
2576+
* @param kind Differentiates coins which represent fiat assets from those which represent crypto assets
2577+
* @param prefix? Optional coin prefix. Defaults to empty string
2578+
* @param suffix? Optional coin suffix. Defaults to coin name.
2579+
* @param isToken? Whether or not this account coin is a token of another coin
2580+
* @param features? Features of this coin. Defaults to the DEFAULT_FEATURES defined in `OfcCoin`
2581+
* @param primaryKeyCurve The elliptic curve for this chain/token
2582+
*/
2583+
export function tofcTempoToken(
2584+
id: string,
2585+
name: string,
2586+
fullName: string,
2587+
decimalPlaces: number,
2588+
asset: UnderlyingAsset,
2589+
kind: CoinKind = CoinKind.CRYPTO,
2590+
features: CoinFeature[] = OfcCoin.DEFAULT_FEATURES,
2591+
prefix = '',
2592+
suffix: string = name.replace(/^ofc/, '').toUpperCase(),
2593+
network: OfcNetwork = Networks.test.ofc,
2594+
isToken = true,
2595+
addressCoin = 'ttempo',
2596+
primaryKeyCurve: KeyCurve = KeyCurve.Secp256k1
2597+
) {
2598+
const filteredFeatures = getFilteredFeatures(suffix);
2599+
if (filteredFeatures.length > 0) {
2600+
features = filteredFeatures;
2601+
}
2602+
return Object.freeze(
2603+
new OfcCoin({
2604+
id,
2605+
name,
2606+
fullName,
2607+
network,
2608+
prefix,
2609+
suffix,
2610+
features,
2611+
decimalPlaces,
2612+
isToken,
2613+
asset,
2614+
kind,
2615+
addressCoin,
2616+
primaryKeyCurve,
2617+
baseUnit: BaseUnit.ETH,
2618+
})
2619+
);
2620+
}

0 commit comments

Comments
 (0)