@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.
@@ -825,38 +825,50 @@ var EvmWallet = /*#__PURE__*/function (_BaseWallet) {
825
825
  }();
826
826
  _proto.generateWallet = /*#__PURE__*/function () {
827
827
  var _generateWallet = /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(_ref2) {
828
- var mnemonic, derivationPath, hdPath, getMnemonic, derivePrivateKey, _yield$this$wallet$ge, address, publicKey, _t2;
828
+ var mnemonic, privateKey, derivationPath, hdPath, derivePrivateKey, _yield$this$wallet$ge, address, publicKey;
829
829
  return _regenerator().w(function (_context2) {
830
830
  while (1) switch (_context2.n) {
831
831
  case 0:
832
- mnemonic = _ref2.mnemonic, derivationPath = _ref2.derivationPath;
832
+ mnemonic = _ref2.mnemonic, privateKey = _ref2.privateKey, derivationPath = _ref2.derivationPath;
833
833
  hdPath = derivationPath || "m/44'/60'/0'/0/0";
834
- if (!(mnemonic != null)) {
834
+ if (!(mnemonic && privateKey)) {
835
835
  _context2.n = 1;
836
836
  break;
837
837
  }
838
- _t2 = mnemonic;
839
- _context2.n = 3;
840
- break;
838
+ throw new Error("Provide either mnemonic or privateKey, not both");
841
839
  case 1:
842
- _context2.n = 2;
843
- return this.generateMnemonic(12);
840
+ if (!privateKey) {
841
+ _context2.n = 2;
842
+ break;
843
+ }
844
+ derivePrivateKey = privateKey;
845
+ _context2.n = 6;
846
+ break;
844
847
  case 2:
845
- _t2 = _context2.v;
846
- case 3:
847
- getMnemonic = _t2;
848
- _context2.n = 4;
848
+ if (!mnemonic) {
849
+ _context2.n = 4;
850
+ break;
851
+ }
852
+ _context2.n = 3;
849
853
  return this.wallet.getDerivedPrivateKey({
850
- mnemonic: getMnemonic,
854
+ mnemonic: mnemonic,
851
855
  hdPath: hdPath
852
856
  });
853
- case 4:
857
+ case 3:
854
858
  derivePrivateKey = _context2.v;
859
+ _context2.n = 6;
860
+ break;
861
+ case 4:
855
862
  _context2.n = 5;
863
+ return this.wallet.getRandomPrivateKey();
864
+ case 5:
865
+ derivePrivateKey = _context2.v;
866
+ case 6:
867
+ _context2.n = 7;
856
868
  return this.wallet.getNewAddress({
857
869
  privateKey: derivePrivateKey
858
870
  });
859
- case 5:
871
+ case 7:
860
872
  _yield$this$wallet$ge = _context2.v;
861
873
  address = _yield$this$wallet$ge.address;
862
874
  publicKey = _yield$this$wallet$ge.publicKey;
@@ -926,7 +938,7 @@ var EvmWallet = /*#__PURE__*/function (_BaseWallet) {
926
938
  }();
927
939
  _proto.transfer = /*#__PURE__*/function () {
928
940
  var _transfer = /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee4(_ref4) {
929
- 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;
941
+ 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;
930
942
  return _regenerator().w(function (_context4) {
931
943
  while (1) switch (_context4.n) {
932
944
  case 0:
@@ -992,16 +1004,16 @@ var EvmWallet = /*#__PURE__*/function (_BaseWallet) {
992
1004
  _context4.n = 8;
993
1005
  break;
994
1006
  }
995
- _t3 = BigInt(args.gasLimit);
1007
+ _t2 = BigInt(args.gasLimit);
996
1008
  _context4.n = 10;
997
1009
  break;
998
1010
  case 8:
999
1011
  _context4.n = 9;
1000
1012
  return contract.transfer.estimateGas(args.recipientAddress, value);
1001
1013
  case 9:
1002
- _t3 = _context4.v;
1014
+ _t2 = _context4.v;
1003
1015
  case 10:
1004
- gasLimit = _t3;
1016
+ gasLimit = _t2;
1005
1017
  _context4.n = 12;
1006
1018
  break;
1007
1019
  case 11:
@@ -1086,7 +1098,7 @@ var EvmWallet = /*#__PURE__*/function (_BaseWallet) {
1086
1098
  }();
1087
1099
  _proto.getTransaction = /*#__PURE__*/function () {
1088
1100
  var _getTransaction = /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee5(_ref5) {
1089
- var hash, rpcUrl, withReceipt, _yield$this$getContra3, providerInstance, _yield$Promise$all, _tx, receipt, memo, tx, _t4;
1101
+ var hash, rpcUrl, withReceipt, _yield$this$getContra3, providerInstance, _yield$Promise$all, _tx, receipt, memo, tx, _t3;
1090
1102
  return _regenerator().w(function (_context5) {
1091
1103
  while (1) switch (_context5.p = _context5.n) {
1092
1104
  case 0:
@@ -1125,8 +1137,8 @@ var EvmWallet = /*#__PURE__*/function (_BaseWallet) {
1125
1137
  }));
1126
1138
  case 6:
1127
1139
  _context5.p = 6;
1128
- _t4 = _context5.v;
1129
- throw _t4;
1140
+ _t3 = _context5.v;
1141
+ throw _t3;
1130
1142
  case 7:
1131
1143
  return _context5.a(2);
1132
1144
  }
@@ -1186,7 +1198,7 @@ var EvmWallet = /*#__PURE__*/function (_BaseWallet) {
1186
1198
  _proto.smartContractCall = /*#__PURE__*/function () {
1187
1199
  var _smartContractCall = /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee7(args) {
1188
1200
  var _args$rpcUrl;
1189
- var _yield$this$getContra5, contract, gasFeeData, nonce, tx, overrides, _t5;
1201
+ var _yield$this$getContra5, contract, gasFeeData, nonce, tx, overrides, _t4;
1190
1202
  return _regenerator().w(function (_context7) {
1191
1203
  while (1) switch (_context7.p = _context7.n) {
1192
1204
  case 0:
@@ -1237,8 +1249,8 @@ var EvmWallet = /*#__PURE__*/function (_BaseWallet) {
1237
1249
  }));
1238
1250
  case 7:
1239
1251
  _context7.p = 7;
1240
- _t5 = _context7.v;
1241
- throw _t5;
1252
+ _t4 = _context7.v;
1253
+ throw _t4;
1242
1254
  case 8:
1243
1255
  return _context7.a(2);
1244
1256
  }
@@ -1251,7 +1263,7 @@ var EvmWallet = /*#__PURE__*/function (_BaseWallet) {
1251
1263
  }();
1252
1264
  _proto.estimateGas = /*#__PURE__*/function () {
1253
1265
  var _estimateGas = /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee8(_ref7) {
1254
- 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;
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, _t5;
1255
1267
  return _regenerator().w(function (_context8) {
1256
1268
  while (1) switch (_context8.p = _context8.n) {
1257
1269
  case 0:
@@ -1354,8 +1366,8 @@ var EvmWallet = /*#__PURE__*/function (_BaseWallet) {
1354
1366
  }));
1355
1367
  case 7:
1356
1368
  _context8.p = 7;
1357
- _t6 = _context8.v;
1358
- throw _t6;
1369
+ _t5 = _context8.v;
1370
+ throw _t5;
1359
1371
  case 8:
1360
1372
  return _context8.a(2);
1361
1373
  }
@@ -1368,35 +1380,35 @@ var EvmWallet = /*#__PURE__*/function (_BaseWallet) {
1368
1380
  }();
1369
1381
  _proto.buildSignParams = /*#__PURE__*/function () {
1370
1382
  var _buildSignParams = /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee9(_ref8) {
1371
- var args, nonce, gasFeeData, recipientAddress, value, contractAddress, txBase, _t7, _t8, _t9, _t0, _t1, _t10, _t11, _t12;
1383
+ var args, nonce, gasFeeData, recipientAddress, value, contractAddress, txBase, _t6, _t7, _t8, _t9, _t0, _t1, _t10, _t11;
1372
1384
  return _regenerator().w(function (_context9) {
1373
1385
  while (1) switch (_context9.n) {
1374
1386
  case 0:
1375
1387
  args = _ref8.args, nonce = _ref8.nonce, gasFeeData = _ref8.gasFeeData, recipientAddress = _ref8.recipientAddress, value = _ref8.value, contractAddress = _ref8.contractAddress;
1376
- _t7 = _extends;
1377
- _t8 = recipientAddress.address;
1378
- _t9 = cryptoLib.BigNumber(value.toString());
1379
- _t0 = args.data ? ethers.ethers.hexlify(ethers.ethers.toUtf8Bytes(args.data)) : '0x';
1380
- _t1 = args.nonce;
1381
- if (_t1) {
1388
+ _t6 = _extends;
1389
+ _t7 = recipientAddress.address;
1390
+ _t8 = cryptoLib.BigNumber(value.toString());
1391
+ _t9 = args.data ? ethers.ethers.hexlify(ethers.ethers.toUtf8Bytes(args.data)) : '0x';
1392
+ _t0 = args.nonce;
1393
+ if (_t0) {
1382
1394
  _context9.n = 2;
1383
1395
  break;
1384
1396
  }
1385
1397
  _context9.n = 1;
1386
1398
  return nonce;
1387
1399
  case 1:
1388
- _t1 = _context9.v;
1400
+ _t0 = _context9.v;
1389
1401
  case 2:
1390
- _t10 = _t1;
1391
- _t11 = args.gasLimit ? cryptoLib.BigNumber(args.gasLimit) : cryptoLib.BigNumber(21000);
1392
- _t12 = Number(this.currentChain.id);
1393
- txBase = _t7({
1394
- to: _t8,
1395
- value: _t9,
1396
- data: _t0,
1397
- nonce: _t10,
1398
- gasLimit: _t11,
1399
- chainId: _t12
1402
+ _t1 = _t0;
1403
+ _t10 = args.gasLimit ? cryptoLib.BigNumber(args.gasLimit) : cryptoLib.BigNumber(21000);
1404
+ _t11 = Number(this.currentChain.id);
1405
+ txBase = _t6({
1406
+ to: _t7,
1407
+ value: _t8,
1408
+ data: _t9,
1409
+ nonce: _t1,
1410
+ gasLimit: _t10,
1411
+ chainId: _t11
1400
1412
  }, contractAddress ? {
1401
1413
  contractAddress: contractAddress
1402
1414
  } : {});