wative 1.0.12 → 1.0.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/index.esm.js +1 -1
- package/lib/index.umd.js +1 -1
- package/package.json +1 -1
- package/src/account.ts +10 -1
- package/src/assets.ts +13 -5
- package/src/network.ts +9 -1
- package/src/tools.ts +48 -3
- package/src/web3.ts +10 -4
package/src/tools.ts
CHANGED
|
@@ -5,7 +5,7 @@ import { addrValidator, chainAddressValidator, confirmSomething, editorSomething
|
|
|
5
5
|
import { loginIn } from './account';
|
|
6
6
|
import { getAccountBalance, getDefaultNetworkByAddress, getEvmNetworks, getNetworkInfoByName, getNetworkTypeByName } from './network';
|
|
7
7
|
import { GasUtil } from './tx_gas_utils';
|
|
8
|
-
import { getAccountBalanceInEvm, getAccountBalanceInSolana, getAccountInfoInSolana, getCodeInEvm, getPrioritizationFee, getTokenBalanceInEvm, getTokenBalanceInSolana, getTokenInfoInEvm, getTokenInfoInSolana, getTransferTokenData } from './web3';
|
|
8
|
+
import { deleteTokenBalance, getAccountBalanceInEvm, getAccountBalanceInSolana, getAccountInfoInSolana, getCodeInEvm, getPrioritizationFee, getTokenBalanceInEvm, getTokenBalanceInSolana, getTokenInfoInEvm, getTokenInfoInSolana, getTransferTokenData } from './web3';
|
|
9
9
|
import { getAssetListByTokenName } from './assets';
|
|
10
10
|
import { ComputeBudgetProgram, PublicKey, SystemProgram, Transaction } from '@solana/web3.js';
|
|
11
11
|
import {
|
|
@@ -62,7 +62,7 @@ const confirmEvmRawTransaction = async (tx_params: any): Promise<any> => {
|
|
|
62
62
|
return await confirmEvmRawTransaction(tx_params);
|
|
63
63
|
}
|
|
64
64
|
|
|
65
|
-
const sendEvmRawTransaction = async (chain_rpc_url: string, chain_symbols: string, account_address: string, wative_core: typeof WativeCore) => {
|
|
65
|
+
const sendEvmRawTransaction = async (chain_id: string, chain_rpc_url: string, chain_symbols: string, account_address: string, wative_core: typeof WativeCore) => {
|
|
66
66
|
const to = await inputSomething("to", chainAddressValidator);
|
|
67
67
|
const gasUtil = new GasUtil(chain_rpc_url);
|
|
68
68
|
const estimateGasPrice = await gasUtil.getGasPrice();
|
|
@@ -165,10 +165,20 @@ const sendEvmRawTransaction = async (chain_rpc_url: string, chain_symbols: strin
|
|
|
165
165
|
return;
|
|
166
166
|
}
|
|
167
167
|
|
|
168
|
+
deleteTokenBalance(
|
|
169
|
+
chain_id,
|
|
170
|
+
[
|
|
171
|
+
account_address,
|
|
172
|
+
to
|
|
173
|
+
],
|
|
174
|
+
[
|
|
175
|
+
"0"
|
|
176
|
+
]
|
|
177
|
+
);
|
|
168
178
|
console.log(chalk.green(`Transaction hash: ${transaction_receipt_result.output.transactionHash}`));
|
|
169
179
|
}
|
|
170
180
|
|
|
171
|
-
export const sendSolanaRawTransaction = async (chain_rpc_url: string, chain_symbols: string, account_address: string, wative_core: typeof WativeCore) => {
|
|
181
|
+
export const sendSolanaRawTransaction = async (chain_id: string, chain_rpc_url: string, chain_symbols: string, account_address: string, wative_core: typeof WativeCore) => {
|
|
172
182
|
const to = await inputSomething("to", chainAddressValidator);
|
|
173
183
|
|
|
174
184
|
let transaction = new Transaction().add(SystemProgram.transfer({
|
|
@@ -278,6 +288,16 @@ export const sendSolanaRawTransaction = async (chain_rpc_url: string, chain_symb
|
|
|
278
288
|
return;
|
|
279
289
|
}
|
|
280
290
|
|
|
291
|
+
deleteTokenBalance(
|
|
292
|
+
chain_id,
|
|
293
|
+
[
|
|
294
|
+
account_address,
|
|
295
|
+
to
|
|
296
|
+
],
|
|
297
|
+
[
|
|
298
|
+
"0"
|
|
299
|
+
]
|
|
300
|
+
);
|
|
281
301
|
console.log(chalk.green(`Transaction hash: ${transaction_receipt_result.output}`));
|
|
282
302
|
}
|
|
283
303
|
|
|
@@ -399,6 +419,17 @@ const sendEvmTokenTransaction = async (keystore_path: string, chain_rpc_url: str
|
|
|
399
419
|
return;
|
|
400
420
|
}
|
|
401
421
|
|
|
422
|
+
deleteTokenBalance(
|
|
423
|
+
chain_id,
|
|
424
|
+
[
|
|
425
|
+
account_address,
|
|
426
|
+
receipt
|
|
427
|
+
],
|
|
428
|
+
[
|
|
429
|
+
"0",
|
|
430
|
+
token_address
|
|
431
|
+
]
|
|
432
|
+
);
|
|
402
433
|
console.log(chalk.green(`Transaction hash: ${transaction_receipt_result.output.transactionHash}`));
|
|
403
434
|
}
|
|
404
435
|
|
|
@@ -596,6 +627,18 @@ const sendSolanaTokenTransaction = async (keystore_path: string, chain_rpc_url:
|
|
|
596
627
|
return;
|
|
597
628
|
}
|
|
598
629
|
|
|
630
|
+
deleteTokenBalance(
|
|
631
|
+
chain_id,
|
|
632
|
+
[
|
|
633
|
+
account_address,
|
|
634
|
+
receipt
|
|
635
|
+
],
|
|
636
|
+
[
|
|
637
|
+
"0",
|
|
638
|
+
token_address
|
|
639
|
+
]
|
|
640
|
+
);
|
|
641
|
+
|
|
599
642
|
console.log(chalk.green(`Transaction hash: ${transaction_receipt_result.output}`));
|
|
600
643
|
}
|
|
601
644
|
|
|
@@ -650,6 +693,7 @@ const excuteTools = async (keystore_path: string, account_label: string, account
|
|
|
650
693
|
case '> Send Raw Tx': {
|
|
651
694
|
if (account_chain_type === "evm") {
|
|
652
695
|
await sendEvmRawTransaction(
|
|
696
|
+
network_info.chainId.toString(),
|
|
653
697
|
network_info.rpcUrl,
|
|
654
698
|
network_info.nativeCurrency.symbol,
|
|
655
699
|
account_address,
|
|
@@ -659,6 +703,7 @@ const excuteTools = async (keystore_path: string, account_label: string, account
|
|
|
659
703
|
|
|
660
704
|
if (account_chain_type === "solana") {
|
|
661
705
|
await sendSolanaRawTransaction(
|
|
706
|
+
network_info.chainId.toString(),
|
|
662
707
|
network_info.rpcUrl,
|
|
663
708
|
network_info.nativeCurrency.symbol,
|
|
664
709
|
account_address,
|
package/src/web3.ts
CHANGED
|
@@ -361,8 +361,14 @@ export const getTokenBalance = (
|
|
|
361
361
|
return batchAccountBalanceOf;
|
|
362
362
|
}
|
|
363
363
|
|
|
364
|
-
export const deleteTokenBalance = (chain_id: string,
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
364
|
+
export const deleteTokenBalance = (chain_id: string, account_address_list: string[], token_address_list: string[]) => {
|
|
365
|
+
for (let i = 0; i < account_address_list.length; i++) {
|
|
366
|
+
let account_address = account_address_list[i];
|
|
367
|
+
for (let j = 0; j < token_address_list.length; j++) {
|
|
368
|
+
let token_address = token_address_list[j];
|
|
369
|
+
try {
|
|
370
|
+
delete chainIdAccountBalanceMap[chain_id][token_address][account_address];
|
|
371
|
+
} catch (err) { }
|
|
372
|
+
}
|
|
373
|
+
}
|
|
368
374
|
}
|