@turnkey/react-wallet-kit 2.1.1 → 2.2.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.
@@ -941,7 +941,7 @@ var ClientProvider = function ClientProvider(_ref) {
941
941
  var walletEvents = provider === null || provider === void 0 ? void 0 : (_provider$features = provider.features) === null || _provider$features === void 0 ? void 0 : _provider$features["standard:events"];
942
942
  if (walletEvents !== null && walletEvents !== void 0 && walletEvents.on) {
943
943
  var offChange = walletEvents.on("change", /*#__PURE__*/function () {
944
- var _ref165 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee140(_evt) {
944
+ var _ref166 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee140(_evt) {
945
945
  return _regenerator().w(function (_context140) {
946
946
  while (1) switch (_context140.n) {
947
947
  case 0:
@@ -953,7 +953,7 @@ var ClientProvider = function ClientProvider(_ref) {
953
953
  }, _callee140);
954
954
  }));
955
955
  return function (_x118) {
956
- return _ref165.apply(this, arguments);
956
+ return _ref166.apply(this, arguments);
957
957
  };
958
958
  }());
959
959
  cleanups.push(offChange);
@@ -967,7 +967,7 @@ var ClientProvider = function ClientProvider(_ref) {
967
967
  attachEthereumListeners = function _attachEthereumListen(provider, onUpdateState) {
968
968
  if (typeof provider.on !== "function") return;
969
969
  var handleChainChanged = /*#__PURE__*/function () {
970
- var _ref163 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee138(_chainId) {
970
+ var _ref164 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee138(_chainId) {
971
971
  return _regenerator().w(function (_context138) {
972
972
  while (1) switch (_context138.n) {
973
973
  case 0:
@@ -976,11 +976,11 @@ var ClientProvider = function ClientProvider(_ref) {
976
976
  }, _callee138);
977
977
  }));
978
978
  return function handleChainChanged(_x116) {
979
- return _ref163.apply(this, arguments);
979
+ return _ref164.apply(this, arguments);
980
980
  };
981
981
  }();
982
982
  var handleAccountsChanged = /*#__PURE__*/function () {
983
- var _ref164 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee139(accounts) {
983
+ var _ref165 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee139(accounts) {
984
984
  return _regenerator().w(function (_context139) {
985
985
  while (1) switch (_context139.n) {
986
986
  case 0:
@@ -991,7 +991,7 @@ var ClientProvider = function ClientProvider(_ref) {
991
991
  }, _callee139);
992
992
  }));
993
993
  return function handleAccountsChanged(_x117) {
994
- return _ref164.apply(this, arguments);
994
+ return _ref165.apply(this, arguments);
995
995
  };
996
996
  }();
997
997
  var handleDisconnect = function handleDisconnect() {
@@ -1048,7 +1048,7 @@ var ClientProvider = function ClientProvider(_ref) {
1048
1048
  if (standardEvents !== null && standardEvents !== void 0 && standardEvents.on) {
1049
1049
  if (standardEvents !== null && standardEvents !== void 0 && standardEvents.on) {
1050
1050
  unsubscribe = standardEvents.on("change", /*#__PURE__*/function () {
1051
- var _ref166 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee141(evt) {
1051
+ var _ref167 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee141(evt) {
1052
1052
  var _callbacks$onError10, providers, currentSession, _wcProviders, wcWallets;
1053
1053
  return _regenerator().w(function (_context141) {
1054
1054
  while (1) switch (_context141.n) {
@@ -1110,7 +1110,7 @@ var ClientProvider = function ClientProvider(_ref) {
1110
1110
  }, _callee141);
1111
1111
  }));
1112
1112
  return function (_x119) {
1113
- return _ref166.apply(this, arguments);
1113
+ return _ref167.apply(this, arguments);
1114
1114
  };
1115
1115
  }());
1116
1116
  cleanups.push(unsubscribe);
@@ -6369,7 +6369,7 @@ var ClientProvider = function ClientProvider(_ref) {
6369
6369
  return _context129.a(2, new Promise(function (resolve, reject) {
6370
6370
  var action = /*#__PURE__*/function () {
6371
6371
  var _ref151 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee128() {
6372
- var _ref153, _txDetails$eth$txHash, _txDetails$eth, _txDetails$solana;
6372
+ var _ref154, _txDetails$eth$txHash, _txDetails$eth, _txDetails$solana;
6373
6373
  var sendTransactionStatusId, pollResult, txDetails, txHash, _t28;
6374
6374
  return _regenerator().w(function (_context128) {
6375
6375
  while (1) switch (_context128.n) {
@@ -6391,22 +6391,20 @@ var ClientProvider = function ClientProvider(_ref) {
6391
6391
  case 2:
6392
6392
  _context128.n = 3;
6393
6393
  return _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee127() {
6394
- var from, to, value, data, nonce, gasLimit, maxFeePerGas, maxPriorityFeePerGas, sponsor, cleanedData, tx;
6394
+ var ethTx, cleanData, from, sponsor, nonce, gasLimit, maxFeePerGas, maxPriorityFeePerGas, commonFields, tx, cleanedData;
6395
6395
  return _regenerator().w(function (_context127) {
6396
6396
  while (1) switch (_context127.n) {
6397
6397
  case 0:
6398
- from = transaction.from, to = transaction.to, value = transaction.value, data = transaction.data, nonce = transaction.nonce, gasLimit = transaction.gasLimit, maxFeePerGas = transaction.maxFeePerGas, maxPriorityFeePerGas = transaction.maxPriorityFeePerGas, sponsor = transaction.sponsor;
6399
- cleanedData = data && data !== "0x" && data !== "" ? data : undefined;
6400
- tx = _objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2({
6398
+ ethTx = transaction; // Drop empty/no-op calldata ("0x" or "") so it isn't sent.
6399
+ cleanData = function cleanData(data) {
6400
+ return data && data !== "0x" && data !== "" ? data : undefined;
6401
+ }; // Shared fee/nonce fields, present on both the V1 and V2 intents.
6402
+ from = ethTx.from, sponsor = ethTx.sponsor, nonce = ethTx.nonce, gasLimit = ethTx.gasLimit, maxFeePerGas = ethTx.maxFeePerGas, maxPriorityFeePerGas = ethTx.maxPriorityFeePerGas;
6403
+ commonFields = _objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2({
6401
6404
  from: from,
6402
- to: to,
6403
- caip2: caip2,
6405
+ caip2: ethTx.caip2,
6404
6406
  sponsor: sponsor !== null && sponsor !== void 0 ? sponsor : false
6405
- }, value ? {
6406
- value: value
6407
- } : {}), cleanedData ? {
6408
- data: cleanedData
6409
- } : {}), nonce ? {
6407
+ }, nonce ? {
6410
6408
  nonce: nonce
6411
6409
  } : {}), gasLimit ? {
6412
6410
  gasLimit: gasLimit
@@ -6414,7 +6412,34 @@ var ClientProvider = function ClientProvider(_ref) {
6414
6412
  maxFeePerGas: maxFeePerGas
6415
6413
  } : {}), maxPriorityFeePerGas ? {
6416
6414
  maxPriorityFeePerGas: maxPriorityFeePerGas
6417
- } : {});
6415
+ } : {}); // V2 multi-call intent vs. legacy single-call (V1) intent.
6416
+ // TODO (breaking change): eventually, we wont generate the v1 activity at all, remove this check and update the intent.
6417
+ if ("calls" in ethTx) {
6418
+ tx = _objectSpread2(_objectSpread2({}, commonFields), {}, {
6419
+ calls: ethTx.calls.map(function (_ref153) {
6420
+ var to = _ref153.to,
6421
+ value = _ref153.value,
6422
+ data = _ref153.data;
6423
+ var cleanedData = cleanData(data);
6424
+ return _objectSpread2(_objectSpread2({
6425
+ to: to
6426
+ }, value ? {
6427
+ value: value
6428
+ } : {}), cleanedData ? {
6429
+ data: cleanedData
6430
+ } : {});
6431
+ })
6432
+ });
6433
+ } else {
6434
+ cleanedData = cleanData(ethTx.data);
6435
+ tx = _objectSpread2(_objectSpread2(_objectSpread2({}, commonFields), {}, {
6436
+ to: ethTx.to
6437
+ }, ethTx.value ? {
6438
+ value: ethTx.value
6439
+ } : {}), cleanedData ? {
6440
+ data: cleanedData
6441
+ } : {});
6442
+ }
6418
6443
  return _context127.a(2, ethSendTransaction({
6419
6444
  organizationId: organizationId,
6420
6445
  transaction: tx,
@@ -6441,7 +6466,7 @@ var ClientProvider = function ClientProvider(_ref) {
6441
6466
  case 6:
6442
6467
  pollResult = _context128.v;
6443
6468
  txDetails = pollResult;
6444
- txHash = (_ref153 = (_txDetails$eth$txHash = (_txDetails$eth = txDetails.eth) === null || _txDetails$eth === void 0 ? void 0 : _txDetails$eth.txHash) !== null && _txDetails$eth$txHash !== void 0 ? _txDetails$eth$txHash : (_txDetails$solana = txDetails.solana) === null || _txDetails$solana === void 0 ? void 0 : _txDetails$solana.signature) !== null && _ref153 !== void 0 ? _ref153 : txDetails.txHash;
6469
+ txHash = (_ref154 = (_txDetails$eth$txHash = (_txDetails$eth = txDetails.eth) === null || _txDetails$eth === void 0 ? void 0 : _txDetails$eth.txHash) !== null && _txDetails$eth$txHash !== void 0 ? _txDetails$eth$txHash : (_txDetails$solana = txDetails.solana) === null || _txDetails$solana === void 0 ? void 0 : _txDetails$solana.signature) !== null && _ref154 !== void 0 ? _ref154 : txDetails.txHash;
6445
6470
  return _context128.a(2, txHash ? {
6446
6471
  txHash: txHash
6447
6472
  } : {});
@@ -6481,7 +6506,7 @@ var ClientProvider = function ClientProvider(_ref) {
6481
6506
  };
6482
6507
  }(), [ethSendTransaction, getSession, pollTransactionStatus, pushPage, solSendTransaction]);
6483
6508
  var handleSendErc20Transfer = useCallback(/*#__PURE__*/function () {
6484
- var _ref154 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee131(params) {
6509
+ var _ref155 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee131(params) {
6485
6510
  var session, organizationId, transfer, icon, stampWith, _params$successPageDu6, successPageDuration, caip2;
6486
6511
  return _regenerator().w(function (_context131) {
6487
6512
  while (1) switch (_context131.n) {
@@ -6501,7 +6526,7 @@ var ClientProvider = function ClientProvider(_ref) {
6501
6526
  caip2 = transfer.caip2;
6502
6527
  return _context131.a(2, new Promise(function (resolve, reject) {
6503
6528
  var action = /*#__PURE__*/function () {
6504
- var _ref155 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee130() {
6529
+ var _ref156 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee130() {
6505
6530
  var _pollResult$eth$txHas, _pollResult$eth;
6506
6531
  var sendTransactionStatusId, pollResult, txHash;
6507
6532
  return _regenerator().w(function (_context130) {
@@ -6536,7 +6561,7 @@ var ClientProvider = function ClientProvider(_ref) {
6536
6561
  }, _callee130);
6537
6562
  }));
6538
6563
  return function action() {
6539
- return _ref155.apply(this, arguments);
6564
+ return _ref156.apply(this, arguments);
6540
6565
  };
6541
6566
  }();
6542
6567
  pushPage({
@@ -6564,11 +6589,11 @@ var ClientProvider = function ClientProvider(_ref) {
6564
6589
  }, _callee131);
6565
6590
  }));
6566
6591
  return function (_x113) {
6567
- return _ref154.apply(this, arguments);
6592
+ return _ref155.apply(this, arguments);
6568
6593
  };
6569
6594
  }(), [ethSendErc20Transfer, getSession, pollTransactionStatus, pushPage]);
6570
6595
  var handleOnRamp = useCallback(/*#__PURE__*/function () {
6571
- var _ref156 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee134(params) {
6596
+ var _ref157 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee134(params) {
6572
6597
  var _walletAccount$addres;
6573
6598
  var walletAccount, fiatCurrencyAmount, fiatCurrencyCode, paymentMethod, countrySubdivisionCode, urlForSignature, countryCode, _params$onrampProvide, onrampProvider, _params$sandboxMode, sandboxMode, _params$successPageDu7, successPageDuration, _params$openInNewTab, openInNewTab, s, organizationId, cryptoCurrencyCode, network, openNewTab, _t31;
6574
6599
  return _regenerator().w(function (_context134) {
@@ -6628,7 +6653,7 @@ var ClientProvider = function ClientProvider(_ref) {
6628
6653
  };
6629
6654
  }, []);
6630
6655
  var action = /*#__PURE__*/function () {
6631
- var _ref157 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee133() {
6656
+ var _ref158 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee133() {
6632
6657
  var _client$httpClient, onRampWindow, result, popupWidth, popupHeight, left, top, onRampTransactionId, _t30;
6633
6658
  return _regenerator().w(function (_context133) {
6634
6659
  while (1) switch (_context133.p = _context133.n) {
@@ -6771,7 +6796,7 @@ var ClientProvider = function ClientProvider(_ref) {
6771
6796
  }, _callee133, null, [[0, 7]]);
6772
6797
  }));
6773
6798
  return function action() {
6774
- return _ref157.apply(this, arguments);
6799
+ return _ref158.apply(this, arguments);
6775
6800
  };
6776
6801
  }();
6777
6802
  return jsx(OnRampPage, {
@@ -6807,16 +6832,16 @@ var ClientProvider = function ClientProvider(_ref) {
6807
6832
  }, _callee134);
6808
6833
  }));
6809
6834
  return function (_x114) {
6810
- return _ref156.apply(this, arguments);
6835
+ return _ref157.apply(this, arguments);
6811
6836
  };
6812
6837
  }(), [getSession, client, pushPage]);
6813
6838
  var handleVerifyAppProofs = useCallback(/*#__PURE__*/function () {
6814
- var _ref159 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee135(params) {
6815
- var _ref160, appProofs, _ref160$successPageDu, successPageDuration, stampWith, s, organizationId, _t32;
6839
+ var _ref160 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee135(params) {
6840
+ var _ref161, appProofs, _ref161$successPageDu, successPageDuration, stampWith, s, organizationId, _t32;
6816
6841
  return _regenerator().w(function (_context135) {
6817
6842
  while (1) switch (_context135.p = _context135.n) {
6818
6843
  case 0:
6819
- _ref160 = params || {}, appProofs = _ref160.appProofs, _ref160$successPageDu = _ref160.successPageDuration, successPageDuration = _ref160$successPageDu === void 0 ? 3000 : _ref160$successPageDu, stampWith = _ref160.stampWith;
6844
+ _ref161 = params || {}, appProofs = _ref161.appProofs, _ref161$successPageDu = _ref161.successPageDuration, successPageDuration = _ref161$successPageDu === void 0 ? 3000 : _ref161$successPageDu, stampWith = _ref161.stampWith;
6820
6845
  _context135.n = 1;
6821
6846
  return getSession();
6822
6847
  case 1:
@@ -6870,14 +6895,14 @@ var ClientProvider = function ClientProvider(_ref) {
6870
6895
  }, _callee135, null, [[2, 3]]);
6871
6896
  }));
6872
6897
  return function (_x115) {
6873
- return _ref159.apply(this, arguments);
6898
+ return _ref160.apply(this, arguments);
6874
6899
  };
6875
6900
  }(), [getSession, pushPage]);
6876
6901
  useEffect(function () {
6877
6902
  if (proxyAuthConfigRef.current) return;
6878
6903
  // Only fetch the proxy auth config once. Use that to build the master config.
6879
6904
  var fetchProxyAuthConfig = /*#__PURE__*/function () {
6880
- var _ref161 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee136() {
6905
+ var _ref162 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee136() {
6881
6906
  var proxyAuthConfig;
6882
6907
  return _regenerator().w(function (_context136) {
6883
6908
  while (1) switch (_context136.p = _context136.n) {
@@ -6908,7 +6933,7 @@ var ClientProvider = function ClientProvider(_ref) {
6908
6933
  }, _callee136, null, [[0, 3]]);
6909
6934
  }));
6910
6935
  return function fetchProxyAuthConfig() {
6911
- return _ref161.apply(this, arguments);
6936
+ return _ref162.apply(this, arguments);
6912
6937
  };
6913
6938
  }();
6914
6939
  fetchProxyAuthConfig();
@@ -6941,7 +6966,7 @@ var ClientProvider = function ClientProvider(_ref) {
6941
6966
  var debouncedFetchWalletProviders = useDebouncedCallback(fetchWalletProviders, 100);
6942
6967
  useEffect(function () {
6943
6968
  var handleUpdateState = /*#__PURE__*/function () {
6944
- var _ref162 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee137() {
6969
+ var _ref163 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee137() {
6945
6970
  var currentSession;
6946
6971
  return _regenerator().w(function (_context137) {
6947
6972
  while (1) switch (_context137.n) {
@@ -6968,7 +6993,7 @@ var ClientProvider = function ClientProvider(_ref) {
6968
6993
  }, _callee137);
6969
6994
  }));
6970
6995
  return function handleUpdateState() {
6971
- return _ref162.apply(this, arguments);
6996
+ return _ref163.apply(this, arguments);
6972
6997
  };
6973
6998
  }();
6974
6999
  var cleanup = function cleanup() {};