@rhinestone/sdk 2.0.0-beta.9 → 2.1.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.
Files changed (615) hide show
  1. package/README.md +2 -2
  2. package/dist/src/accounts/adapter.d.ts +31 -0
  3. package/dist/src/accounts/adapter.d.ts.map +1 -0
  4. package/dist/src/accounts/adapters/eoa.d.ts +4 -0
  5. package/dist/src/accounts/adapters/eoa.d.ts.map +1 -0
  6. package/dist/src/accounts/adapters/eoa.js +45 -0
  7. package/dist/src/accounts/adapters/hca.d.ts +5 -0
  8. package/dist/src/accounts/adapters/hca.d.ts.map +1 -0
  9. package/dist/src/accounts/adapters/hca.js +121 -0
  10. package/dist/src/accounts/adapters/kernel.d.ts +9 -0
  11. package/dist/src/accounts/adapters/kernel.d.ts.map +1 -0
  12. package/dist/src/accounts/adapters/kernel.js +159 -0
  13. package/dist/src/accounts/adapters/nexus.d.ts +16 -0
  14. package/dist/src/accounts/adapters/nexus.d.ts.map +1 -0
  15. package/dist/src/accounts/adapters/nexus.js +212 -0
  16. package/dist/src/accounts/adapters/safe.d.ts +6 -0
  17. package/dist/src/accounts/adapters/safe.d.ts.map +1 -0
  18. package/dist/src/accounts/adapters/safe.js +194 -0
  19. package/dist/src/accounts/adapters/shared.d.ts +9 -0
  20. package/dist/src/accounts/adapters/shared.d.ts.map +1 -0
  21. package/dist/src/accounts/adapters/shared.js +62 -0
  22. package/dist/src/accounts/adapters/startale.d.ts +14 -0
  23. package/dist/src/accounts/adapters/startale.d.ts.map +1 -0
  24. package/dist/src/accounts/adapters/startale.js +165 -0
  25. package/dist/src/accounts/construction.d.ts +25 -0
  26. package/dist/src/accounts/construction.d.ts.map +1 -0
  27. package/dist/src/accounts/construction.js +34 -0
  28. package/dist/src/accounts/deployment.d.ts +12 -0
  29. package/dist/src/accounts/deployment.d.ts.map +1 -0
  30. package/dist/src/accounts/deployment.js +33 -0
  31. package/dist/src/accounts/erc7579-calls.d.ts +4 -0
  32. package/dist/src/accounts/erc7579-calls.d.ts.map +1 -0
  33. package/dist/src/accounts/erc7579-calls.js +57 -0
  34. package/dist/src/accounts/error.d.ts +3 -10
  35. package/dist/src/accounts/error.d.ts.map +1 -1
  36. package/dist/src/accounts/error.js +5 -11
  37. package/dist/src/accounts/legacy.d.ts +14 -0
  38. package/dist/src/accounts/legacy.d.ts.map +1 -0
  39. package/dist/src/accounts/legacy.js +40 -0
  40. package/dist/src/accounts/registry.d.ts +4 -0
  41. package/dist/src/accounts/registry.d.ts.map +1 -0
  42. package/dist/src/accounts/registry.js +22 -0
  43. package/dist/src/accounts/types.d.ts +131 -0
  44. package/dist/src/accounts/types.d.ts.map +1 -0
  45. package/dist/src/accounts/types.js +1 -0
  46. package/dist/src/accounts/wallet-account.d.ts +3 -0
  47. package/dist/src/accounts/wallet-account.d.ts.map +1 -0
  48. package/dist/src/accounts/wallet-account.js +12 -0
  49. package/dist/src/actions/deploy.d.ts +4 -0
  50. package/dist/src/actions/deploy.d.ts.map +1 -0
  51. package/dist/src/actions/deploy.js +8 -0
  52. package/dist/src/actions/ecdsa.d.ts +2 -2
  53. package/dist/src/actions/ecdsa.d.ts.map +1 -1
  54. package/dist/src/actions/ecdsa.js +12 -65
  55. package/dist/src/actions/index.d.ts +2 -16
  56. package/dist/src/actions/index.d.ts.map +1 -1
  57. package/dist/src/actions/index.js +3 -49
  58. package/dist/src/actions/mfa.d.ts +1 -1
  59. package/dist/src/actions/mfa.d.ts.map +1 -1
  60. package/dist/src/actions/mfa.js +30 -10
  61. package/dist/src/actions/modules.d.ts +4 -0
  62. package/dist/src/actions/modules.d.ts.map +1 -0
  63. package/dist/src/actions/modules.js +22 -0
  64. package/dist/src/actions/ownable.d.ts +6 -0
  65. package/dist/src/actions/ownable.d.ts.map +1 -0
  66. package/dist/src/actions/ownable.js +63 -0
  67. package/dist/src/actions/passkeys.d.ts +2 -2
  68. package/dist/src/actions/passkeys.d.ts.map +1 -1
  69. package/dist/src/actions/passkeys.js +23 -78
  70. package/dist/src/actions/recovery.d.ts +58 -24
  71. package/dist/src/actions/recovery.d.ts.map +1 -1
  72. package/dist/src/actions/recovery.js +107 -162
  73. package/dist/src/actions/runtime.d.ts +17 -0
  74. package/dist/src/actions/runtime.d.ts.map +1 -0
  75. package/dist/src/actions/runtime.js +182 -0
  76. package/dist/src/actions/smart-sessions.d.ts +30 -6
  77. package/dist/src/actions/smart-sessions.d.ts.map +1 -1
  78. package/dist/src/actions/smart-sessions.js +69 -18
  79. package/dist/src/actions/webauthn.d.ts +6 -0
  80. package/dist/src/actions/webauthn.d.ts.map +1 -0
  81. package/dist/src/actions/webauthn.js +67 -0
  82. package/dist/src/api/account.d.ts +265 -0
  83. package/dist/src/api/account.d.ts.map +1 -0
  84. package/dist/src/api/account.js +638 -0
  85. package/dist/src/api/accounts.d.ts +12 -0
  86. package/dist/src/api/accounts.d.ts.map +1 -0
  87. package/dist/src/api/accounts.js +17 -0
  88. package/dist/src/api/compose-types.d.ts +147 -0
  89. package/dist/src/api/compose-types.d.ts.map +1 -0
  90. package/dist/src/api/compose-types.js +1 -0
  91. package/dist/src/api/compose.d.ts +6 -0
  92. package/dist/src/api/compose.d.ts.map +1 -0
  93. package/dist/src/api/compose.js +772 -0
  94. package/dist/src/api/direct-signing.d.ts +27 -0
  95. package/dist/src/api/direct-signing.d.ts.map +1 -0
  96. package/dist/src/api/direct-signing.js +191 -0
  97. package/dist/src/api/project-mappers.d.ts +7 -0
  98. package/dist/src/api/project-mappers.d.ts.map +1 -0
  99. package/dist/src/api/project-mappers.js +23 -0
  100. package/dist/src/api/queries/app-fees.d.ts +4 -0
  101. package/dist/src/api/queries/app-fees.d.ts.map +1 -0
  102. package/dist/src/api/queries/app-fees.js +3 -0
  103. package/dist/src/api/queries/portfolio.d.ts +9 -0
  104. package/dist/src/api/queries/portfolio.d.ts.map +1 -0
  105. package/dist/src/api/queries/portfolio.js +28 -0
  106. package/dist/src/api/queries/session.d.ts +8 -0
  107. package/dist/src/api/queries/session.d.ts.map +1 -0
  108. package/dist/src/api/queries/session.js +15 -0
  109. package/dist/src/api/sdk.d.ts +80 -0
  110. package/dist/src/api/sdk.d.ts.map +1 -0
  111. package/dist/src/api/sdk.js +103 -0
  112. package/dist/src/api/signer-selection.d.ts +20 -0
  113. package/dist/src/api/signer-selection.d.ts.map +1 -0
  114. package/dist/src/api/signer-selection.js +159 -0
  115. package/dist/src/calls/normalize.d.ts +9 -0
  116. package/dist/src/calls/normalize.d.ts.map +1 -0
  117. package/dist/src/calls/normalize.js +17 -0
  118. package/dist/src/calls/resolve.d.ts +3 -0
  119. package/dist/src/calls/resolve.d.ts.map +1 -0
  120. package/dist/src/calls/resolve.js +15 -0
  121. package/dist/src/calls/types.d.ts +25 -0
  122. package/dist/src/calls/types.d.ts.map +1 -0
  123. package/dist/src/calls/types.js +1 -0
  124. package/dist/src/chains/caip2.d.ts +10 -0
  125. package/dist/src/chains/caip2.d.ts.map +1 -0
  126. package/dist/src/chains/caip2.js +85 -0
  127. package/dist/src/chains/catalog.d.ts +5 -0
  128. package/dist/src/chains/catalog.d.ts.map +1 -0
  129. package/dist/src/chains/catalog.js +41 -0
  130. package/dist/src/chains/errors.d.ts +15 -0
  131. package/dist/src/chains/errors.d.ts.map +1 -0
  132. package/dist/src/chains/errors.js +21 -0
  133. package/dist/src/{orchestrator/destinations.d.ts → chains/non-evm.d.ts} +9 -6
  134. package/dist/src/chains/non-evm.d.ts.map +1 -0
  135. package/dist/src/chains/non-evm.js +30 -0
  136. package/dist/src/chains/tokens.d.ts +4 -0
  137. package/dist/src/chains/tokens.d.ts.map +1 -0
  138. package/dist/src/chains/tokens.js +22 -0
  139. package/dist/src/chains/types.d.ts +25 -0
  140. package/dist/src/chains/types.d.ts.map +1 -0
  141. package/dist/src/chains/types.js +1 -0
  142. package/dist/src/clients/bundler/client.d.ts +10 -0
  143. package/dist/src/clients/bundler/client.d.ts.map +1 -0
  144. package/dist/src/clients/bundler/client.js +85 -0
  145. package/dist/src/clients/bundler/endpoints.d.ts +3 -0
  146. package/dist/src/clients/bundler/endpoints.d.ts.map +1 -0
  147. package/dist/src/clients/bundler/endpoints.js +18 -0
  148. package/dist/src/clients/bundler/port.d.ts +22 -0
  149. package/dist/src/clients/bundler/port.d.ts.map +1 -0
  150. package/dist/src/clients/bundler/port.js +1 -0
  151. package/dist/src/clients/json-rpc.d.ts +20 -0
  152. package/dist/src/clients/json-rpc.d.ts.map +1 -0
  153. package/dist/src/clients/json-rpc.js +56 -0
  154. package/dist/src/clients/orchestrator/auth.d.ts +7 -0
  155. package/dist/src/clients/orchestrator/auth.d.ts.map +1 -0
  156. package/dist/src/clients/orchestrator/auth.js +27 -0
  157. package/dist/src/clients/orchestrator/chain-catalog.d.ts +36 -0
  158. package/dist/src/clients/orchestrator/chain-catalog.d.ts.map +1 -0
  159. package/dist/src/clients/orchestrator/chain-catalog.js +67 -0
  160. package/dist/src/clients/orchestrator/client.d.ts +13 -0
  161. package/dist/src/clients/orchestrator/client.d.ts.map +1 -0
  162. package/dist/src/clients/orchestrator/client.js +97 -0
  163. package/dist/src/clients/orchestrator/errors.d.ts +238 -0
  164. package/dist/src/clients/orchestrator/errors.d.ts.map +1 -0
  165. package/dist/src/clients/orchestrator/errors.js +525 -0
  166. package/dist/src/clients/orchestrator/fetch.d.ts +7 -0
  167. package/dist/src/clients/orchestrator/fetch.d.ts.map +1 -0
  168. package/dist/src/clients/orchestrator/fetch.js +37 -0
  169. package/dist/src/clients/orchestrator/mappers.d.ts +9 -0
  170. package/dist/src/clients/orchestrator/mappers.d.ts.map +1 -0
  171. package/dist/src/clients/orchestrator/mappers.js +198 -0
  172. package/dist/src/clients/orchestrator/port.d.ts +26 -0
  173. package/dist/src/clients/orchestrator/port.d.ts.map +1 -0
  174. package/dist/src/clients/orchestrator/port.js +1 -0
  175. package/dist/src/{orchestrator/types.d.ts → clients/orchestrator/public.d.ts} +113 -43
  176. package/dist/src/clients/orchestrator/public.d.ts.map +1 -0
  177. package/dist/src/clients/orchestrator/public.js +14 -0
  178. package/dist/src/clients/orchestrator/types.d.ts +144 -0
  179. package/dist/src/clients/orchestrator/types.d.ts.map +1 -0
  180. package/dist/src/clients/orchestrator/types.js +1 -0
  181. package/dist/src/clients/orchestrator/wire.d.ts +19 -0
  182. package/dist/src/clients/orchestrator/wire.d.ts.map +1 -0
  183. package/dist/src/clients/orchestrator/wire.gen.d.ts +6463 -0
  184. package/dist/src/clients/orchestrator/wire.gen.d.ts.map +1 -0
  185. package/dist/src/clients/orchestrator/wire.gen.js +1 -0
  186. package/dist/src/clients/orchestrator/wire.js +1 -0
  187. package/dist/src/clients/paymaster/client.d.ts +8 -0
  188. package/dist/src/clients/paymaster/client.d.ts.map +1 -0
  189. package/dist/src/clients/paymaster/client.js +38 -0
  190. package/dist/src/clients/paymaster/endpoints.d.ts +3 -0
  191. package/dist/src/clients/paymaster/endpoints.d.ts.map +1 -0
  192. package/dist/src/clients/paymaster/endpoints.js +16 -0
  193. package/dist/src/clients/paymaster/port.d.ts +17 -0
  194. package/dist/src/clients/paymaster/port.d.ts.map +1 -0
  195. package/dist/src/clients/paymaster/port.js +1 -0
  196. package/dist/src/clients/rpc/client.d.ts +6 -0
  197. package/dist/src/clients/rpc/client.d.ts.map +1 -0
  198. package/dist/src/clients/rpc/client.js +66 -0
  199. package/dist/src/clients/rpc/compatibility.d.ts +12 -0
  200. package/dist/src/clients/rpc/compatibility.d.ts.map +1 -0
  201. package/dist/src/clients/rpc/compatibility.js +16 -0
  202. package/dist/src/clients/rpc/port.d.ts +13 -0
  203. package/dist/src/clients/rpc/port.d.ts.map +1 -0
  204. package/dist/src/clients/rpc/port.js +1 -0
  205. package/dist/src/clients/rpc/providers.d.ts +3 -0
  206. package/dist/src/clients/rpc/providers.d.ts.map +1 -0
  207. package/dist/src/clients/rpc/providers.js +8 -0
  208. package/dist/src/clients/rpc/transport.d.ts +4 -0
  209. package/dist/src/clients/rpc/transport.d.ts.map +1 -0
  210. package/dist/src/clients/rpc/transport.js +5 -0
  211. package/dist/src/clients/rpc/types.d.ts +23 -0
  212. package/dist/src/clients/rpc/types.d.ts.map +1 -0
  213. package/dist/src/clients/rpc/types.js +1 -0
  214. package/dist/src/config/account-runtime.d.ts +7 -0
  215. package/dist/src/config/account-runtime.d.ts.map +1 -0
  216. package/dist/src/config/account-runtime.js +36 -0
  217. package/dist/src/config/account.d.ts +767 -0
  218. package/dist/src/config/account.d.ts.map +1 -0
  219. package/dist/src/config/account.js +10 -0
  220. package/dist/src/config/defaults.d.ts +14 -0
  221. package/dist/src/config/defaults.d.ts.map +1 -0
  222. package/dist/src/config/defaults.js +26 -0
  223. package/dist/src/config/input.d.ts +59 -0
  224. package/dist/src/config/input.d.ts.map +1 -0
  225. package/dist/src/config/input.js +1 -0
  226. package/dist/src/config/legacy.d.ts +22 -0
  227. package/dist/src/config/legacy.d.ts.map +1 -0
  228. package/dist/src/config/legacy.js +23 -0
  229. package/dist/src/config/resolve.d.ts +13 -0
  230. package/dist/src/config/resolve.d.ts.map +1 -0
  231. package/dist/src/config/resolve.js +200 -0
  232. package/dist/src/config/resolved.d.ts +77 -0
  233. package/dist/src/config/resolved.d.ts.map +1 -0
  234. package/dist/src/config/resolved.js +1 -0
  235. package/dist/src/config/validate.d.ts +3 -0
  236. package/dist/src/config/validate.d.ts.map +1 -0
  237. package/dist/src/config/validate.js +6 -0
  238. package/dist/src/{execution/error.d.ts → errors/execution.d.ts} +47 -9
  239. package/dist/src/errors/execution.d.ts.map +1 -0
  240. package/dist/src/errors/execution.js +131 -0
  241. package/dist/src/errors/index.d.ts +6 -4
  242. package/dist/src/errors/index.d.ts.map +1 -1
  243. package/dist/src/errors/index.js +7 -6
  244. package/dist/src/index.d.ts +14 -84
  245. package/dist/src/index.d.ts.map +1 -1
  246. package/dist/src/index.js +9 -293
  247. package/dist/src/jwt-server/jcs.d.ts +1 -1
  248. package/dist/src/jwt-server/jcs.js +4 -2
  249. package/dist/src/modules/erc7579-abi.d.ts +4 -0
  250. package/dist/src/modules/erc7579-abi.d.ts.map +1 -0
  251. package/dist/src/modules/erc7579-abi.js +12 -0
  252. package/dist/src/modules/intent-executor.d.ts +6 -0
  253. package/dist/src/modules/intent-executor.d.ts.map +1 -0
  254. package/dist/src/modules/intent-executor.js +13 -0
  255. package/dist/src/modules/legacy-core.d.ts +29 -0
  256. package/dist/src/modules/legacy-core.d.ts.map +1 -0
  257. package/dist/src/modules/legacy-core.js +80 -0
  258. package/dist/src/modules/normalize.d.ts +4 -0
  259. package/dist/src/modules/normalize.d.ts.map +1 -0
  260. package/dist/src/modules/normalize.js +15 -0
  261. package/dist/src/modules/plan.d.ts +16 -0
  262. package/dist/src/modules/plan.d.ts.map +1 -0
  263. package/dist/src/modules/plan.js +51 -0
  264. package/dist/src/modules/read-core.d.ts +62 -0
  265. package/dist/src/modules/read-core.d.ts.map +1 -0
  266. package/dist/src/modules/read-core.js +206 -0
  267. package/dist/src/modules/types.d.ts +46 -0
  268. package/dist/src/modules/types.d.ts.map +1 -0
  269. package/dist/src/modules/types.js +1 -0
  270. package/dist/src/modules/validators/capabilities.d.ts +4 -0
  271. package/dist/src/modules/validators/capabilities.d.ts.map +1 -0
  272. package/dist/src/modules/validators/capabilities.js +58 -0
  273. package/dist/src/modules/validators/contribution.d.ts +4 -0
  274. package/dist/src/modules/validators/contribution.d.ts.map +1 -0
  275. package/dist/src/modules/validators/contribution.js +64 -0
  276. package/dist/src/modules/validators/definition.d.ts +3 -0
  277. package/dist/src/modules/validators/definition.d.ts.map +1 -0
  278. package/dist/src/modules/validators/definition.js +68 -0
  279. package/dist/src/modules/validators/ens.d.ts +5 -0
  280. package/dist/src/modules/validators/ens.d.ts.map +1 -0
  281. package/dist/src/modules/validators/ens.js +34 -0
  282. package/dist/src/modules/validators/k1.d.ts +2 -0
  283. package/dist/src/modules/validators/k1.d.ts.map +1 -0
  284. package/dist/src/modules/validators/k1.js +1 -0
  285. package/dist/src/modules/validators/multi-factor.d.ts +18 -0
  286. package/dist/src/modules/validators/multi-factor.d.ts.map +1 -0
  287. package/dist/src/modules/validators/multi-factor.js +79 -0
  288. package/dist/src/modules/validators/ownable.d.ts +26 -0
  289. package/dist/src/modules/validators/ownable.d.ts.map +1 -0
  290. package/dist/src/modules/validators/ownable.js +84 -0
  291. package/dist/src/modules/validators/permissions.d.ts +2 -1
  292. package/dist/src/modules/validators/permissions.d.ts.map +1 -1
  293. package/dist/src/modules/validators/permissions.js +192 -18
  294. package/dist/src/modules/validators/policies/claim/arbiters.d.ts +19 -0
  295. package/dist/src/modules/validators/policies/claim/arbiters.d.ts.map +1 -0
  296. package/dist/src/modules/validators/policies/claim/arbiters.js +82 -0
  297. package/dist/src/modules/validators/resolve.d.ts +5 -0
  298. package/dist/src/modules/validators/resolve.d.ts.map +1 -0
  299. package/dist/src/modules/validators/resolve.js +22 -0
  300. package/dist/src/modules/validators/signer-id.d.ts +5 -0
  301. package/dist/src/modules/validators/signer-id.d.ts.map +1 -0
  302. package/dist/src/modules/validators/signer-id.js +8 -0
  303. package/dist/src/modules/validators/smart-session-signature-types.d.ts +35 -0
  304. package/dist/src/modules/validators/smart-session-signature-types.d.ts.map +1 -0
  305. package/dist/src/modules/validators/smart-session-signature-types.js +1 -0
  306. package/dist/src/modules/validators/smart-sessions/authorization.d.ts +99 -0
  307. package/dist/src/modules/validators/smart-sessions/authorization.d.ts.map +1 -0
  308. package/dist/src/modules/validators/smart-sessions/authorization.js +101 -0
  309. package/dist/src/modules/validators/smart-sessions/calls.d.ts +19 -0
  310. package/dist/src/modules/validators/smart-sessions/calls.d.ts.map +1 -0
  311. package/dist/src/modules/validators/smart-sessions/calls.js +85 -0
  312. package/dist/src/modules/validators/smart-sessions/cross-chain-permits.d.ts +4 -0
  313. package/dist/src/modules/validators/smart-sessions/cross-chain-permits.d.ts.map +1 -0
  314. package/dist/src/modules/validators/smart-sessions/cross-chain-permits.js +77 -0
  315. package/dist/src/modules/validators/smart-sessions/digest.d.ts +5 -0
  316. package/dist/src/modules/validators/smart-sessions/digest.d.ts.map +1 -0
  317. package/dist/src/modules/validators/smart-sessions/digest.js +30 -0
  318. package/dist/src/modules/validators/smart-sessions/mock-signature.d.ts +10 -0
  319. package/dist/src/modules/validators/smart-sessions/mock-signature.d.ts.map +1 -0
  320. package/dist/src/modules/validators/smart-sessions/mock-signature.js +31 -0
  321. package/dist/src/modules/validators/smart-sessions/module.d.ts +11 -0
  322. package/dist/src/modules/validators/smart-sessions/module.d.ts.map +1 -0
  323. package/dist/src/modules/validators/smart-sessions/module.js +18 -0
  324. package/dist/src/modules/validators/smart-sessions/policies/addresses.d.ts +23 -0
  325. package/dist/src/modules/validators/smart-sessions/policies/addresses.d.ts.map +1 -0
  326. package/dist/src/modules/validators/smart-sessions/policies/addresses.js +29 -0
  327. package/dist/src/modules/validators/smart-sessions/policies/claim.d.ts +10 -0
  328. package/dist/src/modules/validators/smart-sessions/policies/claim.d.ts.map +1 -0
  329. package/dist/src/modules/validators/smart-sessions/policies/claim.js +106 -0
  330. package/dist/src/modules/validators/smart-sessions/policies/encode.d.ts +4 -0
  331. package/dist/src/modules/validators/smart-sessions/policies/encode.d.ts.map +1 -0
  332. package/dist/src/modules/validators/smart-sessions/policies/encode.js +197 -0
  333. package/dist/src/modules/validators/smart-sessions/resolve.d.ts +16 -0
  334. package/dist/src/modules/validators/smart-sessions/resolve.d.ts.map +1 -0
  335. package/dist/src/modules/validators/smart-sessions/resolve.js +120 -0
  336. package/dist/src/modules/validators/smart-sessions/signature.d.ts +14 -0
  337. package/dist/src/modules/validators/smart-sessions/signature.d.ts.map +1 -0
  338. package/dist/src/modules/validators/smart-sessions/signature.js +167 -0
  339. package/dist/src/modules/validators/smart-sessions/state.d.ts +19 -0
  340. package/dist/src/modules/validators/smart-sessions/state.d.ts.map +1 -0
  341. package/dist/src/modules/validators/smart-sessions/state.js +42 -0
  342. package/dist/src/modules/validators/smart-sessions/types.d.ts +227 -0
  343. package/dist/src/modules/validators/smart-sessions/types.d.ts.map +1 -0
  344. package/dist/src/modules/validators/smart-sessions/types.js +1 -0
  345. package/dist/src/modules/validators/social-recovery.d.ts +16 -0
  346. package/dist/src/modules/validators/social-recovery.d.ts.map +1 -0
  347. package/dist/src/modules/validators/social-recovery.js +17 -0
  348. package/dist/src/modules/validators/types.d.ts +143 -0
  349. package/dist/src/modules/validators/types.d.ts.map +1 -0
  350. package/dist/src/modules/validators/types.js +1 -0
  351. package/dist/src/modules/validators/webauthn.d.ts +54 -0
  352. package/dist/src/modules/validators/webauthn.d.ts.map +1 -0
  353. package/dist/src/modules/validators/webauthn.js +159 -0
  354. package/dist/src/signing/context.d.ts +25 -0
  355. package/dist/src/signing/context.d.ts.map +1 -0
  356. package/dist/src/signing/context.js +163 -0
  357. package/dist/src/signing/contribution.d.ts +13 -0
  358. package/dist/src/signing/contribution.d.ts.map +1 -0
  359. package/dist/src/signing/contribution.js +83 -0
  360. package/dist/src/signing/eip7702.d.ts +41 -0
  361. package/dist/src/signing/eip7702.d.ts.map +1 -0
  362. package/dist/src/signing/eip7702.js +215 -0
  363. package/dist/src/signing/error.d.ts +27 -0
  364. package/dist/src/signing/error.d.ts.map +1 -0
  365. package/dist/src/signing/error.js +25 -0
  366. package/dist/src/signing/execute.d.ts +17 -0
  367. package/dist/src/signing/execute.d.ts.map +1 -0
  368. package/dist/src/signing/execute.js +138 -0
  369. package/dist/src/signing/intent-plans/assemble.d.ts +15 -0
  370. package/dist/src/signing/intent-plans/assemble.d.ts.map +1 -0
  371. package/dist/src/signing/intent-plans/assemble.js +96 -0
  372. package/dist/src/signing/intent-plans/independent.d.ts +48 -0
  373. package/dist/src/signing/intent-plans/independent.d.ts.map +1 -0
  374. package/dist/src/signing/intent-plans/independent.js +150 -0
  375. package/dist/src/signing/intent-plans/plan.d.ts +14 -0
  376. package/dist/src/signing/intent-plans/plan.d.ts.map +1 -0
  377. package/dist/src/signing/intent-plans/plan.js +187 -0
  378. package/dist/src/signing/intent-plans/types.d.ts +63 -0
  379. package/dist/src/signing/intent-plans/types.d.ts.map +1 -0
  380. package/dist/src/signing/intent-plans/types.js +1 -0
  381. package/dist/src/signing/message.d.ts +28 -0
  382. package/dist/src/signing/message.d.ts.map +1 -0
  383. package/dist/src/signing/message.js +90 -0
  384. package/dist/src/signing/passkeys.d.ts +28 -0
  385. package/dist/src/signing/passkeys.d.ts.map +1 -0
  386. package/dist/src/signing/passkeys.js +17 -0
  387. package/dist/src/signing/plan.d.ts +35 -0
  388. package/dist/src/signing/plan.d.ts.map +1 -0
  389. package/dist/src/signing/plan.js +377 -0
  390. package/dist/src/signing/protocols/erc6492.d.ts +11 -0
  391. package/dist/src/signing/protocols/erc6492.d.ts.map +1 -0
  392. package/dist/src/signing/protocols/erc6492.js +24 -0
  393. package/dist/src/signing/protocols/erc7739.d.ts +17 -0
  394. package/dist/src/signing/protocols/erc7739.d.ts.map +1 -0
  395. package/dist/src/signing/protocols/erc7739.js +84 -0
  396. package/dist/src/signing/session-enable.d.ts +35 -0
  397. package/dist/src/signing/session-enable.d.ts.map +1 -0
  398. package/dist/src/signing/session-enable.js +62 -0
  399. package/dist/src/signing/signers/compatibility.d.ts +4 -0
  400. package/dist/src/signing/signers/compatibility.d.ts.map +1 -0
  401. package/dist/src/signing/signers/compatibility.js +51 -0
  402. package/dist/src/signing/signers/ecdsa.d.ts +14 -0
  403. package/dist/src/signing/signers/ecdsa.d.ts.map +1 -0
  404. package/dist/src/signing/signers/ecdsa.js +54 -0
  405. package/dist/src/signing/signers/registry.d.ts +7 -0
  406. package/dist/src/signing/signers/registry.d.ts.map +1 -0
  407. package/dist/src/signing/signers/registry.js +33 -0
  408. package/dist/src/signing/signers/types.d.ts +16 -0
  409. package/dist/src/signing/signers/types.d.ts.map +1 -0
  410. package/dist/src/signing/signers/types.js +1 -0
  411. package/dist/src/signing/signers/wallet-chain.d.ts +9 -0
  412. package/dist/src/signing/signers/wallet-chain.d.ts.map +1 -0
  413. package/dist/src/signing/signers/wallet-chain.js +15 -0
  414. package/dist/src/signing/signers/webauthn.d.ts +11 -0
  415. package/dist/src/signing/signers/webauthn.d.ts.map +1 -0
  416. package/dist/src/signing/signers/webauthn.js +14 -0
  417. package/dist/src/signing/typed-data.d.ts +39 -0
  418. package/dist/src/signing/typed-data.d.ts.map +1 -0
  419. package/dist/src/signing/typed-data.js +135 -0
  420. package/dist/src/signing/types.d.ts +346 -0
  421. package/dist/src/signing/types.d.ts.map +1 -0
  422. package/dist/src/signing/types.js +1 -0
  423. package/dist/src/signing/user-operation.d.ts +23 -0
  424. package/dist/src/signing/user-operation.d.ts.map +1 -0
  425. package/dist/src/signing/user-operation.js +61 -0
  426. package/dist/src/smart-sessions/index.d.ts +16 -0
  427. package/dist/src/smart-sessions/index.d.ts.map +1 -0
  428. package/dist/src/smart-sessions/index.js +45 -0
  429. package/dist/src/transactions/intents/account.d.ts +15 -0
  430. package/dist/src/transactions/intents/account.d.ts.map +1 -0
  431. package/dist/src/transactions/intents/account.js +48 -0
  432. package/dist/src/transactions/intents/compatibility.d.ts +4 -0
  433. package/dist/src/transactions/intents/compatibility.d.ts.map +1 -0
  434. package/dist/src/transactions/intents/compatibility.js +19 -0
  435. package/dist/src/transactions/intents/normalize.d.ts +5 -0
  436. package/dist/src/transactions/intents/normalize.d.ts.map +1 -0
  437. package/dist/src/transactions/intents/normalize.js +48 -0
  438. package/dist/src/transactions/intents/prepare.d.ts +7 -0
  439. package/dist/src/transactions/intents/prepare.d.ts.map +1 -0
  440. package/dist/src/transactions/intents/prepare.js +249 -0
  441. package/dist/src/transactions/intents/quotes.d.ts +3 -0
  442. package/dist/src/transactions/intents/quotes.d.ts.map +1 -0
  443. package/dist/src/transactions/intents/quotes.js +11 -0
  444. package/dist/src/transactions/intents/request.d.ts +11 -0
  445. package/dist/src/transactions/intents/request.d.ts.map +1 -0
  446. package/dist/src/transactions/intents/request.js +55 -0
  447. package/dist/src/transactions/intents/send.d.ts +3 -0
  448. package/dist/src/transactions/intents/send.d.ts.map +1 -0
  449. package/dist/src/transactions/intents/send.js +22 -0
  450. package/dist/src/transactions/intents/session-signing.d.ts +7 -0
  451. package/dist/src/transactions/intents/session-signing.d.ts.map +1 -0
  452. package/dist/src/transactions/intents/session-signing.js +363 -0
  453. package/dist/src/transactions/intents/sessions.d.ts +17 -0
  454. package/dist/src/transactions/intents/sessions.d.ts.map +1 -0
  455. package/dist/src/transactions/intents/sessions.js +85 -0
  456. package/dist/src/transactions/intents/sign-transaction.d.ts +10 -0
  457. package/dist/src/transactions/intents/sign-transaction.d.ts.map +1 -0
  458. package/dist/src/transactions/intents/sign-transaction.js +386 -0
  459. package/dist/src/transactions/intents/split.d.ts +13 -0
  460. package/dist/src/transactions/intents/split.d.ts.map +1 -0
  461. package/dist/src/transactions/intents/split.js +3 -0
  462. package/dist/src/transactions/intents/status-policy.d.ts +13 -0
  463. package/dist/src/transactions/intents/status-policy.d.ts.map +1 -0
  464. package/dist/src/transactions/intents/status-policy.js +39 -0
  465. package/dist/src/transactions/intents/status.d.ts +4 -0
  466. package/dist/src/transactions/intents/status.d.ts.map +1 -0
  467. package/dist/src/transactions/intents/status.js +50 -0
  468. package/dist/src/transactions/intents/submit.d.ts +3 -0
  469. package/dist/src/transactions/intents/submit.d.ts.map +1 -0
  470. package/dist/src/transactions/intents/submit.js +32 -0
  471. package/dist/src/transactions/intents/types.d.ts +136 -0
  472. package/dist/src/transactions/intents/types.d.ts.map +1 -0
  473. package/dist/src/transactions/intents/types.js +1 -0
  474. package/dist/src/transactions/user-operations/hash.d.ts +5 -0
  475. package/dist/src/transactions/user-operations/hash.d.ts.map +1 -0
  476. package/dist/src/transactions/user-operations/hash.js +9 -0
  477. package/dist/src/transactions/user-operations/nonce.d.ts +18 -0
  478. package/dist/src/transactions/user-operations/nonce.d.ts.map +1 -0
  479. package/dist/src/transactions/user-operations/nonce.js +43 -0
  480. package/dist/src/transactions/user-operations/prepare.d.ts +12 -0
  481. package/dist/src/transactions/user-operations/prepare.d.ts.map +1 -0
  482. package/dist/src/transactions/user-operations/prepare.js +136 -0
  483. package/dist/src/transactions/user-operations/reconstruct.d.ts +28 -0
  484. package/dist/src/transactions/user-operations/reconstruct.d.ts.map +1 -0
  485. package/dist/src/transactions/user-operations/reconstruct.js +52 -0
  486. package/dist/src/transactions/user-operations/send.d.ts +3 -0
  487. package/dist/src/transactions/user-operations/send.d.ts.map +1 -0
  488. package/dist/src/transactions/user-operations/send.js +8 -0
  489. package/dist/src/transactions/user-operations/sign.d.ts +3 -0
  490. package/dist/src/transactions/user-operations/sign.d.ts.map +1 -0
  491. package/dist/src/transactions/user-operations/sign.js +14 -0
  492. package/dist/src/transactions/user-operations/status.d.ts +4 -0
  493. package/dist/src/transactions/user-operations/status.d.ts.map +1 -0
  494. package/dist/src/transactions/user-operations/status.js +37 -0
  495. package/dist/src/transactions/user-operations/submit.d.ts +3 -0
  496. package/dist/src/transactions/user-operations/submit.d.ts.map +1 -0
  497. package/dist/src/transactions/user-operations/submit.js +8 -0
  498. package/dist/src/transactions/user-operations/types.d.ts +68 -0
  499. package/dist/src/transactions/user-operations/types.d.ts.map +1 -0
  500. package/dist/src/transactions/user-operations/types.js +1 -0
  501. package/dist/src/transactions/user-operations/validator-account.d.ts +5 -0
  502. package/dist/src/transactions/user-operations/validator-account.d.ts.map +1 -0
  503. package/dist/src/transactions/user-operations/validator-account.js +26 -0
  504. package/dist/src/utils/index.d.ts +68 -4
  505. package/dist/src/utils/index.d.ts.map +1 -1
  506. package/dist/src/utils/index.js +113 -51
  507. package/package.json +10 -11
  508. package/dist/src/accounts/index.d.ts +0 -51
  509. package/dist/src/accounts/index.d.ts.map +0 -1
  510. package/dist/src/accounts/index.js +0 -589
  511. package/dist/src/accounts/json-rpc/index.d.ts +0 -5
  512. package/dist/src/accounts/json-rpc/index.d.ts.map +0 -1
  513. package/dist/src/accounts/json-rpc/index.js +0 -19
  514. package/dist/src/accounts/json-rpc/providers.d.ts +0 -5
  515. package/dist/src/accounts/json-rpc/providers.d.ts.map +0 -1
  516. package/dist/src/accounts/json-rpc/providers.js +0 -16
  517. package/dist/src/accounts/kernel.d.ts +0 -27
  518. package/dist/src/accounts/kernel.d.ts.map +0 -1
  519. package/dist/src/accounts/kernel.js +0 -272
  520. package/dist/src/accounts/nexus.d.ts +0 -33
  521. package/dist/src/accounts/nexus.d.ts.map +0 -1
  522. package/dist/src/accounts/nexus.js +0 -444
  523. package/dist/src/accounts/safe.d.ts +0 -33
  524. package/dist/src/accounts/safe.d.ts.map +0 -1
  525. package/dist/src/accounts/safe.js +0 -343
  526. package/dist/src/accounts/signing/common.d.ts +0 -32
  527. package/dist/src/accounts/signing/common.d.ts.map +0 -1
  528. package/dist/src/accounts/signing/common.js +0 -184
  529. package/dist/src/accounts/signing/message.d.ts +0 -7
  530. package/dist/src/accounts/signing/message.d.ts.map +0 -1
  531. package/dist/src/accounts/signing/message.js +0 -45
  532. package/dist/src/accounts/signing/passkeys.d.ts +0 -36
  533. package/dist/src/accounts/signing/passkeys.d.ts.map +0 -1
  534. package/dist/src/accounts/signing/passkeys.js +0 -119
  535. package/dist/src/accounts/signing/typedData.d.ts +0 -5
  536. package/dist/src/accounts/signing/typedData.d.ts.map +0 -1
  537. package/dist/src/accounts/signing/typedData.js +0 -33
  538. package/dist/src/accounts/startale.d.ts +0 -26
  539. package/dist/src/accounts/startale.d.ts.map +0 -1
  540. package/dist/src/accounts/startale.js +0 -191
  541. package/dist/src/accounts/utils.d.ts +0 -33
  542. package/dist/src/accounts/utils.d.ts.map +0 -1
  543. package/dist/src/accounts/utils.js +0 -202
  544. package/dist/src/auth/provider.d.ts +0 -7
  545. package/dist/src/auth/provider.d.ts.map +0 -1
  546. package/dist/src/auth/provider.js +0 -38
  547. package/dist/src/execution/compact.d.ts +0 -5
  548. package/dist/src/execution/compact.d.ts.map +0 -1
  549. package/dist/src/execution/compact.js +0 -4
  550. package/dist/src/execution/error.d.ts.map +0 -1
  551. package/dist/src/execution/error.js +0 -85
  552. package/dist/src/execution/index.d.ts +0 -42
  553. package/dist/src/execution/index.d.ts.map +0 -1
  554. package/dist/src/execution/index.js +0 -202
  555. package/dist/src/execution/utils.d.ts +0 -127
  556. package/dist/src/execution/utils.d.ts.map +0 -1
  557. package/dist/src/execution/utils.js +0 -1116
  558. package/dist/src/modules/abi/smart-sessions.d.ts +0 -104
  559. package/dist/src/modules/abi/smart-sessions.d.ts.map +0 -1
  560. package/dist/src/modules/abi/smart-sessions.js +0 -128
  561. package/dist/src/modules/chain-abstraction.d.ts +0 -5
  562. package/dist/src/modules/chain-abstraction.d.ts.map +0 -1
  563. package/dist/src/modules/chain-abstraction.js +0 -3
  564. package/dist/src/modules/common.d.ts +0 -30
  565. package/dist/src/modules/common.d.ts.map +0 -1
  566. package/dist/src/modules/common.js +0 -30
  567. package/dist/src/modules/index.d.ts +0 -11
  568. package/dist/src/modules/index.d.ts.map +0 -1
  569. package/dist/src/modules/index.js +0 -90
  570. package/dist/src/modules/legacy.d.ts +0 -10
  571. package/dist/src/modules/legacy.d.ts.map +0 -1
  572. package/dist/src/modules/legacy.js +0 -62
  573. package/dist/src/modules/read.d.ts +0 -10
  574. package/dist/src/modules/read.d.ts.map +0 -1
  575. package/dist/src/modules/read.js +0 -171
  576. package/dist/src/modules/validators/core.d.ts +0 -31
  577. package/dist/src/modules/validators/core.d.ts.map +0 -1
  578. package/dist/src/modules/validators/core.js +0 -266
  579. package/dist/src/modules/validators/index.d.ts +0 -4
  580. package/dist/src/modules/validators/index.d.ts.map +0 -1
  581. package/dist/src/modules/validators/index.js +0 -3
  582. package/dist/src/modules/validators/smart-sessions.d.ts +0 -196
  583. package/dist/src/modules/validators/smart-sessions.d.ts.map +0 -1
  584. package/dist/src/modules/validators/smart-sessions.js +0 -772
  585. package/dist/src/orchestrator/caip2.d.ts +0 -13
  586. package/dist/src/orchestrator/caip2.d.ts.map +0 -1
  587. package/dist/src/orchestrator/caip2.js +0 -52
  588. package/dist/src/orchestrator/client.d.ts +0 -29
  589. package/dist/src/orchestrator/client.d.ts.map +0 -1
  590. package/dist/src/orchestrator/client.js +0 -293
  591. package/dist/src/orchestrator/consts.d.ts +0 -6
  592. package/dist/src/orchestrator/consts.d.ts.map +0 -1
  593. package/dist/src/orchestrator/consts.js +0 -5
  594. package/dist/src/orchestrator/destinations.d.ts.map +0 -1
  595. package/dist/src/orchestrator/destinations.js +0 -36
  596. package/dist/src/orchestrator/error.d.ts +0 -97
  597. package/dist/src/orchestrator/error.d.ts.map +0 -1
  598. package/dist/src/orchestrator/error.js +0 -173
  599. package/dist/src/orchestrator/index.d.ts +0 -12
  600. package/dist/src/orchestrator/index.d.ts.map +0 -1
  601. package/dist/src/orchestrator/index.js +0 -10
  602. package/dist/src/orchestrator/registry.d.ts +0 -17
  603. package/dist/src/orchestrator/registry.d.ts.map +0 -1
  604. package/dist/src/orchestrator/registry.js +0 -100
  605. package/dist/src/orchestrator/types.d.ts.map +0 -1
  606. package/dist/src/orchestrator/types.js +0 -15
  607. package/dist/src/orchestrator/utils.d.ts +0 -3
  608. package/dist/src/orchestrator/utils.d.ts.map +0 -1
  609. package/dist/src/orchestrator/utils.js +0 -22
  610. package/dist/src/types.d.ts +0 -466
  611. package/dist/src/types.d.ts.map +0 -1
  612. package/dist/src/utils/walletClient.d.ts +0 -34
  613. package/dist/src/utils/walletClient.d.ts.map +0 -1
  614. package/dist/src/utils/walletClient.js +0 -117
  615. /package/dist/src/{types.js → accounts/adapter.js} +0 -0
@@ -1,1116 +0,0 @@
1
- import { concat, createPublicClient, createWalletClient, encodeAbiParameters, encodePacked, hashDomain, hashMessage, hashStruct, hashTypedData, isAddress, keccak256, publicActions, toHex, } from 'viem';
2
- import { entryPoint07Address, getUserOperationHash, } from 'viem/account-abstraction';
3
- import { wrapTypedDataSignature } from 'viem/experimental/erc7739';
4
- import { EoaAccountMustHaveAccountError, EoaSigningMethodNotConfiguredError, FactoryArgsNotAvailableError, getAccountProvider, getAddress, getEip712Domain, getEip1271Signature, getEip7702InitCall, getEmissarySignature, getGuardianSmartAccount, getInitCode, getSmartAccount, getTypedDataPackedSignature, is7702, toErc6492Signature, } from '../accounts/index.js';
5
- import { convertOwnerSetToSignerSet } from '../accounts/signing/common.js';
6
- import { K1_DEFAULT_VALIDATOR_ADDRESS } from '../accounts/startale.js';
7
- import { createTransport, getBundlerClient, } from '../accounts/utils.js';
8
- import { createAuthProvider } from '../auth/provider.js';
9
- import { buildMockSignature, DUMMY_PRECLAIMOP_SELECTOR, DUMMY_PRECLAIMOP_TARGET, getOwnerValidator, getPermissionId, getSmartSessionValidator, isSessionEnabled, } from '../modules/validators/index.js';
10
- import { getMultiFactorValidator, getSocialRecoveryValidator, getWebAuthnValidator, supportsEip712, } from '../modules/validators/core.js';
11
- import { buildPermit2ClaimPolicyCalldata, } from '../modules/validators/policies/claim/permit2.js';
12
- import { resolvePermit2ClaimPolicy, } from '../modules/validators/smart-sessions.js';
13
- import { getOrchestrator, } from '../orchestrator/index.js';
14
- import { getChainId, isNonEvmChain, } from '../orchestrator/destinations.js';
15
- import { getChainById, getTokenAddress, resolveTokenAddress, } from '../orchestrator/registry.js';
16
- import { SIG_MODE_EMISSARY_EXECUTION_ERC1271, SIG_MODE_ERC1271_EMISSARY, } from '../orchestrator/types.js';
17
- import { convertBigIntFields } from '../orchestrator/utils.js';
18
- import { Eip7702InitSignatureRequiredError, QuoteNotInPreparedTransactionError, SignerNotSupportedError, } from './error.js';
19
- function isResolvedSessionSignerSet(signers) {
20
- return (signers?.type === 'experimental_session' && 'verifyExecutions' in signers);
21
- }
22
- async function resolveSignersForChain(config, signers, chainId) {
23
- if (signers?.type !== 'experimental_session') {
24
- return signers;
25
- }
26
- const resolved = resolveSessionForChain(signers, chainId);
27
- const enabled = await isSessionEnabled(getAddress(config), config.provider, resolved.session, config.useDevContracts);
28
- const enableData = enabled ? undefined : resolved.enableData;
29
- const verifyExecutions = resolved.verifyExecutions ??
30
- signers.verifyExecutions ??
31
- resolved.session.hasExplicitPermissions;
32
- return {
33
- type: 'experimental_session',
34
- session: resolved.session,
35
- enableData,
36
- verifyExecutions,
37
- };
38
- }
39
- function resolveSessionForChain(signers, chainId) {
40
- if ('sessions' in signers) {
41
- const config = signers.sessions[chainId];
42
- if (!config) {
43
- throw new Error(`No session configured for chain ${chainId}`);
44
- }
45
- return config;
46
- }
47
- return { session: signers.session, enableData: signers.enableData };
48
- }
49
- async function prepareTransaction(config, transaction) {
50
- const { sourceChains, targetChain, tokenRequests, signers, sponsored, eip7702InitSignature, settlementLayers, sourceAssets, feeAsset, auxiliaryFunds, account, recipient, } = getTransactionParams(transaction);
51
- const accountAddress = getAddress(config);
52
- const isUserOpSigner = signers?.type === 'guardians';
53
- if (isUserOpSigner) {
54
- throw new SignerNotSupportedError();
55
- }
56
- // Destination calls (transaction.calls on a cross-chain transaction) are
57
- // executed on the destination chain by the solver/account. For non-EVM
58
- // destinations we can't resolve arbitrary EVM calls; assert there are
59
- // none and route an empty list through.
60
- let resolvedCalls;
61
- if (isNonEvmChain(targetChain)) {
62
- if (transaction.calls && transaction.calls.length > 0) {
63
- throw new Error(`Destination calls are not supported for non-EVM target chain ${targetChain.name} (${targetChain.caip2})`);
64
- }
65
- resolvedCalls = [];
66
- }
67
- else {
68
- resolvedCalls = await resolveCallInputs(transaction.calls, config, targetChain, accountAddress);
69
- }
70
- const prepared = await prepareTransactionAsIntent(config, sourceChains, targetChain, resolvedCalls, transaction.gasLimit, tokenRequests, recipient, sponsored, eip7702InitSignature, settlementLayers, sourceAssets, feeAsset, auxiliaryFunds, account, signers);
71
- return {
72
- quotes: prepared.quotes,
73
- intentInput: prepared.intentInput,
74
- transaction,
75
- };
76
- }
77
- async function prepareUserOperation(config, transaction) {
78
- const chain = transaction.chain;
79
- const signers = transaction.signers;
80
- const accountAddress = getAddress(config);
81
- const data = await prepareTransactionAsUserOp(config, chain, await resolveCallInputs(transaction.calls, config, chain, accountAddress), signers, transaction.gasLimit);
82
- return {
83
- userOperation: data.userOp,
84
- hash: data.hash,
85
- transaction,
86
- };
87
- }
88
- async function resolveCallInputs(inputs, config, chain, accountAddress) {
89
- const resolved = [];
90
- if (!inputs) {
91
- return resolved;
92
- }
93
- for (const intent of inputs) {
94
- if ('resolve' in intent) {
95
- const result = await intent.resolve({ config, chain, accountAddress });
96
- if (Array.isArray(result)) {
97
- resolved.push(...result);
98
- }
99
- else if (result) {
100
- resolved.push(result);
101
- }
102
- }
103
- else {
104
- resolved.push(intent);
105
- }
106
- }
107
- return resolved;
108
- }
109
- function getTransactionMessages(_config, preparedTransaction, options) {
110
- const quote = resolveQuote(preparedTransaction.quotes, options);
111
- return getIntentMessages(quote.signData);
112
- }
113
- async function signTransaction(config, preparedTransaction, options) {
114
- const { signers } = getTransactionParams(preparedTransaction.transaction);
115
- const quote = resolveQuote(preparedTransaction.quotes, options);
116
- const targetChain = 'targetChain' in preparedTransaction.transaction
117
- ? preparedTransaction.transaction.targetChain
118
- : preparedTransaction.transaction.chain;
119
- const { originSignatures, destinationSignature } = await signIntent(config, quote.signData, targetChain, signers, false);
120
- const targetExecutionSignature = await getTargetExecutionSignature(config, quote.signData, targetChain, signers);
121
- return {
122
- quote,
123
- quotes: preparedTransaction.quotes,
124
- intentInput: preparedTransaction.intentInput,
125
- transaction: preparedTransaction.transaction,
126
- originSignatures,
127
- destinationSignature,
128
- targetExecutionSignature,
129
- };
130
- }
131
- function resolveQuote(quotes, options) {
132
- if (!options)
133
- return quotes.best;
134
- const match = quotes.all.find((q) => q.intentId === options.intentId);
135
- if (!match) {
136
- throw new QuoteNotInPreparedTransactionError({
137
- context: { intentId: options.intentId },
138
- });
139
- }
140
- return match;
141
- }
142
- async function getTargetExecutionSignature(config, signData, targetChain, signers) {
143
- if (signers?.type !== 'experimental_session') {
144
- return undefined;
145
- }
146
- if (!signData.targetExecution) {
147
- return undefined;
148
- }
149
- // Target executions are EVM-only (smart-session validator on destination).
150
- // Non-EVM destinations don't have a validator there to verify the sig.
151
- if (isNonEvmChain(targetChain)) {
152
- return undefined;
153
- }
154
- const resolvedSigners = await resolveSignersForChain(config, signers, targetChain.id);
155
- if (!isResolvedSessionSignerSet(resolvedSigners) ||
156
- !resolvedSigners.verifyExecutions) {
157
- return undefined;
158
- }
159
- const validator = getValidator(config, signers);
160
- if (!validator) {
161
- throw new Error('Validator not available');
162
- }
163
- const ownerValidator = getOwnerValidator(config);
164
- const isRoot = validator.address === ownerValidator.address;
165
- const destination = prepareTypedData(signData.targetExecution);
166
- const signature = await getDestinationSignature(config, resolvedSigners, validator, isRoot, targetChain, destination, [], true);
167
- return signature;
168
- }
169
- async function signUserOperation(config, preparedUserOperation) {
170
- const chain = preparedUserOperation.transaction.chain;
171
- const userOp = preparedUserOperation.userOperation;
172
- const signers = preparedUserOperation.transaction.signers;
173
- // Smart sessions require a UserOp flow
174
- const signature = await signUserOp(config, chain, signers, userOp);
175
- return {
176
- userOperation: preparedUserOperation.userOperation,
177
- hash: preparedUserOperation.hash,
178
- transaction: preparedUserOperation.transaction,
179
- signature,
180
- };
181
- }
182
- async function signAuthorizations(config, preparedTransaction) {
183
- const transaction = preparedTransaction.transaction;
184
- const sourceChains = 'chain' in transaction ? [transaction.chain] : transaction.sourceChains;
185
- const targetChain = 'chain' in transaction ? transaction.chain : transaction.targetChain;
186
- return await signAuthorizationsInternal(config, {
187
- sourceChains,
188
- targetChain,
189
- eip7702InitSignature: transaction.eip7702InitSignature,
190
- });
191
- }
192
- async function signMessage(config, message, chain, signers) {
193
- const validator = getValidator(config, signers);
194
- if (!validator) {
195
- throw new Error('Validator not available');
196
- }
197
- const ownerValidator = getOwnerValidator(config);
198
- const isRoot = validator.address === ownerValidator.address;
199
- const hash = hashMessage(message);
200
- const signature = await getEip1271Signature(config, signers, chain, {
201
- address: validator.address,
202
- isRoot,
203
- }, hash);
204
- return await toErc6492Signature(config, signature, chain);
205
- }
206
- async function signTypedData(config, parameters, chain, signers, options) {
207
- const validator = getValidator(config, signers);
208
- if (!validator) {
209
- throw new Error('Validator not available');
210
- }
211
- const ownerValidator = getOwnerValidator(config);
212
- const isRoot = validator.address === ownerValidator.address;
213
- if (signers?.type === 'experimental_session') {
214
- const resolved = resolveSessionForChain(signers, chain.id);
215
- return await signTypedDataWithSession(config, chain, {
216
- address: validator.address,
217
- isRoot,
218
- }, resolved.session, parameters);
219
- }
220
- const account = getAccountProvider(config);
221
- if (account.type === 'startale' && supportsEip712(validator)) {
222
- const isK1 = validator.address.toLowerCase() ===
223
- K1_DEFAULT_VALIDATOR_ADDRESS.toLowerCase();
224
- if (isK1) {
225
- const sig = await signErc7739TypedData(config, signers, validator, isRoot, parameters, chain);
226
- if (!options?.skipErc6492) {
227
- return await toErc6492Signature(config, sig, chain);
228
- }
229
- return sig;
230
- }
231
- }
232
- const signature = await getTypedDataPackedSignature(config, signers, chain, {
233
- address: validator.address,
234
- isRoot,
235
- }, parameters);
236
- if (!options?.skipErc6492) {
237
- return await toErc6492Signature(config, signature, chain);
238
- }
239
- return signature;
240
- }
241
- async function signTypedDataWithSession(config, chain, validator, session, parameters) {
242
- const { name, version, chainId, verifyingContract, salt } = getEip712Domain(config, chain);
243
- const signers = convertOwnerSetToSignerSet(session.owners);
244
- const signature = await getTypedDataPackedSignature(config, signers, chain, validator, {
245
- domain: parameters.domain,
246
- primaryType: 'TypedDataSign',
247
- types: {
248
- ...parameters.types,
249
- TypedDataSign: [
250
- { name: 'contents', type: parameters.primaryType },
251
- { name: 'name', type: 'string' },
252
- { name: 'version', type: 'string' },
253
- { name: 'chainId', type: 'uint256' },
254
- { name: 'verifyingContract', type: 'address' },
255
- { name: 'salt', type: 'bytes32' },
256
- ],
257
- },
258
- message: {
259
- contents: parameters.message,
260
- name,
261
- version,
262
- chainId,
263
- verifyingContract,
264
- salt,
265
- },
266
- }, (signature) => {
267
- const erc7739Signature = wrapTypedDataSignature({
268
- domain: parameters.domain,
269
- primaryType: parameters.primaryType,
270
- types: parameters.types,
271
- message: parameters.message,
272
- signature,
273
- });
274
- return encodePacked(['bytes32', 'bytes'], [getPermissionId(session), erc7739Signature]);
275
- });
276
- return await toErc6492Signature(config, signature, chain);
277
- }
278
- async function signAuthorizationsInternal(config, context) {
279
- const eoa = config.eoa;
280
- if (!eoa) {
281
- throw new Error('EIP-7702 initialization is required for EOA accounts');
282
- }
283
- const eip7702InitSignature = context.eip7702InitSignature;
284
- if (!eip7702InitSignature) {
285
- return [];
286
- }
287
- const accountAddress = getAddress(config);
288
- const { contract: eip7702Contract } = getEip7702InitCall(config, eip7702InitSignature);
289
- // EIP-7702 authorization is EVM-only — there's no contract to delegate
290
- // to on Solana / Tron. Skip the destination chain entirely when it's
291
- // non-EVM; source chains are always EVM by construction.
292
- const chains = new Map();
293
- for (const chain of context.sourceChains ?? []) {
294
- chains.set(chain.id, chain);
295
- }
296
- if (!isNonEvmChain(context.targetChain)) {
297
- chains.set(context.targetChain.id, context.targetChain);
298
- }
299
- const authorizations = [];
300
- for (const chain of chains.values()) {
301
- const walletClient = createWalletClient({
302
- chain,
303
- account: eoa,
304
- transport: createTransport(chain, config.provider),
305
- }).extend(publicActions);
306
- const code = await walletClient.getCode({
307
- address: accountAddress,
308
- });
309
- const isDelegated = code === concat(['0xef0100', eip7702Contract.toLowerCase()]);
310
- if (isDelegated) {
311
- continue;
312
- }
313
- const authorization = await walletClient.signAuthorization({
314
- contractAddress: eip7702Contract,
315
- chainId: chain.id,
316
- });
317
- authorizations.push(authorization);
318
- }
319
- return authorizations;
320
- }
321
- async function submitTransaction(config, signedTransaction, authorizations, dryRun = false) {
322
- const { quote, intentInput, transaction, originSignatures, destinationSignature, targetExecutionSignature, } = signedTransaction;
323
- const { sourceChains, targetChain } = getTransactionParams(transaction);
324
- return await submitIntentInternal(config, sourceChains, targetChain, quote, originSignatures, destinationSignature, targetExecutionSignature, authorizations, dryRun, intentInput);
325
- }
326
- async function submitUserOperation(config, signedUserOperation) {
327
- const chain = signedUserOperation.transaction.chain;
328
- const userOp = signedUserOperation.userOperation;
329
- const signature = signedUserOperation.signature;
330
- // Smart sessions require a UserOp flow
331
- return await submitUserOp(config, chain, userOp, signature);
332
- }
333
- function getTransactionParams(transaction) {
334
- const sourceChains = 'chain' in transaction ? [transaction.chain] : transaction.sourceChains;
335
- const targetChain = 'chain' in transaction ? transaction.chain : transaction.targetChain;
336
- const initialTokenRequests = transaction.tokenRequests;
337
- const signers = transaction.signers;
338
- const eip7702InitSignature = transaction.eip7702InitSignature;
339
- const sponsored = transaction.sponsored;
340
- const gasLimit = transaction.gasLimit;
341
- const settlementLayers = transaction.settlementLayers;
342
- const sourceAssets = transaction.sourceAssets;
343
- const feeAsset = transaction.feeAsset;
344
- const auxiliaryFunds = transaction.auxiliaryFunds;
345
- const account = transaction.experimental_accountOverride;
346
- const recipient = transaction.recipient;
347
- const tokenRequests = getTokenRequests(targetChain, initialTokenRequests);
348
- return {
349
- sourceChains,
350
- targetChain,
351
- tokenRequests,
352
- signers,
353
- sponsored,
354
- eip7702InitSignature,
355
- gasLimit,
356
- settlementLayers,
357
- sourceAssets,
358
- feeAsset,
359
- auxiliaryFunds,
360
- account,
361
- recipient,
362
- };
363
- }
364
- function getTokenRequests(targetChain, initialTokenRequests) {
365
- // Non-EVM destinations carry SPL mint / Tron T-prefixed addresses that
366
- // aren't valid 0x-hex; skip symbol/EVM-address validation here and let
367
- // the orchestrator validate per its own schema. EVM destinations keep
368
- // the existing strict check so a typo on Optimism still fails fast.
369
- if (initialTokenRequests && !isNonEvmChain(targetChain)) {
370
- // Inside this branch targetChain is a viem `Chain`, which excludes the
371
- // non-EVM transaction variant — token requests are EVM-typed here.
372
- const evmRequests = initialTokenRequests;
373
- validateTokenSymbols(targetChain, evmRequests.map((tokenRequest) => tokenRequest.address));
374
- }
375
- return initialTokenRequests ?? [];
376
- }
377
- async function prepareTransactionAsUserOp(config, chain, callInputs, signers, gasLimit) {
378
- const publicClient = createPublicClient({
379
- chain,
380
- transport: createTransport(chain, config.provider),
381
- });
382
- const validatorAccount = await getValidatorAccount(config, signers, publicClient, chain);
383
- if (!validatorAccount) {
384
- throw new Error('No validator account found');
385
- }
386
- const bundlerClient = getBundlerClient(config, publicClient);
387
- const calls = parseCalls(callInputs, chain.id);
388
- const userOp = await bundlerClient.prepareUserOperation({
389
- account: validatorAccount,
390
- calls,
391
- callGasLimit: gasLimit,
392
- });
393
- return {
394
- userOp,
395
- hash: getUserOperationHash({
396
- userOperation: userOp,
397
- chainId: chain.id,
398
- entryPointAddress: entryPoint07Address,
399
- entryPointVersion: '0.7',
400
- }),
401
- };
402
- }
403
- function getAccountType(accountConfig) {
404
- if (accountConfig?.type === 'eoa') {
405
- return 'EOA';
406
- }
407
- else {
408
- return 'ERC7579';
409
- }
410
- }
411
- function getIntentAccount(config, eip7702InitSignature, account) {
412
- const accountAddress = getAddress(config);
413
- const accountType = getAccountType(config.account);
414
- const { setupOps, delegations } = getSetupOperationsAndDelegations(config, accountAddress, eip7702InitSignature);
415
- return {
416
- address: accountAddress,
417
- accountType: accountType,
418
- setupOps: account?.setupOps ?? setupOps,
419
- delegations,
420
- };
421
- }
422
- async function prepareTransactionAsIntent(config, sourceChains, targetChain, callInputs, gasLimit, tokenRequests, recipientInput, sponsored, eip7702InitSignature, settlementLayers, sourceAssets, feeAsset, auxiliaryFunds, account, signers) {
423
- const targetChainId = getChainId(targetChain);
424
- const calls = parseCalls(callInputs, targetChainId);
425
- const accountAccessList = createAccountAccessList(sourceChains, sourceAssets);
426
- function getRecipient(recipient) {
427
- if (typeof recipient === 'string') {
428
- // Non-EVM recipients (Solana base58 / Tron T-prefix) carry no
429
- // EVM smart-account semantics; orchestrator schema requires
430
- // accountType / setupOps to be unset. Emit just the address.
431
- if (isNonEvmChain(targetChain)) {
432
- return { address: recipient };
433
- }
434
- // EVM passthrough — assume EOA.
435
- return {
436
- address: recipient,
437
- accountType: 'EOA',
438
- setupOps: [],
439
- delegations: undefined,
440
- };
441
- }
442
- if (!recipient) {
443
- return undefined;
444
- }
445
- return getIntentAccount(recipient, eip7702InitSignature, account);
446
- }
447
- const intentAccount = {
448
- ...getIntentAccount(config, eip7702InitSignature, account),
449
- ...(signers?.type === 'experimental_session' && {
450
- // Per-chain map: enables accurate per-chain session validation gas
451
- // simulation. Non-EVM destinations are excluded — they have no
452
- // destination-side session validator, so adding the synthetic chain
453
- // id would force users to configure a session that's never used and
454
- // make `resolveSessionForChain` throw for per-chain session signers.
455
- mockSignatures: Object.fromEntries([
456
- ...new Set([
457
- ...(sourceChains ?? []).map((c) => c.id),
458
- ...(isNonEvmChain(targetChain) ? [] : [targetChainId]),
459
- ]),
460
- ].map((chainId) => [
461
- String(chainId),
462
- buildMockSignature(resolveSessionForChain(signers, chainId).session, config.useDevContracts, sourceChains?.length ?? 1, chainId),
463
- ])),
464
- }),
465
- };
466
- const recipient = getRecipient(recipientInput);
467
- const signatureMode = signers?.type === 'experimental_session'
468
- ? SIG_MODE_EMISSARY_EXECUTION_ERC1271
469
- : SIG_MODE_ERC1271_EMISSARY;
470
- // For session signers that need enabling, pass a dummy preclaimop per source chain
471
- // so the orchestrator bakes it into the bundle before computing its HMAC. The filler
472
- // executes the op via verifyExecution in ENABLE mode, enabling the session on-chain
473
- // without a separate UserOp. Must be sent in the routing request — not injected
474
- // post-facto — because the orchestrator HMAC covers preClaimOps.
475
- const preClaimExecutions = {};
476
- if (signers?.type === 'experimental_session' && sourceChains) {
477
- const resolvedPerChain = await Promise.all(sourceChains.map(async (chain) => ({
478
- chainId: chain.id,
479
- resolved: await resolveSignersForChain(config, signers, chain.id),
480
- })));
481
- for (const { chainId, resolved } of resolvedPerChain) {
482
- if (!isResolvedSessionSignerSet(resolved))
483
- continue;
484
- const { enableData, verifyExecutions } = resolved;
485
- if (!verifyExecutions || !enableData)
486
- continue;
487
- preClaimExecutions[chainId] = [
488
- {
489
- to: DUMMY_PRECLAIMOP_TARGET,
490
- value: 0n,
491
- data: DUMMY_PRECLAIMOP_SELECTOR,
492
- },
493
- ];
494
- }
495
- }
496
- const metaIntent = {
497
- destinationChainId: targetChainId,
498
- tokenRequests: tokenRequests.map((tokenRequest) => ({
499
- tokenAddress: resolveTokenAddress(tokenRequest.address, targetChainId),
500
- amount: tokenRequest.amount,
501
- })),
502
- recipient,
503
- account: intentAccount,
504
- destinationExecutions: calls,
505
- destinationGasUnits: gasLimit,
506
- accountAccessList,
507
- options: {
508
- feeToken: feeAsset,
509
- sponsorSettings: sponsored
510
- ? typeof sponsored === 'object'
511
- ? {
512
- gas: sponsored.gas,
513
- bridgeFees: sponsored.bridging,
514
- swapFees: sponsored.swaps,
515
- }
516
- : {
517
- gas: sponsored,
518
- bridgeFees: sponsored,
519
- swapFees: sponsored,
520
- }
521
- : undefined,
522
- settlementLayers,
523
- signatureMode,
524
- auxiliaryFunds,
525
- },
526
- ...(Object.keys(preClaimExecutions).length > 0 && { preClaimExecutions }),
527
- };
528
- const serializedIntent = convertBigIntFields(metaIntent);
529
- const orchestrator = getOrchestrator(config._authProvider ?? createAuthProvider(config), config.endpointUrl, config.headers);
530
- const { routes } = await orchestrator.createQuote(metaIntent);
531
- const best = routes[0];
532
- if (!best) {
533
- throw new Error('Orchestrator returned no quote');
534
- }
535
- return {
536
- quotes: { best, all: routes },
537
- intentInput: serializedIntent,
538
- };
539
- }
540
- async function signIntent(config, signData, targetChain, signers, targetExecution) {
541
- const { origin, destination } = getIntentMessages(signData);
542
- if (config.account?.type === 'eoa') {
543
- const eoa = config.eoa;
544
- if (!eoa) {
545
- throw new EoaAccountMustHaveAccountError();
546
- }
547
- const originSignatures = [];
548
- for (const typedData of origin) {
549
- if (eoa.signTypedData) {
550
- const signature = await eoa.signTypedData(typedData);
551
- originSignatures.push(signature);
552
- }
553
- else {
554
- throw new EoaSigningMethodNotConfiguredError('signTypedData');
555
- }
556
- }
557
- const destinationSignature = originSignatures.at(-1);
558
- return {
559
- originSignatures,
560
- destinationSignature,
561
- };
562
- }
563
- const validator = getValidator(config, signers);
564
- if (!validator) {
565
- throw new Error('Validator not available');
566
- }
567
- const ownerValidator = getOwnerValidator(config);
568
- const isRoot = validator.address === ownerValidator.address;
569
- const originSignatures = [];
570
- for (const typedData of origin) {
571
- const chain = getChainById(typedData.domain?.chainId);
572
- const originSigners = await resolveSignersForChain(config, signers, chain.id);
573
- const signature = await signIntentTypedData(config, originSigners, validator, isRoot, typedData, chain, targetExecution ?? false);
574
- originSignatures.push(signature);
575
- }
576
- // Non-EVM destinations have no destination-side validator, so there's no
577
- // session to resolve and no signer to derive. Skipping here matters for
578
- // per-chain experimental sessions: `resolveSessionForChain` would throw
579
- // `No session configured for chain {synthetic-id}` since users never
580
- // configure a session keyed by the synthetic Solana/Tron chain id.
581
- const destinationSigners = isNonEvmChain(targetChain)
582
- ? undefined
583
- : await resolveSignersForChain(config, signers, targetChain.id);
584
- const destinationSignature = await getDestinationSignature(config, destinationSigners, validator, isRoot, targetChain, destination, originSignatures, targetExecution ?? false);
585
- return {
586
- originSignatures,
587
- destinationSignature,
588
- };
589
- }
590
- async function getDestinationSignature(config, signers, validator, isRoot, targetChain, destination, originSignatures, targetExecution) {
591
- // Non-EVM destinations have no destination-side validator, no
592
- // eip712Domain(), no smart session enable data. Settlement is solver-
593
- // mediated on the orchestrator side and the origin signatures alone
594
- // authorize the bundle. Fall through to the "reuse last origin sig"
595
- // branch instead of trying to sign on Solana / Tron.
596
- if (!isNonEvmChain(targetChain)) {
597
- // Smart sessions require a separate destination signature because the
598
- // session enable data differs per chain
599
- if (signers?.type === 'experimental_session') {
600
- return await signDestinationSeparately(config, signers, validator, isRoot, targetChain, destination, targetExecution);
601
- }
602
- // ERC-7739 with K1 validator requires a separate destination signature because
603
- // the account's eip712Domain() returns the target chain's chainId, which differs
604
- // from the origin chain used for the last origin signature
605
- const isK1Validator = validator.address.toLowerCase() ===
606
- K1_DEFAULT_VALIDATOR_ADDRESS.toLowerCase();
607
- if (isK1Validator && supportsEip712(validator)) {
608
- return await signDestinationSeparately(config, signers, validator, isRoot, targetChain, destination, targetExecution);
609
- }
610
- }
611
- const lastOriginSignature = originSignatures.at(-1);
612
- return typeof lastOriginSignature === 'object'
613
- ? lastOriginSignature.preClaimSig
614
- : (lastOriginSignature ?? '0x');
615
- }
616
- async function signDestinationSeparately(config, signers, validator, isRoot, targetChain, destination, targetExecution) {
617
- const destinationChain = getChainById(targetChain.id);
618
- const destinationSignatures = await signIntentTypedData(config, signers, validator, isRoot, destination, destinationChain, targetExecution);
619
- return typeof destinationSignatures === 'object'
620
- ? destinationSignatures.preClaimSig
621
- : (destinationSignatures ?? '0x');
622
- }
623
- function getIntentMessages(signData) {
624
- return {
625
- origin: signData.origin.map(prepareTypedData),
626
- destination: prepareTypedData(signData.destination),
627
- targetExecution: signData.targetExecution
628
- ? prepareTypedData(signData.targetExecution)
629
- : undefined,
630
- };
631
- }
632
- // Server emits uint*/int* values as decimal strings; viem's hashTypedData
633
- // expects bigint. Walk the message tree against the type schema and coerce
634
- // numeric fields back to bigint before signing.
635
- function prepareTypedData(td) {
636
- const types = td.types;
637
- return {
638
- ...td,
639
- message: coerceTypedDataMessage(types, td.primaryType, td.message),
640
- };
641
- }
642
- function coerceTypedDataMessage(types, primaryType, message) {
643
- const fields = types[primaryType];
644
- if (!fields)
645
- return message;
646
- const result = { ...message };
647
- for (const { name, type } of fields) {
648
- if (name in message) {
649
- result[name] = coerceTypedDataValue(types, type, message[name]);
650
- }
651
- }
652
- return result;
653
- }
654
- function coerceTypedDataValue(types, type, value) {
655
- if (value === null || value === undefined)
656
- return value;
657
- const arrayMatch = type.match(/^(.+)\[\d*\]$/);
658
- if (arrayMatch) {
659
- const elementType = arrayMatch[1];
660
- if (!Array.isArray(value))
661
- return value;
662
- return value.map((v) => coerceTypedDataValue(types, elementType, v));
663
- }
664
- if (/^u?int\d*$/.test(type)) {
665
- if (typeof value === 'string' || typeof value === 'number') {
666
- return BigInt(value);
667
- }
668
- return value;
669
- }
670
- if (types[type]) {
671
- return coerceTypedDataMessage(types, type, value);
672
- }
673
- return value;
674
- }
675
- /** Computes claim policy calldata when parameters are Permit2 typed data with claim policies. */
676
- function resolveClaimPolicyData(signers, parameters) {
677
- if (parameters.primaryType !== 'PermitBatchWitnessTransferFrom' ||
678
- !signers.session.claimPolicies.length) {
679
- return undefined;
680
- }
681
- const msg = parameters.message;
682
- if (!msg.permitted ||
683
- !msg.mandate ||
684
- typeof msg.spender !== 'string' ||
685
- typeof msg.nonce !== 'bigint' ||
686
- typeof msg.deadline !== 'bigint') {
687
- return undefined;
688
- }
689
- return buildPermit2ClaimPolicyCalldata(resolvePermit2ClaimPolicy(signers.session.claimPolicies[0]), parameters.message);
690
- }
691
- async function signIntentTypedData(config, signers, validator, isRoot, parameters, chain, targetExecution) {
692
- if (supportsEip712(validator)) {
693
- const isK1Validator = validator.address.toLowerCase() ===
694
- K1_DEFAULT_VALIDATOR_ADDRESS.toLowerCase();
695
- if (isK1Validator) {
696
- return await signErc7739TypedData(config, signers, validator, isRoot, parameters, chain);
697
- }
698
- return await getTypedDataPackedSignature(config, signers, chain, {
699
- address: validator.address,
700
- isRoot,
701
- }, parameters);
702
- }
703
- const hash = hashTypedData(parameters);
704
- if (isResolvedSessionSignerSet(signers) && signers.verifyExecutions) {
705
- if (targetExecution) {
706
- const targetSigners = {
707
- type: 'experimental_session',
708
- session: signers.session,
709
- verifyExecutions: true,
710
- enableData: signers.enableData,
711
- };
712
- // signWithSession (called inside getEmissarySignature) already calls packSignature
713
- // internally, so no transform is needed here
714
- return await getEmissarySignature(config, targetSigners, chain, hash);
715
- }
716
- const claimPolicyData = resolveClaimPolicyData(signers, parameters);
717
- const sessionSignersForEip1271 = {
718
- type: 'experimental_session',
719
- session: signers.session,
720
- verifyExecutions: false,
721
- enableData: signers.enableData,
722
- claimPolicyData,
723
- };
724
- const eip1271Signature = await getEip1271Signature(config, sessionSignersForEip1271, chain, {
725
- address: validator.address,
726
- isRoot,
727
- }, hash);
728
- const emissarySignature = await getEmissarySignature(config, {
729
- type: 'experimental_session',
730
- session: signers.session,
731
- verifyExecutions: true,
732
- enableData: signers.enableData,
733
- }, chain, hash);
734
- return {
735
- preClaimSig: emissarySignature,
736
- notarizedClaimSig: eip1271Signature,
737
- };
738
- }
739
- if (isResolvedSessionSignerSet(signers)) {
740
- const claimPolicyData = resolveClaimPolicyData(signers, parameters);
741
- return await getEip1271Signature(config, claimPolicyData !== undefined ? { ...signers, claimPolicyData } : signers, chain, {
742
- address: validator.address,
743
- isRoot,
744
- }, hash);
745
- }
746
- return await getEip1271Signature(config, signers, chain, {
747
- address: validator.address,
748
- isRoot,
749
- }, hash);
750
- }
751
- async function signUserOp(config, chain, signers, userOp) {
752
- const validator = getValidator(config, signers);
753
- if (!validator) {
754
- throw new Error('Validator not available');
755
- }
756
- const publicClient = createPublicClient({
757
- chain,
758
- transport: createTransport(chain, config.provider),
759
- });
760
- const account = await getValidatorAccount(config, signers, publicClient, chain);
761
- if (!account) {
762
- throw new Error('No account found');
763
- }
764
- return await account.signUserOperation(userOp);
765
- }
766
- async function submitUserOp(config, chain, userOp, signature) {
767
- const publicClient = createPublicClient({
768
- chain,
769
- transport: createTransport(chain, config.provider),
770
- });
771
- const bundlerClient = getBundlerClient(config, publicClient);
772
- const hash = await bundlerClient.request({
773
- method: 'eth_sendUserOperation',
774
- params: [
775
- {
776
- sender: userOp.sender,
777
- nonce: toHex(userOp.nonce),
778
- factory: userOp.factory,
779
- factoryData: userOp.factoryData,
780
- callData: userOp.callData,
781
- callGasLimit: toHex(userOp.callGasLimit),
782
- verificationGasLimit: toHex(userOp.verificationGasLimit),
783
- preVerificationGas: toHex(userOp.preVerificationGas),
784
- maxPriorityFeePerGas: toHex(userOp.maxPriorityFeePerGas),
785
- maxFeePerGas: toHex(userOp.maxFeePerGas),
786
- paymaster: userOp.paymaster,
787
- paymasterVerificationGasLimit: userOp.paymasterVerificationGasLimit
788
- ? toHex(userOp.paymasterVerificationGasLimit)
789
- : undefined,
790
- paymasterPostOpGasLimit: userOp.paymasterPostOpGasLimit
791
- ? toHex(userOp.paymasterPostOpGasLimit)
792
- : undefined,
793
- paymasterData: userOp.paymasterData,
794
- signature,
795
- },
796
- entryPoint07Address,
797
- ],
798
- });
799
- return {
800
- type: 'userop',
801
- hash,
802
- chain: chain.id,
803
- };
804
- }
805
- async function submitIntentInternal(config, sourceChains, targetChain, quote, originSignatures, destinationSignature, targetExecutionSignature, authorizations, dryRun, intentInput) {
806
- const request = {
807
- intentId: quote.intentId,
808
- signatures: {
809
- origin: originSignatures,
810
- destination: destinationSignature,
811
- ...(targetExecutionSignature !== undefined && {
812
- targetExecution: targetExecutionSignature,
813
- }),
814
- },
815
- ...(authorizations.length > 0 && {
816
- authorizations: {
817
- sponsor: authorizations.map((authorization) => ({
818
- chainId: authorization.chainId,
819
- address: authorization.address,
820
- nonce: authorization.nonce,
821
- yParity: authorization.yParity ?? 0,
822
- r: authorization.r,
823
- s: authorization.s,
824
- })),
825
- },
826
- }),
827
- ...(dryRun && { options: { dryRun: true } }),
828
- };
829
- const isSponsored = !!intentInput?.options?.sponsorSettings;
830
- const orchestrator = getOrchestrator(config._authProvider ?? createAuthProvider(config), config.endpointUrl, config.headers);
831
- const response = await orchestrator.createIntent(request, intentInput ? { intentInput, isSponsored } : undefined);
832
- return {
833
- type: 'intent',
834
- id: response.intentId,
835
- sourceChains: sourceChains?.map((chain) => chain.id),
836
- targetChain: getChainId(targetChain),
837
- };
838
- }
839
- async function getValidatorAccount(config, signers, publicClient, chain) {
840
- if (!signers) {
841
- return getSmartAccount(config, publicClient, chain);
842
- }
843
- // Owners
844
- const withOwner = signers.type === 'owner' ? signers : null;
845
- if (withOwner) {
846
- return getSmartAccount(config, publicClient, chain);
847
- }
848
- const withGuardians = signers.type === 'guardians' ? signers : null;
849
- return withGuardians
850
- ? await getGuardianSmartAccount(config, publicClient, chain, {
851
- type: 'ecdsa',
852
- accounts: withGuardians.guardians,
853
- })
854
- : null;
855
- }
856
- function getValidator(config, signers) {
857
- if (!signers) {
858
- return getOwnerValidator(config);
859
- }
860
- // Owners
861
- const withOwner = signers.type === 'owner' ? signers : null;
862
- if (withOwner) {
863
- // ECDSA
864
- if (withOwner.kind === 'ecdsa') {
865
- // Use the configured owner validator (e.g., ENS) rather than forcing Ownable
866
- return getOwnerValidator(config);
867
- }
868
- // Passkeys (WebAuthn)
869
- if (withOwner.kind === 'passkey') {
870
- return getWebAuthnValidator(1, withOwner.accounts.map((account) => ({
871
- pubKey: account.publicKey,
872
- authenticatorId: account.id,
873
- })));
874
- }
875
- // Multi-factor
876
- if (withOwner.kind === 'multi-factor') {
877
- return getMultiFactorValidator(1, withOwner.validators);
878
- }
879
- }
880
- // Smart sessions
881
- const withSession = signers.type === 'experimental_session';
882
- if (withSession) {
883
- return getSmartSessionValidator(config);
884
- }
885
- // Guardians (social recovery)
886
- const withGuardians = signers.type === 'guardians' ? signers : null;
887
- if (withGuardians) {
888
- return getSocialRecoveryValidator(withGuardians.guardians);
889
- }
890
- // Fallback
891
- return undefined;
892
- }
893
- function parseCalls(calls, chainId) {
894
- // Destination calls only run on EVM chains (non-EVM destinations reject
895
- // calls upstream), so the resolved `to` is always a viem `Address` here.
896
- return calls.map((call) => ({
897
- data: call.data ?? '0x',
898
- value: call.value ?? 0n,
899
- to: resolveTokenAddress(call.to, chainId),
900
- }));
901
- }
902
- function createAccountAccessList(sourceChains, sourceAssets) {
903
- if (!sourceChains && !sourceAssets)
904
- return undefined;
905
- const chainIds = sourceChains?.map((chain) => chain.id);
906
- if (!sourceAssets)
907
- return { chainIds };
908
- if (Array.isArray(sourceAssets)) {
909
- const isExactConfig = sourceAssets.length > 0 && typeof sourceAssets[0] !== 'string';
910
- if (isExactConfig) {
911
- const chainTokens = {};
912
- const chainTokenAmounts = {};
913
- for (const config of sourceAssets) {
914
- const chainId = config.chain.id;
915
- // Source assets live on viem `Chain`s, which are always EVM, so the
916
- // resolved value is a viem `Address`.
917
- const tokenAddress = resolveTokenAddress(config.address, config.chain.id);
918
- if (config.amount !== undefined) {
919
- if (!chainTokenAmounts[chainId])
920
- chainTokenAmounts[chainId] = {};
921
- chainTokenAmounts[chainId][tokenAddress] = config.amount;
922
- }
923
- else {
924
- if (!chainTokens[chainId])
925
- chainTokens[chainId] = [];
926
- chainTokens[chainId].push(tokenAddress);
927
- }
928
- }
929
- const out = {};
930
- if (Object.keys(chainTokens).length > 0) {
931
- out.chainTokens =
932
- chainTokens;
933
- }
934
- if (Object.keys(chainTokenAmounts).length > 0) {
935
- out.chainTokenAmounts =
936
- chainTokenAmounts;
937
- }
938
- return out;
939
- }
940
- return chainIds
941
- ? { chainIds, tokens: sourceAssets }
942
- : { tokens: sourceAssets };
943
- }
944
- return { chainTokens: sourceAssets };
945
- }
946
- function getSetupOperationsAndDelegations(config, accountAddress, eip7702InitSignature) {
947
- const initCode = getInitCode(config);
948
- if (config.account?.type === 'eoa') {
949
- return {
950
- setupOps: [],
951
- };
952
- }
953
- else if (is7702(config)) {
954
- // EIP-7702 initialization is only needed for EOA accounts
955
- if (!eip7702InitSignature || eip7702InitSignature === '0x') {
956
- throw new Eip7702InitSignatureRequiredError();
957
- }
958
- const { initData: eip7702InitData, contract: eip7702Contract } = getEip7702InitCall(config, eip7702InitSignature);
959
- return {
960
- setupOps: [
961
- {
962
- to: accountAddress,
963
- data: eip7702InitData,
964
- },
965
- ],
966
- delegations: {
967
- 0: {
968
- contract: eip7702Contract,
969
- },
970
- },
971
- };
972
- }
973
- else if (initCode) {
974
- const to = 'factory' in initCode ? initCode.factory : undefined;
975
- const data = 'factory' in initCode ? initCode.factoryData : undefined;
976
- if (!to || !data) {
977
- // Check if it's a migrated account with address-only initData
978
- if (config.initData && !('factory' in config.initData)) {
979
- // Assume the account is already deployed
980
- return {
981
- setupOps: [],
982
- };
983
- }
984
- throw new FactoryArgsNotAvailableError();
985
- }
986
- // Contract account with init code
987
- return {
988
- setupOps: [
989
- {
990
- to,
991
- data,
992
- },
993
- ],
994
- };
995
- }
996
- else {
997
- // Already deployed contract account
998
- return {
999
- setupOps: [],
1000
- };
1001
- }
1002
- }
1003
- function validateTokenSymbols(chain, tokenAddressOrSymbols) {
1004
- function validateTokenSymbol(chain, addressOrSymbol) {
1005
- // Address
1006
- if (isAddress(addressOrSymbol, { strict: false })) {
1007
- return true;
1008
- }
1009
- // Token symbol
1010
- const address = getTokenAddress(addressOrSymbol, chain.id);
1011
- return isAddress(address, { strict: false });
1012
- }
1013
- for (const addressOrSymbol of tokenAddressOrSymbols) {
1014
- if (!validateTokenSymbol(chain, addressOrSymbol)) {
1015
- throw new Error(`Invalid token symbol: ${addressOrSymbol}`);
1016
- }
1017
- }
1018
- }
1019
- // Signs typed data using ERC-7739 nested EIP-712 for Startale accounts.
1020
- // Uses a Solady-compatible TypedDataSign hash and wraps the signature with
1021
- // the app domain separator and contents hash for on-chain verification.
1022
- async function signErc7739TypedData(config, signers, validator, isRoot, parameters, chain) {
1023
- const verifierDomain = getEip712Domain(config, chain);
1024
- const hash = hashErc7739TypedDataForSolady({
1025
- domain: parameters.domain,
1026
- types: parameters.types,
1027
- primaryType: parameters.primaryType,
1028
- message: parameters.message,
1029
- verifierDomain,
1030
- });
1031
- return await getEip1271Signature(config, signers, chain, {
1032
- address: validator.address,
1033
- isRoot,
1034
- }, hash, (signature) => wrapTypedDataSignature({
1035
- domain: parameters.domain,
1036
- primaryType: parameters.primaryType,
1037
- types: parameters.types,
1038
- message: parameters.message,
1039
- signature,
1040
- }));
1041
- }
1042
- // Computes an ERC-7739 TypedDataSign hash compatible with Solady's ERC1271
1043
- // on-chain verification. Solady constructs the TypedDataSign type string by
1044
- // appending the contentsType directly after the TypedDataSign definition,
1045
- // which differs from viem's standard EIP-712 encodeType that re-sorts all
1046
- // referenced types alphabetically.
1047
- function hashErc7739TypedDataForSolady({ domain, types, primaryType, message, verifierDomain, }) {
1048
- // Standard EIP-712 encodeType for the original content type
1049
- function encodeTypeString(primary, allTypes) {
1050
- const deps = new Set();
1051
- function findDeps(t) {
1052
- const match = t.match(/^\w*/);
1053
- const typeName = match?.[0];
1054
- if (!typeName || deps.has(typeName) || !allTypes[typeName])
1055
- return;
1056
- deps.add(typeName);
1057
- for (const field of allTypes[typeName])
1058
- findDeps(field.type);
1059
- }
1060
- findDeps(primary);
1061
- deps.delete(primary);
1062
- const sorted = [primary, ...Array.from(deps).sort()];
1063
- return sorted
1064
- .map((t) => `${t}(${allTypes[t].map((f) => `${f.type} ${f.name}`).join(',')})`)
1065
- .join('');
1066
- }
1067
- const contentsType = encodeTypeString(primaryType, types);
1068
- const contentsName = primaryType;
1069
- // Construct TypedDataSign type string matching Solady's on-chain encoding:
1070
- // TypedDataSign(<contentsName> contents,...salt) + contentsType
1071
- const typedDataSignTypeString = `TypedDataSign(${contentsName} contents,string name,string version,uint256 chainId,address verifyingContract,bytes32 salt)${contentsType}`;
1072
- const typedDataSignTypeHash = keccak256(toHex(typedDataSignTypeString));
1073
- // Hash the original content struct
1074
- const contentsHash = hashStruct({
1075
- data: message,
1076
- primaryType,
1077
- types: types,
1078
- });
1079
- // Compute the TypedDataSign struct hash
1080
- const structHash = keccak256(encodeAbiParameters([
1081
- { type: 'bytes32' },
1082
- { type: 'bytes32' },
1083
- { type: 'bytes32' },
1084
- { type: 'bytes32' },
1085
- { type: 'uint256' },
1086
- { type: 'address' },
1087
- { type: 'bytes32' },
1088
- ], [
1089
- typedDataSignTypeHash,
1090
- contentsHash,
1091
- keccak256(toHex(verifierDomain.name)),
1092
- keccak256(toHex(verifierDomain.version)),
1093
- BigInt(verifierDomain.chainId),
1094
- verifierDomain.verifyingContract,
1095
- verifierDomain.salt,
1096
- ]));
1097
- // Compute the app domain separator
1098
- const domainTypes = [];
1099
- if (domain.name)
1100
- domainTypes.push({ name: 'name', type: 'string' });
1101
- if (domain.version)
1102
- domainTypes.push({ name: 'version', type: 'string' });
1103
- if (domain.chainId)
1104
- domainTypes.push({ name: 'chainId', type: 'uint256' });
1105
- if (domain.verifyingContract)
1106
- domainTypes.push({ name: 'verifyingContract', type: 'address' });
1107
- if (domain.salt)
1108
- domainTypes.push({ name: 'salt', type: 'bytes32' });
1109
- const appDomainSeparator = hashDomain({
1110
- domain,
1111
- types: { EIP712Domain: domainTypes },
1112
- });
1113
- // Final hash: keccak256("\x19\x01" || appDomainSep || structHash)
1114
- return keccak256(concat(['0x1901', appDomainSeparator, structHash]));
1115
- }
1116
- export { prepareTransaction, getTransactionMessages, signTransaction, signAuthorizations, signAuthorizationsInternal, signMessage, signTypedData, submitTransaction, prepareUserOperation, signUserOperation, submitUserOperation, signIntent, prepareTransactionAsIntent, submitIntentInternal, getValidatorAccount, parseCalls, getTokenRequests, resolveCallInputs, getIntentAccount, getTargetExecutionSignature, hashErc7739TypedDataForSolady, resolveSessionForChain, };