Skip to content

feat: v2 rewrite on Ox#35

Draft
janek26 wants to merge 1 commit intomainfrom
v0.2-implementation
Draft

feat: v2 rewrite on Ox#35
janek26 wants to merge 1 commit intomainfrom
v0.2-implementation

Conversation

@janek26
Copy link
Copy Markdown
Contributor

@janek26 janek26 commented Jan 22, 2026

Complete rewrite. Ox-only.

Changes

  • createProvider() replaces RainbowProvider class
  • handleRequests() replaces handleProviderRequest()
  • Full RpcSchema type safety
  • New: /defaults, /schemas exports

Removed deps

@ethersproject/*, viem, eventemitter3, @metamask/eth-sig-util

Added deps

ox (core), zod (optional peer)

Breaking

  • Transport interfaces changed
  • Rate limiting/validation now platform responsibility
  • See docs/MIGRATION.md

};

// ─── Permission Types (EIP-2255) ────────────────────────────────────
export type WalletPermissionCaveat = {
Copy link
Copy Markdown
Contributor

@DanielSinclair DanielSinclair Feb 10, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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",
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changeset will take care of that

rdns: 'me.rainbow',
},
provider,
});
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 });
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Still a manual process for now

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

@DanielSinclair DanielSinclair marked this pull request as draft March 20, 2026 06:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants