kawasekit 0.5.0 → 0.7.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.
@@ -698,19 +698,36 @@ async function transferJpyc(kernelClient, params) {
698
698
  success: receipt.success
699
699
  };
700
700
  }
701
- var ONE_DAY_SECONDS = 86400;
702
- function createJpycDailyLimitPolicies(params) {
701
+ function normalizeRecipientAllowlist(allowlist) {
702
+ const seen = /* @__PURE__ */ new Set();
703
+ const normalized = [];
704
+ for (const entry of allowlist) {
705
+ const checksummed = viem.getAddress(entry);
706
+ if (!seen.has(checksummed)) {
707
+ seen.add(checksummed);
708
+ normalized.push(checksummed);
709
+ }
710
+ }
711
+ return normalized;
712
+ }
713
+
714
+ // src/policy/jpyc-call-policy.ts
715
+ function buildJpycTransferCallPolicy(params) {
703
716
  if (params.maxPerTransfer <= 0n) {
717
+ throw new Error(`maxPerTransfer must be positive, got ${params.maxPerTransfer}.`);
718
+ }
719
+ const recipients = params.recipientAllowlist === void 0 || params.recipientAllowlist === "any" ? null : normalizeRecipientAllowlist(params.recipientAllowlist);
720
+ if (recipients !== null && recipients.length === 0) {
704
721
  throw new Error(
705
- `createJpycDailyLimitPolicies: maxPerTransfer must be positive, got ${params.maxPerTransfer}.`
722
+ 'recipientAllowlist must not be empty \u2014 omit it or pass "any" to allow any recipient.'
706
723
  );
707
724
  }
708
- if (!Number.isInteger(params.maxTransfersPerDay) || params.maxTransfersPerDay < 1) {
725
+ if (recipients !== null && params.callPolicyVersion === policies.CallPolicyVersion.V0_0_1) {
709
726
  throw new Error(
710
- `createJpycDailyLimitPolicies: maxTransfersPerDay must be a positive integer, got ${params.maxTransfersPerDay}.`
727
+ "recipientAllowlist requires callPolicyVersion V0_0_2 or later (the ONE_OF condition is unsupported on V0_0_1)."
711
728
  );
712
729
  }
713
- const callPolicy = policies.toCallPolicy({
730
+ return policies.toCallPolicy({
714
731
  policyVersion: params.callPolicyVersion ?? policies.CallPolicyVersion.V0_0_4,
715
732
  permissions: [
716
733
  {
@@ -718,8 +735,9 @@ function createJpycDailyLimitPolicies(params) {
718
735
  abi: jpycAbi,
719
736
  functionName: "transfer",
720
737
  args: [
721
- // Recipient: any address allowed (no allowlist in M2).
722
- null,
738
+ // Recipient (`to`): unrestricted (`null`) unless an allowlist resolved
739
+ // above, in which case it is constrained via the ONE_OF condition.
740
+ recipients === null ? null : { condition: policies.ParamCondition.ONE_OF, value: recipients },
723
741
  // value: must be ≤ maxPerTransfer.
724
742
  {
725
743
  condition: policies.ParamCondition.LESS_THAN_OR_EQUAL,
@@ -729,6 +747,20 @@ function createJpycDailyLimitPolicies(params) {
729
747
  }
730
748
  ]
731
749
  });
750
+ }
751
+ var ONE_DAY_SECONDS = 86400;
752
+ function createJpycDailyLimitPolicies(params) {
753
+ if (!Number.isInteger(params.maxTransfersPerDay) || params.maxTransfersPerDay < 1) {
754
+ throw new Error(
755
+ `createJpycDailyLimitPolicies: maxTransfersPerDay must be a positive integer, got ${params.maxTransfersPerDay}.`
756
+ );
757
+ }
758
+ const callPolicy = buildJpycTransferCallPolicy({
759
+ jpycAddress: params.jpycAddress,
760
+ maxPerTransfer: params.maxPerTransfer,
761
+ recipientAllowlist: params.recipientAllowlist,
762
+ callPolicyVersion: params.callPolicyVersion
763
+ });
732
764
  const rateLimitPolicy = policies.toRateLimitPolicy({
733
765
  interval: ONE_DAY_SECONDS,
734
766
  count: params.maxTransfersPerDay
@@ -1643,7 +1675,7 @@ function registerTransferCommand(program2) {
1643
1675
  }
1644
1676
 
1645
1677
  // cli/index.ts
1646
- var CLI_VERSION = "0.5.0" ;
1678
+ var CLI_VERSION = "0.7.0" ;
1647
1679
  var program = new commander.Command();
1648
1680
  program.name("kawasekit").description(
1649
1681
  "kawasekit \u2014 CLI for the kawasekit SDK (AI-agent stablecoin payments, Japan-first, JPYC-native)."