This repository has been archived by the owner on Oct 7, 2024. It is now read-only.
generated from MetaMask/metamask-module-template
-
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: remove dependency to @metamask/providers + use local BasePr…
…ovider type
- Loading branch information
Showing
4 changed files
with
34 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
export type Maybe<Type> = Partial<Type> | null | undefined; | ||
|
||
export type RequestArguments = { | ||
/** The RPC method to request. */ | ||
method: string; | ||
|
||
/** The params of the RPC method, if any. */ | ||
params?: unknown[] | Record<string, unknown>; | ||
}; | ||
|
||
/** | ||
* We do re-declare locally the minimum interface from @metamask/providers here. This way this avoid | ||
* depending on it "globally" and thus ease incompatible versions (this generally clash with | ||
* the @metamask/snaps-sdk and @metamask/keyring-api packages! | ||
*/ | ||
export type BaseProvider = { | ||
/** | ||
* Submits an RPC request for the given method, with the given params. | ||
* Resolves with the result of the method call, or rejects on error. | ||
* | ||
* @param args - The RPC request arguments. | ||
* @param args.method - The RPC method name. | ||
* @param args.params - The parameters for the RPC method. | ||
* @returns A Promise that resolves with the result of the RPC method, | ||
* or rejects if an error is encountered. | ||
*/ | ||
request<Type>(args: RequestArguments): Promise<Maybe<Type>>; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters