@reactmore/crypto-wallet-sdk 1.3.0 → 1.3.1
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/dist/crypto-wallet-sdk.cjs.development.js +94 -88
- package/dist/crypto-wallet-sdk.cjs.development.js.map +1 -1
- package/dist/crypto-wallet-sdk.cjs.production.min.js +1 -1
- package/dist/crypto-wallet-sdk.cjs.production.min.js.map +1 -1
- package/dist/crypto-wallet-sdk.esm.js +94 -88
- package/dist/crypto-wallet-sdk.esm.js.map +1 -1
- package/dist/services/evm/types.d.ts +7 -8
- package/package.json +1 -1
|
@@ -938,7 +938,7 @@ var EvmWallet = /*#__PURE__*/function (_BaseWallet) {
|
|
|
938
938
|
}();
|
|
939
939
|
_proto.transfer = /*#__PURE__*/function () {
|
|
940
940
|
var _transfer = /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee4(_ref4) {
|
|
941
|
-
var privateKey, contractAddress, rpcUrl, args, _yield$this$getContra2, contract, providerInstance, gasFeeData, nonce, recipientAddress, prio, max,
|
|
941
|
+
var privateKey, contractAddress, rpcUrl, args, _yield$this$getContra2, contract, providerInstance, gasFeeData, nonce, signer, recipientAddress, prio, max, txTo, txData, txValue, gasLimit, decimals, amount, noFeeProvided, estimate, fee, signParams, signedTx, broadcast, _t2, _t3, _t4, _t5, _t6;
|
|
942
942
|
return _regenerator().w(function (_context4) {
|
|
943
943
|
while (1) switch (_context4.n) {
|
|
944
944
|
case 0:
|
|
@@ -955,6 +955,7 @@ var EvmWallet = /*#__PURE__*/function (_BaseWallet) {
|
|
|
955
955
|
providerInstance = _yield$this$getContra2.providerInstance;
|
|
956
956
|
gasFeeData = _yield$this$getContra2.gasFeeData;
|
|
957
957
|
nonce = _yield$this$getContra2.nonce;
|
|
958
|
+
signer = _yield$this$getContra2.signer;
|
|
958
959
|
_context4.n = 2;
|
|
959
960
|
return this.wallet.validAddress({
|
|
960
961
|
address: args.recipientAddress
|
|
@@ -965,7 +966,7 @@ var EvmWallet = /*#__PURE__*/function (_BaseWallet) {
|
|
|
965
966
|
_context4.n = 3;
|
|
966
967
|
break;
|
|
967
968
|
}
|
|
968
|
-
throw new Error("address not valid");
|
|
969
|
+
throw new Error("recipient address not valid");
|
|
969
970
|
case 3:
|
|
970
971
|
if (!(args.maxPriorityFeePerGas && args.maxFeePerGas)) {
|
|
971
972
|
_context4.n = 4;
|
|
@@ -983,10 +984,10 @@ var EvmWallet = /*#__PURE__*/function (_BaseWallet) {
|
|
|
983
984
|
_context4.n = 5;
|
|
984
985
|
break;
|
|
985
986
|
}
|
|
986
|
-
throw new Error("Cannot
|
|
987
|
+
throw new Error("Cannot mix gasPrice with EIP-1559 fields");
|
|
987
988
|
case 5:
|
|
988
989
|
if (!contractAddress) {
|
|
989
|
-
_context4.n =
|
|
990
|
+
_context4.n = 12;
|
|
990
991
|
break;
|
|
991
992
|
}
|
|
992
993
|
if (contract) {
|
|
@@ -999,93 +1000,97 @@ var EvmWallet = /*#__PURE__*/function (_BaseWallet) {
|
|
|
999
1000
|
return contract.decimals();
|
|
1000
1001
|
case 7:
|
|
1001
1002
|
decimals = _context4.v;
|
|
1002
|
-
|
|
1003
|
+
amount = parseAmount(args.amount.toString(), decimals);
|
|
1004
|
+
txData = contract["interface"].encodeFunctionData("transfer", [args.recipientAddress, amount]);
|
|
1005
|
+
txTo = contractAddress;
|
|
1006
|
+
txValue = 0n;
|
|
1003
1007
|
if (!args.gasLimit) {
|
|
1004
1008
|
_context4.n = 8;
|
|
1005
1009
|
break;
|
|
1006
1010
|
}
|
|
1007
1011
|
_t2 = BigInt(args.gasLimit);
|
|
1008
|
-
_context4.n =
|
|
1012
|
+
_context4.n = 11;
|
|
1009
1013
|
break;
|
|
1010
1014
|
case 8:
|
|
1015
|
+
_t3 = providerInstance;
|
|
1011
1016
|
_context4.n = 9;
|
|
1012
|
-
return
|
|
1017
|
+
return signer.getAddress();
|
|
1013
1018
|
case 9:
|
|
1014
|
-
|
|
1019
|
+
_t4 = _context4.v;
|
|
1020
|
+
_t5 = contractAddress;
|
|
1021
|
+
_t6 = txData;
|
|
1022
|
+
_context4.n = 10;
|
|
1023
|
+
return _t3.estimateGas.call(_t3, {
|
|
1024
|
+
from: _t4,
|
|
1025
|
+
to: _t5,
|
|
1026
|
+
data: _t6
|
|
1027
|
+
});
|
|
1015
1028
|
case 10:
|
|
1029
|
+
_t2 = _context4.v;
|
|
1030
|
+
case 11:
|
|
1016
1031
|
gasLimit = _t2;
|
|
1017
|
-
_context4.n =
|
|
1032
|
+
_context4.n = 13;
|
|
1018
1033
|
break;
|
|
1019
|
-
case 11:
|
|
1020
|
-
value = parseEther(args.amount.toString());
|
|
1021
|
-
gasLimit = args.gasLimit ? BigInt(args.gasLimit) : 21000n;
|
|
1022
1034
|
case 12:
|
|
1023
|
-
//
|
|
1035
|
+
// ===== NATIVE TRANSFER =====
|
|
1036
|
+
txTo = args.recipientAddress;
|
|
1037
|
+
txValue = parseEther(args.amount.toString());
|
|
1038
|
+
txData = args.data ? ethers.ethers.hexlify(ethers.ethers.toUtf8Bytes(args.data)) : '0x';
|
|
1039
|
+
gasLimit = args.gasLimit ? BigInt(args.gasLimit) : 21000n;
|
|
1040
|
+
case 13:
|
|
1041
|
+
// =========================
|
|
1042
|
+
// AUTO ESTIMATE FEE
|
|
1043
|
+
// =========================
|
|
1024
1044
|
noFeeProvided = !args.gasPrice && !args.maxFeePerGas && !args.maxPriorityFeePerGas;
|
|
1025
|
-
if (!noFeeProvided) {
|
|
1026
|
-
_context4.n =
|
|
1045
|
+
if (!(noFeeProvided && !contractAddress)) {
|
|
1046
|
+
_context4.n = 16;
|
|
1027
1047
|
break;
|
|
1028
1048
|
}
|
|
1029
|
-
_context4.n =
|
|
1049
|
+
_context4.n = 14;
|
|
1030
1050
|
return this.estimateGas({
|
|
1031
1051
|
rpcUrl: rpcUrl != null ? rpcUrl : this.config.rpcUrl,
|
|
1032
|
-
recipientAddress:
|
|
1052
|
+
recipientAddress: txTo,
|
|
1033
1053
|
amount: args.amount.toString(),
|
|
1034
|
-
data:
|
|
1054
|
+
data: txData !== '0x' ? txData : undefined
|
|
1035
1055
|
});
|
|
1036
|
-
case
|
|
1056
|
+
case 14:
|
|
1037
1057
|
estimate = _context4.v;
|
|
1038
1058
|
gasLimit = BigInt(estimate.gasLimit);
|
|
1039
|
-
// ===== LEGACY =====
|
|
1040
1059
|
if (!(estimate.model === "LEGACY")) {
|
|
1041
1060
|
_context4.n = 15;
|
|
1042
1061
|
break;
|
|
1043
1062
|
}
|
|
1044
|
-
|
|
1045
|
-
_context4.n = 14;
|
|
1046
|
-
break;
|
|
1047
|
-
}
|
|
1048
|
-
throw new Error("LEGACY estimate missing gasPrice");
|
|
1049
|
-
case 14:
|
|
1050
|
-
args.gasPrice = estimate.gasPrice; // wei
|
|
1063
|
+
args.gasPrice = estimate.gasPrice;
|
|
1051
1064
|
return _context4.a(2, this.transfer(_extends({
|
|
1052
1065
|
privateKey: privateKey,
|
|
1053
1066
|
contractAddress: contractAddress,
|
|
1054
1067
|
rpcUrl: rpcUrl
|
|
1055
1068
|
}, args)));
|
|
1056
1069
|
case 15:
|
|
1057
|
-
// ===== EIP-1559 =====
|
|
1058
1070
|
fee = estimate.fees.regular;
|
|
1059
|
-
if (!(!(fee != null && fee.maxFeePerGas) || !(fee != null && fee.maxPriorityFeePerGas))) {
|
|
1060
|
-
_context4.n = 16;
|
|
1061
|
-
break;
|
|
1062
|
-
}
|
|
1063
|
-
throw new Error("EIP1559 estimate missing fee fields");
|
|
1064
|
-
case 16:
|
|
1065
1071
|
args.maxFeePerGas = fee.maxFeePerGas;
|
|
1066
1072
|
args.maxPriorityFeePerGas = fee.maxPriorityFeePerGas;
|
|
1067
|
-
case
|
|
1068
|
-
_context4.n =
|
|
1073
|
+
case 16:
|
|
1074
|
+
_context4.n = 17;
|
|
1069
1075
|
return this.buildSignParams({
|
|
1070
|
-
|
|
1071
|
-
privateKey: privateKey,
|
|
1072
|
-
gasLimit: gasLimit
|
|
1073
|
-
}),
|
|
1076
|
+
privateKey: privateKey,
|
|
1074
1077
|
nonce: nonce,
|
|
1075
1078
|
gasFeeData: gasFeeData,
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
+
txTo: txTo,
|
|
1080
|
+
txData: txData,
|
|
1081
|
+
txValue: txValue,
|
|
1082
|
+
gasLimit: gasLimit,
|
|
1083
|
+
args: args
|
|
1079
1084
|
});
|
|
1080
|
-
case
|
|
1085
|
+
case 17:
|
|
1081
1086
|
signParams = _context4.v;
|
|
1082
|
-
_context4.n =
|
|
1087
|
+
_context4.n = 18;
|
|
1083
1088
|
return this.wallet.signTransaction(signParams);
|
|
1084
|
-
case
|
|
1089
|
+
case 18:
|
|
1085
1090
|
signedTx = _context4.v;
|
|
1086
|
-
_context4.n =
|
|
1091
|
+
_context4.n = 19;
|
|
1087
1092
|
return providerInstance.broadcastTransaction(signedTx);
|
|
1088
|
-
case
|
|
1093
|
+
case 19:
|
|
1089
1094
|
broadcast = _context4.v;
|
|
1090
1095
|
return _context4.a(2, successResponse(_extends({}, broadcast)));
|
|
1091
1096
|
}
|
|
@@ -1098,7 +1103,7 @@ var EvmWallet = /*#__PURE__*/function (_BaseWallet) {
|
|
|
1098
1103
|
}();
|
|
1099
1104
|
_proto.getTransaction = /*#__PURE__*/function () {
|
|
1100
1105
|
var _getTransaction = /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee5(_ref5) {
|
|
1101
|
-
var hash, rpcUrl, withReceipt, _yield$this$getContra3, providerInstance, _yield$Promise$all, _tx, receipt, memo, tx,
|
|
1106
|
+
var hash, rpcUrl, withReceipt, _yield$this$getContra3, providerInstance, _yield$Promise$all, _tx, receipt, memo, tx, _t7;
|
|
1102
1107
|
return _regenerator().w(function (_context5) {
|
|
1103
1108
|
while (1) switch (_context5.p = _context5.n) {
|
|
1104
1109
|
case 0:
|
|
@@ -1137,8 +1142,8 @@ var EvmWallet = /*#__PURE__*/function (_BaseWallet) {
|
|
|
1137
1142
|
}));
|
|
1138
1143
|
case 6:
|
|
1139
1144
|
_context5.p = 6;
|
|
1140
|
-
|
|
1141
|
-
throw
|
|
1145
|
+
_t7 = _context5.v;
|
|
1146
|
+
throw _t7;
|
|
1142
1147
|
case 7:
|
|
1143
1148
|
return _context5.a(2);
|
|
1144
1149
|
}
|
|
@@ -1198,7 +1203,7 @@ var EvmWallet = /*#__PURE__*/function (_BaseWallet) {
|
|
|
1198
1203
|
_proto.smartContractCall = /*#__PURE__*/function () {
|
|
1199
1204
|
var _smartContractCall = /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee7(args) {
|
|
1200
1205
|
var _args$rpcUrl;
|
|
1201
|
-
var _yield$this$getContra5, contract, gasFeeData, nonce, tx, overrides,
|
|
1206
|
+
var _yield$this$getContra5, contract, gasFeeData, nonce, tx, overrides, _t8;
|
|
1202
1207
|
return _regenerator().w(function (_context7) {
|
|
1203
1208
|
while (1) switch (_context7.p = _context7.n) {
|
|
1204
1209
|
case 0:
|
|
@@ -1249,8 +1254,8 @@ var EvmWallet = /*#__PURE__*/function (_BaseWallet) {
|
|
|
1249
1254
|
}));
|
|
1250
1255
|
case 7:
|
|
1251
1256
|
_context7.p = 7;
|
|
1252
|
-
|
|
1253
|
-
throw
|
|
1257
|
+
_t8 = _context7.v;
|
|
1258
|
+
throw _t8;
|
|
1254
1259
|
case 8:
|
|
1255
1260
|
return _context7.a(2);
|
|
1256
1261
|
}
|
|
@@ -1263,7 +1268,7 @@ var EvmWallet = /*#__PURE__*/function (_BaseWallet) {
|
|
|
1263
1268
|
}();
|
|
1264
1269
|
_proto.estimateGas = /*#__PURE__*/function () {
|
|
1265
1270
|
var _estimateGas = /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee8(_ref7) {
|
|
1266
|
-
var rpcUrl, recipientAddress, amount, data, _yield$this$getContra6, providerInstance, _block$baseFeePerGas, _feeData$maxPriorityF, network, chainId, tx, _yield$Promise$all3, feeData, gasLimit, gasPrice, maxFeePerGas, maxPriorityFeePerGas, applyMultiplier, isEip1559, baseGasPrice, regularGasPrice, expressGasPrice, instantGasPrice, _regularFee, _expressFee, _instantFee, baseFee, priorityFee, block, regularPriority, regularMaxFee, expressPriority, expressMaxFee, instantPriority, instantMaxFee, MAX_GAS_GWEI, cap, regularFee, expressFee, instantFee,
|
|
1271
|
+
var rpcUrl, recipientAddress, amount, data, _yield$this$getContra6, providerInstance, _block$baseFeePerGas, _feeData$maxPriorityF, network, chainId, tx, _yield$Promise$all3, feeData, gasLimit, gasPrice, maxFeePerGas, maxPriorityFeePerGas, applyMultiplier, isEip1559, baseGasPrice, regularGasPrice, expressGasPrice, instantGasPrice, _regularFee, _expressFee, _instantFee, baseFee, priorityFee, block, regularPriority, regularMaxFee, expressPriority, expressMaxFee, instantPriority, instantMaxFee, MAX_GAS_GWEI, cap, regularFee, expressFee, instantFee, _t9;
|
|
1267
1272
|
return _regenerator().w(function (_context8) {
|
|
1268
1273
|
while (1) switch (_context8.p = _context8.n) {
|
|
1269
1274
|
case 0:
|
|
@@ -1366,8 +1371,8 @@ var EvmWallet = /*#__PURE__*/function (_BaseWallet) {
|
|
|
1366
1371
|
}));
|
|
1367
1372
|
case 7:
|
|
1368
1373
|
_context8.p = 7;
|
|
1369
|
-
|
|
1370
|
-
throw
|
|
1374
|
+
_t9 = _context8.v;
|
|
1375
|
+
throw _t9;
|
|
1371
1376
|
case 8:
|
|
1372
1377
|
return _context8.a(2);
|
|
1373
1378
|
}
|
|
@@ -1380,56 +1385,57 @@ var EvmWallet = /*#__PURE__*/function (_BaseWallet) {
|
|
|
1380
1385
|
}();
|
|
1381
1386
|
_proto.buildSignParams = /*#__PURE__*/function () {
|
|
1382
1387
|
var _buildSignParams = /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee9(_ref8) {
|
|
1383
|
-
var
|
|
1388
|
+
var _args$nonce, _args$maxPriorityFeeP, _args$maxFeePerGas;
|
|
1389
|
+
var privateKey, nonce, gasFeeData, txTo, txData, txValue, gasLimit, args, txBase, _t0, _t1, _t10, _t11, _t12, _t13, _t14;
|
|
1384
1390
|
return _regenerator().w(function (_context9) {
|
|
1385
1391
|
while (1) switch (_context9.n) {
|
|
1386
1392
|
case 0:
|
|
1387
|
-
|
|
1388
|
-
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
|
|
1392
|
-
|
|
1393
|
-
if (_t0) {
|
|
1394
|
-
_context9.n = 2;
|
|
1393
|
+
privateKey = _ref8.privateKey, nonce = _ref8.nonce, gasFeeData = _ref8.gasFeeData, txTo = _ref8.txTo, txData = _ref8.txData, txValue = _ref8.txValue, gasLimit = _ref8.gasLimit, args = _ref8.args;
|
|
1394
|
+
_t0 = txTo;
|
|
1395
|
+
_t1 = cryptoLib.BigNumber(txValue.toString());
|
|
1396
|
+
_t10 = txData;
|
|
1397
|
+
if (!((_args$nonce = args.nonce) != null)) {
|
|
1398
|
+
_context9.n = 1;
|
|
1395
1399
|
break;
|
|
1396
1400
|
}
|
|
1397
|
-
|
|
1398
|
-
|
|
1401
|
+
_t11 = _args$nonce;
|
|
1402
|
+
_context9.n = 3;
|
|
1403
|
+
break;
|
|
1399
1404
|
case 1:
|
|
1400
|
-
|
|
1405
|
+
_context9.n = 2;
|
|
1406
|
+
return nonce;
|
|
1401
1407
|
case 2:
|
|
1402
|
-
|
|
1403
|
-
|
|
1404
|
-
|
|
1405
|
-
|
|
1406
|
-
|
|
1407
|
-
|
|
1408
|
-
|
|
1409
|
-
|
|
1410
|
-
|
|
1411
|
-
|
|
1412
|
-
|
|
1413
|
-
|
|
1414
|
-
}
|
|
1408
|
+
_t11 = _context9.v;
|
|
1409
|
+
case 3:
|
|
1410
|
+
_t12 = _t11;
|
|
1411
|
+
_t13 = cryptoLib.BigNumber(gasLimit.toString());
|
|
1412
|
+
_t14 = Number(this.currentChain.id);
|
|
1413
|
+
txBase = {
|
|
1414
|
+
to: _t0,
|
|
1415
|
+
value: _t1,
|
|
1416
|
+
data: _t10,
|
|
1417
|
+
nonce: _t12,
|
|
1418
|
+
gasLimit: _t13,
|
|
1419
|
+
chainId: _t14
|
|
1420
|
+
};
|
|
1415
1421
|
if (!args.gasPrice) {
|
|
1416
|
-
_context9.n =
|
|
1422
|
+
_context9.n = 4;
|
|
1417
1423
|
break;
|
|
1418
1424
|
}
|
|
1419
1425
|
return _context9.a(2, {
|
|
1420
|
-
privateKey:
|
|
1426
|
+
privateKey: privateKey,
|
|
1421
1427
|
data: _extends({}, txBase, {
|
|
1422
1428
|
gasPrice: cryptoLib.BigNumber(parseGwei(args.gasPrice).toString()),
|
|
1423
1429
|
type: 0
|
|
1424
1430
|
})
|
|
1425
1431
|
});
|
|
1426
|
-
case
|
|
1432
|
+
case 4:
|
|
1427
1433
|
return _context9.a(2, {
|
|
1428
|
-
privateKey:
|
|
1434
|
+
privateKey: privateKey,
|
|
1429
1435
|
data: _extends({}, txBase, {
|
|
1430
1436
|
type: 2,
|
|
1431
|
-
maxPriorityFeePerGas: cryptoLib.BigNumber(args.maxPriorityFeePerGas ?
|
|
1432
|
-
maxFeePerGas: cryptoLib.BigNumber(args.maxFeePerGas ?
|
|
1437
|
+
maxPriorityFeePerGas: cryptoLib.BigNumber((_args$maxPriorityFeeP = args.maxPriorityFeePerGas) != null ? _args$maxPriorityFeeP : gasFeeData.maxPriorityFeePerGas.toString()),
|
|
1438
|
+
maxFeePerGas: cryptoLib.BigNumber((_args$maxFeePerGas = args.maxFeePerGas) != null ? _args$maxFeePerGas : gasFeeData.maxFeePerGas.toString())
|
|
1433
1439
|
})
|
|
1434
1440
|
});
|
|
1435
1441
|
}
|