Skip to content

Support custom validator module #271

@KONFeature

Description

@KONFeature

Describe the feature you would like

Right now, we can add custom validators module during the creation of a new account. But we cannot:

  • Use custom validators as account owner
  • Sign UserOperations or messages with the custom validators
  • Compose custom validators with built-in ones (i.e. with multi-factor)

It would be nice to support that, attaching some custom validators to a rhinestoneAccount, being able to set it as owner / custom validator, and be able to use it when signing userOp / message.

I'm thinking of something like that:

const rhinestoneAccount = await rhinestone.createAccount({
  // Define custom validator providers
  validatorProviders: {
    zkSocial: {
      getModule: (_account: Address) => ({
        type: "validator",
        address: zeroAddress,
        initData: "0x",
        deInitData: "0x",
        additionalContext: "0x",
      }),
      getMocksignature: () => "0x",
      sign: async (_params: { hash: Hex, chain: Chain, account: Address }) => "0x",
      supportsEip712: () => true,
    }
  },
  // Use the custom validator as owner
  owners: {
    type: "zkSocial",
  },
});

This would also permit to use the MultiFactor validator with custom validators:

const rhinestoneAccount = await rhinestone.createAccount({
  validatorProviders: { /* ... */ },
  owners: {
    type: "multi-factor",
    validators: [
      { type: "zkSocial" },
      { type: "ecdsa", accounts: [/* ... */] },
      { type: "passkey", accounts: [/* ... */] },
    ],
    threshold: 2
  },
});

Or even just register it and use it later, something like this:

const rhinestoneAccount = await rhinestone.createAccount({
  validatorProviders: { /* ... */ },
  // Regular owner
  owners: {
    type: "ecdsa",
    accounts: [/* ... */]
  },
  // Register the custom validators on the account
  modules: (validators) => [validators.zkSocial]
});

// Use custom validator to sign the message
rhinestoneAccount.signMessage(
  "test",
  arbitrumSepolia,
  {
    type: "validator",
    kind: "zkSocial",
  }
)

The reason behind that for us, is that we are currently experimenting with some custom erc7579 validators, and we can't use them with the Rhinestone SDK (so we are just back with custom viem/account-abstraction implementation, but loosing all the nice stuff from your SDK).

Happy to refine API and provide a PR if there's interest

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions