Skip to content

Commit 43f51bc

Browse files
Merge pull request #6588 from BitGo/COIN-4748-add-gastank-token-name
feat: add gasTankTokenName coin property for vet
2 parents 7e65207 + 5c9be27 commit 43f51bc

File tree

2 files changed

+51
-4
lines changed

2 files changed

+51
-4
lines changed

modules/statics/src/account.ts

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,7 @@ export interface Nep141TokenConstructorOptions extends AccountConstructorOptions
149149

150150
export interface VetTokenConstructorOptions extends AccountConstructorOptions {
151151
contractAddress: string;
152+
gasTankToken?: string;
152153
}
153154
export interface CosmosTokenConstructorOptions extends AccountConstructorOptions {
154155
denom: string;
@@ -623,11 +624,13 @@ export class Nep141Token extends AccountCoinToken {
623624

624625
export class VetToken extends AccountCoinToken {
625626
public contractAddress: string;
627+
public gasTankToken?: string;
626628
constructor(options: VetTokenConstructorOptions) {
627629
super({
628630
...options,
629631
});
630632
this.contractAddress = options.contractAddress;
633+
this.gasTankToken = options.gasTankToken;
631634
}
632635
}
633636

@@ -3176,7 +3179,8 @@ export function vetToken(
31763179
prefix = '',
31773180
suffix: string = name.toUpperCase(),
31783181
network: AccountNetwork = Networks.main.vet,
3179-
primaryKeyCurve: KeyCurve = KeyCurve.Secp256k1
3182+
primaryKeyCurve: KeyCurve = KeyCurve.Secp256k1,
3183+
gasTankToken = 'VET:VTHO'
31803184
) {
31813185
return Object.freeze(
31823186
new VetToken({
@@ -3193,6 +3197,7 @@ export function vetToken(
31933197
isToken: true,
31943198
primaryKeyCurve,
31953199
baseUnit: BaseUnit.VET,
3200+
gasTankToken,
31963201
})
31973202
);
31983203
}
@@ -3221,9 +3226,23 @@ export function tvetToken(
32213226
features: CoinFeature[] = AccountCoin.DEFAULT_FEATURES,
32223227
prefix = '',
32233228
suffix: string = name.toUpperCase(),
3224-
network: AccountNetwork = Networks.test.vet
3229+
network: AccountNetwork = Networks.test.vet,
3230+
gasTankToken = 'TVET:VTHO' // For test environment
32253231
) {
3226-
return vetToken(id, name, fullName, decimalPlaces, contractAddress, asset, features, prefix, suffix, network);
3232+
return vetToken(
3233+
id,
3234+
name,
3235+
fullName,
3236+
decimalPlaces,
3237+
contractAddress,
3238+
asset,
3239+
features,
3240+
prefix,
3241+
suffix,
3242+
network,
3243+
KeyCurve.Secp256k1,
3244+
gasTankToken
3245+
);
32273246
}
32283247

32293248
/**

modules/statics/test/unit/account.ts

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
const should = require('should');
22
import { AccountCoin, Networks, UnderlyingAsset } from '../../src';
3-
import { txrpToken, xrpToken } from '../../src/account';
3+
import { txrpToken, xrpToken, vetToken, tvetToken } from '../../src/account';
44

55
describe('XRP', () => {
66
it('should create a new XRP token with the correct properties', () => {
@@ -62,3 +62,31 @@ describe('XRP', () => {
6262
should(token.baseUnit).equal('drop');
6363
});
6464
});
65+
66+
describe('VET', () => {
67+
it('should create a new VET token with the correct gastankTokenName for production', () => {
68+
const token = vetToken(
69+
'cebb0ba8-6736-46bb-a006-5db7b5b3c376',
70+
'token-name',
71+
'Token fullname',
72+
15,
73+
'contract-address',
74+
UnderlyingAsset.VET
75+
);
76+
should(token.id).equal('cebb0ba8-6736-46bb-a006-5db7b5b3c376');
77+
should(token.gasTankToken).equal('VET:VTHO');
78+
});
79+
80+
it('should create a new TVET token with the correct gasTankToken for testnet', () => {
81+
const token = tvetToken(
82+
'cebb0ba8-6736-46bb-a006-5db7b5b3c376',
83+
'token-name',
84+
'Token fullname',
85+
15,
86+
'contract-address',
87+
UnderlyingAsset.VET
88+
);
89+
should(token.id).equal('cebb0ba8-6736-46bb-a006-5db7b5b3c376');
90+
should(token.gasTankToken).equal('TVET:VTHO');
91+
});
92+
});

0 commit comments

Comments
 (0)