@depay/widgets 12.4.0 → 12.4.2

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.
@@ -753,18 +753,18 @@
753
753
  }, {
754
754
  "name": "Unstoppable Wallet",
755
755
  "desktop": {
756
- "qr": "WalletConnectV1"
756
+ "qr": "WalletConnectV2"
757
757
  },
758
758
  "mobile": {
759
759
  "ios": {
760
760
  "universal": "unstoppable.money://",
761
- "connect": "WalletConnectV1",
762
- "qr": "WalletConnectV1"
761
+ "connect": "WalletConnectV2",
762
+ "qr": "WalletConnectV2"
763
763
  },
764
764
  "android": {
765
765
  "universal": "unstoppable.money://",
766
- "connect": "WalletConnectV1",
767
- "qr": "WalletConnectV1"
766
+ "connect": "WalletConnectV2",
767
+ "qr": "WalletConnectV2"
768
768
  }
769
769
  },
770
770
  "logo": "https://img1.depay.com/wallets/unstoppable.jpg",
@@ -35706,82 +35706,89 @@
35706
35706
  validated = _useContext.validated,
35707
35707
  integration = _useContext.integration,
35708
35708
  link = _useContext.link,
35709
- type = _useContext.type;
35709
+ type = _useContext.type,
35710
+ configurationId = _useContext.id;
35711
+ var _useState = React.useState(),
35712
+ _useState2 = _slicedToArray(_useState, 2),
35713
+ attemptId = _useState2[0],
35714
+ setAttemptId = _useState2[1];
35715
+ var attemptIdRef = React.useRef(attemptId);
35716
+ attemptIdRef.current = attemptId;
35710
35717
  var _useContext2 = React.useContext(reactDialogStack.NavigateStackContext);
35711
35718
  _useContext2.set;
35712
35719
  _useContext2.navigate;
35713
35720
  var _useContext3 = React.useContext(ClosableContext),
35714
35721
  close = _useContext3.close,
35715
35722
  setClosable = _useContext3.setClosable;
35716
- var _useState = React.useState(),
35717
- _useState2 = _slicedToArray(_useState, 2),
35718
- paymentOptions = _useState2[0],
35719
- setPaymentOptions = _useState2[1];
35720
35723
  var _useState3 = React.useState(),
35721
35724
  _useState4 = _slicedToArray(_useState3, 2),
35722
- forwardTo = _useState4[0],
35723
- setForwardTo = _useState4[1];
35725
+ paymentOptions = _useState4[0],
35726
+ setPaymentOptions = _useState4[1];
35724
35727
  var _useState5 = React.useState(),
35725
35728
  _useState6 = _slicedToArray(_useState5, 2),
35726
- pollingPaymentStatusInterval = _useState6[0],
35727
- setPollingPaymentStatusInterval = _useState6[1];
35729
+ forwardTo = _useState6[0],
35730
+ setForwardTo = _useState6[1];
35728
35731
  var _useState7 = React.useState(),
35729
35732
  _useState8 = _slicedToArray(_useState7, 2),
35730
- transactionTrackingInterval = _useState8[0],
35731
- setTransactionTrackingInterval = _useState8[1];
35733
+ pollingPaymentStatusInterval = _useState8[0],
35734
+ setPollingPaymentStatusInterval = _useState8[1];
35732
35735
  var _useState9 = React.useState(),
35733
35736
  _useState10 = _slicedToArray(_useState9, 2),
35734
- selectedPaymentOption = _useState10[0],
35735
- setSelectedPaymantOption = _useState10[1];
35737
+ transactionTrackingInterval = _useState10[0],
35738
+ setTransactionTrackingInterval = _useState10[1];
35736
35739
  var _useState11 = React.useState(),
35737
35740
  _useState12 = _slicedToArray(_useState11, 2),
35738
- transaction = _useState12[0],
35739
- setTransaction = _useState12[1];
35741
+ selectedPaymentOption = _useState12[0],
35742
+ setSelectedPaymantOption = _useState12[1];
35740
35743
  var _useState13 = React.useState(),
35741
35744
  _useState14 = _slicedToArray(_useState13, 2),
35742
- secretId = _useState14[0],
35743
- setSecretId = _useState14[1];
35745
+ transaction = _useState14[0],
35746
+ setTransaction = _useState14[1];
35744
35747
  var _useState15 = React.useState(),
35745
35748
  _useState16 = _slicedToArray(_useState15, 2),
35746
- solanaPayTransactionSocket = _useState16[0],
35747
- setSolanaPayTransactionSocket = _useState16[1];
35749
+ secretId = _useState16[0],
35750
+ setSecretId = _useState16[1];
35748
35751
  var _useState17 = React.useState(),
35749
35752
  _useState18 = _slicedToArray(_useState17, 2),
35750
- transactionTrackingSocket = _useState18[0],
35751
- setTransactionTrackingSocket = _useState18[1];
35753
+ solanaPayTransactionSocket = _useState18[0],
35754
+ setSolanaPayTransactionSocket = _useState18[1];
35752
35755
  var _useState19 = React.useState(),
35753
35756
  _useState20 = _slicedToArray(_useState19, 2),
35754
- paymentValidationSocket = _useState20[0],
35755
- setPaymentValidationSocket = _useState20[1];
35757
+ transactionTrackingSocket = _useState20[0],
35758
+ setTransactionTrackingSocket = _useState20[1];
35756
35759
  var _useState21 = React.useState(),
35757
35760
  _useState22 = _slicedToArray(_useState21, 2),
35758
- QRCodeURI = _useState22[0],
35759
- setQRCodeURI = _useState22[1];
35761
+ paymentValidationSocket = _useState22[0],
35762
+ setPaymentValidationSocket = _useState22[1];
35760
35763
  var _useState23 = React.useState(),
35761
35764
  _useState24 = _slicedToArray(_useState23, 2),
35762
- release = _useState24[0],
35763
- setRelease = _useState24[1];
35765
+ QRCodeURI = _useState24[0],
35766
+ setQRCodeURI = _useState24[1];
35764
35767
  var _useState25 = React.useState(),
35765
35768
  _useState26 = _slicedToArray(_useState25, 2),
35766
- afterBlock = _useState26[0],
35767
- setAfterBlock = _useState26[1];
35769
+ release = _useState26[0],
35770
+ setRelease = _useState26[1];
35768
35771
  var _useState27 = React.useState(),
35769
35772
  _useState28 = _slicedToArray(_useState27, 2),
35770
- QRCode = _useState28[0],
35771
- setQRCode = _useState28[1];
35772
- var _useState29 = React.useState('select'),
35773
+ afterBlock = _useState28[0],
35774
+ setAfterBlock = _useState28[1];
35775
+ var _useState29 = React.useState(),
35773
35776
  _useState30 = _slicedToArray(_useState29, 2),
35774
- state = _useState30[0],
35775
- setState = _useState30[1];
35776
- var _useState31 = React.useState(!!(track && track.poll && (track.poll.endpoint || typeof track.poll.method == 'function') && track.async != true)),
35777
- _useState32 = _slicedToArray(_useState31, 1),
35778
- polling = _useState32[0];
35779
- var _useState33 = React.useState(!!(track && (track.endpoint || typeof track.method == 'function') && track.async != true)),
35777
+ QRCode = _useState30[0],
35778
+ setQRCode = _useState30[1];
35779
+ var _useState31 = React.useState('select'),
35780
+ _useState32 = _slicedToArray(_useState31, 2),
35781
+ state = _useState32[0],
35782
+ setState = _useState32[1];
35783
+ var _useState33 = React.useState(!!configurationId || !!(track && (track.endpoint || typeof track.method == 'function') && track.async != true)),
35780
35784
  _useState34 = _slicedToArray(_useState33, 1),
35781
35785
  synchronousTracking = _useState34[0];
35782
- var _useState35 = React.useState(!!(track && track.async == true)),
35786
+ var _useState35 = React.useState(!configurationId && !!(track && track.async == true)),
35783
35787
  _useState36 = _slicedToArray(_useState35, 1),
35784
35788
  asynchronousTracking = _useState36[0];
35789
+ var _useState37 = React.useState(!!configurationId || !!(track && track.poll && (track.poll.endpoint || typeof track.poll.method == 'function') && track.async != true)),
35790
+ _useState38 = _slicedToArray(_useState37, 1),
35791
+ polling = _useState38[0];
35785
35792
  var isTracking = synchronousTracking || asynchronousTracking;
35786
35793
  var QRCodeElement = React__default["default"].useRef();
35787
35794
  var selectPaymentOption = /*#__PURE__*/function () {
@@ -35801,22 +35808,22 @@
35801
35808
  case 4:
35802
35809
  selectedPaymentOption.fromAmountBN = _context.sent;
35803
35810
  if (!selectedPaymentOption.fee) {
35804
- _context.next = 21;
35811
+ _context.next = 17;
35805
35812
  break;
35806
35813
  }
35807
35814
  if (!selectedPaymentOption.fee.amount.match("%")) {
35808
35815
  _context.next = 10;
35809
35816
  break;
35810
35817
  }
35811
- _context.t1 = selectedPaymentOption.fromAmountBN.div(1000).mul(parseFloat(selectedPaymentOption.fee.amount.replace("%", '')) * 10);
35812
- _context.next = 18;
35818
+ selectedPaymentOption.feeAmountBN = selectedPaymentOption.fromAmountBN.mul(parseFloat(selectedPaymentOption.fee.amount.replace("%", '')) * 10).div(1000);
35819
+ _context.next = 17;
35813
35820
  break;
35814
35821
  case 10:
35815
35822
  if (!(typeof selectedPaymentOption.fee.amount === 'string')) {
35816
35823
  _context.next = 14;
35817
35824
  break;
35818
35825
  }
35819
- _context.t2 = selectedPaymentOption.fee.amount;
35826
+ selectedPaymentOption.feeAmountBN = selectedPaymentOption.fee.amount;
35820
35827
  _context.next = 17;
35821
35828
  break;
35822
35829
  case 14:
@@ -35827,29 +35834,17 @@
35827
35834
  address: selectedPaymentOption.token
35828
35835
  });
35829
35836
  case 16:
35830
- _context.t2 = _context.sent;
35837
+ selectedPaymentOption.feeAmountBN = _context.sent;
35831
35838
  case 17:
35832
- _context.t1 = _context.t2;
35833
- case 18:
35834
- _context.t0 = _context.t1;
35835
- _context.next = 24;
35836
- break;
35837
- case 21:
35838
- _context.next = 23;
35839
- return Token.BigNumber({
35840
- amount: 0,
35841
- blockchain: 'solana',
35842
- address: selectedPaymentOption.token
35843
- });
35844
- case 23:
35845
- _context.t0 = _context.sent;
35846
- case 24:
35847
- selectedPaymentOption.feeAmountBN = _context.t0;
35848
- selectedPaymentOption.toAmountBN = selectedPaymentOption.fee ? selectedPaymentOption.fromAmountBN.sub(selectedPaymentOption.feeAmountBN) : selectedPaymentOption.fromAmountBN;
35839
+ if (selectedPaymentOption.fee) {
35840
+ selectedPaymentOption.toAmountBN = selectedPaymentOption.fromAmountBN.sub(selectedPaymentOption.feeAmountBN);
35841
+ } else {
35842
+ selectedPaymentOption.toAmountBN = selectedPaymentOption.fromAmountBN;
35843
+ }
35849
35844
  setSelectedPaymantOption(selectedPaymentOption);
35850
35845
  setState('wait');
35851
35846
  openSolanaPayTransactionSocket(secretId, selectedPaymentOption);
35852
- case 29:
35847
+ case 21:
35853
35848
  case "end":
35854
35849
  return _context.stop();
35855
35850
  }
@@ -35879,7 +35874,24 @@
35879
35874
  var payment = _ref2.payment,
35880
35875
  resolve = _ref2.resolve,
35881
35876
  reject = _ref2.reject;
35882
- if (track.endpoint) {
35877
+ if (configurationId) {
35878
+ return fetch("https://public.depay.com/configurations/".concat(configurationId, "/attempts"), {
35879
+ method: 'POST',
35880
+ headers: {
35881
+ 'Content-Type': 'application/json'
35882
+ },
35883
+ body: JSON.stringify(payment)
35884
+ }).then(function (response) {
35885
+ if (response.status == 200 || response.status == 201) {
35886
+ response.json().then(function (attempt) {
35887
+ return setAttemptId(attempt.id);
35888
+ });
35889
+ return resolve();
35890
+ } else {
35891
+ return reject('TRACING REQUEST FAILED');
35892
+ }
35893
+ });
35894
+ } else if (track.endpoint) {
35883
35895
  return fetch(track.endpoint, {
35884
35896
  method: 'POST',
35885
35897
  headers: {
@@ -36097,11 +36109,13 @@
36097
36109
  };
36098
36110
  socket.onmessage = function (event) {
36099
36111
  if (event && event.data) {
36100
- var _data$params;
36112
+ var _data$params, _ref9, _data$params2;
36101
36113
  var data = JSON.parse(event.data);
36102
- if (data && data !== null && data !== void 0 && (_data$params = data.params) !== null && _data$params !== void 0 && (_data$params = _data$params.result) !== null && _data$params !== void 0 && _data$params.value) {
36103
- var _data$params2;
36104
- var result = data === null || data === void 0 || (_data$params2 = data.params) === null || _data$params2 === void 0 || (_data$params2 = _data$params2.result) === null || _data$params2 === void 0 ? void 0 : _data$params2.value;
36114
+ if (data && data !== null && data !== void 0 && (_data$params = data.params) !== null && _data$params !== void 0 && (_data$params = _data$params.result) !== null && _data$params !== void 0 && (_data$params = _data$params.value) !== null && _data$params !== void 0 && _data$params.logs && (_ref9 = (data === null || data === void 0 || (_data$params2 = data.params) === null || _data$params2 === void 0 || (_data$params2 = _data$params2.result) === null || _data$params2 === void 0 || (_data$params2 = _data$params2.value) === null || _data$params2 === void 0 ? void 0 : _data$params2.logs) || []) !== null && _ref9 !== void 0 && _ref9.find(function (log) {
36115
+ return log.match('Program DePayRG7ZySPWzeK9Kvq7aPeif7sdbBZNh6DHcvNj7F7');
36116
+ })) {
36117
+ var _data$params3;
36118
+ var result = data === null || data === void 0 || (_data$params3 = data.params) === null || _data$params3 === void 0 || (_data$params3 = _data$params3.result) === null || _data$params3 === void 0 ? void 0 : _data$params3.value;
36105
36119
  if (result && result.err === null) {
36106
36120
  setState('succeeded');
36107
36121
  setTransaction({
@@ -36145,7 +36159,7 @@
36145
36159
  var socket = new WebSocket('wss://integrate.depay.com/cable');
36146
36160
  setPaymentValidationSocket(socket);
36147
36161
  socket.onopen = /*#__PURE__*/function () {
36148
- var _ref9 = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee5(event) {
36162
+ var _ref10 = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee5(event) {
36149
36163
  var msg;
36150
36164
  return regenerator.wrap(function _callee5$(_context5) {
36151
36165
  while (1) switch (_context5.prev = _context5.next) {
@@ -36167,7 +36181,7 @@
36167
36181
  }, _callee5);
36168
36182
  }));
36169
36183
  return function (_x6) {
36170
- return _ref9.apply(this, arguments);
36184
+ return _ref10.apply(this, arguments);
36171
36185
  };
36172
36186
  }();
36173
36187
  socket.onclose = function (event) {
@@ -36210,6 +36224,7 @@
36210
36224
  };
36211
36225
  };
36212
36226
  var pollStatus = function pollStatus(transaction) {
36227
+ var _track$poll, _track$poll2;
36213
36228
  var payment = {
36214
36229
  blockchain: 'solana',
36215
36230
  transaction: transaction.id,
@@ -36236,7 +36251,22 @@
36236
36251
  setRelease(true);
36237
36252
  }
36238
36253
  };
36239
- if (track.poll.endpoint) {
36254
+ if (configurationId) {
36255
+ if (attemptId) {
36256
+ fetch("https://public.depay.com/attempts/".concat(attemptId), {
36257
+ method: 'GET',
36258
+ headers: {
36259
+ 'Content-Type': 'application/json'
36260
+ }
36261
+ }).then(function (response) {
36262
+ if (response.status == 200 || response.status == 201) {
36263
+ return response.json();
36264
+ } else {
36265
+ return undefined;
36266
+ }
36267
+ }).then(handlePollingResponse);
36268
+ }
36269
+ } else if (track !== null && track !== void 0 && (_track$poll = track.poll) !== null && _track$poll !== void 0 && _track$poll.endpoint) {
36240
36270
  fetch(track.poll.endpoint, {
36241
36271
  method: 'POST',
36242
36272
  headers: {
@@ -36252,7 +36282,7 @@
36252
36282
  return undefined;
36253
36283
  }
36254
36284
  }).then(handlePollingResponse);
36255
- } else if (track.poll.method) {
36285
+ } else if (track !== null && track !== void 0 && (_track$poll2 = track.poll) !== null && _track$poll2 !== void 0 && _track$poll2.method) {
36256
36286
  track.poll.method(payment).then(handlePollingResponse);
36257
36287
  }
36258
36288
  };
@@ -36263,9 +36293,9 @@
36263
36293
  }, 5000));
36264
36294
  }
36265
36295
  };
36266
- var trackTransaction = function trackTransaction(_ref10) {
36267
- var account = _ref10.account,
36268
- nonce = _ref10.nonce;
36296
+ var trackTransaction = function trackTransaction(_ref11) {
36297
+ var account = _ref11.account,
36298
+ nonce = _ref11.nonce;
36269
36299
  openTransactionTrackingSocket({
36270
36300
  account: account,
36271
36301
  nonce: nonce
@@ -36292,7 +36322,7 @@
36292
36322
  });
36293
36323
  _context7.next = 10;
36294
36324
  return Promise.all(relevantTransactions.map( /*#__PURE__*/function () {
36295
- var _ref12 = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee6(relevantTransaction) {
36325
+ var _ref13 = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee6(relevantTransaction) {
36296
36326
  var fullTransactionData, foundRouterInstruction;
36297
36327
  return regenerator.wrap(function _callee6$(_context6) {
36298
36328
  while (1) switch (_context6.prev = _context6.next) {
@@ -36343,7 +36373,7 @@
36343
36373
  }, _callee6);
36344
36374
  }));
36345
36375
  return function (_x7) {
36346
- return _ref12.apply(this, arguments);
36376
+ return _ref13.apply(this, arguments);
36347
36377
  };
36348
36378
  }()));
36349
36379
  case 10:
@@ -36356,7 +36386,7 @@
36356
36386
  })), 1000));
36357
36387
  };
36358
36388
  var traceAndContinue = /*#__PURE__*/function () {
36359
- var _ref13 = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee9(secretId, selectedPaymentOption, QRCodeURI) {
36389
+ var _ref14 = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee9(secretId, selectedPaymentOption, QRCodeURI) {
36360
36390
  return regenerator.wrap(function _callee9$(_context9) {
36361
36391
  while (1) switch (_context9.prev = _context9.next) {
36362
36392
  case 0:
@@ -36393,11 +36423,11 @@
36393
36423
  }, _callee9);
36394
36424
  }));
36395
36425
  return function traceAndContinue(_x8, _x9, _x10) {
36396
- return _ref13.apply(this, arguments);
36426
+ return _ref14.apply(this, arguments);
36397
36427
  };
36398
36428
  }();
36399
36429
  var storePayment = /*#__PURE__*/function () {
36400
- var _ref15 = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee10(transaction) {
36430
+ var _ref16 = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee10(transaction) {
36401
36431
  return regenerator.wrap(function _callee10$(_context10) {
36402
36432
  while (1) switch (_context10.prev = _context10.next) {
36403
36433
  case 0:
@@ -36447,7 +36477,7 @@
36447
36477
  }, _callee10);
36448
36478
  }));
36449
36479
  return function storePayment(_x11) {
36450
- return _ref15.apply(this, arguments);
36480
+ return _ref16.apply(this, arguments);
36451
36481
  };
36452
36482
  }();
36453
36483
  React.useEffect(function () {