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