-
Notifications
You must be signed in to change notification settings - Fork 80
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: added support for PrivateKeyAccount as signer in account config #458
Conversation
@@ -51,7 +50,17 @@ export const convertSigner = async (signer: SupportedSigner, skipChainIdCalls: b | |||
} | |||
// convert viems walletClient to alchemy's SmartAccountSigner under the hood | |||
resolvedSmartAccountSigner = new WalletClientSigner(walletClient, "viem"); | |||
rpcUrl = walletClient?.transport?.url ?? null; | |||
rpcUrl = walletClient?.transport?.url ?? undefined; | |||
} else if (signer as PrivateKeyAccount) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this should be instanceof
instead of as
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're casting every other signer to a PrivateKeyAccount here, - not just accounts.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
instanceof works with classes, it does not work with types
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're casting every other signer to a PrivateKeyAccount here, - not just accounts.
Not sure what do you mean as this is the last "else if", it will cast it only if signer is indeed of PrivateKeyAccount type, otherwise it will break and throw an error.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was changed, please review
@@ -55,7 +55,7 @@ export const compareChainIds = async ( | |||
biconomySmartAccountConfig: BiconomySmartAccountV2Config, | |||
skipChainIdCalls: boolean, | |||
): Promise<Error | void> => { | |||
const signerResult = await convertSigner(signer, skipChainIdCalls); | |||
const signerResult = await convertSigner(signer, skipChainIdCalls, biconomySmartAccountConfig.rpcUrl); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why is this added?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If a user passes a PrivateKeyAccount there is no info about transport so he needs to at least pass rpcUrl in the config so we can properly construct the walletClient with the correct transport
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was also changed to a better approach
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
review i
resolve conflicts |
LGTM. We can close this as I have added it here: bb9ba8e |
Summary
Added PrivateKeyAccount support as direct signer in account config.
Change Type
Checklist