wative 1.0.19 → 1.0.20
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 +26 -26
- package/src/tools.ts +15 -40
package/src/tools.ts
CHANGED
|
@@ -202,16 +202,12 @@ export const sendSolanaRawTransaction = async (chain_id: string, chain_rpc_url:
|
|
|
202
202
|
);
|
|
203
203
|
|
|
204
204
|
transaction.feePayer = new PublicKey(account_address);
|
|
205
|
-
console.log(account_address);
|
|
206
|
-
console.log(chain_rpc_url)
|
|
207
|
-
console.log(transaction);
|
|
208
205
|
const simulate_result = await wative_core.account.simulateTransaction(
|
|
209
206
|
account_address,
|
|
210
207
|
chain_rpc_url,
|
|
211
208
|
transaction
|
|
212
209
|
);
|
|
213
210
|
|
|
214
|
-
console.log(simulate_result);
|
|
215
211
|
if (!simulate_result.status) {
|
|
216
212
|
console.log(chalk.red(simulate_result.output));
|
|
217
213
|
return;
|
|
@@ -224,18 +220,16 @@ export const sendSolanaRawTransaction = async (chain_id: string, chain_rpc_url:
|
|
|
224
220
|
|
|
225
221
|
let baseUnitsConsumed = new BigNumber(simulate_result.output.value.unitsConsumed.toString()).multipliedBy(1.2).toFixed(0, BigNumber.ROUND_CEIL);
|
|
226
222
|
let unitsConsumed = new BigNumber(baseUnitsConsumed);
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
const prioritization_fee = new BigNumber(1000);
|
|
223
|
+
const prioritization_fee_result = await getPrioritizationFee(chain_rpc_url);
|
|
224
|
+
if (!prioritization_fee_result.status) {
|
|
225
|
+
console.log(chalk.red(prioritization_fee_result.output));
|
|
226
|
+
return;
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
const prioritization_fee = new BigNumber(prioritization_fee_result.output.toString());
|
|
235
230
|
const used_prioritization_fee = unitsConsumed.multipliedBy(prioritization_fee).dividedBy(1e6).toFixed(0, BigNumber.ROUND_CEIL);
|
|
236
231
|
|
|
237
232
|
const account_balance_result = await getAccountBalanceInSolana(account_address, chain_rpc_url);
|
|
238
|
-
console.log(account_balance_result);
|
|
239
233
|
if (!account_balance_result.status) {
|
|
240
234
|
console.log(chalk.red(account_balance_result.output));
|
|
241
235
|
return;
|
|
@@ -256,23 +250,6 @@ export const sendSolanaRawTransaction = async (chain_id: string, chain_rpc_url:
|
|
|
256
250
|
chain_symbols,
|
|
257
251
|
9
|
|
258
252
|
);
|
|
259
|
-
// let option_select_value_list: any = [
|
|
260
|
-
// '> Input value',
|
|
261
|
-
// `> Total Balance (${total_balance} ${chain_symbols})`
|
|
262
|
-
// ]
|
|
263
|
-
// let selected_value = await selectSomething(option_select_value_list);
|
|
264
|
-
// let value_id = option_select_value_list.indexOf(selected_value);
|
|
265
|
-
// let transfer_amount: string = "0";
|
|
266
|
-
// if (value_id === 0) {
|
|
267
|
-
// let input_value = await inputSomething("value", numberValidator);
|
|
268
|
-
// transfer_amount = new BigNumber(input_value).multipliedBy(1e9).toFixed(0, BigNumber.ROUND_FLOOR);
|
|
269
|
-
// if ((new BigNumber(transfer_amount)).isGreaterThan(new BigNumber(max_value))) {
|
|
270
|
-
// console.log(chalk.red("Not enough balance"));
|
|
271
|
-
// return;
|
|
272
|
-
// }
|
|
273
|
-
// } else if (value_id === 1) {
|
|
274
|
-
// transfer_amount = max_value.toString();
|
|
275
|
-
// }
|
|
276
253
|
|
|
277
254
|
let transactions = new Transaction();
|
|
278
255
|
transactions.add(
|
|
@@ -615,7 +592,6 @@ const sendSolanaTokenTransaction = async (keystore_path: string, chain_rpc_url:
|
|
|
615
592
|
transaction
|
|
616
593
|
);
|
|
617
594
|
|
|
618
|
-
console.log(simulate_result);
|
|
619
595
|
if (!simulate_result.status) {
|
|
620
596
|
console.log(chalk.red(simulate_result.output));
|
|
621
597
|
return;
|
|
@@ -628,15 +604,14 @@ const sendSolanaTokenTransaction = async (keystore_path: string, chain_rpc_url:
|
|
|
628
604
|
|
|
629
605
|
let unitsConsumed = new BigNumber(simulate_result.output.value.unitsConsumed.toString());
|
|
630
606
|
unitsConsumed = new BigNumber(Math.ceil(Number(unitsConsumed) * 1.2));
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
607
|
+
const prioritization_fee_result = await getPrioritizationFee(chain_rpc_url);
|
|
608
|
+
if (!prioritization_fee_result.status) {
|
|
609
|
+
console.log(chalk.red(prioritization_fee_result.output));
|
|
610
|
+
return;
|
|
611
|
+
}
|
|
612
|
+
|
|
613
|
+
const prioritization_fee = new BigNumber(prioritization_fee_result.output.toString());
|
|
614
|
+
|
|
640
615
|
transactions.add(
|
|
641
616
|
createTransferInstruction(
|
|
642
617
|
from_token_account,
|