diff --git a/smart-accounts-kit/troubleshooting/error-codes.md b/smart-accounts-kit/troubleshooting/error-codes.md index 8a9ecd40e88..c97581e7a86 100644 --- a/smart-accounts-kit/troubleshooting/error-codes.md +++ b/smart-accounts-kit/troubleshooting/error-codes.md @@ -14,7 +14,7 @@ Error codes from the [MetaMask Delegation Framework contracts](https://github.co | Error code | Error name | Description | | ---------- | ---------- | ----------- | | `0xb5863604` | `InvalidDelegate()` | The caller is not the delegate specified in the delegation.

See [Invalid delegate troubleshooting page](./invalid-delegate.md) to learn more. | -| `0xb9f0f171` | `InvalidDelegator()` | The caller is not the delegator specificed in the delegation, or the delegator is not deployed. | +| `0xb9f0f171` | `InvalidDelegator()` | The caller is not the delegator specificed in the delegation.

See [Invalid delegator troubleshooting page](./invalid-delegator.md) to learn more. | | `0x05baa052` | `CannotUseADisabledDelegation()` | The delegation has been disabled by the delegator. | | `0xded4370e` | `InvalidAuthority()` | The delegation chain authority validation failed. The authority hash of a child delegation does not match the hash of its parent delegation. | | `0x1bcaf69f` | `BatchDataLengthMismatch()` | The array lengths do not match in a batch `redeemDelegations` contract call. | diff --git a/smart-accounts-kit/troubleshooting/invalid-delegator.md b/smart-accounts-kit/troubleshooting/invalid-delegator.md new file mode 100644 index 00000000000..24fb5d40601 --- /dev/null +++ b/smart-accounts-kit/troubleshooting/invalid-delegator.md @@ -0,0 +1,35 @@ +--- +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 is not 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](../guides/delegation/disable-delegation.md) +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. + +```typescript +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, + }], +}); +```