From 8d79ea109a3d9d6d6c7a1c9f3e49b4749439fa5d Mon Sep 17 00:00:00 2001 From: bluecco Date: Tue, 18 Jun 2024 10:29:16 +0200 Subject: [PATCH] chore: use chainId from connectorData --- src/components/Actions/SignMessage.tsx | 14 +++++++++++--- src/services/signMessage.ts | 5 +---- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/src/components/Actions/SignMessage.tsx b/src/components/Actions/SignMessage.tsx index 73049fb..7a8dcba 100644 --- a/src/components/Actions/SignMessage.tsx +++ b/src/components/Actions/SignMessage.tsx @@ -1,6 +1,9 @@ import { signMessage, signMessageRcpMethod } from "@/services/signMessage" import { walletStarknetkitLatestAtom } from "@/state/connectedWalletStarknetkitLatest" -import { walletStarknetkitNextAtom } from "@/state/connectedWalletStarknetkitNext" +import { + connectorDataAtom, + walletStarknetkitNextAtom, +} from "@/state/connectedWalletStarknetkitNext" import { lastTxStatusAtom } from "@/state/transactionState" import { Button, Flex, Heading, Input, Textarea } from "@chakra-ui/react" import { useAtomValue, useSetAtom } from "jotai" @@ -26,7 +29,7 @@ interface SignMessageProps { const SignMessage: FC = ({ account, wallet }) => { const [shortText, setShortText] = useState("") const [lastSig, setLastSig] = useState([]) - + const connectorData = useAtomValue(connectorDataAtom) const setTransactionStatus = useSetAtom(lastTxStatusAtom) const handleSignSubmit = async (skipDeploy?: boolean) => { @@ -42,7 +45,12 @@ const SignMessage: FC = ({ account, wallet }) => { await account.getChainId(), shortText, ) - : await signMessageRcpMethod(wallet, shortText, skipDeploy) + : await signMessageRcpMethod( + wallet, + connectorData?.chainId, + shortText, + skipDeploy, + ) setLastSig(stark.formatSignature(result)) setTransactionStatus("success") } catch (e) { diff --git a/src/services/signMessage.ts b/src/services/signMessage.ts index d2999c5..102c8f3 100644 --- a/src/services/signMessage.ts +++ b/src/services/signMessage.ts @@ -33,6 +33,7 @@ export const signMessage = async ( export const signMessageRcpMethod = async ( wallet: StarknetWindowObject | undefined | null, + chainId: constants.StarknetChainId | undefined, message: string, skipDeploy = false, ) => { @@ -44,10 +45,6 @@ export const signMessageRcpMethod = async ( throw Error("wallet not connected") } - const chainId = await wallet?.request({ - type: "wallet_requestChainId", - }) - return wallet.request({ type: "wallet_signTypedData", params: {