tek-wallet 0.0.357 → 0.0.358

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.
@@ -114,6 +114,7 @@ var DialogContentLayout_1 = __importDefault(require("../DialogContentLayout"));
114
114
  var AppDialog_1 = __importDefault(require("../AppDialog"));
115
115
  var Formatter_1 = __importDefault(require("../Formatter"));
116
116
  var send_internal_service_1 = __importDefault(require("../../../services/axios/send-internal-service"));
117
+ var get_est_fee_service_1 = __importDefault(require("../../../services/axios/get-est-fee-service"));
117
118
  var SendMethods;
118
119
  (function (SendMethods) {
119
120
  SendMethods["SCAN_QR_CODE"] = "scan qr code";
@@ -163,8 +164,10 @@ var WithdrawFunction = (0, react_1.forwardRef)(function (props, ref) {
163
164
  var suggestUseTransferInternalDialogRef = (0, react_1.useRef)(null);
164
165
  var _m = (0, react_1.useState)(), selectedMethod = _m[0], setSelectedMethod = _m[1];
165
166
  var _o = (0, react_1.useState)(), sendInfoGet = _o[0], setSendInfoGet = _o[1];
166
- var _p = (0, react_1.useState)(), recipientAddressError = _p[0], setRecipientAddressError = _p[1];
167
- var _q = (0, react_1.useState)(), recipientAddressInternal = _q[0], setRecipientAddressInternal = _q[1];
167
+ var _p = (0, react_1.useState)(false), isLoadingEstimateFee = _p[0], setIsLoadingEstimateFee = _p[1];
168
+ // const [estimateFee, setEstimateFee] = useState<number>();
169
+ var _q = (0, react_1.useState)(), recipientAddressError = _q[0], setRecipientAddressError = _q[1];
170
+ var _r = (0, react_1.useState)(), recipientAddressInternal = _r[0], setRecipientAddressInternal = _r[1];
168
171
  var onlyChangeAddress = (0, react_1.useRef)(false);
169
172
  var networks = (0, react_1.useMemo)(function () {
170
173
  console.warn("🚀 ~ networks ~ selectedToken:", selectedToken);
@@ -331,6 +334,25 @@ var WithdrawFunction = (0, react_1.forwardRef)(function (props, ref) {
331
334
  break;
332
335
  }
333
336
  };
337
+ var handleGetEstimateFee = function () { return __awaiter(void 0, void 0, void 0, function () {
338
+ var response;
339
+ return __generator(this, function (_a) {
340
+ switch (_a.label) {
341
+ case 0:
342
+ setIsLoadingEstimateFee(true);
343
+ return [4 /*yield*/, (0, get_est_fee_service_1.default)({
344
+ amount: "".concat(amount),
345
+ transaction_type: "withdrawn",
346
+ currency: (selectedToken === null || selectedToken === void 0 ? void 0 : selectedToken.slug) || "",
347
+ })];
348
+ case 1:
349
+ response = _a.sent();
350
+ console.warn("🚀 ~ handleGetEstimateFee ~ response:", response);
351
+ setIsLoadingEstimateFee(false);
352
+ return [2 /*return*/];
353
+ }
354
+ });
355
+ }); };
334
356
  var openScannerAddressQrCode = function () {
335
357
  var _a;
336
358
  (_a = scannerAddressQrCodeRef.current) === null || _a === void 0 ? void 0 : _a.open();
@@ -483,9 +505,12 @@ var WithdrawFunction = (0, react_1.forwardRef)(function (props, ref) {
483
505
  }
484
506
  });
485
507
  }); };
486
- var handleSendExternal = function () {
487
- console.warn("withdraw external");
488
- };
508
+ var handleSendExternal = function () { return __awaiter(void 0, void 0, void 0, function () {
509
+ return __generator(this, function (_a) {
510
+ console.warn("withdraw external");
511
+ return [2 /*return*/];
512
+ });
513
+ }); };
489
514
  var handleSend = function () {
490
515
  switch (selectedMethod) {
491
516
  case SendMethods.TRANSFER_INTERNAL:
@@ -507,6 +532,9 @@ var WithdrawFunction = (0, react_1.forwardRef)(function (props, ref) {
507
532
  (0, react_1.useEffect)(function () {
508
533
  validateAmount();
509
534
  }, [validateAmount]);
535
+ (0, react_1.useEffect)(function () {
536
+ handleGetEstimateFee();
537
+ }, [amount, selectedToken === null || selectedToken === void 0 ? void 0 : selectedToken.slug]);
510
538
  return ((0, jsx_runtime_1.jsx)(RequireConnect_1.default, { children: (0, jsx_runtime_1.jsx)(DrawerComponent_1.default, { ref: drawerRef, trigger: props.children, onOpen: props.onOpen, onClose: handleOnClose, children: (0, jsx_runtime_1.jsxs)(ModalLayout_1.default, { overrideHeader: (0, jsx_runtime_1.jsx)(BackHeader_1.default, { sx: {
511
539
  width: "100%",
512
540
  display: "flex",
@@ -558,7 +586,8 @@ var WithdrawFunction = (0, react_1.forwardRef)(function (props, ref) {
558
586
  !recipientAddress ||
559
587
  !amount ||
560
588
  !selectedToken ||
561
- !!recipientAddressError
589
+ !!recipientAddressError ||
590
+ isLoadingEstimateFee
562
591
  ? Button_1.BUTTON_STATUS.DISABLED
563
592
  : Button_1.BUTTON_STATUS.ENABLED, children: "Continue" })] }) }, WithdrawStep.FORM)] }, withdrawTokens === null || withdrawTokens === void 0 ? void 0 : withdrawTokens.length), (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: {
564
593
  textAlign: "center",
@@ -0,0 +1,3 @@
1
+ import { GetEstimateFeeServiceResponse } from "./type";
2
+ import { GetEstimateFeeServiceQuery } from "./type";
3
+ export default function getEstimateFeeService(query: GetEstimateFeeServiceQuery): Promise<GetEstimateFeeServiceResponse>;
@@ -0,0 +1,59 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ var __generator = (this && this.__generator) || function (thisArg, body) {
12
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
13
+ return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
14
+ function verb(n) { return function (v) { return step([n, v]); }; }
15
+ function step(op) {
16
+ if (f) throw new TypeError("Generator is already executing.");
17
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
18
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
19
+ if (y = 0, t) op = [op[0] & 2, t.value];
20
+ switch (op[0]) {
21
+ case 0: case 1: t = op; break;
22
+ case 4: _.label++; return { value: op[1], done: false };
23
+ case 5: _.label++; y = op[1]; op = [0]; continue;
24
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
25
+ default:
26
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
27
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
28
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
29
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
30
+ if (t[2]) _.ops.pop();
31
+ _.trys.pop(); continue;
32
+ }
33
+ op = body.call(thisArg, _);
34
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
35
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
36
+ }
37
+ };
38
+ var __importDefault = (this && this.__importDefault) || function (mod) {
39
+ return (mod && mod.__esModule) ? mod : { "default": mod };
40
+ };
41
+ Object.defineProperty(exports, "__esModule", { value: true });
42
+ exports.default = getEstimateFeeService;
43
+ var userClientRequest_1 = __importDefault(require("../clients/userClientRequest"));
44
+ function getEstimateFeeService(query) {
45
+ return __awaiter(this, void 0, void 0, function () {
46
+ var response;
47
+ return __generator(this, function (_a) {
48
+ switch (_a.label) {
49
+ case 0: return [4 /*yield*/, userClientRequest_1.default.get("/fee/calculate?amount=".concat(query.amount, "&transaction_type=").concat(query.transaction_type, "&currency=").concat(query.currency), {
50
+ params: query,
51
+ })];
52
+ case 1:
53
+ response = _a.sent();
54
+ console.warn("🚀 ~ getEstimateFeeService response:", response);
55
+ return [2 /*return*/, response.data];
56
+ }
57
+ });
58
+ });
59
+ }
@@ -0,0 +1,31 @@
1
+ export interface GetEstimateFeeServiceQuery {
2
+ amount: string;
3
+ transaction_type: string;
4
+ currency: string;
5
+ }
6
+ export interface GetEstimateFeeServiceResponse {
7
+ success: boolean;
8
+ message: string;
9
+ data: Data;
10
+ timestamp: string;
11
+ }
12
+ interface Data {
13
+ feeInUSD: number;
14
+ feeInCurrency: number;
15
+ originalAmountInUSD: number;
16
+ originalAmountInCurrency: number;
17
+ originalCurrency: string;
18
+ feeDetail: FeeDetail[];
19
+ }
20
+ interface FeeDetail {
21
+ feeType: FeeType;
22
+ feeInUSD: number;
23
+ feeInCurrency: number;
24
+ feePercent: number;
25
+ feeFixed: number;
26
+ }
27
+ interface FeeType {
28
+ name: string;
29
+ slug: string;
30
+ }
31
+ export {};
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tek-wallet",
3
- "version": "0.0.357",
3
+ "version": "0.0.358",
4
4
  "description": "A custom React provider with TypeScript support",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",