kawasekit 0.9.0 → 0.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -4,7 +4,7 @@ import { getJpycAddress, jpycAbi } from './chunk-KT7XDT2T.js';
4
4
  import { isSupportedChainId } from './chunk-SOTYGX67.js';
5
5
  import { createZeroDevPaymasterClient, createKernelAccountClient } from '@zerodev/sdk';
6
6
  import { http, isAddress, encodeFunctionData } from 'viem';
7
- import { toRateLimitPolicy, toTimestampPolicy } from '@zerodev/permissions/policies';
7
+ import { toTimestampPolicy } from '@zerodev/permissions/policies';
8
8
 
9
9
  async function sponsorWithObservability(sponsor, account, observability) {
10
10
  try {
@@ -78,11 +78,6 @@ function createBuyListPolicies(params) {
78
78
  "createBuyListPolicies: merchants must not be empty \u2014 a buy-list must target at least one merchant."
79
79
  );
80
80
  }
81
- if (!Number.isInteger(params.maxTransfers) || params.maxTransfers < 1) {
82
- throw new Error(
83
- `createBuyListPolicies: maxTransfers must be a positive integer, got ${params.maxTransfers}.`
84
- );
85
- }
86
81
  if (!Number.isInteger(params.validUntil) || params.validUntil <= 0) {
87
82
  throw new Error(
88
83
  `createBuyListPolicies: validUntil must be a positive unix-seconds integer, got ${params.validUntil}.`
@@ -105,17 +100,12 @@ function createBuyListPolicies(params) {
105
100
  recipientAllowlist: params.merchants,
106
101
  callPolicyVersion: params.callPolicyVersion
107
102
  });
108
- const rateLimitPolicy = toRateLimitPolicy({
109
- interval: params.validUntil - validAfter,
110
- count: params.maxTransfers,
111
- startAt: validAfter
112
- });
113
103
  const timestampPolicy = toTimestampPolicy(
114
104
  params.validAfter === void 0 ? { validUntil: params.validUntil } : { validAfter: params.validAfter, validUntil: params.validUntil }
115
105
  );
116
- return [callPolicy, rateLimitPolicy, timestampPolicy];
106
+ return [callPolicy, timestampPolicy];
117
107
  }
118
108
 
119
109
  export { TransferJpycInputError, createBuyListPolicies, createSponsoredKernelClient, transferJpyc };
120
- //# sourceMappingURL=chunk-DMP7YFGA.js.map
121
- //# sourceMappingURL=chunk-DMP7YFGA.js.map
110
+ //# sourceMappingURL=chunk-OUCIKHS2.js.map
111
+ //# sourceMappingURL=chunk-OUCIKHS2.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/client/sponsored-kernel-client.ts","../src/client/transfer-jpyc.ts","../src/policy/buy-list.ts"],"names":[],"mappings":";;;;;;;;AAoCA,eAAsB,wBAAA,CACrB,OAAA,EACA,OAAA,EACA,aAAA,EACa;AACb,EAAA,IAAI;AACH,IAAA,MAAM,IAAA,GAAO,MAAM,OAAA,EAAQ;AAC3B,IAAA,gBAAA,CAAiB,aAAA,EAAe,SAAA,EAAW,EAAE,OAAA,EAAS,CAAA;AACtD,IAAA,OAAO,IAAA;AAAA,EACR,SAAS,KAAA,EAAO;AACf,IAAA,gBAAA,CAAiB,aAAA,EAAe,cAAA,EAAgB,EAAE,OAAA,EAAS,OAAO,CAAA;AAClE,IAAA,MAAM,KAAA;AAAA,EACP;AACD;AA6CO,SAAS,4BACf,MAAA,EACyB;AACzB,EAAA,MAAM,kBAAkB,4BAAA,CAA6B;AAAA,IACpD,OAAO,MAAA,CAAO,KAAA;AAAA,IACd,SAAA,EAAW,IAAA,CAAK,MAAA,CAAO,UAAU;AAAA,GACjC,CAAA;AACD,EAAA,MAAM,SAAS,yBAAA,CAA0B;AAAA,IACxC,SAAS,MAAA,CAAO,OAAA;AAAA,IAChB,OAAO,MAAA,CAAO,KAAA;AAAA;AAAA,IAEd,GAAI,OAAO,YAAA,KAAiB,MAAA,GAAY,EAAE,MAAA,EAAQ,MAAA,CAAO,YAAA,EAAa,GAAI,EAAC;AAAA,IAC3E,gBAAA,EAAkB,IAAA,CAAK,MAAA,CAAO,UAAU,CAAA;AAAA,IACxC,SAAA,EAAW;AAAA,MACV,gBAAA,EAAkB,CAAC,aAAA,KAClB,wBAAA;AAAA,QACC,MAAM,eAAA,CAAgB,oBAAA,CAAqB,EAAE,eAAe,CAAA;AA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,MACT,CAAA,mCAAA,EAAsC,UAAU,CAAA,6BAAA,EAAgC,MAAA,CAAO,UAAU,CAAA,EAAA;AAAA,KAClG;AAAA,EACD;AAGA,EAAA,MAAM,aAAa,2BAAA,CAA4B;AAAA,IAC9C,aAAa,MAAA,CAAO,WAAA;AAAA,IACpB,gBAAgB,MAAA,CAAO,cAAA;AAAA,IACvB,oBAAoB,MAAA,CAAO,SAAA;AAAA,IAC3B,mBAAmB,MAAA,CAAO;AAAA,GAC1B,CAAA;AAID,EAAA,MAAM,eAAA,GAAkB,iBAAA;AAAA,IACvB,MAAA,CAAO,UAAA,KAAe,MAAA,GACnB,EAAE,YAAY,MAAA,CAAO,UAAA,EAAW,GAChC,EAAE,UAAA,EAAY,MAAA,CAAO,UAAA,EAAY,UAAA,EAAY,OAAO,UAAA;AAAW,GACnE;AAEA,EAAA,OAAO,CAAC,YAAY,eAAe,CAAA;AACpC","file":"chunk-OUCIKHS2.js","sourcesContent":["/**\n * Build a gas-sponsored Kernel account client — a {@link ConfiguredKernelClient}\n * whose UserOp gas is paid by the ZeroDev paymaster. Pass the returned client\n * straight to {@link transferJpyc}; callers never construct a paymaster client or\n * cast to {@link ConfiguredKernelClient}.\n *\n * @packageDocumentation\n */\n\nimport {\n\ttype CreateKernelAccountReturnType,\n\tcreateKernelAccountClient,\n\tcreateZeroDevPaymasterClient,\n} from \"@zerodev/sdk\";\nimport { type Address, type Chain, http, type PublicClient, type Transport } from \"viem\";\nimport { invokeHookSafely } from \"../observability/hooks\";\nimport type { ConfiguredKernelClient } from \"./transfer-jpyc\";\n\n/**\n * Optional sponsorship observability. Hooks fire through {@link invokeHookSafely},\n * so a throwing hook never breaks sponsorship. The existing `ObservabilityHooks`\n * is x402-facilitator-shaped (verify/settle); this is the paymaster-seam surface.\n */\nexport interface SponsoredKernelClientObservability {\n\t/** Fired AFTER the paymaster GRANTS sponsorship for a userOp. */\n\treadonly onSponsor?: (event: { readonly account: Address }) => void;\n\t/** Fired when the paymaster DECLINES sponsorship (the raw error then propagates). */\n\treadonly onSponsorError?: (event: { readonly account: Address; readonly error: unknown }) => void;\n}\n\n/**\n * @internal Sponsor a userOp and fire the granted/declined observability hook.\n * The original paymaster error is re-thrown unchanged (no SDK wrapping). Exported\n * for unit testing the seam without a live chain; NOT part of the public API\n * (not re-exported from `src/index.ts`).\n */\nexport async function sponsorWithObservability<T>(\n\tsponsor: () => Promise<T>,\n\taccount: Address,\n\tobservability: SponsoredKernelClientObservability | undefined,\n): Promise<T> {\n\ttry {\n\t\tconst data = await sponsor();\n\t\tinvokeHookSafely(observability?.onSponsor, { account });\n\t\treturn data;\n\t} catch (error) {\n\t\tinvokeHookSafely(observability?.onSponsorError, { account, error });\n\t\tthrow error;\n\t}\n}\n\n/** Parameters for {@link createSponsoredKernelClient}. */\nexport interface CreateSponsoredKernelClientParams {\n\t/** A Kernel v0.7 account from `createAgentSmartAccount` or `restoreSessionAccount`. */\n\treadonly account: CreateKernelAccountReturnType<\"0.7\">;\n\t/** The viem chain the client operates on (e.g. `polygonAmoy`). */\n\treadonly chain: Chain;\n\t/**\n\t * The ZeroDev RPC URL — used for BOTH the bundler and the paymaster (ZeroDev\n\t * serves both from one project RPC). Build it from a project id with\n\t * `zerodevRpcUrl(chain, projectId)`, or paste the dashboard URL.\n\t */\n\treadonly zerodevRpc: string;\n\t/** Optional viem `PublicClient` for on-chain reads during userOp prep (recommended). */\n\treadonly publicClient?: PublicClient<Transport, Chain>;\n\t/** Optional sponsorship observability — granted / declined. */\n\treadonly observability?: SponsoredKernelClientObservability;\n}\n\n/**\n * Build a gas-sponsored Kernel account client. The returned\n * {@link ConfiguredKernelClient} pays UserOp gas via the ZeroDev paymaster and is\n * accepted directly by {@link transferJpyc} — no caller-side cast.\n *\n * @example\n * ```ts\n * import {\n * createSponsoredKernelClient,\n * polygonAmoy,\n * restoreSessionAccount,\n * transferJpyc,\n * zerodevRpcUrl,\n * } from \"kawasekit\";\n *\n * const account = await restoreSessionAccount({ publicClient, envelope, sessionKeySigner });\n * const client = createSponsoredKernelClient({\n * account,\n * chain: polygonAmoy,\n * zerodevRpc: zerodevRpcUrl(polygonAmoy, projectId),\n * publicClient,\n * });\n * const { transactionHash } = await transferJpyc(client, { to, amount });\n * ```\n */\nexport function createSponsoredKernelClient(\n\tparams: CreateSponsoredKernelClientParams,\n): ConfiguredKernelClient {\n\tconst paymasterClient = createZeroDevPaymasterClient({\n\t\tchain: params.chain,\n\t\ttransport: http(params.zerodevRpc),\n\t});\n\tconst client = createKernelAccountClient({\n\t\taccount: params.account,\n\t\tchain: params.chain,\n\t\t// exactOptionalPropertyTypes: only pass `client` when given (never `undefined`).\n\t\t...(params.publicClient !== undefined ? { client: params.publicClient } : {}),\n\t\tbundlerTransport: http(params.zerodevRpc),\n\t\tpaymaster: {\n\t\t\tgetPaymasterData: (userOperation) =>\n\t\t\t\tsponsorWithObservability(\n\t\t\t\t\t() => paymasterClient.sponsorUserOperation({ userOperation }),\n\t\t\t\t\tparams.account.address,\n\t\t\t\t\tparams.observability,\n\t\t\t\t),\n\t\t},\n\t});\n\t// createKernelAccountClient's deep generics don't unify with the exported\n\t// ConfiguredKernelClient alias; the runtime client is identical. One cast here\n\t// means callers never cast (closing gap G4).\n\treturn client as unknown as ConfiguredKernelClient;\n}\n","/**\n * High-level helper: transfer JPYC from a Kernel smart account via a sponsored\n * UserOp.\n *\n * This is the canonical \"agent payment\" path for M2. The flow:\n * 1. Resolve the JPYC contract address for `kernelClient.chain`.\n * 2. Encode `JPYC.transfer(to, amount)` calldata.\n * 3. Wrap it as a Kernel call and submit via `sendUserOperation`.\n * 4. Wait for the bundler receipt and return both hashes.\n *\n * EIP-3009 `transferWithAuthorization` cannot be used here: JPYC's signature\n * verification is pure `ecrecover`, so a smart account cannot be `from`. See\n * `src/tokens/eip3009.ts` for the EOA-payer path.\n *\n * @packageDocumentation\n */\n\nimport type { KernelAccountClient } from \"@zerodev/sdk\";\nimport type { Address, Chain, Hex, Transport } from \"viem\";\nimport { encodeFunctionData, isAddress } from \"viem\";\nimport type { SmartAccount } from \"viem/account-abstraction\";\nimport { isSupportedChainId, type SupportedChainId } from \"../chains\";\nimport { getJpycAddress, jpycAbi } from \"../tokens/jpyc\";\n\n/** A {@link KernelAccountClient} that is fully configured (chain + account). */\nexport type ConfiguredKernelClient = KernelAccountClient<Transport, Chain, SmartAccount>;\n\n/** Parameters for {@link transferJpyc}. */\nexport interface TransferJpycParams {\n\t/** Recipient address. */\n\treadonly to: Address;\n\t/**\n\t * Raw token amount in the token's smallest unit (JPYC has 18 decimals).\n\t *\n\t * @example\n\t * ```ts\n\t * import { parseUnits } from \"viem\";\n\t * import { JPYC_DECIMALS } from \"kawasekit\";\n\t *\n\t * parseUnits(\"100\", JPYC_DECIMALS); // 100 JPYC\n\t * ```\n\t */\n\treadonly amount: bigint;\n\t/**\n\t * Optional. Defaults to waiting for the bundler receipt before returning.\n\t * Set to `false` to return after the UserOp is submitted but before it\n\t * lands on chain — useful when the caller wants to do its own polling.\n\t */\n\treadonly waitForReceipt?: boolean;\n}\n\n/** Result of a {@link transferJpyc} call. */\nexport interface TransferJpycResult {\n\treadonly userOpHash: Hex;\n\t/** `null` when `waitForReceipt: false` was requested. */\n\treadonly transactionHash: Hex | null;\n\t/** `true` if the bundler receipt reported success; `null` if not awaited. */\n\treadonly success: boolean | null;\n}\n\n/** Thrown when {@link transferJpyc} is called with invalid arguments. */\nexport class TransferJpycInputError extends Error {\n\tconstructor(message: string) {\n\t\tsuper(`transferJpyc: ${message}`);\n\t\tthis.name = \"TransferJpycInputError\";\n\t}\n}\n\n/**\n * Transfer JPYC from the Kernel smart account to `to` via a sponsored UserOp.\n *\n * @example\n * ```ts\n * import { parseUnits } from \"viem\";\n * import { JPYC_DECIMALS, transferJpyc } from \"kawasekit\";\n *\n * const { userOpHash, transactionHash } = await transferJpyc(kernelClient, {\n * to: \"0xBeef0000000000000000000000000000DEADBEEF\",\n * amount: parseUnits(\"100\", JPYC_DECIMALS),\n * });\n * ```\n */\nexport async function transferJpyc(\n\tkernelClient: ConfiguredKernelClient,\n\tparams: TransferJpycParams,\n): Promise<TransferJpycResult> {\n\tif (!isAddress(params.to, { strict: false })) {\n\t\tthrow new TransferJpycInputError(`\\`to\\` is not a valid address: ${params.to}`);\n\t}\n\tif (params.amount <= 0n) {\n\t\tthrow new TransferJpycInputError(`\\`amount\\` must be positive, got ${params.amount}.`);\n\t}\n\n\tconst chainId = kernelClient.chain.id;\n\tif (!isSupportedChainId(chainId)) {\n\t\tthrow new TransferJpycInputError(`Chain ID ${chainId} is not a kawasekit-supported chain.`);\n\t}\n\tconst jpycAddress = getJpycAddress(chainId satisfies SupportedChainId);\n\n\tconst data = encodeFunctionData({\n\t\tabi: jpycAbi,\n\t\tfunctionName: \"transfer\",\n\t\targs: [params.to, params.amount],\n\t});\n\n\tconst callData = await kernelClient.account.encodeCalls([{ to: jpycAddress, value: 0n, data }]);\n\n\tconst userOpHash = await kernelClient.sendUserOperation({ callData });\n\n\tif (params.waitForReceipt === false) {\n\t\treturn { userOpHash, transactionHash: null, success: null };\n\t}\n\n\tconst receipt = await kernelClient.waitForUserOperationReceipt({ hash: userOpHash });\n\treturn {\n\t\tuserOpHash,\n\t\ttransactionHash: receipt.receipt.transactionHash,\n\t\tsuccess: receipt.success,\n\t};\n}\n","/**\n * Buy-list → ZeroDev policy bundle for a **disposable, scoped session key**\n * (the Agent Commerce Hub authorization flow).\n *\n * A user's resolved buy-list (its merchants + a per-transfer cap + a schedule\n * window) is baked into a single-use session key by composing two on-chain\n * policies:\n * 1. **callPolicy** — `JPYC.transfer(to, value)` with `value ≤ maxPerTransfer`\n * and `to ∈ merchants` (the allowlist; shared with\n * {@link createJpycDailyLimitPolicies} via {@link buildJpycTransferCallPolicy}).\n * 2. **timestampPolicy** — the session key is only valid within\n * `[validAfter, validUntil]`.\n *\n * Cumulative budget (\"spend ≤ ¥X total\") is NOT a policy field — it is the\n * amount the user funds the account with (funding is the user's responsibility,\n * out of the SDK's scope). These policies bound *who* (allowlist), *how much per\n * transfer* (cap), and *when* (window).\n *\n * The transfer **count** / sponsored-op bound is intentionally NOT a session-key\n * policy — total value is bounded by the funded balance, and an op-count / gas\n * bound (if desired) belongs to the consumer's **sponsor-gas policy**, not this\n * permission bundle. A prior version included a `rateLimitPolicy` for a\n * `maxTransfers` count, but it was built on ZeroDev's **scheduled-release** rate-\n * limit contract (`0xf63d4139…`, which gates op *i* at `startAt + i·interval`)\n * with `interval` = the whole window, so the 2nd transfer was *not-due until\n * `validUntil`* and the 3rd+ never — back-to-back multi-merchant payment reverted\n * `AA22`. It was dropped in `0.10.0`; see `docs/rfc/0004-buylist-drop-scheduled-rate-limit.md`.\n *\n * @packageDocumentation\n */\n\nimport type { Policy } from \"@zerodev/permissions\";\nimport { type CallPolicyVersion, toTimestampPolicy } from \"@zerodev/permissions/policies\";\nimport type { Address } from \"viem\";\nimport { buildJpycTransferCallPolicy } from \"./jpyc-call-policy\";\n\n/** Parameters for {@link createBuyListPolicies}. */\nexport interface CreateBuyListPoliciesParams {\n\t/** JPYC contract address on the target chain. */\n\treadonly jpycAddress: Address;\n\t/**\n\t * The buy-list's resolved merchant recipient addresses — the allowlist the\n\t * session key may pay. **Required and non-empty** (a buy-list always targets\n\t * specific merchants); checksum-normalized + de-duplicated.\n\t */\n\treadonly merchants: readonly Address[];\n\t/** Maximum JPYC (raw units) per single transfer. Must be positive. */\n\treadonly maxPerTransfer: bigint;\n\t/** Schedule-window end (unix seconds); the key is invalid after this. Must be a positive integer. */\n\treadonly validUntil: number;\n\t/**\n\t * Optional schedule-window start (unix seconds); the key is invalid before\n\t * this. Defaults to 0 (valid immediately). Must be `< validUntil`.\n\t */\n\treadonly validAfter?: number;\n\t/** ZeroDev callPolicy on-chain version. Defaults to V0_0_4. */\n\treadonly callPolicyVersion?: CallPolicyVersion;\n}\n\n/**\n * Build the ZeroDev policy bundle for a buy-list-scoped, single-use session key.\n *\n * Plug the returned policies into `toPermissionValidator({ policies, … })` and\n * issue the session key via {@link issueSessionKey}.\n *\n * @example\n * ```ts\n * import { parseUnits } from \"viem\";\n * import { createBuyListPolicies, getJpycAddress, JPYC_DECIMALS, polygonAmoy } from \"kawasekit\";\n *\n * const policies = createBuyListPolicies({\n * jpycAddress: getJpycAddress(polygonAmoy.id),\n * merchants: [merchantA, merchantB], // pay ONLY these (allowlist)\n * maxPerTransfer: parseUnits(\"500\", JPYC_DECIMALS),\n * validUntil: Math.floor(Date.now() / 1000) + 3 * 86_400, // valid 3 days\n * });\n * // user funds the account with their budget; the policies bound who/how-much/when.\n * ```\n */\nexport function createBuyListPolicies(\n\tparams: CreateBuyListPoliciesParams,\n): readonly [Policy, Policy] {\n\tif (params.merchants.length === 0) {\n\t\tthrow new Error(\n\t\t\t\"createBuyListPolicies: merchants must not be empty — a buy-list must target at least one merchant.\",\n\t\t);\n\t}\n\tif (!Number.isInteger(params.validUntil) || params.validUntil <= 0) {\n\t\tthrow new Error(\n\t\t\t`createBuyListPolicies: validUntil must be a positive unix-seconds integer, got ${params.validUntil}.`,\n\t\t);\n\t}\n\tconst validAfter = params.validAfter ?? 0;\n\tif (!Number.isInteger(validAfter) || validAfter < 0) {\n\t\tthrow new Error(\n\t\t\t`createBuyListPolicies: validAfter must be a non-negative unix-seconds integer, got ${params.validAfter}.`,\n\t\t);\n\t}\n\tif (validAfter >= params.validUntil) {\n\t\tthrow new Error(\n\t\t\t`createBuyListPolicies: validAfter (${validAfter}) must be before validUntil (${params.validUntil}).`,\n\t\t);\n\t}\n\n\t// callPolicy: amount cap + merchant allowlist (shared with daily-limit).\n\tconst callPolicy = buildJpycTransferCallPolicy({\n\t\tjpycAddress: params.jpycAddress,\n\t\tmaxPerTransfer: params.maxPerTransfer,\n\t\trecipientAllowlist: params.merchants,\n\t\tcallPolicyVersion: params.callPolicyVersion,\n\t});\n\n\t// timestampPolicy: the key is only valid within the schedule window. Omit\n\t// validAfter when not given (exactOptionalPropertyTypes: don't pass undefined).\n\tconst timestampPolicy = toTimestampPolicy(\n\t\tparams.validAfter === undefined\n\t\t\t? { validUntil: params.validUntil }\n\t\t\t: { validAfter: params.validAfter, validUntil: params.validUntil },\n\t);\n\n\treturn [callPolicy, timestampPolicy] as const;\n}\n"]}
@@ -1690,7 +1690,7 @@ function registerTransferCommand(program2) {
1690
1690
  }
1691
1691
 
1692
1692
  // cli/index.ts
1693
- var CLI_VERSION = "0.9.0" ;
1693
+ var CLI_VERSION = "0.10.0" ;
1694
1694
  var program = new commander.Command();
1695
1695
  program.name("kawasekit").description(
1696
1696
  "kawasekit \u2014 CLI for the kawasekit SDK (AI-agent stablecoin payments, Japan-first, JPYC-native)."