@@ -14,7 +14,7 @@ import {
1414 useWeb3AuthUser ,
1515
1616} from " @web3auth/modal/vue" ;
17- import { CONNECTOR_INITIAL_AUTHENTICATION_MODE , type CustomChainConfig } from " @web3auth/no-modal" ;
17+ import { CONNECTOR_INITIAL_AUTHENTICATION_MODE } from " @web3auth/no-modal" ;
1818import { useI18n } from " petite-vue-i18n" ;
1919
2020import { useSignMessage as useSolanaSignMessage , useSolanaWallet , useSolanaClient } from " @web3auth/modal/vue/solana" ;
@@ -30,7 +30,7 @@ import {
3030import { getCapabilities , getCallsStatus , sendCalls , showCallsStatus } from " @wagmi/core" ;
3131import { parseEther } from " viem" ;
3232import { createWalletTransactionSigner , toAddress } from " @solana/client" ;
33- import { address as solanaAddress , } from " @solana/kit" ;
33+ import { address as solanaAddress } from " @solana/kit" ;
3434import { getTransferSolInstruction } from " @solana-program/system" ;
3535import { computed , ref , watch } from " vue" ;
3636import { getPrivateKey , sendEth , sendEthWithSmartAccount , signTransaction as signEthTransaction } from " ../services/ethHandlers" ;
@@ -40,10 +40,6 @@ const { t } = useI18n({ useScope: "global" });
4040
4141const formData = formDataStore ;
4242
43- const props = defineProps <{
44- chains: CustomChainConfig [];
45- }>();
46-
4743const { isConnected, connection, web3Auth, isMFAEnabled, isAuthorized } = useWeb3Auth ();
4844const { userInfo, loading : userInfoLoading } = useWeb3AuthUser ();
4945const { enableMFA } = useEnableMFA ();
@@ -68,7 +64,7 @@ const balance = useBalance({
6864const config = useConfig ();
6965const trackedCallsId = ref <string | undefined >();
7066
71- const { accounts : solanaAccounts, getPrivateKey : getSolanaPrivateKey } = useSolanaWallet ();
67+ const { accounts : solanaAccounts, getPrivateKey : getSolanaPrivateKey, solanaWallet } = useSolanaWallet ();
7268const solanaClient = useSolanaClient ();
7369const { signMessage : signSolanaMessage } = useSolanaSignMessage ();
7470
@@ -350,7 +346,7 @@ const onSignSolMessage = async () => {
350346const onGetSolBalance = async () => {
351347 const client = solanaClient .value ;
352348 if (! client ) throw new Error (" Solana client not available" );
353- const account = solanaAccounts .value ?.[0 ];
349+ const account = solanaWallet .value ?.accounts [0 ]?. address ;
354350 if (! account ) throw new Error (" No account connected" );
355351
356352 try {
@@ -362,6 +358,20 @@ const onGetSolBalance = async () => {
362358 }
363359};
364360
361+ const onGetSolChain = async () => {
362+ const w3a = web3Auth .value ;
363+ if (! w3a ) {
364+ printToConsole (" Solana chain" , " Web3Auth not initialized" );
365+ return ;
366+ }
367+ const current = w3a .currentChain ;
368+ const chain =
369+ current ?.chainNamespace === CHAIN_NAMESPACES .SOLANA
370+ ? current
371+ : w3a .coreOptions .chains ?.find ((c ) => c .chainNamespace === CHAIN_NAMESPACES .SOLANA );
372+ printToConsole (" Solana chain" , chain ?? null );
373+ };
374+
365375const onGetSolPrivateKey = async () => {
366376 try {
367377 const privateKey = await getSolanaPrivateKey ();
@@ -372,7 +382,7 @@ const onGetSolPrivateKey = async () => {
372382};
373383
374384// EVM-only: wagmi switchChain does not change Solana cluster; only show when multiple EIP-155 chains are configured.
375- const eip155Chains = computed (() => props . chains .filter ((c ) => c .chainNamespace === CHAIN_NAMESPACES .EIP155 ));
385+ const eip155Chains = computed (() => web3Auth . value ?. coreOptions . chains ? .filter ((c ) => c .chainNamespace === CHAIN_NAMESPACES .EIP155 ) || [] );
376386
377387const canSwitchEvmChain = computed (() => {
378388 if (eip155Chains .value .length < 2 ) return false ;
@@ -515,6 +525,7 @@ const onSwitchChain = async () => {
515525 <div class =" mb-2 text-xl font-bold leading-tight text-left" >Solana Transaction</div >
516526 <Button block size =" xs" pill class =" mb-2" @click =" onGetSolPrivateKey" >{{ t("app.buttons.btnGetPrivateKey") }}</Button >
517527 <Button block size =" xs" pill class =" mb-2" @click =" onGetSolBalance" >{{ t("app.buttons.btnGetBalance") }}</Button >
528+ <Button block size =" xs" pill class =" mb-2" @click =" onGetSolChain" >{{ t("app.buttons.btnGetCurrentSolanaChain") }}</Button >
518529 <Button block size =" xs" pill class =" mb-2" @click =" onSignSolMessage" >{{ t("app.buttons.btnSignMessage") }}</Button >
519530 <Button block size =" xs" pill class =" mb-2" @click =" onSignAndSendTransaction" >
520531 {{ t("app.buttons.btnSignAndSendTransaction") }}
0 commit comments