Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions smart-accounts-kit/troubleshooting/error-codes.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ 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.<br/><br/>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. |
| `0xb5863604` | `InvalidDelegate()` | The caller isn't the delegate specified in the delegation.<br/><br/>See [Invalid delegate troubleshooting page](./invalid-delegate.md) to learn more. |
Comment thread
AyushBherwani1998 marked this conversation as resolved.
Outdated
| `0xb9f0f171` | `InvalidDelegator()` | The caller isn't the delegator specificed in the delegation.<br/><br/>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. |
Expand Down
35 changes: 35 additions & 0 deletions smart-accounts-kit/troubleshooting/invalid-delegator.md
Original file line number Diff line number Diff line change
@@ -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 isn't the delegator
specified in the delegation.
Comment thread
AyushBherwani1998 marked this conversation as resolved.
Outdated

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,
}],
});
```
Loading