Skip to content

Conversation

@Nesquiko
Copy link

What it solves

Ability to configure Safe contract addresses for a custom network.

How this PR fixes it

Propagate ContractNetworkingsConfig through Safe4337Pack.init.

Description

Hello, I want to deploy a Safe account with Passkey support to my custom network. I have deployed contracts from the safe-smart-account v1.4.1, safe-modules module 4337 v0.3.0-1 and also safe-modules module passkey v0.2.1-1 according to their custom deployment section in README respectively, but I don't see any way of specifying them when I use Safe4337Pack.init.

Call to Safe4337Pack.init, where passkey is object from extractPasskeyData:

    const safe4337Pack = await Safe4337Pack.init({
      provider: RPC_URL,
      signer: passkey,
      bundlerUrl: BUNDLER_URL,
      customContracts: {
        entryPointAddress: 'SOME-ADDRESS',
        safe4337ModuleAddress: 'SOME-ADDRESS',
        addModulesLibAddress: 'SOME-ADDRESS',
        safeWebAuthnSharedSignerAddress: 'SOME-ADDRESS'
      },
      options: {
        owners: [],
        threshold: 1
      }
    })

I got an error:

BaseContract.js:74 Uncaught (in promise) Error: Invalid safeWebAuthnSignerFactory contract address
    at new BaseContract (BaseContract.js:74:19)
    at new SafeWebAuthnSignerFactoryBaseContract (SafeWebAuthnSignerFactoryBaseContract.js:34:9)
    at new SafeWebAuthnSignerFactoryContract_v0_2_1 (SafeWebAuthnSignerFactoryContract_v0_2_1.js:29:9)
    at getSafeWebAuthnSignerFactoryContractInstance (contractInstances.js:201:63)
    at async getSafeWebAuthnSignerFactoryContract (safeDeploymentContracts.js:78:47)
    at async SafeProvider.init (SafeProvider.js:56:59)
    at async Safe4337Pack.init (Safe4337Pack.js:207:34)

I traced the error through your source code:

  1. In Safe4337Pack.init there is a call to SafeProvider.init with only provider, signer, safeVersion arguments,
  2. In SafeProvider.init a contract addresses are retrieved with chain id from provider from contractNetworks, but the contractNetworks are undefined, because only provider, signer, safeVersion arguments are passed,
  3. Undefined customContracts are passed to getSafeWebAuthnSignerFactoryContract,
  4. Undefined safeWebAuthnSignerFactoryAddress is passed to getSafeWebAuthnSignerFactoryContractInstance (same goes for safeWebAuthnSignerFactoryAbi),
  5. Undefined contractAddress is then used in SafeWebAuthnSignerFactoryContract_v0_2_1 constructor,
  6. Undefined customContractAddress is used in parent SafeWebAuthnSignerFactoryBaseContract constructor (same goes for customContractAbi),
  7. Undefined customContractAddress is passed to BaseContract constructor (same goes for customContractAbi),
  8. In BaseContract resolvedAddress is evaluated to undefined because customContractAddress is undefined and there are no deployments on my network,
  9. The above mentioned error is thrown.

Versions

  • @safe-global/protocol-kit: 5.2.0
  • @safe-global/relay-kit: 3.4.0

@github-actions
Copy link

github-actions bot commented Jan 21, 2025

CLA Assistant Lite bot All contributors have signed the CLA ✍️ ✅

@Nesquiko
Copy link
Author

I have read the CLA Document and I hereby sign the CLA

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.

1 participant