kawasekit 0.7.0 → 0.9.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.
package/dist/index.d.cts CHANGED
@@ -1,11 +1,11 @@
1
- import { Policy } from '@zerodev/permissions';
2
- import { CreateKernelAccountReturnType } from '@zerodev/sdk';
3
- import { EntryPointType, GetKernelVersion } from '@zerodev/sdk/types';
4
- import * as viem from 'viem';
5
- import { PublicClient, Transport, Chain, LocalAccount, Address } from 'viem';
1
+ import { C as ConfiguredKernelClient } from './index-FxiMeqpl.cjs';
2
+ export { A as AgentOwner, B as BuildRevokeSessionKeyCallParams, a as CreateAgentSmartAccountParams, I as IssueSessionKeyParams, K as KAWASEKIT_SESSION_ENVELOPE_VERSION, b as KawasekitSessionEnvelope, c as KawasekitSessionEnvelopeVersion, d as KawasekitSessionPolicySummary, R as RestoreSessionAccountParams, e as RevokeSessionKeyParams, f as RevokeSessionKeyResult, g as RotateSessionKeyParams, h as RotateSessionKeyResult, S as SessionEnvelopeChainMismatchError, i as SessionEnvelopeParseError, j as SessionEnvelopeSignerMismatchError, k as SessionEnvelopeVersionError, T as TransferJpycInputError, l as TransferJpycParams, m as TransferJpycResult, n as buildRevokeSessionKeyCall, o as createAgentSmartAccount, p as issueSessionKey, q as parseSessionEnvelope, r as restoreSessionAccount, s as revokeSessionKey, t as rotateSessionKey, u as serializeSessionEnvelope, v as transferJpyc } from './index-FxiMeqpl.cjs';
6
3
  import { S as SupportedChainId } from './index-2fEOL83n.cjs';
7
4
  export { C as ChainNotSupportedError, g as getChain, i as isSupportedChainId, s as supportedChains } from './index-2fEOL83n.cjs';
8
- export { C as ConfiguredKernelClient, I as IssueSessionKeyParams, K as KAWASEKIT_SESSION_ENVELOPE_VERSION, a as KawasekitSessionEnvelope, b as KawasekitSessionEnvelopeVersion, c as KawasekitSessionPolicySummary, R as RestoreSessionAccountParams, d as RevokeSessionKeyParams, e as RevokeSessionKeyResult, f as RotateSessionKeyParams, g as RotateSessionKeyResult, S as SessionEnvelopeChainMismatchError, h as SessionEnvelopeParseError, i as SessionEnvelopeSignerMismatchError, j as SessionEnvelopeVersionError, T as TransferJpycInputError, k as TransferJpycParams, l as TransferJpycResult, m as issueSessionKey, p as parseSessionEnvelope, r as restoreSessionAccount, n as revokeSessionKey, o as rotateSessionKey, s as serializeSessionEnvelope, t as transferJpyc } from './index-DFChv_fT.cjs';
5
+ import { CreateKernelAccountReturnType } from '@zerodev/sdk';
6
+ import * as viem from 'viem';
7
+ import { Chain, PublicClient, Transport, Address } from 'viem';
8
+ import { Policy } from '@zerodev/permissions';
9
9
  import { CallPolicyVersion } from '@zerodev/permissions/policies';
10
10
  export { CreateJpycDailyLimitPoliciesParams, ONE_DAY_SECONDS, createJpycDailyLimitPolicies } from './policy/index.cjs';
11
11
  export { C as CreateSpendingPolicyParams, P as PolicyDecision, S as SpendState, a as SpendingPolicy, b as SpendingPolicyConfigError, T as TokenLimit, c as createSpendingPolicy, e as evaluateSpendingPolicy, m as mergeSpendState } from './spending-policy-CwXcTFD_.cjs';
@@ -18,85 +18,9 @@ export { F as Facilitator, X as X402AssetTransferMethod, a as X402ExactEvmAuthor
18
18
  export { ClientPaymentEvent, HookCallback, ObservabilityEvent, ObservabilityEventBase, ObservabilityHooks, PaymentAcceptedEvent, PaymentRequiredEvent, SettleEvent, VerifyEvent, extractAcceptedNetworks, invokeHookSafely } from './observability/index.cjs';
19
19
  export { CanonicalRequestIdentity, CreateIdempotencyKeyBuilderParams, IdempotencyConfigError, IdempotencyKeyBuilder, IdempotencyRecordParseError, IdempotencyRecordVersionError, createIdempotencyKeyBuilder, deriveIdempotencyKey, normalizeIntentText } from './idempotency/index.cjs';
20
20
  export { C as CreateInMemoryIdempotencyStoreParams, I as IdempotencyLease, a as IdempotencyLookupResult, b as IdempotencyRecord, c as IdempotencyResponseSnapshot, d as IdempotencyStore, K as KAWASEKIT_IDEMPOTENCY_RECORD_VERSION, e as KawasekitIdempotencyRecordVersion, f as createInMemoryIdempotencyStore, p as parseIdempotencyRecord, s as serializeIdempotencyRecord } from './store-DPOLS6yp.cjs';
21
+ import '@zerodev/sdk/types';
21
22
  import 'viem/account-abstraction';
22
23
 
23
- /**
24
- * Agent smart account = Kernel v3.1 + ECDSA sudo validator + session-key
25
- * permission validator.
26
- *
27
- * The owner EOA keeps full control (sudo) and can revoke / rotate the session
28
- * key at any time. The session key is the day-to-day signer the AI agent
29
- * holds; whatever policies you attach (see {@link createJpycDailyLimitPolicies})
30
- * are enforced at the ERC-4337 validation phase by ZeroDev's
31
- * `PermissionValidator`. Violating userOps revert before execution — they
32
- * never spend any of the smart account's funds, and a sponsored bundler
33
- * cannot be tricked into paying for them either.
34
- *
35
- * @packageDocumentation
36
- */
37
-
38
- /** Parameters for {@link createAgentSmartAccount}. */
39
- interface CreateAgentSmartAccountParams {
40
- /**
41
- * viem `PublicClient` used to read on-chain state during account derivation.
42
- */
43
- readonly publicClient: PublicClient<Transport, Chain | undefined>;
44
- /**
45
- * The owner EOA. Retains sudo authority — can install new plugins,
46
- * revoke / rotate the session key, and bypass any policy.
47
- */
48
- readonly ownerSigner: LocalAccount;
49
- /**
50
- * The day-to-day signer the agent holds. Authority is limited to whatever
51
- * `policies` allow — by default it can do nothing.
52
- */
53
- readonly sessionKeySigner: LocalAccount;
54
- /**
55
- * ZeroDev policies (e.g. {@link createJpycDailyLimitPolicies}) the session
56
- * key must satisfy at userOp validation time.
57
- */
58
- readonly policies: readonly Policy[];
59
- /**
60
- * EntryPoint version + address. Defaults to v0.7 at the canonical
61
- * ERC-4337 entry-point address.
62
- */
63
- readonly entryPoint?: EntryPointType<"0.7">;
64
- /** Kernel version. Defaults to {@link KERNEL_V3_1}. */
65
- readonly kernelVersion?: GetKernelVersion<"0.7">;
66
- }
67
- /**
68
- * Builds a Kernel v3.1 smart account with sudo (owner) + regular (session key)
69
- * validators wired up.
70
- *
71
- * @example
72
- * ```ts
73
- * import { parseUnits } from "viem";
74
- * import { privateKeyToAccount } from "viem/accounts";
75
- * import {
76
- * createAgentSmartAccount,
77
- * createJpycDailyLimitPolicies,
78
- * getJpycAddress,
79
- * JPYC_DECIMALS,
80
- * polygonAmoy,
81
- * } from "kawasekit";
82
- *
83
- * const owner = privateKeyToAccount(process.env.OWNER_PRIVATE_KEY as `0x${string}`);
84
- * const sessionKey = privateKeyToAccount(process.env.SESSION_KEY_PRIVATE_KEY as `0x${string}`);
85
- *
86
- * const account = await createAgentSmartAccount({
87
- * publicClient,
88
- * ownerSigner: owner,
89
- * sessionKeySigner: sessionKey,
90
- * policies: createJpycDailyLimitPolicies({
91
- * jpycAddress: getJpycAddress(polygonAmoy.id),
92
- * maxPerTransfer: parseUnits("100", JPYC_DECIMALS),
93
- * maxTransfersPerDay: 10,
94
- * }),
95
- * });
96
- * ```
97
- */
98
- declare function createAgentSmartAccount(params: CreateAgentSmartAccountParams): Promise<CreateKernelAccountReturnType<"0.7">>;
99
-
100
24
  /**
101
25
  * Avalanche C-Chain — priority 3 production chain.
102
26
  *
@@ -553,6 +477,75 @@ declare const polygonAmoy: {
553
477
  verifyHash?: ((client: viem.Client, parameters: viem.VerifyHashActionParameters) => Promise<viem.VerifyHashActionReturnType>) | undefined;
554
478
  };
555
479
 
480
+ /**
481
+ * Build a gas-sponsored Kernel account client — a {@link ConfiguredKernelClient}
482
+ * whose UserOp gas is paid by the ZeroDev paymaster. Pass the returned client
483
+ * straight to {@link transferJpyc}; callers never construct a paymaster client or
484
+ * cast to {@link ConfiguredKernelClient}.
485
+ *
486
+ * @packageDocumentation
487
+ */
488
+
489
+ /**
490
+ * Optional sponsorship observability. Hooks fire through {@link invokeHookSafely},
491
+ * so a throwing hook never breaks sponsorship. The existing `ObservabilityHooks`
492
+ * is x402-facilitator-shaped (verify/settle); this is the paymaster-seam surface.
493
+ */
494
+ interface SponsoredKernelClientObservability {
495
+ /** Fired AFTER the paymaster GRANTS sponsorship for a userOp. */
496
+ readonly onSponsor?: (event: {
497
+ readonly account: Address;
498
+ }) => void;
499
+ /** Fired when the paymaster DECLINES sponsorship (the raw error then propagates). */
500
+ readonly onSponsorError?: (event: {
501
+ readonly account: Address;
502
+ readonly error: unknown;
503
+ }) => void;
504
+ }
505
+ /** Parameters for {@link createSponsoredKernelClient}. */
506
+ interface CreateSponsoredKernelClientParams {
507
+ /** A Kernel v0.7 account from `createAgentSmartAccount` or `restoreSessionAccount`. */
508
+ readonly account: CreateKernelAccountReturnType<"0.7">;
509
+ /** The viem chain the client operates on (e.g. `polygonAmoy`). */
510
+ readonly chain: Chain;
511
+ /**
512
+ * The ZeroDev RPC URL — used for BOTH the bundler and the paymaster (ZeroDev
513
+ * serves both from one project RPC). Build it from a project id with
514
+ * `zerodevRpcUrl(chain, projectId)`, or paste the dashboard URL.
515
+ */
516
+ readonly zerodevRpc: string;
517
+ /** Optional viem `PublicClient` for on-chain reads during userOp prep (recommended). */
518
+ readonly publicClient?: PublicClient<Transport, Chain>;
519
+ /** Optional sponsorship observability — granted / declined. */
520
+ readonly observability?: SponsoredKernelClientObservability;
521
+ }
522
+ /**
523
+ * Build a gas-sponsored Kernel account client. The returned
524
+ * {@link ConfiguredKernelClient} pays UserOp gas via the ZeroDev paymaster and is
525
+ * accepted directly by {@link transferJpyc} — no caller-side cast.
526
+ *
527
+ * @example
528
+ * ```ts
529
+ * import {
530
+ * createSponsoredKernelClient,
531
+ * polygonAmoy,
532
+ * restoreSessionAccount,
533
+ * transferJpyc,
534
+ * zerodevRpcUrl,
535
+ * } from "kawasekit";
536
+ *
537
+ * const account = await restoreSessionAccount({ publicClient, envelope, sessionKeySigner });
538
+ * const client = createSponsoredKernelClient({
539
+ * account,
540
+ * chain: polygonAmoy,
541
+ * zerodevRpc: zerodevRpcUrl(polygonAmoy, projectId),
542
+ * publicClient,
543
+ * });
544
+ * const { transactionHash } = await transferJpyc(client, { to, amount });
545
+ * ```
546
+ */
547
+ declare function createSponsoredKernelClient(params: CreateSponsoredKernelClientParams): ConfiguredKernelClient;
548
+
556
549
  /**
557
550
  * Buy-list → ZeroDev policy bundle for a **disposable, scoped session key**
558
551
  * (the Agent Commerce Hub authorization flow).
@@ -994,4 +987,4 @@ declare const jpycAbi: readonly [{
994
987
  }];
995
988
  }];
996
989
 
997
- export { type CreateAgentSmartAccountParams, type CreateBuyListPoliciesParams, JPYC_DECIMALS, JPYC_EIP712_DOMAIN_HINT, JPYC_V2_ADDRESS, type JpycDeployment, JpycNotAvailableError, SupportedChainId, avalanche, avalancheFuji, createAgentSmartAccount, createBuyListPolicies, ethereum, getJpycAddress, jpycAbi, jpycDeployments, kaia, kairos, polygon, polygonAmoy, sepolia };
990
+ export { ConfiguredKernelClient, type CreateBuyListPoliciesParams, type CreateSponsoredKernelClientParams, JPYC_DECIMALS, JPYC_EIP712_DOMAIN_HINT, JPYC_V2_ADDRESS, type JpycDeployment, JpycNotAvailableError, type SponsoredKernelClientObservability, SupportedChainId, avalanche, avalancheFuji, createBuyListPolicies, createSponsoredKernelClient, ethereum, getJpycAddress, jpycAbi, jpycDeployments, kaia, kairos, polygon, polygonAmoy, sepolia };
package/dist/index.d.ts CHANGED
@@ -1,11 +1,11 @@
1
- import { Policy } from '@zerodev/permissions';
2
- import { CreateKernelAccountReturnType } from '@zerodev/sdk';
3
- import { EntryPointType, GetKernelVersion } from '@zerodev/sdk/types';
4
- import * as viem from 'viem';
5
- import { PublicClient, Transport, Chain, LocalAccount, Address } from 'viem';
1
+ import { C as ConfiguredKernelClient } from './index-RsuBt-Xw.js';
2
+ export { A as AgentOwner, B as BuildRevokeSessionKeyCallParams, a as CreateAgentSmartAccountParams, I as IssueSessionKeyParams, K as KAWASEKIT_SESSION_ENVELOPE_VERSION, b as KawasekitSessionEnvelope, c as KawasekitSessionEnvelopeVersion, d as KawasekitSessionPolicySummary, R as RestoreSessionAccountParams, e as RevokeSessionKeyParams, f as RevokeSessionKeyResult, g as RotateSessionKeyParams, h as RotateSessionKeyResult, S as SessionEnvelopeChainMismatchError, i as SessionEnvelopeParseError, j as SessionEnvelopeSignerMismatchError, k as SessionEnvelopeVersionError, T as TransferJpycInputError, l as TransferJpycParams, m as TransferJpycResult, n as buildRevokeSessionKeyCall, o as createAgentSmartAccount, p as issueSessionKey, q as parseSessionEnvelope, r as restoreSessionAccount, s as revokeSessionKey, t as rotateSessionKey, u as serializeSessionEnvelope, v as transferJpyc } from './index-RsuBt-Xw.js';
6
3
  import { S as SupportedChainId } from './index-2fEOL83n.js';
7
4
  export { C as ChainNotSupportedError, g as getChain, i as isSupportedChainId, s as supportedChains } from './index-2fEOL83n.js';
8
- export { C as ConfiguredKernelClient, I as IssueSessionKeyParams, K as KAWASEKIT_SESSION_ENVELOPE_VERSION, a as KawasekitSessionEnvelope, b as KawasekitSessionEnvelopeVersion, c as KawasekitSessionPolicySummary, R as RestoreSessionAccountParams, d as RevokeSessionKeyParams, e as RevokeSessionKeyResult, f as RotateSessionKeyParams, g as RotateSessionKeyResult, S as SessionEnvelopeChainMismatchError, h as SessionEnvelopeParseError, i as SessionEnvelopeSignerMismatchError, j as SessionEnvelopeVersionError, T as TransferJpycInputError, k as TransferJpycParams, l as TransferJpycResult, m as issueSessionKey, p as parseSessionEnvelope, r as restoreSessionAccount, n as revokeSessionKey, o as rotateSessionKey, s as serializeSessionEnvelope, t as transferJpyc } from './index-CSpNGigO.js';
5
+ import { CreateKernelAccountReturnType } from '@zerodev/sdk';
6
+ import * as viem from 'viem';
7
+ import { Chain, PublicClient, Transport, Address } from 'viem';
8
+ import { Policy } from '@zerodev/permissions';
9
9
  import { CallPolicyVersion } from '@zerodev/permissions/policies';
10
10
  export { CreateJpycDailyLimitPoliciesParams, ONE_DAY_SECONDS, createJpycDailyLimitPolicies } from './policy/index.js';
11
11
  export { C as CreateSpendingPolicyParams, P as PolicyDecision, S as SpendState, a as SpendingPolicy, b as SpendingPolicyConfigError, T as TokenLimit, c as createSpendingPolicy, e as evaluateSpendingPolicy, m as mergeSpendState } from './spending-policy-BBgXDrVD.js';
@@ -18,85 +18,9 @@ export { F as Facilitator, X as X402AssetTransferMethod, a as X402ExactEvmAuthor
18
18
  export { ClientPaymentEvent, HookCallback, ObservabilityEvent, ObservabilityEventBase, ObservabilityHooks, PaymentAcceptedEvent, PaymentRequiredEvent, SettleEvent, VerifyEvent, extractAcceptedNetworks, invokeHookSafely } from './observability/index.js';
19
19
  export { CanonicalRequestIdentity, CreateIdempotencyKeyBuilderParams, IdempotencyConfigError, IdempotencyKeyBuilder, IdempotencyRecordParseError, IdempotencyRecordVersionError, createIdempotencyKeyBuilder, deriveIdempotencyKey, normalizeIntentText } from './idempotency/index.js';
20
20
  export { C as CreateInMemoryIdempotencyStoreParams, I as IdempotencyLease, a as IdempotencyLookupResult, b as IdempotencyRecord, c as IdempotencyResponseSnapshot, d as IdempotencyStore, K as KAWASEKIT_IDEMPOTENCY_RECORD_VERSION, e as KawasekitIdempotencyRecordVersion, f as createInMemoryIdempotencyStore, p as parseIdempotencyRecord, s as serializeIdempotencyRecord } from './store-DmdoV3Ii.js';
21
+ import '@zerodev/sdk/types';
21
22
  import 'viem/account-abstraction';
22
23
 
23
- /**
24
- * Agent smart account = Kernel v3.1 + ECDSA sudo validator + session-key
25
- * permission validator.
26
- *
27
- * The owner EOA keeps full control (sudo) and can revoke / rotate the session
28
- * key at any time. The session key is the day-to-day signer the AI agent
29
- * holds; whatever policies you attach (see {@link createJpycDailyLimitPolicies})
30
- * are enforced at the ERC-4337 validation phase by ZeroDev's
31
- * `PermissionValidator`. Violating userOps revert before execution — they
32
- * never spend any of the smart account's funds, and a sponsored bundler
33
- * cannot be tricked into paying for them either.
34
- *
35
- * @packageDocumentation
36
- */
37
-
38
- /** Parameters for {@link createAgentSmartAccount}. */
39
- interface CreateAgentSmartAccountParams {
40
- /**
41
- * viem `PublicClient` used to read on-chain state during account derivation.
42
- */
43
- readonly publicClient: PublicClient<Transport, Chain | undefined>;
44
- /**
45
- * The owner EOA. Retains sudo authority — can install new plugins,
46
- * revoke / rotate the session key, and bypass any policy.
47
- */
48
- readonly ownerSigner: LocalAccount;
49
- /**
50
- * The day-to-day signer the agent holds. Authority is limited to whatever
51
- * `policies` allow — by default it can do nothing.
52
- */
53
- readonly sessionKeySigner: LocalAccount;
54
- /**
55
- * ZeroDev policies (e.g. {@link createJpycDailyLimitPolicies}) the session
56
- * key must satisfy at userOp validation time.
57
- */
58
- readonly policies: readonly Policy[];
59
- /**
60
- * EntryPoint version + address. Defaults to v0.7 at the canonical
61
- * ERC-4337 entry-point address.
62
- */
63
- readonly entryPoint?: EntryPointType<"0.7">;
64
- /** Kernel version. Defaults to {@link KERNEL_V3_1}. */
65
- readonly kernelVersion?: GetKernelVersion<"0.7">;
66
- }
67
- /**
68
- * Builds a Kernel v3.1 smart account with sudo (owner) + regular (session key)
69
- * validators wired up.
70
- *
71
- * @example
72
- * ```ts
73
- * import { parseUnits } from "viem";
74
- * import { privateKeyToAccount } from "viem/accounts";
75
- * import {
76
- * createAgentSmartAccount,
77
- * createJpycDailyLimitPolicies,
78
- * getJpycAddress,
79
- * JPYC_DECIMALS,
80
- * polygonAmoy,
81
- * } from "kawasekit";
82
- *
83
- * const owner = privateKeyToAccount(process.env.OWNER_PRIVATE_KEY as `0x${string}`);
84
- * const sessionKey = privateKeyToAccount(process.env.SESSION_KEY_PRIVATE_KEY as `0x${string}`);
85
- *
86
- * const account = await createAgentSmartAccount({
87
- * publicClient,
88
- * ownerSigner: owner,
89
- * sessionKeySigner: sessionKey,
90
- * policies: createJpycDailyLimitPolicies({
91
- * jpycAddress: getJpycAddress(polygonAmoy.id),
92
- * maxPerTransfer: parseUnits("100", JPYC_DECIMALS),
93
- * maxTransfersPerDay: 10,
94
- * }),
95
- * });
96
- * ```
97
- */
98
- declare function createAgentSmartAccount(params: CreateAgentSmartAccountParams): Promise<CreateKernelAccountReturnType<"0.7">>;
99
-
100
24
  /**
101
25
  * Avalanche C-Chain — priority 3 production chain.
102
26
  *
@@ -553,6 +477,75 @@ declare const polygonAmoy: {
553
477
  verifyHash?: ((client: viem.Client, parameters: viem.VerifyHashActionParameters) => Promise<viem.VerifyHashActionReturnType>) | undefined;
554
478
  };
555
479
 
480
+ /**
481
+ * Build a gas-sponsored Kernel account client — a {@link ConfiguredKernelClient}
482
+ * whose UserOp gas is paid by the ZeroDev paymaster. Pass the returned client
483
+ * straight to {@link transferJpyc}; callers never construct a paymaster client or
484
+ * cast to {@link ConfiguredKernelClient}.
485
+ *
486
+ * @packageDocumentation
487
+ */
488
+
489
+ /**
490
+ * Optional sponsorship observability. Hooks fire through {@link invokeHookSafely},
491
+ * so a throwing hook never breaks sponsorship. The existing `ObservabilityHooks`
492
+ * is x402-facilitator-shaped (verify/settle); this is the paymaster-seam surface.
493
+ */
494
+ interface SponsoredKernelClientObservability {
495
+ /** Fired AFTER the paymaster GRANTS sponsorship for a userOp. */
496
+ readonly onSponsor?: (event: {
497
+ readonly account: Address;
498
+ }) => void;
499
+ /** Fired when the paymaster DECLINES sponsorship (the raw error then propagates). */
500
+ readonly onSponsorError?: (event: {
501
+ readonly account: Address;
502
+ readonly error: unknown;
503
+ }) => void;
504
+ }
505
+ /** Parameters for {@link createSponsoredKernelClient}. */
506
+ interface CreateSponsoredKernelClientParams {
507
+ /** A Kernel v0.7 account from `createAgentSmartAccount` or `restoreSessionAccount`. */
508
+ readonly account: CreateKernelAccountReturnType<"0.7">;
509
+ /** The viem chain the client operates on (e.g. `polygonAmoy`). */
510
+ readonly chain: Chain;
511
+ /**
512
+ * The ZeroDev RPC URL — used for BOTH the bundler and the paymaster (ZeroDev
513
+ * serves both from one project RPC). Build it from a project id with
514
+ * `zerodevRpcUrl(chain, projectId)`, or paste the dashboard URL.
515
+ */
516
+ readonly zerodevRpc: string;
517
+ /** Optional viem `PublicClient` for on-chain reads during userOp prep (recommended). */
518
+ readonly publicClient?: PublicClient<Transport, Chain>;
519
+ /** Optional sponsorship observability — granted / declined. */
520
+ readonly observability?: SponsoredKernelClientObservability;
521
+ }
522
+ /**
523
+ * Build a gas-sponsored Kernel account client. The returned
524
+ * {@link ConfiguredKernelClient} pays UserOp gas via the ZeroDev paymaster and is
525
+ * accepted directly by {@link transferJpyc} — no caller-side cast.
526
+ *
527
+ * @example
528
+ * ```ts
529
+ * import {
530
+ * createSponsoredKernelClient,
531
+ * polygonAmoy,
532
+ * restoreSessionAccount,
533
+ * transferJpyc,
534
+ * zerodevRpcUrl,
535
+ * } from "kawasekit";
536
+ *
537
+ * const account = await restoreSessionAccount({ publicClient, envelope, sessionKeySigner });
538
+ * const client = createSponsoredKernelClient({
539
+ * account,
540
+ * chain: polygonAmoy,
541
+ * zerodevRpc: zerodevRpcUrl(polygonAmoy, projectId),
542
+ * publicClient,
543
+ * });
544
+ * const { transactionHash } = await transferJpyc(client, { to, amount });
545
+ * ```
546
+ */
547
+ declare function createSponsoredKernelClient(params: CreateSponsoredKernelClientParams): ConfiguredKernelClient;
548
+
556
549
  /**
557
550
  * Buy-list → ZeroDev policy bundle for a **disposable, scoped session key**
558
551
  * (the Agent Commerce Hub authorization flow).
@@ -994,4 +987,4 @@ declare const jpycAbi: readonly [{
994
987
  }];
995
988
  }];
996
989
 
997
- export { type CreateAgentSmartAccountParams, type CreateBuyListPoliciesParams, JPYC_DECIMALS, JPYC_EIP712_DOMAIN_HINT, JPYC_V2_ADDRESS, type JpycDeployment, JpycNotAvailableError, SupportedChainId, avalanche, avalancheFuji, createAgentSmartAccount, createBuyListPolicies, ethereum, getJpycAddress, jpycAbi, jpycDeployments, kaia, kairos, polygon, polygonAmoy, sepolia };
990
+ export { ConfiguredKernelClient, type CreateBuyListPoliciesParams, type CreateSponsoredKernelClientParams, JPYC_DECIMALS, JPYC_EIP712_DOMAIN_HINT, JPYC_V2_ADDRESS, type JpycDeployment, JpycNotAvailableError, type SponsoredKernelClientObservability, SupportedChainId, avalanche, avalancheFuji, createBuyListPolicies, createSponsoredKernelClient, ethereum, getJpycAddress, jpycAbi, jpycDeployments, kaia, kairos, polygon, polygonAmoy, sepolia };
package/dist/index.js CHANGED
@@ -1,10 +1,10 @@
1
- export { TransferJpycInputError, createBuyListPolicies, transferJpyc } from './chunk-Y2LOACWO.js';
1
+ export { TransferJpycInputError, createBuyListPolicies, createSponsoredKernelClient, transferJpyc } from './chunk-DMP7YFGA.js';
2
2
  export { X402_DEFAULT_AUTHORIZATION_LIFETIME_SECONDS, X402_FACILITATOR_ERROR_CODES, createCoinbaseFacilitator, createHttpFacilitator, createSelfFacilitator, createX402PaymentSigner, deriveReceiptTimeoutMs, wrapFetch } from './chunk-P5563RGP.js';
3
3
  export { X402_DEFAULT_MAX_TIMEOUT_SECONDS, X402_HEADER_IDEMPOTENCY_KEY, X402_HEADER_PAYMENT_REQUIRED, X402_HEADER_PAYMENT_RESPONSE, X402_HEADER_PAYMENT_SIGNATURE, buildPaymentRequiredResponse, buildPaymentRequirements, createX402Handler, decodePaymentRequiredHeader, decodePaymentResponseHeader, decodePaymentSignatureHeader, encodePaymentRequiredHeader, encodePaymentResponseHeader, encodePaymentSignatureHeader } from './chunk-PVUKX6IF.js';
4
4
  export { extractAcceptedNetworks, invokeHookSafely } from './chunk-LEHWRDVS.js';
5
5
  export { createIdempotencyKeyBuilder, createInMemoryIdempotencyStore, deriveIdempotencyKey, normalizeIntentText } from './chunk-TTX3RBIZ.js';
6
6
  export { IdempotencyConfigError, IdempotencyRecordParseError, IdempotencyRecordVersionError, KAWASEKIT_IDEMPOTENCY_RECORD_VERSION, X402_VERSION, chainIdToX402Network, isX402Network, parseIdempotencyRecord, serializeIdempotencyRecord, x402NetworkToChainId } from './chunk-QHUCU5YX.js';
7
- export { KAWASEKIT_SESSION_ENVELOPE_VERSION, SessionEnvelopeChainMismatchError, SessionEnvelopeParseError, SessionEnvelopeSignerMismatchError, SessionEnvelopeVersionError, createAgentSmartAccount, issueSessionKey, parseSessionEnvelope, restoreSessionAccount, revokeSessionKey, rotateSessionKey, serializeSessionEnvelope } from './chunk-N3CVLISJ.js';
7
+ export { KAWASEKIT_SESSION_ENVELOPE_VERSION, SessionEnvelopeChainMismatchError, SessionEnvelopeParseError, SessionEnvelopeSignerMismatchError, SessionEnvelopeVersionError, buildRevokeSessionKeyCall, createAgentSmartAccount, issueSessionKey, parseSessionEnvelope, restoreSessionAccount, revokeSessionKey, rotateSessionKey, serializeSessionEnvelope } from './chunk-KYVAOUQV.js';
8
8
  export { WIRE_VERSION, canonicalRequestBytes, createLocalPolicyGatedSigner, createMpc2pPolicyGatedSigner, toWireIntent } from './chunk-NY6VLXQB.js';
9
9
  export { CoSignUnavailableError, PolicyGatedSignerConfigError, assertNonBypassable, authorizationDeadlineFromNow, cancelAuthorizationTypes, deriveAuthorizationNonce, generateAuthorizationNonce, getKnownAssetDomain, listKnownAssetIds, receiveWithAuthorizationTypes, requireNonBypassable, resolvedAssetToEip3009Domain, signCancelAuthorization, signReceiveWithAuthorization, signTransferWithAuthorization, transferWithAuthorizationTypes } from './chunk-VJUXTVSW.js';
10
10
  export { X402InvalidConfigError, X402InvalidPayloadError, X402PolicyRejectedError } from './chunk-WMVJNPX2.js';
@@ -3,10 +3,10 @@
3
3
  var viem = require('viem');
4
4
  var chains = require('viem/chains');
5
5
  var permissions = require('@zerodev/permissions');
6
+ var sdk = require('@zerodev/sdk');
6
7
  var constants = require('@zerodev/sdk/constants');
7
8
  var ecdsaValidator = require('@zerodev/ecdsa-validator');
8
9
  var signers = require('@zerodev/permissions/signers');
9
- var sdk = require('@zerodev/sdk');
10
10
 
11
11
  // src/session/envelope.ts
12
12
  var avalanche = {
@@ -222,28 +222,27 @@ function parseSessionEnvelope(input) {
222
222
  }
223
223
  return base;
224
224
  }
225
- async function createAgentSmartAccount(params) {
226
- const entryPoint = params.entryPoint ?? constants.getEntryPoint("0.7");
227
- const kernelVersion = params.kernelVersion ?? constants.KERNEL_V3_1;
228
- const sudoValidator = await ecdsaValidator.signerToEcdsaValidator(params.publicClient, {
225
+ async function resolveSudoValidator(params) {
226
+ if (params.ownerSigner !== void 0 && params.sudoValidator !== void 0) {
227
+ throw new Error("kawasekit: pass exactly one of `ownerSigner` or `sudoValidator`, not both.");
228
+ }
229
+ if (params.sudoValidator !== void 0) return params.sudoValidator;
230
+ if (params.ownerSigner === void 0) {
231
+ throw new Error("kawasekit: pass one of `ownerSigner` (ECDSA) or `sudoValidator` (pre-built).");
232
+ }
233
+ return ecdsaValidator.signerToEcdsaValidator(params.publicClient, {
229
234
  signer: params.ownerSigner,
230
- entryPoint,
231
- kernelVersion
235
+ entryPoint: params.entryPoint,
236
+ kernelVersion: params.kernelVersion
232
237
  });
233
- const modularSessionSigner = await signers.toECDSASigner({ signer: params.sessionKeySigner });
234
- const permissionValidator = await permissions.toPermissionValidator(params.publicClient, {
235
- signer: modularSessionSigner,
238
+ }
239
+ async function buildSessionPermissionValidator(params) {
240
+ const signer = await signers.toECDSASigner({ signer: params.sessionKeySigner });
241
+ return permissions.toPermissionValidator(params.publicClient, {
242
+ signer,
236
243
  policies: [...params.policies],
237
- entryPoint,
238
- kernelVersion
239
- });
240
- return sdk.createKernelAccount(params.publicClient, {
241
- plugins: {
242
- sudo: sudoValidator,
243
- regular: permissionValidator
244
- },
245
- entryPoint,
246
- kernelVersion
244
+ entryPoint: params.entryPoint,
245
+ kernelVersion: params.kernelVersion
247
246
  });
248
247
  }
249
248
 
@@ -258,15 +257,28 @@ async function issueSessionKey(params) {
258
257
  const supportedChainId = chainId;
259
258
  const entryPoint = params.entryPoint ?? constants.getEntryPoint("0.7");
260
259
  const kernelVersion = params.kernelVersion ?? constants.KERNEL_V3_1;
261
- const account = await createAgentSmartAccount({
260
+ const sudoValidator = await resolveSudoValidator({
262
261
  publicClient: params.publicClient,
263
262
  ownerSigner: params.ownerSigner,
263
+ sudoValidator: params.sudoValidator,
264
+ entryPoint,
265
+ kernelVersion
266
+ });
267
+ const permissionValidator = await buildSessionPermissionValidator({
268
+ publicClient: params.publicClient,
264
269
  sessionKeySigner: params.sessionKeySigner,
265
270
  policies: params.policies,
266
271
  entryPoint,
267
272
  kernelVersion
268
273
  });
269
- const serialized = await permissions.serializePermissionAccount(account);
274
+ const account = await sdk.createKernelAccount(params.publicClient, {
275
+ plugins: { sudo: sudoValidator, regular: permissionValidator },
276
+ ...params.address !== void 0 ? { address: params.address } : {},
277
+ entryPoint,
278
+ kernelVersion
279
+ });
280
+ const enableSignature = params.approveEnable ? await params.approveEnable(permissionValidator) : void 0;
281
+ const serialized = enableSignature ? await permissions.serializePermissionAccount(account, void 0, enableSignature) : await permissions.serializePermissionAccount(account);
270
282
  const base = {
271
283
  kawasekitVersion: KAWASEKIT_SESSION_ENVELOPE_VERSION,
272
284
  chainId: supportedChainId,
@@ -342,10 +354,10 @@ async function revokeSessionKey(params) {
342
354
  "revokeSessionKey: ownerKernelClient.client is undefined \u2014 pass `client: publicClient` when constructing the Kernel client so the validator can be reconstructed."
343
355
  );
344
356
  }
345
- const modularSigner = await signers.toECDSASigner({ signer: sessionKeySigner });
346
- const permissionPlugin = await permissions.toPermissionValidator(ownerKernelClient.client, {
347
- signer: modularSigner,
348
- policies: [...policies],
357
+ const permissionPlugin = await buildSessionPermissionValidator({
358
+ publicClient: ownerKernelClient.client,
359
+ sessionKeySigner,
360
+ policies,
349
361
  entryPoint,
350
362
  kernelVersion
351
363
  });
@@ -364,6 +376,9 @@ async function revokeSessionKey(params) {
364
376
  success: receipt.success
365
377
  };
366
378
  }
379
+ viem.parseAbi([
380
+ "function uninstallValidation(bytes21 vId, bytes deinitData, bytes hookDeinitData)"
381
+ ]);
367
382
 
368
383
  // src/session/rotate.ts
369
384
  async function rotateSessionKey(params) {