Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
109 changes: 109 additions & 0 deletions modules/statics/src/account.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {
CANTON_TOKEN_FEATURES,
CELO_TOKEN_FEATURES,
COSMOS_SIDECHAIN_FEATURES,
TEMPO_FEATURES,
} from './coinFeatures';

/**
Expand Down Expand Up @@ -188,6 +189,10 @@ export interface CantonTokenConstructorOptions extends AccountConstructorOptions
contractAddress: string;
}

export interface Tip20TokenConstructorOptions extends AccountConstructorOptions {
contractAddress: string;
}

export interface ContractAddress extends String {
__contractaddress_phantom__: never;
}
Expand Down Expand Up @@ -798,6 +803,20 @@ export class CantonToken extends AccountCoinToken {
}
}

/**
* The Tempo network supports TIP20 tokens
* TIP20 tokens are ERC20-compatible tokens on the Tempo network
*/
export class Tip20Token extends AccountCoinToken {
public contractAddress: string;
constructor(options: Tip20TokenConstructorOptions) {
super({
...options,
});
this.contractAddress = options.contractAddress;
}
}

/**
* Factory function for account coin instances.
*
Expand Down Expand Up @@ -4291,3 +4310,93 @@ export function tcantonToken(
primaryKeyCurve
);
}

/**
* Factory function for TIP20 token instances on Tempo network.
*
* @param id uuid v4
* @param name unique identifier of the token
* @param fullName Complete human-readable name of the token
* @param decimalPlaces Number of decimal places this token supports (divisibility exponent)
* @param contractAddress the contract address of the token
* @param asset Asset which this coin represents. This is the same for both mainnet and testnet variants of a coin.
* @param features Features of this coin. Defaults to the TEMPO_FEATURES
* @param prefix Optional token prefix. Defaults to empty string
* @param suffix Optional token suffix. Defaults to token name.
* @param network Optional token network. Defaults to the mainnet Tempo network.
* @param primaryKeyCurve The elliptic curve for this chain/token
*/
export function tip20Token(
id: string,
name: string,
fullName: string,
decimalPlaces: number,
contractAddress: string,
asset: UnderlyingAsset,
features: CoinFeature[] = TEMPO_FEATURES,
prefix = '',
suffix: string = name.toUpperCase(),
network: AccountNetwork = Networks.main.tempo,
primaryKeyCurve: KeyCurve = KeyCurve.Secp256k1
) {
return Object.freeze(
new Tip20Token({
id,
name,
fullName,
decimalPlaces,
network,
contractAddress,
asset,
features,
prefix,
suffix,
isToken: true,
primaryKeyCurve,
baseUnit: BaseUnit.ETH,
})
);
}

/**
* Factory function for testnet TIP20 token instances on Tempo network.
*
* @param id uuid v4
* @param name unique identifier of the token
* @param fullName Complete human-readable name of the token
* @param decimalPlaces Number of decimal places this token supports (divisibility exponent)
* @param contractAddress the contract address of the token
* @param asset Asset which this coin represents. This is the same for both mainnet and testnet variants of a coin.
* @param features Features of this coin. Defaults to the TEMPO_FEATURES
* @param prefix Optional token prefix. Defaults to empty string
* @param suffix Optional token suffix. Defaults to token name.
* @param network Optional token network. Defaults to the testnet Tempo network.
* @param primaryKeyCurve The elliptic curve for this chain/token
*/
export function ttip20Token(
id: string,
name: string,
fullName: string,
decimalPlaces: number,
contractAddress: string,
asset: UnderlyingAsset,
features: CoinFeature[] = TEMPO_FEATURES,
prefix = '',
suffix: string = name.toUpperCase(),
network: AccountNetwork = Networks.test.tempo,
primaryKeyCurve: KeyCurve = KeyCurve.Secp256k1
) {
return tip20Token(
id,
name,
fullName,
decimalPlaces,
contractAddress,
asset,
features,
prefix,
suffix,
network,
primaryKeyCurve
);
}
38 changes: 38 additions & 0 deletions modules/statics/src/allCoinsAndTokens.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ import {
tstellarToken,
tsuiToken,
ttaoToken,
ttip20Token,
ttronToken,
tvetNFTCollection,
tworldErc20,
Expand Down Expand Up @@ -2738,6 +2739,43 @@ export const allCoinsAndTokens = [
BaseUnit.ETH,
TEMPO_FEATURES
),
// Tempo TIP20 testnet tokens
ttip20Token(
'e1872fd8-14ee-4dc9-bc5e-fd52552d9c60',
'ttempo:pathusd',
'Testnet pathUSD',
18,
'0x20c0000000000000000000000000000000000000',
UnderlyingAsset['ttempo:pathusd'],
TEMPO_FEATURES
),
ttip20Token(
'3c67eaa8-f073-4e1a-9d3a-c6756a31bef0',
'ttempo:alphausd',
'Testnet AlphaUSD',
18,
'0x20c0000000000000000000000000000000000001',
UnderlyingAsset['ttempo:alphausd'],
TEMPO_FEATURES
),
ttip20Token(
'da6d27bd-ed3b-4b59-b574-6e013e5eb55d',
'ttempo:betausd',
'Testnet BetaUSD',
18,
'0x20c0000000000000000000000000000000000002',
UnderlyingAsset['ttempo:betausd'],
TEMPO_FEATURES
),
ttip20Token(
'58cbb592-446e-4753-8c2a-c89f662135ba',
'ttempo:thetausd',
'Testnet ThetaUSD',
18,
'0x20c0000000000000000000000000000000000003',
UnderlyingAsset['ttempo:thetausd'],
TEMPO_FEATURES
),
canton(
'07385320-5a4f-48e9-97a5-86d4be9f24b0',
'canton',
Expand Down
6 changes: 6 additions & 0 deletions modules/statics/src/base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3578,6 +3578,12 @@ export enum UnderlyingAsset {
'canton:usdcx' = 'canton:usdcx',
'canton:cbtc' = 'canton:cbtc',

// Tempo testnet tokens
'ttempo:pathusd' = 'ttempo:pathusd',
'ttempo:alphausd' = 'ttempo:alphausd',
'ttempo:betausd' = 'ttempo:betausd',
'ttempo:thetausd' = 'ttempo:thetausd',

// fiats
AED = 'aed',
EUR = 'eur',
Expand Down
30 changes: 30 additions & 0 deletions modules/statics/src/coins/ofcCoins.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ import {
tofcTonToken,
ofcSuiToken,
tofcSuiToken,
tofcTempoToken,
} from '../ofc';
import { UnderlyingAsset, CoinKind, CoinFeature } from '../base';

Expand Down Expand Up @@ -3992,4 +3993,33 @@ export const ofcCoins = [
),
// New SUI OFC token
ofcSuiToken('1e01eb3d-2573-4662-aa5e-4c390e4a9b38', 'ofcsui:dmc', 'DeLorean', 9, UnderlyingAsset['sui:dmc']),
// Tempo testnet OFC tokens
tofcTempoToken(
'7912e76e-5a5c-4f1b-86e9-1fc2a51f5a98',
'ofcttempo:pathusd',
'Testnet pathUSD',
18,
UnderlyingAsset['ttempo:pathusd']
),
tofcTempoToken(
'349f887a-e764-4640-9ba1-2e29e02d5d65',
'ofcttempo:alphausd',
'Testnet AlphaUSD',
18,
UnderlyingAsset['ttempo:alphausd']
),
tofcTempoToken(
'dc2b6c3d-b7a4-4940-bee3-32defbeff3bf',
'ofcttempo:betausd',
'Testnet BetaUSD',
18,
UnderlyingAsset['ttempo:betausd']
),
tofcTempoToken(
'490a65b6-e01f-4fae-9aa5-7528d1848075',
'ofcttempo:thetausd',
'Testnet ThetaUSD',
18,
UnderlyingAsset['ttempo:thetausd']
),
];
110 changes: 110 additions & 0 deletions modules/statics/src/ofc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2508,3 +2508,113 @@ export function tofcSuiToken(
})
);
}

/**
* Factory function for ofc tempo 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 ofcTempoToken(
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 = 'tempo',
primaryKeyCurve: KeyCurve = KeyCurve.Secp256k1
) {
const filteredFeatures = getFilteredFeatures(suffix);
if (filteredFeatures.length > 0) {
features = filteredFeatures;
}
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 tempo 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 tofcTempoToken(
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.test.ofc,
isToken = true,
addressCoin = 'ttempo',
primaryKeyCurve: KeyCurve = KeyCurve.Secp256k1
) {
const filteredFeatures = getFilteredFeatures(suffix);
if (filteredFeatures.length > 0) {
features = filteredFeatures;
}
return Object.freeze(
new OfcCoin({
id,
name,
fullName,
network,
prefix,
suffix,
features,
decimalPlaces,
isToken,
asset,
kind,
addressCoin,
primaryKeyCurve,
baseUnit: BaseUnit.ETH,
})
);
}
Loading