@rhinestone/sdk 2.0.0-beta.44 → 2.0.0-beta.45

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 (603) hide show
  1. package/dist/src/accounts/adapter.d.ts +31 -0
  2. package/dist/src/accounts/adapter.d.ts.map +1 -0
  3. package/dist/src/accounts/adapters/eoa.d.ts +4 -0
  4. package/dist/src/accounts/adapters/eoa.d.ts.map +1 -0
  5. package/dist/src/accounts/adapters/eoa.js +45 -0
  6. package/dist/src/accounts/adapters/hca.d.ts +5 -0
  7. package/dist/src/accounts/adapters/hca.d.ts.map +1 -0
  8. package/dist/src/accounts/adapters/hca.js +118 -0
  9. package/dist/src/accounts/adapters/kernel.d.ts +9 -0
  10. package/dist/src/accounts/adapters/kernel.d.ts.map +1 -0
  11. package/dist/src/accounts/adapters/kernel.js +159 -0
  12. package/dist/src/accounts/adapters/nexus.d.ts +17 -0
  13. package/dist/src/accounts/adapters/nexus.d.ts.map +1 -0
  14. package/dist/src/accounts/adapters/nexus.js +227 -0
  15. package/dist/src/accounts/adapters/safe.d.ts +6 -0
  16. package/dist/src/accounts/adapters/safe.d.ts.map +1 -0
  17. package/dist/src/accounts/adapters/safe.js +194 -0
  18. package/dist/src/accounts/adapters/shared.d.ts +9 -0
  19. package/dist/src/accounts/adapters/shared.d.ts.map +1 -0
  20. package/dist/src/accounts/adapters/shared.js +62 -0
  21. package/dist/src/accounts/adapters/startale.d.ts +14 -0
  22. package/dist/src/accounts/adapters/startale.d.ts.map +1 -0
  23. package/dist/src/accounts/adapters/startale.js +165 -0
  24. package/dist/src/accounts/construction.d.ts +25 -0
  25. package/dist/src/accounts/construction.d.ts.map +1 -0
  26. package/dist/src/accounts/construction.js +34 -0
  27. package/dist/src/accounts/deployment.d.ts +12 -0
  28. package/dist/src/accounts/deployment.d.ts.map +1 -0
  29. package/dist/src/accounts/deployment.js +33 -0
  30. package/dist/src/accounts/erc7579-calls.d.ts +4 -0
  31. package/dist/src/accounts/erc7579-calls.d.ts.map +1 -0
  32. package/dist/src/accounts/erc7579-calls.js +57 -0
  33. package/dist/src/accounts/error.d.ts +1 -1
  34. package/dist/src/accounts/error.d.ts.map +1 -1
  35. package/dist/src/accounts/legacy.d.ts +14 -0
  36. package/dist/src/accounts/legacy.d.ts.map +1 -0
  37. package/dist/src/accounts/legacy.js +40 -0
  38. package/dist/src/accounts/registry.d.ts +4 -0
  39. package/dist/src/accounts/registry.d.ts.map +1 -0
  40. package/dist/src/accounts/registry.js +22 -0
  41. package/dist/src/accounts/types.d.ts +131 -0
  42. package/dist/src/accounts/types.d.ts.map +1 -0
  43. package/dist/src/accounts/wallet-account.d.ts +3 -0
  44. package/dist/src/accounts/wallet-account.d.ts.map +1 -0
  45. package/dist/src/accounts/wallet-account.js +12 -0
  46. package/dist/src/actions/deploy.d.ts +4 -0
  47. package/dist/src/actions/deploy.d.ts.map +1 -0
  48. package/dist/src/actions/deploy.js +8 -0
  49. package/dist/src/actions/ecdsa.d.ts +1 -1
  50. package/dist/src/actions/ecdsa.d.ts.map +1 -1
  51. package/dist/src/actions/ecdsa.js +8 -8
  52. package/dist/src/actions/index.d.ts +2 -16
  53. package/dist/src/actions/index.d.ts.map +1 -1
  54. package/dist/src/actions/index.js +3 -49
  55. package/dist/src/actions/mfa.d.ts +1 -1
  56. package/dist/src/actions/mfa.d.ts.map +1 -1
  57. package/dist/src/actions/mfa.js +30 -10
  58. package/dist/src/actions/modules.d.ts +4 -0
  59. package/dist/src/actions/modules.d.ts.map +1 -0
  60. package/dist/src/actions/modules.js +22 -0
  61. package/dist/src/actions/passkeys.d.ts +2 -2
  62. package/dist/src/actions/passkeys.d.ts.map +1 -1
  63. package/dist/src/actions/passkeys.js +19 -14
  64. package/dist/src/actions/runtime.d.ts +12 -0
  65. package/dist/src/actions/runtime.d.ts.map +1 -0
  66. package/dist/src/actions/runtime.js +161 -0
  67. package/dist/src/actions/smart-sessions.d.ts +2 -2
  68. package/dist/src/actions/smart-sessions.d.ts.map +1 -1
  69. package/dist/src/actions/smart-sessions.js +35 -12
  70. package/dist/src/api/account.d.ts +265 -0
  71. package/dist/src/api/account.d.ts.map +1 -0
  72. package/dist/src/api/account.js +635 -0
  73. package/dist/src/api/accounts.d.ts +12 -0
  74. package/dist/src/api/accounts.d.ts.map +1 -0
  75. package/dist/src/api/accounts.js +17 -0
  76. package/dist/src/api/compose-types.d.ts +147 -0
  77. package/dist/src/api/compose-types.d.ts.map +1 -0
  78. package/dist/src/api/compose.d.ts +6 -0
  79. package/dist/src/api/compose.d.ts.map +1 -0
  80. package/dist/src/api/compose.js +766 -0
  81. package/dist/src/api/direct-signing.d.ts +27 -0
  82. package/dist/src/api/direct-signing.d.ts.map +1 -0
  83. package/dist/src/api/direct-signing.js +191 -0
  84. package/dist/src/api/project-mappers.d.ts +7 -0
  85. package/dist/src/api/project-mappers.d.ts.map +1 -0
  86. package/dist/src/api/project-mappers.js +23 -0
  87. package/dist/src/api/queries/app-fees.d.ts +4 -0
  88. package/dist/src/api/queries/app-fees.d.ts.map +1 -0
  89. package/dist/src/api/queries/app-fees.js +3 -0
  90. package/dist/src/api/queries/portfolio.d.ts +9 -0
  91. package/dist/src/api/queries/portfolio.d.ts.map +1 -0
  92. package/dist/src/api/queries/portfolio.js +28 -0
  93. package/dist/src/api/queries/session.d.ts +8 -0
  94. package/dist/src/api/queries/session.d.ts.map +1 -0
  95. package/dist/src/api/queries/session.js +15 -0
  96. package/dist/src/api/sdk.d.ts +80 -0
  97. package/dist/src/api/sdk.d.ts.map +1 -0
  98. package/dist/src/api/sdk.js +103 -0
  99. package/dist/src/api/signer-selection.d.ts +7 -0
  100. package/dist/src/api/signer-selection.d.ts.map +1 -0
  101. package/dist/src/api/signer-selection.js +109 -0
  102. package/dist/src/calls/normalize.d.ts +9 -0
  103. package/dist/src/calls/normalize.d.ts.map +1 -0
  104. package/dist/src/calls/normalize.js +17 -0
  105. package/dist/src/calls/resolve.d.ts +3 -0
  106. package/dist/src/calls/resolve.d.ts.map +1 -0
  107. package/dist/src/calls/resolve.js +15 -0
  108. package/dist/src/calls/types.d.ts +25 -0
  109. package/dist/src/calls/types.d.ts.map +1 -0
  110. package/dist/src/calls/types.js +1 -0
  111. package/dist/src/chains/caip2.d.ts +10 -0
  112. package/dist/src/chains/caip2.d.ts.map +1 -0
  113. package/dist/src/chains/caip2.js +85 -0
  114. package/dist/src/chains/catalog.d.ts +5 -0
  115. package/dist/src/chains/catalog.d.ts.map +1 -0
  116. package/dist/src/chains/catalog.js +41 -0
  117. package/dist/src/chains/errors.d.ts +15 -0
  118. package/dist/src/chains/errors.d.ts.map +1 -0
  119. package/dist/src/chains/errors.js +21 -0
  120. package/dist/src/{orchestrator/destinations.d.ts → chains/non-evm.d.ts} +7 -5
  121. package/dist/src/chains/non-evm.d.ts.map +1 -0
  122. package/dist/src/chains/non-evm.js +30 -0
  123. package/dist/src/chains/tokens.d.ts +4 -0
  124. package/dist/src/chains/tokens.d.ts.map +1 -0
  125. package/dist/src/chains/tokens.js +22 -0
  126. package/dist/src/chains/types.d.ts +25 -0
  127. package/dist/src/chains/types.d.ts.map +1 -0
  128. package/dist/src/chains/types.js +1 -0
  129. package/dist/src/clients/bundler/client.d.ts +10 -0
  130. package/dist/src/clients/bundler/client.d.ts.map +1 -0
  131. package/dist/src/clients/bundler/client.js +85 -0
  132. package/dist/src/clients/bundler/endpoints.d.ts +3 -0
  133. package/dist/src/clients/bundler/endpoints.d.ts.map +1 -0
  134. package/dist/src/clients/bundler/endpoints.js +18 -0
  135. package/dist/src/clients/bundler/port.d.ts +22 -0
  136. package/dist/src/clients/bundler/port.d.ts.map +1 -0
  137. package/dist/src/clients/bundler/port.js +1 -0
  138. package/dist/src/clients/json-rpc.d.ts +20 -0
  139. package/dist/src/clients/json-rpc.d.ts.map +1 -0
  140. package/dist/src/clients/json-rpc.js +56 -0
  141. package/dist/src/clients/orchestrator/auth.d.ts +7 -0
  142. package/dist/src/clients/orchestrator/auth.d.ts.map +1 -0
  143. package/dist/src/clients/orchestrator/auth.js +27 -0
  144. package/dist/src/{orchestrator → clients/orchestrator}/chain-catalog.d.ts +5 -3
  145. package/dist/src/clients/orchestrator/chain-catalog.d.ts.map +1 -0
  146. package/dist/src/{orchestrator → clients/orchestrator}/chain-catalog.js +24 -3
  147. package/dist/src/clients/orchestrator/client.d.ts +13 -0
  148. package/dist/src/clients/orchestrator/client.d.ts.map +1 -0
  149. package/dist/src/clients/orchestrator/client.js +97 -0
  150. package/dist/src/{orchestrator/error.d.ts → clients/orchestrator/errors.d.ts} +2 -16
  151. package/dist/src/clients/orchestrator/errors.d.ts.map +1 -0
  152. package/dist/src/{orchestrator/error.js → clients/orchestrator/errors.js} +1 -22
  153. package/dist/src/clients/orchestrator/fetch.d.ts +7 -0
  154. package/dist/src/clients/orchestrator/fetch.d.ts.map +1 -0
  155. package/dist/src/clients/orchestrator/fetch.js +37 -0
  156. package/dist/src/clients/orchestrator/mappers.d.ts +9 -0
  157. package/dist/src/clients/orchestrator/mappers.d.ts.map +1 -0
  158. package/dist/src/clients/orchestrator/mappers.js +198 -0
  159. package/dist/src/clients/orchestrator/port.d.ts +26 -0
  160. package/dist/src/clients/orchestrator/port.d.ts.map +1 -0
  161. package/dist/src/clients/orchestrator/port.js +1 -0
  162. package/dist/src/{orchestrator/types.d.ts → clients/orchestrator/public.d.ts} +4 -4
  163. package/dist/src/clients/orchestrator/public.d.ts.map +1 -0
  164. package/dist/src/{orchestrator/types.js → clients/orchestrator/public.js} +3 -0
  165. package/dist/src/clients/orchestrator/types.d.ts +140 -0
  166. package/dist/src/clients/orchestrator/types.d.ts.map +1 -0
  167. package/dist/src/clients/orchestrator/types.js +1 -0
  168. package/dist/src/clients/orchestrator/wire.d.ts +19 -0
  169. package/dist/src/clients/orchestrator/wire.d.ts.map +1 -0
  170. package/dist/src/{orchestrator → clients/orchestrator}/wire.gen.d.ts +498 -498
  171. package/dist/src/clients/orchestrator/wire.gen.d.ts.map +1 -0
  172. package/dist/src/clients/orchestrator/wire.gen.js +1 -0
  173. package/dist/src/clients/orchestrator/wire.js +1 -0
  174. package/dist/src/clients/paymaster/client.d.ts +8 -0
  175. package/dist/src/clients/paymaster/client.d.ts.map +1 -0
  176. package/dist/src/clients/paymaster/client.js +38 -0
  177. package/dist/src/clients/paymaster/endpoints.d.ts +3 -0
  178. package/dist/src/clients/paymaster/endpoints.d.ts.map +1 -0
  179. package/dist/src/clients/paymaster/endpoints.js +16 -0
  180. package/dist/src/clients/paymaster/port.d.ts +17 -0
  181. package/dist/src/clients/paymaster/port.d.ts.map +1 -0
  182. package/dist/src/clients/paymaster/port.js +1 -0
  183. package/dist/src/clients/rpc/client.d.ts +6 -0
  184. package/dist/src/clients/rpc/client.d.ts.map +1 -0
  185. package/dist/src/clients/rpc/client.js +66 -0
  186. package/dist/src/clients/rpc/compatibility.d.ts +12 -0
  187. package/dist/src/clients/rpc/compatibility.d.ts.map +1 -0
  188. package/dist/src/clients/rpc/compatibility.js +16 -0
  189. package/dist/src/clients/rpc/port.d.ts +13 -0
  190. package/dist/src/clients/rpc/port.d.ts.map +1 -0
  191. package/dist/src/clients/rpc/port.js +1 -0
  192. package/dist/src/clients/rpc/providers.d.ts +3 -0
  193. package/dist/src/clients/rpc/providers.d.ts.map +1 -0
  194. package/dist/src/clients/rpc/providers.js +8 -0
  195. package/dist/src/clients/rpc/transport.d.ts +4 -0
  196. package/dist/src/clients/rpc/transport.d.ts.map +1 -0
  197. package/dist/src/clients/rpc/transport.js +5 -0
  198. package/dist/src/clients/rpc/types.d.ts +23 -0
  199. package/dist/src/clients/rpc/types.d.ts.map +1 -0
  200. package/dist/src/clients/rpc/types.js +1 -0
  201. package/dist/src/config/account-runtime.d.ts +7 -0
  202. package/dist/src/config/account-runtime.d.ts.map +1 -0
  203. package/dist/src/config/account-runtime.js +36 -0
  204. package/dist/src/{types.d.ts → config/account.d.ts} +23 -14
  205. package/dist/src/config/account.d.ts.map +1 -0
  206. package/dist/src/config/account.js +10 -0
  207. package/dist/src/config/defaults.d.ts +14 -0
  208. package/dist/src/config/defaults.d.ts.map +1 -0
  209. package/dist/src/config/defaults.js +26 -0
  210. package/dist/src/config/input.d.ts +54 -0
  211. package/dist/src/config/input.d.ts.map +1 -0
  212. package/dist/src/config/input.js +1 -0
  213. package/dist/src/config/legacy.d.ts +22 -0
  214. package/dist/src/config/legacy.d.ts.map +1 -0
  215. package/dist/src/config/legacy.js +23 -0
  216. package/dist/src/config/resolve.d.ts +13 -0
  217. package/dist/src/config/resolve.d.ts.map +1 -0
  218. package/dist/src/config/resolve.js +174 -0
  219. package/dist/src/config/resolved.d.ts +77 -0
  220. package/dist/src/config/resolved.d.ts.map +1 -0
  221. package/dist/src/config/resolved.js +1 -0
  222. package/dist/src/config/validate.d.ts +3 -0
  223. package/dist/src/config/validate.d.ts.map +1 -0
  224. package/dist/src/config/validate.js +6 -0
  225. package/dist/src/{execution/error.d.ts → errors/execution.d.ts} +2 -2
  226. package/dist/src/errors/execution.d.ts.map +1 -0
  227. package/dist/src/{execution/error.js → errors/execution.js} +1 -1
  228. package/dist/src/errors/index.d.ts +4 -4
  229. package/dist/src/errors/index.d.ts.map +1 -1
  230. package/dist/src/errors/index.js +4 -3
  231. package/dist/src/index.d.ts +13 -324
  232. package/dist/src/index.d.ts.map +1 -1
  233. package/dist/src/index.js +6 -286
  234. package/dist/src/modules/erc7579-abi.d.ts +4 -0
  235. package/dist/src/modules/erc7579-abi.d.ts.map +1 -0
  236. package/dist/src/modules/erc7579-abi.js +12 -0
  237. package/dist/src/modules/intent-executor.d.ts +6 -0
  238. package/dist/src/modules/intent-executor.d.ts.map +1 -0
  239. package/dist/src/modules/intent-executor.js +13 -0
  240. package/dist/src/modules/legacy-core.d.ts +29 -0
  241. package/dist/src/modules/legacy-core.d.ts.map +1 -0
  242. package/dist/src/modules/legacy-core.js +80 -0
  243. package/dist/src/modules/normalize.d.ts +4 -0
  244. package/dist/src/modules/normalize.d.ts.map +1 -0
  245. package/dist/src/modules/normalize.js +15 -0
  246. package/dist/src/modules/plan.d.ts +16 -0
  247. package/dist/src/modules/plan.d.ts.map +1 -0
  248. package/dist/src/modules/plan.js +51 -0
  249. package/dist/src/modules/read-core.d.ts +39 -0
  250. package/dist/src/modules/read-core.d.ts.map +1 -0
  251. package/dist/src/modules/read-core.js +149 -0
  252. package/dist/src/modules/types.d.ts +46 -0
  253. package/dist/src/modules/types.d.ts.map +1 -0
  254. package/dist/src/modules/types.js +1 -0
  255. package/dist/src/modules/validators/capabilities.d.ts +4 -0
  256. package/dist/src/modules/validators/capabilities.d.ts.map +1 -0
  257. package/dist/src/modules/validators/capabilities.js +58 -0
  258. package/dist/src/modules/validators/contribution.d.ts +4 -0
  259. package/dist/src/modules/validators/contribution.d.ts.map +1 -0
  260. package/dist/src/modules/validators/contribution.js +64 -0
  261. package/dist/src/modules/validators/definition.d.ts +3 -0
  262. package/dist/src/modules/validators/definition.d.ts.map +1 -0
  263. package/dist/src/modules/validators/definition.js +68 -0
  264. package/dist/src/modules/validators/ens.d.ts +5 -0
  265. package/dist/src/modules/validators/ens.d.ts.map +1 -0
  266. package/dist/src/modules/validators/ens.js +34 -0
  267. package/dist/src/modules/validators/k1.d.ts +2 -0
  268. package/dist/src/modules/validators/k1.d.ts.map +1 -0
  269. package/dist/src/modules/validators/k1.js +1 -0
  270. package/dist/src/modules/validators/multi-factor.d.ts +18 -0
  271. package/dist/src/modules/validators/multi-factor.d.ts.map +1 -0
  272. package/dist/src/modules/validators/multi-factor.js +79 -0
  273. package/dist/src/modules/validators/ownable.d.ts +26 -0
  274. package/dist/src/modules/validators/ownable.d.ts.map +1 -0
  275. package/dist/src/modules/validators/ownable.js +84 -0
  276. package/dist/src/modules/validators/permissions.d.ts +1 -1
  277. package/dist/src/modules/validators/permissions.d.ts.map +1 -1
  278. package/dist/src/modules/validators/policies/claim/arbiters.d.ts +1 -1
  279. package/dist/src/modules/validators/policies/claim/arbiters.d.ts.map +1 -1
  280. package/dist/src/modules/validators/policies/claim/arbiters.js +3 -1
  281. package/dist/src/modules/validators/resolve.d.ts +5 -0
  282. package/dist/src/modules/validators/resolve.d.ts.map +1 -0
  283. package/dist/src/modules/validators/resolve.js +22 -0
  284. package/dist/src/modules/validators/signer-id.d.ts +5 -0
  285. package/dist/src/modules/validators/signer-id.d.ts.map +1 -0
  286. package/dist/src/modules/validators/signer-id.js +8 -0
  287. package/dist/src/modules/validators/smart-session-signature-types.d.ts +35 -0
  288. package/dist/src/modules/validators/smart-session-signature-types.d.ts.map +1 -0
  289. package/dist/src/modules/validators/smart-session-signature-types.js +1 -0
  290. package/dist/src/modules/validators/smart-sessions/authorization.d.ts +99 -0
  291. package/dist/src/modules/validators/smart-sessions/authorization.d.ts.map +1 -0
  292. package/dist/src/modules/validators/smart-sessions/authorization.js +101 -0
  293. package/dist/src/modules/validators/smart-sessions/calls.d.ts +19 -0
  294. package/dist/src/modules/validators/smart-sessions/calls.d.ts.map +1 -0
  295. package/dist/src/modules/validators/smart-sessions/calls.js +85 -0
  296. package/dist/src/modules/validators/smart-sessions/cross-chain-permits.d.ts +4 -0
  297. package/dist/src/modules/validators/smart-sessions/cross-chain-permits.d.ts.map +1 -0
  298. package/dist/src/modules/validators/smart-sessions/cross-chain-permits.js +77 -0
  299. package/dist/src/modules/validators/smart-sessions/digest.d.ts +5 -0
  300. package/dist/src/modules/validators/smart-sessions/digest.d.ts.map +1 -0
  301. package/dist/src/modules/validators/smart-sessions/digest.js +30 -0
  302. package/dist/src/modules/validators/smart-sessions/mock-signature.d.ts +10 -0
  303. package/dist/src/modules/validators/smart-sessions/mock-signature.d.ts.map +1 -0
  304. package/dist/src/modules/validators/smart-sessions/mock-signature.js +31 -0
  305. package/dist/src/modules/validators/smart-sessions/module.d.ts +11 -0
  306. package/dist/src/modules/validators/smart-sessions/module.d.ts.map +1 -0
  307. package/dist/src/modules/validators/smart-sessions/module.js +18 -0
  308. package/dist/src/modules/validators/smart-sessions/policies/addresses.d.ts +23 -0
  309. package/dist/src/modules/validators/smart-sessions/policies/addresses.d.ts.map +1 -0
  310. package/dist/src/modules/validators/smart-sessions/policies/addresses.js +29 -0
  311. package/dist/src/modules/validators/smart-sessions/policies/claim.d.ts +10 -0
  312. package/dist/src/modules/validators/smart-sessions/policies/claim.d.ts.map +1 -0
  313. package/dist/src/modules/validators/smart-sessions/policies/claim.js +106 -0
  314. package/dist/src/modules/validators/smart-sessions/policies/encode.d.ts +4 -0
  315. package/dist/src/modules/validators/smart-sessions/policies/encode.d.ts.map +1 -0
  316. package/dist/src/modules/validators/smart-sessions/policies/encode.js +197 -0
  317. package/dist/src/modules/validators/smart-sessions/resolve.d.ts +16 -0
  318. package/dist/src/modules/validators/smart-sessions/resolve.d.ts.map +1 -0
  319. package/dist/src/modules/validators/smart-sessions/resolve.js +120 -0
  320. package/dist/src/modules/validators/smart-sessions/signature.d.ts +14 -0
  321. package/dist/src/modules/validators/smart-sessions/signature.d.ts.map +1 -0
  322. package/dist/src/modules/validators/smart-sessions/signature.js +167 -0
  323. package/dist/src/modules/validators/smart-sessions/state.d.ts +19 -0
  324. package/dist/src/modules/validators/smart-sessions/state.d.ts.map +1 -0
  325. package/dist/src/modules/validators/smart-sessions/state.js +42 -0
  326. package/dist/src/modules/validators/smart-sessions/types.d.ts +227 -0
  327. package/dist/src/modules/validators/smart-sessions/types.d.ts.map +1 -0
  328. package/dist/src/modules/validators/smart-sessions/types.js +1 -0
  329. package/dist/src/modules/validators/types.d.ts +143 -0
  330. package/dist/src/modules/validators/types.d.ts.map +1 -0
  331. package/dist/src/modules/validators/types.js +1 -0
  332. package/dist/src/modules/validators/webauthn.d.ts +54 -0
  333. package/dist/src/modules/validators/webauthn.d.ts.map +1 -0
  334. package/dist/src/modules/validators/webauthn.js +159 -0
  335. package/dist/src/signing/context.d.ts +25 -0
  336. package/dist/src/signing/context.d.ts.map +1 -0
  337. package/dist/src/signing/context.js +163 -0
  338. package/dist/src/signing/contribution.d.ts +13 -0
  339. package/dist/src/signing/contribution.d.ts.map +1 -0
  340. package/dist/src/signing/contribution.js +83 -0
  341. package/dist/src/signing/eip7702.d.ts +41 -0
  342. package/dist/src/signing/eip7702.d.ts.map +1 -0
  343. package/dist/src/signing/eip7702.js +215 -0
  344. package/dist/src/signing/error.d.ts +27 -0
  345. package/dist/src/signing/error.d.ts.map +1 -0
  346. package/dist/src/signing/error.js +25 -0
  347. package/dist/src/signing/execute.d.ts +17 -0
  348. package/dist/src/signing/execute.d.ts.map +1 -0
  349. package/dist/src/signing/execute.js +138 -0
  350. package/dist/src/signing/intent-plans/assemble.d.ts +15 -0
  351. package/dist/src/signing/intent-plans/assemble.d.ts.map +1 -0
  352. package/dist/src/signing/intent-plans/assemble.js +96 -0
  353. package/dist/src/signing/intent-plans/independent.d.ts +48 -0
  354. package/dist/src/signing/intent-plans/independent.d.ts.map +1 -0
  355. package/dist/src/signing/intent-plans/independent.js +150 -0
  356. package/dist/src/signing/intent-plans/plan.d.ts +14 -0
  357. package/dist/src/signing/intent-plans/plan.d.ts.map +1 -0
  358. package/dist/src/signing/intent-plans/plan.js +187 -0
  359. package/dist/src/signing/intent-plans/types.d.ts +63 -0
  360. package/dist/src/signing/intent-plans/types.d.ts.map +1 -0
  361. package/dist/src/signing/intent-plans/types.js +1 -0
  362. package/dist/src/signing/message.d.ts +28 -0
  363. package/dist/src/signing/message.d.ts.map +1 -0
  364. package/dist/src/signing/message.js +90 -0
  365. package/dist/src/signing/passkeys.d.ts +28 -0
  366. package/dist/src/signing/passkeys.d.ts.map +1 -0
  367. package/dist/src/signing/passkeys.js +17 -0
  368. package/dist/src/signing/plan.d.ts +35 -0
  369. package/dist/src/signing/plan.d.ts.map +1 -0
  370. package/dist/src/signing/plan.js +377 -0
  371. package/dist/src/signing/protocols/erc6492.d.ts +11 -0
  372. package/dist/src/signing/protocols/erc6492.d.ts.map +1 -0
  373. package/dist/src/signing/protocols/erc6492.js +24 -0
  374. package/dist/src/signing/protocols/erc7739.d.ts +17 -0
  375. package/dist/src/signing/protocols/erc7739.d.ts.map +1 -0
  376. package/dist/src/signing/protocols/erc7739.js +84 -0
  377. package/dist/src/signing/session-enable.d.ts +35 -0
  378. package/dist/src/signing/session-enable.d.ts.map +1 -0
  379. package/dist/src/signing/session-enable.js +62 -0
  380. package/dist/src/signing/signers/compatibility.d.ts +4 -0
  381. package/dist/src/signing/signers/compatibility.d.ts.map +1 -0
  382. package/dist/src/signing/signers/compatibility.js +51 -0
  383. package/dist/src/signing/signers/ecdsa.d.ts +14 -0
  384. package/dist/src/signing/signers/ecdsa.d.ts.map +1 -0
  385. package/dist/src/signing/signers/ecdsa.js +54 -0
  386. package/dist/src/signing/signers/registry.d.ts +7 -0
  387. package/dist/src/signing/signers/registry.d.ts.map +1 -0
  388. package/dist/src/signing/signers/registry.js +33 -0
  389. package/dist/src/signing/signers/types.d.ts +16 -0
  390. package/dist/src/signing/signers/types.d.ts.map +1 -0
  391. package/dist/src/signing/signers/types.js +1 -0
  392. package/dist/src/signing/signers/wallet-chain.d.ts +9 -0
  393. package/dist/src/signing/signers/wallet-chain.d.ts.map +1 -0
  394. package/dist/src/signing/signers/wallet-chain.js +15 -0
  395. package/dist/src/signing/signers/webauthn.d.ts +11 -0
  396. package/dist/src/signing/signers/webauthn.d.ts.map +1 -0
  397. package/dist/src/signing/signers/webauthn.js +14 -0
  398. package/dist/src/signing/typed-data.d.ts +39 -0
  399. package/dist/src/signing/typed-data.d.ts.map +1 -0
  400. package/dist/src/signing/typed-data.js +135 -0
  401. package/dist/src/signing/types.d.ts +346 -0
  402. package/dist/src/signing/types.d.ts.map +1 -0
  403. package/dist/src/signing/types.js +1 -0
  404. package/dist/src/signing/user-operation.d.ts +23 -0
  405. package/dist/src/signing/user-operation.d.ts.map +1 -0
  406. package/dist/src/signing/user-operation.js +61 -0
  407. package/dist/src/smart-sessions/index.d.ts +13 -3
  408. package/dist/src/smart-sessions/index.d.ts.map +1 -1
  409. package/dist/src/smart-sessions/index.js +44 -6
  410. package/dist/src/transactions/intents/account.d.ts +15 -0
  411. package/dist/src/transactions/intents/account.d.ts.map +1 -0
  412. package/dist/src/transactions/intents/account.js +48 -0
  413. package/dist/src/transactions/intents/compatibility.d.ts +4 -0
  414. package/dist/src/transactions/intents/compatibility.d.ts.map +1 -0
  415. package/dist/src/transactions/intents/compatibility.js +19 -0
  416. package/dist/src/transactions/intents/normalize.d.ts +5 -0
  417. package/dist/src/transactions/intents/normalize.d.ts.map +1 -0
  418. package/dist/src/transactions/intents/normalize.js +48 -0
  419. package/dist/src/transactions/intents/prepare.d.ts +7 -0
  420. package/dist/src/transactions/intents/prepare.d.ts.map +1 -0
  421. package/dist/src/transactions/intents/prepare.js +249 -0
  422. package/dist/src/transactions/intents/quotes.d.ts +3 -0
  423. package/dist/src/transactions/intents/quotes.d.ts.map +1 -0
  424. package/dist/src/transactions/intents/quotes.js +11 -0
  425. package/dist/src/transactions/intents/request.d.ts +11 -0
  426. package/dist/src/transactions/intents/request.d.ts.map +1 -0
  427. package/dist/src/transactions/intents/request.js +55 -0
  428. package/dist/src/transactions/intents/send.d.ts +3 -0
  429. package/dist/src/transactions/intents/send.d.ts.map +1 -0
  430. package/dist/src/transactions/intents/send.js +22 -0
  431. package/dist/src/transactions/intents/session-signing.d.ts +7 -0
  432. package/dist/src/transactions/intents/session-signing.d.ts.map +1 -0
  433. package/dist/src/transactions/intents/session-signing.js +363 -0
  434. package/dist/src/transactions/intents/sessions.d.ts +17 -0
  435. package/dist/src/transactions/intents/sessions.d.ts.map +1 -0
  436. package/dist/src/transactions/intents/sessions.js +85 -0
  437. package/dist/src/transactions/intents/sign-transaction.d.ts +10 -0
  438. package/dist/src/transactions/intents/sign-transaction.d.ts.map +1 -0
  439. package/dist/src/transactions/intents/sign-transaction.js +386 -0
  440. package/dist/src/transactions/intents/split.d.ts +13 -0
  441. package/dist/src/transactions/intents/split.d.ts.map +1 -0
  442. package/dist/src/transactions/intents/split.js +3 -0
  443. package/dist/src/transactions/intents/status-policy.d.ts +13 -0
  444. package/dist/src/transactions/intents/status-policy.d.ts.map +1 -0
  445. package/dist/src/transactions/intents/status-policy.js +39 -0
  446. package/dist/src/transactions/intents/status.d.ts +4 -0
  447. package/dist/src/transactions/intents/status.d.ts.map +1 -0
  448. package/dist/src/transactions/intents/status.js +50 -0
  449. package/dist/src/transactions/intents/submit.d.ts +3 -0
  450. package/dist/src/transactions/intents/submit.d.ts.map +1 -0
  451. package/dist/src/transactions/intents/submit.js +32 -0
  452. package/dist/src/transactions/intents/types.d.ts +136 -0
  453. package/dist/src/transactions/intents/types.d.ts.map +1 -0
  454. package/dist/src/transactions/intents/types.js +1 -0
  455. package/dist/src/transactions/user-operations/hash.d.ts +5 -0
  456. package/dist/src/transactions/user-operations/hash.d.ts.map +1 -0
  457. package/dist/src/transactions/user-operations/hash.js +9 -0
  458. package/dist/src/transactions/user-operations/nonce.d.ts +18 -0
  459. package/dist/src/transactions/user-operations/nonce.d.ts.map +1 -0
  460. package/dist/src/transactions/user-operations/nonce.js +43 -0
  461. package/dist/src/transactions/user-operations/prepare.d.ts +12 -0
  462. package/dist/src/transactions/user-operations/prepare.d.ts.map +1 -0
  463. package/dist/src/transactions/user-operations/prepare.js +138 -0
  464. package/dist/src/transactions/user-operations/reconstruct.d.ts +28 -0
  465. package/dist/src/transactions/user-operations/reconstruct.d.ts.map +1 -0
  466. package/dist/src/transactions/user-operations/reconstruct.js +52 -0
  467. package/dist/src/transactions/user-operations/send.d.ts +3 -0
  468. package/dist/src/transactions/user-operations/send.d.ts.map +1 -0
  469. package/dist/src/transactions/user-operations/send.js +8 -0
  470. package/dist/src/transactions/user-operations/sign.d.ts +3 -0
  471. package/dist/src/transactions/user-operations/sign.d.ts.map +1 -0
  472. package/dist/src/transactions/user-operations/sign.js +14 -0
  473. package/dist/src/transactions/user-operations/status.d.ts +4 -0
  474. package/dist/src/transactions/user-operations/status.d.ts.map +1 -0
  475. package/dist/src/transactions/user-operations/status.js +37 -0
  476. package/dist/src/transactions/user-operations/submit.d.ts +3 -0
  477. package/dist/src/transactions/user-operations/submit.d.ts.map +1 -0
  478. package/dist/src/transactions/user-operations/submit.js +8 -0
  479. package/dist/src/transactions/user-operations/types.d.ts +68 -0
  480. package/dist/src/transactions/user-operations/types.d.ts.map +1 -0
  481. package/dist/src/transactions/user-operations/types.js +1 -0
  482. package/dist/src/transactions/user-operations/validator-account.d.ts +5 -0
  483. package/dist/src/transactions/user-operations/validator-account.d.ts.map +1 -0
  484. package/dist/src/transactions/user-operations/validator-account.js +26 -0
  485. package/dist/src/utils/index.d.ts +9 -4
  486. package/dist/src/utils/index.d.ts.map +1 -1
  487. package/dist/src/utils/index.js +54 -51
  488. package/package.json +3 -3
  489. package/dist/src/accounts/hca.d.ts +0 -25
  490. package/dist/src/accounts/hca.d.ts.map +0 -1
  491. package/dist/src/accounts/hca.js +0 -148
  492. package/dist/src/accounts/index.d.ts +0 -64
  493. package/dist/src/accounts/index.d.ts.map +0 -1
  494. package/dist/src/accounts/index.js +0 -680
  495. package/dist/src/accounts/json-rpc/index.d.ts +0 -5
  496. package/dist/src/accounts/json-rpc/index.d.ts.map +0 -1
  497. package/dist/src/accounts/json-rpc/index.js +0 -13
  498. package/dist/src/accounts/json-rpc/providers.d.ts +0 -3
  499. package/dist/src/accounts/json-rpc/providers.d.ts.map +0 -1
  500. package/dist/src/accounts/json-rpc/providers.js +0 -4
  501. package/dist/src/accounts/kernel.d.ts +0 -26
  502. package/dist/src/accounts/kernel.d.ts.map +0 -1
  503. package/dist/src/accounts/kernel.js +0 -265
  504. package/dist/src/accounts/nexus.d.ts +0 -34
  505. package/dist/src/accounts/nexus.d.ts.map +0 -1
  506. package/dist/src/accounts/nexus.js +0 -520
  507. package/dist/src/accounts/safe.d.ts +0 -32
  508. package/dist/src/accounts/safe.d.ts.map +0 -1
  509. package/dist/src/accounts/safe.js +0 -337
  510. package/dist/src/accounts/signing/common.d.ts +0 -38
  511. package/dist/src/accounts/signing/common.d.ts.map +0 -1
  512. package/dist/src/accounts/signing/common.js +0 -186
  513. package/dist/src/accounts/signing/message.d.ts +0 -7
  514. package/dist/src/accounts/signing/message.d.ts.map +0 -1
  515. package/dist/src/accounts/signing/message.js +0 -42
  516. package/dist/src/accounts/signing/passkeys.d.ts +0 -36
  517. package/dist/src/accounts/signing/passkeys.d.ts.map +0 -1
  518. package/dist/src/accounts/signing/passkeys.js +0 -119
  519. package/dist/src/accounts/signing/typedData.d.ts +0 -5
  520. package/dist/src/accounts/signing/typedData.d.ts.map +0 -1
  521. package/dist/src/accounts/signing/typedData.js +0 -30
  522. package/dist/src/accounts/startale.d.ts +0 -25
  523. package/dist/src/accounts/startale.d.ts.map +0 -1
  524. package/dist/src/accounts/startale.js +0 -188
  525. package/dist/src/accounts/utils.d.ts +0 -33
  526. package/dist/src/accounts/utils.d.ts.map +0 -1
  527. package/dist/src/accounts/utils.js +0 -202
  528. package/dist/src/auth/provider.d.ts +0 -7
  529. package/dist/src/auth/provider.d.ts.map +0 -1
  530. package/dist/src/auth/provider.js +0 -38
  531. package/dist/src/execution/compact.d.ts +0 -5
  532. package/dist/src/execution/compact.d.ts.map +0 -1
  533. package/dist/src/execution/compact.js +0 -4
  534. package/dist/src/execution/error.d.ts.map +0 -1
  535. package/dist/src/execution/index.d.ts +0 -42
  536. package/dist/src/execution/index.d.ts.map +0 -1
  537. package/dist/src/execution/index.js +0 -186
  538. package/dist/src/execution/utils.d.ts +0 -167
  539. package/dist/src/execution/utils.d.ts.map +0 -1
  540. package/dist/src/execution/utils.js +0 -1603
  541. package/dist/src/modules/abi/smart-sessions.d.ts +0 -104
  542. package/dist/src/modules/abi/smart-sessions.d.ts.map +0 -1
  543. package/dist/src/modules/abi/smart-sessions.js +0 -128
  544. package/dist/src/modules/chain-abstraction.d.ts +0 -5
  545. package/dist/src/modules/chain-abstraction.d.ts.map +0 -1
  546. package/dist/src/modules/chain-abstraction.js +0 -3
  547. package/dist/src/modules/common.d.ts +0 -30
  548. package/dist/src/modules/common.d.ts.map +0 -1
  549. package/dist/src/modules/common.js +0 -30
  550. package/dist/src/modules/index.d.ts +0 -11
  551. package/dist/src/modules/index.d.ts.map +0 -1
  552. package/dist/src/modules/index.js +0 -85
  553. package/dist/src/modules/legacy.d.ts +0 -10
  554. package/dist/src/modules/legacy.d.ts.map +0 -1
  555. package/dist/src/modules/legacy.js +0 -62
  556. package/dist/src/modules/read.d.ts +0 -11
  557. package/dist/src/modules/read.d.ts.map +0 -1
  558. package/dist/src/modules/read.js +0 -219
  559. package/dist/src/modules/validators/core.d.ts +0 -31
  560. package/dist/src/modules/validators/core.d.ts.map +0 -1
  561. package/dist/src/modules/validators/core.js +0 -269
  562. package/dist/src/modules/validators/cross-chain-permits.d.ts +0 -22
  563. package/dist/src/modules/validators/cross-chain-permits.d.ts.map +0 -1
  564. package/dist/src/modules/validators/cross-chain-permits.js +0 -107
  565. package/dist/src/modules/validators/index.d.ts +0 -4
  566. package/dist/src/modules/validators/index.d.ts.map +0 -1
  567. package/dist/src/modules/validators/index.js +0 -3
  568. package/dist/src/modules/validators/smart-sessions.d.ts +0 -226
  569. package/dist/src/modules/validators/smart-sessions.d.ts.map +0 -1
  570. package/dist/src/modules/validators/smart-sessions.js +0 -1197
  571. package/dist/src/orchestrator/caip2.d.ts +0 -18
  572. package/dist/src/orchestrator/caip2.d.ts.map +0 -1
  573. package/dist/src/orchestrator/caip2.js +0 -58
  574. package/dist/src/orchestrator/chain-catalog.d.ts.map +0 -1
  575. package/dist/src/orchestrator/client.d.ts +0 -43
  576. package/dist/src/orchestrator/client.d.ts.map +0 -1
  577. package/dist/src/orchestrator/client.js +0 -336
  578. package/dist/src/orchestrator/consts.d.ts +0 -6
  579. package/dist/src/orchestrator/consts.d.ts.map +0 -1
  580. package/dist/src/orchestrator/consts.js +0 -5
  581. package/dist/src/orchestrator/destinations.d.ts.map +0 -1
  582. package/dist/src/orchestrator/destinations.js +0 -59
  583. package/dist/src/orchestrator/error.d.ts.map +0 -1
  584. package/dist/src/orchestrator/index.d.ts +0 -12
  585. package/dist/src/orchestrator/index.d.ts.map +0 -1
  586. package/dist/src/orchestrator/index.js +0 -9
  587. package/dist/src/orchestrator/registry.d.ts +0 -7
  588. package/dist/src/orchestrator/registry.d.ts.map +0 -1
  589. package/dist/src/orchestrator/registry.js +0 -46
  590. package/dist/src/orchestrator/types.d.ts.map +0 -1
  591. package/dist/src/orchestrator/utils.d.ts +0 -3
  592. package/dist/src/orchestrator/utils.d.ts.map +0 -1
  593. package/dist/src/orchestrator/utils.js +0 -22
  594. package/dist/src/orchestrator/wire.d.ts +0 -31
  595. package/dist/src/orchestrator/wire.d.ts.map +0 -1
  596. package/dist/src/orchestrator/wire.gen.d.ts.map +0 -1
  597. package/dist/src/types.d.ts.map +0 -1
  598. package/dist/src/utils/walletClient.d.ts +0 -34
  599. package/dist/src/utils/walletClient.d.ts.map +0 -1
  600. package/dist/src/utils/walletClient.js +0 -117
  601. /package/dist/src/{orchestrator/wire.gen.js → accounts/adapter.js} +0 -0
  602. /package/dist/src/{types.js → accounts/types.js} +0 -0
  603. /package/dist/src/{orchestrator/wire.js → api/compose-types.js} +0 -0
@@ -1,1603 +0,0 @@
1
- import { concat, createPublicClient, createWalletClient, encodeAbiParameters, encodePacked, hashDomain, hashMessage, hashStruct, hashTypedData, isAddress, keccak256, pad, 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, getInitCode, getOwnerEcdsaSignature, getOwnerPasskeySignature, getSmartAccount, getTypedDataPackedSignature, is7702, packAccountSignature, toErc6492Signature, } from '../accounts/index.js';
5
- import { convertOwnerSetToSignerSet, packMultiFactorOwnerSignatures, packPasskeyOwnerSignatures, } 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, getValidator as getValidatorModule, getWebAuthnValidator, supportsEip712, } from '../modules/validators/core.js';
11
- import { buildPermit2ClaimPolicyCalldata, } from '../modules/validators/policies/claim/permit2.js';
12
- import { resolvePermit2ClaimPolicy, selectPermit2ClaimPolicyForMessage, } from '../modules/validators/smart-sessions.js';
13
- import { getOrchestrator, } from '../orchestrator/index.js';
14
- import { isNonEvmChainId, toCaip2 } from '../orchestrator/caip2.js';
15
- import { getChainId, isNonEvmChain, } from '../orchestrator/destinations.js';
16
- import { getChainById, resolveTokenAddress } from '../orchestrator/registry.js';
17
- import { SIG_MODE_EMISSARY_EXECUTION_ERC1271, SIG_MODE_ERC1271, } from '../orchestrator/types.js';
18
- import { convertBigIntFields } from '../orchestrator/utils.js';
19
- import { Eip7702InitSignatureRequiredError, IndependentSigningNotSupportedError, InsufficientOwnerSignaturesError, InvalidOwnerSigningOptionsError, InvalidSourceCallsError, MismatchedOwnerSignaturesError, QuoteNotInPreparedTransactionError, UnknownOwnerError, } from './error.js';
20
- function isResolvedSessionSignerSet(signers) {
21
- return (signers?.type === 'experimental_session' && 'verifyExecutions' in signers);
22
- }
23
- async function resolveSignersForChain(config, signers, chainId) {
24
- if (signers?.type !== 'experimental_session') {
25
- return signers;
26
- }
27
- const resolved = resolveSessionForChain(signers, chainId);
28
- const enabled = await isSessionEnabled(getAddress(config), config.provider, resolved.session, config.useDevContracts);
29
- const enableData = enabled ? undefined : resolved.enableData;
30
- return {
31
- type: 'experimental_session',
32
- session: resolved.session,
33
- enableData,
34
- // First use of any session must go through the emissary's verifyExecution
35
- // path: that's the only mechanism that consumes enableData + calls setConfig
36
- // to install the session on-chain. Once installed, steady-state signing can
37
- // drop to mode 1 unless the session has explicit permissions to enforce.
38
- verifyExecutions: !enabled || resolved.session.hasExplicitPermissions,
39
- };
40
- }
41
- // Picks the single signature mode that matches the bytes shape the SDK will
42
- // actually sign, so the on-chain dispatcher hits the right validator on the
43
- // first try instead of falling through a hybrid.
44
- async function resolveSignatureMode(config, signers, sourceChains, targetChainId,
45
- // Optional pre-resolved per-chain signer sets. When supplied, reuse them
46
- // instead of resolving again — each resolveSignersForChain does an
47
- // isSessionEnabled RPC, so sharing one map across mockSignatures, sigMode, and
48
- // preClaim avoids duplicate calls per intent. The map also defines *which*
49
- // chains carry a session: the caller omits a non-EVM target (it has no session
50
- // validator), so deriving the chain set from the map's keys keeps us from
51
- // resolving — and throwing on — a target with no configured session.
52
- preResolved) {
53
- if (config.account?.type === 'eoa') {
54
- return SIG_MODE_ERC1271;
55
- }
56
- if (signers?.type !== 'experimental_session') {
57
- return SIG_MODE_ERC1271;
58
- }
59
- const chainIds = preResolved
60
- ? [...preResolved.keys()]
61
- : [...new Set([...(sourceChains ?? []).map((c) => c.id), targetChainId])];
62
- const resolvedSet = await Promise.all(chainIds.map((chainId) =>
63
- // Use has() not `?? resolve` so a cached `undefined` entry is still reused
64
- // (get() can't distinguish "missing key" from "present but undefined").
65
- preResolved?.has(chainId)
66
- ? preResolved.get(chainId)
67
- : resolveSignersForChain(config, signers, chainId)));
68
- let anyVerifyExecutions = false;
69
- for (const resolved of resolvedSet) {
70
- if (!isResolvedSessionSignerSet(resolved)) {
71
- return SIG_MODE_ERC1271;
72
- }
73
- // Conservative: one chain with verifyExecutions=true forces mode 5 across
74
- // all origin signatures — a single mode field can't describe divergence.
75
- if (resolved.verifyExecutions)
76
- anyVerifyExecutions = true;
77
- }
78
- // Mode 4 (pure emissary-execution) is unused: signIntentTypedData always
79
- // emits a dual sig for the intent's origin/destination signatures when
80
- // verifyExecutions=true, so mode 5 is the right hybrid.
81
- return anyVerifyExecutions
82
- ? SIG_MODE_EMISSARY_EXECUTION_ERC1271
83
- : SIG_MODE_ERC1271;
84
- }
85
- function resolveSessionForChain(signers, chainId) {
86
- if ('sessions' in signers) {
87
- const config = signers.sessions[chainId];
88
- if (!config) {
89
- throw new Error(`No session configured for chain ${chainId}`);
90
- }
91
- return config;
92
- }
93
- return { session: signers.session, enableData: signers.enableData };
94
- }
95
- async function prepareTransaction(config, transaction) {
96
- const { sourceChains, targetChain, tokenRequests, signers, sponsored, eip7702InitSignature, settlementLayers, sourceAssets, auxiliaryFunds, appFees, customDeadline, account, recipient, sourceCalls, } = getTransactionParams(transaction);
97
- const accountAddress = getAddress(config);
98
- // Destination calls (transaction.calls on a cross-chain transaction) are
99
- // executed on the destination chain by the solver/account. For non-EVM
100
- // destinations we can't resolve arbitrary EVM calls; assert there are
101
- // none and route an empty list through.
102
- let resolvedCalls;
103
- if (isNonEvmChain(targetChain)) {
104
- if (transaction.calls && transaction.calls.length > 0) {
105
- throw new Error(`Destination calls are not supported for non-EVM target chain ${targetChain.name} (${targetChain.caip2})`);
106
- }
107
- resolvedCalls = [];
108
- }
109
- else {
110
- resolvedCalls = await resolveCallInputs(transaction.calls, config, targetChain, accountAddress);
111
- }
112
- const prepared = await prepareTransactionAsIntent(config, sourceChains, targetChain, resolvedCalls, transaction.gasLimit, tokenRequests, recipient, sponsored, eip7702InitSignature, settlementLayers, sourceAssets, auxiliaryFunds, account, signers, sourceCalls, appFees, customDeadline);
113
- return {
114
- quotes: prepared.quotes,
115
- intentInput: prepared.intentInput,
116
- transaction,
117
- };
118
- }
119
- async function prepareUserOperation(config, transaction) {
120
- const chain = transaction.chain;
121
- const signers = transaction.signers;
122
- const accountAddress = getAddress(config);
123
- const data = await prepareTransactionAsUserOp(config, chain, await resolveCallInputs(transaction.calls, config, chain, accountAddress), signers, transaction.gasLimit);
124
- return {
125
- userOperation: data.userOp,
126
- hash: data.hash,
127
- transaction,
128
- };
129
- }
130
- async function resolveCallInputs(inputs, config, chain, accountAddress) {
131
- const resolved = [];
132
- if (!inputs) {
133
- return resolved;
134
- }
135
- for (const intent of inputs) {
136
- if ('resolve' in intent) {
137
- const result = await intent.resolve({ config, chain, accountAddress });
138
- if (Array.isArray(result)) {
139
- resolved.push(...result);
140
- }
141
- else if (result) {
142
- resolved.push(result);
143
- }
144
- }
145
- else {
146
- resolved.push(intent);
147
- }
148
- }
149
- return resolved;
150
- }
151
- function getTransactionMessages(_config, preparedTransaction, options) {
152
- const quote = resolveQuote(preparedTransaction.quotes, options);
153
- return getIntentMessages(quote.signData);
154
- }
155
- async function signTransaction(config, preparedTransaction, options) {
156
- if (options && 'owner' in options) {
157
- return signTransactionAsOwner(config, preparedTransaction, options);
158
- }
159
- const { signers } = getTransactionParams(preparedTransaction.transaction);
160
- const quote = resolveQuote(preparedTransaction.quotes, options);
161
- const targetChain = 'targetChain' in preparedTransaction.transaction
162
- ? preparedTransaction.transaction.targetChain
163
- : preparedTransaction.transaction.chain;
164
- const { originSignatures, destinationSignature } = await signIntent(config, quote.signData, targetChain, signers, false);
165
- const targetExecutionSignature = await getTargetExecutionSignature(config, quote.signData, targetChain, signers);
166
- return {
167
- quote,
168
- quotes: preparedTransaction.quotes,
169
- intentInput: preparedTransaction.intentInput,
170
- transaction: preparedTransaction.transaction,
171
- originSignatures,
172
- destinationSignature,
173
- targetExecutionSignature,
174
- };
175
- }
176
- function assertIndependentSigningSupported(config, preparedTransaction) {
177
- if (config.account?.type === 'eoa') {
178
- throw new IndependentSigningNotSupportedError({
179
- context: { reason: 'eoa-account' },
180
- });
181
- }
182
- const { signers } = getTransactionParams(preparedTransaction.transaction);
183
- if (signers?.type === 'experimental_session') {
184
- throw new IndependentSigningNotSupportedError({
185
- context: { reason: 'smart-session' },
186
- });
187
- }
188
- const validator = getOwnerValidator(config);
189
- const selectedValidator = getValidator(config, signers);
190
- if (!selectedValidator ||
191
- selectedValidator.address.toLowerCase() !== validator.address.toLowerCase()) {
192
- throw new IndependentSigningNotSupportedError({
193
- context: { reason: 'non-owner-validator' },
194
- });
195
- }
196
- if (validator.address.toLowerCase() ===
197
- K1_DEFAULT_VALIDATOR_ADDRESS.toLowerCase()) {
198
- throw new IndependentSigningNotSupportedError({
199
- context: { reason: 'erc7739-validator' },
200
- });
201
- }
202
- if (!config.owners) {
203
- throw new IndependentSigningNotSupportedError({
204
- context: { reason: 'missing-owner-set' },
205
- });
206
- }
207
- return { owners: config.owners, signers, validator };
208
- }
209
- function getValidatorIdKey(id) {
210
- if (typeof id === 'number' && (!Number.isSafeInteger(id) || id < 0)) {
211
- return undefined;
212
- }
213
- try {
214
- return pad(toHex(id), { size: 12 }).toLowerCase();
215
- }
216
- catch {
217
- return undefined;
218
- }
219
- }
220
- function getMultiFactorOwnerFactors(owners, signers) {
221
- if (signers?.type === 'owner' && signers.kind === 'multi-factor') {
222
- return signers.validators.map((factor) => {
223
- switch (factor.type) {
224
- case 'ecdsa':
225
- return {
226
- id: factor.id,
227
- owners: {
228
- type: 'ecdsa',
229
- accounts: factor.accounts,
230
- threshold: factor.accounts.length,
231
- },
232
- };
233
- case 'passkey':
234
- return {
235
- id: factor.id,
236
- owners: {
237
- type: 'passkey',
238
- accounts: factor.accounts,
239
- threshold: factor.accounts.length,
240
- },
241
- };
242
- }
243
- });
244
- }
245
- return owners.validators.map((factor, id) => ({ id, owners: factor }));
246
- }
247
- function resolveAtomicOwnerSet(owners, validatorId, signers) {
248
- if (owners.type !== 'multi-factor') {
249
- return validatorId === undefined ? { id: 0, owners } : undefined;
250
- }
251
- if (validatorId === undefined)
252
- return undefined;
253
- const key = getValidatorIdKey(validatorId);
254
- if (!key)
255
- return undefined;
256
- return getMultiFactorOwnerFactors(owners, signers).find((factor) => getValidatorIdKey(factor.id) === key);
257
- }
258
- function getAtomicOwnerAccounts(owners) {
259
- switch (owners.type) {
260
- case 'ecdsa':
261
- case 'passkey':
262
- return owners.accounts;
263
- case 'ens':
264
- return owners.owners.map(({ account }) => account);
265
- }
266
- }
267
- function getAtomicOwnerThreshold(owners) {
268
- return owners.threshold ?? 1;
269
- }
270
- function isWebAuthnAccount(account) {
271
- return account.type === 'webAuthn';
272
- }
273
- function getAccountIdentity(account) {
274
- return isWebAuthnAccount(account)
275
- ? account.publicKey.toLowerCase()
276
- : account.address.toLowerCase();
277
- }
278
- function getAtomicSignatureIdentity(signature) {
279
- return signature.kind === 'passkey'
280
- ? signature.publicKey.toLowerCase()
281
- : signature.signer.toLowerCase();
282
- }
283
- function isOwnerMember(owners, account) {
284
- if ((owners.type === 'passkey') !== isWebAuthnAccount(account))
285
- return false;
286
- const identity = getAccountIdentity(account);
287
- return getAtomicOwnerAccounts(owners).some((configured) => getAccountIdentity(configured) === identity);
288
- }
289
- async function signTransactionAsOwner(config, preparedTransaction, options) {
290
- const { owners, signers } = assertIndependentSigningSupported(config, preparedTransaction);
291
- const factor = resolveAtomicOwnerSet(owners, options.validatorId, signers);
292
- if (!factor) {
293
- throw new InvalidOwnerSigningOptionsError({
294
- context: { validatorId: options.validatorId },
295
- });
296
- }
297
- const atomicOwners = factor.owners;
298
- if (!isOwnerMember(atomicOwners, options.owner)) {
299
- throw new UnknownOwnerError({
300
- context: {
301
- ...(isWebAuthnAccount(options.owner)
302
- ? { publicKey: options.owner.publicKey }
303
- : { signer: options.owner.address }),
304
- validatorId: options.validatorId,
305
- },
306
- });
307
- }
308
- const quote = resolveQuote(preparedTransaction.quotes, options.intentId === undefined ? undefined : { intentId: options.intentId });
309
- const { origin } = getIntentMessages(quote.signData);
310
- const atomicSigners = convertOwnerSetToSignerSet(atomicOwners);
311
- if (atomicSigners.type !== 'owner' || atomicSigners.kind === 'multi-factor') {
312
- throw new IndependentSigningNotSupportedError();
313
- }
314
- const validatorSupportsEip712 = supportsEip712(getValidatorModule(atomicOwners));
315
- let signature;
316
- if (atomicSigners.kind === 'ecdsa' && !isWebAuthnAccount(options.owner)) {
317
- const signatures = [];
318
- for (const typedData of origin) {
319
- signatures.push(await getOwnerEcdsaSignature(config, getChainById(typedData.domain?.chainId), typedData, options.owner, atomicSigners.module, validatorSupportsEip712));
320
- }
321
- signature = {
322
- kind: 'ecdsa',
323
- signer: options.owner.address,
324
- origin: signatures,
325
- };
326
- }
327
- else if (atomicSigners.kind === 'passkey' &&
328
- isWebAuthnAccount(options.owner)) {
329
- const signatures = [];
330
- for (const typedData of origin) {
331
- signatures.push(await getOwnerPasskeySignature(config, typedData, options.owner, validatorSupportsEip712));
332
- }
333
- signature = {
334
- kind: 'passkey',
335
- publicKey: options.owner.publicKey,
336
- origin: signatures,
337
- };
338
- }
339
- else {
340
- throw new UnknownOwnerError({
341
- context: { validatorId: options.validatorId },
342
- });
343
- }
344
- return owners.type === 'multi-factor'
345
- ? {
346
- intentId: quote.intentId,
347
- kind: 'multi-factor',
348
- validatorId: factor.id,
349
- signature,
350
- }
351
- : { intentId: quote.intentId, ...signature };
352
- }
353
- function orderAtomicOwnerSignatures(owners, signatures, originCount, validatorId) {
354
- const expectedKind = owners.type === 'passkey' ? 'passkey' : 'ecdsa';
355
- const byIdentity = new Map();
356
- const configuredIdentities = new Set(getAtomicOwnerAccounts(owners).map(getAccountIdentity));
357
- for (const signature of signatures) {
358
- if (signature.kind !== expectedKind ||
359
- signature.origin.length !== originCount) {
360
- throw new MismatchedOwnerSignaturesError({
361
- context: {
362
- expectedKind,
363
- expectedOriginCount: originCount,
364
- validatorId,
365
- },
366
- });
367
- }
368
- const identity = getAtomicSignatureIdentity(signature);
369
- if (!configuredIdentities.has(identity)) {
370
- throw new UnknownOwnerError({
371
- context: {
372
- ...(signature.kind === 'passkey'
373
- ? { publicKey: signature.publicKey }
374
- : { signer: signature.signer }),
375
- validatorId,
376
- },
377
- });
378
- }
379
- if (!byIdentity.has(identity))
380
- byIdentity.set(identity, signature);
381
- }
382
- const ordered = [...configuredIdentities].flatMap((identity) => {
383
- const signature = byIdentity.get(identity);
384
- return signature ? [signature] : [];
385
- });
386
- const required = getAtomicOwnerThreshold(owners);
387
- if (ordered.length < required) {
388
- throw new InsufficientOwnerSignaturesError({
389
- required,
390
- provided: ordered.length,
391
- validatorId,
392
- });
393
- }
394
- return ordered;
395
- }
396
- function packAtomicOwnerSignatures(owners, signatures, originIndex, chain, accountAddress) {
397
- const signers = convertOwnerSetToSignerSet(owners);
398
- if (owners.type === 'passkey' &&
399
- signers.type === 'owner' &&
400
- signers.kind === 'passkey') {
401
- const passkeySignatures = signatures.map((signature) => {
402
- if (signature.kind !== 'passkey') {
403
- throw new MismatchedOwnerSignaturesError();
404
- }
405
- return {
406
- publicKey: signature.publicKey,
407
- signature: signature.origin[originIndex],
408
- };
409
- });
410
- return packPasskeyOwnerSignatures(chain, accountAddress, passkeySignatures.map(({ publicKey }) => publicKey), passkeySignatures.map(({ signature }) => signature), signers.module);
411
- }
412
- return concat(signatures.map((signature) => {
413
- if (signature.kind !== 'ecdsa') {
414
- throw new MismatchedOwnerSignaturesError();
415
- }
416
- return signature.origin[originIndex];
417
- }));
418
- }
419
- async function assembleTransaction(config, preparedTransaction, signatures) {
420
- const { owners, signers, validator } = assertIndependentSigningSupported(config, preparedTransaction);
421
- if (signatures.length === 0) {
422
- throw new InsufficientOwnerSignaturesError({
423
- required: owners.threshold ?? 1,
424
- provided: 0,
425
- });
426
- }
427
- const intentIds = [...new Set(signatures.map(({ intentId }) => intentId))];
428
- if (intentIds.length !== 1) {
429
- throw new MismatchedOwnerSignaturesError({ context: { intentIds } });
430
- }
431
- const quote = resolveQuote(preparedTransaction.quotes, {
432
- intentId: intentIds[0],
433
- });
434
- const { origin } = getIntentMessages(quote.signData);
435
- const accountAddress = getAddress(config);
436
- const validatorConfig = {
437
- address: validator.address,
438
- isRoot: true,
439
- };
440
- let directSignatures;
441
- let factorSignatures;
442
- if (owners.type === 'multi-factor') {
443
- const factors = getMultiFactorOwnerFactors(owners, signers);
444
- const factorsById = new Map(factors.flatMap((factor) => {
445
- const key = getValidatorIdKey(factor.id);
446
- return key ? [[key, factor]] : [];
447
- }));
448
- const grouped = new Map();
449
- for (const signature of signatures) {
450
- if (signature.kind !== 'multi-factor') {
451
- throw new MismatchedOwnerSignaturesError({
452
- context: { expectedKind: 'multi-factor' },
453
- });
454
- }
455
- const key = getValidatorIdKey(signature.validatorId);
456
- if (!key || !factorsById.has(key)) {
457
- throw new MismatchedOwnerSignaturesError({
458
- context: { validatorId: signature.validatorId },
459
- });
460
- }
461
- const current = grouped.get(key) ?? [];
462
- current.push(signature.signature);
463
- grouped.set(key, current);
464
- }
465
- factorSignatures = factors.flatMap((factor) => {
466
- const key = getValidatorIdKey(factor.id);
467
- const groupedSignatures = key ? grouped.get(key) : undefined;
468
- if (!groupedSignatures)
469
- return [];
470
- return [
471
- {
472
- id: factor.id,
473
- owners: factor.owners,
474
- signatures: orderAtomicOwnerSignatures(factor.owners, groupedSignatures, origin.length, factor.id),
475
- },
476
- ];
477
- });
478
- const required = owners.threshold ?? 1;
479
- if (factorSignatures.length < required) {
480
- throw new InsufficientOwnerSignaturesError({
481
- required,
482
- provided: factorSignatures.length,
483
- });
484
- }
485
- }
486
- else {
487
- directSignatures = orderAtomicOwnerSignatures(owners, signatures.map((signature) => {
488
- if (signature.kind === 'multi-factor') {
489
- throw new MismatchedOwnerSignaturesError({
490
- context: { expectedKind: owners.type },
491
- });
492
- }
493
- const { intentId: _, ...atomicSignature } = signature;
494
- return atomicSignature;
495
- }), origin.length);
496
- }
497
- const originSignatures = [];
498
- for (const [originIndex, typedData] of origin.entries()) {
499
- const chain = getChainById(typedData.domain?.chainId);
500
- const validatorSignature = factorSignatures
501
- ? packMultiFactorOwnerSignatures(factorSignatures.map((factor) => ({
502
- id: factor.id,
503
- validatorAddress: getValidatorModule(factor.owners).address,
504
- signature: packAtomicOwnerSignatures(factor.owners, factor.signatures, originIndex, chain, accountAddress),
505
- })))
506
- : packAtomicOwnerSignatures(owners, directSignatures, originIndex, chain, accountAddress);
507
- originSignatures.push(await packAccountSignature(config, validatorSignature, validatorConfig));
508
- }
509
- return {
510
- quote,
511
- quotes: preparedTransaction.quotes,
512
- intentInput: preparedTransaction.intentInput,
513
- transaction: preparedTransaction.transaction,
514
- originSignatures,
515
- destinationSignature: originSignatures.at(-1) ?? '0x',
516
- targetExecutionSignature: undefined,
517
- };
518
- }
519
- function resolveQuote(quotes, options) {
520
- if (!options)
521
- return quotes.best;
522
- const match = quotes.all.find((q) => q.intentId === options.intentId);
523
- if (!match) {
524
- throw new QuoteNotInPreparedTransactionError({
525
- context: { intentId: options.intentId },
526
- });
527
- }
528
- return match;
529
- }
530
- async function getTargetExecutionSignature(config, signData, targetChain, signers) {
531
- if (signers?.type !== 'experimental_session') {
532
- return undefined;
533
- }
534
- if (!signData.targetExecution) {
535
- return undefined;
536
- }
537
- // Target executions are EVM-only (smart-session validator on destination).
538
- // Non-EVM destinations don't have a validator there to verify the sig.
539
- if (isNonEvmChain(targetChain)) {
540
- return undefined;
541
- }
542
- const resolvedSigners = await resolveSignersForChain(config, signers, targetChain.id);
543
- if (!isResolvedSessionSignerSet(resolvedSigners) ||
544
- !resolvedSigners.verifyExecutions) {
545
- return undefined;
546
- }
547
- const validator = getValidator(config, signers);
548
- if (!validator) {
549
- throw new Error('Validator not available');
550
- }
551
- const ownerValidator = getOwnerValidator(config);
552
- const isRoot = validator.address === ownerValidator.address;
553
- const destination = prepareTypedData(signData.targetExecution);
554
- const signature = await getDestinationSignature(config, resolvedSigners, validator, isRoot, targetChain, destination, [], true);
555
- return signature;
556
- }
557
- async function signUserOperation(config, preparedUserOperation) {
558
- const chain = preparedUserOperation.transaction.chain;
559
- const userOp = preparedUserOperation.userOperation;
560
- const signers = preparedUserOperation.transaction.signers;
561
- // Smart sessions require a UserOp flow
562
- const signature = await signUserOp(config, chain, signers, userOp);
563
- return {
564
- userOperation: preparedUserOperation.userOperation,
565
- hash: preparedUserOperation.hash,
566
- transaction: preparedUserOperation.transaction,
567
- signature,
568
- };
569
- }
570
- async function signAuthorizations(config, preparedTransaction) {
571
- const transaction = preparedTransaction.transaction;
572
- const sourceChains = 'chain' in transaction ? [transaction.chain] : transaction.sourceChains;
573
- const targetChain = 'chain' in transaction ? transaction.chain : transaction.targetChain;
574
- return await signAuthorizationsInternal(config, {
575
- sourceChains,
576
- targetChain,
577
- eip7702InitSignature: transaction.eip7702InitSignature,
578
- });
579
- }
580
- async function signMessage(config, message, chain, signers) {
581
- const validator = getValidator(config, signers);
582
- if (!validator) {
583
- throw new Error('Validator not available');
584
- }
585
- const ownerValidator = getOwnerValidator(config);
586
- const isRoot = validator.address === ownerValidator.address;
587
- const hash = hashMessage(message);
588
- const signature = await getEip1271Signature(config, signers, chain, {
589
- address: validator.address,
590
- isRoot,
591
- }, hash);
592
- return await toErc6492Signature(config, signature, chain);
593
- }
594
- async function signTypedData(config, parameters, chain, signers, options) {
595
- const validator = getValidator(config, signers);
596
- if (!validator) {
597
- throw new Error('Validator not available');
598
- }
599
- const ownerValidator = getOwnerValidator(config);
600
- const isRoot = validator.address === ownerValidator.address;
601
- if (signers?.type === 'experimental_session') {
602
- const resolved = resolveSessionForChain(signers, chain.id);
603
- return await signTypedDataWithSession(config, chain, {
604
- address: validator.address,
605
- isRoot,
606
- }, resolved.session, parameters);
607
- }
608
- const account = getAccountProvider(config);
609
- if (account.type === 'startale' && supportsEip712(validator)) {
610
- const isK1 = validator.address.toLowerCase() ===
611
- K1_DEFAULT_VALIDATOR_ADDRESS.toLowerCase();
612
- if (isK1) {
613
- const sig = await signErc7739TypedData(config, signers, validator, isRoot, parameters, chain);
614
- if (!options?.skipErc6492) {
615
- return await toErc6492Signature(config, sig, chain);
616
- }
617
- return sig;
618
- }
619
- }
620
- const signature = await getTypedDataPackedSignature(config, signers, chain, {
621
- address: validator.address,
622
- isRoot,
623
- }, parameters);
624
- if (!options?.skipErc6492) {
625
- return await toErc6492Signature(config, signature, chain);
626
- }
627
- return signature;
628
- }
629
- async function signTypedDataWithSession(config, chain, validator, session, parameters) {
630
- const { name, version, chainId, verifyingContract, salt } = getEip712Domain(config, chain);
631
- const signers = convertOwnerSetToSignerSet(session.owners);
632
- const signature = await getTypedDataPackedSignature(config, signers, chain, validator, {
633
- domain: parameters.domain,
634
- primaryType: 'TypedDataSign',
635
- types: {
636
- ...parameters.types,
637
- TypedDataSign: [
638
- { name: 'contents', type: parameters.primaryType },
639
- { name: 'name', type: 'string' },
640
- { name: 'version', type: 'string' },
641
- { name: 'chainId', type: 'uint256' },
642
- { name: 'verifyingContract', type: 'address' },
643
- { name: 'salt', type: 'bytes32' },
644
- ],
645
- },
646
- message: {
647
- contents: parameters.message,
648
- name,
649
- version,
650
- chainId,
651
- verifyingContract,
652
- salt,
653
- },
654
- }, (signature) => {
655
- const erc7739Signature = wrapTypedDataSignature({
656
- domain: parameters.domain,
657
- primaryType: parameters.primaryType,
658
- types: parameters.types,
659
- message: parameters.message,
660
- signature,
661
- });
662
- return encodePacked(['bytes32', 'bytes'], [getPermissionId(session), erc7739Signature]);
663
- });
664
- return await toErc6492Signature(config, signature, chain);
665
- }
666
- async function signAuthorizationsInternal(config, context) {
667
- const eoa = config.eoa;
668
- if (!eoa) {
669
- throw new Error('EIP-7702 initialization is required for EOA accounts');
670
- }
671
- const eip7702InitSignature = context.eip7702InitSignature;
672
- if (!eip7702InitSignature) {
673
- return [];
674
- }
675
- const accountAddress = getAddress(config);
676
- const { contract: eip7702Contract } = getEip7702InitCall(config, eip7702InitSignature);
677
- // EIP-7702 authorization is EVM-only — there's no contract to delegate
678
- // to on Solana / Tron. Skip the destination chain entirely when it's
679
- // non-EVM; source chains are always EVM by construction.
680
- const chains = new Map();
681
- for (const chain of context.sourceChains ?? []) {
682
- chains.set(chain.id, chain);
683
- }
684
- if (!isNonEvmChain(context.targetChain)) {
685
- chains.set(context.targetChain.id, context.targetChain);
686
- }
687
- const authorizations = [];
688
- for (const chain of chains.values()) {
689
- const walletClient = createWalletClient({
690
- chain,
691
- account: eoa,
692
- transport: createTransport(chain, config.provider),
693
- }).extend(publicActions);
694
- const code = await walletClient.getCode({
695
- address: accountAddress,
696
- });
697
- const isDelegated = code === concat(['0xef0100', eip7702Contract.toLowerCase()]);
698
- if (isDelegated) {
699
- continue;
700
- }
701
- const authorization = await walletClient.signAuthorization({
702
- contractAddress: eip7702Contract,
703
- chainId: chain.id,
704
- });
705
- authorizations.push(authorization);
706
- }
707
- return authorizations;
708
- }
709
- async function submitTransaction(config, signedTransaction, authorizations, dryRun = false) {
710
- const { quote, intentInput, transaction, originSignatures, destinationSignature, targetExecutionSignature, } = signedTransaction;
711
- const { sourceChains, targetChain } = getTransactionParams(transaction);
712
- return await submitIntentInternal(config, sourceChains, targetChain, quote, originSignatures, destinationSignature, targetExecutionSignature, authorizations, dryRun, intentInput);
713
- }
714
- async function submitUserOperation(config, signedUserOperation) {
715
- const chain = signedUserOperation.transaction.chain;
716
- const userOp = signedUserOperation.userOperation;
717
- const signature = signedUserOperation.signature;
718
- // Smart sessions require a UserOp flow
719
- return await submitUserOp(config, chain, userOp, signature);
720
- }
721
- function getTransactionParams(transaction) {
722
- const sourceChains = 'chain' in transaction ? [transaction.chain] : transaction.sourceChains;
723
- const targetChain = 'chain' in transaction ? transaction.chain : transaction.targetChain;
724
- const initialTokenRequests = transaction.tokenRequests;
725
- const signers = transaction.signers;
726
- const eip7702InitSignature = transaction.eip7702InitSignature;
727
- const sponsored = transaction.sponsored;
728
- const gasLimit = transaction.gasLimit;
729
- const settlementLayers = transaction.settlementLayers;
730
- const sourceAssets = transaction.sourceAssets;
731
- const auxiliaryFunds = transaction.auxiliaryFunds;
732
- const appFees = transaction.appFees;
733
- // customDeadline lives only on same-chain transactions (see types.ts) — it's
734
- // meaningless cross-chain, so narrow before reading it.
735
- const customDeadline = 'chain' in transaction ? transaction.customDeadline : undefined;
736
- const account = transaction.experimental_accountOverride;
737
- const recipient = transaction.recipient;
738
- const sourceCalls = transaction.sourceCalls;
739
- const tokenRequests = getTokenRequests(targetChain, initialTokenRequests);
740
- return {
741
- sourceChains,
742
- targetChain,
743
- tokenRequests,
744
- signers,
745
- sponsored,
746
- eip7702InitSignature,
747
- gasLimit,
748
- settlementLayers,
749
- sourceAssets,
750
- auxiliaryFunds,
751
- appFees,
752
- customDeadline,
753
- account,
754
- recipient,
755
- sourceCalls,
756
- };
757
- }
758
- function getTokenRequests(targetChain, initialTokenRequests) {
759
- // Non-EVM destinations carry SPL mint / Tron T-prefixed addresses that
760
- // aren't valid 0x-hex; skip symbol/EVM-address validation here and let
761
- // the orchestrator validate per its own schema. EVM destinations keep
762
- // the existing strict check so a typo on Optimism still fails fast.
763
- if (initialTokenRequests && !isNonEvmChain(targetChain)) {
764
- // Inside this branch targetChain is a viem `Chain`, which excludes the
765
- // non-EVM transaction variant — token requests are EVM-typed here.
766
- const evmRequests = initialTokenRequests;
767
- validateTokenAddresses(evmRequests.map((tokenRequest) => tokenRequest.address));
768
- }
769
- return initialTokenRequests ?? [];
770
- }
771
- async function prepareTransactionAsUserOp(config, chain, callInputs, signers, gasLimit) {
772
- const publicClient = createPublicClient({
773
- chain,
774
- transport: createTransport(chain, config.provider),
775
- });
776
- const validatorAccount = await getValidatorAccount(config, signers, publicClient, chain);
777
- if (!validatorAccount) {
778
- throw new Error('No validator account found');
779
- }
780
- const bundlerClient = getBundlerClient(config, publicClient);
781
- const calls = parseCalls(callInputs, chain.id);
782
- const userOp = await bundlerClient.prepareUserOperation({
783
- account: validatorAccount,
784
- calls,
785
- callGasLimit: gasLimit,
786
- });
787
- return {
788
- userOp,
789
- hash: getUserOperationHash({
790
- userOperation: userOp,
791
- chainId: chain.id,
792
- entryPointAddress: entryPoint07Address,
793
- entryPointVersion: '0.7',
794
- }),
795
- };
796
- }
797
- function getAccountType(accountConfig) {
798
- if (accountConfig?.type === 'eoa') {
799
- return 'EOA';
800
- }
801
- else {
802
- return 'ERC7579';
803
- }
804
- }
805
- function getIntentAccount(config, eip7702InitSignature, account) {
806
- const accountAddress = getAddress(config);
807
- const accountType = getAccountType(config.account);
808
- const { setupOps, delegations } = getSetupOperationsAndDelegations(config, accountAddress, eip7702InitSignature);
809
- return {
810
- address: accountAddress,
811
- accountType: accountType,
812
- setupOps: account?.setupOps ?? setupOps,
813
- delegations,
814
- };
815
- }
816
- function cloneAuxiliaryFunds(auxiliaryFunds) {
817
- if (!auxiliaryFunds)
818
- return undefined;
819
- return Object.fromEntries(Object.entries(auxiliaryFunds).map(([chainId, funds]) => [
820
- Number(chainId),
821
- { ...funds },
822
- ]));
823
- }
824
- function toCallInput(sourceCall) {
825
- const { provides: _provides, ...call } = sourceCall;
826
- return call;
827
- }
828
- function addProvidedFunds(auxiliaryFunds, chainId, calls) {
829
- let next = auxiliaryFunds;
830
- for (const call of calls) {
831
- for (const provided of call.provides ?? []) {
832
- next ??= {};
833
- next[chainId] ??= {};
834
- const token = provided.token;
835
- next[chainId][token] = (next[chainId][token] ?? 0n) + provided.amount;
836
- }
837
- }
838
- return next;
839
- }
840
- async function prepareTransactionAsIntent(config, sourceChains, targetChain, callInputs, gasLimit, tokenRequests, recipientInput, sponsored, eip7702InitSignature, settlementLayers, sourceAssets, auxiliaryFunds, account, signers, sourceCalls, appFees, customDeadline) {
841
- const targetChainId = getChainId(targetChain);
842
- const calls = parseCalls(callInputs, targetChainId);
843
- const accountAccessList = createAccountAccessList(sourceChains, sourceAssets);
844
- function getRecipient(recipient) {
845
- if (typeof recipient === 'string') {
846
- // Non-EVM-addressed recipients (Solana base58 / Tron T-prefix) carry no
847
- // EVM smart-account semantics; the orchestrator schema requires
848
- // accountType / setupOps to be unset. Emit just the address. HyperCore
849
- // is EVM-addressed (eip155:1337) so it falls through to the EOA
850
- // passthrough below — the orchestrator's HyperCore gate requires
851
- // accountType: 'EOA'.
852
- if (isNonEvmChainId(targetChainId)) {
853
- return { address: recipient };
854
- }
855
- // EVM (and HyperCore) passthrough — assume EOA.
856
- return {
857
- address: recipient,
858
- accountType: 'EOA',
859
- setupOps: [],
860
- delegations: undefined,
861
- };
862
- }
863
- if (!recipient) {
864
- return undefined;
865
- }
866
- return getIntentAccount(recipient, eip7702InitSignature, account);
867
- }
868
- // Resolve per-chain signer state once (each resolveSignersForChain does an
869
- // isSessionEnabled RPC) and reuse it for mock signatures, the signature mode,
870
- // and preClaim ops. Exclude a non-EVM destination — it has no session
871
- // validator, so resolving it would waste an RPC (or throw for per-chain
872
- // session signers). resolveSignatureMode derives its chain set from this map's
873
- // keys, so the excluded non-EVM target is never resolved there either.
874
- const sessionChainIds = [
875
- ...new Set([
876
- ...(sourceChains ?? []).map((c) => c.id),
877
- ...(isNonEvmChain(targetChain) ? [] : [targetChainId]),
878
- ]),
879
- ];
880
- const resolvedByChain = signers?.type === 'experimental_session'
881
- ? new Map(await Promise.all(sessionChainIds.map(async (chainId) => [
882
- chainId,
883
- await resolveSignersForChain(config, signers, chainId),
884
- ])))
885
- : undefined;
886
- // Per-chain mock signatures: enables accurate per-chain session validation gas
887
- // simulation. Non-EVM destinations are excluded — they have no destination-side
888
- // session validator. Each chain's mock sig carries that chain's own resolved
889
- // shape (ENABLE / USE / ERC-1271). Note these are per-chain and may differ in
890
- // shape, whereas `signatureMode` (below) is a single global value resolved
891
- // conservatively (anyVerifyExecutions across chains → mode 5) — so in mixed
892
- // states a chain's mock shape need not match the global signatureMode.
893
- let mockSignatures;
894
- if (resolvedByChain) {
895
- const entries = [...resolvedByChain.entries()].flatMap(([chainId, resolved]) => {
896
- // resolvedByChain is keyed by sessionChainIds, which already excludes a
897
- // non-EVM target — so no per-entry target guard is needed here.
898
- if (!isResolvedSessionSignerSet(resolved))
899
- return [];
900
- // Match the mock shape to what the real sig will be: ERC-1271 when not
901
- // verifying executions; otherwise ENABLE if the session still needs
902
- // installing (enableData present), else USE (already enabled, e.g.
903
- // explicit permissions — its real sig is MODE_USE with no enableData).
904
- const shape = !resolved.verifyExecutions
905
- ? 'erc1271'
906
- : resolved.enableData !== undefined
907
- ? 'enable'
908
- : 'use';
909
- return [
910
- [
911
- String(chainId),
912
- buildMockSignature(resolved.session, config.useDevContracts, sourceChains?.length ?? 1, chainId, shape),
913
- ],
914
- ];
915
- });
916
- // Leave mockSignatures undefined (not {}) when there are no eligible chains,
917
- // so downstream consumers can treat presence as "per-chain sigs provided".
918
- if (entries.length > 0)
919
- mockSignatures = Object.fromEntries(entries);
920
- }
921
- const intentAccount = {
922
- ...getIntentAccount(config, eip7702InitSignature, account),
923
- ...(mockSignatures && { mockSignatures }),
924
- };
925
- const recipient = getRecipient(recipientInput);
926
- const signatureMode = await resolveSignatureMode(config, signers, sourceChains, targetChainId, resolvedByChain);
927
- // For session signers that need enabling, pass a dummy preclaimop per source chain
928
- // so the orchestrator bakes it into the bundle before computing its HMAC. The filler
929
- // executes the op via verifyExecution in ENABLE mode, enabling the session on-chain
930
- // without a separate UserOp. Must be sent in the routing request — not injected
931
- // post-facto — because the orchestrator HMAC covers preClaimOps.
932
- const preClaimExecutions = {};
933
- if (signers?.type === 'experimental_session' && sourceChains) {
934
- // Reuse the shared per-chain resolution (source chains are a subset of
935
- // sessionChainIds) instead of resolving — and re-doing isSessionEnabled — again.
936
- for (const chain of sourceChains) {
937
- const chainId = chain.id;
938
- const resolved = resolvedByChain?.get(chainId);
939
- if (!isResolvedSessionSignerSet(resolved))
940
- continue;
941
- const { enableData, verifyExecutions } = resolved;
942
- if (!verifyExecutions || !enableData)
943
- continue;
944
- preClaimExecutions[chainId] = [
945
- {
946
- to: DUMMY_PRECLAIMOP_TARGET,
947
- value: 0n,
948
- data: DUMMY_PRECLAIMOP_SELECTOR,
949
- },
950
- ];
951
- }
952
- }
953
- let combinedAuxiliaryFunds = cloneAuxiliaryFunds(auxiliaryFunds);
954
- if (sourceCalls) {
955
- const accountAddress = getAddress(config);
956
- const allowedChainIds = new Set([
957
- ...(sourceChains ?? []).map((c) => c.id),
958
- ...(!isNonEvmChain(targetChain) ? [targetChainId] : []),
959
- ]);
960
- for (const [chainIdStr, calls] of Object.entries(sourceCalls)) {
961
- const chainId = Number(chainIdStr);
962
- if (!allowedChainIds.has(chainId)) {
963
- throw new InvalidSourceCallsError({ chainId });
964
- }
965
- const chain = sourceChains?.find((c) => c.id === chainId) ??
966
- (!isNonEvmChain(targetChain) && targetChainId === chainId
967
- ? targetChain
968
- : undefined);
969
- if (!chain) {
970
- throw new InvalidSourceCallsError({ chainId });
971
- }
972
- combinedAuxiliaryFunds = addProvidedFunds(combinedAuxiliaryFunds, chainId, calls);
973
- const resolved = await resolveCallInputs(calls.map(toCallInput), config, chain, accountAddress);
974
- const userExecutions = parseCalls(resolved, chainId);
975
- if (userExecutions.length === 0)
976
- continue;
977
- preClaimExecutions[chainId] = [
978
- ...(preClaimExecutions[chainId] ?? []),
979
- ...userExecutions,
980
- ];
981
- }
982
- }
983
- const metaIntent = {
984
- destinationChainId: targetChainId,
985
- tokenRequests: tokenRequests.map((tokenRequest) => ({
986
- tokenAddress: resolveTokenAddress(tokenRequest.address, targetChainId),
987
- amount: tokenRequest.amount,
988
- })),
989
- recipient,
990
- account: intentAccount,
991
- destinationExecutions: calls,
992
- destinationGasUnits: gasLimit,
993
- accountAccessList,
994
- options: {
995
- sponsorSettings: sponsored
996
- ? typeof sponsored === 'object'
997
- ? {
998
- gas: sponsored.gas,
999
- bridgeFees: sponsored.bridging,
1000
- swapFees: sponsored.swaps,
1001
- }
1002
- : {
1003
- gas: sponsored,
1004
- bridgeFees: sponsored,
1005
- swapFees: sponsored,
1006
- }
1007
- : undefined,
1008
- settlementLayers,
1009
- signatureMode,
1010
- auxiliaryFunds: combinedAuxiliaryFunds,
1011
- appFees,
1012
- customDeadline,
1013
- },
1014
- ...(Object.keys(preClaimExecutions).length > 0 && { preClaimExecutions }),
1015
- };
1016
- const serializedIntent = convertBigIntFields(metaIntent);
1017
- const orchestrator = getOrchestrator(config._authProvider ?? createAuthProvider(config), config.endpointUrl, config.headers);
1018
- const { routes, traceId } = await orchestrator.createQuote(metaIntent);
1019
- const best = routes[0];
1020
- if (!best) {
1021
- throw new Error('Orchestrator returned no quote');
1022
- }
1023
- return {
1024
- quotes: { traceId, best, all: routes },
1025
- intentInput: serializedIntent,
1026
- };
1027
- }
1028
- async function signIntent(config, signData, targetChain, signers, targetExecution) {
1029
- const { origin, destination } = getIntentMessages(signData);
1030
- if (config.account?.type === 'eoa') {
1031
- const eoa = config.eoa;
1032
- if (!eoa) {
1033
- throw new EoaAccountMustHaveAccountError();
1034
- }
1035
- const originSignatures = [];
1036
- for (const typedData of origin) {
1037
- if (eoa.signTypedData) {
1038
- const signature = await eoa.signTypedData(typedData);
1039
- originSignatures.push(signature);
1040
- }
1041
- else {
1042
- throw new EoaSigningMethodNotConfiguredError('signTypedData');
1043
- }
1044
- }
1045
- const destinationSignature = originSignatures.at(-1);
1046
- return {
1047
- originSignatures,
1048
- destinationSignature,
1049
- };
1050
- }
1051
- const validator = getValidator(config, signers);
1052
- if (!validator) {
1053
- throw new Error('Validator not available');
1054
- }
1055
- const ownerValidator = getOwnerValidator(config);
1056
- const isRoot = validator.address === ownerValidator.address;
1057
- const originSignatures = [];
1058
- for (const typedData of origin) {
1059
- const chain = getChainById(typedData.domain?.chainId);
1060
- const originSigners = await resolveSignersForChain(config, signers, chain.id);
1061
- const signature = await signIntentTypedData(config, originSigners, validator, isRoot, typedData, chain, targetExecution ?? false);
1062
- originSignatures.push(signature);
1063
- }
1064
- // Non-EVM destinations have no destination-side validator, so there's no
1065
- // session to resolve and no signer to derive. Skipping here matters for
1066
- // per-chain experimental sessions: `resolveSessionForChain` would throw
1067
- // `No session configured for chain {synthetic-id}` since users never
1068
- // configure a session keyed by the synthetic Solana/Tron chain id.
1069
- const destinationSigners = isNonEvmChain(targetChain)
1070
- ? undefined
1071
- : await resolveSignersForChain(config, signers, targetChain.id);
1072
- const destinationSignature = await getDestinationSignature(config, destinationSigners, validator, isRoot, targetChain, destination, originSignatures, targetExecution ?? false);
1073
- return {
1074
- originSignatures,
1075
- destinationSignature,
1076
- };
1077
- }
1078
- async function getDestinationSignature(config, signers, validator, isRoot, targetChain, destination, originSignatures, targetExecution) {
1079
- // Non-EVM destinations have no destination-side validator, no
1080
- // eip712Domain(), no smart session enable data. Settlement is solver-
1081
- // mediated on the orchestrator side and the origin signatures alone
1082
- // authorize the bundle. Fall through to the "reuse last origin sig"
1083
- // branch instead of trying to sign on Solana / Tron.
1084
- if (!isNonEvmChain(targetChain)) {
1085
- // Smart sessions require a separate destination signature because the
1086
- // session enable data differs per chain
1087
- if (signers?.type === 'experimental_session') {
1088
- return await signDestinationSeparately(config, signers, validator, isRoot, targetChain, destination, targetExecution);
1089
- }
1090
- // ERC-7739 with K1 validator requires a separate destination signature because
1091
- // the account's eip712Domain() returns the target chain's chainId, which differs
1092
- // from the origin chain used for the last origin signature
1093
- const isK1Validator = validator.address.toLowerCase() ===
1094
- K1_DEFAULT_VALIDATOR_ADDRESS.toLowerCase();
1095
- if (isK1Validator && supportsEip712(validator)) {
1096
- return await signDestinationSeparately(config, signers, validator, isRoot, targetChain, destination, targetExecution);
1097
- }
1098
- }
1099
- const lastOriginSignature = originSignatures.at(-1);
1100
- return typeof lastOriginSignature === 'object'
1101
- ? lastOriginSignature.preClaimSig
1102
- : (lastOriginSignature ?? '0x');
1103
- }
1104
- async function signDestinationSeparately(config, signers, validator, isRoot, targetChain, destination, targetExecution) {
1105
- // `targetChain` is already the destination viem `Chain`; no lookup needed.
1106
- const destinationChain = targetChain;
1107
- const destinationSignatures = await signIntentTypedData(config, signers, validator, isRoot, destination, destinationChain, targetExecution);
1108
- return typeof destinationSignatures === 'object'
1109
- ? destinationSignatures.preClaimSig
1110
- : (destinationSignatures ?? '0x');
1111
- }
1112
- function getIntentMessages(signData) {
1113
- return {
1114
- origin: signData.origin.map(prepareTypedData),
1115
- destination: prepareTypedData(signData.destination),
1116
- targetExecution: signData.targetExecution
1117
- ? prepareTypedData(signData.targetExecution)
1118
- : undefined,
1119
- };
1120
- }
1121
- // Server emits uint*/int* values as decimal strings; viem's hashTypedData
1122
- // expects bigint. Walk the message tree against the type schema and coerce
1123
- // numeric fields back to bigint before signing.
1124
- function prepareTypedData(td) {
1125
- const types = td.types;
1126
- return {
1127
- ...td,
1128
- message: coerceTypedDataMessage(types, td.primaryType, td.message),
1129
- };
1130
- }
1131
- function coerceTypedDataMessage(types, primaryType, message) {
1132
- const fields = types[primaryType];
1133
- if (!fields)
1134
- return message;
1135
- const result = { ...message };
1136
- for (const { name, type } of fields) {
1137
- if (name in message) {
1138
- result[name] = coerceTypedDataValue(types, type, message[name]);
1139
- }
1140
- }
1141
- return result;
1142
- }
1143
- function coerceTypedDataValue(types, type, value) {
1144
- if (value === null || value === undefined)
1145
- return value;
1146
- const arrayMatch = type.match(/^(.+)\[\d*\]$/);
1147
- if (arrayMatch) {
1148
- const elementType = arrayMatch[1];
1149
- if (!Array.isArray(value))
1150
- return value;
1151
- return value.map((v) => coerceTypedDataValue(types, elementType, v));
1152
- }
1153
- if (/^u?int\d*$/.test(type)) {
1154
- if (typeof value === 'string' || typeof value === 'number') {
1155
- return BigInt(value);
1156
- }
1157
- return value;
1158
- }
1159
- if (types[type]) {
1160
- return coerceTypedDataMessage(types, type, value);
1161
- }
1162
- return value;
1163
- }
1164
- /** Computes claim policy calldata when parameters are Permit2 typed data with claim policies. */
1165
- function resolveClaimPolicyData(signers, parameters) {
1166
- if (parameters.primaryType !== 'PermitBatchWitnessTransferFrom' ||
1167
- !signers.session.claimPolicies.length) {
1168
- return undefined;
1169
- }
1170
- const msg = parameters.message;
1171
- if (!msg.permitted ||
1172
- !msg.mandate ||
1173
- typeof msg.spender !== 'string' ||
1174
- typeof msg.nonce !== 'bigint' ||
1175
- typeof msg.deadline !== 'bigint') {
1176
- return undefined;
1177
- }
1178
- const message = parameters.message;
1179
- // A session may carry several claim policies (a user policy plus one or
1180
- // more synthesized cross-chain permits). The on-chain emissary validates
1181
- // against the policy that matches this Permit2 message, and the calldata
1182
- // layout is policy-specific — so we must build it from the matching policy,
1183
- // not blindly `claimPolicies[0]`.
1184
- const claimPolicy = selectPermit2ClaimPolicyForMessage(signers.session.claimPolicies, message);
1185
- if (!claimPolicy) {
1186
- return undefined;
1187
- }
1188
- return buildPermit2ClaimPolicyCalldata(resolvePermit2ClaimPolicy(claimPolicy), message);
1189
- }
1190
- async function signIntentTypedData(config, signers, validator, isRoot, parameters, chain, targetExecution) {
1191
- if (supportsEip712(validator)) {
1192
- const isK1Validator = validator.address.toLowerCase() ===
1193
- K1_DEFAULT_VALIDATOR_ADDRESS.toLowerCase();
1194
- if (isK1Validator) {
1195
- return await signErc7739TypedData(config, signers, validator, isRoot, parameters, chain);
1196
- }
1197
- return await getTypedDataPackedSignature(config, signers, chain, {
1198
- address: validator.address,
1199
- isRoot,
1200
- }, parameters);
1201
- }
1202
- const hash = hashTypedData(parameters);
1203
- if (isResolvedSessionSignerSet(signers) && signers.verifyExecutions) {
1204
- if (targetExecution) {
1205
- const targetSigners = {
1206
- type: 'experimental_session',
1207
- session: signers.session,
1208
- verifyExecutions: true,
1209
- enableData: signers.enableData,
1210
- };
1211
- // signWithSession (called inside getEmissarySignature) already calls packSignature
1212
- // internally, so no transform is needed here
1213
- return await getEmissarySignature(config, targetSigners, chain, hash);
1214
- }
1215
- const claimPolicyData = resolveClaimPolicyData(signers, parameters);
1216
- const sessionSignersForEip1271 = {
1217
- type: 'experimental_session',
1218
- session: signers.session,
1219
- verifyExecutions: false,
1220
- enableData: signers.enableData,
1221
- claimPolicyData,
1222
- };
1223
- const eip1271Signature = await getEip1271Signature(config, sessionSignersForEip1271, chain, {
1224
- address: validator.address,
1225
- isRoot,
1226
- }, hash);
1227
- const emissarySignature = await getEmissarySignature(config, {
1228
- type: 'experimental_session',
1229
- session: signers.session,
1230
- verifyExecutions: true,
1231
- enableData: signers.enableData,
1232
- }, chain, hash);
1233
- return {
1234
- preClaimSig: emissarySignature,
1235
- notarizedClaimSig: eip1271Signature,
1236
- };
1237
- }
1238
- if (isResolvedSessionSignerSet(signers)) {
1239
- const claimPolicyData = resolveClaimPolicyData(signers, parameters);
1240
- return await getEip1271Signature(config, claimPolicyData !== undefined ? { ...signers, claimPolicyData } : signers, chain, {
1241
- address: validator.address,
1242
- isRoot,
1243
- }, hash);
1244
- }
1245
- return await getEip1271Signature(config, signers, chain, {
1246
- address: validator.address,
1247
- isRoot,
1248
- }, hash);
1249
- }
1250
- async function signUserOp(config, chain, signers, userOp) {
1251
- const validator = getValidator(config, signers);
1252
- if (!validator) {
1253
- throw new Error('Validator not available');
1254
- }
1255
- const publicClient = createPublicClient({
1256
- chain,
1257
- transport: createTransport(chain, config.provider),
1258
- });
1259
- const account = await getValidatorAccount(config, signers, publicClient, chain);
1260
- if (!account) {
1261
- throw new Error('No account found');
1262
- }
1263
- return await account.signUserOperation(userOp);
1264
- }
1265
- async function submitUserOp(config, chain, userOp, signature) {
1266
- const publicClient = createPublicClient({
1267
- chain,
1268
- transport: createTransport(chain, config.provider),
1269
- });
1270
- const bundlerClient = getBundlerClient(config, publicClient);
1271
- const hash = await bundlerClient.request({
1272
- method: 'eth_sendUserOperation',
1273
- params: [
1274
- {
1275
- sender: userOp.sender,
1276
- nonce: toHex(userOp.nonce),
1277
- factory: userOp.factory,
1278
- factoryData: userOp.factoryData,
1279
- callData: userOp.callData,
1280
- callGasLimit: toHex(userOp.callGasLimit),
1281
- verificationGasLimit: toHex(userOp.verificationGasLimit),
1282
- preVerificationGas: toHex(userOp.preVerificationGas),
1283
- maxPriorityFeePerGas: toHex(userOp.maxPriorityFeePerGas),
1284
- maxFeePerGas: toHex(userOp.maxFeePerGas),
1285
- paymaster: userOp.paymaster,
1286
- paymasterVerificationGasLimit: userOp.paymasterVerificationGasLimit
1287
- ? toHex(userOp.paymasterVerificationGasLimit)
1288
- : undefined,
1289
- paymasterPostOpGasLimit: userOp.paymasterPostOpGasLimit
1290
- ? toHex(userOp.paymasterPostOpGasLimit)
1291
- : undefined,
1292
- paymasterData: userOp.paymasterData,
1293
- signature,
1294
- },
1295
- entryPoint07Address,
1296
- ],
1297
- });
1298
- return {
1299
- type: 'userop',
1300
- hash,
1301
- chain: chain.id,
1302
- };
1303
- }
1304
- async function submitIntentInternal(config, sourceChains, targetChain, quote, originSignatures, destinationSignature, targetExecutionSignature, authorizations, dryRun, intentInput) {
1305
- const request = {
1306
- intentId: quote.intentId,
1307
- signatures: {
1308
- origin: originSignatures,
1309
- destination: destinationSignature,
1310
- ...(targetExecutionSignature !== undefined && {
1311
- targetExecution: targetExecutionSignature,
1312
- }),
1313
- },
1314
- ...(authorizations.length > 0 && {
1315
- authorizations: {
1316
- sponsor: authorizations.map((authorization) => ({
1317
- chainId: toCaip2(authorization.chainId),
1318
- address: authorization.address,
1319
- nonce: authorization.nonce,
1320
- yParity: authorization.yParity ?? 0,
1321
- r: authorization.r,
1322
- s: authorization.s,
1323
- })),
1324
- },
1325
- }),
1326
- ...(dryRun && { options: { dryRun: true } }),
1327
- };
1328
- const isSponsored = !!intentInput?.options?.sponsorSettings;
1329
- const orchestrator = getOrchestrator(config._authProvider ?? createAuthProvider(config), config.endpointUrl, config.headers);
1330
- const response = await orchestrator.createIntent(request, intentInput ? { intentInput, isSponsored } : undefined);
1331
- return {
1332
- type: 'intent',
1333
- id: response.intentId,
1334
- traceId: response.traceId,
1335
- sourceChains: sourceChains?.map((chain) => chain.id),
1336
- targetChain: getChainId(targetChain),
1337
- };
1338
- }
1339
- async function getValidatorAccount(config, signers, publicClient, chain) {
1340
- if (!signers) {
1341
- return getSmartAccount(config, publicClient, chain);
1342
- }
1343
- // Owners
1344
- const withOwner = signers.type === 'owner' ? signers : null;
1345
- if (withOwner) {
1346
- return getSmartAccount(config, publicClient, chain);
1347
- }
1348
- return null;
1349
- }
1350
- function getValidator(config, signers) {
1351
- if (!signers) {
1352
- return getOwnerValidator(config);
1353
- }
1354
- // Owners
1355
- const withOwner = signers.type === 'owner' ? signers : null;
1356
- if (withOwner) {
1357
- // ECDSA
1358
- if (withOwner.kind === 'ecdsa') {
1359
- // Use the configured owner validator (e.g., ENS) rather than forcing Ownable
1360
- return getOwnerValidator(config);
1361
- }
1362
- // Passkeys (WebAuthn)
1363
- if (withOwner.kind === 'passkey') {
1364
- return getWebAuthnValidator(1, withOwner.accounts.map((account) => ({
1365
- pubKey: account.publicKey,
1366
- authenticatorId: account.id,
1367
- })), withOwner.module);
1368
- }
1369
- // Multi-factor
1370
- if (withOwner.kind === 'multi-factor') {
1371
- return getMultiFactorValidator(1, withOwner.validators, withOwner.module);
1372
- }
1373
- }
1374
- // Smart sessions
1375
- const withSession = signers.type === 'experimental_session';
1376
- if (withSession) {
1377
- return getSmartSessionValidator(config);
1378
- }
1379
- // Fallback
1380
- return undefined;
1381
- }
1382
- function parseCalls(calls, chainId) {
1383
- // Destination calls only run on EVM chains (non-EVM destinations reject
1384
- // calls upstream), so the resolved `to` is always a viem `Address` here.
1385
- return calls.map((call) => ({
1386
- data: call.data ?? '0x',
1387
- value: call.value ?? 0n,
1388
- to: resolveTokenAddress(call.to, chainId),
1389
- }));
1390
- }
1391
- function createAccountAccessList(sourceChains, sourceAssets) {
1392
- if (!sourceChains && !sourceAssets)
1393
- return undefined;
1394
- const chainIds = sourceChains?.map((chain) => chain.id);
1395
- if (!sourceAssets)
1396
- return { chainIds };
1397
- if (Array.isArray(sourceAssets)) {
1398
- const isExactConfig = sourceAssets.length > 0 && typeof sourceAssets[0] !== 'string';
1399
- if (isExactConfig) {
1400
- const chainTokens = {};
1401
- const chainTokenAmounts = {};
1402
- for (const config of sourceAssets) {
1403
- const chainId = config.chain.id;
1404
- // Source assets live on viem `Chain`s, which are always EVM, so the
1405
- // resolved value is a viem `Address`.
1406
- const tokenAddress = resolveTokenAddress(config.address, config.chain.id);
1407
- if (config.amount !== undefined) {
1408
- if (!chainTokenAmounts[chainId])
1409
- chainTokenAmounts[chainId] = {};
1410
- chainTokenAmounts[chainId][tokenAddress] = config.amount;
1411
- }
1412
- else {
1413
- if (!chainTokens[chainId])
1414
- chainTokens[chainId] = [];
1415
- chainTokens[chainId].push(tokenAddress);
1416
- }
1417
- }
1418
- const out = {};
1419
- if (Object.keys(chainTokens).length > 0) {
1420
- out.chainTokens =
1421
- chainTokens;
1422
- }
1423
- if (Object.keys(chainTokenAmounts).length > 0) {
1424
- out.chainTokenAmounts =
1425
- chainTokenAmounts;
1426
- }
1427
- return out;
1428
- }
1429
- const tokens = sourceAssets;
1430
- validateTokenAddresses(tokens);
1431
- return chainIds ? { chainIds, tokens } : { tokens };
1432
- }
1433
- // ChainTokenMap: validate every per-chain list too, so symbols can't slip
1434
- // through this input the way they can't through tokenRequests/ExactInputConfig.
1435
- for (const tokens of Object.values(sourceAssets)) {
1436
- validateTokenAddresses(tokens);
1437
- }
1438
- return { chainTokens: sourceAssets };
1439
- }
1440
- function getSetupOperationsAndDelegations(config, accountAddress, eip7702InitSignature) {
1441
- const initCode = getInitCode(config);
1442
- if (config.account?.type === 'eoa') {
1443
- return {
1444
- setupOps: [],
1445
- };
1446
- }
1447
- else if (is7702(config)) {
1448
- // EIP-7702 initialization is only needed for EOA accounts
1449
- if (!eip7702InitSignature || eip7702InitSignature === '0x') {
1450
- throw new Eip7702InitSignatureRequiredError();
1451
- }
1452
- const { initData: eip7702InitData, contract: eip7702Contract } = getEip7702InitCall(config, eip7702InitSignature);
1453
- return {
1454
- setupOps: [
1455
- {
1456
- to: accountAddress,
1457
- data: eip7702InitData,
1458
- },
1459
- ],
1460
- delegations: {
1461
- 0: {
1462
- contract: eip7702Contract,
1463
- },
1464
- },
1465
- };
1466
- }
1467
- else if (initCode) {
1468
- const to = 'factory' in initCode ? initCode.factory : undefined;
1469
- const data = 'factory' in initCode ? initCode.factoryData : undefined;
1470
- if (!to || !data) {
1471
- // Check if it's a migrated account with address-only initData
1472
- if (config.initData && !('factory' in config.initData)) {
1473
- // Assume the account is already deployed
1474
- return {
1475
- setupOps: [],
1476
- };
1477
- }
1478
- throw new FactoryArgsNotAvailableError();
1479
- }
1480
- // Contract account with init code
1481
- return {
1482
- setupOps: [
1483
- {
1484
- to,
1485
- data,
1486
- },
1487
- ],
1488
- };
1489
- }
1490
- else {
1491
- // Already deployed contract account
1492
- return {
1493
- setupOps: [],
1494
- };
1495
- }
1496
- }
1497
- function validateTokenAddresses(tokenAddresses) {
1498
- for (const address of tokenAddresses) {
1499
- if (!isAddress(address, { strict: false })) {
1500
- throw new Error(`Invalid token address: ${address}`);
1501
- }
1502
- }
1503
- }
1504
- // Signs typed data using ERC-7739 nested EIP-712 for Startale accounts.
1505
- // Uses a Solady-compatible TypedDataSign hash and wraps the signature with
1506
- // the app domain separator and contents hash for on-chain verification.
1507
- async function signErc7739TypedData(config, signers, validator, isRoot, parameters, chain) {
1508
- const verifierDomain = getEip712Domain(config, chain);
1509
- const hash = hashErc7739TypedDataForSolady({
1510
- domain: parameters.domain,
1511
- types: parameters.types,
1512
- primaryType: parameters.primaryType,
1513
- message: parameters.message,
1514
- verifierDomain,
1515
- });
1516
- return await getEip1271Signature(config, signers, chain, {
1517
- address: validator.address,
1518
- isRoot,
1519
- }, hash, (signature) => wrapTypedDataSignature({
1520
- domain: parameters.domain,
1521
- primaryType: parameters.primaryType,
1522
- types: parameters.types,
1523
- message: parameters.message,
1524
- signature,
1525
- }));
1526
- }
1527
- // Computes an ERC-7739 TypedDataSign hash compatible with Solady's ERC1271
1528
- // on-chain verification. Solady constructs the TypedDataSign type string by
1529
- // appending the contentsType directly after the TypedDataSign definition,
1530
- // which differs from viem's standard EIP-712 encodeType that re-sorts all
1531
- // referenced types alphabetically.
1532
- function hashErc7739TypedDataForSolady({ domain, types, primaryType, message, verifierDomain, }) {
1533
- // Standard EIP-712 encodeType for the original content type
1534
- function encodeTypeString(primary, allTypes) {
1535
- const deps = new Set();
1536
- function findDeps(t) {
1537
- const match = t.match(/^\w*/);
1538
- const typeName = match?.[0];
1539
- if (!typeName || deps.has(typeName) || !allTypes[typeName])
1540
- return;
1541
- deps.add(typeName);
1542
- for (const field of allTypes[typeName])
1543
- findDeps(field.type);
1544
- }
1545
- findDeps(primary);
1546
- deps.delete(primary);
1547
- const sorted = [primary, ...Array.from(deps).sort()];
1548
- return sorted
1549
- .map((t) => `${t}(${allTypes[t]
1550
- .map((f) => `${f.type} ${f.name}`)
1551
- .join(',')})`)
1552
- .join('');
1553
- }
1554
- const contentsType = encodeTypeString(primaryType, types);
1555
- const contentsName = primaryType;
1556
- // Construct TypedDataSign type string matching Solady's on-chain encoding:
1557
- // TypedDataSign(<contentsName> contents,...salt) + contentsType
1558
- const typedDataSignTypeString = `TypedDataSign(${contentsName} contents,string name,string version,uint256 chainId,address verifyingContract,bytes32 salt)${contentsType}`;
1559
- const typedDataSignTypeHash = keccak256(toHex(typedDataSignTypeString));
1560
- // Hash the original content struct
1561
- const contentsHash = hashStruct({
1562
- data: message,
1563
- primaryType,
1564
- types: types,
1565
- });
1566
- // Compute the TypedDataSign struct hash
1567
- const structHash = keccak256(encodeAbiParameters([
1568
- { type: 'bytes32' },
1569
- { type: 'bytes32' },
1570
- { type: 'bytes32' },
1571
- { type: 'bytes32' },
1572
- { type: 'uint256' },
1573
- { type: 'address' },
1574
- { type: 'bytes32' },
1575
- ], [
1576
- typedDataSignTypeHash,
1577
- contentsHash,
1578
- keccak256(toHex(verifierDomain.name)),
1579
- keccak256(toHex(verifierDomain.version)),
1580
- BigInt(verifierDomain.chainId),
1581
- verifierDomain.verifyingContract,
1582
- verifierDomain.salt,
1583
- ]));
1584
- // Compute the app domain separator
1585
- const domainTypes = [];
1586
- if (domain.name)
1587
- domainTypes.push({ name: 'name', type: 'string' });
1588
- if (domain.version)
1589
- domainTypes.push({ name: 'version', type: 'string' });
1590
- if (domain.chainId)
1591
- domainTypes.push({ name: 'chainId', type: 'uint256' });
1592
- if (domain.verifyingContract)
1593
- domainTypes.push({ name: 'verifyingContract', type: 'address' });
1594
- if (domain.salt)
1595
- domainTypes.push({ name: 'salt', type: 'bytes32' });
1596
- const appDomainSeparator = hashDomain({
1597
- domain,
1598
- types: { EIP712Domain: domainTypes },
1599
- });
1600
- // Final hash: keccak256("\x19\x01" || appDomainSep || structHash)
1601
- return keccak256(concat(['0x1901', appDomainSeparator, structHash]));
1602
- }
1603
- export { prepareTransaction, getTransactionMessages, signTransaction, assembleTransaction, signAuthorizations, signAuthorizationsInternal, signMessage, signTypedData, submitTransaction, prepareUserOperation, signUserOperation, submitUserOperation, signIntent, prepareTransactionAsIntent, submitIntentInternal, getValidatorAccount, parseCalls, getTokenRequests, resolveCallInputs, getIntentAccount, getTargetExecutionSignature, hashErc7739TypedDataForSolady, resolveSessionForChain, resolveSignatureMode, };