-
-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import { expectAssignable, expectNotAssignable } from 'tsd'; | ||
Check failure on line 1 in src/json-rpc-provider-types.test-d.ts GitHub Actions / Build, lint, and test / Lint (16.x)
Check failure on line 1 in src/json-rpc-provider-types.test-d.ts GitHub Actions / Build, lint, and test / Lint (18.x)
|
||
import EthQuery from '@metamask/eth-query'; | ||
Check failure on line 2 in src/json-rpc-provider-types.test-d.ts GitHub Actions / Build, lint, and test / Lint (16.x)
Check failure on line 2 in src/json-rpc-provider-types.test-d.ts GitHub Actions / Build, lint, and test / Lint (18.x)
|
||
import { Web3Provider } from '@ethersproject/providers'; | ||
Check failure on line 3 in src/json-rpc-provider-types.test-d.ts GitHub Actions / Build, lint, and test / Lint (16.x)
Check failure on line 3 in src/json-rpc-provider-types.test-d.ts GitHub Actions / Build, lint, and test / Lint (18.x)
|
||
|
||
import type { | ||
Check failure on line 5 in src/json-rpc-provider-types.test-d.ts GitHub Actions / Build, lint, and test / Lint (16.x)
Check failure on line 5 in src/json-rpc-provider-types.test-d.ts GitHub Actions / Build, lint, and test / Lint (18.x)
|
||
LegacyEthereumProvider | ||
} from '.'; | ||
|
||
// Known legacy providers | ||
|
||
expectAssignable<LegacyEthereumProvider>(new EthQuery({} as any)); | ||
expectAssignable<LegacyEthereumProvider>(new Web3Provider({} as any)); |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -33,17 +33,46 @@ export type EIP1993Provider = SafeEventEmitter & { | |
* [EIP-1193](https://eips.ethereum.org/EIPS/eip-1193). It is not compliant with | ||
* any Ethereum provider standard. | ||
*/ | ||
export type LegacyEthereumProvider = { | ||
export type LegacyEthereumProvider = LegacyEthersProvider | LegacyEthJsQueryProvider | LegacyWeb3Provider; | ||
Check failure on line 36 in src/json-rpc-provider-types.ts GitHub Actions / Build, lint, and test / Lint (16.x)
Check failure on line 36 in src/json-rpc-provider-types.ts GitHub Actions / Build, lint, and test / Lint (18.x)
|
||
|
||
type LegacyWeb3Provider = { | ||
/** | ||
* Send a provider request asynchronously. | ||
* | ||
* @param req - The request to send. | ||
* @param callback - A function that is called upon the success or failure of the request. | ||
*/ | ||
sendAsync<Result extends Json = Json>( | ||
send?<Result extends Json = Json>( | ||
req: Partial<JsonRpcRequest>, | ||
callback: SendAsyncCallback<Result>, | ||
): void; | ||
} | ||
Check failure on line 49 in src/json-rpc-provider-types.ts GitHub Actions / Build, lint, and test / Lint (16.x)
Check failure on line 49 in src/json-rpc-provider-types.ts GitHub Actions / Build, lint, and test / Lint (18.x)
|
||
|
||
type LegacyEthJsQueryProvider = { | ||
/** | ||
* Send a provider request asynchronously. (ethjs-query) | ||
* | ||
* @param req - The request to send. | ||
* @param callback - A function that is called upon the success or failure of the request. | ||
*/ | ||
sendAsync?<Result extends Json = Json>( | ||
req: Partial<JsonRpcRequest>, | ||
callback: SendAsyncCallback<Result>, | ||
): void; | ||
}; | ||
|
||
type LegacyEthersProvider = { | ||
/** | ||
* Send a provider request asynchronously. (ethers v5 Web3Provider) | ||
* | ||
* @param method - The RPC method to call. | ||
* @param params - Array with method parameters. | ||
* @returns - A promise resolving with the result of the RPC call, or rejecting on failure. | ||
Check failure on line 70 in src/json-rpc-provider-types.ts GitHub Actions / Build, lint, and test / Lint (16.x)
Check failure on line 70 in src/json-rpc-provider-types.ts GitHub Actions / Build, lint, and test / Lint (18.x)
Check failure on line 70 in src/json-rpc-provider-types.ts GitHub Actions / Build, lint, and test / Lint (20.x)
|
||
*/ | ||
send?<Result extends Json = Json>( | ||
method: string, | ||
params: any[], | ||
): Promise<Result>; | ||
}; | ||
|
||
type SendAsyncCallback<Result extends Json> = ( | ||
|