@dev.sail.money/sailor 0.0.2-17 → 0.0.2-19

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.
Files changed (172) hide show
  1. package/README.md +28 -1
  2. package/package.json +1 -1
  3. package/packages/cli/dist/server.cjs +933 -93
  4. package/packages/sdk/dist/intelligence.d.ts +1 -1
  5. package/packages/sdk/dist/intelligence.js +1 -1
  6. package/packages/ui/dist/assets/Arc-VDBY7LNS-BChRXCXW.js +0 -1
  7. package/packages/ui/dist/assets/Brave-BRAKJXDS-mq-Xo37j.js +0 -1
  8. package/packages/ui/dist/assets/Browser-76IHF3Y2-BMhRaC5Z.js +0 -1
  9. package/packages/ui/dist/assets/Chrome-65Q5P54Y-DR9MQEVr.js +0 -1
  10. package/packages/ui/dist/assets/Edge-XSPUTORV-DEoZslQE.js +0 -1
  11. package/packages/ui/dist/assets/Firefox-AAHGJQIP-Bp_Hm04m.js +0 -1
  12. package/packages/ui/dist/assets/Linux-OO4TNCLJ-B0aw93n9.js +0 -1
  13. package/packages/ui/dist/assets/Macos-MW4AE7LN-Vvm8Drw3.js +0 -1
  14. package/packages/ui/dist/assets/Opera-KQZLSACL-Cwv5MDFy.js +0 -1
  15. package/packages/ui/dist/assets/Safari-ZPL37GXR-C4Ggg6rz.js +0 -1
  16. package/packages/ui/dist/assets/Windows-PPTHQER6-BlyV2p7Y.js +0 -1
  17. package/packages/ui/dist/assets/add-BHtIsGoW.js +0 -15
  18. package/packages/ui/dist/assets/all-wallets-BH8IiQp_.js +0 -6
  19. package/packages/ui/dist/assets/apechain-SX5YFU6N-q5qBv-mp.js +0 -1
  20. package/packages/ui/dist/assets/app-store-C7je0Hvt.js +0 -17
  21. package/packages/ui/dist/assets/apple-C24YGi7n.js +0 -18
  22. package/packages/ui/dist/assets/ar_AR-LIPSOZP5-BQrIDibT.js +0 -1519
  23. package/packages/ui/dist/assets/arbitrum-WURIBY6W-CqVkHBr5.js +0 -1
  24. package/packages/ui/dist/assets/arrow-bottom-NmB75e6T.js +0 -8
  25. package/packages/ui/dist/assets/arrow-bottom-circle-D9vkbcGm.js +0 -11
  26. package/packages/ui/dist/assets/arrow-left-BXX7egmu.js +0 -8
  27. package/packages/ui/dist/assets/arrow-right-CL5l1ER5.js +0 -8
  28. package/packages/ui/dist/assets/arrow-top-B3NcsHvl.js +0 -8
  29. package/packages/ui/dist/assets/assets-Q6ZU7ZJ5-P8HioiAD.js +0 -1
  30. package/packages/ui/dist/assets/avalanche-KOMJD3XY-Dsn_JPR4.js +0 -1
  31. package/packages/ui/dist/assets/bank-DyxCAL_C.js +0 -14
  32. package/packages/ui/dist/assets/base-OAXLRA4F-CoYTVIiL.js +0 -1
  33. package/packages/ui/dist/assets/base-QS6CYWIN-CsjdbWCf.js +0 -1
  34. package/packages/ui/dist/assets/basic-CnjXr1WW.js +0 -2128
  35. package/packages/ui/dist/assets/berachain-NJECWIVC-DumxnFvf.js +0 -1
  36. package/packages/ui/dist/assets/blast-V555OVXZ-BbhJh1tj.js +0 -1
  37. package/packages/ui/dist/assets/browser-C1sQ7PjQ.js +0 -14
  38. package/packages/ui/dist/assets/bsc-N647EYR2-B2nLKXWV.js +0 -1
  39. package/packages/ui/dist/assets/card-DUcWbZgm.js +0 -14
  40. package/packages/ui/dist/assets/ccip-ZC8164Ut.js +0 -1
  41. package/packages/ui/dist/assets/celo-GEP4TUHG-CenIBYLU.js +0 -1
  42. package/packages/ui/dist/assets/checkmark-BFIb0gZI.js +0 -11
  43. package/packages/ui/dist/assets/checkmark-bold-GxOovLvw.js +0 -8
  44. package/packages/ui/dist/assets/chevron-bottom-BWFm5iOO.js +0 -8
  45. package/packages/ui/dist/assets/chevron-left-Dw1vrfPS.js +0 -8
  46. package/packages/ui/dist/assets/chevron-right-Lj-4a_f7.js +0 -8
  47. package/packages/ui/dist/assets/chevron-top-CNtyUs8e.js +0 -8
  48. package/packages/ui/dist/assets/chrome-store-BFjfxT2g.js +0 -61
  49. package/packages/ui/dist/assets/clock-upNWT1cC.js +0 -8
  50. package/packages/ui/dist/assets/close-BXOvqFtp.js +0 -8
  51. package/packages/ui/dist/assets/coinPlaceholder-IDofua41.js +0 -8
  52. package/packages/ui/dist/assets/compass-Du2xGTuZ.js +0 -8
  53. package/packages/ui/dist/assets/connect-UA7M4XW6-IY3X6Bmr.js +0 -1
  54. package/packages/ui/dist/assets/copy-thfTJs3L.js +0 -15
  55. package/packages/ui/dist/assets/core-C8jSlwHY.js +0 -907
  56. package/packages/ui/dist/assets/create-FASO7PVG-D_rvSpre.js +0 -1
  57. package/packages/ui/dist/assets/cronos-HJPAQTAE-BEOvlOC4.js +0 -1
  58. package/packages/ui/dist/assets/cursor-Dc-Hxk5X.js +0 -3
  59. package/packages/ui/dist/assets/cursor-transparent-DGzNzXxd.js +0 -12
  60. package/packages/ui/dist/assets/de_DE-YE3KOFHU-BRt5ztUe.js +0 -1519
  61. package/packages/ui/dist/assets/degen-FQQ4XGHB-CeHTs88l.js +0 -1
  62. package/packages/ui/dist/assets/desktop-BozY9d6T.js +0 -9
  63. package/packages/ui/dist/assets/disconnect-B-oC8Fzu.js +0 -8
  64. package/packages/ui/dist/assets/discord-CpgvcuGY.js +0 -17
  65. package/packages/ui/dist/assets/es_419-7LMPU7G4-DH7rM0yQ.js +0 -1519
  66. package/packages/ui/dist/assets/ethereum-RGGVA4PY-SWGOlkuk.js +0 -1
  67. package/packages/ui/dist/assets/etherscan-DB-rL796.js +0 -6
  68. package/packages/ui/dist/assets/events-i9ztcj9W.js +0 -1
  69. package/packages/ui/dist/assets/exclamation-triangle-Ct0mzv3Y.js +0 -4
  70. package/packages/ui/dist/assets/extension-CubWAVae.js +0 -8
  71. package/packages/ui/dist/assets/external-link-CgYSHh7f.js +0 -8
  72. package/packages/ui/dist/assets/facebook-DI_kGikU.js +0 -26
  73. package/packages/ui/dist/assets/fallback-CtKplO-p.js +0 -1
  74. package/packages/ui/dist/assets/farcaster-PEZAXYqi.js +0 -12
  75. package/packages/ui/dist/assets/filters-D6NPvINV.js +0 -8
  76. package/packages/ui/dist/assets/flow-5FQJFCTK-CUie2reO.js +0 -1
  77. package/packages/ui/dist/assets/fr_FR-VBJP3ZLL-B-_ocunw.js +0 -1519
  78. package/packages/ui/dist/assets/github-BRk_ww3A.js +0 -18
  79. package/packages/ui/dist/assets/gnosis-37ZC4RBL-B137OtHZ.js +0 -1
  80. package/packages/ui/dist/assets/google-3tO0AiTd.js +0 -18
  81. package/packages/ui/dist/assets/gravity-J5YQHTYH-Bj6B0uod.js +0 -1
  82. package/packages/ui/dist/assets/hardhat-TX56IT5N-CV1FY-wE.js +0 -1
  83. package/packages/ui/dist/assets/help-circle-DtbseC_9.js +0 -12
  84. package/packages/ui/dist/assets/hi_IN-WBVD5XYI-D73g2UFs.js +0 -1519
  85. package/packages/ui/dist/assets/hyperevm-VKPAA4SA-CHwraEsx.js +0 -1
  86. package/packages/ui/dist/assets/id-DNQF-HQS.js +0 -12
  87. package/packages/ui/dist/assets/id_ID-SBYANJ7G-Cjpa4ay6.js +0 -1519
  88. package/packages/ui/dist/assets/image-D4l2W9gw.js +0 -4
  89. package/packages/ui/dist/assets/index-A8Mpr5Rm.js +0 -1
  90. package/packages/ui/dist/assets/index-BnYYo2S0.js +0 -16
  91. package/packages/ui/dist/assets/index-CKxgNxS9.css +0 -1
  92. package/packages/ui/dist/assets/index-D-PqJKnq.js +0 -1
  93. package/packages/ui/dist/assets/index-L6zhWbjO.js +0 -2103
  94. package/packages/ui/dist/assets/index-cl7Zazmz.js +0 -1
  95. package/packages/ui/dist/assets/index-vIXQ5sb2.js +0 -395
  96. package/packages/ui/dist/assets/index.es-BxPfiRyX.js +0 -26
  97. package/packages/ui/dist/assets/info-DAwJNl3r.js +0 -3
  98. package/packages/ui/dist/assets/info-circle-lvyXhzfD.js +0 -12
  99. package/packages/ui/dist/assets/ink-FZMYZWHG-62p-5IK5.js +0 -1
  100. package/packages/ui/dist/assets/ja_JP-ZRMWJV3I-DXbifiMm.js +0 -1519
  101. package/packages/ui/dist/assets/kaia-65D2U3PU-JmuLQ4gC.js +0 -1
  102. package/packages/ui/dist/assets/ko_KR-FR54RFUG-upinSHjQ.js +0 -1519
  103. package/packages/ui/dist/assets/lightbulb-BkrBfCQo.js +0 -3
  104. package/packages/ui/dist/assets/linea-QRMVQ5DY-DuI3vv0d.js +0 -1
  105. package/packages/ui/dist/assets/login-UP3DZBGS-Db_wM5oQ.js +0 -1
  106. package/packages/ui/dist/assets/mail-CrRh9uAx.js +0 -8
  107. package/packages/ui/dist/assets/manta-SI27YFEJ-CpVOKa06.js +0 -1
  108. package/packages/ui/dist/assets/mantle-CKIUT334-DR2WgqzU.js +0 -1
  109. package/packages/ui/dist/assets/metaMaskWallet-EI6MED72-D5HFOsnz.js +0 -1
  110. package/packages/ui/dist/assets/metamask-sdk-SH1hL_jU.js +0 -542
  111. package/packages/ui/dist/assets/mobile-Cq71LsIe.js +0 -9
  112. package/packages/ui/dist/assets/monad-4KWC6TSS-DVXSkpiz.js +0 -1
  113. package/packages/ui/dist/assets/more-CzCaTRQT.js +0 -11
  114. package/packages/ui/dist/assets/ms_MY-EZSGYYYQ-4cPLK-3L.js +0 -1519
  115. package/packages/ui/dist/assets/native-CJ5et6AR.js +0 -1
  116. package/packages/ui/dist/assets/network-placeholder-B7ilsHLj.js +0 -14
  117. package/packages/ui/dist/assets/nftPlaceholder-DYo4ThqR.js +0 -8
  118. package/packages/ui/dist/assets/off-CVXtiamx.js +0 -8
  119. package/packages/ui/dist/assets/optimism-HAF2GUT7-ec6Nqxs9.js +0 -1
  120. package/packages/ui/dist/assets/parseSignature-DDqjAA1x.js +0 -1
  121. package/packages/ui/dist/assets/play-store-Bxo5wDfY.js +0 -32
  122. package/packages/ui/dist/assets/plus-ByOmN8u0.js +0 -13
  123. package/packages/ui/dist/assets/polygon-WW6ZI7PM-DXlmm4L1.js +0 -1
  124. package/packages/ui/dist/assets/pt_BR-JQFQ3P4L-DOHfdcA2.js +0 -1519
  125. package/packages/ui/dist/assets/qr-code-BLcaF-bG.js +0 -6
  126. package/packages/ui/dist/assets/rainbowWallet-O26YNBMX-DUhYus-9.js +0 -1
  127. package/packages/ui/dist/assets/recycle-horizontal-R32E5-sJ.js +0 -9
  128. package/packages/ui/dist/assets/refresh-DV3LEAlt.js +0 -8
  129. package/packages/ui/dist/assets/refresh-S4T5V5GX-CwqIaaxK.js +0 -1
  130. package/packages/ui/dist/assets/reown-logo-CzXV-ULV.js +0 -12
  131. package/packages/ui/dist/assets/ronin-EMCPYXZT-N-QBHZdV.js +0 -1
  132. package/packages/ui/dist/assets/ru_RU-Z42UEJBP-Cvb2oWxQ.js +0 -1519
  133. package/packages/ui/dist/assets/safeWallet-5MNKTR5Z-D-5imDLD.js +0 -1
  134. package/packages/ui/dist/assets/sanko-RHQYXGM5-OX010CbN.js +0 -1
  135. package/packages/ui/dist/assets/scan-4UYSQ56Q-CjMz6-XC.js +0 -1
  136. package/packages/ui/dist/assets/scroll-5OBGQVOV-DJFECiai.js +0 -1
  137. package/packages/ui/dist/assets/search-C4ArXMR1.js +0 -8
  138. package/packages/ui/dist/assets/secp256k1-CigFWhM4.js +0 -1
  139. package/packages/ui/dist/assets/send-nlnStDog.js +0 -15
  140. package/packages/ui/dist/assets/sign-A7IJEUT5-CGsRnPrd.js +0 -1
  141. package/packages/ui/dist/assets/superposition-HG6MMR2Y-bRkgatRO.js +0 -1
  142. package/packages/ui/dist/assets/swapHorizontal-I-zOG8Yz.js +0 -8
  143. package/packages/ui/dist/assets/swapHorizontalBold-5VnEg1-A.js +0 -8
  144. package/packages/ui/dist/assets/swapHorizontalMedium-DK837_PS.js +0 -16
  145. package/packages/ui/dist/assets/swapHorizontalRoundedBold-EcrRbYtU.js +0 -8
  146. package/packages/ui/dist/assets/swapVertical--ZRk6QJu.js +0 -8
  147. package/packages/ui/dist/assets/telegram-DQOf_6vw.js +0 -16
  148. package/packages/ui/dist/assets/th_TH-4YB4VSB2-BUipNP-V.js +0 -1519
  149. package/packages/ui/dist/assets/three-dots-RaCioLRu.js +0 -5
  150. package/packages/ui/dist/assets/tr_TR-5FKHPPIO-D5jTpIm9.js +0 -1519
  151. package/packages/ui/dist/assets/twitch-CXMYNleq.js +0 -18
  152. package/packages/ui/dist/assets/twitterIcon-CafuOSTc.js +0 -6
  153. package/packages/ui/dist/assets/uk_UA-ZD4IBC52-DgnQrpzl.js +0 -1519
  154. package/packages/ui/dist/assets/unichain-C5BWO2ZY-BfguYsnu.js +0 -1
  155. package/packages/ui/dist/assets/verify-B5SZMJAG.js +0 -8
  156. package/packages/ui/dist/assets/verify-filled-BrlLx5ry.js +0 -8
  157. package/packages/ui/dist/assets/vi_VN-5EVRZKLY-x078672g.js +0 -1519
  158. package/packages/ui/dist/assets/w3m-modal-57iUR7pY.js +0 -642
  159. package/packages/ui/dist/assets/wallet-Fu8Tn5wK.js +0 -8
  160. package/packages/ui/dist/assets/wallet-placeholder-BYpbF3M_.js +0 -14
  161. package/packages/ui/dist/assets/walletConnectWallet-YHWKVTDY-D3lyiczV.js +0 -1
  162. package/packages/ui/dist/assets/walletconnect-BT9pozGB.js +0 -30
  163. package/packages/ui/dist/assets/warning-circle-BQ8awbZW.js +0 -12
  164. package/packages/ui/dist/assets/x-D21DQ5BR.js +0 -12
  165. package/packages/ui/dist/assets/xdc-KJ3TDBYO-DNV6zchh.js +0 -1
  166. package/packages/ui/dist/assets/zetachain-TLDS5IPW-Udhyw16T.js +0 -1
  167. package/packages/ui/dist/assets/zh_CN-4XK5YJPR-Bt6Yz5Ek.js +0 -1519
  168. package/packages/ui/dist/assets/zh_HK-N4YN2WSI-Cvzl1V16.js +0 -1519
  169. package/packages/ui/dist/assets/zh_TW-CNCRXH6Z-BNelatfN.js +0 -1519
  170. package/packages/ui/dist/assets/zksync-DH7HK5U4-Dt4usFw6.js +0 -1
  171. package/packages/ui/dist/assets/zora-FYL5H3IO-iB4wygST.js +0 -1
  172. package/packages/ui/dist/index.html +0 -14
@@ -5113,7 +5113,7 @@ var require_lib2 = __commonJS({
5113
5113
  iconv.encodings = null;
5114
5114
  iconv.defaultCharUnicode = "\uFFFD";
5115
5115
  iconv.defaultCharSingleByte = "?";
5116
- iconv.encode = function encode4(str, encoding, options) {
5116
+ iconv.encode = function encode5(str, encoding, options) {
5117
5117
  str = "" + (str || "");
5118
5118
  var encoder7 = iconv.getEncoder(encoding, options);
5119
5119
  var res = encoder7.write(str);
@@ -15943,7 +15943,7 @@ var require_get_intrinsic = __commonJS({
15943
15943
  var abs = require_abs();
15944
15944
  var floor = require_floor();
15945
15945
  var max = require_max();
15946
- var min = require_min();
15946
+ var min2 = require_min();
15947
15947
  var pow = require_pow();
15948
15948
  var round = require_round();
15949
15949
  var sign3 = require_sign();
@@ -16057,7 +16057,7 @@ var require_get_intrinsic = __commonJS({
16057
16057
  "%Math.abs%": abs,
16058
16058
  "%Math.floor%": floor,
16059
16059
  "%Math.max%": max,
16060
- "%Math.min%": min,
16060
+ "%Math.min%": min2,
16061
16061
  "%Math.pow%": pow,
16062
16062
  "%Math.round%": round,
16063
16063
  "%Math.sign%": sign3,
@@ -16626,7 +16626,7 @@ var require_utils = __commonJS({
16626
16626
  }
16627
16627
  };
16628
16628
  var limit = 1024;
16629
- var encode4 = function encode5(str, defaultEncoder, charset, kind, format) {
16629
+ var encode5 = function encode6(str, defaultEncoder, charset, kind, format) {
16630
16630
  if (str.length === 0) {
16631
16631
  return str;
16632
16632
  }
@@ -16728,7 +16728,7 @@ var require_utils = __commonJS({
16728
16728
  combine,
16729
16729
  compact,
16730
16730
  decode: decode2,
16731
- encode: encode4,
16731
+ encode: encode5,
16732
16732
  isBuffer,
16733
16733
  isOverflow,
16734
16734
  isRegExp,
@@ -22055,12 +22055,12 @@ var require_cookie = __commonJS({
22055
22055
  } while (++index2 < max);
22056
22056
  return max;
22057
22057
  }
22058
- function endIndex(str, index2, min) {
22059
- while (index2 > min) {
22058
+ function endIndex(str, index2, min2) {
22059
+ while (index2 > min2) {
22060
22060
  var code = str.charCodeAt(--index2);
22061
22061
  if (code !== 32 && code !== 9) return index2 + 1;
22062
22062
  }
22063
- return min;
22063
+ return min2;
22064
22064
  }
22065
22065
  function serialize(name, val, opt) {
22066
22066
  var enc = opt && opt.encode || encodeURIComponent;
@@ -27538,7 +27538,7 @@ var init_base = __esm({
27538
27538
  });
27539
27539
 
27540
27540
  // ../../node_modules/.pnpm/viem@2.51.3_bufferutil@4.1.0_typescript@5.9.3_utf-8-validate@5.0.10_zod@4.4.3/node_modules/viem/_esm/errors/abi.js
27541
- var AbiEncodingArrayLengthMismatchError, AbiEncodingBytesSizeMismatchError, AbiEncodingLengthMismatchError, AbiFunctionNotFoundError, AbiItemAmbiguityError, BytesSizeMismatchError, InvalidAbiEncodingTypeError, InvalidArrayError, InvalidDefinitionTypeError;
27541
+ var AbiEncodingArrayLengthMismatchError, AbiEncodingBytesSizeMismatchError, AbiEncodingLengthMismatchError, AbiFunctionNotFoundError, AbiItemAmbiguityError, BytesSizeMismatchError, InvalidAbiEncodingTypeError, InvalidArrayError, InvalidDefinitionTypeError, UnsupportedPackedAbiType;
27542
27542
  var init_abi = __esm({
27543
27543
  "../../node_modules/.pnpm/viem@2.51.3_bufferutil@4.1.0_typescript@5.9.3_utf-8-validate@5.0.10_zod@4.4.3/node_modules/viem/_esm/errors/abi.js"() {
27544
27544
  init_formatAbiItem2();
@@ -27622,6 +27622,13 @@ var init_abi = __esm({
27622
27622
  ].join("\n"), { name: "InvalidDefinitionTypeError" });
27623
27623
  }
27624
27624
  };
27625
+ UnsupportedPackedAbiType = class extends BaseError2 {
27626
+ constructor(type) {
27627
+ super(`Type "${type}" is not supported for packed encoding.`, {
27628
+ name: "UnsupportedPackedAbiType"
27629
+ });
27630
+ }
27631
+ };
27625
27632
  }
27626
27633
  });
27627
27634
 
@@ -27689,8 +27696,8 @@ var init_encoding = __esm({
27689
27696
  "../../node_modules/.pnpm/viem@2.51.3_bufferutil@4.1.0_typescript@5.9.3_utf-8-validate@5.0.10_zod@4.4.3/node_modules/viem/_esm/errors/encoding.js"() {
27690
27697
  init_base();
27691
27698
  IntegerOutOfRangeError = class extends BaseError2 {
27692
- constructor({ max, min, signed, size: size6, value }) {
27693
- super(`Number "${value}" is not in safe ${size6 ? `${size6 * 8}-bit ${signed ? "signed" : "unsigned"} ` : ""}integer range ${max ? `(${min} to ${max})` : `(above ${min})`}`, { name: "IntegerOutOfRangeError" });
27699
+ constructor({ max, min: min2, signed, size: size6, value }) {
27700
+ super(`Number "${value}" is not in safe ${size6 ? `${size6 * 8}-bit ${signed ? "signed" : "unsigned"} ` : ""}integer range ${max ? `(${min2} to ${max})` : `(above ${min2})`}`, { name: "IntegerOutOfRangeError" });
27694
27701
  }
27695
27702
  };
27696
27703
  SizeOverflowError = class extends BaseError2 {
@@ -28001,9 +28008,9 @@ function aexists(instance, checkFinished = true) {
28001
28008
  }
28002
28009
  function aoutput(out, instance) {
28003
28010
  abytes(out);
28004
- const min = instance.outputLen;
28005
- if (out.length < min) {
28006
- throw new Error("digestInto() expects output buffer of length at least " + min);
28011
+ const min2 = instance.outputLen;
28012
+ if (out.length < min2) {
28013
+ throw new Error("digestInto() expects output buffer of length at least " + min2);
28007
28014
  }
28008
28015
  }
28009
28016
  function u32(arr) {
@@ -28639,9 +28646,10 @@ var init_slice = __esm({
28639
28646
  });
28640
28647
 
28641
28648
  // ../../node_modules/.pnpm/viem@2.51.3_bufferutil@4.1.0_typescript@5.9.3_utf-8-validate@5.0.10_zod@4.4.3/node_modules/viem/_esm/utils/regex.js
28642
- var bytesRegex2, integerRegex2;
28649
+ var arrayRegex, bytesRegex2, integerRegex2;
28643
28650
  var init_regex2 = __esm({
28644
28651
  "../../node_modules/.pnpm/viem@2.51.3_bufferutil@4.1.0_typescript@5.9.3_utf-8-validate@5.0.10_zod@4.4.3/node_modules/viem/_esm/utils/regex.js"() {
28652
+ arrayRegex = /^(.*)\[([0-9]*)\]$/;
28645
28653
  bytesRegex2 = /^bytes([1-9]|1[0-9]|2[0-9]|3[0-2])?$/;
28646
28654
  integerRegex2 = /^(u?int)(8|16|24|32|40|48|56|64|72|80|88|96|104|112|120|128|136|144|152|160|168|176|184|192|200|208|216|224|232|240|248|256)?$/;
28647
28655
  }
@@ -28799,11 +28807,11 @@ function encodeBool(value) {
28799
28807
  function encodeNumber(value, { signed, size: size6 = 256 }) {
28800
28808
  if (typeof size6 === "number") {
28801
28809
  const max = 2n ** (BigInt(size6) - (signed ? 1n : 0n)) - 1n;
28802
- const min = signed ? -max - 1n : 0n;
28803
- if (value > max || value < min)
28810
+ const min2 = signed ? -max - 1n : 0n;
28811
+ if (value > max || value < min2)
28804
28812
  throw new IntegerOutOfRangeError({
28805
28813
  max: max.toString(),
28806
- min: min.toString(),
28814
+ min: min2.toString(),
28807
28815
  signed,
28808
28816
  size: size6 / 8,
28809
28817
  value: value.toString()
@@ -29412,8 +29420,8 @@ function getEncodableList(list) {
29412
29420
  else
29413
29421
  cursor.pushUint32(bodyLength);
29414
29422
  }
29415
- for (const { encode: encode4 } of list) {
29416
- encode4(cursor);
29423
+ for (const { encode: encode5 } of list) {
29424
+ encode5(cursor);
29417
29425
  }
29418
29426
  }
29419
29427
  };
@@ -30634,12 +30642,12 @@ function utf8ToBytes2(str) {
30634
30642
  throw new Error("string expected");
30635
30643
  return new Uint8Array(new TextEncoder().encode(str));
30636
30644
  }
30637
- function inRange(n, min, max) {
30638
- return isPosBig(n) && isPosBig(min) && isPosBig(max) && min <= n && n < max;
30645
+ function inRange(n, min2, max) {
30646
+ return isPosBig(n) && isPosBig(min2) && isPosBig(max) && min2 <= n && n < max;
30639
30647
  }
30640
- function aInRange(title, n, min, max) {
30641
- if (!inRange(n, min, max))
30642
- throw new Error("expected valid " + title + ": " + min + " <= n < " + max + ", got " + n);
30648
+ function aInRange(title, n, min2, max) {
30649
+ if (!inRange(n, min2, max))
30650
+ throw new Error("expected valid " + title + ": " + min2 + " <= n < " + max + ", got " + n);
30643
30651
  }
30644
30652
  function bitLen(n) {
30645
30653
  let len;
@@ -30764,6 +30772,80 @@ var init_chain = __esm({
30764
30772
  }
30765
30773
  });
30766
30774
 
30775
+ // ../../node_modules/.pnpm/viem@2.51.3_bufferutil@4.1.0_typescript@5.9.3_utf-8-validate@5.0.10_zod@4.4.3/node_modules/viem/_esm/utils/abi/encodePacked.js
30776
+ function encodePacked(types, values) {
30777
+ if (types.length !== values.length)
30778
+ throw new AbiEncodingLengthMismatchError({
30779
+ expectedLength: types.length,
30780
+ givenLength: values.length
30781
+ });
30782
+ const data = [];
30783
+ for (let i = 0; i < types.length; i++) {
30784
+ const type = types[i];
30785
+ const value = values[i];
30786
+ data.push(encode(type, value));
30787
+ }
30788
+ return concatHex(data);
30789
+ }
30790
+ function encode(type, value, isArray = false) {
30791
+ if (type === "address") {
30792
+ const address = value;
30793
+ if (!isAddress(address))
30794
+ throw new InvalidAddressError({ address });
30795
+ return pad(address.toLowerCase(), {
30796
+ size: isArray ? 32 : null
30797
+ });
30798
+ }
30799
+ if (type === "string")
30800
+ return stringToHex(value);
30801
+ if (type === "bytes")
30802
+ return value;
30803
+ if (type === "bool")
30804
+ return pad(boolToHex(value), { size: isArray ? 32 : 1 });
30805
+ const intMatch = type.match(integerRegex2);
30806
+ if (intMatch) {
30807
+ const [_type, baseType, bits = "256"] = intMatch;
30808
+ const size6 = Number.parseInt(bits, 10) / 8;
30809
+ return numberToHex(value, {
30810
+ size: isArray ? 32 : size6,
30811
+ signed: baseType === "int"
30812
+ });
30813
+ }
30814
+ const bytesMatch = type.match(bytesRegex2);
30815
+ if (bytesMatch) {
30816
+ const [_type, size6] = bytesMatch;
30817
+ if (Number.parseInt(size6, 10) !== (value.length - 2) / 2)
30818
+ throw new BytesSizeMismatchError({
30819
+ expectedSize: Number.parseInt(size6, 10),
30820
+ givenSize: (value.length - 2) / 2
30821
+ });
30822
+ return pad(value, { dir: "right", size: isArray ? 32 : null });
30823
+ }
30824
+ const arrayMatch = type.match(arrayRegex);
30825
+ if (arrayMatch && Array.isArray(value)) {
30826
+ const [_type, childType] = arrayMatch;
30827
+ const data = [];
30828
+ for (let i = 0; i < value.length; i++) {
30829
+ data.push(encode(childType, value[i], true));
30830
+ }
30831
+ if (data.length === 0)
30832
+ return "0x";
30833
+ return concatHex(data);
30834
+ }
30835
+ throw new UnsupportedPackedAbiType(type);
30836
+ }
30837
+ var init_encodePacked = __esm({
30838
+ "../../node_modules/.pnpm/viem@2.51.3_bufferutil@4.1.0_typescript@5.9.3_utf-8-validate@5.0.10_zod@4.4.3/node_modules/viem/_esm/utils/abi/encodePacked.js"() {
30839
+ init_abi();
30840
+ init_address();
30841
+ init_isAddress();
30842
+ init_concat();
30843
+ init_pad();
30844
+ init_toHex();
30845
+ init_regex2();
30846
+ }
30847
+ });
30848
+
30767
30849
  // ../../node_modules/.pnpm/viem@2.51.3_bufferutil@4.1.0_typescript@5.9.3_utf-8-validate@5.0.10_zod@4.4.3/node_modules/viem/_esm/utils/transaction/assertTransaction.js
30768
30850
  function assertTransactionEIP7702(transaction) {
30769
30851
  const { authorizationList } = transaction;
@@ -33539,6 +33621,8 @@ var init_esm = __esm({
33539
33621
  init_exports();
33540
33622
  init_address2();
33541
33623
  init_encodeFunctionData();
33624
+ init_encodePacked();
33625
+ init_pad();
33542
33626
  init_toBytes();
33543
33627
  init_keccak256();
33544
33628
  init_hashTypedData();
@@ -34998,8 +35082,8 @@ var init_encoding2 = __esm({
34998
35082
  "../../node_modules/.pnpm/viem@2.51.3_bufferutil@4.1.0_typescript@5.9.3_utf-8-validate@5.0.10_zod@3.25.76/node_modules/viem/_esm/errors/encoding.js"() {
34999
35083
  init_base2();
35000
35084
  IntegerOutOfRangeError2 = class extends BaseError4 {
35001
- constructor({ max, min, signed, size: size6, value }) {
35002
- super(`Number "${value}" is not in safe ${size6 ? `${size6 * 8}-bit ${signed ? "signed" : "unsigned"} ` : ""}integer range ${max ? `(${min} to ${max})` : `(above ${min})`}`, { name: "IntegerOutOfRangeError" });
35085
+ constructor({ max, min: min2, signed, size: size6, value }) {
35086
+ super(`Number "${value}" is not in safe ${size6 ? `${size6 * 8}-bit ${signed ? "signed" : "unsigned"} ` : ""}integer range ${max ? `(${min2} to ${max})` : `(above ${min2})`}`, { name: "IntegerOutOfRangeError" });
35003
35087
  }
35004
35088
  };
35005
35089
  InvalidBytesBooleanError = class extends BaseError4 {
@@ -35728,11 +35812,11 @@ function encodeBool2(value) {
35728
35812
  function encodeNumber2(value, { signed, size: size6 = 256 }) {
35729
35813
  if (typeof size6 === "number") {
35730
35814
  const max = 2n ** (BigInt(size6) - (signed ? 1n : 0n)) - 1n;
35731
- const min = signed ? -max - 1n : 0n;
35732
- if (value > max || value < min)
35815
+ const min2 = signed ? -max - 1n : 0n;
35816
+ if (value > max || value < min2)
35733
35817
  throw new IntegerOutOfRangeError2({
35734
35818
  max: max.toString(),
35735
- min: min.toString(),
35819
+ min: min2.toString(),
35736
35820
  signed,
35737
35821
  size: size6 / 8,
35738
35822
  value: value.toString()
@@ -38832,8 +38916,8 @@ var init_Hex = __esm({
38832
38916
  encoder6 = /* @__PURE__ */ new TextEncoder();
38833
38917
  hexes5 = /* @__PURE__ */ Array.from({ length: 256 }, (_v, i) => i.toString(16).padStart(2, "0"));
38834
38918
  IntegerOutOfRangeError3 = class extends BaseError5 {
38835
- constructor({ max, min, signed, size: size6, value }) {
38836
- super(`Number \`${value}\` is not in safe${size6 ? ` ${size6 * 8}-bit` : ""}${signed ? " signed" : " unsigned"} integer range ${max ? `(\`${min}\` to \`${max}\`)` : `(above \`${min}\`)`}`);
38919
+ constructor({ max, min: min2, signed, size: size6, value }) {
38920
+ super(`Number \`${value}\` is not in safe${size6 ? ` ${size6 * 8}-bit` : ""}${signed ? " signed" : " unsigned"} integer range ${max ? `(\`${min2}\` to \`${max}\`)` : `(above \`${min2}\`)`}`);
38837
38921
  Object.defineProperty(this, "name", {
38838
38922
  enumerable: true,
38839
38923
  configurable: true,
@@ -40696,6 +40780,35 @@ var KERNEL_ERROR_SIGNATURES = [
40696
40780
  ];
40697
40781
  var KERNEL_ERROR_ABI = parseAbi(KERNEL_ERROR_SIGNATURES);
40698
40782
 
40783
+ // ../sdk/dist/eip712.js
40784
+ var REGISTER_PERMISSIONS_BATCH_TYPES = {
40785
+ RegisterPermissions: [
40786
+ { name: "account", type: "address" },
40787
+ { name: "permissions", type: "address[]" },
40788
+ { name: "nonce", type: "uint256" },
40789
+ { name: "deadline", type: "uint256" }
40790
+ ]
40791
+ };
40792
+ function buildRegisterPermissionsBatchTypedData(args) {
40793
+ const deadline = args.deadline ?? BigInt(Math.floor(Date.now() / 1e3) + 600);
40794
+ return {
40795
+ domain: {
40796
+ name: "SailKernel",
40797
+ version: "1",
40798
+ chainId: args.chainId,
40799
+ verifyingContract: args.kernel
40800
+ },
40801
+ types: REGISTER_PERMISSIONS_BATCH_TYPES,
40802
+ primaryType: "RegisterPermissions",
40803
+ message: {
40804
+ account: args.account,
40805
+ permissions: args.permissions,
40806
+ nonce: args.nonce.toString(),
40807
+ deadline: deadline.toString()
40808
+ }
40809
+ };
40810
+ }
40811
+
40699
40812
  // ../sdk/dist/lifi.js
40700
40813
  init_esm();
40701
40814
  var ERC20_ABI = parseAbi([
@@ -40761,9 +40874,9 @@ function anumArr(label, input) {
40761
40874
  function chain(...args) {
40762
40875
  const id = (a) => a;
40763
40876
  const wrap3 = (a, b) => (c) => a(b(c));
40764
- const encode4 = args.map((x) => x.encode).reduceRight(wrap3, id);
40877
+ const encode5 = args.map((x) => x.encode).reduceRight(wrap3, id);
40765
40878
  const decode2 = args.map((x) => x.decode).reduce(wrap3, id);
40766
- return { encode: encode4, decode: decode2 };
40879
+ return { encode: encode5, decode: decode2 };
40767
40880
  }
40768
40881
  // @__NO_SIDE_EFFECTS__
40769
40882
  function alphabet(letters) {
@@ -41530,8 +41643,83 @@ var LocalKeyring = class _LocalKeyring {
41530
41643
  }
41531
41644
  };
41532
41645
 
41646
+ // ../sdk/dist/abis/SailGovernance.js
41647
+ var SailGovernanceAbi = [
41648
+ {
41649
+ type: "function",
41650
+ name: "baseFee",
41651
+ stateMutability: "view",
41652
+ inputs: [],
41653
+ outputs: [{ type: "uint256" }]
41654
+ },
41655
+ {
41656
+ type: "function",
41657
+ name: "complexityRate",
41658
+ stateMutability: "view",
41659
+ inputs: [],
41660
+ outputs: [{ type: "uint256" }]
41661
+ },
41662
+ {
41663
+ type: "function",
41664
+ name: "MAX_PERMISSION_FEE_WEI",
41665
+ stateMutability: "view",
41666
+ inputs: [],
41667
+ outputs: [{ type: "uint256" }]
41668
+ },
41669
+ {
41670
+ type: "function",
41671
+ name: "permissionRegistrationFee",
41672
+ stateMutability: "view",
41673
+ inputs: [],
41674
+ outputs: [{ type: "uint256" }]
41675
+ },
41676
+ {
41677
+ type: "function",
41678
+ name: "maxPermissionsPerAccount",
41679
+ stateMutability: "view",
41680
+ inputs: [],
41681
+ outputs: [{ type: "uint256" }]
41682
+ },
41683
+ {
41684
+ type: "function",
41685
+ name: "isPaused",
41686
+ stateMutability: "view",
41687
+ inputs: [],
41688
+ outputs: [{ type: "bool" }]
41689
+ }
41690
+ ];
41691
+
41533
41692
  // ../sdk/dist/safe.js
41534
41693
  init_esm();
41694
+ var setManagerAbi = [
41695
+ {
41696
+ type: "function",
41697
+ name: "setManager",
41698
+ stateMutability: "nonpayable",
41699
+ inputs: [{ name: "newManager", type: "address" }],
41700
+ outputs: []
41701
+ }
41702
+ ];
41703
+ var gnosisSafeExecAbi = [
41704
+ {
41705
+ type: "function",
41706
+ name: "execTransaction",
41707
+ stateMutability: "payable",
41708
+ inputs: [
41709
+ { name: "to", type: "address" },
41710
+ { name: "value", type: "uint256" },
41711
+ { name: "data", type: "bytes" },
41712
+ { name: "operation", type: "uint8" },
41713
+ { name: "safeTxGas", type: "uint256" },
41714
+ { name: "baseGas", type: "uint256" },
41715
+ { name: "gasPrice", type: "uint256" },
41716
+ { name: "gasToken", type: "address" },
41717
+ { name: "refundReceiver", type: "address" },
41718
+ { name: "signatures", type: "bytes" }
41719
+ ],
41720
+ outputs: [{ name: "success", type: "bool" }]
41721
+ }
41722
+ ];
41535
41723
  var gnosisSafeAbi = [
41536
41724
  {
41537
41725
  type: "function",
@@ -41590,6 +41778,81 @@ function buildSafeSetupInitializer(params) {
41590
41778
  ]
41591
41779
  });
41592
41780
  }
41781
+ function buildApprovedHashSignature(owner) {
41782
+ return encodePacked(["bytes32", "bytes32", "uint8"], [pad(owner, { size: 32 }), pad("0x", { size: 32 }), 1]);
41783
+ }
41784
+ function encodeSetManager(newManager) {
41785
+ return encodeFunctionData({
41786
+ abi: setManagerAbi,
41787
+ functionName: "setManager",
41788
+ args: [newManager]
41789
+ });
41790
+ }
41791
+ function buildSetManagerExecTransaction(params) {
41792
+ const innerData = encodeSetManager(params.newManager);
41793
+ const data = encodeFunctionData({
41794
+ abi: gnosisSafeExecAbi,
41795
+ functionName: "execTransaction",
41796
+ args: [
41797
+ params.kernel,
41798
+ // to
41799
+ 0n,
41800
+ // value
41801
+ innerData,
41802
+ // data: setManager(newManager)
41803
+ 0,
41804
+ // operation: Call
41805
+ 0n,
41806
+ // safeTxGas
41807
+ 0n,
41808
+ // baseGas
41809
+ 0n,
41810
+ // gasPrice
41811
+ zeroAddress,
41812
+ // gasToken
41813
+ zeroAddress,
41814
+ // refundReceiver
41815
+ buildApprovedHashSignature(params.owner)
41816
+ ]
41817
+ });
41818
+ return { to: params.safe, data };
41819
+ }
41820
+
41821
+ // ../sdk/dist/fees.js
41822
+ function min(a, b) {
41823
+ return a < b ? a : b;
41824
+ }
41825
+ async function estimatePermissionFee(publicClient, governance, permission) {
41826
+ try {
41827
+ const [baseFee, complexityRate, cap, code] = await Promise.all([
41828
+ publicClient.readContract({
41829
+ address: governance,
41830
+ abi: SailGovernanceAbi,
41831
+ functionName: "baseFee"
41832
+ }),
41833
+ publicClient.readContract({
41834
+ address: governance,
41835
+ abi: SailGovernanceAbi,
41836
+ functionName: "complexityRate"
41837
+ }),
41838
+ publicClient.readContract({
41839
+ address: governance,
41840
+ abi: SailGovernanceAbi,
41841
+ functionName: "MAX_PERMISSION_FEE_WEI"
41842
+ }),
41843
+ publicClient.getBytecode({ address: permission })
41844
+ ]);
41845
+ const byteLength = code ? BigInt((code.length - 2) / 2) : 0n;
41846
+ const fee = min(baseFee, cap) + min(byteLength * complexityRate, cap);
41847
+ return min(fee, cap);
41848
+ } catch {
41849
+ return publicClient.readContract({
41850
+ address: governance,
41851
+ abi: SailGovernanceAbi,
41852
+ functionName: "permissionRegistrationFee"
41853
+ });
41854
+ }
41855
+ }
41593
41856
 
41594
41857
  // ../../node_modules/.pnpm/viem@2.51.3_bufferutil@4.1.0_typescript@5.9.3_utf-8-validate@5.0.10_zod@3.25.76/node_modules/viem/_esm/utils/getAction.js
41595
41858
  function getAction(client, actionFn, name) {
@@ -41844,8 +42107,8 @@ function getEncodableList2(list) {
41844
42107
  else
41845
42108
  cursor.pushUint32(bodyLength);
41846
42109
  }
41847
- for (const { encode: encode4 } of list) {
41848
- encode4(cursor);
42110
+ for (const { encode: encode5 } of list) {
42111
+ encode5(cursor);
41849
42112
  }
41850
42113
  }
41851
42114
  };
@@ -46003,7 +46266,7 @@ init_Errors();
46003
46266
  init_Hex();
46004
46267
 
46005
46268
  // ../../node_modules/.pnpm/ox@0.14.25_typescript@5.9.3_zod@3.25.76/node_modules/ox/_esm/core/Solidity.js
46006
- var arrayRegex = /^(.*)\[([0-9]*)\]$/;
46269
+ var arrayRegex2 = /^(.*)\[([0-9]*)\]$/;
46007
46270
  var bytesRegex5 = /^bytes([1-9]|1[0-9]|2[0-9]|3[0-2])?$/;
46008
46271
  var integerRegex5 = /^(u?int)(8|16|24|32|40|48|56|64|72|80|88|96|104|112|120|128|136|144|152|160|168|176|184|192|200|208|216|224|232|240|248|256)?$/;
46009
46272
  var maxInt83 = 2n ** (8n - 1n) - 1n;
@@ -46316,7 +46579,7 @@ function prepareParameter({ checksumAddress: checksumAddress3 = false, parameter
46316
46579
  }
46317
46580
  throw new InvalidTypeError(parameter.type);
46318
46581
  }
46319
- function encode(preparedParameters) {
46582
+ function encode2(preparedParameters) {
46320
46583
  let staticSize = 0;
46321
46584
  for (let i = 0; i < preparedParameters.length; i++) {
46322
46585
  const { dynamic, encoded } = preparedParameters[i];
@@ -46372,7 +46635,7 @@ function encodeArray3(value, options) {
46372
46635
  preparedParameters.push(preparedParam);
46373
46636
  }
46374
46637
  if (dynamic || dynamicChild) {
46375
- const data = encode(preparedParameters);
46638
+ const data = encode2(preparedParameters);
46376
46639
  if (dynamic) {
46377
46640
  const length2 = fromNumber(preparedParameters.length, { size: 32 });
46378
46641
  return {
@@ -46415,11 +46678,11 @@ function encodeBoolean(value) {
46415
46678
  function encodeNumber3(value, { signed, size: size6 }) {
46416
46679
  if (typeof size6 === "number") {
46417
46680
  const max = 2n ** (BigInt(size6) - (signed ? 1n : 0n)) - 1n;
46418
- const min = signed ? -max - 1n : 0n;
46419
- if (value > max || value < min)
46681
+ const min2 = signed ? -max - 1n : 0n;
46682
+ if (value > max || value < min2)
46420
46683
  throw new IntegerOutOfRangeError3({
46421
46684
  max: max.toString(),
46422
- min: min.toString(),
46685
+ min: min2.toString(),
46423
46686
  signed,
46424
46687
  size: size6 / 8,
46425
46688
  value: value.toString()
@@ -46463,7 +46726,7 @@ function encodeTuple3(value, options) {
46463
46726
  }
46464
46727
  return {
46465
46728
  dynamic,
46466
- encoded: dynamic ? encode(preparedParameters) : concat3(...preparedParameters.map(({ encoded }) => encoded))
46729
+ encoded: dynamic ? encode2(preparedParameters) : concat3(...preparedParameters.map(({ encoded }) => encoded))
46467
46730
  };
46468
46731
  }
46469
46732
  function getArrayComponents3(type) {
@@ -46725,7 +46988,7 @@ function decode(parameters, data, options = {}) {
46725
46988
  }
46726
46989
  return values;
46727
46990
  }
46728
- function encode2(parameters, values, options) {
46991
+ function encode3(parameters, values, options) {
46729
46992
  const { checksumAddress: checksumAddress3 = false } = options ?? {};
46730
46993
  if (parameters.length !== values.length)
46731
46994
  throw new LengthMismatchError({
@@ -46737,7 +47000,7 @@ function encode2(parameters, values, options) {
46737
47000
  parameters,
46738
47001
  values
46739
47002
  });
46740
- const data = encode(preparedParameters);
47003
+ const data = encode2(preparedParameters);
46741
47004
  if (data.length === 0)
46742
47005
  return "0x";
46743
47006
  return data;
@@ -46757,7 +47020,7 @@ function encodePacked2(types, values) {
46757
47020
  return concat3(...data);
46758
47021
  }
46759
47022
  (function(encodePacked3) {
46760
- function encode4(type, value, isArray = false) {
47023
+ function encode5(type, value, isArray = false) {
46761
47024
  if (type === "address") {
46762
47025
  const address = value;
46763
47026
  assert4(address);
@@ -46788,12 +47051,12 @@ function encodePacked2(types, values) {
46788
47051
  });
46789
47052
  return padRight(value, isArray ? 32 : 0);
46790
47053
  }
46791
- const arrayMatch = type.match(arrayRegex);
47054
+ const arrayMatch = type.match(arrayRegex2);
46792
47055
  if (arrayMatch && Array.isArray(value)) {
46793
47056
  const [_type, childType] = arrayMatch;
46794
47057
  const data = [];
46795
47058
  for (let i = 0; i < value.length; i++) {
46796
- data.push(encode4(childType, value[i], true));
47059
+ data.push(encode5(childType, value[i], true));
46797
47060
  }
46798
47061
  if (data.length === 0)
46799
47062
  return "0x";
@@ -46801,7 +47064,7 @@ function encodePacked2(types, values) {
46801
47064
  }
46802
47065
  throw new InvalidTypeError(type);
46803
47066
  }
46804
- encodePacked3.encode = encode4;
47067
+ encodePacked3.encode = encode5;
46805
47068
  })(encodePacked2 || (encodePacked2 = {}));
46806
47069
  function from5(parameters) {
46807
47070
  if (Array.isArray(parameters) && typeof parameters[0] === "string")
@@ -46946,8 +47209,8 @@ function getEncodableList3(list) {
46946
47209
  else
46947
47210
  cursor.pushUint32(bodyLength);
46948
47211
  }
46949
- for (const { encode: encode4 } of list) {
46950
- encode4(cursor);
47212
+ for (const { encode: encode5 } of list) {
47213
+ encode5(cursor);
46951
47214
  }
46952
47215
  }
46953
47216
  };
@@ -47281,7 +47544,7 @@ function wrap(value) {
47281
47544
  payload: getSignPayload(value.authorization),
47282
47545
  signature: from7(value.authorization)
47283
47546
  });
47284
- const suffix = encode2(suffixParameters, [
47547
+ const suffix = encode3(suffixParameters, [
47285
47548
  {
47286
47549
  ...value.authorization,
47287
47550
  delegation: value.authorization.address,
@@ -47937,7 +48200,7 @@ var NotFoundError = class extends BaseError5 {
47937
48200
 
47938
48201
  // ../../node_modules/.pnpm/ox@0.14.25_typescript@5.9.3_zod@3.25.76/node_modules/ox/_esm/core/AbiConstructor.js
47939
48202
  init_Hex();
47940
- function encode3(...parameters) {
48203
+ function encode4(...parameters) {
47941
48204
  const [abiConstructor, options] = (() => {
47942
48205
  if (Array.isArray(parameters[0])) {
47943
48206
  const [abi2, options2] = parameters;
@@ -47946,7 +48209,7 @@ function encode3(...parameters) {
47946
48209
  return parameters;
47947
48210
  })();
47948
48211
  const { bytecode, args } = options;
47949
- return concat3(bytecode, abiConstructor.inputs?.length && args?.length ? encode2(abiConstructor.inputs, args) : "0x");
48212
+ return concat3(bytecode, abiConstructor.inputs?.length && args?.length ? encode3(abiConstructor.inputs, args) : "0x");
47950
48213
  }
47951
48214
  function from11(abiConstructor) {
47952
48215
  return from10(abiConstructor);
@@ -47974,7 +48237,7 @@ function encodeData3(...parameters) {
47974
48237
  args
47975
48238
  }) : abiFunction;
47976
48239
  const selector = getSelector2(item);
47977
- const data = args.length > 0 ? encode2(item.inputs, args) : void 0;
48240
+ const data = args.length > 0 ? encode3(item.inputs, args) : void 0;
47978
48241
  return data ? concat3(selector, data) : selector;
47979
48242
  }
47980
48243
  function from12(abiFunction, options = {}) {
@@ -48007,7 +48270,7 @@ async function simulateCalls(client, parameters) {
48007
48270
  const account = parameters.account ? parseAccount(parameters.account) : void 0;
48008
48271
  if (traceAssetChanges && !account)
48009
48272
  throw new BaseError4("`account` is required when `traceAssetChanges` is true");
48010
- const getBalanceData = account ? encode3(from11("constructor(bytes, bytes)"), {
48273
+ const getBalanceData = account ? encode4(from11("constructor(bytes, bytes)"), {
48011
48274
  bytecode: deploylessCallViaBytecodeBytecode,
48012
48275
  args: [
48013
48276
  getBalanceCode,
@@ -48274,7 +48537,7 @@ function unwrap2(wrapped) {
48274
48537
  }
48275
48538
  function wrap2(value) {
48276
48539
  const { data, signature, to } = value;
48277
- return concat3(encode2(from5("address, bytes, bytes"), [
48540
+ return concat3(encode3(from5("address, bytes, bytes"), [
48278
48541
  to,
48279
48542
  data,
48280
48543
  signature
@@ -49399,6 +49662,7 @@ function http(url, config = {}) {
49399
49662
  }
49400
49663
 
49401
49664
  // ../../node_modules/.pnpm/viem@2.51.3_bufferutil@4.1.0_typescript@5.9.3_utf-8-validate@5.0.10_zod@3.25.76/node_modules/viem/_esm/index.js
49665
+ init_encodeDeployData();
49402
49666
  init_encodeFunctionData2();
49403
49667
  init_getAddress2();
49404
49668
  init_isAddress2();
@@ -49629,6 +49893,8 @@ function startServer(sailDir, { port = PORT } = {}) {
49629
49893
  app.use((0, import_cors.default)({ origin: "http://localhost:3333" }));
49630
49894
  app.use(import_express.default.json());
49631
49895
  const at = (name) => import_node_path.default.join(sailDir, name);
49896
+ const projectRoot = import_node_path.default.dirname(sailDir);
49897
+ const outAt = (name) => import_node_path.default.join(projectRoot, "out", name);
49632
49898
  const overviewCacheByAccount = /* @__PURE__ */ new Map();
49633
49899
  const overviewInFlight = /* @__PURE__ */ new Set();
49634
49900
  const overviewSnapshotPath = (safe) => at(`state/overview/${safe.toLowerCase()}.json`);
@@ -50030,6 +50296,514 @@ function startServer(sailDir, { port = PORT } = {}) {
50030
50296
  res.status(500).json({ error: String(err) });
50031
50297
  }
50032
50298
  });
50299
+ const rotationContext = () => {
50300
+ let account;
50301
+ try {
50302
+ account = JSON.parse(import_node_fs2.default.readFileSync(at("account.json"), "utf-8"));
50303
+ } catch {
50304
+ return { error: "no-account", message: "No active SMA. Deploy one first." };
50305
+ }
50306
+ const env = parseEnvFile(at(".env.local"));
50307
+ const chainId = Number(account.chainId ?? env.CHAIN_ID ?? 0);
50308
+ let kernel = env.KERNEL_ADDRESS;
50309
+ let governance;
50310
+ try {
50311
+ const deployment = getSailDeployment(chainId);
50312
+ kernel = kernel ?? deployment?.kernel;
50313
+ governance = deployment?.governance;
50314
+ } catch {
50315
+ }
50316
+ const rpcUrl = env.RPC_URL;
50317
+ if (!kernel || !isAddress2(kernel)) {
50318
+ return { error: "no-kernel", message: "No kernel address for this chain." };
50319
+ }
50320
+ if (!rpcUrl) {
50321
+ return { error: "no-rpc", message: "No RPC_URL configured (.sail/.env.local)." };
50322
+ }
50323
+ const client = createPublicClient({ transport: http(rpcUrl) });
50324
+ return { account, env, chainId, kernel: getAddress(kernel), governance, rpcUrl, client };
50325
+ };
50326
+ app.get("/api/account/rotation-preview", async (_req, res) => {
50327
+ const ctx = rotationContext();
50328
+ if (ctx.error) {
50329
+ res.status(400).json({ error: ctx.error, message: ctx.message });
50330
+ return;
50331
+ }
50332
+ try {
50333
+ const safe = getAddress(ctx.account.safe);
50334
+ const [configs, permissions] = await Promise.all([
50335
+ ctx.client.readContract({ address: ctx.kernel, abi: SailKernelAbi, functionName: "configs", args: [safe] }),
50336
+ ctx.client.readContract({ address: ctx.kernel, abi: SailKernelAbi, functionName: "getPermissions", args: [safe] })
50337
+ ]);
50338
+ const [permissionSigner, manager] = configs;
50339
+ res.json({
50340
+ safe,
50341
+ chainId: ctx.chainId,
50342
+ owner: getAddress(ctx.account.owner),
50343
+ permissionSigner: getAddress(permissionSigner),
50344
+ currentManager: manager && getAddress(manager) !== zeroAddress2 ? getAddress(manager) : null,
50345
+ permissions: permissions.map((p) => getAddress(p))
50346
+ });
50347
+ } catch (err) {
50348
+ res.status(502).json({ error: "rpc", message: String(err) });
50349
+ }
50350
+ });
50351
+ app.post("/api/account/build-set-manager", async (req, res) => {
50352
+ const { newManager } = req.body ?? {};
50353
+ if (!isAddress2(newManager)) {
50354
+ res.status(400).json({ error: "newManager must be a valid address" });
50355
+ return;
50356
+ }
50357
+ const ctx = rotationContext();
50358
+ if (ctx.error) {
50359
+ res.status(400).json({ error: ctx.error, message: ctx.message });
50360
+ return;
50361
+ }
50362
+ try {
50363
+ const safe = getAddress(ctx.account.safe);
50364
+ const owner = getAddress(ctx.account.owner);
50365
+ const configs = await ctx.client.readContract({
50366
+ address: ctx.kernel,
50367
+ abi: SailKernelAbi,
50368
+ functionName: "configs",
50369
+ args: [safe]
50370
+ });
50371
+ const oldManager = configs[1] && getAddress(configs[1]) !== zeroAddress2 ? getAddress(configs[1]) : null;
50372
+ if (oldManager && oldManager.toLowerCase() === getAddress(newManager).toLowerCase()) {
50373
+ res.status(400).json({ error: "same-signer", message: "New signer is the same as the current one." });
50374
+ return;
50375
+ }
50376
+ const permissions = await ctx.client.readContract({
50377
+ address: ctx.kernel,
50378
+ abi: SailKernelAbi,
50379
+ functionName: "getPermissions",
50380
+ args: [safe]
50381
+ });
50382
+ const { to, data } = buildSetManagerExecTransaction({
50383
+ safe,
50384
+ kernel: ctx.kernel,
50385
+ newManager: getAddress(newManager),
50386
+ owner
50387
+ });
50388
+ res.json({ to, data, chainId: ctx.chainId, oldManager, permissions: permissions.map((p) => getAddress(p)) });
50389
+ } catch (err) {
50390
+ res.status(502).json({ error: "rpc", message: String(err) });
50391
+ }
50392
+ });
50393
+ app.post("/api/account/rotate-generate-key", async (req, res) => {
50394
+ const target = at("keys/manager.json");
50395
+ try {
50396
+ const passphrase = req.body?.passphrase ?? "";
50397
+ if (import_node_fs2.default.existsSync(target)) {
50398
+ const backup = `${target}.${Date.now()}.bak`;
50399
+ import_node_fs2.default.copyFileSync(target, backup);
50400
+ }
50401
+ const privateKey = generatePrivateKey2();
50402
+ const keyring = LocalKeyring.fromPrivateKey(privateKey);
50403
+ const keystore = await keyring.exportKeystore(passphrase);
50404
+ import_node_fs2.default.mkdirSync(at("keys"), { recursive: true });
50405
+ import_node_fs2.default.writeFileSync(target, `${JSON.stringify(keystore, null, 2)}
50406
+ `);
50407
+ res.json({ address: getAddress(keyring.address) });
50408
+ } catch (err) {
50409
+ res.status(500).json({ error: String(err) });
50410
+ }
50411
+ });
50412
+ app.post("/api/account/build-reattach", async (req, res) => {
50413
+ const permissions = Array.isArray(req.body?.permissions) ? req.body.permissions : [];
50414
+ if (permissions.length === 0 || !permissions.every((p) => isAddress2(p))) {
50415
+ res.status(400).json({ error: "permissions must be a non-empty array of addresses" });
50416
+ return;
50417
+ }
50418
+ const ctx = rotationContext();
50419
+ if (ctx.error) {
50420
+ res.status(400).json({ error: ctx.error, message: ctx.message });
50421
+ return;
50422
+ }
50423
+ try {
50424
+ const safe = getAddress(ctx.account.safe);
50425
+ const nonce = await ctx.client.readContract({
50426
+ address: ctx.kernel,
50427
+ abi: SailKernelAbi,
50428
+ functionName: "signerNonces",
50429
+ args: [safe]
50430
+ });
50431
+ const deadline = BigInt(Math.floor(Date.now() / 1e3) + 600);
50432
+ const typedData = buildRegisterPermissionsBatchTypedData({
50433
+ chainId: ctx.chainId,
50434
+ kernel: ctx.kernel,
50435
+ account: safe,
50436
+ permissions: permissions.map((p) => getAddress(p)),
50437
+ nonce,
50438
+ deadline
50439
+ });
50440
+ res.json({ typedData, deadline: deadline.toString() });
50441
+ } catch (err) {
50442
+ res.status(502).json({ error: "rpc", message: String(err) });
50443
+ }
50444
+ });
50445
+ app.post("/api/account/build-reattach-tx", async (req, res) => {
50446
+ const { permissions, deadline, signature } = req.body ?? {};
50447
+ if (!Array.isArray(permissions) || permissions.length === 0 || !permissions.every((p) => isAddress2(p))) {
50448
+ res.status(400).json({ error: "permissions must be a non-empty array of addresses" });
50449
+ return;
50450
+ }
50451
+ if (typeof signature !== "string" || !signature.startsWith("0x")) {
50452
+ res.status(400).json({ error: "signature is required" });
50453
+ return;
50454
+ }
50455
+ if (deadline == null) {
50456
+ res.status(400).json({ error: "deadline is required" });
50457
+ return;
50458
+ }
50459
+ const ctx = rotationContext();
50460
+ if (ctx.error) {
50461
+ res.status(400).json({ error: ctx.error, message: ctx.message });
50462
+ return;
50463
+ }
50464
+ try {
50465
+ const safe = getAddress(ctx.account.safe);
50466
+ const perms = permissions.map((p) => getAddress(p));
50467
+ let fee = 0n;
50468
+ if (ctx.governance && isAddress2(ctx.governance)) {
50469
+ for (const permission of perms) {
50470
+ fee += await estimatePermissionFee(ctx.client, ctx.governance, permission);
50471
+ }
50472
+ }
50473
+ const data = encodeFunctionData2({
50474
+ abi: SailKernelAbi,
50475
+ functionName: "registerPermissions",
50476
+ args: [safe, perms, BigInt(deadline), signature]
50477
+ });
50478
+ res.json({ to: ctx.kernel, data, value: fee.toString(), chainId: ctx.chainId });
50479
+ } catch (err) {
50480
+ res.status(502).json({ error: "rpc", message: String(err) });
50481
+ }
50482
+ });
50483
+ const REVOKE_PERMISSIONS_ABI = [
50484
+ {
50485
+ type: "function",
50486
+ name: "revokePermissions",
50487
+ stateMutability: "nonpayable",
50488
+ inputs: [
50489
+ { name: "account", type: "address" },
50490
+ { name: "permissions", type: "address[]" },
50491
+ { name: "deadline", type: "uint256" },
50492
+ { name: "sig", type: "bytes" }
50493
+ ],
50494
+ outputs: []
50495
+ }
50496
+ ];
50497
+ const REVOKE_PERMISSIONS_TYPES = {
50498
+ RevokePermissions: [
50499
+ { name: "account", type: "address" },
50500
+ { name: "permissions", type: "address[]" },
50501
+ { name: "nonce", type: "uint256" },
50502
+ { name: "deadline", type: "uint256" }
50503
+ ]
50504
+ };
50505
+ app.post("/api/account/build-revoke", async (req, res) => {
50506
+ const permissions = Array.isArray(req.body?.permissions) ? req.body.permissions : [];
50507
+ if (permissions.length === 0 || !permissions.every((p) => isAddress2(p))) {
50508
+ res.status(400).json({ error: "permissions must be a non-empty array of addresses" });
50509
+ return;
50510
+ }
50511
+ const ctx = rotationContext();
50512
+ if (ctx.error) {
50513
+ res.status(400).json({ error: ctx.error, message: ctx.message });
50514
+ return;
50515
+ }
50516
+ try {
50517
+ const safe = getAddress(ctx.account.safe);
50518
+ const [active, nonce] = await Promise.all([
50519
+ ctx.client.readContract({ address: ctx.kernel, abi: SailKernelAbi, functionName: "getPermissions", args: [safe] }),
50520
+ ctx.client.readContract({ address: ctx.kernel, abi: SailKernelAbi, functionName: "signerNonces", args: [safe] })
50521
+ ]);
50522
+ const activeSet = new Set(active.map((p) => getAddress(p).toLowerCase()));
50523
+ const targets = permissions.map((p) => getAddress(p));
50524
+ const missing = targets.filter((p) => !activeSet.has(p.toLowerCase()));
50525
+ if (missing.length > 0) {
50526
+ res.status(409).json({ error: "not-active", message: `Not in the SMA's active permission set: ${missing.join(", ")}` });
50527
+ return;
50528
+ }
50529
+ const deadline = BigInt(Math.floor(Date.now() / 1e3) + 600);
50530
+ const typedData = {
50531
+ domain: { name: "SailKernel", version: "1", chainId: ctx.chainId, verifyingContract: ctx.kernel },
50532
+ types: REVOKE_PERMISSIONS_TYPES,
50533
+ primaryType: "RevokePermissions",
50534
+ message: { account: safe, permissions: targets, nonce: nonce.toString(), deadline: deadline.toString() }
50535
+ };
50536
+ res.json({ typedData, deadline: deadline.toString() });
50537
+ } catch (err) {
50538
+ res.status(502).json({ error: "rpc", message: String(err) });
50539
+ }
50540
+ });
50541
+ app.post("/api/account/build-revoke-tx", async (req, res) => {
50542
+ const { permissions, deadline, signature } = req.body ?? {};
50543
+ if (!Array.isArray(permissions) || permissions.length === 0 || !permissions.every((p) => isAddress2(p))) {
50544
+ res.status(400).json({ error: "permissions must be a non-empty array of addresses" });
50545
+ return;
50546
+ }
50547
+ if (typeof signature !== "string" || !signature.startsWith("0x")) {
50548
+ res.status(400).json({ error: "signature is required" });
50549
+ return;
50550
+ }
50551
+ if (deadline == null) {
50552
+ res.status(400).json({ error: "deadline is required" });
50553
+ return;
50554
+ }
50555
+ const ctx = rotationContext();
50556
+ if (ctx.error) {
50557
+ res.status(400).json({ error: ctx.error, message: ctx.message });
50558
+ return;
50559
+ }
50560
+ try {
50561
+ const safe = getAddress(ctx.account.safe);
50562
+ const perms = permissions.map((p) => getAddress(p));
50563
+ const data = encodeFunctionData2({
50564
+ abi: REVOKE_PERMISSIONS_ABI,
50565
+ functionName: "revokePermissions",
50566
+ args: [safe, perms, BigInt(deadline), signature]
50567
+ });
50568
+ res.json({ to: ctx.kernel, data, chainId: ctx.chainId });
50569
+ } catch (err) {
50570
+ res.status(502).json({ error: "rpc", message: String(err) });
50571
+ }
50572
+ });
50573
+ app.post("/api/account/revoke-complete", (req, res) => {
50574
+ const { permissions, txHash } = req.body ?? {};
50575
+ if (!Array.isArray(permissions) || permissions.length === 0 || !permissions.every((p) => isAddress2(p))) {
50576
+ res.status(400).json({ error: "permissions must be a non-empty array of addresses" });
50577
+ return;
50578
+ }
50579
+ const safe = readActiveSafe();
50580
+ if (!safe) {
50581
+ res.status(400).json({ error: "No active SMA." });
50582
+ return;
50583
+ }
50584
+ try {
50585
+ const nameByAddr = /* @__PURE__ */ new Map();
50586
+ try {
50587
+ const tracked = JSON.parse(import_node_fs2.default.readFileSync(at("state/mandates.json"), "utf-8"));
50588
+ for (const m of tracked.mandates ?? []) {
50589
+ if (m.address && m.name) nameByAddr.set(m.address.toLowerCase(), m.name);
50590
+ }
50591
+ } catch {
50592
+ }
50593
+ const ts = (/* @__PURE__ */ new Date()).toISOString();
50594
+ for (const p of permissions) {
50595
+ const permission = getAddress(p);
50596
+ const ev = {
50597
+ ts,
50598
+ actor: "owner",
50599
+ type: "permission_revoked",
50600
+ permission,
50601
+ safe,
50602
+ ...nameByAddr.has(permission.toLowerCase()) ? { name: nameByAddr.get(permission.toLowerCase()) } : {},
50603
+ ...txHash ? { txHash } : {}
50604
+ };
50605
+ import_node_fs2.default.appendFileSync(at("activity.jsonl"), `${JSON.stringify(ev)}
50606
+ `);
50607
+ }
50608
+ overviewCacheByAccount.delete(safe.toLowerCase());
50609
+ try {
50610
+ import_node_fs2.default.rmSync(overviewSnapshotPath(safe));
50611
+ } catch {
50612
+ }
50613
+ res.json({ ok: true, revoked: permissions.length });
50614
+ } catch (err) {
50615
+ res.status(500).json({ error: String(err) });
50616
+ }
50617
+ });
50618
+ const isSafeArtifactName = (name) => typeof name === "string" && /^[A-Za-z0-9_]+$/.test(name);
50619
+ const readArtifact = (name) => {
50620
+ if (!isSafeArtifactName(name)) return null;
50621
+ try {
50622
+ const artifact = JSON.parse(import_node_fs2.default.readFileSync(outAt(`${name}.sol/${name}.json`), "utf-8"));
50623
+ const bytecodeRaw = artifact.bytecode?.object ?? artifact.bytecode;
50624
+ if (!artifact.abi || !bytecodeRaw) return null;
50625
+ const bytecode = String(bytecodeRaw).startsWith("0x") ? bytecodeRaw : `0x${bytecodeRaw}`;
50626
+ if (bytecode.length <= 2) return null;
50627
+ return { abi: artifact.abi, bytecode, path: outAt(`${name}.sol/${name}.json`) };
50628
+ } catch {
50629
+ return null;
50630
+ }
50631
+ };
50632
+ app.get("/api/mandate-templates", (_req, res) => {
50633
+ const templates = [];
50634
+ try {
50635
+ const outDir = import_node_path.default.join(projectRoot, "out");
50636
+ for (const dir of import_node_fs2.default.readdirSync(outDir)) {
50637
+ if (!dir.endsWith(".sol")) continue;
50638
+ const name = dir.slice(0, -4);
50639
+ if (!/permission/i.test(name)) continue;
50640
+ const art = readArtifact(name);
50641
+ if (!art) continue;
50642
+ const ctor = (art.abi ?? []).find((x) => x.type === "constructor");
50643
+ templates.push({
50644
+ name,
50645
+ inputs: (ctor?.inputs ?? []).map((i) => ({ name: i.name, type: i.type }))
50646
+ });
50647
+ }
50648
+ } catch {
50649
+ }
50650
+ res.json({ templates });
50651
+ });
50652
+ const coerceArg = (type, value) => {
50653
+ const asList = (v) => {
50654
+ if (Array.isArray(v)) return v;
50655
+ const s = String(v ?? "").trim();
50656
+ if (!s) return [];
50657
+ if (s.startsWith("[")) return JSON.parse(s);
50658
+ return s.split(/[\n,]+/).map((x) => x.trim()).filter(Boolean);
50659
+ };
50660
+ if (type.endsWith("[]")) {
50661
+ const base = type.slice(0, -2);
50662
+ return asList(value).map((v) => coerceArg(base, v));
50663
+ }
50664
+ if (type.startsWith("uint") || type.startsWith("int")) return BigInt(String(value).trim() || "0");
50665
+ if (type === "bool") return value === true || /^(true|1|yes)$/i.test(String(value).trim());
50666
+ if (type === "address") return getAddress(String(value).trim());
50667
+ return String(value).trim();
50668
+ };
50669
+ app.post("/api/account/build-deploy-mandate", (req, res) => {
50670
+ const { template, args } = req.body ?? {};
50671
+ const art = readArtifact(template);
50672
+ if (!art) {
50673
+ res.status(404).json({ error: "no-artifact", message: `No compiled artifact for "${template}". Run \`forge build\` in the project first.` });
50674
+ return;
50675
+ }
50676
+ const ctx = rotationContext();
50677
+ if (ctx.error) {
50678
+ res.status(400).json({ error: ctx.error, message: ctx.message });
50679
+ return;
50680
+ }
50681
+ try {
50682
+ const ctor = (art.abi ?? []).find((x) => x.type === "constructor");
50683
+ const inputs = ctor?.inputs ?? [];
50684
+ const provided = Array.isArray(args) ? args : [];
50685
+ if (provided.length !== inputs.length) {
50686
+ res.status(400).json({ error: "args", message: `Expected ${inputs.length} constructor arg(s), got ${provided.length}.` });
50687
+ return;
50688
+ }
50689
+ const coerced = inputs.map((inp, i) => coerceArg(inp.type, provided[i]));
50690
+ const data = encodeDeployData({ abi: art.abi, bytecode: art.bytecode, args: coerced });
50691
+ res.json({ data, chainId: ctx.chainId, name: template });
50692
+ } catch (err) {
50693
+ res.status(400).json({ error: "encode", message: String(err) });
50694
+ }
50695
+ });
50696
+ app.post("/api/account/mandate-complete", (req, res) => {
50697
+ const { name, address, template, constructorArgs, deployTxHash, registerTxHash } = req.body ?? {};
50698
+ if (!isAddress2(address)) {
50699
+ res.status(400).json({ error: "address must be a valid address" });
50700
+ return;
50701
+ }
50702
+ const safe = readActiveSafe();
50703
+ if (!safe) {
50704
+ res.status(400).json({ error: "No active SMA." });
50705
+ return;
50706
+ }
50707
+ try {
50708
+ const permission = getAddress(address);
50709
+ const label = name || template || "Mandate";
50710
+ const account = (() => {
50711
+ try {
50712
+ return JSON.parse(import_node_fs2.default.readFileSync(at("account.json"), "utf-8"));
50713
+ } catch {
50714
+ return {};
50715
+ }
50716
+ })();
50717
+ const chainId = Number(account.chainId ?? 0) || void 0;
50718
+ const now = (/* @__PURE__ */ new Date()).toISOString();
50719
+ const storePath = at("state/mandates.json");
50720
+ let store = { version: 1, mandates: [] };
50721
+ try {
50722
+ store = JSON.parse(import_node_fs2.default.readFileSync(storePath, "utf-8"));
50723
+ } catch {
50724
+ }
50725
+ if (!Array.isArray(store.mandates)) store.mandates = [];
50726
+ const attachment = { sma: safe, txHash: registerTxHash ?? null, at: now };
50727
+ const idx = store.mandates.findIndex((m) => m.address?.toLowerCase() === permission.toLowerCase());
50728
+ if (idx === -1) {
50729
+ store.mandates.push({
50730
+ name: label,
50731
+ address: permission,
50732
+ txHash: deployTxHash ?? null,
50733
+ chainId,
50734
+ ...template ? { artifactPath: outAt(`${template}.sol/${template}.json`) } : {},
50735
+ ...Array.isArray(constructorArgs) ? { constructorArgs } : {},
50736
+ deployedAt: now,
50737
+ attachments: [attachment]
50738
+ });
50739
+ } else {
50740
+ store.mandates[idx].attachments = [...store.mandates[idx].attachments ?? [], attachment];
50741
+ }
50742
+ import_node_fs2.default.mkdirSync(at("state"), { recursive: true });
50743
+ import_node_fs2.default.writeFileSync(storePath, `${JSON.stringify(store, null, 2)}
50744
+ `);
50745
+ if (deployTxHash) {
50746
+ import_node_fs2.default.appendFileSync(at("activity.jsonl"), `${JSON.stringify({ ts: now, actor: "owner", type: "mandate_deployed", name: label, address: permission, safe, txHash: deployTxHash, ...chainId ? { chainId } : {} })}
50747
+ `);
50748
+ }
50749
+ import_node_fs2.default.appendFileSync(at("activity.jsonl"), `${JSON.stringify({ ts: now, actor: "owner", type: "permission_registered", permission, name: label, sma: safe, safe, ...registerTxHash ? { txHash: registerTxHash } : {}, ...chainId ? { chainId } : {} })}
50750
+ `);
50751
+ overviewCacheByAccount.delete(safe.toLowerCase());
50752
+ try {
50753
+ import_node_fs2.default.rmSync(overviewSnapshotPath(safe));
50754
+ } catch {
50755
+ }
50756
+ res.json({ ok: true, address: permission });
50757
+ } catch (err) {
50758
+ res.status(500).json({ error: String(err) });
50759
+ }
50760
+ });
50761
+ app.post("/api/account/rotate-complete", (req, res) => {
50762
+ const { newManager, txHash, reattachTxHash, permissions } = req.body ?? {};
50763
+ if (!isAddress2(newManager)) {
50764
+ res.status(400).json({ error: "newManager must be a valid address" });
50765
+ return;
50766
+ }
50767
+ try {
50768
+ const account = JSON.parse(import_node_fs2.default.readFileSync(at("account.json"), "utf-8"));
50769
+ const safe = account.safe;
50770
+ const manager = getAddress(newManager);
50771
+ const oldManager = account.manager ? getAddress(account.manager) : null;
50772
+ import_node_fs2.default.writeFileSync(at("account.json"), `${JSON.stringify({ ...account, manager }, null, 2)}
50773
+ `);
50774
+ try {
50775
+ const listPath = at("state/accounts.json");
50776
+ const list = JSON.parse(import_node_fs2.default.readFileSync(listPath, "utf-8"));
50777
+ const idx = list.findIndex((a) => a.safe.toLowerCase() === safe.toLowerCase());
50778
+ if (idx !== -1) {
50779
+ list[idx] = { ...list[idx], manager };
50780
+ import_node_fs2.default.writeFileSync(listPath, `${JSON.stringify(list, null, 2)}
50781
+ `);
50782
+ }
50783
+ } catch {
50784
+ }
50785
+ const append = (event) => {
50786
+ try {
50787
+ import_node_fs2.default.mkdirSync(sailDir, { recursive: true });
50788
+ import_node_fs2.default.appendFileSync(at("activity.jsonl"), `${JSON.stringify({ ts: (/* @__PURE__ */ new Date()).toISOString(), safe, ...event })}
50789
+ `);
50790
+ } catch {
50791
+ }
50792
+ };
50793
+ append({ actor: "owner", type: "signer_rotated", oldManager, newManager: manager, txHash, chainId: account.chainId });
50794
+ if (reattachTxHash && Array.isArray(permissions) && permissions.length > 0) {
50795
+ append({ actor: "owner", type: "mandates_reattached", permissions, txHash: reattachTxHash, chainId: account.chainId });
50796
+ }
50797
+ overviewCacheByAccount.delete(safe.toLowerCase());
50798
+ try {
50799
+ import_node_fs2.default.rmSync(overviewSnapshotPath(safe));
50800
+ } catch {
50801
+ }
50802
+ res.json({ ok: true, manager });
50803
+ } catch (err) {
50804
+ res.status(500).json({ error: String(err) });
50805
+ }
50806
+ });
50033
50807
  app.get("/api/mandate", (_req, res) => {
50034
50808
  try {
50035
50809
  res.json(JSON.parse(import_node_fs2.default.readFileSync(at("mandate.json"), "utf-8")));
@@ -50122,7 +50896,13 @@ function startServer(sailDir, { port = PORT } = {}) {
50122
50896
  if (match) repoUrl = match[1].replace(/\.git$/, "");
50123
50897
  } catch {
50124
50898
  }
50125
- return { file, repoUrl };
50899
+ let cron = null;
50900
+ try {
50901
+ const cm = content.match(/cron:\s*["']([^"']+)["']/);
50902
+ if (cm) cron = cm[1].trim();
50903
+ } catch {
50904
+ }
50905
+ return { file, repoUrl, cron };
50126
50906
  }
50127
50907
  } catch {
50128
50908
  }
@@ -50462,35 +51242,7 @@ function startServer(sailDir, { port = PORT } = {}) {
50462
51242
  res.status(500).json({ error: String(err) });
50463
51243
  }
50464
51244
  });
50465
- app.get("/api/wizard-state", (_req, res) => {
50466
- try {
50467
- const raw = import_node_fs2.default.readFileSync(at(".wizard-state.json"), "utf-8");
50468
- res.json(JSON.parse(raw));
50469
- } catch {
50470
- res.json(null);
50471
- }
50472
- });
50473
- app.post("/api/wizard-state", (req, res) => {
50474
- try {
50475
- import_node_fs2.default.mkdirSync(sailDir, { recursive: true });
50476
- import_node_fs2.default.writeFileSync(at(".wizard-state.json"), `${JSON.stringify(req.body, null, 2)}
50477
- `);
50478
- res.json({ ok: true });
50479
- } catch (err) {
50480
- res.status(500).json({ error: String(err) });
50481
- }
50482
- });
50483
- app.get("/api/positions", (_req, res) => {
50484
- try {
50485
- const account = JSON.parse(import_node_fs2.default.readFileSync(at("account.json"), "utf-8"));
50486
- const chainId = account?.chainId ?? 8453;
50487
- const file = at(`state/positions-${chainId}.json`);
50488
- res.json(JSON.parse(import_node_fs2.default.readFileSync(file, "utf-8")));
50489
- } catch {
50490
- res.status(404).json({ error: "no positions snapshot" });
50491
- }
50492
- });
50493
- app.get("/api/overview", async (_req, res) => {
51245
+ app.get("/api/overview", async (req, res) => {
50494
51246
  let account = null;
50495
51247
  try {
50496
51248
  account = JSON.parse(import_node_fs2.default.readFileSync(at("account.json"), "utf-8"));
@@ -50503,6 +51255,16 @@ function startServer(sailDir, { port = PORT } = {}) {
50503
51255
  return;
50504
51256
  }
50505
51257
  const key = account.safe.toLowerCase();
51258
+ if (req.query?.fresh != null) {
51259
+ try {
51260
+ const data2 = await computeOverview(account);
51261
+ storeOverview(account.safe, data2);
51262
+ res.json(data2);
51263
+ } catch {
51264
+ res.json(overviewCacheByAccount.get(key)?.data ?? readOverviewSnapshot(account.safe) ?? null);
51265
+ }
51266
+ return;
51267
+ }
50506
51268
  const cached = overviewCacheByAccount.get(key);
50507
51269
  if (cached && Date.now() - cached.at < OVERVIEW_TTL_MS) {
50508
51270
  res.json(cached.data);
@@ -50518,6 +51280,74 @@ function startServer(sailDir, { port = PORT } = {}) {
50518
51280
  storeOverview(account.safe, data);
50519
51281
  res.json(data);
50520
51282
  });
51283
+ const buildMandateLedger = (safe, activeAddrs, nameByAddr, templateByAddr, network) => {
51284
+ const safeLower = safe.toLowerCase();
51285
+ const meta = /* @__PURE__ */ new Map();
51286
+ try {
51287
+ const tracked = JSON.parse(import_node_fs2.default.readFileSync(at("state/mandates.json"), "utf-8"));
51288
+ for (const m of tracked.mandates ?? []) {
51289
+ if (!m.address) continue;
51290
+ const mine = (m.attachments ?? []).filter((a) => a.sma?.toLowerCase() === safeLower);
51291
+ if (mine.length === 0) continue;
51292
+ const first = mine.reduce((a, b) => a.at && b.at && a.at < b.at ? a : b);
51293
+ meta.set(m.address.toLowerCase(), { firstAt: first?.at ?? m.deployedAt ?? null, txHash: first?.txHash ?? m.txHash ?? null });
51294
+ }
51295
+ } catch {
51296
+ }
51297
+ const registeredAt = /* @__PURE__ */ new Map();
51298
+ const revokedAt = /* @__PURE__ */ new Map();
51299
+ try {
51300
+ for (const line of import_node_fs2.default.readFileSync(at("activity.jsonl"), "utf-8").split("\n")) {
51301
+ if (!line.trim()) continue;
51302
+ let e;
51303
+ try {
51304
+ e = JSON.parse(line);
51305
+ } catch {
51306
+ continue;
51307
+ }
51308
+ if (e.safe && e.safe.toLowerCase() !== safeLower) continue;
51309
+ const addrs = [];
51310
+ if (typeof e.permission === "string") addrs.push(e.permission);
51311
+ if (Array.isArray(e.permissions)) addrs.push(...e.permissions);
51312
+ if (e.type === "mandate_deployed" && typeof e.address === "string") addrs.push(e.address);
51313
+ const reg = e.type === "permission_registered" || e.type === "mandates_reattached" || e.type === "mandate_deployed";
51314
+ const rev = e.type === "permission_revoked" || e.type === "mandate_revoked" || e.type === "permission_detached";
51315
+ for (const a of addrs) {
51316
+ const al = a.toLowerCase();
51317
+ if (reg && (!registeredAt.has(al) || e.ts < registeredAt.get(al))) registeredAt.set(al, e.ts);
51318
+ if (rev && (!revokedAt.has(al) || e.ts > revokedAt.get(al))) revokedAt.set(al, e.ts);
51319
+ }
51320
+ }
51321
+ } catch {
51322
+ }
51323
+ const all = /* @__PURE__ */ new Set([...activeAddrs, ...meta.keys(), ...registeredAt.keys()]);
51324
+ const ledger = [];
51325
+ for (const al of all) {
51326
+ const isActive = activeAddrs.has(al);
51327
+ const revoked = revokedAt.get(al);
51328
+ let status;
51329
+ if (isActive) status = "active";
51330
+ else if (revoked) status = "revoked";
51331
+ else if (meta.has(al) || registeredAt.has(al)) status = "revoked";
51332
+ else continue;
51333
+ ledger.push({
51334
+ address: getAddress(`0x${al.replace(/^0x/, "")}`),
51335
+ name: nameByAddr.get(al) ?? null,
51336
+ template: templateByAddr.get(al) ?? null,
51337
+ status,
51338
+ registeredAt: registeredAt.get(al) ?? meta.get(al)?.firstAt ?? null,
51339
+ revokedAt: revoked ?? null,
51340
+ txHash: meta.get(al)?.txHash ?? null,
51341
+ network
51342
+ });
51343
+ }
51344
+ const ts = (m) => m.revokedAt ?? m.registeredAt ?? "";
51345
+ ledger.sort((a, b) => {
51346
+ if (a.status === "active" !== (b.status === "active")) return a.status === "active" ? -1 : 1;
51347
+ return ts(b).localeCompare(ts(a));
51348
+ });
51349
+ return ledger;
51350
+ };
50521
51351
  async function computeOverview(account) {
50522
51352
  const env = parseEnvFile(at(".env.local"));
50523
51353
  const chainId = Number(account.chainId ?? env.CHAIN_ID ?? 0);
@@ -50611,12 +51441,8 @@ function startServer(sailDir, { port = PORT } = {}) {
50611
51441
  result.sma.balanceWei = safeBal.toString();
50612
51442
  result.sma.balanceEth = formatEther(safeBal);
50613
51443
  result.sma.balanceStatus = balanceStatus(safeBal);
50614
- result.mandates = perms.map((addr) => ({
50615
- address: addr,
50616
- name: nameByAddr.get(addr.toLowerCase()) ?? null,
50617
- template: templateByAddr.get(addr.toLowerCase()) ?? null,
50618
- network
50619
- }));
51444
+ const activeAddrs = new Set(perms.map((a) => a.toLowerCase()));
51445
+ result.mandates = buildMandateLedger(account.safe, activeAddrs, nameByAddr, templateByAddr, network);
50620
51446
  let managerEntry;
50621
51447
  if (managerSet) {
50622
51448
  managerEntry = signerEntry("manager", managerAddr, balanceByAddr);
@@ -50688,6 +51514,20 @@ function startServer(sailDir, { port = PORT } = {}) {
50688
51514
  socket.destroy();
50689
51515
  return;
50690
51516
  }
51517
+ const origin = req.headers.origin;
51518
+ if (origin) {
51519
+ try {
51520
+ const { hostname } = new URL(origin);
51521
+ if (hostname !== "localhost" && hostname !== "127.0.0.1") {
51522
+ socket.write("HTTP/1.1 403 Forbidden\r\n\r\n");
51523
+ socket.destroy();
51524
+ return;
51525
+ }
51526
+ } catch {
51527
+ socket.destroy();
51528
+ return;
51529
+ }
51530
+ }
50691
51531
  wss.handleUpgrade(req, socket, head, (client) => relayToDaemon(client));
50692
51532
  });
50693
51533
  async function relayToDaemon(client) {