From 674cca600f1ac6e4f047b0caf6ea862bfa07e32a Mon Sep 17 00:00:00 2001 From: HoangNDM6 Date: Tue, 26 Mar 2024 16:35:43 +0700 Subject: [PATCH 1/8] update chainId --- public/config.json | 4 +- src/config/cache/chains.ts | 2 +- .../Transactions/TxActionModal/Send/index.tsx | 37 +++++++++++++++---- 3 files changed, 32 insertions(+), 11 deletions(-) diff --git a/public/config.json b/public/config.json index 1c9021c48c..85c5bbcccd 100644 --- a/public/config.json +++ b/public/config.json @@ -1,12 +1,12 @@ { "api-gateway": "https://safe-api.dev.aura.network", - "chain_id": "aura-testnet-2", + "chain_id": "auradev_1235-3", "chain_info": [ { "features": [ "ibc-transfer" ], - "chainId": "aura-testnet-2", + "chainId": "auradev_1235-3", "chainName": "aura testnet", "rpc": "https://rpc.dev.aura.network", "rest": "https://lcd.dev.aura.network", diff --git a/src/config/cache/chains.ts b/src/config/cache/chains.ts index c8dd5dd3d4..877c348ed3 100644 --- a/src/config/cache/chains.ts +++ b/src/config/cache/chains.ts @@ -21,7 +21,7 @@ export const loadChains = async () => { environment: 'serenity', } } - if (chain.chainId.includes('aura-testnet')) { + if (chain.chainId.includes('auradev_1235-3')) { return { ...chain, environment: 'auratestnet', diff --git a/src/pages/Transactions/TxActionModal/Send/index.tsx b/src/pages/Transactions/TxActionModal/Send/index.tsx index 6319b29ce5..404eba326c 100644 --- a/src/pages/Transactions/TxActionModal/Send/index.tsx +++ b/src/pages/Transactions/TxActionModal/Send/index.tsx @@ -6,31 +6,43 @@ import AddressInfo from 'src/components/AddressInfo' import { FilledButton, OutlinedNeutralButton } from 'src/components/Button' import Divider from 'src/components/Divider' import Gap from 'src/components/Gap' +import TxMemo from 'src/components/Input/TxMemo' import { Popup } from 'src/components/Popup' import Footer from 'src/components/Popup/Footer' import Header from 'src/components/Popup/Header' import Amount from 'src/components/TxComponents/Amount' -import { getCoinMinimalDenom } from 'src/config' +import { getChainDefaultGasPrice, getCoinDecimal, getCoinMinimalDenom } from 'src/config' import { currentSafeWithNames } from 'src/logic/safe/store/selectors' -import { formatNativeCurrency, formatNativeToken } from 'src/utils' +import { convertAmount, formatNativeCurrency, formatNativeToken, formatWithComma } from 'src/utils' import { signAndChangeTransactionSequence, signAndConfirmTransaction } from 'src/utils/signer' import { getNotice, getTitle } from '..' import { TxSignModalContext } from '../../Queue' import { ReviewTxPopupWrapper } from '../../styled' import EditSequence from '../EditSequence' -import TxMemo from 'src/components/Input/TxMemo' import { DeleteButton, TxContent } from '../styles' +import calculateGasFee from '../../../../logic/providers/utils/fee' export default function Execute({ open, onClose, data, sendTx, rejectTx, disabled, setDisabled, deleteTx }) { const { action } = useContext(TxSignModalContext) - const { nativeBalance: balance, sequence: currentSequence } = useSelector(currentSafeWithNames) + const { nativeBalance: balance, sequence: currentSequence, coinConfig } = useSelector(currentSafeWithNames) + const chainDefaultGasPrice = getChainDefaultGasPrice() + const decimal = getCoinDecimal() + const gasFee = chainDefaultGasPrice ? calculateGasFee(400000, +chainDefaultGasPrice, decimal) : chainDefaultGasPrice const dispatch = useDispatch() const [sequence, setSequence] = useState(data?.txSequence) const [txMemo, setTxMemo] = useState(data?.txDetails?.txMemo) - const totalAllocationAmount = formatNativeToken( - new BigNumber(+data?.txDetails?.txMessage[0]?.amount || 0).plus(+data.txDetails?.fee || 0).toString(), - ) + const isNativeToken = data?.txDetails?.txMessage[0]?.denom === coinConfig?.find((e) => e.type === 'native').denom + const otherToken = coinConfig?.find((e) => e.denom === data?.txDetails?.txMessage[0]?.denom) + + const totalAllocationAmount = isNativeToken + ? formatNativeToken( + new BigNumber(+data?.txDetails?.txMessage[0]?.amount || 0).plus(+data.txDetails?.fee || 0).toString(), + ) + : `${formatWithComma(data?.txDetails?.txMessage[0]?.amount)} ${otherToken?.coinDenom} + ${formatNativeCurrency( + new BigNumber(+gasFee).toString(), + )}` + const txHandler = async (type) => { if (type == 'confirm') { dispatch( @@ -80,6 +92,9 @@ export default function Execute({ open, onClose, data, sendTx, rejectTx, disable ) } } + console.log(data?.txDetails) + console.log(coinConfig) + return ( <> @@ -115,7 +130,13 @@ export default function Execute({ open, onClose, data, sendTx, rejectTx, disable ) : ( <> - + {action == 'change-sequence' && ( <> From 070d15517b383dad67637759d8725b9170c34728 Mon Sep 17 00:00:00 2001 From: HoangNDM6 Date: Tue, 26 Mar 2024 16:39:14 +0700 Subject: [PATCH 2/8] update chainId --- src/config/cache/chains.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/config/cache/chains.ts b/src/config/cache/chains.ts index 877c348ed3..e39e41cd36 100644 --- a/src/config/cache/chains.ts +++ b/src/config/cache/chains.ts @@ -21,7 +21,7 @@ export const loadChains = async () => { environment: 'serenity', } } - if (chain.chainId.includes('auradev_1235-3')) { + if (chain.chainId.includes('auradev')) { return { ...chain, environment: 'auratestnet', From 6b8798fc04fdad3fac0643dc77836ec8abbac1b3 Mon Sep 17 00:00:00 2001 From: HoangNDM6 Date: Tue, 26 Mar 2024 16:45:16 +0700 Subject: [PATCH 3/8] fix send ibc token --- src/pages/Transactions/TxActionModal/Send/index.tsx | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/pages/Transactions/TxActionModal/Send/index.tsx b/src/pages/Transactions/TxActionModal/Send/index.tsx index 404eba326c..105663e7dd 100644 --- a/src/pages/Transactions/TxActionModal/Send/index.tsx +++ b/src/pages/Transactions/TxActionModal/Send/index.tsx @@ -92,8 +92,6 @@ export default function Execute({ open, onClose, data, sendTx, rejectTx, disable ) } } - console.log(data?.txDetails) - console.log(coinConfig) return ( <> From f0c579cbd26025f3298e43b883e46291a0d5e389 Mon Sep 17 00:00:00 2001 From: HoangNDM6 Date: Tue, 26 Mar 2024 17:30:54 +0700 Subject: [PATCH 4/8] fix send ibc token --- src/pages/Transactions/TxActionModal/Send/index.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/Transactions/TxActionModal/Send/index.tsx b/src/pages/Transactions/TxActionModal/Send/index.tsx index 105663e7dd..b873c587cf 100644 --- a/src/pages/Transactions/TxActionModal/Send/index.tsx +++ b/src/pages/Transactions/TxActionModal/Send/index.tsx @@ -32,7 +32,7 @@ export default function Execute({ open, onClose, data, sendTx, rejectTx, disable const [sequence, setSequence] = useState(data?.txSequence) const [txMemo, setTxMemo] = useState(data?.txDetails?.txMemo) - const isNativeToken = data?.txDetails?.txMessage[0]?.denom === coinConfig?.find((e) => e.type === 'native').denom + const isNativeToken = data?.txDetails?.txMessage[0]?.denom === coinConfig?.find((e) => e?.type === 'native')?.denom const otherToken = coinConfig?.find((e) => e.denom === data?.txDetails?.txMessage[0]?.denom) const totalAllocationAmount = isNativeToken From 729aad996a3b0decefbaa7e09813870c5280012e Mon Sep 17 00:00:00 2001 From: HoangNDM6 Date: Tue, 26 Mar 2024 17:36:09 +0700 Subject: [PATCH 5/8] fix send ibc token --- src/pages/Transactions/TxActionModal/Send/index.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/Transactions/TxActionModal/Send/index.tsx b/src/pages/Transactions/TxActionModal/Send/index.tsx index b873c587cf..6906bee527 100644 --- a/src/pages/Transactions/TxActionModal/Send/index.tsx +++ b/src/pages/Transactions/TxActionModal/Send/index.tsx @@ -33,7 +33,7 @@ export default function Execute({ open, onClose, data, sendTx, rejectTx, disable const [txMemo, setTxMemo] = useState(data?.txDetails?.txMemo) const isNativeToken = data?.txDetails?.txMessage[0]?.denom === coinConfig?.find((e) => e?.type === 'native')?.denom - const otherToken = coinConfig?.find((e) => e.denom === data?.txDetails?.txMessage[0]?.denom) + const otherToken = coinConfig?.find((e) => e?.denom ?? e?.cosmosDenom === data?.txDetails?.txMessage[0]?.denom) const totalAllocationAmount = isNativeToken ? formatNativeToken( From c377e05f6042bc3c1a58e5af88eb6d95f3e0c751 Mon Sep 17 00:00:00 2001 From: hoangndm Date: Tue, 26 Mar 2024 23:03:09 +0700 Subject: [PATCH 6/8] fix send ibc token --- src/pages/Transactions/TxActionModal/Send/index.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/Transactions/TxActionModal/Send/index.tsx b/src/pages/Transactions/TxActionModal/Send/index.tsx index 6906bee527..b70931b012 100644 --- a/src/pages/Transactions/TxActionModal/Send/index.tsx +++ b/src/pages/Transactions/TxActionModal/Send/index.tsx @@ -132,7 +132,7 @@ export default function Execute({ open, onClose, data, sendTx, rejectTx, disable amount={ isNativeToken ? formatNativeToken(data?.txDetails?.txMessage[0]?.amount) - : convertAmount(data?.txDetails?.txMessage[0]?.amount, false, otherToken?.coinDenom) + : convertAmount(data?.txDetails?.txMessage[0]?.amount, false, otherToken?.decimals) } /> {action == 'change-sequence' && ( From 73c03e7a345b249df068919600d887bf5144952d Mon Sep 17 00:00:00 2001 From: hoangndm Date: Tue, 26 Mar 2024 23:22:42 +0700 Subject: [PATCH 7/8] fix send ibc token --- .../Transactions/TxActionModal/Send/index.tsx | 20 +++++++++---------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/src/pages/Transactions/TxActionModal/Send/index.tsx b/src/pages/Transactions/TxActionModal/Send/index.tsx index b70931b012..ae1fbe2156 100644 --- a/src/pages/Transactions/TxActionModal/Send/index.tsx +++ b/src/pages/Transactions/TxActionModal/Send/index.tsx @@ -35,13 +35,17 @@ export default function Execute({ open, onClose, data, sendTx, rejectTx, disable const isNativeToken = data?.txDetails?.txMessage[0]?.denom === coinConfig?.find((e) => e?.type === 'native')?.denom const otherToken = coinConfig?.find((e) => e?.denom ?? e?.cosmosDenom === data?.txDetails?.txMessage[0]?.denom) + const amount = isNativeToken + ? formatNativeToken(data?.txDetails?.txMessage[0]?.amount) + : `${convertAmount(data?.txDetails?.txMessage[0]?.amount, false, otherToken?.decimals)} ${otherToken?.coinDenom}` + const totalAllocationAmount = isNativeToken ? formatNativeToken( new BigNumber(+data?.txDetails?.txMessage[0]?.amount || 0).plus(+data.txDetails?.fee || 0).toString(), ) - : `${formatWithComma(data?.txDetails?.txMessage[0]?.amount)} ${otherToken?.coinDenom} + ${formatNativeCurrency( - new BigNumber(+gasFee).toString(), - )}` + : `${convertAmount(data?.txDetails?.txMessage[0]?.amount, false, otherToken?.decimals)} ${ + otherToken?.coinDenom + } + ${formatNativeCurrency(new BigNumber(+gasFee).toString())}` const txHandler = async (type) => { if (type == 'confirm') { @@ -110,7 +114,7 @@ export default function Execute({ open, onClose, data, sendTx, rejectTx, disable
Amount
-
{formatNativeToken(data?.txDetails?.txMessage[0]?.amount)}
+
{amount}
Transaction fee
@@ -128,13 +132,7 @@ export default function Execute({ open, onClose, data, sendTx, rejectTx, disable ) : ( <> - + {action == 'change-sequence' && ( <> From 06725e49f59221d1da8da60c768251c42135c61b Mon Sep 17 00:00:00 2001 From: hoangndm Date: Mon, 1 Apr 2024 21:22:27 +0700 Subject: [PATCH 8/8] fix reload safe --- src/logic/safe/store/selectors/index.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/logic/safe/store/selectors/index.ts b/src/logic/safe/store/selectors/index.ts index d1c59f9ab1..42c5def3cc 100644 --- a/src/logic/safe/store/selectors/index.ts +++ b/src/logic/safe/store/selectors/index.ts @@ -16,8 +16,7 @@ export const safesAsMap = (state: AppReduxState): SafesMap => safesState(state). export const safesAsList = createSelector(safesAsMap, (safes): List => safes.toList()) -export const currentSafe = createSelector([safesAsMap], (safes: SafesMap) => { - const address = extractSafeAddress() +export const currentSafe = createSelector([safesAsMap, extractSafeAddress], (safes: SafesMap, address: string) => { return safes.get(address, baseSafe(address)) }) export const safeByAddressSelector = createSelector(