feat(evm): EIP-2612 permit signing helper (Node SDK + Rust CLI) - #187
feat(evm): EIP-2612 permit signing helper (Node SDK + Rust CLI)#187teyrebaz33 wants to merge 1 commit into
Conversation
Adds signPermit() to the Node SDK and `ows sign permit` to the CLI. Closes open-wallet-standard#132 Node SDK (bindings/node/src/evm/permit.mjs): - signPermit(ownerAddress, chainId, params, signTypedData) function - Auto-fetches permit nonce from chain when not supplied - Domain resolution: eip712Domain() (EIP-5267) → well-known override table (USDC v2, DAI v1) → name() + version fallback - Handles tokens that omit version from their EIP712Domain - No new runtime dependencies (raw fetch + minimal ABI decode) Rust CLI (ows sign permit): - New sign_permit() in ows-lib with synchronous ureq HTTP calls - PermitParams and PermitSignResult types in ows-lib - ows sign permit --wallet --chain --token --spender --value --deadline [--nonce] [--rpc-url] [--json] [--index] - Follows existing sign_message / sign_transaction command patterns Tests (bindings/node/__test__/permit.spec.mjs): - 12 offline tests, all passing - Covers: v/r/s splitting, typed data structure, eip712Domain() path, fallback path, nonce auto-fetch, nonce skip, version omission, chainId, error cases, known token versions Docs (docs/examples/eip2612-permit.md): - SDK and CLI usage examples - Domain resolution strategy explained - Supported chains and tokens table
|
@teyrebaz33 is attempting to deploy a commit to the MoonPay Team on Vercel. A member of the Team first needs to authorize it. |
|
Review the following changes in direct dependencies. Learn more about Socket for GitHub.
|
|
Warning Review the following alerts detected in dependencies. According to your organization's Security Policy, it is recommended to resolve "Warn" alerts. Learn more about Socket for GitHub.
|
|
Thanks for this. The EIP-712 structure looks right, and reusing the existing typed-data signing path for the permit is the correct call. The concern is what it pulls in around the signing flow on the Rust side. This adds a new HTTP client (ureq) into ows-lib, the FFI library crate that sits right next to key handling and today has no HTTP dependencies at all, and it calls hardcoded third-party RPC endpoints from the permit flow by default. That crate should not be opening network connections, and definitely not to endpoints baked into the source. Could you move the network calls out of ows-lib, to the CLI or binding layer, or make the RPC endpoint an explicit, required argument so nothing is contacted implicitly and nothing is hardcoded? One more: the hand-rolled ABI decode silently returns 0 for a nonce at or above 2^64 (the parse overflows and falls back to 0), so an oversized nonce would produce a wrong value and an invalid signature with no error raised. Please use the existing ABI decoding rather than a hand-rolled one so large values are handled correctly. Once the network surface is out of ows-lib and the decode is fixed, this is in good shape. Final sign-off is @njdawn's. |
Summary
Adds a purpose-built
signPermithelper that eliminates the boilerplate currently required to sign EIP-2612 permits via OWS. Closes #132What's included
Node SDK —
signPermit()CLI —
ows sign permitDomain resolution
The hard part of EIP-2612 is getting the domain separator right.
signPermitresolves it in three stages:eip712Domain()(EIP-5267) — self-describing; works for USDC v2.2+, OZ ERC20Permit 5.x"2"), DAI ("1"), Base USDTname()+ default version"1"— generic fallbackTokens that omit
versionfrom their domain are handled correctly — theEIP712Domaintype array is built dynamically.Tests
Files changed
bindings/node/src/evm/permit.mjsbindings/node/__test__/permit.spec.mjsdocs/examples/eip2612-permit.mdows/crates/ows-lib/src/ops.rssign_permit()Rust implementationows/crates/ows-lib/src/types.rsPermitParams,PermitSignResulttypesows/crates/ows-lib/Cargo.tomlureqfor sync HTTPows/crates/ows-cli/src/commands/sign_permit.rsows/crates/ows-cli/src/commands/mod.rsows/crates/ows-cli/src/main.rsPermitsubcommand + handlerChecklist
signPermit()ows sign permit