RPC Error in providerToSmartAccountSigner for web3auth provider
saqlain1020 opened this issue · 4 comments
I am getting internal json rpc error when using providerToSmartAccountSigner
to convert web3auth provider to smart account signer.
It seems internally permissionless is trying to call eth_requestAccounts using the web3auth provider, but web3auth provider is transfering that call to the rpc which is set when configuring chain in web3auth.
It works if we provider signerAddress to providerToSmartAccountSigner
, or if we use Web3.js to convert web3auth provider to Web3Provider
then calling web3Provider.eth.getAccounts()
to fetch eoa address.
Package versions being used:-
"@web3auth/base": "^8.0.0",
"@web3auth/ethereum-provider": "^8.0.1",
"@web3auth/no-modal": "^8.0.1",
"@web3auth/openlogin-adapter": "^8.0.1",
"permissionless": "^0.1.18",
"viem": "^2.9.23",
"wagmi": "^2.5.20",
"web3": "^4.5.0"
Working Code:-
const web3authProvider = web3auth.provider;
const web3 = new Web3(web3authProvider);
const [_address] = await web3.eth.getAccounts();
const smartAccountSigner = await providerToSmartAccountSigner(web3authProvider, {
signerAddress: _address,
});
Not Working Code:-
const web3authProvider = web3auth.provider;
const smartAccountSigner = await providerToSmartAccountSigner(web3authProvider);
Error:-
"The method eth_requestAccounts does not exist/is not available"
Culprit Code inside permissionless:-
export const providerToSmartAccountSigner = async (
provider: EIP1193Provider,
params?: {
signerAddress: Hex
}
) => {
let account: Hex
if (!params) {
;[account] = await provider.request({ method: "eth_requestAccounts" })
} else {
account = params.signerAddress
}
const walletClient = createWalletClient({
account: account as Hex,
transport: custom(provider)
})
return walletClientToSmartAccountSigner(walletClient)
}
Hey since the parameters require parameter to be EIP1193Provider
, we accept the prover to have exposed eth_requestAccounts
rpc call. Though is eth_accounts
supported? We can add it as a fallback.
@plusminushalf eth_accounts is supported by web3auth provider, it can be added as a fallback.
Added a fix - #176
Merged - #177 You can use permissionless@0.1.19
. Thanks for pointing this out!