Skip to content

Commit

Permalink
fix: too low balance on kadena
Browse files Browse the repository at this point in the history
  • Loading branch information
kvhnuke committed May 13, 2024
1 parent f5b124d commit 74d97e1
Showing 1 changed file with 28 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ import KadenaAPI from "@/providers/kadena/libs/api";
import getUiPath from "@/libs/utils/get-ui-path";
import { ProviderName } from "@/types/provider";
import Browser from "webextension-polyfill";
import { ICommandResult } from "@kadena/client";
const props = defineProps({
network: {
Expand Down Expand Up @@ -256,21 +257,41 @@ const validateFields = async () => {
);
const networkApi = (await props.network.api()) as KadenaAPI;
const transactionResult = await networkApi.sendLocalTransaction(
localTransaction
);
const transactionResult = await networkApi
.sendLocalTransaction(localTransaction)
.catch((e) => {
if ((e.message as string).includes("Insufficient funds")) {
return {
result: {
status: "error",
error: {
message: "Insufficient funds",
},
},
};
}
return {
result: {
status: "error",
error: {
message: "An error occurred",
},
},
};
});
if (transactionResult.result.status !== "success") {
fieldsValidation.value.amount = false;
console.log(transactionResult.result.error);
errorMsg.value =
(transactionResult.result.error as any).message ||
(transactionResult.result as any).error.message ||
"An error occurred";
return;
}
const gasLimit = transactionResult.metaData?.publicMeta?.gasLimit;
const gasPrice = transactionResult.metaData?.publicMeta?.gasPrice;
const gasLimit = (transactionResult as ICommandResult).metaData
?.publicMeta?.gasLimit;
const gasPrice = (transactionResult as ICommandResult).metaData
?.publicMeta?.gasPrice;
const gasFee = gasLimit && gasPrice ? gasLimit * gasPrice : 0;
const rawFee = toBN(
Expand Down

1 comment on commit 74d97e1

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.