@depay/widgets 7.15.2 → 7.16.1

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
@@ -18938,7 +18938,7 @@ var ChangableAmountProvider = (function (props) {
18938
18938
  maxRoute = _useState12[0],
18939
18939
  setMaxRoute = _useState12[1];
18940
18940
 
18941
- var _useState13 = useState(100),
18941
+ var _useState13 = useState(),
18942
18942
  _useState14 = _slicedToArray(_useState13, 2),
18943
18943
  maxAmount = _useState14[0],
18944
18944
  setMaxAmount = _useState14[1];
@@ -19061,6 +19061,11 @@ var ChangableAmountProvider = (function (props) {
19061
19061
  toAddress: account
19062
19062
  }).then(function (routes) {
19063
19063
  if (routes[0] == undefined) {
19064
+ Token.readable({
19065
+ amount: maxRoute.fromBalance,
19066
+ blockchain: maxRoute.blockchain,
19067
+ address: maxRoute.toToken.address
19068
+ }).then(setMaxAmount);
19064
19069
  return;
19065
19070
  }
19066
19071
 
@@ -19318,30 +19323,34 @@ var PaymentProvider = (function (props) {
19318
19323
  switch (_context.prev = _context.next) {
19319
19324
  case 0:
19320
19325
  if (!before) {
19321
- _context.next = 4;
19326
+ _context.next = 6;
19322
19327
  break;
19323
19328
  }
19324
19329
 
19325
- stop = before(payment.route.transaction);
19330
+ _context.next = 3;
19331
+ return before(payment.route.transaction);
19332
+
19333
+ case 3:
19334
+ stop = _context.sent;
19326
19335
 
19327
19336
  if (!(stop === false)) {
19328
- _context.next = 4;
19337
+ _context.next = 6;
19329
19338
  break;
19330
19339
  }
19331
19340
 
19332
19341
  return _context.abrupt("return");
19333
19342
 
19334
- case 4:
19343
+ case 6:
19335
19344
  setClosable(false);
19336
19345
  setPaymentState('paying');
19337
19346
  setUpdatable(false);
19338
- _context.next = 9;
19347
+ _context.next = 11;
19339
19348
  return request({
19340
19349
  blockchain: payment.route.transaction.blockchain,
19341
19350
  method: 'latestBlockNumber'
19342
19351
  });
19343
19352
 
19344
- case 9:
19353
+ case 11:
19345
19354
  currentBlock = _context.sent;
19346
19355
  wallet.sendTransaction(Object.assign({}, payment.route.transaction, {
19347
19356
  sent: function sent(transaction) {
@@ -19367,7 +19376,7 @@ var PaymentProvider = (function (props) {
19367
19376
  }
19368
19377
  });
19369
19378
 
19370
- case 11:
19379
+ case 13:
19371
19380
  case "end":
19372
19381
  return _context.stop();
19373
19382
  }
@@ -20377,7 +20386,11 @@ var ChangeAmountDialog = (function (props) {
20377
20386
 
20378
20387
  var toValidValue = function toValidValue(value) {
20379
20388
  value = toValidStep(value);
20380
- value = Math.max(min, Math.min(value, maxAmount));
20389
+
20390
+ if (maxAmount) {
20391
+ value = Math.max(min, Math.min(value, maxAmount));
20392
+ }
20393
+
20381
20394
  value = toValidStep(value);
20382
20395
  return value;
20383
20396
  };
@@ -20404,7 +20417,7 @@ var ChangeAmountDialog = (function (props) {
20404
20417
  }, /*#__PURE__*/React.createElement("div", {
20405
20418
  className: "PaddingBottomM"
20406
20419
  }, /*#__PURE__*/React.createElement("input", {
20407
- max: parseFloat(maxAmount),
20420
+ max: maxAmount ? parseFloat(maxAmount) : null,
20408
20421
  min: min,
20409
20422
  step: step,
20410
20423
  className: "Input FontSizeXXL TextAlignCenter",
@@ -20417,7 +20430,7 @@ var ChangeAmountDialog = (function (props) {
20417
20430
  onBlur: function onBlur(event) {
20418
20431
  setValidValue(event.target.value);
20419
20432
  }
20420
- })), /*#__PURE__*/React.createElement("div", {
20433
+ })), maxAmount && /*#__PURE__*/React.createElement("div", {
20421
20434
  style: {
20422
20435
  height: '40px'
20423
20436
  }
@@ -20611,19 +20624,6 @@ var DonationOverviewSkeleton = (function (props) {
20611
20624
  });
20612
20625
  });
20613
20626
 
20614
- var AlertIcon = (function (props) {
20615
- return /*#__PURE__*/React.createElement("svg", {
20616
- className: "AlertIcon Icon " + props.className,
20617
- version: "1.1",
20618
- xmlns: "http://www.w3.org/2000/svg",
20619
- x: "0px",
20620
- y: "0px",
20621
- viewBox: "0 0 20 20"
20622
- }, /*#__PURE__*/React.createElement("path", {
20623
- 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"
20624
- }));
20625
- });
20626
-
20627
20627
  var Checkmark = (function (props) {
20628
20628
  return /*#__PURE__*/React.createElement("svg", {
20629
20629
  className: "Checkmark Icon " + props.className,
@@ -20698,8 +20698,7 @@ var Footer = (function () {
20698
20698
  var _useContext2 = useContext(PaymentTrackingContext),
20699
20699
  tracking = _useContext2.tracking,
20700
20700
  release = _useContext2.release,
20701
- forwardTo = _useContext2.forwardTo,
20702
- trackingFailed = _useContext2.trackingFailed;
20701
+ forwardTo = _useContext2.forwardTo;
20703
20702
 
20704
20703
  var _useContext3 = useContext(PaymentContext),
20705
20704
  payment = _useContext3.payment,
@@ -20746,37 +20745,21 @@ var Footer = (function () {
20746
20745
  className: "Opacity05"
20747
20746
  }, "Payment validated")))));
20748
20747
  } else {
20749
- if (trackingFailed) {
20750
- return /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("div", {
20751
- className: "Card transparent small"
20752
- }, /*#__PURE__*/React.createElement("div", {
20753
- className: "CardImage"
20754
- }, /*#__PURE__*/React.createElement("div", {
20755
- className: "TextCenter"
20756
- }, /*#__PURE__*/React.createElement(AlertIcon, {
20757
- className: "small"
20758
- }))), /*#__PURE__*/React.createElement("div", {
20759
- className: "CardBody"
20760
- }, /*#__PURE__*/React.createElement("div", {
20761
- className: "CardBodyWrapper"
20762
- }, /*#__PURE__*/React.createElement("div", null, "Tracking payment failed!")))));
20763
- } else {
20764
- return /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("div", {
20765
- className: "Card transparent small disabled"
20766
- }, /*#__PURE__*/React.createElement("div", {
20767
- className: "CardImage"
20768
- }, /*#__PURE__*/React.createElement("div", {
20769
- className: "TextCenter"
20770
- }, /*#__PURE__*/React.createElement("div", {
20771
- className: "Loading Icon"
20772
- }))), /*#__PURE__*/React.createElement("div", {
20773
- className: "CardBody"
20774
- }, /*#__PURE__*/React.createElement("div", {
20775
- className: "CardBodyWrapper"
20776
- }, /*#__PURE__*/React.createElement("div", {
20777
- className: "Opacity05"
20778
- }, "Validating payment")))));
20779
- }
20748
+ return /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("div", {
20749
+ className: "Card transparent small disabled"
20750
+ }, /*#__PURE__*/React.createElement("div", {
20751
+ className: "CardImage"
20752
+ }, /*#__PURE__*/React.createElement("div", {
20753
+ className: "TextCenter"
20754
+ }, /*#__PURE__*/React.createElement("div", {
20755
+ className: "Loading Icon"
20756
+ }))), /*#__PURE__*/React.createElement("div", {
20757
+ className: "CardBody"
20758
+ }, /*#__PURE__*/React.createElement("div", {
20759
+ className: "CardBodyWrapper"
20760
+ }, /*#__PURE__*/React.createElement("div", {
20761
+ className: "Opacity05"
20762
+ }, "Validating payment")))));
20780
20763
  }
20781
20764
  };
20782
20765
 
@@ -21159,8 +21142,8 @@ var NavigateProvider = (function (props) {
21159
21142
  });
21160
21143
 
21161
21144
  var PaymentTrackingProvider = (function (props) {
21162
- var _useContext = useContext(ErrorContext),
21163
- errorCallback = _useContext.errorCallback;
21145
+ var _useContext = useContext(ErrorContext);
21146
+ _useContext.errorCallback;
21164
21147
 
21165
21148
  var _useContext2 = useContext(ConfigurationContext),
21166
21149
  track = _useContext2.track,
@@ -21197,20 +21180,16 @@ var PaymentTrackingProvider = (function (props) {
21197
21180
  release = _useState12[0],
21198
21181
  setRelease = _useState12[1];
21199
21182
 
21200
- var _useState13 = useState(false),
21183
+ var _useState13 = useState(),
21201
21184
  _useState14 = _slicedToArray(_useState13, 2),
21202
- trackingFailed = _useState14[0],
21203
- setTrackingFailed = _useState14[1];
21204
-
21205
- var _useState15 = useState(),
21206
- _useState16 = _slicedToArray(_useState15, 2),
21207
- forwardTo = _useState16[0],
21208
- setForwardTo = _useState16[1];
21185
+ forwardTo = _useState14[0],
21186
+ setForwardTo = _useState14[1];
21209
21187
 
21210
21188
  var _useContext3 = useContext(ClosableContext),
21211
21189
  setClosable = _useContext3.setClosable;
21212
21190
 
21213
21191
  var _useContext4 = useContext(NavigateContext),
21192
+ navigate = _useContext4.navigate,
21214
21193
  set = _useContext4.set;
21215
21194
 
21216
21195
  var openSocket = function openSocket(transaction) {
@@ -21268,23 +21247,23 @@ var PaymentTrackingProvider = (function (props) {
21268
21247
 
21269
21248
  var retryStartTracking = function retryStartTracking(transaction, afterBlock, paymentRoute, attempt) {
21270
21249
  attempt = parseInt(attempt || 1, 10);
21250
+ console.log('attempt', attempt);
21251
+ console.log('track.attempts', track === null || track === void 0 ? void 0 : track.attempts);
21271
21252
 
21272
- if (attempt < 3) {
21253
+ if (attempt < ((track === null || track === void 0 ? void 0 : track.attempts) || 40)) {
21273
21254
  setTimeout(function () {
21274
21255
  startTracking(transaction, afterBlock, paymentRoute, attempt + 1);
21275
21256
  }, 3000);
21276
21257
  } else {
21277
- console.log('PAYMENT TRACKING FAILED AFTER 3 ATTEMPTS!');
21278
- setTrackingFailed(true);
21279
-
21280
- if (typeof errorCallback == 'function') {
21281
- errorCallback({
21282
- code: 'TRACKING_FAILED'
21283
- });
21284
- }
21258
+ console.log('navigate TrackingFailed');
21259
+ navigate('TrackingFailed');
21285
21260
  }
21286
21261
  };
21287
21262
 
21263
+ var continueTryTracking = function continueTryTracking() {
21264
+ retryStartTracking(transaction, afterBlock, paymentRoute, 1);
21265
+ };
21266
+
21288
21267
  var callTracking = function callTracking(payment) {
21289
21268
  if (track.endpoint) {
21290
21269
  return fetch(track.endpoint, {
@@ -21391,10 +21370,6 @@ var PaymentTrackingProvider = (function (props) {
21391
21370
  }, [polling, transaction, afterBlock, paymentRoute]);
21392
21371
 
21393
21372
  var storePayment = function storePayment(transaction, afterBlock, paymentRoute, attempt) {
21394
- if (attempt > 3) {
21395
- return;
21396
- }
21397
-
21398
21373
  fetch('https://public.depay.com/payments', {
21399
21374
  headers: {
21400
21375
  'Content-Type': 'application/json'
@@ -21425,18 +21400,18 @@ var PaymentTrackingProvider = (function (props) {
21425
21400
  }).then(function (response) {
21426
21401
  if (response.status == 200 || response.status == 201) ; else {
21427
21402
  setTimeout(function () {
21428
- storePayment(transaction, afterBlock, paymentRoute, attempt + 1);
21403
+ storePayment(transaction, afterBlock, paymentRoute);
21429
21404
  }, 3000);
21430
21405
  }
21431
21406
  })["catch"](function (error) {
21432
21407
  setTimeout(function () {
21433
- storePayment(transaction, afterBlock, paymentRoute, attempt + 1);
21408
+ storePayment(transaction, afterBlock, paymentRoute);
21434
21409
  }, 3000);
21435
21410
  });
21436
21411
  };
21437
21412
 
21438
21413
  var initializeTracking = function initializeTracking(transaction, afterBlock, paymentRoute) {
21439
- storePayment(transaction, afterBlock, paymentRoute, 1);
21414
+ storePayment(transaction, afterBlock, paymentRoute);
21440
21415
 
21441
21416
  if (tracking || track && track.async == true) {
21442
21417
  startTracking(transaction, afterBlock, paymentRoute);
@@ -21456,9 +21431,9 @@ var PaymentTrackingProvider = (function (props) {
21456
21431
  value: {
21457
21432
  tracking: tracking,
21458
21433
  initializeTracking: initializeTracking,
21434
+ continueTryTracking: continueTryTracking,
21459
21435
  release: release,
21460
- forwardTo: forwardTo,
21461
- trackingFailed: trackingFailed
21436
+ forwardTo: forwardTo
21462
21437
  }
21463
21438
  }, props.children);
21464
21439
  });
@@ -22154,6 +22129,54 @@ var PaymentOverviewDialog = (function (props) {
22154
22129
  });
22155
22130
  });
22156
22131
 
22132
+ var TrackingFailedDialog = (function () {
22133
+ var _useContext = useContext(PaymentTrackingContext),
22134
+ continueTryTracking = _useContext.continueTryTracking;
22135
+
22136
+ var _useContext2 = useContext(PaymentContext),
22137
+ transaction = _useContext2.transaction;
22138
+
22139
+ var _useContext3 = useContext(NavigateStackContext),
22140
+ navigate = _useContext3.navigate;
22141
+
22142
+ var tryAgain = function tryAgain() {
22143
+ continueTryTracking();
22144
+ navigate('back');
22145
+ };
22146
+
22147
+ return /*#__PURE__*/React.createElement(Dialog$1, {
22148
+ stacked: false,
22149
+ header: /*#__PURE__*/React.createElement("div", {
22150
+ className: "PaddingTopS PaddingLeftM PaddingRightM"
22151
+ }),
22152
+ body: /*#__PURE__*/React.createElement("div", {
22153
+ className: "TextCenter"
22154
+ }, /*#__PURE__*/React.createElement("div", {
22155
+ className: "GraphicWrapper"
22156
+ }, /*#__PURE__*/React.createElement("img", {
22157
+ className: "Graphic",
22158
+ src: ErrorGraphic
22159
+ })), /*#__PURE__*/React.createElement("h1", {
22160
+ className: "LineHeightL Text FontSizeL PaddingTopS FontWeightBold"
22161
+ }, "Tracking payment failed"), /*#__PURE__*/React.createElement("div", {
22162
+ className: "Text PaddingTopS PaddingBottomS PaddingLeftS PaddingRightS"
22163
+ }, /*#__PURE__*/React.createElement("strong", {
22164
+ className: "FontSizeM"
22165
+ }, "Please ensure you are connected to the internet, then click \"Try again\"."), /*#__PURE__*/React.createElement("div", {
22166
+ className: "PaddingTopS"
22167
+ }, /*#__PURE__*/React.createElement("span", null, "If this keeps happening, "), /*#__PURE__*/React.createElement("a", {
22168
+ className: "Link",
22169
+ href: "mailto:support@depay.com?subject=Payment%20tracking%20failed&body=Tracking%20my%20payment%20failed%0A%0ATransaction:%20".concat(transaction.url)
22170
+ }, "please report it"), "."))),
22171
+ footer: /*#__PURE__*/React.createElement("div", {
22172
+ className: "PaddingTopXS PaddingRightM PaddingLeftM PaddingBottomM"
22173
+ }, /*#__PURE__*/React.createElement("button", {
22174
+ className: "ButtonPrimary",
22175
+ onClick: tryAgain
22176
+ }, "Try again"))
22177
+ });
22178
+ });
22179
+
22157
22180
  var PaymentStack = (function (props) {
22158
22181
  var _useContext = useContext(ClosableContext),
22159
22182
  open = _useContext.open,
@@ -22174,7 +22197,8 @@ var PaymentStack = (function (props) {
22174
22197
  ChangeAmount: /*#__PURE__*/React.createElement(ChangeAmountDialog, null),
22175
22198
  ChangePayment: /*#__PURE__*/React.createElement(ChangePaymentDialog, null),
22176
22199
  PaymentError: /*#__PURE__*/React.createElement(PaymentErrorDialog, null),
22177
- WrongNetwork: /*#__PURE__*/React.createElement(WrongNetworkDialog, null)
22200
+ WrongNetwork: /*#__PURE__*/React.createElement(WrongNetworkDialog, null),
22201
+ TrackingFailed: /*#__PURE__*/React.createElement(TrackingFailedDialog, null)
22178
22202
  }
22179
22203
  });
22180
22204
  });