Skip to content

Commit a42a4d4

Browse files
kylecrawshawclaude
andcommitted
Keep Permit2 actions off the SDK root entry
The Permit2 actions and EIP-712 helpers import viem, which the root entry point must not load at runtime. Their runtime exports move to radius-sdk/client alongside the balance and ERC-20 actions; the root keeps only the types. Add the changeset. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
1 parent 87e75e6 commit a42a4d4

5 files changed

Lines changed: 53 additions & 29 deletions

File tree

‎.changeset/sdk-permit2.md‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"radius-sdk": minor
3+
---
4+
5+
Add Permit2 interactions covering both SignatureTransfer (with optional witness) and AllowanceTransfer: `approvePermit2`, `signPermit2Transfer`, `permit2TransferFrom`, `signPermit2Allowance`, `permit2Permit`, `permit2AllowanceTransferFrom`, the `permit2Actions()` client extension and the EIP-712 helpers, exported from `radius-sdk/client`.

‎packages/sdk/README.md‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -160,10 +160,10 @@ asset next to `send`.
160160

161161
Actions for the canonical [Permit2](https://github.com/Uniswap/permit2) contract (`PERMIT2_ADDRESS`,
162162
the same on every Radius network), covering both of its flows. `permit2Actions()` is a client
163-
extension; each action is also exported on its own.
163+
extension; each action is also exported on its own. All of them come from `radius-sdk/client`.
164164

165165
```ts
166-
import { permit2Actions } from 'radius-sdk';
166+
import { permit2Actions } from 'radius-sdk/client';
167167
const owner = createWalletClient({ account, chain: radiusTestnet.chain, transport: http() }).extend(permit2Actions());
168168
const spender = createWalletClient({ account: spenderAccount, chain: radiusTestnet.chain, transport: http() }).extend(permit2Actions());
169169

@@ -193,7 +193,7 @@ Nonces: SignatureTransfer nonces are random 256-bit values (`randomPermit2Nonce(
193193
AllowanceTransfer nonces are sequential per (owner, token, spender) and read from Permit2 when
194194
omitted. Deadlines default to 600 s, the same cap the x402 client applies. The EIP-712 domain,
195195
type sets (`PERMIT_TRANSFER_FROM_TYPES`, `PERMIT_SINGLE_TYPES`), `permit2WitnessTypeString` and
196-
`permit2WitnessHash` are exported for anyone assembling calls by hand; the witness type string is
196+
`permit2WitnessHash` are exported from `radius-sdk/client` for anyone assembling calls by hand; the witness type string is
197197
derived with EIP-712's ordering rule and checked against the x402 layout in the tests.
198198

199199
## Balances: native RUSD vs stablecoins

‎packages/sdk/examples/agent-buyer/permit2-pull.mjs‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@
77
// SBC via Turnstile). The collector pays gas for the pull, so it needs a little SBC too.
88
import { createWalletClient, http } from 'viem';
99
import { privateKeyToAccount } from 'viem/accounts';
10-
import { SBC, erc20Actions, formatTokenAmount, permit2Actions, radiusActions, radiusTestnet } from 'radius-sdk';
10+
import { erc20Actions, formatTokenAmount, permit2Actions, radiusActions } from 'radius-sdk/client';
11+
import { SBC, radiusTestnet } from 'radius-sdk';
1112

1213
const amount = process.argv[2] ?? '0.001';
1314
const payer = createWalletClient({ account: privateKeyToAccount(process.env.RADIUS_PRIVATE_KEY), chain: radiusTestnet.chain, transport: http() })

‎packages/sdk/src/client/index.ts‎

Lines changed: 42 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -599,8 +599,48 @@ export type {
599599
GetTransfersParameters,
600600
WatchTransfersParameters,
601601
} from '../erc20.js';
602-
export { permit2Actions, getPermit2Approval, getPermit2Allowance, isPermit2NonceUsed, approvePermit2, signPermit2Transfer, signPermit2Allowance, permit2TransferFrom, permit2Permit, permit2AllowanceTransferFrom } from '../permit2.js';
603-
export type { Permit2Actions, Permit2Witness, SignedPermit2Transfer, SignedPermit2Allowance, Permit2Allowance } from '../permit2.js';
602+
export {
603+
permit2Actions,
604+
getPermit2Approval,
605+
getPermit2Allowance,
606+
isPermit2NonceUsed,
607+
approvePermit2,
608+
signPermit2Transfer,
609+
signPermit2Allowance,
610+
permit2TransferFrom,
611+
permit2Permit,
612+
permit2AllowanceTransferFrom,
613+
permit2Domain,
614+
permit2WitnessTypeString,
615+
permit2WitnessHash,
616+
permitWitnessTransferFromTypes,
617+
encodeTypedDataType,
618+
randomPermit2Nonce,
619+
PERMIT2_ABI,
620+
PERMIT_TRANSFER_FROM_TYPES,
621+
PERMIT_SINGLE_TYPES,
622+
TOKEN_PERMISSIONS_TYPE,
623+
PERMIT2_DEFAULT_DEADLINE_SECONDS,
624+
} from '../permit2.js';
625+
export type {
626+
Permit2Actions,
627+
Permit2ActionsConfig,
628+
Permit2Witness,
629+
PermitTransferFrom,
630+
PermitSingle,
631+
SignedPermit2Transfer,
632+
SignedPermit2Allowance,
633+
Permit2Allowance,
634+
GetPermit2ApprovalParameters,
635+
GetPermit2AllowanceParameters,
636+
IsPermit2NonceUsedParameters,
637+
ApprovePermit2Parameters,
638+
SignPermit2TransferParameters,
639+
SignPermit2AllowanceParameters,
640+
Permit2TransferFromParameters,
641+
Permit2PermitParameters,
642+
Permit2AllowanceTransferFromParameters,
643+
} from '../permit2.js';
604644
export { getPaymentReceipt, decodePaymentReceipt, parseUptoSettlementAmount } from '../receipt.js';
605645
export type { PaymentReceipt } from '../receipt.js';
606646
export { RadiusPaymentError } from '../errors.js';

‎packages/sdk/src/index.ts‎

Lines changed: 1 addition & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -54,29 +54,7 @@ export type {
5454
GetTransfersParameters,
5555
WatchTransfersParameters,
5656
} from './erc20.js';
57-
export {
58-
permit2Actions,
59-
getPermit2Approval,
60-
getPermit2Allowance,
61-
isPermit2NonceUsed,
62-
approvePermit2,
63-
signPermit2Transfer,
64-
signPermit2Allowance,
65-
permit2TransferFrom,
66-
permit2Permit,
67-
permit2AllowanceTransferFrom,
68-
permit2Domain,
69-
permit2WitnessTypeString,
70-
permit2WitnessHash,
71-
permitWitnessTransferFromTypes,
72-
encodeTypedDataType,
73-
randomPermit2Nonce,
74-
PERMIT2_ABI,
75-
PERMIT_TRANSFER_FROM_TYPES,
76-
PERMIT_SINGLE_TYPES,
77-
TOKEN_PERMISSIONS_TYPE,
78-
PERMIT2_DEFAULT_DEADLINE_SECONDS,
79-
} from './permit2.js';
57+
// Permit2 actions and EIP-712 helpers load viem too; their runtime exports live on `radius-sdk/client`.
8058
export type {
8159
Permit2Actions,
8260
Permit2ActionsConfig,

0 commit comments

Comments
 (0)