eth-provider-types
Advanced tools
Comparing version 0.0.2 to 0.1.0-beta.0
# eth-provider-types | ||
## 0.1.0-beta.0 | ||
### Minor Changes | ||
- [#300](https://github.com/BitskiCo/bitski-js/pull/300) [`3e2ced1`](https://github.com/BitskiCo/bitski-js/commit/3e2ced1d2ff939c15f3aefec6f65fec3d97b8638) Thanks [@pzuraq](https://github.com/pzuraq)! - Switch to json rpc engine | ||
This PR updates the provider to use a simpler JSON-RPC based | ||
architecture. It also includes a number of other changes and enhancements: | ||
- Builds with Rollup instead of Browserify for smaller bundle size (down | ||
to 170kb minified). | ||
- Adds `bitski.initialize()` to reinitialize Bitski after page loads | ||
- Updates sign in and initialize methods to set `window.ethereum` to the | ||
Bitski provider after successful login. This should make it easier for | ||
devs to integrate into their DApps. | ||
- Adds storage for provider state so the provider can store custom | ||
chains, current chain ID, etc. | ||
- Adds custom chain RPC url to transaction request contexts, so we can | ||
send the transaction server side in the near future. | ||
- Updates `eth-provider-types` to be more accurate overall | ||
- Ability for middlewares to add arbitrary context to transactions/signs | ||
## 0.0.2 | ||
@@ -4,0 +26,0 @@ |
102
index.d.ts
@@ -21,2 +21,3 @@ /** | ||
eth_accounts = 'eth_accounts', | ||
eth_requestAccounts = 'eth_requestAccounts', | ||
eth_blockNumber = 'eth_blockNumber', | ||
@@ -33,2 +34,6 @@ eth_getBalance = 'eth_getBalance', | ||
eth_signTransaction = 'eth_signTransaction', | ||
eth_signTypedData = 'eth_signTypedData', | ||
eth_signTypedData_v1 = 'eth_signTypedData_v1', | ||
eth_signTypedData_v3 = 'eth_signTypedData_v3', | ||
eth_signTypedData_v4 = 'eth_signTypedData_v4', | ||
eth_sendTransaction = 'eth_sendTransaction', | ||
@@ -56,2 +61,7 @@ eth_sendRawTransaction = 'eth_sendRawTransaction', | ||
eth_submitHashrate = 'eth_submitHashrate', | ||
eth_chainId = 'eth_chainId', | ||
eth_subscribe = 'eth_subscribe', | ||
eth_unsubscribe = 'eth_unsubscribe', | ||
wallet_addEthereumChain = 'wallet_addEthereumChain', | ||
wallet_switchEthereumChain = 'wallet_switchEthereumChain', | ||
} | ||
@@ -66,8 +76,10 @@ | ||
export interface EthTransactionSend { | ||
from: string; | ||
from?: string; | ||
to?: string; | ||
gas?: string; | ||
gasPrice?: string; | ||
maxFeePerGas?: string; | ||
maxPriorityFeePerGas?: string; | ||
value?: string; | ||
data: string; | ||
data?: string; | ||
nonce?: string; | ||
@@ -81,2 +93,4 @@ } | ||
gasPrice?: string; | ||
maxFeePerGas?: string; | ||
maxPriorityFeePerGas?: string; | ||
value?: string; | ||
@@ -207,2 +221,38 @@ data?: string; | ||
export interface TypedPropertyDef { | ||
name: string; | ||
type: string; | ||
} | ||
export type TypedDataDefinition = TypedPropertyDef[]; | ||
export interface TypedDataTypes { | ||
EIP712Domain: TypedDataDefinition; // Required. Specify the domain fields you are using. | ||
[typeName: string]: TypedDataDefinition; | ||
} | ||
export interface TypedData { | ||
types: TypedDataTypes; | ||
domain: Record<string, unknown>; // Provide object format of domain according to spec in `types` | ||
primaryType: string; // The name of the top-level type being used in `message` | ||
message: Record<string, unknown>; // The values for your object, starting from the `primaryType` | ||
} | ||
interface EthChainDefinition { | ||
chainId: string; // A 0x-prefixed hexadecimal string | ||
chainName?: string; | ||
nativeCurrency?: { | ||
name: string; | ||
symbol: string; // 2-6 characters long | ||
decimals: number; | ||
}; | ||
rpcUrls?: string[]; | ||
blockExplorerUrls?: string[]; | ||
iconUrls?: string[]; // Currently ignored. | ||
} | ||
export interface SwitchEthereumChainParameter { | ||
chainId: string; // A 0x-prefixed hexadecimal string | ||
} | ||
export type EthMethodParams = { | ||
@@ -221,2 +271,3 @@ [EthMethod.web3_clientVersion]: void; | ||
[EthMethod.eth_accounts]: void; | ||
[EthMethod.eth_requestAccounts]: void; | ||
[EthMethod.eth_blockNumber]: void; | ||
@@ -230,11 +281,15 @@ [EthMethod.eth_getBalance]: [address: string, tag?: EthBlockNumberTag | string]; | ||
[EthMethod.eth_getTransactionCount]: [address: string, tag?: EthBlockNumberTag | string]; | ||
[EthMethod.eth_getBlockTransactionCountByHash]: { params: [blockHash: string]; result: any }; | ||
[EthMethod.eth_getBlockTransactionCountByHash]: [blockHash: string]; | ||
[EthMethod.eth_getBlockTransactionCountByNumber]: [tag: EthBlockNumberTag | string]; | ||
[EthMethod.eth_getUncleCountByBlockHash]: { params: [blockHash: string]; result: any }; | ||
[EthMethod.eth_getUncleCountByBlockHash]: [blockHash: string]; | ||
[EthMethod.eth_getUncleCountByBlockNumber]: [tag: EthBlockNumberTag | string]; | ||
[EthMethod.eth_getCode]: [address: string, tag?: EthBlockNumberTag | string]; | ||
[EthMethod.eth_sign]: { params: [address: string, data: string]; result: any }; | ||
[EthMethod.eth_signTransaction]: { params: [transaction: EthTransactionSend]; result: any }; | ||
[EthMethod.eth_sendTransaction]: { params: [transaction: EthTransactionSend]; result: any }; | ||
[EthMethod.eth_sendRawTransaction]: { params: [data: string]; result: any }; | ||
[EthMethod.eth_sign]: [address: string, data: string]; | ||
[EthMethod.eth_signTransaction]: [transaction: EthTransactionSend]; | ||
[EthMethod.eth_signTypedData]: [address: string, data: string | TypedData]; | ||
[EthMethod.eth_signTypedData_v1]: [address: string, data: string | TypedData]; | ||
[EthMethod.eth_signTypedData_v3]: [address: string, data: string | TypedData]; | ||
[EthMethod.eth_signTypedData_v4]: [address: string, data: string | TypedData]; | ||
[EthMethod.eth_sendTransaction]: [transaction: EthTransactionSend]; | ||
[EthMethod.eth_sendRawTransaction]: [data: string]; | ||
[EthMethod.eth_call]: [transactionCall: EthTransactionCall, tag?: EthBlockNumberTag | string]; | ||
@@ -278,2 +333,7 @@ [EthMethod.eth_estimateGas]: [ | ||
[EthMethod.eth_submitHashrate]: [hashrate: string, id: string]; | ||
[EthMethod.eth_chainId]: void; | ||
[EthMethod.eth_subscribe]: [subscriptionName: string, data?: unknown]; | ||
[EthMethod.eth_unsubscribe]: [subscriptionId: string]; | ||
[EthMethod.wallet_addEthereumChain]: [definition: EthChainDefinition]; | ||
[EthMethod.wallet_switchEthereumChain]: [SwitchEthereumChainParameter]; | ||
}; | ||
@@ -296,2 +356,3 @@ | ||
[EthMethod.eth_accounts]: string[]; | ||
[EthMethod.eth_requestAccounts]: string[]; | ||
[EthMethod.eth_blockNumber]: string; | ||
@@ -308,2 +369,6 @@ [EthMethod.eth_getBalance]: string; | ||
[EthMethod.eth_signTransaction]: string; | ||
[EthMethod.eth_signTypedData]: string; | ||
[EthMethod.eth_signTypedData_v1]: string; | ||
[EthMethod.eth_signTypedData_v3]: string; | ||
[EthMethod.eth_signTypedData_v4]: string; | ||
[EthMethod.eth_sendTransaction]: string; | ||
@@ -331,2 +396,7 @@ [EthMethod.eth_sendRawTransaction]: string; | ||
[EthMethod.eth_submitHashrate]: true; | ||
[EthMethod.eth_chainId]: string; | ||
[EthMethod.eth_subscribe]: string; | ||
[EthMethod.eth_unsubscribe]: boolean; | ||
[EthMethod.wallet_addEthereumChain]: null; | ||
[EthMethod.wallet_switchEthereumChain]: null; | ||
}; | ||
@@ -357,2 +427,3 @@ | ||
accountsChanged = 'accountsChanged', | ||
data = 'data', | ||
} | ||
@@ -364,7 +435,9 @@ | ||
export interface EthSubscriptionData { | ||
readonly subscription: string; | ||
readonly result: unknown; | ||
} | ||
export type EthProviderMessageData = { | ||
[EthProviderMessageType.eth_subscription]: { | ||
readonly subscription: string; | ||
readonly result: unknown; | ||
}; | ||
[EthProviderMessageType.eth_subscription]: EthSubscriptionData; | ||
}; | ||
@@ -387,2 +460,3 @@ | ||
[EthEvent.accountsChanged]: [string[]]; | ||
[EthEvent.data]: [null, { params: EthSubscriptionData }]; | ||
}; | ||
@@ -392,3 +466,3 @@ | ||
export type EthRequest<T extends EthMethod> = EthMethodParams[T] extends void | ||
export type EthRequest<T extends EthMethod = EthMethod> = EthMethodParams[T] extends void | ||
? { | ||
@@ -412,3 +486,3 @@ method: T; | ||
}): Promise<EthBlock<T>>; | ||
request<T extends EthMethod>(req: EthRequest<T>): EthMethodResults[T]; | ||
request<T extends EthMethod>(req: EthRequest<T>): EthResult<T>; | ||
@@ -415,0 +489,0 @@ on<T extends EthEvent>(eventName: T, listener: EthEventListener<T>): void; |
{ | ||
"name": "eth-provider-types", | ||
"version": "0.0.2", | ||
"version": "0.1.0-beta.0", | ||
"description": "TypeScript types for Ethereum providers, with types for every RPC method", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
20856
439