@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.
package/dist/esm/index.js CHANGED
@@ -756,18 +756,18 @@ var allWallets = [{
756
756
  }, {
757
757
  "name": "Unstoppable Wallet",
758
758
  "desktop": {
759
- "qr": "WalletConnectV1"
759
+ "qr": "WalletConnectV2"
760
760
  },
761
761
  "mobile": {
762
762
  "ios": {
763
763
  "universal": "unstoppable.money://",
764
- "connect": "WalletConnectV1",
765
- "qr": "WalletConnectV1"
764
+ "connect": "WalletConnectV2",
765
+ "qr": "WalletConnectV2"
766
766
  },
767
767
  "android": {
768
768
  "universal": "unstoppable.money://",
769
- "connect": "WalletConnectV1",
770
- "qr": "WalletConnectV1"
769
+ "connect": "WalletConnectV2",
770
+ "qr": "WalletConnectV2"
771
771
  }
772
772
  },
773
773
  "logo": "https://img1.depay.com/wallets/unstoppable.jpg",
@@ -28099,82 +28099,89 @@ var SolanaPayDialog = (function (props) {
28099
28099
  validated = _useContext.validated,
28100
28100
  integration = _useContext.integration,
28101
28101
  link = _useContext.link,
28102
- type = _useContext.type;
28102
+ type = _useContext.type,
28103
+ configurationId = _useContext.id;
28104
+ var _useState = useState(),
28105
+ _useState2 = _slicedToArray(_useState, 2),
28106
+ attemptId = _useState2[0],
28107
+ setAttemptId = _useState2[1];
28108
+ var attemptIdRef = useRef(attemptId);
28109
+ attemptIdRef.current = attemptId;
28103
28110
  var _useContext2 = useContext(NavigateStackContext);
28104
28111
  _useContext2.set;
28105
28112
  _useContext2.navigate;
28106
28113
  var _useContext3 = useContext(ClosableContext),
28107
28114
  close = _useContext3.close,
28108
28115
  setClosable = _useContext3.setClosable;
28109
- var _useState = useState(),
28110
- _useState2 = _slicedToArray(_useState, 2),
28111
- paymentOptions = _useState2[0],
28112
- setPaymentOptions = _useState2[1];
28113
28116
  var _useState3 = useState(),
28114
28117
  _useState4 = _slicedToArray(_useState3, 2),
28115
- forwardTo = _useState4[0],
28116
- setForwardTo = _useState4[1];
28118
+ paymentOptions = _useState4[0],
28119
+ setPaymentOptions = _useState4[1];
28117
28120
  var _useState5 = useState(),
28118
28121
  _useState6 = _slicedToArray(_useState5, 2),
28119
- pollingPaymentStatusInterval = _useState6[0],
28120
- setPollingPaymentStatusInterval = _useState6[1];
28122
+ forwardTo = _useState6[0],
28123
+ setForwardTo = _useState6[1];
28121
28124
  var _useState7 = useState(),
28122
28125
  _useState8 = _slicedToArray(_useState7, 2),
28123
- transactionTrackingInterval = _useState8[0],
28124
- setTransactionTrackingInterval = _useState8[1];
28126
+ pollingPaymentStatusInterval = _useState8[0],
28127
+ setPollingPaymentStatusInterval = _useState8[1];
28125
28128
  var _useState9 = useState(),
28126
28129
  _useState10 = _slicedToArray(_useState9, 2),
28127
- selectedPaymentOption = _useState10[0],
28128
- setSelectedPaymantOption = _useState10[1];
28130
+ transactionTrackingInterval = _useState10[0],
28131
+ setTransactionTrackingInterval = _useState10[1];
28129
28132
  var _useState11 = useState(),
28130
28133
  _useState12 = _slicedToArray(_useState11, 2),
28131
- transaction = _useState12[0],
28132
- setTransaction = _useState12[1];
28134
+ selectedPaymentOption = _useState12[0],
28135
+ setSelectedPaymantOption = _useState12[1];
28133
28136
  var _useState13 = useState(),
28134
28137
  _useState14 = _slicedToArray(_useState13, 2),
28135
- secretId = _useState14[0],
28136
- setSecretId = _useState14[1];
28138
+ transaction = _useState14[0],
28139
+ setTransaction = _useState14[1];
28137
28140
  var _useState15 = useState(),
28138
28141
  _useState16 = _slicedToArray(_useState15, 2),
28139
- solanaPayTransactionSocket = _useState16[0],
28140
- setSolanaPayTransactionSocket = _useState16[1];
28142
+ secretId = _useState16[0],
28143
+ setSecretId = _useState16[1];
28141
28144
  var _useState17 = useState(),
28142
28145
  _useState18 = _slicedToArray(_useState17, 2),
28143
- transactionTrackingSocket = _useState18[0],
28144
- setTransactionTrackingSocket = _useState18[1];
28146
+ solanaPayTransactionSocket = _useState18[0],
28147
+ setSolanaPayTransactionSocket = _useState18[1];
28145
28148
  var _useState19 = useState(),
28146
28149
  _useState20 = _slicedToArray(_useState19, 2),
28147
- paymentValidationSocket = _useState20[0],
28148
- setPaymentValidationSocket = _useState20[1];
28150
+ transactionTrackingSocket = _useState20[0],
28151
+ setTransactionTrackingSocket = _useState20[1];
28149
28152
  var _useState21 = useState(),
28150
28153
  _useState22 = _slicedToArray(_useState21, 2),
28151
- QRCodeURI = _useState22[0],
28152
- setQRCodeURI = _useState22[1];
28154
+ paymentValidationSocket = _useState22[0],
28155
+ setPaymentValidationSocket = _useState22[1];
28153
28156
  var _useState23 = useState(),
28154
28157
  _useState24 = _slicedToArray(_useState23, 2),
28155
- release = _useState24[0],
28156
- setRelease = _useState24[1];
28158
+ QRCodeURI = _useState24[0],
28159
+ setQRCodeURI = _useState24[1];
28157
28160
  var _useState25 = useState(),
28158
28161
  _useState26 = _slicedToArray(_useState25, 2),
28159
- afterBlock = _useState26[0],
28160
- setAfterBlock = _useState26[1];
28162
+ release = _useState26[0],
28163
+ setRelease = _useState26[1];
28161
28164
  var _useState27 = useState(),
28162
28165
  _useState28 = _slicedToArray(_useState27, 2),
28163
- QRCode = _useState28[0],
28164
- setQRCode = _useState28[1];
28165
- var _useState29 = useState('select'),
28166
+ afterBlock = _useState28[0],
28167
+ setAfterBlock = _useState28[1];
28168
+ var _useState29 = useState(),
28166
28169
  _useState30 = _slicedToArray(_useState29, 2),
28167
- state = _useState30[0],
28168
- setState = _useState30[1];
28169
- var _useState31 = useState(!!(track && track.poll && (track.poll.endpoint || typeof track.poll.method == 'function') && track.async != true)),
28170
- _useState32 = _slicedToArray(_useState31, 1),
28171
- polling = _useState32[0];
28172
- var _useState33 = useState(!!(track && (track.endpoint || typeof track.method == 'function') && track.async != true)),
28170
+ QRCode = _useState30[0],
28171
+ setQRCode = _useState30[1];
28172
+ var _useState31 = useState('select'),
28173
+ _useState32 = _slicedToArray(_useState31, 2),
28174
+ state = _useState32[0],
28175
+ setState = _useState32[1];
28176
+ var _useState33 = useState(!!configurationId || !!(track && (track.endpoint || typeof track.method == 'function') && track.async != true)),
28173
28177
  _useState34 = _slicedToArray(_useState33, 1),
28174
28178
  synchronousTracking = _useState34[0];
28175
- var _useState35 = useState(!!(track && track.async == true)),
28179
+ var _useState35 = useState(!configurationId && !!(track && track.async == true)),
28176
28180
  _useState36 = _slicedToArray(_useState35, 1),
28177
28181
  asynchronousTracking = _useState36[0];
28182
+ var _useState37 = useState(!!configurationId || !!(track && track.poll && (track.poll.endpoint || typeof track.poll.method == 'function') && track.async != true)),
28183
+ _useState38 = _slicedToArray(_useState37, 1),
28184
+ polling = _useState38[0];
28178
28185
  var isTracking = synchronousTracking || asynchronousTracking;
28179
28186
  var QRCodeElement = React.useRef();
28180
28187
  var selectPaymentOption = /*#__PURE__*/function () {
@@ -28194,22 +28201,22 @@ var SolanaPayDialog = (function (props) {
28194
28201
  case 4:
28195
28202
  selectedPaymentOption.fromAmountBN = _context.sent;
28196
28203
  if (!selectedPaymentOption.fee) {
28197
- _context.next = 21;
28204
+ _context.next = 17;
28198
28205
  break;
28199
28206
  }
28200
28207
  if (!selectedPaymentOption.fee.amount.match("%")) {
28201
28208
  _context.next = 10;
28202
28209
  break;
28203
28210
  }
28204
- _context.t1 = selectedPaymentOption.fromAmountBN.div(1000).mul(parseFloat(selectedPaymentOption.fee.amount.replace("%", '')) * 10);
28205
- _context.next = 18;
28211
+ selectedPaymentOption.feeAmountBN = selectedPaymentOption.fromAmountBN.mul(parseFloat(selectedPaymentOption.fee.amount.replace("%", '')) * 10).div(1000);
28212
+ _context.next = 17;
28206
28213
  break;
28207
28214
  case 10:
28208
28215
  if (!(typeof selectedPaymentOption.fee.amount === 'string')) {
28209
28216
  _context.next = 14;
28210
28217
  break;
28211
28218
  }
28212
- _context.t2 = selectedPaymentOption.fee.amount;
28219
+ selectedPaymentOption.feeAmountBN = selectedPaymentOption.fee.amount;
28213
28220
  _context.next = 17;
28214
28221
  break;
28215
28222
  case 14:
@@ -28220,29 +28227,17 @@ var SolanaPayDialog = (function (props) {
28220
28227
  address: selectedPaymentOption.token
28221
28228
  });
28222
28229
  case 16:
28223
- _context.t2 = _context.sent;
28230
+ selectedPaymentOption.feeAmountBN = _context.sent;
28224
28231
  case 17:
28225
- _context.t1 = _context.t2;
28226
- case 18:
28227
- _context.t0 = _context.t1;
28228
- _context.next = 24;
28229
- break;
28230
- case 21:
28231
- _context.next = 23;
28232
- return Token.BigNumber({
28233
- amount: 0,
28234
- blockchain: 'solana',
28235
- address: selectedPaymentOption.token
28236
- });
28237
- case 23:
28238
- _context.t0 = _context.sent;
28239
- case 24:
28240
- selectedPaymentOption.feeAmountBN = _context.t0;
28241
- selectedPaymentOption.toAmountBN = selectedPaymentOption.fee ? selectedPaymentOption.fromAmountBN.sub(selectedPaymentOption.feeAmountBN) : selectedPaymentOption.fromAmountBN;
28232
+ if (selectedPaymentOption.fee) {
28233
+ selectedPaymentOption.toAmountBN = selectedPaymentOption.fromAmountBN.sub(selectedPaymentOption.feeAmountBN);
28234
+ } else {
28235
+ selectedPaymentOption.toAmountBN = selectedPaymentOption.fromAmountBN;
28236
+ }
28242
28237
  setSelectedPaymantOption(selectedPaymentOption);
28243
28238
  setState('wait');
28244
28239
  openSolanaPayTransactionSocket(secretId, selectedPaymentOption);
28245
- case 29:
28240
+ case 21:
28246
28241
  case "end":
28247
28242
  return _context.stop();
28248
28243
  }
@@ -28272,7 +28267,24 @@ var SolanaPayDialog = (function (props) {
28272
28267
  var payment = _ref2.payment,
28273
28268
  resolve = _ref2.resolve,
28274
28269
  reject = _ref2.reject;
28275
- if (track.endpoint) {
28270
+ if (configurationId) {
28271
+ return fetch("https://public.depay.com/configurations/".concat(configurationId, "/attempts"), {
28272
+ method: 'POST',
28273
+ headers: {
28274
+ 'Content-Type': 'application/json'
28275
+ },
28276
+ body: JSON.stringify(payment)
28277
+ }).then(function (response) {
28278
+ if (response.status == 200 || response.status == 201) {
28279
+ response.json().then(function (attempt) {
28280
+ return setAttemptId(attempt.id);
28281
+ });
28282
+ return resolve();
28283
+ } else {
28284
+ return reject('TRACING REQUEST FAILED');
28285
+ }
28286
+ });
28287
+ } else if (track.endpoint) {
28276
28288
  return fetch(track.endpoint, {
28277
28289
  method: 'POST',
28278
28290
  headers: {
@@ -28490,11 +28502,13 @@ var SolanaPayDialog = (function (props) {
28490
28502
  };
28491
28503
  socket.onmessage = function (event) {
28492
28504
  if (event && event.data) {
28493
- var _data$params;
28505
+ var _data$params, _ref9, _data$params2;
28494
28506
  var data = JSON.parse(event.data);
28495
- 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) {
28496
- var _data$params2;
28497
- 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;
28507
+ 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) {
28508
+ return log.match('Program DePayRG7ZySPWzeK9Kvq7aPeif7sdbBZNh6DHcvNj7F7');
28509
+ })) {
28510
+ var _data$params3;
28511
+ 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;
28498
28512
  if (result && result.err === null) {
28499
28513
  setState('succeeded');
28500
28514
  setTransaction({
@@ -28538,7 +28552,7 @@ var SolanaPayDialog = (function (props) {
28538
28552
  var socket = new WebSocket('wss://integrate.depay.com/cable');
28539
28553
  setPaymentValidationSocket(socket);
28540
28554
  socket.onopen = /*#__PURE__*/function () {
28541
- var _ref9 = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee5(event) {
28555
+ var _ref10 = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee5(event) {
28542
28556
  var msg;
28543
28557
  return regenerator.wrap(function _callee5$(_context5) {
28544
28558
  while (1) switch (_context5.prev = _context5.next) {
@@ -28560,7 +28574,7 @@ var SolanaPayDialog = (function (props) {
28560
28574
  }, _callee5);
28561
28575
  }));
28562
28576
  return function (_x6) {
28563
- return _ref9.apply(this, arguments);
28577
+ return _ref10.apply(this, arguments);
28564
28578
  };
28565
28579
  }();
28566
28580
  socket.onclose = function (event) {
@@ -28603,6 +28617,7 @@ var SolanaPayDialog = (function (props) {
28603
28617
  };
28604
28618
  };
28605
28619
  var pollStatus = function pollStatus(transaction) {
28620
+ var _track$poll, _track$poll2;
28606
28621
  var payment = {
28607
28622
  blockchain: 'solana',
28608
28623
  transaction: transaction.id,
@@ -28629,7 +28644,22 @@ var SolanaPayDialog = (function (props) {
28629
28644
  setRelease(true);
28630
28645
  }
28631
28646
  };
28632
- if (track.poll.endpoint) {
28647
+ if (configurationId) {
28648
+ if (attemptId) {
28649
+ fetch("https://public.depay.com/attempts/".concat(attemptId), {
28650
+ method: 'GET',
28651
+ headers: {
28652
+ 'Content-Type': 'application/json'
28653
+ }
28654
+ }).then(function (response) {
28655
+ if (response.status == 200 || response.status == 201) {
28656
+ return response.json();
28657
+ } else {
28658
+ return undefined;
28659
+ }
28660
+ }).then(handlePollingResponse);
28661
+ }
28662
+ } else if (track !== null && track !== void 0 && (_track$poll = track.poll) !== null && _track$poll !== void 0 && _track$poll.endpoint) {
28633
28663
  fetch(track.poll.endpoint, {
28634
28664
  method: 'POST',
28635
28665
  headers: {
@@ -28645,7 +28675,7 @@ var SolanaPayDialog = (function (props) {
28645
28675
  return undefined;
28646
28676
  }
28647
28677
  }).then(handlePollingResponse);
28648
- } else if (track.poll.method) {
28678
+ } else if (track !== null && track !== void 0 && (_track$poll2 = track.poll) !== null && _track$poll2 !== void 0 && _track$poll2.method) {
28649
28679
  track.poll.method(payment).then(handlePollingResponse);
28650
28680
  }
28651
28681
  };
@@ -28656,9 +28686,9 @@ var SolanaPayDialog = (function (props) {
28656
28686
  }, 5000));
28657
28687
  }
28658
28688
  };
28659
- var trackTransaction = function trackTransaction(_ref10) {
28660
- var account = _ref10.account,
28661
- nonce = _ref10.nonce;
28689
+ var trackTransaction = function trackTransaction(_ref11) {
28690
+ var account = _ref11.account,
28691
+ nonce = _ref11.nonce;
28662
28692
  openTransactionTrackingSocket({
28663
28693
  account: account,
28664
28694
  nonce: nonce
@@ -28685,7 +28715,7 @@ var SolanaPayDialog = (function (props) {
28685
28715
  });
28686
28716
  _context7.next = 10;
28687
28717
  return Promise.all(relevantTransactions.map( /*#__PURE__*/function () {
28688
- var _ref12 = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee6(relevantTransaction) {
28718
+ var _ref13 = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee6(relevantTransaction) {
28689
28719
  var fullTransactionData, foundRouterInstruction;
28690
28720
  return regenerator.wrap(function _callee6$(_context6) {
28691
28721
  while (1) switch (_context6.prev = _context6.next) {
@@ -28736,7 +28766,7 @@ var SolanaPayDialog = (function (props) {
28736
28766
  }, _callee6);
28737
28767
  }));
28738
28768
  return function (_x7) {
28739
- return _ref12.apply(this, arguments);
28769
+ return _ref13.apply(this, arguments);
28740
28770
  };
28741
28771
  }()));
28742
28772
  case 10:
@@ -28749,7 +28779,7 @@ var SolanaPayDialog = (function (props) {
28749
28779
  })), 1000));
28750
28780
  };
28751
28781
  var traceAndContinue = /*#__PURE__*/function () {
28752
- var _ref13 = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee9(secretId, selectedPaymentOption, QRCodeURI) {
28782
+ var _ref14 = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee9(secretId, selectedPaymentOption, QRCodeURI) {
28753
28783
  return regenerator.wrap(function _callee9$(_context9) {
28754
28784
  while (1) switch (_context9.prev = _context9.next) {
28755
28785
  case 0:
@@ -28786,11 +28816,11 @@ var SolanaPayDialog = (function (props) {
28786
28816
  }, _callee9);
28787
28817
  }));
28788
28818
  return function traceAndContinue(_x8, _x9, _x10) {
28789
- return _ref13.apply(this, arguments);
28819
+ return _ref14.apply(this, arguments);
28790
28820
  };
28791
28821
  }();
28792
28822
  var storePayment = /*#__PURE__*/function () {
28793
- var _ref15 = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee10(transaction) {
28823
+ var _ref16 = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee10(transaction) {
28794
28824
  return regenerator.wrap(function _callee10$(_context10) {
28795
28825
  while (1) switch (_context10.prev = _context10.next) {
28796
28826
  case 0:
@@ -28840,7 +28870,7 @@ var SolanaPayDialog = (function (props) {
28840
28870
  }, _callee10);
28841
28871
  }));
28842
28872
  return function storePayment(_x11) {
28843
- return _ref15.apply(this, arguments);
28873
+ return _ref16.apply(this, arguments);
28844
28874
  };
28845
28875
  }();
28846
28876
  useEffect(function () {