@reactmore/crypto-wallet-sdk 1.2.0 → 1.3.0

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.
@@ -819,38 +819,50 @@ var EvmWallet = /*#__PURE__*/function (_BaseWallet) {
819
819
  }();
820
820
  _proto.generateWallet = /*#__PURE__*/function () {
821
821
  var _generateWallet = /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(_ref2) {
822
- var mnemonic, derivationPath, hdPath, getMnemonic, derivePrivateKey, _yield$this$wallet$ge, address, publicKey, _t2;
822
+ var mnemonic, privateKey, derivationPath, hdPath, derivePrivateKey, _yield$this$wallet$ge, address, publicKey;
823
823
  return _regenerator().w(function (_context2) {
824
824
  while (1) switch (_context2.n) {
825
825
  case 0:
826
- mnemonic = _ref2.mnemonic, derivationPath = _ref2.derivationPath;
826
+ mnemonic = _ref2.mnemonic, privateKey = _ref2.privateKey, derivationPath = _ref2.derivationPath;
827
827
  hdPath = derivationPath || "m/44'/60'/0'/0/0";
828
- if (!(mnemonic != null)) {
828
+ if (!(mnemonic && privateKey)) {
829
829
  _context2.n = 1;
830
830
  break;
831
831
  }
832
- _t2 = mnemonic;
833
- _context2.n = 3;
834
- break;
832
+ throw new Error("Provide either mnemonic or privateKey, not both");
835
833
  case 1:
836
- _context2.n = 2;
837
- return this.generateMnemonic(12);
834
+ if (!privateKey) {
835
+ _context2.n = 2;
836
+ break;
837
+ }
838
+ derivePrivateKey = privateKey;
839
+ _context2.n = 6;
840
+ break;
838
841
  case 2:
839
- _t2 = _context2.v;
840
- case 3:
841
- getMnemonic = _t2;
842
- _context2.n = 4;
842
+ if (!mnemonic) {
843
+ _context2.n = 4;
844
+ break;
845
+ }
846
+ _context2.n = 3;
843
847
  return this.wallet.getDerivedPrivateKey({
844
- mnemonic: getMnemonic,
848
+ mnemonic: mnemonic,
845
849
  hdPath: hdPath
846
850
  });
847
- case 4:
851
+ case 3:
848
852
  derivePrivateKey = _context2.v;
853
+ _context2.n = 6;
854
+ break;
855
+ case 4:
849
856
  _context2.n = 5;
857
+ return this.wallet.getRandomPrivateKey();
858
+ case 5:
859
+ derivePrivateKey = _context2.v;
860
+ case 6:
861
+ _context2.n = 7;
850
862
  return this.wallet.getNewAddress({
851
863
  privateKey: derivePrivateKey
852
864
  });
853
- case 5:
865
+ case 7:
854
866
  _yield$this$wallet$ge = _context2.v;
855
867
  address = _yield$this$wallet$ge.address;
856
868
  publicKey = _yield$this$wallet$ge.publicKey;
@@ -920,7 +932,7 @@ var EvmWallet = /*#__PURE__*/function (_BaseWallet) {
920
932
  }();
921
933
  _proto.transfer = /*#__PURE__*/function () {
922
934
  var _transfer = /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee4(_ref4) {
923
- var privateKey, contractAddress, rpcUrl, args, _yield$this$getContra2, contract, providerInstance, gasFeeData, nonce, recipientAddress, prio, max, value, gasLimit, decimals, noFeeProvided, estimate, fee, signParams, signedTx, broadcast, _t3;
935
+ var privateKey, contractAddress, rpcUrl, args, _yield$this$getContra2, contract, providerInstance, gasFeeData, nonce, recipientAddress, prio, max, value, gasLimit, decimals, noFeeProvided, estimate, fee, signParams, signedTx, broadcast, _t2;
924
936
  return _regenerator().w(function (_context4) {
925
937
  while (1) switch (_context4.n) {
926
938
  case 0:
@@ -986,16 +998,16 @@ var EvmWallet = /*#__PURE__*/function (_BaseWallet) {
986
998
  _context4.n = 8;
987
999
  break;
988
1000
  }
989
- _t3 = BigInt(args.gasLimit);
1001
+ _t2 = BigInt(args.gasLimit);
990
1002
  _context4.n = 10;
991
1003
  break;
992
1004
  case 8:
993
1005
  _context4.n = 9;
994
1006
  return contract.transfer.estimateGas(args.recipientAddress, value);
995
1007
  case 9:
996
- _t3 = _context4.v;
1008
+ _t2 = _context4.v;
997
1009
  case 10:
998
- gasLimit = _t3;
1010
+ gasLimit = _t2;
999
1011
  _context4.n = 12;
1000
1012
  break;
1001
1013
  case 11:
@@ -1080,7 +1092,7 @@ var EvmWallet = /*#__PURE__*/function (_BaseWallet) {
1080
1092
  }();
1081
1093
  _proto.getTransaction = /*#__PURE__*/function () {
1082
1094
  var _getTransaction = /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee5(_ref5) {
1083
- var hash, rpcUrl, withReceipt, _yield$this$getContra3, providerInstance, _yield$Promise$all, _tx, receipt, memo, tx, _t4;
1095
+ var hash, rpcUrl, withReceipt, _yield$this$getContra3, providerInstance, _yield$Promise$all, _tx, receipt, memo, tx, _t3;
1084
1096
  return _regenerator().w(function (_context5) {
1085
1097
  while (1) switch (_context5.p = _context5.n) {
1086
1098
  case 0:
@@ -1119,8 +1131,8 @@ var EvmWallet = /*#__PURE__*/function (_BaseWallet) {
1119
1131
  }));
1120
1132
  case 6:
1121
1133
  _context5.p = 6;
1122
- _t4 = _context5.v;
1123
- throw _t4;
1134
+ _t3 = _context5.v;
1135
+ throw _t3;
1124
1136
  case 7:
1125
1137
  return _context5.a(2);
1126
1138
  }
@@ -1180,7 +1192,7 @@ var EvmWallet = /*#__PURE__*/function (_BaseWallet) {
1180
1192
  _proto.smartContractCall = /*#__PURE__*/function () {
1181
1193
  var _smartContractCall = /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee7(args) {
1182
1194
  var _args$rpcUrl;
1183
- var _yield$this$getContra5, contract, gasFeeData, nonce, tx, overrides, _t5;
1195
+ var _yield$this$getContra5, contract, gasFeeData, nonce, tx, overrides, _t4;
1184
1196
  return _regenerator().w(function (_context7) {
1185
1197
  while (1) switch (_context7.p = _context7.n) {
1186
1198
  case 0:
@@ -1231,8 +1243,8 @@ var EvmWallet = /*#__PURE__*/function (_BaseWallet) {
1231
1243
  }));
1232
1244
  case 7:
1233
1245
  _context7.p = 7;
1234
- _t5 = _context7.v;
1235
- throw _t5;
1246
+ _t4 = _context7.v;
1247
+ throw _t4;
1236
1248
  case 8:
1237
1249
  return _context7.a(2);
1238
1250
  }
@@ -1245,7 +1257,7 @@ var EvmWallet = /*#__PURE__*/function (_BaseWallet) {
1245
1257
  }();
1246
1258
  _proto.estimateGas = /*#__PURE__*/function () {
1247
1259
  var _estimateGas = /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee8(_ref7) {
1248
- 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, _t6;
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, _t5;
1249
1261
  return _regenerator().w(function (_context8) {
1250
1262
  while (1) switch (_context8.p = _context8.n) {
1251
1263
  case 0:
@@ -1348,8 +1360,8 @@ var EvmWallet = /*#__PURE__*/function (_BaseWallet) {
1348
1360
  }));
1349
1361
  case 7:
1350
1362
  _context8.p = 7;
1351
- _t6 = _context8.v;
1352
- throw _t6;
1363
+ _t5 = _context8.v;
1364
+ throw _t5;
1353
1365
  case 8:
1354
1366
  return _context8.a(2);
1355
1367
  }
@@ -1362,35 +1374,35 @@ var EvmWallet = /*#__PURE__*/function (_BaseWallet) {
1362
1374
  }();
1363
1375
  _proto.buildSignParams = /*#__PURE__*/function () {
1364
1376
  var _buildSignParams = /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee9(_ref8) {
1365
- var args, nonce, gasFeeData, recipientAddress, value, contractAddress, txBase, _t7, _t8, _t9, _t0, _t1, _t10, _t11, _t12;
1377
+ var args, nonce, gasFeeData, recipientAddress, value, contractAddress, txBase, _t6, _t7, _t8, _t9, _t0, _t1, _t10, _t11;
1366
1378
  return _regenerator().w(function (_context9) {
1367
1379
  while (1) switch (_context9.n) {
1368
1380
  case 0:
1369
1381
  args = _ref8.args, nonce = _ref8.nonce, gasFeeData = _ref8.gasFeeData, recipientAddress = _ref8.recipientAddress, value = _ref8.value, contractAddress = _ref8.contractAddress;
1370
- _t7 = _extends;
1371
- _t8 = recipientAddress.address;
1372
- _t9 = BigNumber$1(value.toString());
1373
- _t0 = args.data ? ethers.hexlify(ethers.toUtf8Bytes(args.data)) : '0x';
1374
- _t1 = args.nonce;
1375
- if (_t1) {
1382
+ _t6 = _extends;
1383
+ _t7 = recipientAddress.address;
1384
+ _t8 = BigNumber$1(value.toString());
1385
+ _t9 = args.data ? ethers.hexlify(ethers.toUtf8Bytes(args.data)) : '0x';
1386
+ _t0 = args.nonce;
1387
+ if (_t0) {
1376
1388
  _context9.n = 2;
1377
1389
  break;
1378
1390
  }
1379
1391
  _context9.n = 1;
1380
1392
  return nonce;
1381
1393
  case 1:
1382
- _t1 = _context9.v;
1394
+ _t0 = _context9.v;
1383
1395
  case 2:
1384
- _t10 = _t1;
1385
- _t11 = args.gasLimit ? BigNumber$1(args.gasLimit) : BigNumber$1(21000);
1386
- _t12 = Number(this.currentChain.id);
1387
- txBase = _t7({
1388
- to: _t8,
1389
- value: _t9,
1390
- data: _t0,
1391
- nonce: _t10,
1392
- gasLimit: _t11,
1393
- chainId: _t12
1396
+ _t1 = _t0;
1397
+ _t10 = args.gasLimit ? BigNumber$1(args.gasLimit) : BigNumber$1(21000);
1398
+ _t11 = Number(this.currentChain.id);
1399
+ txBase = _t6({
1400
+ to: _t7,
1401
+ value: _t8,
1402
+ data: _t9,
1403
+ nonce: _t1,
1404
+ gasLimit: _t10,
1405
+ chainId: _t11
1394
1406
  }, contractAddress ? {
1395
1407
  contractAddress: contractAddress
1396
1408
  } : {});