@depay/widgets 7.15.3 → 7.16.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
@@ -1622,15 +1622,11 @@
1622
1622
 
1623
1623
  var direction = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'up';
1624
1624
  var inputAsFloat = parseFloat(input);
1625
- var digitsAfterDecimal = inputAsFloat.toString().match(/\d+\.0*(\d{3})/);
1625
+ var digitsAfterDecimal = inputAsFloat.toString().match(/\d+\.0*(\d{5})/);
1626
1626
 
1627
1627
  if ((_digitsAfterDecimal = digitsAfterDecimal) !== null && _digitsAfterDecimal !== void 0 && _digitsAfterDecimal.length) {
1628
1628
  digitsAfterDecimal = digitsAfterDecimal[0];
1629
- var focus = digitsAfterDecimal.match(/\d{3}$/)[0];
1630
-
1631
- if (focus.match(/^00/)) {
1632
- return inputAsFloat;
1633
- }
1629
+ var focus = digitsAfterDecimal.match(/\d{5}$/)[0];
1634
1630
 
1635
1631
  var _float;
1636
1632
 
@@ -1638,35 +1634,35 @@
1638
1634
 
1639
1635
  if (focus.match(/^0/)) {
1640
1636
  if (direction == 'up') {
1641
- _float = parseFloat("".concat(focus[1], ".").concat(focus[2]));
1637
+ _float = parseFloat("".concat(focus[1], ".").concat(focus[2]).concat(focus[3]).concat(focus[4]));
1642
1638
  } else {
1643
- _float = parseFloat("".concat(focus[1], ".").concat(focus[2]));
1639
+ _float = parseFloat("".concat(focus[1], ".").concat(focus[2]).concat(focus[3]).concat(focus[4]));
1644
1640
  }
1645
1641
 
1646
- focusToFixed = parseFloat(_float).toFixed(1);
1642
+ focusToFixed = parseFloat(_float).toFixed(3);
1647
1643
  focusToFixed = "0".concat(focusToFixed).replace('.', '');
1648
1644
  } else {
1649
1645
  if (direction == 'up') {
1650
- _float = parseFloat("".concat(focus[0], ".").concat(focus[1], "9"));
1646
+ _float = parseFloat("".concat(focus[0], ".").concat(focus[1]).concat(focus[2]).concat(focus[3], "9"));
1651
1647
  } else {
1652
- _float = parseFloat("".concat(focus[0], ".").concat(focus[1], "1"));
1648
+ _float = parseFloat("".concat(focus[0], ".").concat(focus[1]).concat(focus[2]).concat(focus[3], "1"));
1653
1649
  }
1654
1650
 
1655
- focusToFixed = parseFloat(_float).toFixed(1).replace('.', '');
1651
+ focusToFixed = parseFloat(_float).toFixed(3).replace('.', '');
1656
1652
  }
1657
1653
 
1658
- if (focusToFixed == '099' && parseInt(inputAsFloat.toFixed(0)) == 0) {
1659
- focusToFixed = direction == 'up' ? '100' : '990';
1660
- return parseFloat(digitsAfterDecimal.replace(/\d{3}$/, focusToFixed));
1661
- } else if (focusToFixed == '100' && parseInt(inputAsFloat.toFixed(0)) == 0) {
1662
- return parseFloat(digitsAfterDecimal.replace(/\d{4}$/, focusToFixed));
1663
- } else if (focusToFixed.toString()[0] != "0" && focusToFixed.toString().length > 2) {
1654
+ if (focusToFixed == '09999' && parseInt(inputAsFloat.toFixed(0)) == 0) {
1655
+ focusToFixed = direction == 'up' ? '10000' : '09999';
1656
+ return parseFloat(digitsAfterDecimal.replace(/\d{5}$/, focusToFixed));
1657
+ } else if (focusToFixed == '10000' && parseInt(inputAsFloat.toFixed(0)) == 0) {
1658
+ return parseFloat(digitsAfterDecimal.replace(/\d{6}$/, focusToFixed));
1659
+ } else if (focusToFixed.toString()[0] != "0" && focusToFixed.toString().length > 4) {
1664
1660
  return parseInt(inputAsFloat.toFixed(0));
1665
1661
  } else {
1666
- return parseFloat(digitsAfterDecimal.replace(/\d{3}$/, focusToFixed));
1662
+ return parseFloat(digitsAfterDecimal.replace(/\d{5}$/, focusToFixed));
1667
1663
  }
1668
1664
  } else {
1669
- return parseFloat(inputAsFloat.toFixed(2));
1665
+ return parseFloat(inputAsFloat.toFixed(4));
1670
1666
  }
1671
1667
  });
1672
1668
 
@@ -19318,30 +19314,34 @@
19318
19314
  switch (_context.prev = _context.next) {
19319
19315
  case 0:
19320
19316
  if (!before) {
19321
- _context.next = 4;
19317
+ _context.next = 6;
19322
19318
  break;
19323
19319
  }
19324
19320
 
19325
- stop = before(payment.route.transaction);
19321
+ _context.next = 3;
19322
+ return before(payment.route.transaction);
19323
+
19324
+ case 3:
19325
+ stop = _context.sent;
19326
19326
 
19327
19327
  if (!(stop === false)) {
19328
- _context.next = 4;
19328
+ _context.next = 6;
19329
19329
  break;
19330
19330
  }
19331
19331
 
19332
19332
  return _context.abrupt("return");
19333
19333
 
19334
- case 4:
19334
+ case 6:
19335
19335
  setClosable(false);
19336
19336
  setPaymentState('paying');
19337
19337
  setUpdatable(false);
19338
- _context.next = 9;
19338
+ _context.next = 11;
19339
19339
  return web3Client.request({
19340
19340
  blockchain: payment.route.transaction.blockchain,
19341
19341
  method: 'latestBlockNumber'
19342
19342
  });
19343
19343
 
19344
- case 9:
19344
+ case 11:
19345
19345
  currentBlock = _context.sent;
19346
19346
  wallet.sendTransaction(Object.assign({}, payment.route.transaction, {
19347
19347
  sent: function sent(transaction) {
@@ -19367,7 +19367,7 @@
19367
19367
  }
19368
19368
  });
19369
19369
 
19370
- case 11:
19370
+ case 13:
19371
19371
  case "end":
19372
19372
  return _context.stop();
19373
19373
  }
@@ -20615,19 +20615,6 @@
20615
20615
  });
20616
20616
  });
20617
20617
 
20618
- var AlertIcon = (function (props) {
20619
- return /*#__PURE__*/React__default["default"].createElement("svg", {
20620
- className: "AlertIcon Icon " + props.className,
20621
- version: "1.1",
20622
- xmlns: "http://www.w3.org/2000/svg",
20623
- x: "0px",
20624
- y: "0px",
20625
- viewBox: "0 0 20 20"
20626
- }, /*#__PURE__*/React__default["default"].createElement("path", {
20627
- d: "M19.64 16.36L11.53 2.3A1.85 1.85 0 0 0 10 1.21 1.85 1.85 0 0 0 8.48 2.3L.36 16.36C-.48 17.81.21 19 1.88 19h16.24c1.67 0 2.36-1.19 1.52-2.64zM11 16H9v-2h2zm0-4H9V6h2z"
20628
- }));
20629
- });
20630
-
20631
20618
  var Checkmark = (function (props) {
20632
20619
  return /*#__PURE__*/React__default["default"].createElement("svg", {
20633
20620
  className: "Checkmark Icon " + props.className,
@@ -20702,8 +20689,7 @@
20702
20689
  var _useContext2 = React.useContext(PaymentTrackingContext),
20703
20690
  tracking = _useContext2.tracking,
20704
20691
  release = _useContext2.release,
20705
- forwardTo = _useContext2.forwardTo,
20706
- trackingFailed = _useContext2.trackingFailed;
20692
+ forwardTo = _useContext2.forwardTo;
20707
20693
 
20708
20694
  var _useContext3 = React.useContext(PaymentContext),
20709
20695
  payment = _useContext3.payment,
@@ -20750,37 +20736,21 @@
20750
20736
  className: "Opacity05"
20751
20737
  }, "Payment validated")))));
20752
20738
  } else {
20753
- if (trackingFailed) {
20754
- return /*#__PURE__*/React__default["default"].createElement("div", null, /*#__PURE__*/React__default["default"].createElement("div", {
20755
- className: "Card transparent small"
20756
- }, /*#__PURE__*/React__default["default"].createElement("div", {
20757
- className: "CardImage"
20758
- }, /*#__PURE__*/React__default["default"].createElement("div", {
20759
- className: "TextCenter"
20760
- }, /*#__PURE__*/React__default["default"].createElement(AlertIcon, {
20761
- className: "small"
20762
- }))), /*#__PURE__*/React__default["default"].createElement("div", {
20763
- className: "CardBody"
20764
- }, /*#__PURE__*/React__default["default"].createElement("div", {
20765
- className: "CardBodyWrapper"
20766
- }, /*#__PURE__*/React__default["default"].createElement("div", null, "Tracking payment failed!")))));
20767
- } else {
20768
- return /*#__PURE__*/React__default["default"].createElement("div", null, /*#__PURE__*/React__default["default"].createElement("div", {
20769
- className: "Card transparent small disabled"
20770
- }, /*#__PURE__*/React__default["default"].createElement("div", {
20771
- className: "CardImage"
20772
- }, /*#__PURE__*/React__default["default"].createElement("div", {
20773
- className: "TextCenter"
20774
- }, /*#__PURE__*/React__default["default"].createElement("div", {
20775
- className: "Loading Icon"
20776
- }))), /*#__PURE__*/React__default["default"].createElement("div", {
20777
- className: "CardBody"
20778
- }, /*#__PURE__*/React__default["default"].createElement("div", {
20779
- className: "CardBodyWrapper"
20780
- }, /*#__PURE__*/React__default["default"].createElement("div", {
20781
- className: "Opacity05"
20782
- }, "Validating payment")))));
20783
- }
20739
+ return /*#__PURE__*/React__default["default"].createElement("div", null, /*#__PURE__*/React__default["default"].createElement("div", {
20740
+ className: "Card transparent small disabled"
20741
+ }, /*#__PURE__*/React__default["default"].createElement("div", {
20742
+ className: "CardImage"
20743
+ }, /*#__PURE__*/React__default["default"].createElement("div", {
20744
+ className: "TextCenter"
20745
+ }, /*#__PURE__*/React__default["default"].createElement("div", {
20746
+ className: "Loading Icon"
20747
+ }))), /*#__PURE__*/React__default["default"].createElement("div", {
20748
+ className: "CardBody"
20749
+ }, /*#__PURE__*/React__default["default"].createElement("div", {
20750
+ className: "CardBodyWrapper"
20751
+ }, /*#__PURE__*/React__default["default"].createElement("div", {
20752
+ className: "Opacity05"
20753
+ }, "Validating payment")))));
20784
20754
  }
20785
20755
  };
20786
20756
 
@@ -21163,8 +21133,8 @@
21163
21133
  });
21164
21134
 
21165
21135
  var PaymentTrackingProvider = (function (props) {
21166
- var _useContext = React.useContext(ErrorContext),
21167
- errorCallback = _useContext.errorCallback;
21136
+ var _useContext = React.useContext(ErrorContext);
21137
+ _useContext.errorCallback;
21168
21138
 
21169
21139
  var _useContext2 = React.useContext(ConfigurationContext),
21170
21140
  track = _useContext2.track,
@@ -21201,20 +21171,16 @@
21201
21171
  release = _useState12[0],
21202
21172
  setRelease = _useState12[1];
21203
21173
 
21204
- var _useState13 = React.useState(false),
21174
+ var _useState13 = React.useState(),
21205
21175
  _useState14 = _slicedToArray(_useState13, 2),
21206
- trackingFailed = _useState14[0],
21207
- setTrackingFailed = _useState14[1];
21208
-
21209
- var _useState15 = React.useState(),
21210
- _useState16 = _slicedToArray(_useState15, 2),
21211
- forwardTo = _useState16[0],
21212
- setForwardTo = _useState16[1];
21176
+ forwardTo = _useState14[0],
21177
+ setForwardTo = _useState14[1];
21213
21178
 
21214
21179
  var _useContext3 = React.useContext(ClosableContext),
21215
21180
  setClosable = _useContext3.setClosable;
21216
21181
 
21217
21182
  var _useContext4 = React.useContext(NavigateContext),
21183
+ navigate = _useContext4.navigate,
21218
21184
  set = _useContext4.set;
21219
21185
 
21220
21186
  var openSocket = function openSocket(transaction) {
@@ -21272,23 +21238,23 @@
21272
21238
 
21273
21239
  var retryStartTracking = function retryStartTracking(transaction, afterBlock, paymentRoute, attempt) {
21274
21240
  attempt = parseInt(attempt || 1, 10);
21241
+ console.log('attempt', attempt);
21242
+ console.log('track.attempts', track === null || track === void 0 ? void 0 : track.attempts);
21275
21243
 
21276
- if (attempt < 3) {
21244
+ if (attempt < ((track === null || track === void 0 ? void 0 : track.attempts) || 40)) {
21277
21245
  setTimeout(function () {
21278
21246
  startTracking(transaction, afterBlock, paymentRoute, attempt + 1);
21279
21247
  }, 3000);
21280
21248
  } else {
21281
- console.log('PAYMENT TRACKING FAILED AFTER 3 ATTEMPTS!');
21282
- setTrackingFailed(true);
21283
-
21284
- if (typeof errorCallback == 'function') {
21285
- errorCallback({
21286
- code: 'TRACKING_FAILED'
21287
- });
21288
- }
21249
+ console.log('navigate TrackingFailed');
21250
+ navigate('TrackingFailed');
21289
21251
  }
21290
21252
  };
21291
21253
 
21254
+ var continueTryTracking = function continueTryTracking() {
21255
+ retryStartTracking(transaction, afterBlock, paymentRoute, 1);
21256
+ };
21257
+
21292
21258
  var callTracking = function callTracking(payment) {
21293
21259
  if (track.endpoint) {
21294
21260
  return fetch(track.endpoint, {
@@ -21395,10 +21361,6 @@
21395
21361
  }, [polling, transaction, afterBlock, paymentRoute]);
21396
21362
 
21397
21363
  var storePayment = function storePayment(transaction, afterBlock, paymentRoute, attempt) {
21398
- if (attempt > 3) {
21399
- return;
21400
- }
21401
-
21402
21364
  fetch('https://public.depay.com/payments', {
21403
21365
  headers: {
21404
21366
  'Content-Type': 'application/json'
@@ -21429,18 +21391,18 @@
21429
21391
  }).then(function (response) {
21430
21392
  if (response.status == 200 || response.status == 201) ; else {
21431
21393
  setTimeout(function () {
21432
- storePayment(transaction, afterBlock, paymentRoute, attempt + 1);
21394
+ storePayment(transaction, afterBlock, paymentRoute);
21433
21395
  }, 3000);
21434
21396
  }
21435
21397
  })["catch"](function (error) {
21436
21398
  setTimeout(function () {
21437
- storePayment(transaction, afterBlock, paymentRoute, attempt + 1);
21399
+ storePayment(transaction, afterBlock, paymentRoute);
21438
21400
  }, 3000);
21439
21401
  });
21440
21402
  };
21441
21403
 
21442
21404
  var initializeTracking = function initializeTracking(transaction, afterBlock, paymentRoute) {
21443
- storePayment(transaction, afterBlock, paymentRoute, 1);
21405
+ storePayment(transaction, afterBlock, paymentRoute);
21444
21406
 
21445
21407
  if (tracking || track && track.async == true) {
21446
21408
  startTracking(transaction, afterBlock, paymentRoute);
@@ -21460,9 +21422,9 @@
21460
21422
  value: {
21461
21423
  tracking: tracking,
21462
21424
  initializeTracking: initializeTracking,
21425
+ continueTryTracking: continueTryTracking,
21463
21426
  release: release,
21464
- forwardTo: forwardTo,
21465
- trackingFailed: trackingFailed
21427
+ forwardTo: forwardTo
21466
21428
  }
21467
21429
  }, props.children);
21468
21430
  });
@@ -22158,6 +22120,54 @@
22158
22120
  });
22159
22121
  });
22160
22122
 
22123
+ var TrackingFailedDialog = (function () {
22124
+ var _useContext = React.useContext(PaymentTrackingContext),
22125
+ continueTryTracking = _useContext.continueTryTracking;
22126
+
22127
+ var _useContext2 = React.useContext(PaymentContext),
22128
+ transaction = _useContext2.transaction;
22129
+
22130
+ var _useContext3 = React.useContext(reactDialogStack.NavigateStackContext),
22131
+ navigate = _useContext3.navigate;
22132
+
22133
+ var tryAgain = function tryAgain() {
22134
+ continueTryTracking();
22135
+ navigate('back');
22136
+ };
22137
+
22138
+ return /*#__PURE__*/React__default["default"].createElement(Dialog$1, {
22139
+ stacked: false,
22140
+ header: /*#__PURE__*/React__default["default"].createElement("div", {
22141
+ className: "PaddingTopS PaddingLeftM PaddingRightM"
22142
+ }),
22143
+ body: /*#__PURE__*/React__default["default"].createElement("div", {
22144
+ className: "TextCenter"
22145
+ }, /*#__PURE__*/React__default["default"].createElement("div", {
22146
+ className: "GraphicWrapper"
22147
+ }, /*#__PURE__*/React__default["default"].createElement("img", {
22148
+ className: "Graphic",
22149
+ src: ErrorGraphic
22150
+ })), /*#__PURE__*/React__default["default"].createElement("h1", {
22151
+ className: "LineHeightL Text FontSizeL PaddingTopS FontWeightBold"
22152
+ }, "Tracking payment failed"), /*#__PURE__*/React__default["default"].createElement("div", {
22153
+ className: "Text PaddingTopS PaddingBottomS PaddingLeftS PaddingRightS"
22154
+ }, /*#__PURE__*/React__default["default"].createElement("strong", {
22155
+ className: "FontSizeM"
22156
+ }, "Please ensure you are connected to the internet, then click \"Try again\"."), /*#__PURE__*/React__default["default"].createElement("div", {
22157
+ className: "PaddingTopS"
22158
+ }, /*#__PURE__*/React__default["default"].createElement("span", null, "If this keeps happening, "), /*#__PURE__*/React__default["default"].createElement("a", {
22159
+ className: "Link",
22160
+ href: "mailto:support@depay.com?subject=Payment%20tracking%20failed&body=Tracking%20my%20payment%20failed%0A%0ATransaction:%20".concat(transaction.url)
22161
+ }, "please report it"), "."))),
22162
+ footer: /*#__PURE__*/React__default["default"].createElement("div", {
22163
+ className: "PaddingTopXS PaddingRightM PaddingLeftM PaddingBottomM"
22164
+ }, /*#__PURE__*/React__default["default"].createElement("button", {
22165
+ className: "ButtonPrimary",
22166
+ onClick: tryAgain
22167
+ }, "Try again"))
22168
+ });
22169
+ });
22170
+
22161
22171
  var PaymentStack = (function (props) {
22162
22172
  var _useContext = React.useContext(ClosableContext),
22163
22173
  open = _useContext.open,
@@ -22178,7 +22188,8 @@
22178
22188
  ChangeAmount: /*#__PURE__*/React__default["default"].createElement(ChangeAmountDialog, null),
22179
22189
  ChangePayment: /*#__PURE__*/React__default["default"].createElement(ChangePaymentDialog, null),
22180
22190
  PaymentError: /*#__PURE__*/React__default["default"].createElement(PaymentErrorDialog, null),
22181
- WrongNetwork: /*#__PURE__*/React__default["default"].createElement(WrongNetworkDialog, null)
22191
+ WrongNetwork: /*#__PURE__*/React__default["default"].createElement(WrongNetworkDialog, null),
22192
+ TrackingFailed: /*#__PURE__*/React__default["default"].createElement(TrackingFailedDialog, null)
22182
22193
  }
22183
22194
  });
22184
22195
  });
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@depay/widgets",
3
3
  "moduleName": "DePayWidgets",
4
- "version": "7.15.3",
4
+ "version": "7.16.2",
5
5
  "description": "Web3 Payments with any token. DePay simplifies and improves Web3 Payments with the power of DeFi. Accept any token with on-the-fly conversion.",
6
6
  "main": "./dist/umd/index.js",
7
7
  "module": "./dist/esm/index.js",
@@ -44,7 +44,7 @@
44
44
  "@depay/web3-client": "^8.5.0",
45
45
  "@depay/web3-constants": "^6.0.0",
46
46
  "@depay/web3-exchanges": "^9.2.0",
47
- "@depay/web3-payments": "^10.6.1",
47
+ "@depay/web3-payments": "^10.6.2",
48
48
  "@depay/web3-tokens": "^8.2.0",
49
49
  "@depay/web3-wallets": "^11.1.1",
50
50
  "decimal.js": "^10.3.1"