Conversation
| }; | ||
|
|
||
| // ─── Permission Types (EIP-2255) ──────────────────────────────────── | ||
| export type WalletPermissionCaveat = { |
There was a problem hiding this comment.
We should import these from ox and/or viem; no need to re-invent the wheel with our own types. As close to viem as possible is going to be easier to maintain
| { | ||
| "name": "@rainbow-me/provider", | ||
| "version": "0.1.3", | ||
| "version": "0.2.0", |
There was a problem hiding this comment.
Changeset will take care of that
| rdns: 'me.rainbow', | ||
| }, | ||
| provider, | ||
| }); |
There was a problem hiding this comment.
Any harm in bringing the mipd announcer and inpage setup into this repo? Some duplicity on the app and bx for that
| ```ts | ||
| createSessionMethods({ getSession }); // eth_chainId, eth_accounts, eth_coinbase | ||
| createRpcMethods({ transport }); // eth_blockNumber, eth_getBalance, eth_call, ... | ||
| createLocalMethods({ getPermissions, getCapabilities, getCallsStatus }); |
There was a problem hiding this comment.
Curious about the naming scheme here. We could logically separate these into implementation directories, but not sure about the explicit naming vs borrowing the existing public vs wallet naming from viem. All of the method and type contracts are here: https://github.com/wevm/viem/blob/main/src/types/eip1193.ts#L2152
| with: | ||
| title: 'chore: version packages' | ||
| commit: 'chore: version packages' | ||
| publish: yarn release |
There was a problem hiding this comment.
Still a manual process for now
There was a problem hiding this comment.
The MetaMask entrypoint logically makes a bit more sense to me; would be a wrapper on top of this. Initializes and announces the provider to bridge 1193 + 6963 + 5749 (window.ethereum.providers array) https://github.com/MetaMask/providers/blob/main/src/initializeInpageProvider.ts
There was a problem hiding this comment.
I think this is a case where ts-to-zod or another generator library would better serve us. All of the schemas are well codified by viem and that is more likely to be maintained responsibly vs on our side: https://github.com/wevm/viem/blob/main/src/types/eip1193.ts
| // Forward all eth_* RPC calls to node | ||
| // The transport.request is already typed, so we pass through | ||
| const forward = async <T>(req: { method: string; params?: unknown }) => | ||
| config.transport.request(req as never) as T; |
There was a problem hiding this comment.
We should keep the throttle mechanism here; the cross-boundary parsing would further bottleneck if a provider is being abused
|
|
||
| type LocalMethods = { | ||
| personal_ecRecover: MethodHandler; | ||
| wallet_getPermissions: MethodHandler; |
There was a problem hiding this comment.
If implemented properly this would actually be using session data; it's a per-dapp permission boundary for things like session key spend limits https://docs.metamask.io/wallet/how-to/manage-permissions
Complete rewrite. Ox-only.
Changes
createProvider()replacesRainbowProviderclasshandleRequests()replaceshandleProviderRequest()/defaults,/schemasexportsRemoved deps
@ethersproject/*, viem, eventemitter3, @metamask/eth-sig-util
Added deps
ox (core), zod (optional peer)
Breaking