@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
|
@@ -932,7 +932,7 @@ var EvmWallet = /*#__PURE__*/function (_BaseWallet) {
|
|
|
932
932
|
}();
|
|
933
933
|
_proto.transfer = /*#__PURE__*/function () {
|
|
934
934
|
var _transfer = /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee4(_ref4) {
|
|
935
|
-
var privateKey, contractAddress, rpcUrl, args, _yield$this$getContra2, contract, providerInstance, gasFeeData, nonce, recipientAddress, prio, max,
|
|
935
|
+
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;
|
|
936
936
|
return _regenerator().w(function (_context4) {
|
|
937
937
|
while (1) switch (_context4.n) {
|
|
938
938
|
case 0:
|
|
@@ -949,6 +949,7 @@ var EvmWallet = /*#__PURE__*/function (_BaseWallet) {
|
|
|
949
949
|
providerInstance = _yield$this$getContra2.providerInstance;
|
|
950
950
|
gasFeeData = _yield$this$getContra2.gasFeeData;
|
|
951
951
|
nonce = _yield$this$getContra2.nonce;
|
|
952
|
+
signer = _yield$this$getContra2.signer;
|
|
952
953
|
_context4.n = 2;
|
|
953
954
|
return this.wallet.validAddress({
|
|
954
955
|
address: args.recipientAddress
|
|
@@ -959,7 +960,7 @@ var EvmWallet = /*#__PURE__*/function (_BaseWallet) {
|
|
|
959
960
|
_context4.n = 3;
|
|
960
961
|
break;
|
|
961
962
|
}
|
|
962
|
-
throw new Error("address not valid");
|
|
963
|
+
throw new Error("recipient address not valid");
|
|
963
964
|
case 3:
|
|
964
965
|
if (!(args.maxPriorityFeePerGas && args.maxFeePerGas)) {
|
|
965
966
|
_context4.n = 4;
|
|
@@ -977,10 +978,10 @@ var EvmWallet = /*#__PURE__*/function (_BaseWallet) {
|
|
|
977
978
|
_context4.n = 5;
|
|
978
979
|
break;
|
|
979
980
|
}
|
|
980
|
-
throw new Error("Cannot
|
|
981
|
+
throw new Error("Cannot mix gasPrice with EIP-1559 fields");
|
|
981
982
|
case 5:
|
|
982
983
|
if (!contractAddress) {
|
|
983
|
-
_context4.n =
|
|
984
|
+
_context4.n = 12;
|
|
984
985
|
break;
|
|
985
986
|
}
|
|
986
987
|
if (contract) {
|
|
@@ -993,93 +994,97 @@ var EvmWallet = /*#__PURE__*/function (_BaseWallet) {
|
|
|
993
994
|
return contract.decimals();
|
|
994
995
|
case 7:
|
|
995
996
|
decimals = _context4.v;
|
|
996
|
-
|
|
997
|
+
amount = parseAmount(args.amount.toString(), decimals);
|
|
998
|
+
txData = contract["interface"].encodeFunctionData("transfer", [args.recipientAddress, amount]);
|
|
999
|
+
txTo = contractAddress;
|
|
1000
|
+
txValue = 0n;
|
|
997
1001
|
if (!args.gasLimit) {
|
|
998
1002
|
_context4.n = 8;
|
|
999
1003
|
break;
|
|
1000
1004
|
}
|
|
1001
1005
|
_t2 = BigInt(args.gasLimit);
|
|
1002
|
-
_context4.n =
|
|
1006
|
+
_context4.n = 11;
|
|
1003
1007
|
break;
|
|
1004
1008
|
case 8:
|
|
1009
|
+
_t3 = providerInstance;
|
|
1005
1010
|
_context4.n = 9;
|
|
1006
|
-
return
|
|
1011
|
+
return signer.getAddress();
|
|
1007
1012
|
case 9:
|
|
1008
|
-
|
|
1013
|
+
_t4 = _context4.v;
|
|
1014
|
+
_t5 = contractAddress;
|
|
1015
|
+
_t6 = txData;
|
|
1016
|
+
_context4.n = 10;
|
|
1017
|
+
return _t3.estimateGas.call(_t3, {
|
|
1018
|
+
from: _t4,
|
|
1019
|
+
to: _t5,
|
|
1020
|
+
data: _t6
|
|
1021
|
+
});
|
|
1009
1022
|
case 10:
|
|
1023
|
+
_t2 = _context4.v;
|
|
1024
|
+
case 11:
|
|
1010
1025
|
gasLimit = _t2;
|
|
1011
|
-
_context4.n =
|
|
1026
|
+
_context4.n = 13;
|
|
1012
1027
|
break;
|
|
1013
|
-
case 11:
|
|
1014
|
-
value = parseEther(args.amount.toString());
|
|
1015
|
-
gasLimit = args.gasLimit ? BigInt(args.gasLimit) : 21000n;
|
|
1016
1028
|
case 12:
|
|
1017
|
-
//
|
|
1029
|
+
// ===== NATIVE TRANSFER =====
|
|
1030
|
+
txTo = args.recipientAddress;
|
|
1031
|
+
txValue = parseEther(args.amount.toString());
|
|
1032
|
+
txData = args.data ? ethers.hexlify(ethers.toUtf8Bytes(args.data)) : '0x';
|
|
1033
|
+
gasLimit = args.gasLimit ? BigInt(args.gasLimit) : 21000n;
|
|
1034
|
+
case 13:
|
|
1035
|
+
// =========================
|
|
1036
|
+
// AUTO ESTIMATE FEE
|
|
1037
|
+
// =========================
|
|
1018
1038
|
noFeeProvided = !args.gasPrice && !args.maxFeePerGas && !args.maxPriorityFeePerGas;
|
|
1019
|
-
if (!noFeeProvided) {
|
|
1020
|
-
_context4.n =
|
|
1039
|
+
if (!(noFeeProvided && !contractAddress)) {
|
|
1040
|
+
_context4.n = 16;
|
|
1021
1041
|
break;
|
|
1022
1042
|
}
|
|
1023
|
-
_context4.n =
|
|
1043
|
+
_context4.n = 14;
|
|
1024
1044
|
return this.estimateGas({
|
|
1025
1045
|
rpcUrl: rpcUrl != null ? rpcUrl : this.config.rpcUrl,
|
|
1026
|
-
recipientAddress:
|
|
1046
|
+
recipientAddress: txTo,
|
|
1027
1047
|
amount: args.amount.toString(),
|
|
1028
|
-
data:
|
|
1048
|
+
data: txData !== '0x' ? txData : undefined
|
|
1029
1049
|
});
|
|
1030
|
-
case
|
|
1050
|
+
case 14:
|
|
1031
1051
|
estimate = _context4.v;
|
|
1032
1052
|
gasLimit = BigInt(estimate.gasLimit);
|
|
1033
|
-
// ===== LEGACY =====
|
|
1034
1053
|
if (!(estimate.model === "LEGACY")) {
|
|
1035
1054
|
_context4.n = 15;
|
|
1036
1055
|
break;
|
|
1037
1056
|
}
|
|
1038
|
-
|
|
1039
|
-
_context4.n = 14;
|
|
1040
|
-
break;
|
|
1041
|
-
}
|
|
1042
|
-
throw new Error("LEGACY estimate missing gasPrice");
|
|
1043
|
-
case 14:
|
|
1044
|
-
args.gasPrice = estimate.gasPrice; // wei
|
|
1057
|
+
args.gasPrice = estimate.gasPrice;
|
|
1045
1058
|
return _context4.a(2, this.transfer(_extends({
|
|
1046
1059
|
privateKey: privateKey,
|
|
1047
1060
|
contractAddress: contractAddress,
|
|
1048
1061
|
rpcUrl: rpcUrl
|
|
1049
1062
|
}, args)));
|
|
1050
1063
|
case 15:
|
|
1051
|
-
// ===== EIP-1559 =====
|
|
1052
1064
|
fee = estimate.fees.regular;
|
|
1053
|
-
if (!(!(fee != null && fee.maxFeePerGas) || !(fee != null && fee.maxPriorityFeePerGas))) {
|
|
1054
|
-
_context4.n = 16;
|
|
1055
|
-
break;
|
|
1056
|
-
}
|
|
1057
|
-
throw new Error("EIP1559 estimate missing fee fields");
|
|
1058
|
-
case 16:
|
|
1059
1065
|
args.maxFeePerGas = fee.maxFeePerGas;
|
|
1060
1066
|
args.maxPriorityFeePerGas = fee.maxPriorityFeePerGas;
|
|
1061
|
-
case
|
|
1062
|
-
_context4.n =
|
|
1067
|
+
case 16:
|
|
1068
|
+
_context4.n = 17;
|
|
1063
1069
|
return this.buildSignParams({
|
|
1064
|
-
|
|
1065
|
-
privateKey: privateKey,
|
|
1066
|
-
gasLimit: gasLimit
|
|
1067
|
-
}),
|
|
1070
|
+
privateKey: privateKey,
|
|
1068
1071
|
nonce: nonce,
|
|
1069
1072
|
gasFeeData: gasFeeData,
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
+
txTo: txTo,
|
|
1074
|
+
txData: txData,
|
|
1075
|
+
txValue: txValue,
|
|
1076
|
+
gasLimit: gasLimit,
|
|
1077
|
+
args: args
|
|
1073
1078
|
});
|
|
1074
|
-
case
|
|
1079
|
+
case 17:
|
|
1075
1080
|
signParams = _context4.v;
|
|
1076
|
-
_context4.n =
|
|
1081
|
+
_context4.n = 18;
|
|
1077
1082
|
return this.wallet.signTransaction(signParams);
|
|
1078
|
-
case
|
|
1083
|
+
case 18:
|
|
1079
1084
|
signedTx = _context4.v;
|
|
1080
|
-
_context4.n =
|
|
1085
|
+
_context4.n = 19;
|
|
1081
1086
|
return providerInstance.broadcastTransaction(signedTx);
|
|
1082
|
-
case
|
|
1087
|
+
case 19:
|
|
1083
1088
|
broadcast = _context4.v;
|
|
1084
1089
|
return _context4.a(2, successResponse(_extends({}, broadcast)));
|
|
1085
1090
|
}
|
|
@@ -1092,7 +1097,7 @@ var EvmWallet = /*#__PURE__*/function (_BaseWallet) {
|
|
|
1092
1097
|
}();
|
|
1093
1098
|
_proto.getTransaction = /*#__PURE__*/function () {
|
|
1094
1099
|
var _getTransaction = /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee5(_ref5) {
|
|
1095
|
-
var hash, rpcUrl, withReceipt, _yield$this$getContra3, providerInstance, _yield$Promise$all, _tx, receipt, memo, tx,
|
|
1100
|
+
var hash, rpcUrl, withReceipt, _yield$this$getContra3, providerInstance, _yield$Promise$all, _tx, receipt, memo, tx, _t7;
|
|
1096
1101
|
return _regenerator().w(function (_context5) {
|
|
1097
1102
|
while (1) switch (_context5.p = _context5.n) {
|
|
1098
1103
|
case 0:
|
|
@@ -1131,8 +1136,8 @@ var EvmWallet = /*#__PURE__*/function (_BaseWallet) {
|
|
|
1131
1136
|
}));
|
|
1132
1137
|
case 6:
|
|
1133
1138
|
_context5.p = 6;
|
|
1134
|
-
|
|
1135
|
-
throw
|
|
1139
|
+
_t7 = _context5.v;
|
|
1140
|
+
throw _t7;
|
|
1136
1141
|
case 7:
|
|
1137
1142
|
return _context5.a(2);
|
|
1138
1143
|
}
|
|
@@ -1192,7 +1197,7 @@ var EvmWallet = /*#__PURE__*/function (_BaseWallet) {
|
|
|
1192
1197
|
_proto.smartContractCall = /*#__PURE__*/function () {
|
|
1193
1198
|
var _smartContractCall = /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee7(args) {
|
|
1194
1199
|
var _args$rpcUrl;
|
|
1195
|
-
var _yield$this$getContra5, contract, gasFeeData, nonce, tx, overrides,
|
|
1200
|
+
var _yield$this$getContra5, contract, gasFeeData, nonce, tx, overrides, _t8;
|
|
1196
1201
|
return _regenerator().w(function (_context7) {
|
|
1197
1202
|
while (1) switch (_context7.p = _context7.n) {
|
|
1198
1203
|
case 0:
|
|
@@ -1243,8 +1248,8 @@ var EvmWallet = /*#__PURE__*/function (_BaseWallet) {
|
|
|
1243
1248
|
}));
|
|
1244
1249
|
case 7:
|
|
1245
1250
|
_context7.p = 7;
|
|
1246
|
-
|
|
1247
|
-
throw
|
|
1251
|
+
_t8 = _context7.v;
|
|
1252
|
+
throw _t8;
|
|
1248
1253
|
case 8:
|
|
1249
1254
|
return _context7.a(2);
|
|
1250
1255
|
}
|
|
@@ -1257,7 +1262,7 @@ var EvmWallet = /*#__PURE__*/function (_BaseWallet) {
|
|
|
1257
1262
|
}();
|
|
1258
1263
|
_proto.estimateGas = /*#__PURE__*/function () {
|
|
1259
1264
|
var _estimateGas = /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee8(_ref7) {
|
|
1260
|
-
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,
|
|
1265
|
+
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;
|
|
1261
1266
|
return _regenerator().w(function (_context8) {
|
|
1262
1267
|
while (1) switch (_context8.p = _context8.n) {
|
|
1263
1268
|
case 0:
|
|
@@ -1360,8 +1365,8 @@ var EvmWallet = /*#__PURE__*/function (_BaseWallet) {
|
|
|
1360
1365
|
}));
|
|
1361
1366
|
case 7:
|
|
1362
1367
|
_context8.p = 7;
|
|
1363
|
-
|
|
1364
|
-
throw
|
|
1368
|
+
_t9 = _context8.v;
|
|
1369
|
+
throw _t9;
|
|
1365
1370
|
case 8:
|
|
1366
1371
|
return _context8.a(2);
|
|
1367
1372
|
}
|
|
@@ -1374,56 +1379,57 @@ var EvmWallet = /*#__PURE__*/function (_BaseWallet) {
|
|
|
1374
1379
|
}();
|
|
1375
1380
|
_proto.buildSignParams = /*#__PURE__*/function () {
|
|
1376
1381
|
var _buildSignParams = /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee9(_ref8) {
|
|
1377
|
-
var
|
|
1382
|
+
var _args$nonce, _args$maxPriorityFeeP, _args$maxFeePerGas;
|
|
1383
|
+
var privateKey, nonce, gasFeeData, txTo, txData, txValue, gasLimit, args, txBase, _t0, _t1, _t10, _t11, _t12, _t13, _t14;
|
|
1378
1384
|
return _regenerator().w(function (_context9) {
|
|
1379
1385
|
while (1) switch (_context9.n) {
|
|
1380
1386
|
case 0:
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
|
|
1385
|
-
|
|
1386
|
-
|
|
1387
|
-
if (_t0) {
|
|
1388
|
-
_context9.n = 2;
|
|
1387
|
+
privateKey = _ref8.privateKey, nonce = _ref8.nonce, gasFeeData = _ref8.gasFeeData, txTo = _ref8.txTo, txData = _ref8.txData, txValue = _ref8.txValue, gasLimit = _ref8.gasLimit, args = _ref8.args;
|
|
1388
|
+
_t0 = txTo;
|
|
1389
|
+
_t1 = BigNumber$1(txValue.toString());
|
|
1390
|
+
_t10 = txData;
|
|
1391
|
+
if (!((_args$nonce = args.nonce) != null)) {
|
|
1392
|
+
_context9.n = 1;
|
|
1389
1393
|
break;
|
|
1390
1394
|
}
|
|
1391
|
-
|
|
1392
|
-
|
|
1395
|
+
_t11 = _args$nonce;
|
|
1396
|
+
_context9.n = 3;
|
|
1397
|
+
break;
|
|
1393
1398
|
case 1:
|
|
1394
|
-
|
|
1399
|
+
_context9.n = 2;
|
|
1400
|
+
return nonce;
|
|
1395
1401
|
case 2:
|
|
1396
|
-
|
|
1397
|
-
|
|
1398
|
-
|
|
1399
|
-
|
|
1400
|
-
|
|
1401
|
-
|
|
1402
|
-
|
|
1403
|
-
|
|
1404
|
-
|
|
1405
|
-
|
|
1406
|
-
|
|
1407
|
-
|
|
1408
|
-
}
|
|
1402
|
+
_t11 = _context9.v;
|
|
1403
|
+
case 3:
|
|
1404
|
+
_t12 = _t11;
|
|
1405
|
+
_t13 = BigNumber$1(gasLimit.toString());
|
|
1406
|
+
_t14 = Number(this.currentChain.id);
|
|
1407
|
+
txBase = {
|
|
1408
|
+
to: _t0,
|
|
1409
|
+
value: _t1,
|
|
1410
|
+
data: _t10,
|
|
1411
|
+
nonce: _t12,
|
|
1412
|
+
gasLimit: _t13,
|
|
1413
|
+
chainId: _t14
|
|
1414
|
+
};
|
|
1409
1415
|
if (!args.gasPrice) {
|
|
1410
|
-
_context9.n =
|
|
1416
|
+
_context9.n = 4;
|
|
1411
1417
|
break;
|
|
1412
1418
|
}
|
|
1413
1419
|
return _context9.a(2, {
|
|
1414
|
-
privateKey:
|
|
1420
|
+
privateKey: privateKey,
|
|
1415
1421
|
data: _extends({}, txBase, {
|
|
1416
1422
|
gasPrice: BigNumber$1(parseGwei(args.gasPrice).toString()),
|
|
1417
1423
|
type: 0
|
|
1418
1424
|
})
|
|
1419
1425
|
});
|
|
1420
|
-
case
|
|
1426
|
+
case 4:
|
|
1421
1427
|
return _context9.a(2, {
|
|
1422
|
-
privateKey:
|
|
1428
|
+
privateKey: privateKey,
|
|
1423
1429
|
data: _extends({}, txBase, {
|
|
1424
1430
|
type: 2,
|
|
1425
|
-
maxPriorityFeePerGas: BigNumber$1(args.maxPriorityFeePerGas ?
|
|
1426
|
-
maxFeePerGas: BigNumber$1(args.maxFeePerGas ?
|
|
1431
|
+
maxPriorityFeePerGas: BigNumber$1((_args$maxPriorityFeeP = args.maxPriorityFeePerGas) != null ? _args$maxPriorityFeeP : gasFeeData.maxPriorityFeePerGas.toString()),
|
|
1432
|
+
maxFeePerGas: BigNumber$1((_args$maxFeePerGas = args.maxFeePerGas) != null ? _args$maxFeePerGas : gasFeeData.maxFeePerGas.toString())
|
|
1427
1433
|
})
|
|
1428
1434
|
});
|
|
1429
1435
|
}
|