Skip to content

Commit 5bf5237

Browse files
Merge pull request #6594 from BitGo/COIN-4748-add-gas-tank-token
feat: add gasTankToken property for vet in statics
2 parents 41d9246 + ef3453b commit 5bf5237

File tree

3 files changed

+30
-5
lines changed

3 files changed

+30
-5
lines changed

modules/statics/src/account.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,8 @@ export interface GasTankAccountConstructorOptions extends AccountConstructorOpti
7575
gasTankLowBalanceAlertFactor: number;
7676
// min gas tank balance recommendation is calculated as (feeEstimate x gasTankMinBalanceRecommendationFactor)
7777
gasTankMinBalanceRecommendationFactor: number;
78+
// gas tank token is the token used to pay for gas
79+
gasTankToken?: string;
7880
}
7981

8082
export interface Erc20ConstructorOptions extends AccountConstructorOptions {
@@ -170,12 +172,14 @@ export class AccountCoinToken extends AccountCoin {
170172
export class GasTankAccountCoin extends AccountCoin {
171173
public gasTankLowBalanceAlertFactor: number;
172174
public gasTankMinBalanceRecommendationFactor: number;
175+
public gasTankToken?: string;
173176
constructor(options: GasTankAccountConstructorOptions) {
174177
super({
175178
...options,
176179
});
177180
this.gasTankLowBalanceAlertFactor = options.gasTankLowBalanceAlertFactor;
178181
this.gasTankMinBalanceRecommendationFactor = options.gasTankMinBalanceRecommendationFactor;
182+
this.gasTankToken = options?.gasTankToken;
179183
}
180184
}
181185

@@ -729,7 +733,8 @@ export function gasTankAccount(
729733
gasTankMinBalanceRecommendationFactor = 10,
730734
prefix = '',
731735
suffix: string = name.toUpperCase(),
732-
isToken = false
736+
isToken = false,
737+
gasTankToken?: string
733738
) {
734739
return Object.freeze(
735740
new GasTankAccountCoin({
@@ -747,6 +752,7 @@ export function gasTankAccount(
747752
primaryKeyCurve,
748753
gasTankLowBalanceAlertFactor,
749754
gasTankMinBalanceRecommendationFactor,
755+
gasTankToken,
750756
})
751757
);
752758
}

modules/statics/src/coins.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1708,7 +1708,11 @@ export const coins = CoinMap.fromCoins([
17081708
VET_FEATURES,
17091709
KeyCurve.Secp256k1,
17101710
80,
1711-
200
1711+
200,
1712+
'',
1713+
'VET',
1714+
false,
1715+
'VET:VTHO'
17121716
),
17131717
gasTankAccount(
17141718
'b3158e80-f6ea-4922-98ab-d773a680ce76',
@@ -1721,7 +1725,11 @@ export const coins = CoinMap.fromCoins([
17211725
VET_FEATURES,
17221726
KeyCurve.Secp256k1,
17231727
80,
1724-
200
1728+
200,
1729+
'',
1730+
'TVET',
1731+
false,
1732+
'TVET:VTHO'
17251733
),
17261734
erc20CompatibleAccountCoin(
17271735
'bfae821b-cf3a-4190-b1a8-a54af51d730e',

modules/statics/test/unit/account.ts

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

55
describe('XRP', () => {
66
it('should create a new XRP token with the correct properties', () => {
@@ -89,4 +89,15 @@ describe('VET', () => {
8989
should(token.id).equal('cebb0ba8-6736-46bb-a006-5db7b5b3c376');
9090
should(token.gasTankToken).equal('TVET:VTHO');
9191
});
92+
93+
it('should create a base VET coin with the correct gasTankToken property', () => {
94+
// Get the base VET coin
95+
const vetCoin = coins.get('vet') as GasTankAccountCoin;
96+
should(vetCoin).not.be.undefined();
97+
should(vetCoin.gasTankToken).equal('VET:VTHO');
98+
// Get the testnet VET coin
99+
const tvetCoin = coins.get('tvet') as GasTankAccountCoin;
100+
should(tvetCoin).not.be.undefined();
101+
should(tvetCoin.gasTankToken).equal('TVET:VTHO');
102+
});
92103
});

0 commit comments

Comments
 (0)