Skip to content
This repository has been archived by the owner on Oct 7, 2024. It is now read-only.

Commit

Permalink
feat!(307): add KeyringExecutionContext to user ops methods
Browse files Browse the repository at this point in the history
  • Loading branch information
ccharly committed Mar 13, 2024
1 parent 2e1b611 commit 6d33fb2
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/contexts.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
/**
* Context used by a Keyring implementation.
*/
export type KeyringExecutionContext = {
/** The chain ID. */
chainId: string;
};
1 change: 1 addition & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
export * from './api';
export * from './contexts';
export * from './eth';
export * from './events';
export * from './internal';
Expand Down
7 changes: 7 additions & 0 deletions src/internal/eth/EthKeyring.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import type { Json, Keyring } from '@metamask/utils';

import type { KeyringExecutionContext } from '../../contexts';
import type {
EthBaseTransaction,
EthBaseUserOperation,
Expand All @@ -13,11 +14,13 @@ export type EthKeyring<State extends Json> = Keyring<State> & {
*
* @param address - Address of the sender.
* @param transactions - Base transactions to include in the UserOperation.
* @param chainId - Chain ID.
* @returns A pseudo-UserOperation that can be used to construct a real.
*/
prepareUserOperation?(
address: string,
transactions: EthBaseTransaction[],
context: KeyringExecutionContext,
): Promise<EthBaseUserOperation>;

/**
Expand All @@ -26,22 +29,26 @@ export type EthKeyring<State extends Json> = Keyring<State> & {
*
* @param address - Address of the sender.
* @param userOp - UserOperation to patch.
* @param chainId - Chain ID.
* @returns A patch to apply to the UserOperation.
*/
patchUserOperation?(
address: string,
userOp: EthUserOperation,
context: KeyringExecutionContext,
): Promise<EthUserOperationPatch>;

/**
* Signs an UserOperation.
*
* @param address - Address of the sender.
* @param userOp - UserOperation to sign.
* @param chainId - Chain ID.
* @returns The signature of the UserOperation.
*/
signUserOperation?(
address: string,
userOp: EthUserOperation,
context: KeyringExecutionContext,
): Promise<string>;
};

0 comments on commit 6d33fb2

Please sign in to comment.