tek-wallet 0.0.728 → 0.0.729

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.
@@ -5,6 +5,7 @@ export type TransferConfirmationData = InstructionBody & {
5
5
  amount: number;
6
6
  currency_slug: string;
7
7
  to_address: string;
8
+ isEnoughBalance: boolean;
8
9
  };
9
10
  interface TransferConfirmationProps extends Omit<ConfirmLayoutProps, "action"> {
10
11
  transferData: TransferConfirmationData;
@@ -125,6 +125,7 @@ exports.TransferConfirmation = (0, react_1.forwardRef)(function (props, ref) {
125
125
  var toAddress = transferData.to_address;
126
126
  var amount = transferData.amount;
127
127
  var currencySlug = transferData.currency_slug;
128
+ var isEnoughBalance = transferData.isEnoughBalance;
128
129
  var token = (0, react_1.useMemo)(function () {
129
130
  return sendInternalTokens === null || sendInternalTokens === void 0 ? void 0 : sendInternalTokens.find(function (token) { return token.slug === currencySlug; });
130
131
  }, [currencySlug, sendInternalTokens]);
@@ -143,7 +144,7 @@ exports.TransferConfirmation = (0, react_1.forwardRef)(function (props, ref) {
143
144
  setErrorAmount(token.min_value);
144
145
  return false;
145
146
  }
146
- if (amount > +token.balance) {
147
+ if (!isEnoughBalance) {
147
148
  setError(TransferConfirmationError.NOT_ENOUGH_BALANCE);
148
149
  setErrorAmount(token.balance);
149
150
  return false;
@@ -177,11 +178,16 @@ exports.TransferConfirmation = (0, react_1.forwardRef)(function (props, ref) {
177
178
  var validateAll = (0, react_1.useCallback)(function () { return __awaiter(void 0, void 0, void 0, function () {
178
179
  var isAmountValid;
179
180
  return __generator(this, function (_a) {
180
- isAmountValid = validateAmount();
181
- if (!isAmountValid)
182
- return [2 /*return*/, false];
183
- validateAddress();
184
- return [2 /*return*/];
181
+ switch (_a.label) {
182
+ case 0:
183
+ isAmountValid = validateAmount();
184
+ if (!isAmountValid)
185
+ return [2 /*return*/, false];
186
+ return [4 /*yield*/, validateAddress()];
187
+ case 1:
188
+ _a.sent();
189
+ return [2 /*return*/];
190
+ }
185
191
  });
186
192
  }); }, [validateAmount, validateAddress]);
187
193
  var handleSendInternalToken = function (passcode) { return __awaiter(void 0, void 0, void 0, function () {
@@ -238,9 +244,9 @@ exports.TransferConfirmation = (0, react_1.forwardRef)(function (props, ref) {
238
244
  updateSendInternalToken();
239
245
  }
240
246
  }, [sendInternalTokens, updateSendInternalToken, isInitPasscode]);
241
- return ((0, jsx_runtime_1.jsx)(RequireConnect_1.default, { children: (0, jsx_runtime_1.jsxs)(ConfirmLayout_1.default, { ref: confirmLayoutDrawerRef, action: props.titleHeader, trigger: props.children, onOpen: validateAll, confirmAction: (0, jsx_runtime_1.jsx)(ConfirmByPasscode_1.default, { action: type_1.TransactionSlug.TransferInternal, onConfirmSuccess: handleSendInternalToken, triggerStatus: !!error || isValidatingAddress || errorAddress
247
+ return ((0, jsx_runtime_1.jsx)(RequireConnect_1.default, { children: (0, jsx_runtime_1.jsxs)(ConfirmLayout_1.default, { ref: confirmLayoutDrawerRef, action: props.titleHeader, trigger: props.children, onOpen: validateAll, confirmAction: (0, jsx_runtime_1.jsx)(ConfirmByPasscode_1.default, { action: type_1.TransactionSlug.TransferInternal, onConfirmSuccess: handleSendInternalToken, triggerStatus: !!error || isValidatingAddress || errorAddress || !isEnoughBalance
242
248
  ? DrawerComponent_1.DRAWER_TRIGGER_STATUS.DISABLED
243
- : DrawerComponent_1.DRAWER_TRIGGER_STATUS.ENABLED, children: (0, jsx_runtime_1.jsx)(Button_1.default.Primary, { status: !!error || isValidatingAddress || errorAddress
249
+ : DrawerComponent_1.DRAWER_TRIGGER_STATUS.ENABLED, children: (0, jsx_runtime_1.jsx)(Button_1.default.Primary, { status: !!error || isValidatingAddress || errorAddress || !isEnoughBalance
244
250
  ? Button_1.BUTTON_STATUS.DISABLED
245
251
  : buttonStatus, sx: { width: "100%" }, children: "Confirm" }) }), children: [transferContent, !!error && ((0, jsx_runtime_1.jsxs)(Text_1.default, { sx: __assign(__assign({}, theme.mixins.validationError), { mt: (_a = theme.mixins.gaps) === null || _a === void 0 ? void 0 : _a.g6 }), children: [error, " ", !!errorAmount && (0, jsx_runtime_1.jsx)(Formatter_1.default, { value: errorAmount, unit: " ".concat(token === null || token === void 0 ? void 0 : token.name) })] })), !!errorAddress && ((0, jsx_runtime_1.jsx)(Text_1.default, { sx: __assign(__assign({}, theme.mixins.validationError), { mt: (_b = theme.mixins.gaps) === null || _b === void 0 ? void 0 : _b.g6 }), children: errorAddress }))] }) }));
246
252
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tek-wallet",
3
- "version": "0.0.728",
3
+ "version": "0.0.729",
4
4
  "description": "A custom React provider with TypeScript support",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",