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
8 changes: 7 additions & 1 deletion modules/statics/src/account.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,8 @@ export interface GasTankAccountConstructorOptions extends AccountConstructorOpti
gasTankLowBalanceAlertFactor: number;
// min gas tank balance recommendation is calculated as (feeEstimate x gasTankMinBalanceRecommendationFactor)
gasTankMinBalanceRecommendationFactor: number;
// gas tank token is the token used to pay for gas
gasTankToken?: string;
}

export interface Erc20ConstructorOptions extends AccountConstructorOptions {
Expand Down Expand Up @@ -170,12 +172,14 @@ export class AccountCoinToken extends AccountCoin {
export class GasTankAccountCoin extends AccountCoin {
public gasTankLowBalanceAlertFactor: number;
public gasTankMinBalanceRecommendationFactor: number;
public gasTankToken?: string;
constructor(options: GasTankAccountConstructorOptions) {
super({
...options,
});
this.gasTankLowBalanceAlertFactor = options.gasTankLowBalanceAlertFactor;
this.gasTankMinBalanceRecommendationFactor = options.gasTankMinBalanceRecommendationFactor;
this.gasTankToken = options?.gasTankToken;
}
}

Expand Down Expand Up @@ -729,7 +733,8 @@ export function gasTankAccount(
gasTankMinBalanceRecommendationFactor = 10,
prefix = '',
suffix: string = name.toUpperCase(),
isToken = false
isToken = false,
gasTankToken?: string
) {
return Object.freeze(
new GasTankAccountCoin({
Expand All @@ -747,6 +752,7 @@ export function gasTankAccount(
primaryKeyCurve,
gasTankLowBalanceAlertFactor,
gasTankMinBalanceRecommendationFactor,
gasTankToken,
})
);
}
Expand Down
12 changes: 10 additions & 2 deletions modules/statics/src/coins.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1708,7 +1708,11 @@ export const coins = CoinMap.fromCoins([
VET_FEATURES,
KeyCurve.Secp256k1,
80,
200
200,
'',
'VET',
false,
'VET:VTHO'
),
gasTankAccount(
'b3158e80-f6ea-4922-98ab-d773a680ce76',
Expand All @@ -1721,7 +1725,11 @@ export const coins = CoinMap.fromCoins([
VET_FEATURES,
KeyCurve.Secp256k1,
80,
200
200,
'',
'TVET',
false,
'TVET:VTHO'
),
erc20CompatibleAccountCoin(
'bfae821b-cf3a-4190-b1a8-a54af51d730e',
Expand Down
15 changes: 13 additions & 2 deletions modules/statics/test/unit/account.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const should = require('should');
import { AccountCoin, Networks, UnderlyingAsset } from '../../src';
import { txrpToken, xrpToken, vetToken, tvetToken } from '../../src/account';
import { AccountCoin, coins, Networks, UnderlyingAsset } from '../../src';
import { txrpToken, xrpToken, vetToken, tvetToken, GasTankAccountCoin } from '../../src/account';

describe('XRP', () => {
it('should create a new XRP token with the correct properties', () => {
Expand Down Expand Up @@ -89,4 +89,15 @@ describe('VET', () => {
should(token.id).equal('cebb0ba8-6736-46bb-a006-5db7b5b3c376');
should(token.gasTankToken).equal('TVET:VTHO');
});

it('should create a base VET coin with the correct gasTankToken property', () => {
// Get the base VET coin
const vetCoin = coins.get('vet') as GasTankAccountCoin;
should(vetCoin).not.be.undefined();
should(vetCoin.gasTankToken).equal('VET:VTHO');
// Get the testnet VET coin
const tvetCoin = coins.get('tvet') as GasTankAccountCoin;
should(tvetCoin).not.be.undefined();
should(tvetCoin.gasTankToken).equal('TVET:VTHO');
});
});