@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/umd/index.js CHANGED
@@ -752,18 +752,18 @@
752
752
  }, {
753
753
  "name": "Unstoppable Wallet",
754
754
  "desktop": {
755
- "qr": "WalletConnectV1"
755
+ "qr": "WalletConnectV2"
756
756
  },
757
757
  "mobile": {
758
758
  "ios": {
759
759
  "universal": "unstoppable.money://",
760
- "connect": "WalletConnectV1",
761
- "qr": "WalletConnectV1"
760
+ "connect": "WalletConnectV2",
761
+ "qr": "WalletConnectV2"
762
762
  },
763
763
  "android": {
764
764
  "universal": "unstoppable.money://",
765
- "connect": "WalletConnectV1",
766
- "qr": "WalletConnectV1"
765
+ "connect": "WalletConnectV2",
766
+ "qr": "WalletConnectV2"
767
767
  }
768
768
  },
769
769
  "logo": "https://img1.depay.com/wallets/unstoppable.jpg",
@@ -28095,82 +28095,89 @@
28095
28095
  validated = _useContext.validated,
28096
28096
  integration = _useContext.integration,
28097
28097
  link = _useContext.link,
28098
- type = _useContext.type;
28098
+ type = _useContext.type,
28099
+ configurationId = _useContext.id;
28100
+ var _useState = React.useState(),
28101
+ _useState2 = _slicedToArray(_useState, 2),
28102
+ attemptId = _useState2[0],
28103
+ setAttemptId = _useState2[1];
28104
+ var attemptIdRef = React.useRef(attemptId);
28105
+ attemptIdRef.current = attemptId;
28099
28106
  var _useContext2 = React.useContext(reactDialogStack.NavigateStackContext);
28100
28107
  _useContext2.set;
28101
28108
  _useContext2.navigate;
28102
28109
  var _useContext3 = React.useContext(ClosableContext),
28103
28110
  close = _useContext3.close,
28104
28111
  setClosable = _useContext3.setClosable;
28105
- var _useState = React.useState(),
28106
- _useState2 = _slicedToArray(_useState, 2),
28107
- paymentOptions = _useState2[0],
28108
- setPaymentOptions = _useState2[1];
28109
28112
  var _useState3 = React.useState(),
28110
28113
  _useState4 = _slicedToArray(_useState3, 2),
28111
- forwardTo = _useState4[0],
28112
- setForwardTo = _useState4[1];
28114
+ paymentOptions = _useState4[0],
28115
+ setPaymentOptions = _useState4[1];
28113
28116
  var _useState5 = React.useState(),
28114
28117
  _useState6 = _slicedToArray(_useState5, 2),
28115
- pollingPaymentStatusInterval = _useState6[0],
28116
- setPollingPaymentStatusInterval = _useState6[1];
28118
+ forwardTo = _useState6[0],
28119
+ setForwardTo = _useState6[1];
28117
28120
  var _useState7 = React.useState(),
28118
28121
  _useState8 = _slicedToArray(_useState7, 2),
28119
- transactionTrackingInterval = _useState8[0],
28120
- setTransactionTrackingInterval = _useState8[1];
28122
+ pollingPaymentStatusInterval = _useState8[0],
28123
+ setPollingPaymentStatusInterval = _useState8[1];
28121
28124
  var _useState9 = React.useState(),
28122
28125
  _useState10 = _slicedToArray(_useState9, 2),
28123
- selectedPaymentOption = _useState10[0],
28124
- setSelectedPaymantOption = _useState10[1];
28126
+ transactionTrackingInterval = _useState10[0],
28127
+ setTransactionTrackingInterval = _useState10[1];
28125
28128
  var _useState11 = React.useState(),
28126
28129
  _useState12 = _slicedToArray(_useState11, 2),
28127
- transaction = _useState12[0],
28128
- setTransaction = _useState12[1];
28130
+ selectedPaymentOption = _useState12[0],
28131
+ setSelectedPaymantOption = _useState12[1];
28129
28132
  var _useState13 = React.useState(),
28130
28133
  _useState14 = _slicedToArray(_useState13, 2),
28131
- secretId = _useState14[0],
28132
- setSecretId = _useState14[1];
28134
+ transaction = _useState14[0],
28135
+ setTransaction = _useState14[1];
28133
28136
  var _useState15 = React.useState(),
28134
28137
  _useState16 = _slicedToArray(_useState15, 2),
28135
- solanaPayTransactionSocket = _useState16[0],
28136
- setSolanaPayTransactionSocket = _useState16[1];
28138
+ secretId = _useState16[0],
28139
+ setSecretId = _useState16[1];
28137
28140
  var _useState17 = React.useState(),
28138
28141
  _useState18 = _slicedToArray(_useState17, 2),
28139
- transactionTrackingSocket = _useState18[0],
28140
- setTransactionTrackingSocket = _useState18[1];
28142
+ solanaPayTransactionSocket = _useState18[0],
28143
+ setSolanaPayTransactionSocket = _useState18[1];
28141
28144
  var _useState19 = React.useState(),
28142
28145
  _useState20 = _slicedToArray(_useState19, 2),
28143
- paymentValidationSocket = _useState20[0],
28144
- setPaymentValidationSocket = _useState20[1];
28146
+ transactionTrackingSocket = _useState20[0],
28147
+ setTransactionTrackingSocket = _useState20[1];
28145
28148
  var _useState21 = React.useState(),
28146
28149
  _useState22 = _slicedToArray(_useState21, 2),
28147
- QRCodeURI = _useState22[0],
28148
- setQRCodeURI = _useState22[1];
28150
+ paymentValidationSocket = _useState22[0],
28151
+ setPaymentValidationSocket = _useState22[1];
28149
28152
  var _useState23 = React.useState(),
28150
28153
  _useState24 = _slicedToArray(_useState23, 2),
28151
- release = _useState24[0],
28152
- setRelease = _useState24[1];
28154
+ QRCodeURI = _useState24[0],
28155
+ setQRCodeURI = _useState24[1];
28153
28156
  var _useState25 = React.useState(),
28154
28157
  _useState26 = _slicedToArray(_useState25, 2),
28155
- afterBlock = _useState26[0],
28156
- setAfterBlock = _useState26[1];
28158
+ release = _useState26[0],
28159
+ setRelease = _useState26[1];
28157
28160
  var _useState27 = React.useState(),
28158
28161
  _useState28 = _slicedToArray(_useState27, 2),
28159
- QRCode = _useState28[0],
28160
- setQRCode = _useState28[1];
28161
- var _useState29 = React.useState('select'),
28162
+ afterBlock = _useState28[0],
28163
+ setAfterBlock = _useState28[1];
28164
+ var _useState29 = React.useState(),
28162
28165
  _useState30 = _slicedToArray(_useState29, 2),
28163
- state = _useState30[0],
28164
- setState = _useState30[1];
28165
- var _useState31 = React.useState(!!(track && track.poll && (track.poll.endpoint || typeof track.poll.method == 'function') && track.async != true)),
28166
- _useState32 = _slicedToArray(_useState31, 1),
28167
- polling = _useState32[0];
28168
- var _useState33 = React.useState(!!(track && (track.endpoint || typeof track.method == 'function') && track.async != true)),
28166
+ QRCode = _useState30[0],
28167
+ setQRCode = _useState30[1];
28168
+ var _useState31 = React.useState('select'),
28169
+ _useState32 = _slicedToArray(_useState31, 2),
28170
+ state = _useState32[0],
28171
+ setState = _useState32[1];
28172
+ var _useState33 = React.useState(!!configurationId || !!(track && (track.endpoint || typeof track.method == 'function') && track.async != true)),
28169
28173
  _useState34 = _slicedToArray(_useState33, 1),
28170
28174
  synchronousTracking = _useState34[0];
28171
- var _useState35 = React.useState(!!(track && track.async == true)),
28175
+ var _useState35 = React.useState(!configurationId && !!(track && track.async == true)),
28172
28176
  _useState36 = _slicedToArray(_useState35, 1),
28173
28177
  asynchronousTracking = _useState36[0];
28178
+ var _useState37 = React.useState(!!configurationId || !!(track && track.poll && (track.poll.endpoint || typeof track.poll.method == 'function') && track.async != true)),
28179
+ _useState38 = _slicedToArray(_useState37, 1),
28180
+ polling = _useState38[0];
28174
28181
  var isTracking = synchronousTracking || asynchronousTracking;
28175
28182
  var QRCodeElement = React__default["default"].useRef();
28176
28183
  var selectPaymentOption = /*#__PURE__*/function () {
@@ -28190,22 +28197,22 @@
28190
28197
  case 4:
28191
28198
  selectedPaymentOption.fromAmountBN = _context.sent;
28192
28199
  if (!selectedPaymentOption.fee) {
28193
- _context.next = 21;
28200
+ _context.next = 17;
28194
28201
  break;
28195
28202
  }
28196
28203
  if (!selectedPaymentOption.fee.amount.match("%")) {
28197
28204
  _context.next = 10;
28198
28205
  break;
28199
28206
  }
28200
- _context.t1 = selectedPaymentOption.fromAmountBN.div(1000).mul(parseFloat(selectedPaymentOption.fee.amount.replace("%", '')) * 10);
28201
- _context.next = 18;
28207
+ selectedPaymentOption.feeAmountBN = selectedPaymentOption.fromAmountBN.mul(parseFloat(selectedPaymentOption.fee.amount.replace("%", '')) * 10).div(1000);
28208
+ _context.next = 17;
28202
28209
  break;
28203
28210
  case 10:
28204
28211
  if (!(typeof selectedPaymentOption.fee.amount === 'string')) {
28205
28212
  _context.next = 14;
28206
28213
  break;
28207
28214
  }
28208
- _context.t2 = selectedPaymentOption.fee.amount;
28215
+ selectedPaymentOption.feeAmountBN = selectedPaymentOption.fee.amount;
28209
28216
  _context.next = 17;
28210
28217
  break;
28211
28218
  case 14:
@@ -28216,29 +28223,17 @@
28216
28223
  address: selectedPaymentOption.token
28217
28224
  });
28218
28225
  case 16:
28219
- _context.t2 = _context.sent;
28226
+ selectedPaymentOption.feeAmountBN = _context.sent;
28220
28227
  case 17:
28221
- _context.t1 = _context.t2;
28222
- case 18:
28223
- _context.t0 = _context.t1;
28224
- _context.next = 24;
28225
- break;
28226
- case 21:
28227
- _context.next = 23;
28228
- return Token__default["default"].BigNumber({
28229
- amount: 0,
28230
- blockchain: 'solana',
28231
- address: selectedPaymentOption.token
28232
- });
28233
- case 23:
28234
- _context.t0 = _context.sent;
28235
- case 24:
28236
- selectedPaymentOption.feeAmountBN = _context.t0;
28237
- selectedPaymentOption.toAmountBN = selectedPaymentOption.fee ? selectedPaymentOption.fromAmountBN.sub(selectedPaymentOption.feeAmountBN) : selectedPaymentOption.fromAmountBN;
28228
+ if (selectedPaymentOption.fee) {
28229
+ selectedPaymentOption.toAmountBN = selectedPaymentOption.fromAmountBN.sub(selectedPaymentOption.feeAmountBN);
28230
+ } else {
28231
+ selectedPaymentOption.toAmountBN = selectedPaymentOption.fromAmountBN;
28232
+ }
28238
28233
  setSelectedPaymantOption(selectedPaymentOption);
28239
28234
  setState('wait');
28240
28235
  openSolanaPayTransactionSocket(secretId, selectedPaymentOption);
28241
- case 29:
28236
+ case 21:
28242
28237
  case "end":
28243
28238
  return _context.stop();
28244
28239
  }
@@ -28268,7 +28263,24 @@
28268
28263
  var payment = _ref2.payment,
28269
28264
  resolve = _ref2.resolve,
28270
28265
  reject = _ref2.reject;
28271
- if (track.endpoint) {
28266
+ if (configurationId) {
28267
+ return fetch("https://public.depay.com/configurations/".concat(configurationId, "/attempts"), {
28268
+ method: 'POST',
28269
+ headers: {
28270
+ 'Content-Type': 'application/json'
28271
+ },
28272
+ body: JSON.stringify(payment)
28273
+ }).then(function (response) {
28274
+ if (response.status == 200 || response.status == 201) {
28275
+ response.json().then(function (attempt) {
28276
+ return setAttemptId(attempt.id);
28277
+ });
28278
+ return resolve();
28279
+ } else {
28280
+ return reject('TRACING REQUEST FAILED');
28281
+ }
28282
+ });
28283
+ } else if (track.endpoint) {
28272
28284
  return fetch(track.endpoint, {
28273
28285
  method: 'POST',
28274
28286
  headers: {
@@ -28486,11 +28498,13 @@
28486
28498
  };
28487
28499
  socket.onmessage = function (event) {
28488
28500
  if (event && event.data) {
28489
- var _data$params;
28501
+ var _data$params, _ref9, _data$params2;
28490
28502
  var data = JSON.parse(event.data);
28491
- 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) {
28492
- var _data$params2;
28493
- 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;
28503
+ 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) {
28504
+ return log.match('Program DePayRG7ZySPWzeK9Kvq7aPeif7sdbBZNh6DHcvNj7F7');
28505
+ })) {
28506
+ var _data$params3;
28507
+ 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;
28494
28508
  if (result && result.err === null) {
28495
28509
  setState('succeeded');
28496
28510
  setTransaction({
@@ -28534,7 +28548,7 @@
28534
28548
  var socket = new WebSocket('wss://integrate.depay.com/cable');
28535
28549
  setPaymentValidationSocket(socket);
28536
28550
  socket.onopen = /*#__PURE__*/function () {
28537
- var _ref9 = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee5(event) {
28551
+ var _ref10 = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee5(event) {
28538
28552
  var msg;
28539
28553
  return regenerator.wrap(function _callee5$(_context5) {
28540
28554
  while (1) switch (_context5.prev = _context5.next) {
@@ -28556,7 +28570,7 @@
28556
28570
  }, _callee5);
28557
28571
  }));
28558
28572
  return function (_x6) {
28559
- return _ref9.apply(this, arguments);
28573
+ return _ref10.apply(this, arguments);
28560
28574
  };
28561
28575
  }();
28562
28576
  socket.onclose = function (event) {
@@ -28599,6 +28613,7 @@
28599
28613
  };
28600
28614
  };
28601
28615
  var pollStatus = function pollStatus(transaction) {
28616
+ var _track$poll, _track$poll2;
28602
28617
  var payment = {
28603
28618
  blockchain: 'solana',
28604
28619
  transaction: transaction.id,
@@ -28625,7 +28640,22 @@
28625
28640
  setRelease(true);
28626
28641
  }
28627
28642
  };
28628
- if (track.poll.endpoint) {
28643
+ if (configurationId) {
28644
+ if (attemptId) {
28645
+ fetch("https://public.depay.com/attempts/".concat(attemptId), {
28646
+ method: 'GET',
28647
+ headers: {
28648
+ 'Content-Type': 'application/json'
28649
+ }
28650
+ }).then(function (response) {
28651
+ if (response.status == 200 || response.status == 201) {
28652
+ return response.json();
28653
+ } else {
28654
+ return undefined;
28655
+ }
28656
+ }).then(handlePollingResponse);
28657
+ }
28658
+ } else if (track !== null && track !== void 0 && (_track$poll = track.poll) !== null && _track$poll !== void 0 && _track$poll.endpoint) {
28629
28659
  fetch(track.poll.endpoint, {
28630
28660
  method: 'POST',
28631
28661
  headers: {
@@ -28641,7 +28671,7 @@
28641
28671
  return undefined;
28642
28672
  }
28643
28673
  }).then(handlePollingResponse);
28644
- } else if (track.poll.method) {
28674
+ } else if (track !== null && track !== void 0 && (_track$poll2 = track.poll) !== null && _track$poll2 !== void 0 && _track$poll2.method) {
28645
28675
  track.poll.method(payment).then(handlePollingResponse);
28646
28676
  }
28647
28677
  };
@@ -28652,9 +28682,9 @@
28652
28682
  }, 5000));
28653
28683
  }
28654
28684
  };
28655
- var trackTransaction = function trackTransaction(_ref10) {
28656
- var account = _ref10.account,
28657
- nonce = _ref10.nonce;
28685
+ var trackTransaction = function trackTransaction(_ref11) {
28686
+ var account = _ref11.account,
28687
+ nonce = _ref11.nonce;
28658
28688
  openTransactionTrackingSocket({
28659
28689
  account: account,
28660
28690
  nonce: nonce
@@ -28681,7 +28711,7 @@
28681
28711
  });
28682
28712
  _context7.next = 10;
28683
28713
  return Promise.all(relevantTransactions.map( /*#__PURE__*/function () {
28684
- var _ref12 = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee6(relevantTransaction) {
28714
+ var _ref13 = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee6(relevantTransaction) {
28685
28715
  var fullTransactionData, foundRouterInstruction;
28686
28716
  return regenerator.wrap(function _callee6$(_context6) {
28687
28717
  while (1) switch (_context6.prev = _context6.next) {
@@ -28732,7 +28762,7 @@
28732
28762
  }, _callee6);
28733
28763
  }));
28734
28764
  return function (_x7) {
28735
- return _ref12.apply(this, arguments);
28765
+ return _ref13.apply(this, arguments);
28736
28766
  };
28737
28767
  }()));
28738
28768
  case 10:
@@ -28745,7 +28775,7 @@
28745
28775
  })), 1000));
28746
28776
  };
28747
28777
  var traceAndContinue = /*#__PURE__*/function () {
28748
- var _ref13 = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee9(secretId, selectedPaymentOption, QRCodeURI) {
28778
+ var _ref14 = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee9(secretId, selectedPaymentOption, QRCodeURI) {
28749
28779
  return regenerator.wrap(function _callee9$(_context9) {
28750
28780
  while (1) switch (_context9.prev = _context9.next) {
28751
28781
  case 0:
@@ -28782,11 +28812,11 @@
28782
28812
  }, _callee9);
28783
28813
  }));
28784
28814
  return function traceAndContinue(_x8, _x9, _x10) {
28785
- return _ref13.apply(this, arguments);
28815
+ return _ref14.apply(this, arguments);
28786
28816
  };
28787
28817
  }();
28788
28818
  var storePayment = /*#__PURE__*/function () {
28789
- var _ref15 = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee10(transaction) {
28819
+ var _ref16 = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee10(transaction) {
28790
28820
  return regenerator.wrap(function _callee10$(_context10) {
28791
28821
  while (1) switch (_context10.prev = _context10.next) {
28792
28822
  case 0:
@@ -28836,7 +28866,7 @@
28836
28866
  }, _callee10);
28837
28867
  }));
28838
28868
  return function storePayment(_x11) {
28839
- return _ref15.apply(this, arguments);
28869
+ return _ref16.apply(this, arguments);
28840
28870
  };
28841
28871
  }();
28842
28872
  React.useEffect(function () {