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

Fix/state issue #180

Merged

Conversation

talhamalik883
Copy link
Contributor

This PR has following changes

  1. Fallback code scrapping
  2. Removed getSmartAccountByOwner api call and getting wallet address from factory contract
  3. isDeployed state update in sendUserPaidTransaction function

@talhamalik883 talhamalik883 changed the base branch from master to fix/current-forward-flow-fixes-optimise June 1, 2023 16:19
Copy link
Contributor

@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.

reviewed

@@ -67,6 +67,7 @@ export type SmartAccountState = {
isDeployed: boolean // chain specific
entryPointAddress: string // chain specific?
implementationAddress: string
factoryAddress: string
Copy link
Contributor

Choose a reason for hiding this comment

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

why did we have to add this? does this impact anywhere else when this is being used, since it's not optional

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The initializeContracts function now requires SmartAccountState instead of ISmartAccount. It's necessary to include the factoryAddress field in SmartAccountState, previously required in ISmartAccount. This change doesn't cause any issues because the factoryAddress is only set in the getAddress function, which has the needed information.

@@ -46,6 +48,7 @@ import { JsonRpcProvider, Provider, Web3Provider } from '@ethersproject/provider
import { IRelayer, RestRelayer, FallbackRelayer, IFallbackRelayer } from '@biconomy/relayer'
import * as _ from 'lodash'
import TransactionManager, {
getSmartWalletFactoryContract,
Copy link
Contributor

Choose a reason for hiding this comment

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

getSmartWalletFactoryContract is directly exported from transactions package?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We've taken out a step that used to get account information (getSmartAccountByOwner API) and we now get an address directly from the factory contract instead. To do this, we need to create a factory instance within the getAddress function, which is why we need to bring this function over from the transaction package.

Copy link
Contributor

Choose a reason for hiding this comment

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

ok

// // }

// if (isFallbackEnabled) {
// return this.sendFallbackTransaction(transactionDto)
Copy link
Contributor

Choose a reason for hiding this comment

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

let's remove this whole method also
this.sendFallbackTransaction

Copy link
Contributor Author

Choose a reason for hiding this comment

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

resolved

@@ -8,5 +8,6 @@ export default TransactionManager
export * from './AccountUtils'
export * from './Execution'
export * from './MultiSend'
export * from './utils/FetchContractsInfo'
Copy link
Contributor

Choose a reason for hiding this comment

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

I see

@@ -483,7 +483,7 @@ class TransactionManager {
const connectedWallet = smartAccountState.address
walletContract = walletContract.attach(connectedWallet)

const isDeployed = smartAccountState.isDeployed
const isDeployed = await this.contractUtils.isDeployed(chainId, smartAccountState.address)
Copy link
Contributor

Choose a reason for hiding this comment

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

how is this reflected / needed?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Previously, the batching function decided whether to fetch the nonce from the proxy or just use 0 based on the value of smartAccountState.isDeployed. If a new transaction was sent before resetting the SDK, right after deploying the wallet, this could lead to an invalid nonce error.

@@ -52,7 +52,7 @@ class ContractUtils {
initializeContracts(
signer: Signer,
readProvider: ethers.providers.JsonRpcProvider,
walletInfo: ISmartAccount,
walletInfo: SmartAccountState,
Copy link
Contributor

Choose a reason for hiding this comment

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

what was the type earlier?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ISmartAccount same as returned by getSmartAccountByOwner. This function called initializeContracts is set up using data we get from getSmartAccountByOwner api consumption.

Copy link
Contributor

@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.

LGTM, let's merge and pass it on to QA

@livingrockrises livingrockrises merged commit c8e5139 into fix/current-forward-flow-fixes-optimise Jun 4, 2023
@talhamalik883 talhamalik883 deleted the fix/state_issue branch June 21, 2023 08:24
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