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

Commit

Permalink
feat: add EthKeyring type
Browse files Browse the repository at this point in the history
  • Loading branch information
danroc committed Dec 1, 2023
1 parent 1a7f356 commit 7cd842d
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 1 deletion.
6 changes: 5 additions & 1 deletion jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,11 @@ module.exports = {
collectCoverage: true,

// An array of glob patterns indicating a set of files for which coverage information should be collected
collectCoverageFrom: ['./src/**/*.ts', '!./src/**/*.test-d.ts'],
collectCoverageFrom: [
'./src/**/*.ts',
'!./src/**/index.ts',
'!./src/**/*.test-d.ts',
],

// The directory where Jest should output its coverage files
coverageDirectory: 'coverage',
Expand Down
44 changes: 44 additions & 0 deletions src/internal/eth/EthKeyring.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import type { Json, Keyring } from '@metamask/utils';

import type {
EthBaseTransaction,
EthBaseUserOperation,
EthUserOperation,
EthUserOperationPatch,
} from '../../eth';

export type EthKeyring<State extends Json> = Keyring<State> & {
/**
* Convert a base transaction to a base UserOperation.
*
* @param address - Address of the sender.
* @param transactions - Base transactions to include in the UserOperation.
* @returns A pseudo-UserOperation that can be used to construct a real.
*/
prepareUserOperation(
address: string,
transactions: EthBaseTransaction[],
): Promise<EthBaseUserOperation>;

/**
* Patches properties of a UserOperation. Currently, only the
* `paymasterAndData` can be patched.
*
* @param address - Address of the sender.
* @param userOp - UserOperation to patch.
* @returns A patch to apply to the UserOperation.
*/
patchUserOperation(
address: string,
userOp: EthUserOperation,
): Promise<EthUserOperationPatch>;

/**
* Signs an UserOperation.
*
* @param address - Address of the sender.
* @param userOp - UserOperation to sign.
* @returns The signature of the UserOperation.
*/
signUserOperation(address: string, userOp: EthUserOperation): Promise<string>;
};
1 change: 1 addition & 0 deletions src/internal/eth/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './EthKeyring';

0 comments on commit 7cd842d

Please sign in to comment.