Skip to content

LiFi EIP-4337 #48

@Dargon789

Description

@Dargon789

Reviewer's Guide

This PR adds AnyPay (LiFi) support and broad EIP-4337 enhancements by extending API clients, wallet modules, relayers/bundlers, session managers, and utility libraries. Key work includes new intent payload types, additional Sequence-API endpoints for LiFi chains/tokens and intent configs, upgraded codegen versions, expanded transaction and relayer flows (including Pimlico and RPC bundlers), session manager chainId handling, unsafe mode options in wallet configs, and a new PermissionBuilder and Precondition framework.

ER diagram for new intent and LiFi-related data types

erDiagram
  IntentConfig ||--o{ IntentCallsPayload : has
  IntentConfig ||--o{ IntentPrecondition : has
  IntentConfig ||--o{ AnypayLifiInfo : has
  IntentCallsPayload }o--|| Call : contains
  GetIntentCallsPayloadsReturn ||--o{ IntentCallsPayload : has
  GetIntentCallsPayloadsReturn ||--o{ IntentPrecondition : has
  GetIntentCallsPayloadsReturn ||--o{ MetaTxn : has
  GetIntentCallsPayloadsReturn ||--o{ AnypayLifiInfo : has
  CommitIntentConfigReturn ||--|| IntentConfig : returns
  GetIntentConfigReturn ||--|| IntentConfig : returns
Loading

Class diagram for new and updated transaction and relayer types (EIP-4337, AnyPay, LiFi)

classDiagram
  class Transactions {
    +initialize()
    +refreshStatus(onlyTxId?)
    +list()
    +request(from, chainId, txs, options?)
    +define(transactionId)
    +selectRelayerOption(transactionId, relayerOptionId)
    +sign(transactionId)
    +relay(transactionId)
  }
  class Relayer {
    <<interface>>
    +kind: string
    +type: string
    +id: string
    +isAvailable(wallet, chainId)
    +feeOptions(wallet, chainId, calls)
    +relay(to, data, chainId, quote?)
    +status(opHash, chainId)
    +checkPrecondition(precondition)
  }
  class StandardRelayerOption {
    +kind: 'standard'
    +id: string
    +relayerType: string
    +relayerId: string
    +feeOption?: FeeOption
    +quote?: FeeQuote
    +name?: string
    +icon?: string
  }
  class ERC4337RelayerOption {
    +kind: 'erc4337'
    +id: string
    +relayerType: string
    +relayerId: string
    +alternativePayload: Calls4337_07
    +speed?: 'slow'|'standard'|'fast'
  }
  class TransactionRequested
  class TransactionDefined
  class TransactionFormed
  class TransactionRelayed {
    +relayedAt: number
    +relayerId: string
    +opStatus?: OperationStatus
  }
  class TransactionFinal {
    +relayedAt: number
    +relayerId: string
    +opStatus: OperationStatus
  }
  class Calls4337_07 {
    +type: 'call_4337_07'
    +calls: Call[]
    +entrypoint: Address
    +callGasLimit: bigint
    +maxFeePerGas: bigint
    +maxPriorityFeePerGas: bigint
    +space: bigint
    +nonce: bigint
    +paymaster?: Address
    +paymasterData?: Hex
    +factory?: Address
    +factoryData?: Hex
  }
  class IntentConfig {
    +id: number
    +configHash: string
    +walletAddress: string
    +mainSigner: string
    +calls: IntentCallsPayload[]
    +preconditions: IntentPrecondition[]
    +anypayLifiInfo: AnypayLifiInfo
    +updatedAt?: string
    +createdAt?: string
  }
  class IntentCallsPayload {
    +chainId: string
    +space?: string
    +nonce?: string
    +calls: Call[]
  }
  class IntentPrecondition {
    +type: string
    +chainId: string
    +data: any
  }
  class AnypayLifiInfo {
    +originToken: string
    +amount: string
    +originChainId: string
    +destinationChainId: string
  }
  class MetaTxn {
    +id: string
    +chainId: string
    +walletAddress: string
    +contract: string
    +input: string
  }
  Transactions --> Relayer
  Transactions --> StandardRelayerOption
  Transactions --> ERC4337RelayerOption
  Transactions --> TransactionRequested
  Transactions --> TransactionDefined
  Transactions --> TransactionFormed
  Transactions --> TransactionRelayed
  Transactions --> TransactionFinal
  ERC4337RelayerOption --> Calls4337_07
  IntentConfig --> IntentCallsPayload
  IntentConfig --> IntentPrecondition
  IntentConfig --> AnypayLifiInfo
  IntentCallsPayload --> Call
  IntentPrecondition --> AnypayLifiInfo
Loading

Class diagram for updated SessionPermissions and Permission types

classDiagram
  class SessionPermissions {
    +signer: Address
    +chainId: bigint
    +valueLimit: bigint
    +deadline: bigint
    +permissions: Permission[]
  }
  class Permission {
    +selector: string
    +rules: ParameterRule[]
  }
  class ParameterRule {
    +offset: number
    +mask: Bytes
    +cumulative: boolean
  }
  SessionPermissions --> Permission
  Permission --> ParameterRule
Loading

Class diagram for updated API endpoints (LiFi, Intents, SwapQuoteV2)

classDiagram
  class API {
    +getLifiChains()
    +getLifiTokens(args)
    +getIntentCallsPayloads(args)
    +commitIntentConfig(args)
    +getIntentConfig(args)
    +getSwapQuoteV2(args)
  }
  class GetLifiChainsReturn {
    +chains: number[]
  }
  class GetLifiTokensReturn {
    +tokens: Token[]
  }
  class GetIntentCallsPayloadsReturn {
    +calls: IntentCallsPayload[]
    +preconditions: IntentPrecondition[]
    +metaTxns: MetaTxn[]
    +lifiInfos: AnypayLifiInfo[]
  }
  class CommitIntentConfigReturn {
    +config: IntentConfig
  }
  class GetIntentConfigReturn {
    +config: IntentConfig
  }
  class SwapQuoteV2 {
    +currencyAddress: string
    +currencyBalance: string
    +price: string
    +maxPrice: string
    +to: string
    +transactionData: string
    +transactionValue: string
    +approveData: string
    +amount: string
    +amountMin: string
  }
  API --> GetLifiChainsReturn
  API --> GetLifiTokensReturn
  API --> GetIntentCallsPayloadsReturn
  API --> CommitIntentConfigReturn
  API --> GetIntentConfigReturn
  API --> SwapQuoteV2
Loading

Class diagram for updated Manager and Sequence types (relayers, bundlers, context)

classDiagram
  class Manager {
    +shared: Shared
    +request(from, chainId, txs, options?)
    +getNetworks()
    +getNetwork(chainId)
  }
  class Shared {
    +sequence: Sequence
  }
  class Sequence {
    +context: Context
    +context4337: Context
    +relayers: Relayer[]
    +bundlers: Bundler[]
  }
  class Relayer {
    <<interface>>
  }
  class Bundler {
    <<interface>>
  }
  Manager --> Shared
  Shared --> Sequence
  Sequence --> Relayer
  Sequence --> Bundler
  Sequence --> Context
  Sequence --> Context
Loading

Class diagram for updated MemoryStore deep copy logic

classDiagram
  class MemoryStore {
    +deepCopy(value)
    +loadConfig(imageHash)
    +saveConfig(imageHash, config)
    +loadCounterfactualWallet(wallet)
    +saveCounterfactualWallet(wallet, imageHash, context)
    +loadPayloadOfSubdigest(subdigest)
    +savePayloadOfSubdigest(subdigest, payload)
    +loadSubdigestsOfSigner(signer)
    +loadSignatureOfSubdigest(signer, subdigest)
    +saveSignatureOfSubdigest(signer, subdigest, signature)
    +loadSapientSignatureOfSubdigest(signer, subdigest, imageHash)
    +saveSapientSignatureOfSubdigest(signer, subdigest, imageHash, signature)
    +loadTree(rootHash)
    +saveTree(rootHash, tree)
  }
Loading

File-Level Changes

Change Details Files
Upgrade and extend API client with AnyPay/LiFi intent support
  • Bumped webrpc Gen versions (webrpc-gen v0.24→v0.25.3, client code and headers)
  • Added MetaTxn, AnypayLifiInfo, Call, IntentCallsPayload, IntentConfig types
  • Introduced new endpoints: getLifiChains, getLifiTokens, getIntentCallsPayloads, commitIntentConfig, getIntentConfig
  • Replaced intentQuery with structured intent calls flows
packages/services/api/src/api.gen.ts
Enhance Wallet modules for EIP-4337 and unsafe configuration
  • Supported multiple contexts (Dev2_4337) with ERC-4337 entrypoint in Context
  • Added prepare4337Transaction, build4337Transaction, get4337Nonce and get4337Entrypoint to Wallet
  • Introduced unsafe mode checks in fromConfiguration and prepareUpdate
  • Emitted counterFactual context in getStatus
  • Upgraded codegen and dependencies
packages/wallet/core/src/wallet.ts
Extend relayers and bundlers with RPC/Pimlico and precondition checks
  • Unified Relayer interface to include isAvailable and checkPrecondition
  • Added RpcRelayer (HTTP) and PimlicoBundler implementations
  • Enhanced LocalRelayer for IntentPrecondition polling
  • Introduced EIP-6963 discovery support
  • Mapped precondition types (native/ERC20/ERC721/ERC1155) in codec and runtime
  • Added PermissionBuilder for granular call rules
packages/wallet/core/src/relayer
packages/wallet/primitives/src/precondition.ts
packages/wallet/core/src/utils/session/permission-builder.ts
Expand SessionManager and session flows
  • Allow chainId filtering for explicit sessions and dynamic usage increments
  • Chain-aware sessionSigner.findSupportedPermission changes
  • Enhanced wdk Sessions handler to auto‐add missing session manager leaf
  • Updated tests and constants for Extensions.Dev1.sessions
packages/wallet/core/src/signers/session
packages/wallet/wdk/src/sequence/sessions.ts
Overhaul Transactions module in WDK
  • Added cron job to auto‐refresh transaction status
  • Extended transaction states with timestamp, relayerId, opStatus, final state
  • Merged legacy and ERC-4337 options in define stage
  • Interval‐based status polling on relay
packages/wallet/wdk/src/sequence/transactions.ts
Add precondition tests and types
  • Defined rich Precondition classes and IntentPrecondition codec/selectors
  • Test coverage for native/ERC20/ERC721/ERC1155 preconditions
  • Normalized precondition data handling
packages/wallet/core/src/preconditions
packages/wallet/core/test/preconditions.test.ts

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Originally posted by @sourcery-ai[bot] in #45 (comment)

Sub-issues

Metadata

Metadata

Assignees

Labels

dependenciesPull requests that update a dependency filedocumentationImprovements or additions to documentationduplicateThis issue or pull request already existsenhancementNew feature or requestgood first issueGood for newcomershelp wantedExtra attention is neededjavascriptPull requests that update javascript code

Projects

Status

Done

Status

Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions