Skip to content

Commit

Permalink
fix(core): add missing null return type of eth_getUserOperation* (#…
Browse files Browse the repository at this point in the history
…93)

Affected methods: `eth_getUserOperationReceipt`, `eth_getUserOperationByHash`
  • Loading branch information
freeatnet committed Aug 29, 2023
1 parent 38b2ebf commit cba9a0c
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 10 deletions.
4 changes: 2 additions & 2 deletions packages/core/src/client/create-client.ts
Expand Up @@ -62,14 +62,14 @@ export const createPublicErc4337FromClient: <
});
},

getUserOperationByHash(hash: Hash): Promise<UserOperationResponse> {
getUserOperationByHash(hash: Hash): Promise<UserOperationResponse | null> {
return clientAdapter.request({
method: "eth_getUserOperationByHash",
params: [hash],
});
},

getUserOperationReceipt(hash: Hash): Promise<UserOperationReceipt> {
getUserOperationReceipt(hash: Hash): Promise<UserOperationReceipt | null> {
return clientAdapter.request({
method: "eth_getUserOperationReceipt",
params: [hash],
Expand Down
8 changes: 4 additions & 4 deletions packages/core/src/client/types.ts
Expand Up @@ -36,12 +36,12 @@ export type Erc337RpcSchema = [
{
Method: "eth_getUserOperationReceipt";
Parameters: [Hash];
ReturnType: UserOperationReceipt;
ReturnType: UserOperationReceipt | null;
},
{
Method: "eth_getUserOperationByHash";
Parameters: [Hash];
ReturnType: UserOperationResponse;
ReturnType: UserOperationResponse | null;
},
{
Method: "eth_supportedEntryPoints";
Expand Down Expand Up @@ -86,15 +86,15 @@ export interface Erc4337Actions {
* @param hash - the hash of the UserOperation to get the receipt for
* @returns - {@link UserOperationResponse}
*/
getUserOperationByHash(hash: Hash): Promise<UserOperationResponse>;
getUserOperationByHash(hash: Hash): Promise<UserOperationResponse | null>;

/**
* calls `eth_getUserOperationReceipt` and returns the {@link UserOperationReceipt}
*
* @param hash - the hash of the UserOperation to get the receipt for
* @returns - {@link UserOperationResponse}
*/
getUserOperationReceipt(hash: Hash): Promise<UserOperationReceipt>;
getUserOperationReceipt(hash: Hash): Promise<UserOperationReceipt | null>;

/**
* calls `eth_supportedEntryPoints` and returns the entrypoints the RPC
Expand Down
8 changes: 6 additions & 2 deletions packages/core/src/provider/base.ts
Expand Up @@ -301,11 +301,15 @@ export class SmartAccountProvider<
throw new Error("Failed to find transaction for User Operation");
};

getUserOperationByHash = (hash: Hash): Promise<UserOperationResponse> => {
getUserOperationByHash = (
hash: Hash
): Promise<UserOperationResponse | null> => {
return this.rpcClient.getUserOperationByHash(hash);
};

getUserOperationReceipt = (hash: Hash): Promise<UserOperationReceipt> => {
getUserOperationReceipt = (
hash: Hash
): Promise<UserOperationReceipt | null> => {
return this.rpcClient.getUserOperationReceipt(hash);
};

Expand Down
4 changes: 2 additions & 2 deletions packages/core/src/provider/types.ts
Expand Up @@ -133,15 +133,15 @@ export interface ISmartAccountProvider<
* @param hash - the hash of the UserOperation to get the receipt for
* @returns - {@link UserOperationResponse}
*/
getUserOperationByHash: (hash: Hash) => Promise<UserOperationResponse>;
getUserOperationByHash: (hash: Hash) => Promise<UserOperationResponse | null>;

/**
* calls `eth_getUserOperationReceipt` and returns the {@link UserOperationReceipt}
*
* @param hash - the hash of the UserOperation to get the receipt for
* @returns - {@link UserOperationResponse}
*/
getUserOperationReceipt: (hash: Hash) => Promise<UserOperationReceipt>;
getUserOperationReceipt: (hash: Hash) => Promise<UserOperationReceipt | null>;

/**
* This takes an ethereum transaction and converts it into a UserOperation, sends the UserOperation, and waits
Expand Down

0 comments on commit cba9a0c

Please sign in to comment.