Skip to content

feat: Align grant registration with new gateway struct#150

Open
letonchanh wants to merge 3 commits into
mainfrom
feat/grant-registration-struct
Open

feat: Align grant registration with new gateway struct#150
letonchanh wants to merge 3 commits into
mainfrom
feat/grant-registration-struct

Conversation

@letonchanh
Copy link
Copy Markdown
Member

Replace the legacy grant: string JSON blob + fileIds: uint256[] with first-class EIP-712 fields scopes: string[], grantVersion: uint256, and expiresAt: uint256, and add grantVersion to GrantRevocation so the monotonic nonce defends both events against replay. Update the gateway client wire format and GET response shape (now carries expiresAt/expired/paymentStatus/paidAt/paidBy/grantVersion/ fee) to match data-gateway.

Replace the legacy `grant: string` JSON blob + `fileIds: uint256[]` with
first-class EIP-712 fields `scopes: string[]`, `grantVersion: uint256`,
and `expiresAt: uint256`, and add `grantVersion` to GrantRevocation so
the monotonic nonce defends both events against replay. Update the
gateway client wire format and GET response shape (now carries
`expiresAt`/`expired`/`paymentStatus`/`paidAt`/`paidBy`/`grantVersion`/
`fee`) to match data-gateway.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@vercel
Copy link
Copy Markdown

vercel Bot commented May 20, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

3 Skipped Deployments
Project Deployment Actions Updated (UTC)
vana-console Ignored Ignored May 21, 2026 2:31am
vana-rbac-auditor Ignored Ignored May 21, 2026 2:31am
vana-vibes-demo Ignored Ignored May 21, 2026 2:31am

Request Review

@github-actions
Copy link
Copy Markdown

Findings

  • packages/vana-sdk/src/protocol/eip712.ts:100: The EIP-712 grant shape was updated to scopes/grantVersion/expiresAt, but the exported DataPortabilityPermissionsABI still exposes legacy grant/fileIds and revocation nonce/permissionId structs. If SDK consumers use getAbi("DataPortabilityPermissions"), they can now sign one shape and submit another. Regenerate/update the ABI if the contract/gateway contract surface changed.

  • packages/vana-sdk/src/protocol/grants.ts:68: toUint256 accepts number and converts with BigInt(value), which silently preserves already-rounded unsafe integers. For uint256 fields, reject non-safe integers with Number.isSafeInteger(value) or require string/bigint for grantVersion and expiresAt.

Verification

  • Could not run tests or typecheck: dependencies are not installed in this checkout (vitest missing, @types/node missing).

letonchanh and others added 2 commits May 20, 2026 22:05
Add the GenericPayment EIP-712 typed-data and gateway-client wrappers
for /v1/escrow/balance, /v1/escrow/deposit, and /v1/escrow/pay so a
builder can settle a grant's registration + data-access fees before
calling the Personal Server. Adds `dataPortabilityEscrow` to the
contracts config (so existing fixtures gain the field) and a
NATIVE_VANA_ASSET sentinel for the native-asset case.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Add primitives for funding the escrow balance from a wallet —
buildDepositNativeRequest / buildDepositTokenRequest return the
raw {to, data, value?} request object for any tx-submission stack
(viem, ethers, wallet-rpc, MPC, Safe). The credited `account` is
encoded in calldata, so a third party can fund someone else's escrow.

Add an e2e test that wires the deposit + payment helpers through a
real viem WalletClient against an in-memory L1 (custom RPC transport)
and a fetch-mocked gateway that decodes the same calldata via
ESCROW_DEPOSIT_ABI and recovers the GenericPayment signer with
recoverTypedDataAddress — the same cryptographic checks the real
gateway runs. Covers happy path, 402 insufficient-balance, and 409
nonce-replay.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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.

1 participant