tek-wallet 0.0.406 → 0.0.407

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.
@@ -2,7 +2,7 @@ import { GeneralProps } from "../../../types/ui";
2
2
  import { ActionConfirm } from "../ConfirmLayout/type";
3
3
  import { DrawerComponentProps, DrawerComponentRef } from "../DrawerComponent";
4
4
  interface ConfirmByPasscodeProps extends Omit<GeneralProps, "onclick" | "sx" | "onClick">, DrawerComponentProps {
5
- onConfirmSuccess?: (value: string) => any;
5
+ onConfirmSuccess?: (passcode: string) => any;
6
6
  action: ActionConfirm;
7
7
  }
8
8
  export interface ConfirmByPasscodeRef extends Omit<DrawerComponentRef, "trigger"> {
@@ -120,6 +120,7 @@ var ConfirmLayout_1 = __importDefault(require("../ConfirmLayout"));
120
120
  var type_1 = require("../ConfirmLayout/type");
121
121
  var ConfirmByPasscode_1 = __importDefault(require("../ConfirmByPasscode"));
122
122
  var LineValue_1 = __importDefault(require("../LineValue"));
123
+ var send_external_service_1 = __importDefault(require("../../../services/axios/send-external-service"));
123
124
  var SendMethods;
124
125
  (function (SendMethods) {
125
126
  SendMethods["SCAN_QR_CODE"] = "scan qr code";
@@ -176,6 +177,7 @@ var WithdrawFunction = (0, react_1.forwardRef)(function (props, ref) {
176
177
  var _t = (0, react_1.useState)(), estimateFee = _t[0], setEstimateFee = _t[1];
177
178
  var _u = (0, react_1.useState)(), recipientAddressError = _u[0], setRecipientAddressError = _u[1];
178
179
  var onlyChangeAddress = (0, react_1.useRef)(false);
180
+ var _v = (0, react_1.useState)(Button_1.BUTTON_STATUS.ENABLED), sendButtonStatus = _v[0], setSendButtonStatus = _v[1];
179
181
  var withdrawToken = (0, react_1.useMemo)(function () {
180
182
  return selectedMethod === SendMethods.TRANSFER_EXTERNAL
181
183
  ? withdrawTokens
@@ -527,7 +529,7 @@ var WithdrawFunction = (0, react_1.forwardRef)(function (props, ref) {
527
529
  return [2 /*return*/];
528
530
  });
529
531
  }); };
530
- var handleSendInternal = function () { return __awaiter(void 0, void 0, void 0, function () {
532
+ var handleSendInternal = function (passcode) { return __awaiter(void 0, void 0, void 0, function () {
531
533
  var response;
532
534
  return __generator(this, function (_a) {
533
535
  switch (_a.label) {
@@ -537,7 +539,7 @@ var WithdrawFunction = (0, react_1.forwardRef)(function (props, ref) {
537
539
  amount: "".concat(amount),
538
540
  to_address: recipientAddress || "",
539
541
  currency_slug: (selectedToken === null || selectedToken === void 0 ? void 0 : selectedToken.slug) || "",
540
- passcode: "111111",
542
+ passcode: passcode,
541
543
  })];
542
544
  case 1:
543
545
  response = _a.sent();
@@ -546,19 +548,36 @@ var WithdrawFunction = (0, react_1.forwardRef)(function (props, ref) {
546
548
  }
547
549
  });
548
550
  }); };
549
- var handleSendExternal = function () { return __awaiter(void 0, void 0, void 0, function () {
551
+ var handleSendExternal = function (passcode) { return __awaiter(void 0, void 0, void 0, function () {
552
+ var response;
550
553
  return __generator(this, function (_a) {
551
- console.warn("withdraw external");
552
- return [2 /*return*/];
554
+ switch (_a.label) {
555
+ case 0:
556
+ console.warn("withdraw external");
557
+ setSendButtonStatus(Button_1.BUTTON_STATUS.LOADING);
558
+ return [4 /*yield*/, (0, send_external_service_1.default)({
559
+ amount: "".concat(amount),
560
+ to_address: recipientAddress || "",
561
+ currency_slug: (selectedToken === null || selectedToken === void 0 ? void 0 : selectedToken.slug) || "",
562
+ passcode: passcode,
563
+ network: (selectedNetwork === null || selectedNetwork === void 0 ? void 0 : selectedNetwork.slug) || "",
564
+ memo: memo || "",
565
+ })];
566
+ case 1:
567
+ response = _a.sent();
568
+ console.warn("🚀 ~ handleSendExternal ~ response:", response);
569
+ setSendButtonStatus(Button_1.BUTTON_STATUS.ENABLED);
570
+ return [2 /*return*/];
571
+ }
553
572
  });
554
573
  }); };
555
- var handleSend = function () {
574
+ var handleSend = function (passcode) {
556
575
  switch (selectedMethod) {
557
576
  case SendMethods.TRANSFER_INTERNAL:
558
- handleSendInternal();
577
+ handleSendInternal(passcode);
559
578
  break;
560
579
  case SendMethods.TRANSFER_EXTERNAL:
561
- handleSendExternal();
580
+ handleSendExternal(passcode);
562
581
  break;
563
582
  default:
564
583
  break;
@@ -629,7 +648,7 @@ var WithdrawFunction = (0, react_1.forwardRef)(function (props, ref) {
629
648
  // ref={confirmByPasscodeDrawerRef}
630
649
  , {
631
650
  // ref={confirmByPasscodeDrawerRef}
632
- action: type_1.ActionConfirm.SEND, trigger: (0, jsx_runtime_1.jsx)(Button_1.default.Primary, { sx: { width: "100%" }, onClick: handleSend, status: !!amountError ||
651
+ action: type_1.ActionConfirm.SEND, trigger: (0, jsx_runtime_1.jsx)(Button_1.default.Primary, { sx: { width: "100%" }, status: !!amountError ||
633
652
  !!recipientAddressError ||
634
653
  !recipientAddress ||
635
654
  !amount ||
@@ -637,14 +656,11 @@ var WithdrawFunction = (0, react_1.forwardRef)(function (props, ref) {
637
656
  isLoadingEstimateFee ||
638
657
  isValidatingAddress
639
658
  ? Button_1.BUTTON_STATUS.DISABLED
640
- : Button_1.BUTTON_STATUS.ENABLED, children: "Continue" }), children: (0, jsx_runtime_1.jsxs)(material_1.Box, { sx: __assign(__assign({}, theme.mixins.column), { gap: theme.mixins.gaps.g12 }), children: [(0, jsx_runtime_1.jsxs)(material_1.Box, { sx: __assign({}, theme.mixins.paper), children: [(0, jsx_runtime_1.jsx)(LineValue_1.default, { field: "Recipient address", value: (0, jsx_runtime_1.jsx)(Text_1.default, { sx: { wordBreak: "break-all" }, children: recipientAddress }) }), selectedMethod === SendMethods.TRANSFER_EXTERNAL && ((0, jsx_runtime_1.jsx)(LineValue_1.default, { field: "Network", value: (0, jsx_runtime_1.jsxs)(material_1.Box, { sx: __assign(__assign({}, theme.mixins.row), { gap: theme.mixins.gaps.g6, ml: "auto" }), children: [(0, jsx_runtime_1.jsx)(Icon_1.default, { width: 20, src: selectedNetwork === null || selectedNetwork === void 0 ? void 0 : selectedNetwork.icon }), (0, jsx_runtime_1.jsx)(Text_1.default, { sx: __assign({}, theme.mixins.value), children: selectedNetwork === null || selectedNetwork === void 0 ? void 0 : selectedNetwork.name })] }) })), (0, jsx_runtime_1.jsx)(LineValue_1.default, { field: "Amount", value: (0, jsx_runtime_1.jsx)(Text_1.default, { sx: {
641
- fontWeight: theme.typography.fontWeight600,
642
- fontSize: theme.typography.fontSize16,
643
- }, children: (0, jsx_runtime_1.jsx)(Formatter_1.default, { value: amount, unit: " ".concat(selectedToken === null || selectedToken === void 0 ? void 0 : selectedToken.name) }) }) }), !!memo &&
659
+ : Button_1.BUTTON_STATUS.ENABLED, children: "Continue" }), children: (0, jsx_runtime_1.jsxs)(material_1.Box, { sx: __assign(__assign({}, theme.mixins.column), { gap: theme.mixins.gaps.g12 }), children: [(0, jsx_runtime_1.jsxs)(material_1.Box, { sx: __assign({}, theme.mixins.paper), children: [(0, jsx_runtime_1.jsx)(LineValue_1.default, { field: "Recipient address", value: (0, jsx_runtime_1.jsx)(Text_1.default, { sx: { wordBreak: "break-all" }, children: recipientAddress }) }), selectedMethod === SendMethods.TRANSFER_EXTERNAL && ((0, jsx_runtime_1.jsx)(LineValue_1.default, { field: "Network", value: (0, jsx_runtime_1.jsxs)(material_1.Box, { sx: __assign(__assign({}, theme.mixins.row), { gap: theme.mixins.gaps.g6, ml: "auto" }), children: [(0, jsx_runtime_1.jsx)(Icon_1.default, { width: 20, src: selectedNetwork === null || selectedNetwork === void 0 ? void 0 : selectedNetwork.icon }), (0, jsx_runtime_1.jsx)(Text_1.default, { sx: __assign({}, theme.mixins.value), children: selectedNetwork === null || selectedNetwork === void 0 ? void 0 : selectedNetwork.name })] }) })), (0, jsx_runtime_1.jsx)(LineValue_1.default, { field: "Amount", value: (0, jsx_runtime_1.jsx)(Formatter_1.default, { value: amount, unit: " ".concat(selectedToken === null || selectedToken === void 0 ? void 0 : selectedToken.name) }) }), !!memo &&
644
660
  selectedMethod === SendMethods.TRANSFER_EXTERNAL && ((0, jsx_runtime_1.jsx)(LineValue_1.default, { field: "Memo", value: memo })), ((_b = estimateFee === null || estimateFee === void 0 ? void 0 : estimateFee.feeDetail) === null || _b === void 0 ? void 0 : _b.length) && !!amount && ((0, jsx_runtime_1.jsx)(Fees_1.default, { feesData: JSON.stringify(estimateFee), amount: +amount })), (0, jsx_runtime_1.jsx)(LineValue_1.default, { field: "Receive amount estimated", value: (0, jsx_runtime_1.jsx)(Text_1.default, { sx: {
645
661
  fontWeight: theme.typography.fontWeight600,
646
662
  fontSize: theme.typography.fontSize16,
647
- }, children: (0, jsx_runtime_1.jsx)(Formatter_1.default, { value: estimateReceive, unit: " ".concat(selectedToken === null || selectedToken === void 0 ? void 0 : selectedToken.name) }) }) })] }), (0, jsx_runtime_1.jsx)(ConfirmByPasscode_1.default, { action: type_1.ActionConfirm.SEND, onConfirmSuccess: function () { return console.warn("confirm success"); }, children: (0, jsx_runtime_1.jsx)(Button_1.default.Primary, { status: Button_1.BUTTON_STATUS.ENABLED, sx: { width: "100%" }, children: "Confirm" }) })] }) })] }) }, WithdrawStep.FORM)] }), (0, jsx_runtime_1.jsx)(QrCodeReader_1.default, { ref: scannerAllQrCodeRef, onResult: handleScanAllQrCode }), (0, jsx_runtime_1.jsx)(QrCodeReader_1.default, { ref: scannerAddressQrCodeRef, onResult: handleScanAddressQrCode }), (0, jsx_runtime_1.jsx)(AppBackDrop_1.default, { ref: backDropRef }), (0, jsx_runtime_1.jsx)(AppDialog_1.default, { overrideOpen: !!infoDialogContent, children: (0, jsx_runtime_1.jsx)(DialogContentLayout_1.default, { content: (0, jsx_runtime_1.jsx)(Text_1.default, { sx: {
663
+ }, children: (0, jsx_runtime_1.jsx)(Formatter_1.default, { value: estimateReceive, unit: " ".concat(selectedToken === null || selectedToken === void 0 ? void 0 : selectedToken.name) }) }) })] }), (0, jsx_runtime_1.jsx)(ConfirmByPasscode_1.default, { action: type_1.ActionConfirm.SEND, onConfirmSuccess: handleSend, children: (0, jsx_runtime_1.jsx)(Button_1.default.Primary, { status: sendButtonStatus, sx: { width: "100%" }, children: "Confirm" }) })] }) })] }) }, WithdrawStep.FORM)] }), (0, jsx_runtime_1.jsx)(QrCodeReader_1.default, { ref: scannerAllQrCodeRef, onResult: handleScanAllQrCode }), (0, jsx_runtime_1.jsx)(QrCodeReader_1.default, { ref: scannerAddressQrCodeRef, onResult: handleScanAddressQrCode }), (0, jsx_runtime_1.jsx)(AppBackDrop_1.default, { ref: backDropRef }), (0, jsx_runtime_1.jsx)(AppDialog_1.default, { overrideOpen: !!infoDialogContent, children: (0, jsx_runtime_1.jsx)(DialogContentLayout_1.default, { content: (0, jsx_runtime_1.jsx)(Text_1.default, { sx: {
648
664
  textAlign: "center",
649
665
  display: "inline-block",
650
666
  width: "100%",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tek-wallet",
3
- "version": "0.0.406",
3
+ "version": "0.0.407",
4
4
  "description": "A custom React provider with TypeScript support",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",