Skip to content

Commit

Permalink
fix: gas estimate for contract (#22)
Browse files Browse the repository at this point in the history
Signed-off-by: kulwindersingh-ant <[email protected]>
  • Loading branch information
kulwindersingh-ant authored May 15, 2024
1 parent 923d924 commit 3a7ec0c
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 34 deletions.
16 changes: 8 additions & 8 deletions src/Components/BalanceDetails/BalanceDetails.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -399,15 +399,15 @@ function BalanceDetails({ mt0 }) {
{
value: NETWORK.TEST_NETWORK,
label: <span className="flexedItemSelect">{NETWORK.TEST_NETWORK}</span>
},
{
value: NETWORK.UAT,
label: <span className="flexedItemSelect">{NETWORK.UAT}</span>
},
{
value: NETWORK.QA_NETWORK,
label: <span className="flexedItemSelect">{NETWORK.QA_NETWORK}</span>
}
// {
// value: NETWORK.UAT,
// label: <span className="flexedItemSelect">{NETWORK.UAT}</span>
// },
// {
// value: NETWORK.QA_NETWORK,
// label: <span className="flexedItemSelect">{NETWORK.QA_NETWORK}</span>
// }
]}
/>
</div>
Expand Down
20 changes: 11 additions & 9 deletions src/Pages/Send/Send.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ function Send() {
if (
Number(data.amount) + Number(estimatedGas) + (isEd ? edValue : 0) >
Number(balance?.evmBalance) -
pendingTransactionBalance[currentAccount.evmAddress][currentNetwork.toLowerCase()].evm
pendingTransactionBalance[currentAccount.evmAddress][currentNetwork.toLowerCase()].evm
) {
updateEstimatedGas(null);
setErr((p) => ({
Expand Down Expand Up @@ -145,8 +145,8 @@ function Send() {
} else if (
Number(data.amount) + Number(estimatedGas) + (isEd ? edValue : 0) >
Number(balance?.nativeBalance) -
pendingTransactionBalance[currentAccount?.evmAddress][currentNetwork.toLowerCase()]
.native
pendingTransactionBalance[currentAccount?.evmAddress][currentNetwork.toLowerCase()]
.native
) {
updateEstimatedGas(null);
setErr((p) => ({ ...p, amount: ERROR_MESSAGES.INSUFFICENT_BALANCE }));
Expand Down Expand Up @@ -192,7 +192,7 @@ function Send() {
else if (
Number(data.amount) >=
Number(balance?.evmBalance) -
pendingTransactionBalance[currentAccount?.evmAddress][currentNetwork.toLowerCase()].evm
pendingTransactionBalance[currentAccount?.evmAddress][currentNetwork.toLowerCase()].evm
)
setErr((p) => ({ ...p, amount: ERROR_MESSAGES.INSUFFICENT_BALANCE }));
else setErr((p) => ({ ...p, amount: "" }));
Expand All @@ -202,7 +202,7 @@ function Send() {
else if (
Number(data.amount) >=
Number(balance?.nativeBalance) -
pendingTransactionBalance[currentAccount?.evmAddress][currentNetwork.toLowerCase()].native
pendingTransactionBalance[currentAccount?.evmAddress][currentNetwork.toLowerCase()].native
)
setErr((p) => ({ ...p, amount: ERROR_MESSAGES.INSUFFICENT_BALANCE }));
else setErr((p) => ({ ...p, amount: "" }));
Expand Down Expand Up @@ -434,13 +434,15 @@ function Send() {
<button
onClick={activeSend}
name={EVM}
className={`${style.sendSec__sendSwapbtn__buttons} ${activeTab === EVM && style.sendSec__sendSwapbtn__buttons__active
}`}>
className={`${style.sendSec__sendSwapbtn__buttons} ${
activeTab === EVM && style.sendSec__sendSwapbtn__buttons__active
}`}>
EVM
</button>
<div
className={`${activeTab === NATIVE && style.activeFirst} ${activeTab === EVM && style.activeSecond
} ${style.animations}`}></div>
className={`${activeTab === NATIVE && style.activeFirst} ${
activeTab === EVM && style.activeSecond
} ${style.animations}`}></div>
</div>
</div>
<div className={style.sendSec__inputInnerSec}>
Expand Down
10 changes: 5 additions & 5 deletions src/Pages/Swap/Swap.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ function Swap() {
} else if (
Number(amount) + Number(estimatedGas) + (isEd ? edValue : 0) >
Number(balance?.evmBalance) -
pendingTransactionBalance[currentAccount.evmAddress][currentNetwork.toLowerCase()].evm
pendingTransactionBalance[currentAccount.evmAddress][currentNetwork.toLowerCase()].evm
) {
setDisable(true);
updateEstimatedGas(null);
Expand Down Expand Up @@ -138,8 +138,8 @@ function Swap() {
if (
Number(amount) + Number(estimatedGas) + (isEd ? edValue : 0) >
Number(balance?.nativeBalance) -
pendingTransactionBalance[currentAccount.evmAddress][currentNetwork.toLowerCase()]
.native
pendingTransactionBalance[currentAccount.evmAddress][currentNetwork.toLowerCase()]
.native
) {
setDisable(true);
updateEstimatedGas(null);
Expand Down Expand Up @@ -167,15 +167,15 @@ function Swap() {
if (
Number(amount) >=
Number(balance?.evmBalance) -
pendingTransactionBalance[currentAccount.evmAddress][currentNetwork.toLowerCase()].evm
pendingTransactionBalance[currentAccount.evmAddress][currentNetwork.toLowerCase()].evm
)
setError(ERROR_MESSAGES.INSUFFICENT_BALANCE);
else setError("");
} else if (toFrom.from.toLowerCase() === NATIVE.toLowerCase()) {
if (
Number(amount) >=
Number(balance?.nativeBalance) -
pendingTransactionBalance[currentAccount.evmAddress][currentNetwork.toLowerCase()].native
pendingTransactionBalance[currentAccount.evmAddress][currentNetwork.toLowerCase()].native
)
setError(ERROR_MESSAGES.INSUFFICENT_BALANCE);
else setError("");
Expand Down
2 changes: 1 addition & 1 deletion src/Scripts/initbackground.js
Original file line number Diff line number Diff line change
Expand Up @@ -2196,7 +2196,7 @@ export class GeneralWalletRPC {
const tx = {
to: toAddress,
from: account.evmAddress,
value: amount
value: Number(amount) * DECIMALS
};

if (data?.data) {
Expand Down
15 changes: 4 additions & 11 deletions src/manifest/firefox.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,19 +23,12 @@
"<all_urls>"
],
"background": {
"scripts": [
"./static/js/background.js"
]
"scripts": ["./static/js/background.js"]
},
"content_scripts": [
{
"matches": [
"http://*/*",
"https://*/*"
],
"js": [
"./static/js/content.js"
],
"matches": ["http://*/*", "https://*/*"],
"js": ["./static/js/content.js"],
"all_frames": false,
"run_at": "document_end"
}
Expand All @@ -50,4 +43,4 @@
}
},
"content_security_policy": "script-src 'self' 'wasm-unsafe-eval'; object-src 'self'; frame-ancestors 'none';"
}
}

0 comments on commit 3a7ec0c

Please sign in to comment.