|
8 | 8 | CANTON_TOKEN_FEATURES, |
9 | 9 | CELO_TOKEN_FEATURES, |
10 | 10 | COSMOS_SIDECHAIN_FEATURES, |
| 11 | + TEMPO_FEATURES, |
11 | 12 | } from './coinFeatures'; |
12 | 13 |
|
13 | 14 | /** |
@@ -188,6 +189,10 @@ export interface CantonTokenConstructorOptions extends AccountConstructorOptions |
188 | 189 | contractAddress: string; |
189 | 190 | } |
190 | 191 |
|
| 192 | +export interface Tip20TokenConstructorOptions extends AccountConstructorOptions { |
| 193 | + contractAddress: string; |
| 194 | +} |
| 195 | + |
191 | 196 | export interface ContractAddress extends String { |
192 | 197 | __contractaddress_phantom__: never; |
193 | 198 | } |
@@ -798,6 +803,20 @@ export class CantonToken extends AccountCoinToken { |
798 | 803 | } |
799 | 804 | } |
800 | 805 |
|
| 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 | + |
801 | 820 | /** |
802 | 821 | * Factory function for account coin instances. |
803 | 822 | * |
@@ -4291,3 +4310,93 @@ export function tcantonToken( |
4291 | 4310 | primaryKeyCurve |
4292 | 4311 | ); |
4293 | 4312 | } |
| 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 | +} |
0 commit comments