Skip to content

Commit b6a3993

Browse files
authored
Merge pull request #6245 from BitGo/WIN-5533-onboarding-vaulta
refactor(statics): add contract symbol for eos tokens
2 parents 9ea1939 + e0a390a commit b6a3993

File tree

2 files changed

+15
-3
lines changed

2 files changed

+15
-3
lines changed

modules/statics/src/account.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@ export interface HederaTokenConstructorOptions extends AccountConstructorOptions
100100
export interface EosCoinConstructorOptions extends AccountConstructorOptions {
101101
contractName: string;
102102
contractAddress: string;
103+
symbol?: string;
103104
}
104105

105106
export interface SolCoinConstructorOptions extends AccountConstructorOptions {
@@ -356,13 +357,15 @@ export class AlgoCoin extends AccountCoinToken {
356357
export class EosCoin extends AccountCoinToken {
357358
public contractName: string;
358359
public contractAddress: string;
360+
public symbol: string;
359361
constructor(options: EosCoinConstructorOptions) {
360362
super({
361363
...options,
362364
});
363365

364366
this.contractName = options.contractAddress;
365367
this.contractAddress = options.contractAddress;
368+
this.symbol = options.symbol ?? options.name.split(':')[1];
366369
}
367370
}
368371

@@ -1530,6 +1533,7 @@ export function eosToken(
15301533
features: CoinFeature[] = AccountCoin.DEFAULT_FEATURES,
15311534
prefix = '',
15321535
suffix: string = name.toUpperCase(),
1536+
symbol?: string,
15331537
network: AccountNetwork = Networks.main.eos,
15341538
primaryKeyCurve: KeyCurve = KeyCurve.Secp256k1
15351539
) {
@@ -1549,6 +1553,7 @@ export function eosToken(
15491553
isToken: true,
15501554
primaryKeyCurve,
15511555
baseUnit: BaseUnit.EOS,
1556+
symbol,
15521557
})
15531558
);
15541559
}
@@ -1565,6 +1570,7 @@ export function eosToken(
15651570
* @param asset Asset which this coin represents. This is the same for both mainnet and testnet variants of a coin.
15661571
* @param prefix? Optional token prefix. Defaults to empty string
15671572
* @param suffix? Optional token suffix. Defaults to token name.
1573+
* @param symbol? token symbol as defined in token contract.
15681574
* @param network? Optional token network. Defaults to the testnet EOS network.
15691575
* @param features? Features of this coin. Defaults to the DEFAULT_FEATURES defined in `AccountCoin`
15701576
*/
@@ -1579,6 +1585,7 @@ export function teosToken(
15791585
features: CoinFeature[] = AccountCoin.DEFAULT_FEATURES,
15801586
prefix = '',
15811587
suffix: string = name.toUpperCase(),
1588+
symbol?: string,
15821589
network: AccountNetwork = Networks.test.eos
15831590
) {
15841591
return eosToken(
@@ -1592,6 +1599,7 @@ export function teosToken(
15921599
features,
15931600
prefix,
15941601
suffix,
1602+
symbol,
15951603
network
15961604
);
15971605
}

modules/statics/src/coins.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2306,7 +2306,8 @@ export const coins = CoinMap.fromCoins([
23062306
UnderlyingAsset.VAULTA,
23072307
AccountCoin.DEFAULT_FEATURES,
23082308
'',
2309-
'VAULTA'
2309+
'VAULTA',
2310+
'A'
23102311
),
23112312
teosToken(
23122313
'1c627bb5-4bee-4ab0-8bb6-3d535e17a769',
@@ -2366,7 +2367,8 @@ export const coins = CoinMap.fromCoins([
23662367
UnderlyingAsset.VAULTA,
23672368
AccountCoin.DEFAULT_FEATURES,
23682369
'',
2369-
'VAULTA'
2370+
'VAULTA',
2371+
'A'
23702372
),
23712373
erc721(
23722374
'dd743064-09e6-4028-9e61-ebf7c24ff40b',
@@ -3694,7 +3696,9 @@ export function createToken(token: AmsTokenConfig): Readonly<BaseCoin> | undefin
36943696
...commonArgs.slice(0, 4), // id, name, fullName, decimalPlaces
36953697
token.contractName, // contractName
36963698
token.contractAddress, // contractAddress
3697-
...commonArgs.slice(4) // asset, features, prefix, suffix, network, primaryKeyCurve
3699+
...commonArgs.slice(4, 8), // asset, features, prefix, suffix
3700+
token.symbol, // symbol
3701+
...commonArgs.slice(8) // network, primaryKeyCurve
36983702
);
36993703

37003704
case 'hbar':

0 commit comments

Comments
 (0)