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

feat!: add KeyringExecutionContext to user ops methods #275

Merged
merged 1 commit into from
Mar 14, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
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 context - Keyring execution context.
* @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 context - Keyring execution context.
* @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 context - Keyring execution context.
* @returns The signature of the UserOperation.
*/
signUserOperation?(
address: string,
userOp: EthUserOperation,
context: KeyringExecutionContext,
): Promise<string>;
};
Loading