Skip to content
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

smartAccount.getContractVersion #461

Closed
wants to merge 2 commits into from
Closed

Conversation

joepegler
Copy link
Collaborator

@joepegler joepegler commented Apr 9, 2024

helper method for detecting the contract version

const version = await smartAccount.getContractVersion(); // 1 or 2

@joepegler joepegler marked this pull request as ready for review April 9, 2024 12:33
* const version = await smartAccount.getContractVersion();
*
*/
public async getContractVersion(): Promise<1 | 2> {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how can it be V1 if initialised through SmartAccountV2?

Copy link
Collaborator

@livingrockrises livingrockrises left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

review i

@joepegler
Copy link
Collaborator Author

joepegler commented Apr 9, 2024

const accounts = await Promise.all([
 BiconomySmartAccount.create(biconomySmartAccountConfigV1), // using sdk v3 tutorials
 BiconomySmartAccountV2.create(biconomySmartAccountConfigV2), // using latest tutorials. 
])

const counterFactualAddresses = await Promise.all(accounts.map(account => account.getCounterFactualAddress()));
const byteCodes = await Promise.all(counterFactualAddresses.map(address => publicClient.getBytecode({ address })))

const version = byteCodes.findIndex(Boolean) + 1; // 0, 1 or 2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants