Skip to content

Commit 2158a52

Browse files
authored
v4 fix: several issues OK-27771 (#4586)
* fix: account balance * fix: account index symbol * fix: base&arb testnet max send error
1 parent 8cb5177 commit 2158a52

File tree

4 files changed

+56
-33
lines changed

4 files changed

+56
-33
lines changed

packages/engine/src/vaults/impl/ada/settings.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ const settings: IVaultSettings = Object.freeze({
2929
template: `m/1852'/${COINTYPE_ADA}'/${INDEX_PLACEHOLDER}'/0/0`,
3030
coinType: COINTYPE_ADA,
3131
label: 'Shelley',
32-
subDesc: `m/1852'/${COINTYPE_ADA}'/x'/0/0`,
32+
subDesc: `m/1852'/${COINTYPE_ADA}'/*'/0/0`,
3333
},
3434
},
3535
});

packages/engine/src/vaults/impl/dynex/Vault.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,8 +83,12 @@ export default class Vault extends VaultBase {
8383
const client = await this.getClient();
8484
const balances: (BigNumber | undefined)[] = [];
8585
for (let i = 0; i < requests.length; i += 1) {
86-
const balance = await client.getBalanceOfAddress(requests[i].address);
87-
balances.push(balance);
86+
try {
87+
const balance = await client.getBalanceOfAddress(requests[i].address);
88+
balances.push(balance);
89+
} catch (e) {
90+
balances.push(new BigNumber(0));
91+
}
8892
}
8993

9094
return balances;

packages/engine/src/vaults/impl/dynex/settings.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ const settings: IVaultSettings = Object.freeze({
3434
template: `m/44'/${COINTYPE_DYNEX}'/0'/0'/${INDEX_PLACEHOLDER}'`,
3535
coinType: COINTYPE_DYNEX,
3636
label: 'Default',
37-
subDesc: `m/44'/${COINTYPE_DYNEX}'/0'/0'/x'`,
37+
subDesc: `m/44'/${COINTYPE_DYNEX}'/0'/0'/*'`,
3838
},
3939
},
4040
});

packages/engine/src/vaults/impl/evm/Vault.ts

Lines changed: 48 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -140,10 +140,17 @@ import type {
140140
import type { IRpcTxEvm } from './types';
141141
import type { IJsonRpcRequest } from '@onekeyfe/cross-inpage-provider-types';
142142

143+
const BASE_SEPOLIA = 'evm--84532';
144+
const ARB_SEPOLIA = 'evm--421614';
145+
143146
const EVM_L2_NETWORKS_REQUIRE_L1_FEE: string[] = [
144147
OnekeyNetwork.optimism,
145148
OnekeyNetwork.toptimism,
146149
OnekeyNetwork.base,
150+
OnekeyNetwork.arbitrum,
151+
OnekeyNetwork.tarbitrum,
152+
BASE_SEPOLIA,
153+
ARB_SEPOLIA,
147154
];
148155

149156
const ERC721 = ERC721MetadataArtifact.abi;
@@ -1273,37 +1280,49 @@ export default class Vault extends VaultBase {
12731280
// For L2 networks with L1 fee.
12741281
let baseFeeValue = '0';
12751282
if (EVM_L2_NETWORKS_REQUIRE_L1_FEE.includes(this.networkId)) {
1276-
// Optimism & Optimism Kovan
1277-
// call gasL1Fee(bytes) of GasPriceOracle at 0x420000000000000000000000000000000000000F
1278-
const txData = ethers.utils.serializeTransaction({
1279-
value: encodedTx.value,
1280-
data: encodedTx.data,
1281-
gasLimit: `0x${(unsignedTx?.feeLimit ?? new BigNumber('0')).toString(
1282-
16,
1283-
)}`,
1284-
to: encodedTx.to,
1285-
chainId: 10, // any number other than 0 will lead to fixed length of data
1286-
gasPrice: '0xf4240', // 0.001 Gwei
1287-
nonce: 1,
1288-
});
1289-
1290-
// keccak256(Buffer.from('getL1Fee(bytes)')) => '0x49948e0e...'
1291-
const data = `0x49948e0e${defaultAbiCoder
1292-
.encode(['bytes'], [txData])
1293-
.slice(2)}`;
12941283
const client = await this.getJsonRPCClient();
1284+
if (
1285+
this.networkId === OnekeyNetwork.arbitrum ||
1286+
this.networkId === ARB_SEPOLIA
1287+
) {
1288+
// keccak256(Buffer.from('getL1BaseFeeEstimate()')) => '0xf5d6ded7...'
1289+
const data = '0xf5d6ded7';
1290+
const l1FeeHex = await client.rpc.call('eth_call', [
1291+
{ to: '0x000000000000000000000000000000000000006C', data },
1292+
'latest',
1293+
]);
1294+
1295+
baseFeeValue = new BigNumber(l1FeeHex as string)
1296+
.shiftedBy(-network.feeDecimals)
1297+
.toFixed();
1298+
} else {
1299+
const txData = ethers.utils.serializeTransaction({
1300+
value: encodedTx.value,
1301+
data: encodedTx.data,
1302+
gasLimit: `0x${(unsignedTx?.feeLimit ?? new BigNumber('0')).toString(
1303+
16,
1304+
)}`,
1305+
to: encodedTx.to,
1306+
chainId: 10, // any number other than 0 will lead to fixed length of data
1307+
gasPrice: '0xf4240', // 0.001 Gwei
1308+
nonce: 1,
1309+
});
12951310

1296-
// RPC: eth_call
1297-
const l1FeeHex = await client.rpc.call('eth_call', [
1298-
{ to: '0x420000000000000000000000000000000000000F', data },
1299-
'latest',
1300-
]);
1301-
// RPC: eth_getBlockByNumber (rpc status check?)
1302-
// RPC: eth_getBalance useManageTokensOfAccount/useReloadAccountBalance
1303-
// may call multiple times
1304-
baseFeeValue = new BigNumber(l1FeeHex as string)
1305-
.shiftedBy(-network.feeDecimals)
1306-
.toFixed();
1311+
// keccak256(Buffer.from('getL1Fee(bytes)')) => '0x49948e0e...'
1312+
const data = `0x49948e0e${defaultAbiCoder
1313+
.encode(['bytes'], [txData])
1314+
.slice(2)}`;
1315+
1316+
// RPC: eth_call
1317+
const l1FeeHex = await client.rpc.call('eth_call', [
1318+
{ to: '0x420000000000000000000000000000000000000F', data },
1319+
'latest',
1320+
]);
1321+
1322+
baseFeeValue = new BigNumber(l1FeeHex as string)
1323+
.shiftedBy(-network.feeDecimals)
1324+
.toFixed();
1325+
}
13071326
}
13081327

13091328
const eip1559 = Boolean(

0 commit comments

Comments
 (0)