Skip to content

Commit bc4872e

Browse files
authored
Merge pull request #6735 from BitGo/coin-5253
chore(statics): add vet nfts to statics
2 parents 2d124f6 + 1557186 commit bc4872e

File tree

4 files changed

+263
-0
lines changed

4 files changed

+263
-0
lines changed

modules/statics/src/account.ts

Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -585,6 +585,21 @@ export class AptCoin extends AccountCoinToken {
585585
*/
586586
export class AptNFTCollection extends NFTCollectionIdDefinedToken {}
587587

588+
/**
589+
* The Vechain network supports non-fungible tokens
590+
* Every NFT belongs to an NFT collection(contract).
591+
*/
592+
export class VetNFTCollection extends AccountCoinToken {
593+
public nftCollectionId: string;
594+
public gasTankToken?: string;
595+
596+
constructor(options: NFTCollectionIdConstructorOptions & { gasTankToken?: string }) {
597+
super(options);
598+
this.nftCollectionId = options.nftCollectionId;
599+
this.gasTankToken = options.gasTankToken;
600+
}
601+
}
602+
588603
/**
589604
* Fiat currencies, such as USD, EUR, or YEN.
590605
*/
@@ -3267,6 +3282,7 @@ export function tnep141Token(
32673282
* @param suffix Optional token suffix. Defaults to token name.
32683283
* @param network Optional token network. Defaults to Near main network.
32693284
* @param primaryKeyCurve The elliptic curve for this chain/token
3285+
* @param gasTankToken representing the token with which gas is paid on the network, defaults to 'VET:VTHO'
32703286
*/
32713287
export function vetToken(
32723288
id: string,
@@ -3315,6 +3331,7 @@ export function vetToken(
33153331
* @param prefix Optional token prefix. Defaults to empty string
33163332
* @param suffix Optional token suffix. Defaults to token name.
33173333
* @param network Optional token network. Defaults to the testnet Near network.
3334+
* @param gasTankToken representing the token with which gas is paid on the network, defaults to 'TVET:VTHO'
33183335
*/
33193336
export function tvetToken(
33203337
id: string,
@@ -3345,6 +3362,97 @@ export function tvetToken(
33453362
);
33463363
}
33473364

3365+
/**
3366+
* Factory function for Vet NFT collections.
3367+
*
3368+
* @param id uuid v4
3369+
* @param name unique identifier of the NFT collection
3370+
* @param fullName Complete human-readable name of the NFT collection
3371+
* @param nftCollectionId collection ID of the non-fungible tokens (NFTs)
3372+
* @param asset Asset which this coin represents. This is the same for both mainnet and testnet variants of a coin.
3373+
* @param prefix Optional token prefix. Defaults to empty string
3374+
* @param suffix Optional token suffix. Defaults to token name.
3375+
* @param network Optional token network. Defaults to VET main network.
3376+
* @param features Features of this coin. Defaults to the DEFAULT_FEATURES and REQUIRES_RESERVE defined in `AccountCoin`
3377+
* @param primaryKeyCurve The elliptic curve for this chain/token
3378+
* @param gasTankToken representing the token with which gas is paid on the network, defaults to 'VET:VTHO'
3379+
*/
3380+
export function vetNFTCollection(
3381+
id: string,
3382+
name: string,
3383+
fullName: string,
3384+
nftCollectionId: string,
3385+
asset: UnderlyingAsset,
3386+
features: CoinFeature[] = AccountCoin.DEFAULT_FEATURES,
3387+
prefix = '',
3388+
suffix: string = name.toUpperCase(),
3389+
network: AccountNetwork = Networks.main.vet,
3390+
primaryKeyCurve: KeyCurve = KeyCurve.Secp256k1,
3391+
gasTankToken = 'VET:VTHO'
3392+
) {
3393+
return Object.freeze(
3394+
new VetNFTCollection({
3395+
id,
3396+
name,
3397+
fullName,
3398+
network,
3399+
nftCollectionId,
3400+
prefix,
3401+
suffix,
3402+
features,
3403+
decimalPlaces: 0,
3404+
asset,
3405+
isToken: true,
3406+
primaryKeyCurve,
3407+
baseUnit: BaseUnit.VET,
3408+
gasTankToken,
3409+
})
3410+
);
3411+
}
3412+
3413+
/**
3414+
* Factory function for testnet Vet NFT collections.
3415+
*
3416+
* @param id uuid v4
3417+
* @param name unique identifier of the NFT collection
3418+
* @param fullName Complete human-readable name of the NFT collection
3419+
* @param nftCollectionId collection ID of the non-fungible tokens (NFTs)
3420+
* @param asset Asset which this coin represents. This is the same for both mainnet and testnet variants of a coin.
3421+
* @param prefix Optional token prefix. Defaults to empty string
3422+
* @param suffix Optional token suffix. Defaults to token name.
3423+
* @param network Optional token network. Defaults to VET test network.
3424+
* @param features Features of this coin. Defaults to the DEFAULT_FEATURES and REQUIRES_RESERVE defined in `AccountCoin`
3425+
* @param primaryKeyCurve The elliptic curve for this chain/token
3426+
* @param gasTankToken representing the token with which gas is paid on the network, defaults to 'TVET:VTHO'
3427+
*/
3428+
export function tvetNFTCollection(
3429+
id: string,
3430+
name: string,
3431+
fullName: string,
3432+
nftCollectionId: string,
3433+
asset: UnderlyingAsset,
3434+
features: CoinFeature[] = AccountCoin.DEFAULT_FEATURES,
3435+
prefix = 't',
3436+
suffix: string = name.toUpperCase(),
3437+
network: AccountNetwork = Networks.test.vet,
3438+
primaryKeyCurve: KeyCurve = KeyCurve.Secp256k1,
3439+
gasTankToken = 'TVET:VTHO'
3440+
) {
3441+
return vetNFTCollection(
3442+
id,
3443+
name,
3444+
fullName,
3445+
nftCollectionId,
3446+
asset,
3447+
features,
3448+
prefix,
3449+
suffix,
3450+
network,
3451+
primaryKeyCurve,
3452+
gasTankToken
3453+
);
3454+
}
3455+
33483456
/**
33493457
* Factory function for Cosmos chain token instances.
33503458
*

modules/statics/src/base.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2989,6 +2989,12 @@ export enum UnderlyingAsset {
29892989
// VET testnet tokens
29902990
'tvet:vtho' = 'tvet:vtho',
29912991

2992+
// Vet mainnet NFTs
2993+
'vet:sdt' = 'vet:sdt',
2994+
2995+
// Vet testnet NFTs
2996+
'tvet:sdt' = 'tvet:sdt',
2997+
29922998
// COSMOS tokens
29932999
'hash:ylds' = 'hash:ylds',
29943000

modules/statics/src/coins.ts

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,11 @@ import {
4747
tsuiToken,
4848
ttaoToken,
4949
ttronToken,
50+
tvetNFTCollection,
5051
tworldErc20,
5152
txrpToken,
5253
tzkethErc20,
54+
vetNFTCollection,
5355
vetToken,
5456
worldErc20,
5557
xrpToken,
@@ -4239,6 +4241,22 @@ export const coins = CoinMap.fromCoins([
42394241
UnderlyingAsset['tapt:beta3loanbook'],
42404242
APT_FEATURES
42414243
),
4244+
vetNFTCollection(
4245+
'4f56375d-f682-4045-a3a2-cabb29556c07',
4246+
'vet:sdt',
4247+
'StarGate Delegator Token',
4248+
'0x1856c533ac2d94340aaa8544d35a5c1d4a21dee7',
4249+
UnderlyingAsset['vet:sdt'],
4250+
VET_FEATURES
4251+
),
4252+
tvetNFTCollection(
4253+
'dd710759-1b87-4435-bef5-db377040deaf',
4254+
'tvet:sdt',
4255+
'Testnet StarGate Delegator Token',
4256+
'0x1ec1d168574603ec35b9d229843b7c2b44bcb770',
4257+
UnderlyingAsset['tvet:sdt'],
4258+
VET_FEATURES
4259+
),
42424260
fiat('3f89b1f5-4ada-49c0-a613-15e484d42426', 'fiatusd', 'US Dollar', Networks.main.fiat, 2, UnderlyingAsset.USD),
42434261
fiat(
42444262
'8691cc4f-a425-4192-b6cb-3b0b6f646cbc',
@@ -4397,6 +4415,22 @@ export function createToken(token: AmsTokenConfig): Readonly<BaseCoin> | undefin
43974415
...commonArgs.slice(4) // asset, features, prefix, suffix, network, primaryKeyCurve
43984416
);
43994417

4418+
case 'vet':
4419+
const { vetInitFunc, vetObjectId, isNFT } = getVetTokenInitializer(token);
4420+
if (isNFT) {
4421+
return vetInitFunc(
4422+
...commonArgs.slice(0, 3), // id, name, fullName
4423+
vetObjectId,
4424+
...commonArgs.slice(4) // asset, features, prefix, suffix, network, primaryKeyCurve
4425+
);
4426+
} else {
4427+
return vetInitFunc(
4428+
...commonArgs.slice(0, 4), // id, name, fullName, decimalPlaces
4429+
vetObjectId,
4430+
...commonArgs.slice(4) // asset, features, prefix, suffix, network, primaryKeyCurve
4431+
);
4432+
}
4433+
44004434
case 'stx':
44014435
return initializer(
44024436
...commonArgs.slice(0, 4), // id, name, fullName, decimalPlaces
@@ -4530,6 +4564,22 @@ function getAptTokenInitializer(token: AmsTokenConfig) {
45304564
};
45314565
}
45324566

4567+
function getVetTokenInitializer(token: AmsTokenConfig) {
4568+
if (token.nftCollectionId) {
4569+
return {
4570+
vetInitFunc: vetNFTCollection as (...args: unknown[]) => Readonly<BaseCoin>,
4571+
vetObjectId: token.nftCollectionId,
4572+
isNFT: true,
4573+
};
4574+
}
4575+
4576+
return {
4577+
vetInitFunc: vetToken as (...args: unknown[]) => Readonly<BaseCoin>,
4578+
vetObjectId: token.contractAddress,
4579+
isNFT: false,
4580+
};
4581+
}
4582+
45334583
export function isCoinPresentInCoinMap({ name, id, alias }: { name: string; id?: string; alias?: string }): boolean {
45344584
return Boolean(coins.has(name) || (id && coins.has(id)) || (alias && coins.has(alias)));
45354585
}

modules/statics/test/unit/resources/amsTokenConfig.ts

Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -618,6 +618,105 @@ export const amsTokenConfig = {
618618
contractAddress: '0xterc1155:bsctoken',
619619
},
620620
],
621+
'tvet:sdt': [
622+
{
623+
id: 'dd710759-1b87-4435-bef5-db377040deaf',
624+
fullName: 'Testnet StarGate Delegator Token',
625+
name: 'tvet:sdt',
626+
prefix: 't',
627+
suffix: 'TVET:SDT',
628+
baseUnit: 'wei',
629+
kind: 'crypto',
630+
family: 'vet',
631+
isToken: true,
632+
features: [
633+
'account-model',
634+
'requires-big-number',
635+
'valueless-transfer',
636+
'transaction-data',
637+
'custody',
638+
'custody-bitgo-trust',
639+
'custody-bitgo-mena-fze',
640+
'custody-bitgo-custody-mena-fze',
641+
'custody-bitgo-singapore',
642+
'custody-bitgo-korea',
643+
'custody-bitgo-europe-aps',
644+
'custody-bitgo-frankfurt',
645+
'custody-bitgo-india',
646+
'tss',
647+
'tss-cold',
648+
'supports-tokens',
649+
'enterprise-pays-fees',
650+
'tss-enterprise-pays-fees',
651+
'fees-paid-with-token',
652+
'mpcv2',
653+
],
654+
decimalPlaces: 0,
655+
asset: 'tvet:sdt',
656+
network: {
657+
type: 'testnet',
658+
name: 'VeChainTestnet',
659+
family: 'vet',
660+
explorerUrl: 'https://explore-testnet.vechain.org/transactions/',
661+
accountExplorerUrl: 'https://explore-testnet.vechain.org/accounts/',
662+
chainId: 100010,
663+
forwarderFactoryAddress: '0x65343e18c376d2fc8c3cf10cd146d63e2e0dc9ef',
664+
forwarderImplementationAddress: '0x62de34c87f847d385af07f6c25dbd97b1fffefc0',
665+
},
666+
primaryKeyCurve: 'secp256k1',
667+
nftCollectionId: '0x1ec1d168574603ec35b9d229843b7c2b44bcb770',
668+
gasTankToken: 'TVET:VTHO',
669+
},
670+
],
671+
'tvet:vtho': [
672+
{
673+
id: '27dd32d2-7311-4552-9beb-c57f76d09205',
674+
fullName: 'Testnet VeThor',
675+
name: 'tvet:vtho',
676+
prefix: '',
677+
suffix: 'TVET:VTHO',
678+
baseUnit: 'wei',
679+
kind: 'crypto',
680+
family: 'vet',
681+
isToken: true,
682+
features: [
683+
'account-model',
684+
'requires-big-number',
685+
'valueless-transfer',
686+
'transaction-data',
687+
'custody',
688+
'custody-bitgo-trust',
689+
'custody-bitgo-mena-fze',
690+
'custody-bitgo-custody-mena-fze',
691+
'custody-bitgo-singapore',
692+
'custody-bitgo-korea',
693+
'custody-bitgo-europe-aps',
694+
'custody-bitgo-frankfurt',
695+
'custody-bitgo-india',
696+
'tss',
697+
'tss-cold',
698+
'enterprise-pays-fees',
699+
'tss-enterprise-pays-fees',
700+
'mpcv2',
701+
'fees-paid-with-token',
702+
],
703+
decimalPlaces: 18,
704+
asset: 'tvet:vtho',
705+
network: {
706+
type: 'testnet',
707+
name: 'VeChainTestnet',
708+
family: 'vet',
709+
explorerUrl: 'https://explore-testnet.vechain.org/transactions/',
710+
accountExplorerUrl: 'https://explore-testnet.vechain.org/accounts/',
711+
chainId: 100010,
712+
forwarderFactoryAddress: '0x65343e18c376d2fc8c3cf10cd146d63e2e0dc9ef',
713+
forwarderImplementationAddress: '0x62de34c87f847d385af07f6c25dbd97b1fffefc0',
714+
},
715+
primaryKeyCurve: 'secp256k1',
716+
contractAddress: '0x0000000000000000000000000000456e65726779',
717+
gasTankToken: 'TVET:VTHO',
718+
},
719+
],
621720
};
622721

623722
export const amsTokenConfigWithCustomToken = {

0 commit comments

Comments
 (0)