Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: gas estimate for contract #22

Merged
merged 1 commit into from
May 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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';"
}
}
Loading