Skip to content

Latest commit

 

History

History
35 lines (27 loc) · 1.16 KB

File metadata and controls

35 lines (27 loc) · 1.16 KB
description How to resolve the InvalidDelegator error.
sidebar_label Invalid delegator
keywords
InvalidDelegator
error code
delegation
troubleshooting

Invalid delegator

The Delegation Manager reverts with InvalidDelegator() when the caller isn't the delegator specified in the delegation.

This error is thrown by the disableDelegation and enableDelegation contract functions. Only the account that created the delegation can disable or enable it.

Solution

Verify that you're sending the transaction from the delegator's account. If the delegator is a smart account, submit a user operation through the smart account.

import { DelegationManager } from "@metamask/smart-accounts-kit/contracts";

// Generate calldata to disable the delegation.
const disableCalldata = DelegationManager.encode.disableDelegation({
  delegation: signedDelegation, // Signed by delegatorSmartAccount
});

const userOpHash = await bundlerClient.sendUserOperation({
  account: delegatorSmartAccount,
  calls: [{ 
    to: delegatorSmartAccount.environment.DelegationManager, 
    data: disableCalldata,
  }],
});