wative 1.0.29 → 1.0.31

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/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 { deleteTokenBalance, getAccountBalanceInEvm, getAccountBalanceInSolana, getAccountInfoInSolana, getCodeInEvm, getPrioritizationFee, getTokenBalanceInEvm, getTokenBalanceInSolana, getTokenInfoInEvm, getTokenInfoInSolana, getTransferTokenData } from './web3';
8
+ import { deleteTokenBalance, getAccountBalanceInEvm, getAccountBalanceInSolana, getAccountInfoInSolana, getCodeInEvm, getLatestBlockhash, 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 {
@@ -184,6 +184,13 @@ export const sendSolanaRawTransaction = async (chain_id: string, chain_rpc_url:
184
184
  );
185
185
 
186
186
  transaction.feePayer = new PublicKey(account_address);
187
+
188
+ let last_blockhash: any = await getLatestBlockhash(chain_rpc_url);
189
+ if (!last_blockhash.status) {
190
+ console.log(chalk.red(last_blockhash.output));
191
+ return;
192
+ }
193
+ transaction.recentBlockhash = last_blockhash.output.blockhash;
187
194
  const simulate_result = await wative_core.account.simulateTransaction(
188
195
  account_address,
189
196
  chain_rpc_url,
@@ -253,7 +260,8 @@ export const sendSolanaRawTransaction = async (chain_id: string, chain_rpc_url:
253
260
  lamports: Number(transfer_amount)
254
261
  }));
255
262
 
256
- transaction.feePayer = new PublicKey(account_address);
263
+ transactions.feePayer = new PublicKey(account_address);
264
+ transactions.recentBlockhash = last_blockhash.output.blockhash;
257
265
 
258
266
  const signed_message_result = await wative_core.account.signTransaction(
259
267
  account_address,
@@ -705,7 +713,7 @@ const excuteTools = async (keystore_path: string, account_label: string, account
705
713
  }
706
714
 
707
715
  if (network_type === "evm") {
708
- let confirm = await confirmSomething(`Network (${default_network}), want a change?`);
716
+ let confirm = await confirmSomething(`Network (${default_network}), want a change?`, false);
709
717
  if (confirm) {
710
718
  const evm_networks = getEvmNetworks(keystore_path);
711
719
  const selected_network = await selectSomething(evm_networks, "Select a network");
package/src/utils.ts CHANGED
@@ -421,12 +421,13 @@ export const inputPassword = async (text: string) => {
421
421
  return password;
422
422
  }
423
423
 
424
- export const confirmSomething = async (text: string) => {
424
+ export const confirmSomething = async (text: string, _default = true) => {
425
425
  const questions = [
426
426
  {
427
427
  name: 'confirm',
428
428
  type: 'confirm',
429
429
  message: `${text}`,
430
+ default: _default
430
431
  }
431
432
  ]
432
433
  const { confirm } = await inquirer.prompt(questions);
package/src/web3.ts CHANGED
@@ -253,6 +253,23 @@ export const getPrioritizationFee = async (rpc_url: string) => {
253
253
  }
254
254
  }
255
255
 
256
+ export const getLatestBlockhash = async (rpc_url: string) => {
257
+ const connection = new Connection(rpc_url);
258
+ let result = await excutePromiseFunction(connection.getLatestBlockhash.bind(connection), [{
259
+ commitment: "finalized"
260
+ }]);
261
+ if (!result.status) {
262
+ return {
263
+ status: false,
264
+ output: "Failed to get latest blockhash"
265
+ }
266
+ }
267
+ return {
268
+ status: true,
269
+ output: result.output
270
+ }
271
+ }
272
+
256
273
  export const getAccountInfoInSolana = async (account: string, rpc_url: string) => {
257
274
  const connection = new Connection(rpc_url);
258
275
  let result = await excutePromiseFunction(connection.getAccountInfo.bind(connection), [