From b1fcf9acb367df973f3dacb3662f80be449f709b Mon Sep 17 00:00:00 2001 From: vkulinich Date: Fri, 29 Nov 2024 14:23:33 +0100 Subject: [PATCH 1/9] Adjust toasts for snowbridge --- .../transaction/ReviewTransaction.utils.tsx | 36 ++++++++++++++++--- src/sections/xcm/XcmPage.tsx | 8 ++++- src/utils/evm.ts | 3 +- 3 files changed, 41 insertions(+), 6 deletions(-) diff --git a/src/sections/transaction/ReviewTransaction.utils.tsx b/src/sections/transaction/ReviewTransaction.utils.tsx index df9b60287..b51870440 100644 --- a/src/sections/transaction/ReviewTransaction.utils.tsx +++ b/src/sections/transaction/ReviewTransaction.utils.tsx @@ -187,6 +187,7 @@ export const useSendEvmTransactionMutation = ( const [xcallMeta, setCallMeta] = useState | undefined>( undefined, ) + const [isSnowbridge, setIsSnowbridge] = useState(false) const { account } = useEvmAccount() const isTestnet = useIsTestnet() @@ -194,6 +195,12 @@ export const useSendEvmTransactionMutation = ( const sendTx = useMutation(async ({ evmTx, xcallMeta }) => { return await new Promise(async (resolve, reject) => { try { + const isSnowBridge = xcallMeta?.tags === "Snowbridge" + + if (isSnowBridge) { + setIsSnowbridge(true) + } + setTxState("Broadcast") setTxHash(evmTx?.hash ?? "") setTxData(evmTx?.data) @@ -210,7 +217,9 @@ export const useSendEvmTransactionMutation = ( const chain = account?.chainId ? getEvmChainById(account.chainId) : null const txLink = - txHash && chain ? getEvmTxLink(txHash, txData, chain.key, isTestnet) : "" + txHash && chain + ? getEvmTxLink(txHash, txData, chain.key, isTestnet, isSnowbridge) + : "" const isApproveTx = txData?.startsWith("0x095ea7b3") @@ -226,12 +235,13 @@ export const useSendEvmTransactionMutation = ( txState, txLink, txHash, - bridge: isApproveTx ? undefined : bridge, + bridge: isApproveTx || isSnowbridge ? undefined : bridge, reset: () => { setTxState(null) setTxHash("") setCallMeta(undefined) sendTx.reset() + setIsSnowbridge(false) }, } } @@ -313,6 +323,7 @@ export const useSendDispatchPermit = ( const [xcallMeta, setCallMeta] = useState | undefined>( undefined, ) + const [isSnowbridge, setIsSnowbridge] = useState(false) const isMounted = useMountedState() const sendTx = useMutation(async ({ permit, xcallMeta }) => { @@ -335,6 +346,12 @@ export const useSendDispatchPermit = ( const isInBlock = result.status.type === "InBlock" if (isMounted()) { + const isSnowBridge = xcallMeta?.tags === "Snowbridge" + + if (isSnowBridge) { + setIsSnowbridge(true) + } + setTxHash(result.txHash.toHex()) setTxState(result.status.type) setCallMeta(xcallMeta) @@ -403,7 +420,8 @@ export const useSendDispatchPermit = ( ? createSubscanLink("extrinsic", txHash, srcChain.key) : undefined - const bridge = destChain?.isEvmChain() ? "substrate" : undefined + const bridge = + destChain?.isEvmChain() && !isSnowbridge ? "substrate" : undefined return { ...sendTx, @@ -415,6 +433,7 @@ export const useSendDispatchPermit = ( setTxState(null) setTxHash("") sendTx.reset() + setIsSnowbridge(false) }, } } @@ -436,6 +455,7 @@ export const useSendTransactionMutation = ( const [xcallMeta, setCallMeta] = useState | undefined>( undefined, ) + const [isSnowbridge, setIsSnowbridge] = useState(false) const sendTx = useMutation(async ({ tx, xcallMeta }) => { return await new Promise(async (resolve, reject) => { @@ -444,6 +464,12 @@ export const useSendTransactionMutation = ( if (!result || !result.status) return if (isMounted()) { + const isSnowBridge = xcallMeta?.tags === "Snowbridge" + + if (isSnowBridge) { + setIsSnowbridge(true) + } + setTxHash(result.txHash.toHex()) setTxState(result.status.type) setCallMeta(xcallMeta) @@ -488,7 +514,8 @@ export const useSendTransactionMutation = ( ? createSubscanLink("extrinsic", txHash, srcChain.key) : undefined - const bridge = destChain?.isEvmChain() ? "substrate" : undefined + const bridge = + destChain?.isEvmChain() && !isSnowbridge ? "substrate" : undefined return { ...sendTx, @@ -501,6 +528,7 @@ export const useSendTransactionMutation = ( setTxHash("") setCallMeta(undefined) sendTx.reset() + setIsSnowbridge(false) }, } } diff --git a/src/sections/xcm/XcmPage.tsx b/src/sections/xcm/XcmPage.tsx index 83e2506cb..db1303c87 100644 --- a/src/sections/xcm/XcmPage.tsx +++ b/src/sections/xcm/XcmPage.tsx @@ -75,6 +75,9 @@ export function XcmPage() { const rpcUrlList = useActiveRpcUrlList() const handleSubmit = async (e: CustomEvent) => { + const isSnowbridge = e.detail?.meta?.tags === "Snowbridge" + const isApprove = e.detail.transaction.hex.startsWith("0x095ea7b3") + await createTransaction( { tx: await getSubmittableExtrinsic(e.detail), @@ -83,7 +86,10 @@ export function XcmPage() { { onSuccess: () => {}, onSubmitted: () => {}, - toast: getNotificationToastTemplates(e.detail), + toast: + !isSnowbridge || isApprove + ? getNotificationToastTemplates(e.detail) + : undefined, }, ) } diff --git a/src/utils/evm.ts b/src/utils/evm.ts index bfdd4e2c3..7ffc49aa6 100644 --- a/src/utils/evm.ts +++ b/src/utils/evm.ts @@ -78,6 +78,7 @@ export function getEvmTxLink( txData: string | undefined, chainKey = "hydration", isTestnet = false, + isSnowbridge = false, ) { const chain = chainsMap.get(chainKey) @@ -86,7 +87,7 @@ export function getEvmTxLink( if (chain.isEvmChain()) { const isApproveTx = txData?.startsWith("0x095ea7b3") - return isApproveTx + return isApproveTx || isSnowbridge ? `https://etherscan.io/tx/${txHash}` : `https://wormholescan.io/#/tx/${txHash}` } From 851db65b0587d2e4e2f03f0a1140bcfcca1efc74 Mon Sep 17 00:00:00 2001 From: vkulinich Date: Fri, 29 Nov 2024 16:15:28 +0100 Subject: [PATCH 2/9] address PR cooments --- src/sections/transaction/ReviewTransaction.utils.tsx | 7 ++++--- src/sections/xcm/XcmPage.tsx | 3 ++- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/sections/transaction/ReviewTransaction.utils.tsx b/src/sections/transaction/ReviewTransaction.utils.tsx index b51870440..266c0c9ac 100644 --- a/src/sections/transaction/ReviewTransaction.utils.tsx +++ b/src/sections/transaction/ReviewTransaction.utils.tsx @@ -44,6 +44,7 @@ import { isAnyParachain, Maybe } from "utils/helpers" import { createSubscanLink } from "utils/formatting" import { QUERY_KEYS } from "utils/queryKeys" import { useIsTestnet } from "api/provider" +import { tags } from "@galacticcouncil/xcm-cfg" const EVM_PERMIT_BLOCKTIME = 20_000 @@ -195,7 +196,7 @@ export const useSendEvmTransactionMutation = ( const sendTx = useMutation(async ({ evmTx, xcallMeta }) => { return await new Promise(async (resolve, reject) => { try { - const isSnowBridge = xcallMeta?.tags === "Snowbridge" + const isSnowBridge = xcallMeta?.tags === tags.Tag.Snowbridge if (isSnowBridge) { setIsSnowbridge(true) @@ -346,7 +347,7 @@ export const useSendDispatchPermit = ( const isInBlock = result.status.type === "InBlock" if (isMounted()) { - const isSnowBridge = xcallMeta?.tags === "Snowbridge" + const isSnowBridge = xcallMeta?.tags === tags.Tag.Snowbridge if (isSnowBridge) { setIsSnowbridge(true) @@ -464,7 +465,7 @@ export const useSendTransactionMutation = ( if (!result || !result.status) return if (isMounted()) { - const isSnowBridge = xcallMeta?.tags === "Snowbridge" + const isSnowBridge = xcallMeta?.tags === tags.Tag.Snowbridge if (isSnowBridge) { setIsSnowbridge(true) diff --git a/src/sections/xcm/XcmPage.tsx b/src/sections/xcm/XcmPage.tsx index db1303c87..477e94e05 100644 --- a/src/sections/xcm/XcmPage.tsx +++ b/src/sections/xcm/XcmPage.tsx @@ -24,6 +24,7 @@ import { genesisHashToChain } from "utils/helpers" import { Asset } from "@galacticcouncil/sdk" import { useRpcProvider } from "providers/rpcProvider" import { ExternalAssetUpdateModal } from "sections/trade/modal/ExternalAssetUpdateModal" +import { tags } from "@galacticcouncil/xcm-cfg" type WalletChangeDetail = { srcChain: string @@ -75,7 +76,7 @@ export function XcmPage() { const rpcUrlList = useActiveRpcUrlList() const handleSubmit = async (e: CustomEvent) => { - const isSnowbridge = e.detail?.meta?.tags === "Snowbridge" + const isSnowbridge = e.detail?.meta?.tags === tags.Tag.Snowbridge const isApprove = e.detail.transaction.hex.startsWith("0x095ea7b3") await createTransaction( From d3fc3b01345e0497440f973f5fa94bcb5bd1e623 Mon Sep 17 00:00:00 2001 From: vkulinich Date: Fri, 6 Dec 2024 11:30:43 +0100 Subject: [PATCH 3/9] wip --- src/sections/transaction/ReviewTransaction.tsx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/sections/transaction/ReviewTransaction.tsx b/src/sections/transaction/ReviewTransaction.tsx index 222cde2dd..206cbb86f 100644 --- a/src/sections/transaction/ReviewTransaction.tsx +++ b/src/sections/transaction/ReviewTransaction.tsx @@ -14,6 +14,7 @@ import { ReviewTransactionEvmTxForm } from "sections/transaction/ReviewTransacti import { WalletUpgradeModal } from "sections/web3-connect/upgrade/WalletUpgradeModal" import { isEvmXCall } from "sections/transaction/ReviewTransactionXCallForm.utils" import { useRpcProvider } from "providers/rpcProvider" +import { tags } from "@galacticcouncil/xcm-cfg" export const ReviewTransaction = (props: Transaction) => { const { isLoaded } = useRpcProvider() @@ -89,7 +90,7 @@ export const ReviewTransaction = (props: Transaction) => { reset() setMinimizeModal(true) } - + console.log(props.xcallMeta?.tags === tags.Tag.Snowbridge) return ( <> {minimizeModal && ( From 4e3844e45569c1f3eb4062bbdb1c517a621a3bc1 Mon Sep 17 00:00:00 2001 From: vkulinich Date: Fri, 6 Dec 2024 11:33:53 +0100 Subject: [PATCH 4/9] wip --- .../transaction/ReviewTransaction.utils.tsx | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/src/sections/transaction/ReviewTransaction.utils.tsx b/src/sections/transaction/ReviewTransaction.utils.tsx index 266c0c9ac..9f650f26b 100644 --- a/src/sections/transaction/ReviewTransaction.utils.tsx +++ b/src/sections/transaction/ReviewTransaction.utils.tsx @@ -188,7 +188,6 @@ export const useSendEvmTransactionMutation = ( const [xcallMeta, setCallMeta] = useState | undefined>( undefined, ) - const [isSnowbridge, setIsSnowbridge] = useState(false) const { account } = useEvmAccount() const isTestnet = useIsTestnet() @@ -196,12 +195,6 @@ export const useSendEvmTransactionMutation = ( const sendTx = useMutation(async ({ evmTx, xcallMeta }) => { return await new Promise(async (resolve, reject) => { try { - const isSnowBridge = xcallMeta?.tags === tags.Tag.Snowbridge - - if (isSnowBridge) { - setIsSnowbridge(true) - } - setTxState("Broadcast") setTxHash(evmTx?.hash ?? "") setTxData(evmTx?.data) @@ -216,10 +209,11 @@ export const useSendEvmTransactionMutation = ( }) }, options) + const isSnowBridge = xcallMeta?.tags === tags.Tag.Snowbridge const chain = account?.chainId ? getEvmChainById(account.chainId) : null const txLink = txHash && chain - ? getEvmTxLink(txHash, txData, chain.key, isTestnet, isSnowbridge) + ? getEvmTxLink(txHash, txData, chain.key, isTestnet, isSnowBridge) : "" const isApproveTx = txData?.startsWith("0x095ea7b3") @@ -231,18 +225,18 @@ export const useSendEvmTransactionMutation = ( const bridge = chain?.isEvmChain() || destChain?.isEvmChain() ? chain?.key : undefined + console.log(isSnowBridge, "isSnowBridge in mutation") return { ...sendTx, txState, txLink, txHash, - bridge: isApproveTx || isSnowbridge ? undefined : bridge, + bridge: isApproveTx || isSnowBridge ? undefined : bridge, reset: () => { setTxState(null) setTxHash("") setCallMeta(undefined) sendTx.reset() - setIsSnowbridge(false) }, } } From 085638442393648ce9f2b4891511a6d897b2465e Mon Sep 17 00:00:00 2001 From: vkulinich Date: Fri, 6 Dec 2024 11:47:45 +0100 Subject: [PATCH 5/9] wip --- .../transaction/ReviewTransaction.tsx | 2 +- .../transaction/ReviewTransaction.utils.tsx | 36 ++++++++++--------- src/utils/evm.ts | 2 +- 3 files changed, 22 insertions(+), 18 deletions(-) diff --git a/src/sections/transaction/ReviewTransaction.tsx b/src/sections/transaction/ReviewTransaction.tsx index 206cbb86f..0417cb84e 100644 --- a/src/sections/transaction/ReviewTransaction.tsx +++ b/src/sections/transaction/ReviewTransaction.tsx @@ -36,7 +36,7 @@ export const ReviewTransaction = (props: Transaction) => { txLink, txHash, bridge, - } = useSendTx() + } = useSendTx(props.xcallMeta) if (!isLoaded) return null diff --git a/src/sections/transaction/ReviewTransaction.utils.tsx b/src/sections/transaction/ReviewTransaction.utils.tsx index 9f650f26b..daf3c081a 100644 --- a/src/sections/transaction/ReviewTransaction.utils.tsx +++ b/src/sections/transaction/ReviewTransaction.utils.tsx @@ -181,13 +181,14 @@ export const useSendEvmTransactionMutation = ( xcallMeta?: Record } > = {}, + xcallMeta, ) => { const [txState, setTxState] = useState(null) const [txHash, setTxHash] = useState("") const [txData, setTxData] = useState() - const [xcallMeta, setCallMeta] = useState | undefined>( - undefined, - ) + // const [xcallMeta, setCallMeta] = useState | undefined>( + // undefined, + // ) const { account } = useEvmAccount() const isTestnet = useIsTestnet() @@ -198,7 +199,7 @@ export const useSendEvmTransactionMutation = ( setTxState("Broadcast") setTxHash(evmTx?.hash ?? "") setTxData(evmTx?.data) - setCallMeta(xcallMeta) + // setCallMeta(xcallMeta) const receipt = await evmTx.wait() setTxState("InBlock") @@ -225,7 +226,7 @@ export const useSendEvmTransactionMutation = ( const bridge = chain?.isEvmChain() || destChain?.isEvmChain() ? chain?.key : undefined - console.log(isSnowBridge, "isSnowBridge in mutation") + console.log(isSnowBridge, xcallMeta, "isSnowBridge in mutation") return { ...sendTx, txState, @@ -235,7 +236,7 @@ export const useSendEvmTransactionMutation = ( reset: () => { setTxState(null) setTxHash("") - setCallMeta(undefined) + //setCallMeta(undefined) sendTx.reset() }, } @@ -643,7 +644,7 @@ const useStoreExternalAssetsOnSign = () => { ) } -export const useSendTx = () => { +export const useSendTx = (xcallMeta) => { const [txType, setTxType] = useState<"default" | "evm" | "permit" | null>( null, ) @@ -660,16 +661,19 @@ export const useSendTx = () => { onSuccess: boundReferralToast.onSuccess, }) - const sendEvmTx = useSendEvmTransactionMutation({ - onMutate: ({ tx }) => { - if (tx) { - boundReferralToast.onLoading(tx) - storeExternalAssetsOnSign(getAssetIdsFromTx(tx)) - } - setTxType("evm") + const sendEvmTx = useSendEvmTransactionMutation( + { + onMutate: ({ tx }) => { + if (tx) { + boundReferralToast.onLoading(tx) + storeExternalAssetsOnSign(getAssetIdsFromTx(tx)) + } + setTxType("evm") + }, + onSuccess: boundReferralToast.onSuccess, }, - onSuccess: boundReferralToast.onSuccess, - }) + xcallMeta, + ) const sendPermitTx = useSendDispatchPermit({ onMutate: () => { diff --git a/src/utils/evm.ts b/src/utils/evm.ts index 7ffc49aa6..a74cc6380 100644 --- a/src/utils/evm.ts +++ b/src/utils/evm.ts @@ -78,7 +78,7 @@ export function getEvmTxLink( txData: string | undefined, chainKey = "hydration", isTestnet = false, - isSnowbridge = false, + isSnowbridge: boolean, ) { const chain = chainsMap.get(chainKey) From ecc10a18e97afaee3ffaf5caad3d295cf3df7e7c Mon Sep 17 00:00:00 2001 From: vkulinich Date: Fri, 6 Dec 2024 12:02:25 +0100 Subject: [PATCH 6/9] wip --- .../transaction/ReviewTransaction.tsx | 4 +- .../transaction/ReviewTransaction.utils.tsx | 81 +++++++------------ .../transaction/ReviewTransactionForm.tsx | 19 +---- 3 files changed, 37 insertions(+), 67 deletions(-) diff --git a/src/sections/transaction/ReviewTransaction.tsx b/src/sections/transaction/ReviewTransaction.tsx index 0417cb84e..2c2e05e7d 100644 --- a/src/sections/transaction/ReviewTransaction.tsx +++ b/src/sections/transaction/ReviewTransaction.tsx @@ -146,9 +146,9 @@ export const ReviewTransaction = (props: Transaction) => { props.onSubmitted?.() sendEvmTx(data) }} - onSigned={(tx, xcallMeta) => { + onSigned={(tx) => { props.onSubmitted?.() - sendTx({ tx, xcallMeta }) + sendTx({ tx }) }} onPermitDispatched={(permit) => { props.onSubmitted?.() diff --git a/src/sections/transaction/ReviewTransaction.utils.tsx b/src/sections/transaction/ReviewTransaction.utils.tsx index daf3c081a..898e951d6 100644 --- a/src/sections/transaction/ReviewTransaction.utils.tsx +++ b/src/sections/transaction/ReviewTransaction.utils.tsx @@ -178,22 +178,18 @@ export const useSendEvmTransactionMutation = ( { evmTx: TransactionResponse tx?: SubmittableExtrinsic<"promise"> - xcallMeta?: Record } > = {}, - xcallMeta, + xcallMeta?: Record, ) => { const [txState, setTxState] = useState(null) const [txHash, setTxHash] = useState("") const [txData, setTxData] = useState() - // const [xcallMeta, setCallMeta] = useState | undefined>( - // undefined, - // ) const { account } = useEvmAccount() const isTestnet = useIsTestnet() - const sendTx = useMutation(async ({ evmTx, xcallMeta }) => { + const sendTx = useMutation(async ({ evmTx }) => { return await new Promise(async (resolve, reject) => { try { setTxState("Broadcast") @@ -236,7 +232,6 @@ export const useSendEvmTransactionMutation = ( reset: () => { setTxState(null) setTxHash("") - //setCallMeta(undefined) sendTx.reset() }, } @@ -307,22 +302,19 @@ export const useSendDispatchPermit = ( unknown, { permit: PermitResult - xcallMeta?: Record } > = {}, + xcallMeta?: Record, ) => { const { api } = useRpcProvider() const { wallet } = useWallet() const queryClient = useQueryClient() const [txState, setTxState] = useState(null) const [txHash, setTxHash] = useState("") - const [xcallMeta, setCallMeta] = useState | undefined>( - undefined, - ) - const [isSnowbridge, setIsSnowbridge] = useState(false) + const isMounted = useMountedState() - const sendTx = useMutation(async ({ permit, xcallMeta }) => { + const sendTx = useMutation(async ({ permit }) => { return await new Promise(async (resolve, reject) => { try { const extrinsic = api.tx.multiTransactionPayment.dispatchPermit( @@ -342,15 +334,8 @@ export const useSendDispatchPermit = ( const isInBlock = result.status.type === "InBlock" if (isMounted()) { - const isSnowBridge = xcallMeta?.tags === tags.Tag.Snowbridge - - if (isSnowBridge) { - setIsSnowbridge(true) - } - setTxHash(result.txHash.toHex()) setTxState(result.status.type) - setCallMeta(xcallMeta) } const account = new H160(permit.message.from).toAccount() @@ -405,6 +390,8 @@ export const useSendDispatchPermit = ( }) }, options) + const isSnowBridge = xcallMeta?.tags === tags.Tag.Snowbridge + const destChain = xcallMeta?.dstChain ? chainsMap.get(xcallMeta.dstChain) : undefined @@ -417,7 +404,7 @@ export const useSendDispatchPermit = ( : undefined const bridge = - destChain?.isEvmChain() && !isSnowbridge ? "substrate" : undefined + destChain?.isEvmChain() && !isSnowBridge ? "substrate" : undefined return { ...sendTx, @@ -429,7 +416,6 @@ export const useSendDispatchPermit = ( setTxState(null) setTxHash("") sendTx.reset() - setIsSnowbridge(false) }, } } @@ -440,35 +426,24 @@ export const useSendTransactionMutation = ( unknown, { tx: SubmittableExtrinsic<"promise"> - xcallMeta?: Record } > = {}, + xcallMeta?: Record, ) => { const { api } = useRpcProvider() const isMounted = useMountedState() const [txState, setTxState] = useState(null) const [txHash, setTxHash] = useState("") - const [xcallMeta, setCallMeta] = useState | undefined>( - undefined, - ) - const [isSnowbridge, setIsSnowbridge] = useState(false) - const sendTx = useMutation(async ({ tx, xcallMeta }) => { + const sendTx = useMutation(async ({ tx }) => { return await new Promise(async (resolve, reject) => { try { const unsubscribe = await tx.send(async (result) => { if (!result || !result.status) return if (isMounted()) { - const isSnowBridge = xcallMeta?.tags === tags.Tag.Snowbridge - - if (isSnowBridge) { - setIsSnowbridge(true) - } - setTxHash(result.txHash.toHex()) setTxState(result.status.type) - setCallMeta(xcallMeta) } const externalChain = @@ -499,6 +474,8 @@ export const useSendTransactionMutation = ( }) }, options) + const isSnowBridge = xcallMeta?.tags === tags.Tag.Snowbridge + const destChain = xcallMeta?.dstChain ? chainsMap.get(xcallMeta.dstChain) : undefined @@ -511,7 +488,7 @@ export const useSendTransactionMutation = ( : undefined const bridge = - destChain?.isEvmChain() && !isSnowbridge ? "substrate" : undefined + destChain?.isEvmChain() && !isSnowBridge ? "substrate" : undefined return { ...sendTx, @@ -522,9 +499,7 @@ export const useSendTransactionMutation = ( reset: () => { setTxState(null) setTxHash("") - setCallMeta(undefined) sendTx.reset() - setIsSnowbridge(false) }, } } @@ -644,7 +619,7 @@ const useStoreExternalAssetsOnSign = () => { ) } -export const useSendTx = (xcallMeta) => { +export const useSendTx = (xcallMeta?: Record) => { const [txType, setTxType] = useState<"default" | "evm" | "permit" | null>( null, ) @@ -652,14 +627,17 @@ export const useSendTx = (xcallMeta) => { const boundReferralToast = useBoundReferralToast() const storeExternalAssetsOnSign = useStoreExternalAssetsOnSign() - const sendTx = useSendTransactionMutation({ - onMutate: ({ tx }) => { - boundReferralToast.onLoading(tx) - storeExternalAssetsOnSign(getAssetIdsFromTx(tx)) - setTxType("default") + const sendTx = useSendTransactionMutation( + { + onMutate: ({ tx }) => { + boundReferralToast.onLoading(tx) + storeExternalAssetsOnSign(getAssetIdsFromTx(tx)) + setTxType("default") + }, + onSuccess: boundReferralToast.onSuccess, }, - onSuccess: boundReferralToast.onSuccess, - }) + xcallMeta, + ) const sendEvmTx = useSendEvmTransactionMutation( { @@ -675,11 +653,14 @@ export const useSendTx = (xcallMeta) => { xcallMeta, ) - const sendPermitTx = useSendDispatchPermit({ - onMutate: () => { - setTxType("permit") + const sendPermitTx = useSendDispatchPermit( + { + onMutate: () => { + setTxType("permit") + }, }, - }) + xcallMeta, + ) const activeMutation = txType === "default" ? sendTx : txType === "evm" ? sendEvmTx : sendPermitTx diff --git a/src/sections/transaction/ReviewTransactionForm.tsx b/src/sections/transaction/ReviewTransactionForm.tsx index 787b68b47..d718b1e38 100644 --- a/src/sections/transaction/ReviewTransactionForm.tsx +++ b/src/sections/transaction/ReviewTransactionForm.tsx @@ -47,22 +47,12 @@ type TxProps = Omit & { type Props = TxProps & { onCancel: () => void - onPermitDispatched: ({ - permit, - xcallMeta, - }: { - permit: PermitResult - xcallMeta?: Record - }) => void + onPermitDispatched: ({ permit }: { permit: PermitResult }) => void onEvmSigned: (data: { evmTx: TransactionResponse tx: SubmittableExtrinsic<"promise"> - xcallMeta?: Record }) => void - onSigned: ( - signed: SubmittableExtrinsic<"promise">, - xcallMeta?: Record, - ) => void + onSigned: (signed: SubmittableExtrinsic<"promise">) => void onSignError?: (error: unknown) => void } @@ -141,7 +131,6 @@ export const ReviewTransactionForm: FC = (props) => { const permit = await wallet.signer.getPermit(txData, nonce) return props.onPermitDispatched({ permit, - xcallMeta: props.xcallMeta, }) } @@ -149,7 +138,7 @@ export const ReviewTransactionForm: FC = (props) => { txData, props.xcallMeta?.srcChain, ) - return props.onEvmSigned({ evmTx, tx, xcallMeta: props.xcallMeta }) + return props.onEvmSigned({ evmTx, tx }) } const srcChain = props?.xcallMeta?.srcChain @@ -171,7 +160,7 @@ export const ReviewTransactionForm: FC = (props) => { withSignedTransaction: true, }) - return props.onSigned(signature, props.xcallMeta) + return props.onSigned(signature) } catch (error) { props.onSignError?.(error) } From ec3ee63d492a01296d978d4454c09df46c329e31 Mon Sep 17 00:00:00 2001 From: vkulinich Date: Fri, 6 Dec 2024 12:16:15 +0100 Subject: [PATCH 7/9] remove logs --- src/sections/transaction/ReviewTransaction.tsx | 3 +-- src/sections/transaction/ReviewTransaction.utils.tsx | 1 - 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/src/sections/transaction/ReviewTransaction.tsx b/src/sections/transaction/ReviewTransaction.tsx index 2c2e05e7d..3607e0af7 100644 --- a/src/sections/transaction/ReviewTransaction.tsx +++ b/src/sections/transaction/ReviewTransaction.tsx @@ -14,7 +14,6 @@ import { ReviewTransactionEvmTxForm } from "sections/transaction/ReviewTransacti import { WalletUpgradeModal } from "sections/web3-connect/upgrade/WalletUpgradeModal" import { isEvmXCall } from "sections/transaction/ReviewTransactionXCallForm.utils" import { useRpcProvider } from "providers/rpcProvider" -import { tags } from "@galacticcouncil/xcm-cfg" export const ReviewTransaction = (props: Transaction) => { const { isLoaded } = useRpcProvider() @@ -90,7 +89,7 @@ export const ReviewTransaction = (props: Transaction) => { reset() setMinimizeModal(true) } - console.log(props.xcallMeta?.tags === tags.Tag.Snowbridge) + return ( <> {minimizeModal && ( diff --git a/src/sections/transaction/ReviewTransaction.utils.tsx b/src/sections/transaction/ReviewTransaction.utils.tsx index 898e951d6..21df95fc5 100644 --- a/src/sections/transaction/ReviewTransaction.utils.tsx +++ b/src/sections/transaction/ReviewTransaction.utils.tsx @@ -222,7 +222,6 @@ export const useSendEvmTransactionMutation = ( const bridge = chain?.isEvmChain() || destChain?.isEvmChain() ? chain?.key : undefined - console.log(isSnowBridge, xcallMeta, "isSnowBridge in mutation") return { ...sendTx, txState, From fc898bc6f562f7b7293f0990ff2a0ab310c74c57 Mon Sep 17 00:00:00 2001 From: vkulinich Date: Fri, 6 Dec 2024 14:02:35 +0100 Subject: [PATCH 8/9] revert notification textation --- src/sections/xcm/XcmPage.tsx | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/src/sections/xcm/XcmPage.tsx b/src/sections/xcm/XcmPage.tsx index 477e94e05..83e2506cb 100644 --- a/src/sections/xcm/XcmPage.tsx +++ b/src/sections/xcm/XcmPage.tsx @@ -24,7 +24,6 @@ import { genesisHashToChain } from "utils/helpers" import { Asset } from "@galacticcouncil/sdk" import { useRpcProvider } from "providers/rpcProvider" import { ExternalAssetUpdateModal } from "sections/trade/modal/ExternalAssetUpdateModal" -import { tags } from "@galacticcouncil/xcm-cfg" type WalletChangeDetail = { srcChain: string @@ -76,9 +75,6 @@ export function XcmPage() { const rpcUrlList = useActiveRpcUrlList() const handleSubmit = async (e: CustomEvent) => { - const isSnowbridge = e.detail?.meta?.tags === tags.Tag.Snowbridge - const isApprove = e.detail.transaction.hex.startsWith("0x095ea7b3") - await createTransaction( { tx: await getSubmittableExtrinsic(e.detail), @@ -87,10 +83,7 @@ export function XcmPage() { { onSuccess: () => {}, onSubmitted: () => {}, - toast: - !isSnowbridge || isApprove - ? getNotificationToastTemplates(e.detail) - : undefined, + toast: getNotificationToastTemplates(e.detail), }, ) } From 73148b8c4c384a7fe6ea4b1ba007418ed064c219 Mon Sep 17 00:00:00 2001 From: vkulinich Date: Fri, 6 Dec 2024 14:05:09 +0100 Subject: [PATCH 9/9] minor thing --- src/sections/transaction/ReviewTransaction.utils.tsx | 1 - 1 file changed, 1 deletion(-) diff --git a/src/sections/transaction/ReviewTransaction.utils.tsx b/src/sections/transaction/ReviewTransaction.utils.tsx index 21df95fc5..7a3dcc91d 100644 --- a/src/sections/transaction/ReviewTransaction.utils.tsx +++ b/src/sections/transaction/ReviewTransaction.utils.tsx @@ -195,7 +195,6 @@ export const useSendEvmTransactionMutation = ( setTxState("Broadcast") setTxHash(evmTx?.hash ?? "") setTxData(evmTx?.data) - // setCallMeta(xcallMeta) const receipt = await evmTx.wait() setTxState("InBlock")