Skip to content

Commit 54c8023

Browse files
Merge branch 'master' into manas/WIN-4102-destination-tag-check-for-address
TICKET: WIN-4102
2 parents 436e08b + 88ba6bb commit 54c8023

File tree

6 files changed

+110
-15
lines changed

6 files changed

+110
-15
lines changed

modules/abstract-eth/src/abstractEthLikeNewCoins.ts

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1373,7 +1373,7 @@ export abstract class AbstractEthLikeNewCoins extends AbstractEthLikeCoin {
13731373
? new optionalDeps.ethUtil.BN(params.eip1559.maxFeePerGas)
13741374
: params.gasPrice
13751375
? new optionalDeps.ethUtil.BN(this.setGasPrice(params.gasPrice))
1376-
: await this.getGasPriceFromExternalAPI();
1376+
: await this.getGasPriceFromExternalAPI(this.staticsCoin?.name as string);
13771377

13781378
const bitgoFeeAddressNonce = await this.getAddressNonce(bitgoFeeAddress);
13791379

@@ -1480,6 +1480,7 @@ export abstract class AbstractEthLikeNewCoins extends AbstractEthLikeCoin {
14801480
if (!params.gasLimit && userKey && !userKey.startsWith('xpub')) {
14811481
const sendData = txBuilder.getSendData();
14821482
gasLimit = await this.getGasLimitFromExternalAPI(
1483+
params.intendedChain as string,
14831484
params.bitgoFeeAddress as string,
14841485
params.walletContractAddress,
14851486
sendData
@@ -1650,6 +1651,7 @@ export abstract class AbstractEthLikeNewCoins extends AbstractEthLikeCoin {
16501651
if (!params.gasLimit && userKey && !userKey.startsWith('xpub')) {
16511652
const sendData = txBuilder.getSendData();
16521653
gasLimit = await this.getGasLimitFromExternalAPI(
1654+
params.intendedChain as string,
16531655
params.bitgoFeeAddress as string,
16541656
params.walletContractAddress,
16551657
sendData
@@ -2447,7 +2449,7 @@ export abstract class AbstractEthLikeNewCoins extends AbstractEthLikeCoin {
24472449
/**
24482450
* Fetch the gas price from the explorer
24492451
*/
2450-
async getGasPriceFromExternalAPI(): Promise<BN> {
2452+
async getGasPriceFromExternalAPI(wrongChainCoin: string): Promise<BN> {
24512453
try {
24522454
const res = await this.recoveryBlockchainExplorerQuery({
24532455
module: 'proxy',
@@ -2457,17 +2459,18 @@ export abstract class AbstractEthLikeNewCoins extends AbstractEthLikeCoin {
24572459
console.log(` Got gas price: ${gasPrice}`);
24582460
return gasPrice;
24592461
} catch (e) {
2460-
throw new Error('Failed to get gas price');
2462+
throw new Error(`Failed to get gas price. Please make sure to use the api key of ${wrongChainCoin}`);
24612463
}
24622464
}
24632465

24642466
/**
24652467
* Fetch the gas limit from the explorer
2468+
* @param intendedChain
24662469
* @param from
24672470
* @param to
24682471
* @param data
24692472
*/
2470-
async getGasLimitFromExternalAPI(from: string, to: string, data: string): Promise<BN> {
2473+
async getGasLimitFromExternalAPI(intendedChain: string, from: string, to: string, data: string): Promise<BN> {
24712474
try {
24722475
const res = await this.recoveryBlockchainExplorerQuery({
24732476
module: 'proxy',
@@ -2480,7 +2483,9 @@ export abstract class AbstractEthLikeNewCoins extends AbstractEthLikeCoin {
24802483
console.log(`Got gas limit: ${gasLimit}`);
24812484
return gasLimit;
24822485
} catch (e) {
2483-
throw new Error('Failed to get gas limit: ');
2486+
throw new Error(
2487+
`Failed to get gas limit. Please make sure to use the privateKey aka userKey of ${intendedChain} wallet ${to}`
2488+
);
24842489
}
24852490
}
24862491

modules/sdk-coin-avaxc/src/avaxc.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1212,11 +1212,12 @@ export class AvaxC extends AbstractEthLikeNewCoins {
12121212

12131213
/**
12141214
* Fetch the gas limit from the explorer
1215+
* @param intendedChain
12151216
* @param from
12161217
* @param to
12171218
* @param data
12181219
*/
1219-
async getGasLimitFromExternalAPI(from: string, to: string, data: string): Promise<BN> {
1220+
async getGasLimitFromExternalAPI(intendedChain: string, from: string, to: string, data: string): Promise<BN> {
12201221
try {
12211222
const res = await this.recoveryBlockchainExplorerQuery({
12221223
jsonrpc: '2.0',
@@ -1235,7 +1236,9 @@ export class AvaxC extends AbstractEthLikeNewCoins {
12351236
console.log(`Got gas limit: ${gasLimit}`);
12361237
return gasLimit;
12371238
} catch (e) {
1238-
throw new Error('Failed to get gas limit: ');
1239+
throw new Error(
1240+
`Failed to get gas limit. Please make sure to use the privateKey aka userKey of ${intendedChain} wallet ${to}`
1241+
);
12391242
}
12401243
}
12411244
}

modules/statics/src/account.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1678,7 +1678,7 @@ export function polygonErc20(
16781678
decimalPlaces: number,
16791679
contractAddress: string,
16801680
asset: UnderlyingAsset,
1681-
features: CoinFeature[] = AccountCoin.DEFAULT_FEATURES,
1681+
features: CoinFeature[] = [...AccountCoin.DEFAULT_FEATURES, CoinFeature.EIP1559],
16821682
prefix = '',
16831683
suffix: string = name.toUpperCase(),
16841684
network: AccountNetwork = Networks.main.polygon,
@@ -1768,7 +1768,7 @@ export function arbethErc20(
17681768
decimalPlaces: number,
17691769
contractAddress: string,
17701770
asset: UnderlyingAsset,
1771-
features: CoinFeature[] = AccountCoin.DEFAULT_FEATURES,
1771+
features: CoinFeature[] = [...AccountCoin.DEFAULT_FEATURES, CoinFeature.EIP1559],
17721772
prefix = '',
17731773
suffix: string = name.toUpperCase(),
17741774
network: AccountNetwork = Networks.main.arbitrum,
@@ -1858,7 +1858,7 @@ export function opethErc20(
18581858
decimalPlaces: number,
18591859
contractAddress: string,
18601860
asset: UnderlyingAsset,
1861-
features: CoinFeature[] = AccountCoin.DEFAULT_FEATURES,
1861+
features: CoinFeature[] = [...AccountCoin.DEFAULT_FEATURES, CoinFeature.EIP1559],
18621862
prefix = '',
18631863
suffix: string = name.toUpperCase(),
18641864
network: AccountNetwork = Networks.main.optimism,
@@ -2038,7 +2038,7 @@ export function beraErc20(
20382038
decimalPlaces: number,
20392039
contractAddress: string,
20402040
asset: UnderlyingAsset,
2041-
features: CoinFeature[] = AccountCoin.DEFAULT_FEATURES,
2041+
features: CoinFeature[] = [...AccountCoin.DEFAULT_FEATURES, CoinFeature.EIP1559],
20422042
prefix = '',
20432043
suffix: string = name.toUpperCase(),
20442044
network: AccountNetwork = Networks.main.bera,

modules/statics/src/base.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -304,6 +304,11 @@ export enum CoinFeature {
304304
* This coin is onboarded on etheruem rollup chain
305305
*/
306306
ETH_ROLLUP_CHAIN = 'eth-rollup-chain',
307+
308+
/**
309+
* This coin supports EIP1559 proposal for transaction fee
310+
*/
311+
EIP1559 = 'EIP1559',
307312
}
308313

309314
/**
@@ -2354,6 +2359,8 @@ export enum UnderlyingAsset {
23542359
'sol:drift' = 'sol:drift',
23552360
'sol:spx' = 'sol:spx',
23562361
'sol:turbo' = 'sol:turbo',
2362+
'sol:corn' = 'sol:corn',
2363+
'sol:yes' = 'sol:yes',
23572364

23582365
// TRX tokens
23592366
'trx:htx' = 'trx:htx',

modules/statics/src/coins.ts

Lines changed: 50 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -97,13 +97,15 @@ const AVAXC_FEATURES = [
9797
CoinFeature.CUSTODY_BITGO_SWITZERLAND,
9898
CoinFeature.CUSTODY_BITGO_SINGAPORE,
9999
CoinFeature.MULTISIG_COLD,
100+
CoinFeature.EIP1559,
100101
];
101102
const CELO_FEATURES = [
102103
...ETH_FEATURES,
103104
CoinFeature.CUSTODY_BITGO_GERMANY,
104105
CoinFeature.CUSTODY_BITGO_FRANKFURT,
105106
CoinFeature.CUSTODY_BITGO_SINGAPORE,
106107
CoinFeature.MULTISIG_COLD,
108+
CoinFeature.EIP1559,
107109
];
108110
const ETH2_FEATURES = [...AccountCoin.DEFAULT_FEATURES, CoinFeature.SUPPORTS_TOKENS];
109111
const RBTC_FEATURES = [
@@ -162,7 +164,7 @@ const ALGO_FEATURES = [
162164
CoinFeature.MULTISIG_COLD,
163165
CoinFeature.BULK_TRANSACTION,
164166
];
165-
const HTETH_TOKEN_FEATURES = [...AccountCoin.DEFAULT_FEATURES, CoinFeature.BULK_TRANSACTION];
167+
const HTETH_TOKEN_FEATURES = [...AccountCoin.DEFAULT_FEATURES, CoinFeature.BULK_TRANSACTION, CoinFeature.EIP1559];
166168
const ADA_FEATURES = [...Ada.DEFAULT_FEATURES, CoinFeature.BULK_TRANSACTION];
167169
const ADA_FEATURES_WITH_FRANKFURT = [...ADA_FEATURES, CoinFeature.CUSTODY_BITGO_FRANKFURT];
168170
const DOT_FEATURES = [
@@ -368,6 +370,7 @@ const ARBETH_FEATURES = [
368370
CoinFeature.USES_NON_PACKED_ENCODING_FOR_TXDATA,
369371
CoinFeature.ETH_ROLLUP_CHAIN,
370372
CoinFeature.CUSTODY_BITGO_FRANKFURT,
373+
CoinFeature.EIP1559,
371374
];
372375
const OPETH_FEATURES = [
373376
...ETH_FEATURES,
@@ -376,13 +379,15 @@ const OPETH_FEATURES = [
376379
CoinFeature.USES_NON_PACKED_ENCODING_FOR_TXDATA,
377380
CoinFeature.ETH_ROLLUP_CHAIN,
378381
CoinFeature.CUSTODY_BITGO_FRANKFURT,
382+
CoinFeature.EIP1559,
379383
];
380384
const ZKETH_FEATURES = [
381385
...ETH_FEATURES,
382386
CoinFeature.MULTISIG_COLD,
383387
CoinFeature.EVM_WALLET,
384388
CoinFeature.USES_NON_PACKED_ENCODING_FOR_TXDATA,
385389
CoinFeature.ETH_ROLLUP_CHAIN,
390+
CoinFeature.EIP1559,
386391
];
387392
const BERA_FEATURES = [
388393
...ETH_FEATURES,
@@ -392,6 +397,7 @@ const BERA_FEATURES = [
392397
CoinFeature.EVM_WALLET,
393398
CoinFeature.USES_NON_PACKED_ENCODING_FOR_TXDATA,
394399
CoinFeature.BULK_TRANSACTION,
400+
CoinFeature.EIP1559,
395401
];
396402
const OAS_FEATURES = [
397403
...ETH_FEATURES,
@@ -401,6 +407,7 @@ const OAS_FEATURES = [
401407
CoinFeature.EVM_WALLET,
402408
CoinFeature.BULK_TRANSACTION,
403409
CoinFeature.STUCK_TRANSACTION_MANAGEMENT_TSS,
410+
CoinFeature.EIP1559,
404411
];
405412
const COREDAO_FEATURES = [
406413
...ETH_FEATURES,
@@ -410,7 +417,9 @@ const COREDAO_FEATURES = [
410417
CoinFeature.EVM_WALLET,
411418
CoinFeature.BULK_TRANSACTION,
412419
CoinFeature.STUCK_TRANSACTION_MANAGEMENT_TSS,
420+
CoinFeature.EIP1559,
413421
CoinFeature.STAKING,
422+
CoinFeature.EIP1559,
414423
];
415424
const APT_FEATURES = [
416425
...AccountCoin.DEFAULT_FEATURES,
@@ -586,6 +595,7 @@ export const coins = CoinMap.fromCoins([
586595
CoinFeature.BULK_TRANSACTION,
587596
CoinFeature.STUCK_TRANSACTION_MANAGEMENT_ONCHAIN,
588597
CoinFeature.STUCK_TRANSACTION_MANAGEMENT_TSS,
598+
CoinFeature.EIP1559,
589599
]
590600
), // we should probably refactor this into a eth() method
591601
account(
@@ -596,7 +606,7 @@ export const coins = CoinMap.fromCoins([
596606
18,
597607
UnderlyingAsset.ETH,
598608
BaseUnit.ETH,
599-
[...ETH_FEATURES, CoinFeature.DEPRECATED]
609+
[...ETH_FEATURES, CoinFeature.DEPRECATED, CoinFeature.EIP1559]
600610
),
601611
account(
602612
'41b75ac4-46d6-4dac-b741-bf11406b142f',
@@ -617,6 +627,7 @@ export const coins = CoinMap.fromCoins([
617627
CoinFeature.CUSTODY_BITGO_SWITZERLAND,
618628
CoinFeature.CUSTODY_BITGO_FRANKFURT,
619629
CoinFeature.CUSTODY_BITGO_SINGAPORE,
630+
CoinFeature.EIP1559,
620631
]
621632
),
622633
account(
@@ -642,6 +653,7 @@ export const coins = CoinMap.fromCoins([
642653
CoinFeature.BULK_TRANSACTION,
643654
CoinFeature.STUCK_TRANSACTION_MANAGEMENT_ONCHAIN,
644655
CoinFeature.STUCK_TRANSACTION_MANAGEMENT_TSS,
656+
CoinFeature.EIP1559,
645657
]
646658
),
647659
account(
@@ -1230,7 +1242,7 @@ export const coins = CoinMap.fromCoins([
12301242
18,
12311243
UnderlyingAsset.POLYGON,
12321244
BaseUnit.ETH,
1233-
POLYGON_FEATURES
1245+
[...POLYGON_FEATURES, CoinFeature.EIP1559]
12341246
),
12351247
account(
12361248
'aa7b72d1-9197-492d-b2ca-2c9c9732115d',
@@ -1240,7 +1252,7 @@ export const coins = CoinMap.fromCoins([
12401252
18,
12411253
UnderlyingAsset.POLYGON,
12421254
BaseUnit.ETH,
1243-
POLYGON_FEATURES
1255+
[...POLYGON_FEATURES, CoinFeature.EIP1559]
12441256
),
12451257
account(
12461258
'b5ba2fc6-706b-433f-9bcf-4ea4aaa09281',
@@ -1912,6 +1924,22 @@ export const coins = CoinMap.fromCoins([
19121924
CoinKind.CRYPTO
19131925
),
19141926
ofc('07083ea6-74ba-4da7-8cf3-031126a130a4', 'ofcton', 'Ton', 9, UnderlyingAsset.TON, CoinKind.CRYPTO),
1927+
ofc(
1928+
'055691ec-f750-4349-b505-92954ca08257',
1929+
'ofccoredao',
1930+
'coredaochain',
1931+
18,
1932+
UnderlyingAsset.COREDAO,
1933+
CoinKind.CRYPTO
1934+
),
1935+
tofc(
1936+
'f17727ec-5d0b-4c5d-bbbc-cd93da537f40',
1937+
'ofctcoredao',
1938+
'Testnet coredao chain',
1939+
18,
1940+
UnderlyingAsset.COREDAO,
1941+
CoinKind.CRYPTO
1942+
),
19151943
tofc('e85d3b60-b6c8-4e29-b6db-38966125cfeb', 'ofctusd', 'Test USD', 2, UnderlyingAsset.USD, CoinKind.FIAT),
19161944
tofc('dbac74bb-5dbc-4cdd-ad66-f71315b53a3f', 'ofcteur', 'Test Euro', 2, UnderlyingAsset.EUR, CoinKind.FIAT),
19171945
tofc(
@@ -16186,6 +16214,24 @@ export const coins = CoinMap.fromCoins([
1618616214
UnderlyingAsset['sol:turbo'],
1618716215
SOL_TOKEN_FEATURES
1618816216
),
16217+
solToken(
16218+
'e743ddc6-9d5e-41b6-9367-9d6e5f7dd7b4',
16219+
'sol:corn',
16220+
'Solanacorn',
16221+
7,
16222+
'6DSqVXg9WLTWgz6LACqxN757QdHe1sCqkUfojWmxWtok', // https://solscan.io/token/6DSqVXg9WLTWgz6LACqxN757QdHe1sCqkUfojWmxWtok
16223+
UnderlyingAsset['sol:corn'],
16224+
SOL_TOKEN_FEATURES
16225+
),
16226+
solToken(
16227+
'4eee379c-7f46-4f75-bb92-baf6583f0787',
16228+
'sol:yes',
16229+
'Yes Token',
16230+
9,
16231+
'32h846XXTSWGUaaKHMC5b2e39n1nwJD6UtDBppX5p4E9', // ttps://solscan.io/token/32h846XXTSWGUaaKHMC5b2e39n1nwJD6UtDBppX5p4E9
16232+
UnderlyingAsset['sol:yes'],
16233+
SOL_TOKEN_FEATURES
16234+
),
1618916235
solToken(
1619016236
'45d95e60-81df-4c5d-9ceb-e6e4f5b75eeb',
1619116237
'sol:bome',

modules/statics/test/unit/coins.ts

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -682,3 +682,37 @@ describe('Bulk Transaction Features', () => {
682682
});
683683
});
684684
});
685+
686+
describe('Eip1559 coins', () => {
687+
const eip1559Coins = [
688+
'avaxc',
689+
'tavaxc',
690+
'eth',
691+
'teth',
692+
'gteth',
693+
'hteth',
694+
'hteth:bgerchv2',
695+
'celo',
696+
'tcelo',
697+
'arbeth',
698+
'tarbeth',
699+
'opeth',
700+
'topeth',
701+
'polygon',
702+
'tpolygon',
703+
'zketh',
704+
'tzketh',
705+
'bera',
706+
'tbera',
707+
'oas',
708+
'toas',
709+
'coredao',
710+
'tcoredao',
711+
];
712+
it('should have EIP1559 feature', () => {
713+
eip1559Coins.forEach((coinName) => {
714+
const coin = coins.get(coinName);
715+
coin.features.includes(CoinFeature.EIP1559).should.eql(true);
716+
});
717+
});
718+
});

0 commit comments

Comments
 (0)