safe-global / safe-core-sdk

The Safe{Core} SDK allows builders to add account abstraction functionality into their apps.
https://docs.safe.global/sdk/overview
MIT License
242 stars 177 forks source link

[Passkeys] Detect Shared Signer Passkey as owner #862

Open DaniSomoza opened 2 weeks ago

DaniSomoza commented 2 weeks ago

Context / issue

When a Safe is deployed via 4337 using passkeys, the owner's address is set to the Shared Signer contract address instead of the passkey signer address.

We need to implement a fix in the protocol-kit to ensure it correctly identifies Shared Signer passkeys as the owners of the Safe.

Affected Flows:

Proposed solution

Extend the getPasskeyOwnerAddress function correctly identifies Shared Signer passkeys as the owners of the Safe:


  /**
   * Returns the owner address of the specific passkey.
   * If it is the Shared Signer of this Safe returns Shared signer passkey contract address
   *
   * @param {PasskeyArgType} passkey The passkey owner
   * @returns {Promise<string>} Returns the passkey owner address
   */
  async getPasskeyOwnerAddress(passkey: PasskeyArgType): Promise<string> {
    // TODO: implement the isSharedSignerPasskey(passkey) logic
    const isSharedSigner = isSharedSignerPasskey(passkey)

    if (isSharedSigner) {
      return SAFE_WEBAUTHN_SHARED_SIGNER_ADDRESS
    }

    const passkeySigner = await this.#getPasskeySigner(passkey)
    const passkeyOwnerAddress = await passkeySigner.getAddress()

    return passkeyOwnerAddress
  }