@sidhujag/sysweb3-keyring 1.0.510 → 1.0.511
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/cjs/keyring-manager.js +9 -7
- package/cjs/keyring-manager.js.map +1 -1
- package/cjs/providers.js +68 -20
- package/cjs/providers.js.map +1 -1
- package/cjs/transactions/ethereum.js +62 -56
- package/cjs/transactions/ethereum.js.map +1 -1
- package/cjs/types.js.map +1 -1
- package/cjs/utils.js +12 -11
- package/cjs/utils.js.map +1 -1
- package/package.json +22 -7
- package/types/keyring-manager.d.ts +3 -3
- package/types/providers.d.ts +14 -11
- package/types/transactions/ethereum.d.ts +3 -2
- package/types/types.d.ts +15 -12
|
@@ -4,11 +4,17 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.EthereumTransactions = void 0;
|
|
7
|
+
const bignumber_1 = require("@ethersproject/bignumber");
|
|
8
|
+
const bytes_1 = require("@ethersproject/bytes");
|
|
9
|
+
const constants_1 = require("@ethersproject/constants");
|
|
10
|
+
const contracts_1 = require("@ethersproject/contracts");
|
|
11
|
+
const transactions_1 = require("@ethersproject/transactions");
|
|
12
|
+
const units_1 = require("@ethersproject/units");
|
|
13
|
+
const wallet_1 = require("@ethersproject/wallet");
|
|
7
14
|
const eth_sig_util_1 = require("@metamask/eth-sig-util");
|
|
8
15
|
const sysweb3_network_1 = require("@sidhujag/sysweb3-network");
|
|
9
16
|
const sysweb3_utils_1 = require("@sidhujag/sysweb3-utils");
|
|
10
17
|
const ethereumjs_util_1 = require("ethereumjs-util");
|
|
11
|
-
const ethers_1 = require("ethers");
|
|
12
18
|
const omit_1 = __importDefault(require("lodash/omit"));
|
|
13
19
|
const providers_1 = require("../providers");
|
|
14
20
|
const types_1 = require("../types");
|
|
@@ -331,7 +337,7 @@ class EthereumTransactions {
|
|
|
331
337
|
throw error;
|
|
332
338
|
}
|
|
333
339
|
};
|
|
334
|
-
this.toBigNumber = (aBigNumberish) =>
|
|
340
|
+
this.toBigNumber = (aBigNumberish) => bignumber_1.BigNumber.from(String(aBigNumberish));
|
|
335
341
|
this.getData = ({ contractAddress, receivingAddress, value, }) => {
|
|
336
342
|
const abi = (0, sysweb3_utils_1.getErc20Abi)();
|
|
337
343
|
try {
|
|
@@ -353,11 +359,11 @@ class EthereumTransactions {
|
|
|
353
359
|
if (block && block.baseFeePerGas) {
|
|
354
360
|
try {
|
|
355
361
|
const ethMaxPriorityFee = await this.web3Provider.send('eth_maxPriorityFeePerGas', []);
|
|
356
|
-
maxPriorityFeePerGas =
|
|
362
|
+
maxPriorityFeePerGas = bignumber_1.BigNumber.from(ethMaxPriorityFee);
|
|
357
363
|
maxFeePerGas = block.baseFeePerGas.mul(2).add(maxPriorityFeePerGas);
|
|
358
364
|
}
|
|
359
365
|
catch (e) {
|
|
360
|
-
maxPriorityFeePerGas =
|
|
366
|
+
maxPriorityFeePerGas = bignumber_1.BigNumber.from('1500000000');
|
|
361
367
|
maxFeePerGas = block.baseFeePerGas.mul(2).add(maxPriorityFeePerGas);
|
|
362
368
|
}
|
|
363
369
|
return { maxFeePerGas, maxPriorityFeePerGas };
|
|
@@ -386,7 +392,7 @@ class EthereumTransactions {
|
|
|
386
392
|
const calculateAndConvertNewValue = (feeValue) => {
|
|
387
393
|
const calculateValue = String(feeValue * multiplierToUse);
|
|
388
394
|
const convertValueToHex = '0x' + parseInt(calculateValue, 10).toString(16);
|
|
389
|
-
return
|
|
395
|
+
return bignumber_1.BigNumber.from(convertValueToHex);
|
|
390
396
|
};
|
|
391
397
|
const maxFeePerGasToNumber = maxFeePerGas?.toNumber();
|
|
392
398
|
const maxPriorityFeePerGasToNumber = maxPriorityFeePerGas?.toNumber();
|
|
@@ -403,7 +409,7 @@ class EthereumTransactions {
|
|
|
403
409
|
if (isForCancel) {
|
|
404
410
|
const DEFAULT_GAS_LIMIT_VALUE = '21000';
|
|
405
411
|
const convertToHex = '0x' + parseInt(DEFAULT_GAS_LIMIT_VALUE, 10).toString(16);
|
|
406
|
-
newGasValues.gasLimit =
|
|
412
|
+
newGasValues.gasLimit = bignumber_1.BigNumber.from(convertToHex);
|
|
407
413
|
}
|
|
408
414
|
if (!isForCancel) {
|
|
409
415
|
newGasValues.gasLimit = calculateAndConvertNewValue(gasLimitToNumber);
|
|
@@ -421,7 +427,7 @@ class EthereumTransactions {
|
|
|
421
427
|
};
|
|
422
428
|
}
|
|
423
429
|
const { decryptedPrivateKey } = this.getDecryptedPrivateKey();
|
|
424
|
-
const wallet = new
|
|
430
|
+
const wallet = new wallet_1.Wallet(decryptedPrivateKey, this.web3Provider);
|
|
425
431
|
let changedTxToCancel;
|
|
426
432
|
const oldTxsGasValues = {
|
|
427
433
|
maxFeePerGas: tx.maxFeePerGas,
|
|
@@ -437,7 +443,7 @@ class EthereumTransactions {
|
|
|
437
443
|
nonce: tx.nonce,
|
|
438
444
|
from: wallet.address,
|
|
439
445
|
to: wallet.address,
|
|
440
|
-
value:
|
|
446
|
+
value: constants_1.Zero,
|
|
441
447
|
maxFeePerGas: newGasValues.maxFeePerGas,
|
|
442
448
|
maxPriorityFeePerGas: newGasValues.maxPriorityFeePerGas,
|
|
443
449
|
gasLimit: newGasValues.gasLimit,
|
|
@@ -451,7 +457,7 @@ class EthereumTransactions {
|
|
|
451
457
|
nonce: tx.nonce,
|
|
452
458
|
from: wallet.address,
|
|
453
459
|
to: wallet.address,
|
|
454
|
-
value:
|
|
460
|
+
value: constants_1.Zero,
|
|
455
461
|
gasLimit: newGasValues.gasLimit,
|
|
456
462
|
gasPrice: newGasValues.gasPrice,
|
|
457
463
|
};
|
|
@@ -501,7 +507,7 @@ class EthereumTransactions {
|
|
|
501
507
|
chainId: activeNetwork.chainId,
|
|
502
508
|
type: 2,
|
|
503
509
|
};
|
|
504
|
-
const rawTx =
|
|
510
|
+
const rawTx = (0, transactions_1.serialize)(txFormattedForEthers);
|
|
505
511
|
const signature = await this.ledgerSigner.evm.signEVMTransaction({
|
|
506
512
|
rawTx: rawTx.replace('0x', ''),
|
|
507
513
|
accountIndex: activeAccountId,
|
|
@@ -513,7 +519,7 @@ class EthereumTransactions {
|
|
|
513
519
|
};
|
|
514
520
|
if (signature) {
|
|
515
521
|
try {
|
|
516
|
-
const signedTx =
|
|
522
|
+
const signedTx = (0, transactions_1.serialize)(txFormattedForEthers, formattedSignature);
|
|
517
523
|
const finalTx = await this.web3Provider.sendTransaction(signedTx);
|
|
518
524
|
return finalTx;
|
|
519
525
|
}
|
|
@@ -616,7 +622,7 @@ class EthereumTransactions {
|
|
|
616
622
|
type: 2,
|
|
617
623
|
};
|
|
618
624
|
signature.payload.v = parseInt(signature.payload.v, 16); //v parameter must be a number by ethers standards
|
|
619
|
-
const signedTx =
|
|
625
|
+
const signedTx = (0, transactions_1.serialize)(txFormattedForEthers, signature.payload);
|
|
620
626
|
const finalTx = await this.web3Provider.sendTransaction(signedTx);
|
|
621
627
|
return finalTx;
|
|
622
628
|
}
|
|
@@ -636,7 +642,7 @@ class EthereumTransactions {
|
|
|
636
642
|
throw new Error(`Account state mismatch detected during transaction. Expected ${activeAccount.address} but got ${address}. Please wait for account switching to complete and try again.`);
|
|
637
643
|
}
|
|
638
644
|
const tx = params;
|
|
639
|
-
const wallet = new
|
|
645
|
+
const wallet = new wallet_1.Wallet(decryptedPrivateKey, this.web3Provider);
|
|
640
646
|
try {
|
|
641
647
|
const transaction = await wallet.sendTransaction(tx);
|
|
642
648
|
const response = await this.web3Provider.getTransaction(transaction.hash);
|
|
@@ -670,7 +676,7 @@ class EthereumTransactions {
|
|
|
670
676
|
};
|
|
671
677
|
}
|
|
672
678
|
const { decryptedPrivateKey, address } = this.getDecryptedPrivateKey();
|
|
673
|
-
const wallet = new
|
|
679
|
+
const wallet = new wallet_1.Wallet(decryptedPrivateKey, this.web3Provider);
|
|
674
680
|
// Check if this might be a max send transaction by comparing total cost to balance
|
|
675
681
|
const currentBalance = await this.web3Provider.getBalance(address);
|
|
676
682
|
// Ensure all transaction values are resolved from promises
|
|
@@ -717,7 +723,7 @@ class EthereumTransactions {
|
|
|
717
723
|
// For non-contract calls, reduce value to fit within balance
|
|
718
724
|
adjustedValue = currentBalance.sub(newGasCost);
|
|
719
725
|
// Ensure we don't go below a minimum threshold (0.0001 ETH)
|
|
720
|
-
const minValue =
|
|
726
|
+
const minValue = (0, units_1.parseEther)('0.0001');
|
|
721
727
|
if (adjustedValue.lt(minValue)) {
|
|
722
728
|
console.warn('[SpeedUp] Adjusted value too low, keeping original');
|
|
723
729
|
adjustedValue = txValue;
|
|
@@ -754,7 +760,7 @@ class EthereumTransactions {
|
|
|
754
760
|
// For non-contract calls, reduce value to fit within balance
|
|
755
761
|
adjustedValue = currentBalance.sub(newGasCost);
|
|
756
762
|
// Ensure we don't go below a minimum threshold (0.0001 ETH)
|
|
757
|
-
const minValue =
|
|
763
|
+
const minValue = (0, units_1.parseEther)('0.0001');
|
|
758
764
|
if (adjustedValue.lt(minValue)) {
|
|
759
765
|
console.warn('[SpeedUp] Adjusted value too low, keeping original');
|
|
760
766
|
adjustedValue = txValue;
|
|
@@ -802,9 +808,9 @@ class EthereumTransactions {
|
|
|
802
808
|
this.sendTransaction = async ({ sender, receivingAddress, amount, gasLimit, token, }) => {
|
|
803
809
|
const tokenDecimals = token && token.decimals ? token.decimals : 18;
|
|
804
810
|
const decimals = this.toBigNumber(tokenDecimals);
|
|
805
|
-
const parsedAmount =
|
|
811
|
+
const parsedAmount = (0, units_1.parseEther)(String(amount));
|
|
806
812
|
const { decryptedPrivateKey } = this.getDecryptedPrivateKey();
|
|
807
|
-
const wallet = new
|
|
813
|
+
const wallet = new wallet_1.Wallet(decryptedPrivateKey, this.web3Provider);
|
|
808
814
|
const value = token && token.contract_address
|
|
809
815
|
? parsedAmount.mul(this.toBigNumber('10').pow(decimals))
|
|
810
816
|
: parsedAmount;
|
|
@@ -848,13 +854,13 @@ class EthereumTransactions {
|
|
|
848
854
|
const { accounts, activeAccountType, activeAccountId, activeNetwork } = this.getState();
|
|
849
855
|
const { address: activeAccountAddress } = accounts[activeAccountType][activeAccountId];
|
|
850
856
|
const sendERC20Token = async () => {
|
|
851
|
-
const currentWallet = new
|
|
857
|
+
const currentWallet = new wallet_1.Wallet(decryptedPrivateKey);
|
|
852
858
|
const walletSigned = currentWallet.connect(this.web3Provider);
|
|
853
859
|
try {
|
|
854
|
-
const _contract = new
|
|
855
|
-
const calculatedTokenAmount =
|
|
856
|
-
?
|
|
857
|
-
:
|
|
860
|
+
const _contract = new contracts_1.Contract(tokenAddress, (0, sysweb3_utils_1.getErc20Abi)(), walletSigned);
|
|
861
|
+
const calculatedTokenAmount = bignumber_1.BigNumber.from(decimals
|
|
862
|
+
? (0, units_1.parseUnits)(tokenAmount, this.toBigNumber(decimals))
|
|
863
|
+
: (0, units_1.parseEther)(tokenAmount));
|
|
858
864
|
let transferMethod;
|
|
859
865
|
if (isLegacy) {
|
|
860
866
|
const overrides = {
|
|
@@ -883,8 +889,8 @@ class EthereumTransactions {
|
|
|
883
889
|
const signer = this.web3Provider.getSigner(activeAccountAddress);
|
|
884
890
|
const transactionNonce = await this.getRecommendedNonce(activeAccountAddress);
|
|
885
891
|
try {
|
|
886
|
-
const _contract = new
|
|
887
|
-
const calculatedTokenAmount =
|
|
892
|
+
const _contract = new contracts_1.Contract(tokenAddress, (0, sysweb3_utils_1.getErc20Abi)(), signer);
|
|
893
|
+
const calculatedTokenAmount = bignumber_1.BigNumber.from((0, units_1.parseEther)(tokenAmount));
|
|
888
894
|
const txData = _contract.interface.encodeFunctionData('transfer', [
|
|
889
895
|
receiver,
|
|
890
896
|
calculatedTokenAmount,
|
|
@@ -917,7 +923,7 @@ class EthereumTransactions {
|
|
|
917
923
|
type: 2,
|
|
918
924
|
};
|
|
919
925
|
}
|
|
920
|
-
const rawTx =
|
|
926
|
+
const rawTx = (0, transactions_1.serialize)(txFormattedForEthers);
|
|
921
927
|
const signature = await this.ledgerSigner.evm.signEVMTransaction({
|
|
922
928
|
rawTx: rawTx.replace('0x', ''),
|
|
923
929
|
accountIndex: activeAccountId,
|
|
@@ -929,7 +935,7 @@ class EthereumTransactions {
|
|
|
929
935
|
};
|
|
930
936
|
if (signature) {
|
|
931
937
|
try {
|
|
932
|
-
const signedTx =
|
|
938
|
+
const signedTx = (0, transactions_1.serialize)(txFormattedForEthers, formattedSignature);
|
|
933
939
|
const finalTx = await this.web3Provider.sendTransaction(signedTx);
|
|
934
940
|
saveTrezorTx && saveTrezorTx(finalTx);
|
|
935
941
|
return finalTx;
|
|
@@ -950,8 +956,8 @@ class EthereumTransactions {
|
|
|
950
956
|
const signer = this.web3Provider.getSigner(activeAccountAddress);
|
|
951
957
|
const transactionNonce = await this.getRecommendedNonce(activeAccountAddress);
|
|
952
958
|
try {
|
|
953
|
-
const _contract = new
|
|
954
|
-
const calculatedTokenAmount =
|
|
959
|
+
const _contract = new contracts_1.Contract(tokenAddress, (0, sysweb3_utils_1.getErc20Abi)(), signer);
|
|
960
|
+
const calculatedTokenAmount = bignumber_1.BigNumber.from((0, units_1.parseEther)(tokenAmount));
|
|
955
961
|
const txData = _contract.interface.encodeFunctionData('transfer', [
|
|
956
962
|
receiver,
|
|
957
963
|
calculatedTokenAmount,
|
|
@@ -1022,7 +1028,7 @@ class EthereumTransactions {
|
|
|
1022
1028
|
};
|
|
1023
1029
|
}
|
|
1024
1030
|
signature.payload.v = parseInt(signature.payload.v, 16); //v parameter must be a number by ethers standards
|
|
1025
|
-
const signedTx =
|
|
1031
|
+
const signedTx = (0, transactions_1.serialize)(txFormattedForEthers, signature.payload);
|
|
1026
1032
|
const finalTx = await this.web3Provider.sendTransaction(signedTx);
|
|
1027
1033
|
saveTrezorTx && saveTrezorTx(finalTx);
|
|
1028
1034
|
return finalTx;
|
|
@@ -1053,11 +1059,11 @@ class EthereumTransactions {
|
|
|
1053
1059
|
const { accounts, activeAccountType, activeAccountId, activeNetwork } = this.getState();
|
|
1054
1060
|
const { address: activeAccountAddress } = accounts[activeAccountType][activeAccountId];
|
|
1055
1061
|
const sendERC721Token = async () => {
|
|
1056
|
-
const currentWallet = new
|
|
1062
|
+
const currentWallet = new wallet_1.Wallet(decryptedPrivateKey);
|
|
1057
1063
|
const walletSigned = currentWallet.connect(this.web3Provider);
|
|
1058
1064
|
let transferMethod;
|
|
1059
1065
|
try {
|
|
1060
|
-
const _contract = new
|
|
1066
|
+
const _contract = new contracts_1.Contract(tokenAddress, (0, sysweb3_utils_1.getErc21Abi)(), walletSigned);
|
|
1061
1067
|
if (isLegacy) {
|
|
1062
1068
|
const overrides = {
|
|
1063
1069
|
nonce: await this.web3Provider.getTransactionCount(walletSigned.address, 'pending'),
|
|
@@ -1082,7 +1088,7 @@ class EthereumTransactions {
|
|
|
1082
1088
|
const signer = this.web3Provider.getSigner(activeAccountAddress);
|
|
1083
1089
|
const transactionNonce = await this.getRecommendedNonce(activeAccountAddress);
|
|
1084
1090
|
try {
|
|
1085
|
-
const _contract = new
|
|
1091
|
+
const _contract = new contracts_1.Contract(tokenAddress, (0, sysweb3_utils_1.getErc21Abi)(), signer);
|
|
1086
1092
|
const txData = _contract.interface.encodeFunctionData('transferFrom', [
|
|
1087
1093
|
activeAccountAddress,
|
|
1088
1094
|
receiver,
|
|
@@ -1116,7 +1122,7 @@ class EthereumTransactions {
|
|
|
1116
1122
|
type: 2,
|
|
1117
1123
|
};
|
|
1118
1124
|
}
|
|
1119
|
-
const rawTx =
|
|
1125
|
+
const rawTx = (0, transactions_1.serialize)(txFormattedForEthers);
|
|
1120
1126
|
const signature = await this.ledgerSigner.evm.signEVMTransaction({
|
|
1121
1127
|
rawTx: rawTx.replace('0x', ''),
|
|
1122
1128
|
accountIndex: activeAccountId,
|
|
@@ -1128,7 +1134,7 @@ class EthereumTransactions {
|
|
|
1128
1134
|
};
|
|
1129
1135
|
if (signature) {
|
|
1130
1136
|
try {
|
|
1131
|
-
const signedTx =
|
|
1137
|
+
const signedTx = (0, transactions_1.serialize)(txFormattedForEthers, formattedSignature);
|
|
1132
1138
|
const finalTx = await this.web3Provider.sendTransaction(signedTx);
|
|
1133
1139
|
return finalTx;
|
|
1134
1140
|
}
|
|
@@ -1148,7 +1154,7 @@ class EthereumTransactions {
|
|
|
1148
1154
|
const signer = this.web3Provider.getSigner(activeAccountAddress);
|
|
1149
1155
|
const transactionNonce = await this.getRecommendedNonce(activeAccountAddress);
|
|
1150
1156
|
try {
|
|
1151
|
-
const _contract = new
|
|
1157
|
+
const _contract = new contracts_1.Contract(tokenAddress, (0, sysweb3_utils_1.getErc21Abi)(), signer);
|
|
1152
1158
|
const txData = _contract.interface.encodeFunctionData('transferFrom', [
|
|
1153
1159
|
activeAccountAddress,
|
|
1154
1160
|
receiver,
|
|
@@ -1223,7 +1229,7 @@ class EthereumTransactions {
|
|
|
1223
1229
|
};
|
|
1224
1230
|
}
|
|
1225
1231
|
signature.payload.v = parseInt(signature.payload.v, 16); //v parameter must be a number by ethers standards
|
|
1226
|
-
const signedTx =
|
|
1232
|
+
const signedTx = (0, transactions_1.serialize)(txFormattedForEthers, signature.payload);
|
|
1227
1233
|
const finalTx = await this.web3Provider.sendTransaction(signedTx);
|
|
1228
1234
|
return finalTx;
|
|
1229
1235
|
}
|
|
@@ -1255,11 +1261,11 @@ class EthereumTransactions {
|
|
|
1255
1261
|
const { accounts, activeAccountType, activeAccountId, activeNetwork } = this.getState();
|
|
1256
1262
|
const { address: activeAccountAddress } = accounts[activeAccountType][activeAccountId];
|
|
1257
1263
|
const sendERC1155Token = async () => {
|
|
1258
|
-
const currentWallet = new
|
|
1264
|
+
const currentWallet = new wallet_1.Wallet(decryptedPrivateKey);
|
|
1259
1265
|
const walletSigned = currentWallet.connect(this.web3Provider);
|
|
1260
1266
|
let transferMethod;
|
|
1261
1267
|
try {
|
|
1262
|
-
const _contract = new
|
|
1268
|
+
const _contract = new contracts_1.Contract(tokenAddress, (0, sysweb3_utils_1.getErc55Abi)(), walletSigned);
|
|
1263
1269
|
const amount = tokenAmount ? parseInt(tokenAmount) : 1;
|
|
1264
1270
|
const overrides = {};
|
|
1265
1271
|
transferMethod = await _contract.safeTransferFrom(walletSigned.address, receiver, tokenId, amount, [], overrides);
|
|
@@ -1273,7 +1279,7 @@ class EthereumTransactions {
|
|
|
1273
1279
|
const signer = this.web3Provider.getSigner(activeAccountAddress);
|
|
1274
1280
|
const transactionNonce = await this.getRecommendedNonce(activeAccountAddress);
|
|
1275
1281
|
try {
|
|
1276
|
-
const _contract = new
|
|
1282
|
+
const _contract = new contracts_1.Contract(tokenAddress, (0, sysweb3_utils_1.getErc55Abi)(), signer);
|
|
1277
1283
|
const amount = tokenAmount ? parseInt(tokenAmount) : 1;
|
|
1278
1284
|
const txData = _contract.interface.encodeFunctionData('safeTransferFrom', [activeAccountAddress, receiver, tokenId, amount, []]);
|
|
1279
1285
|
// Use fallback gas limit if not provided (for auto-estimation)
|
|
@@ -1304,7 +1310,7 @@ class EthereumTransactions {
|
|
|
1304
1310
|
type: 2,
|
|
1305
1311
|
};
|
|
1306
1312
|
}
|
|
1307
|
-
const rawTx =
|
|
1313
|
+
const rawTx = (0, transactions_1.serialize)(txFormattedForEthers);
|
|
1308
1314
|
const signature = await this.ledgerSigner.evm.signEVMTransaction({
|
|
1309
1315
|
rawTx: rawTx.replace('0x', ''),
|
|
1310
1316
|
accountIndex: activeAccountId,
|
|
@@ -1316,7 +1322,7 @@ class EthereumTransactions {
|
|
|
1316
1322
|
};
|
|
1317
1323
|
if (signature) {
|
|
1318
1324
|
try {
|
|
1319
|
-
const signedTx =
|
|
1325
|
+
const signedTx = (0, transactions_1.serialize)(txFormattedForEthers, formattedSignature);
|
|
1320
1326
|
const finalTx = await this.web3Provider.sendTransaction(signedTx);
|
|
1321
1327
|
return finalTx;
|
|
1322
1328
|
}
|
|
@@ -1336,7 +1342,7 @@ class EthereumTransactions {
|
|
|
1336
1342
|
const signer = this.web3Provider.getSigner(activeAccountAddress);
|
|
1337
1343
|
const transactionNonce = await this.getRecommendedNonce(activeAccountAddress);
|
|
1338
1344
|
try {
|
|
1339
|
-
const _contract = new
|
|
1345
|
+
const _contract = new contracts_1.Contract(tokenAddress, (0, sysweb3_utils_1.getErc55Abi)(), signer);
|
|
1340
1346
|
const amount = tokenAmount ? parseInt(tokenAmount) : 1;
|
|
1341
1347
|
const txData = _contract.interface.encodeFunctionData('safeTransferFrom', [activeAccountAddress, receiver, tokenId, amount, []]);
|
|
1342
1348
|
// Use fallback gas limit if not provided (for auto-estimation)
|
|
@@ -1405,7 +1411,7 @@ class EthereumTransactions {
|
|
|
1405
1411
|
};
|
|
1406
1412
|
}
|
|
1407
1413
|
signature.payload.v = parseInt(signature.payload.v, 16); //v parameter must be a number by ethers standards
|
|
1408
|
-
const signedTx =
|
|
1414
|
+
const signedTx = (0, transactions_1.serialize)(txFormattedForEthers, signature.payload);
|
|
1409
1415
|
const finalTx = await this.web3Provider.sendTransaction(signedTx);
|
|
1410
1416
|
return finalTx;
|
|
1411
1417
|
}
|
|
@@ -1443,12 +1449,12 @@ class EthereumTransactions {
|
|
|
1443
1449
|
this.getFeeByType = async (type) => {
|
|
1444
1450
|
const gasPrice = (await this.getRecommendedGasPrice(false));
|
|
1445
1451
|
const low = this.toBigNumber(gasPrice)
|
|
1446
|
-
.mul(
|
|
1447
|
-
.div(
|
|
1452
|
+
.mul(bignumber_1.BigNumber.from('8'))
|
|
1453
|
+
.div(bignumber_1.BigNumber.from('10'))
|
|
1448
1454
|
.toString();
|
|
1449
1455
|
const high = this.toBigNumber(gasPrice)
|
|
1450
|
-
.mul(
|
|
1451
|
-
.div(
|
|
1456
|
+
.mul(bignumber_1.BigNumber.from('11'))
|
|
1457
|
+
.div(bignumber_1.BigNumber.from('10'))
|
|
1452
1458
|
.toString();
|
|
1453
1459
|
if (type === 'low')
|
|
1454
1460
|
return low;
|
|
@@ -1461,7 +1467,7 @@ class EthereumTransactions {
|
|
|
1461
1467
|
const estimated = await this.web3Provider.estimateGas({
|
|
1462
1468
|
to: toAddress,
|
|
1463
1469
|
});
|
|
1464
|
-
return Number(
|
|
1470
|
+
return Number((0, units_1.formatUnits)(estimated, 'gwei'));
|
|
1465
1471
|
}
|
|
1466
1472
|
catch (error) {
|
|
1467
1473
|
throw error;
|
|
@@ -1480,8 +1486,8 @@ class EthereumTransactions {
|
|
|
1480
1486
|
const gasPriceBN = await this.web3Provider.getGasPrice();
|
|
1481
1487
|
if (formatted) {
|
|
1482
1488
|
return {
|
|
1483
|
-
gwei: Number(
|
|
1484
|
-
ethers:
|
|
1489
|
+
gwei: Number((0, units_1.formatUnits)(gasPriceBN, 'gwei')).toFixed(2),
|
|
1490
|
+
ethers: (0, units_1.formatEther)(gasPriceBN),
|
|
1485
1491
|
};
|
|
1486
1492
|
}
|
|
1487
1493
|
return gasPriceBN.toString();
|
|
@@ -1493,7 +1499,7 @@ class EthereumTransactions {
|
|
|
1493
1499
|
this.getBalance = async (address) => {
|
|
1494
1500
|
try {
|
|
1495
1501
|
const balance = await this.web3Provider.getBalance(address);
|
|
1496
|
-
const formattedBalance =
|
|
1502
|
+
const formattedBalance = (0, units_1.formatEther)(balance);
|
|
1497
1503
|
return parseFloat(formattedBalance); // Return full precision
|
|
1498
1504
|
}
|
|
1499
1505
|
catch (error) {
|
|
@@ -1508,11 +1514,11 @@ class EthereumTransactions {
|
|
|
1508
1514
|
};
|
|
1509
1515
|
};
|
|
1510
1516
|
this.importAccount = (mnemonicOrPrivKey) => {
|
|
1511
|
-
if (
|
|
1512
|
-
return new
|
|
1517
|
+
if ((0, bytes_1.isHexString)(mnemonicOrPrivKey)) {
|
|
1518
|
+
return new wallet_1.Wallet(mnemonicOrPrivKey);
|
|
1513
1519
|
}
|
|
1514
|
-
const { privateKey } =
|
|
1515
|
-
const account = new
|
|
1520
|
+
const { privateKey } = wallet_1.Wallet.fromMnemonic(mnemonicOrPrivKey);
|
|
1521
|
+
const account = new wallet_1.Wallet(privateKey);
|
|
1516
1522
|
return account;
|
|
1517
1523
|
};
|
|
1518
1524
|
this.getNetwork = getNetwork;
|