rise-wallet 0.1.4-beta.1 → 0.2.28

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 (486) hide show
  1. package/README.md +64 -34
  2. package/dist/cli/Dialog.d.ts +34 -0
  3. package/dist/cli/Dialog.js +60 -0
  4. package/dist/cli/Dialog.js.map +1 -0
  5. package/dist/cli/Messenger.d.ts +7 -0
  6. package/dist/cli/Messenger.js +123 -0
  7. package/dist/cli/Messenger.js.map +1 -0
  8. package/dist/cli/bin/commands-D7N5ucUu.js +50 -0
  9. package/dist/cli/bin/index.js +9 -0
  10. package/dist/cli/index.d.ts +2 -0
  11. package/dist/cli/index.js +3 -0
  12. package/dist/cli/index.js.map +1 -0
  13. package/dist/cli/internal/http.d.ts +6 -0
  14. package/dist/cli/internal/http.js +17 -0
  15. package/dist/cli/internal/http.js.map +1 -0
  16. package/dist/cli/tsdown.config.d.ts +2 -0
  17. package/dist/cli/tsdown.config.js +28 -0
  18. package/dist/cli/tsdown.config.js.map +1 -0
  19. package/dist/core/Chains.d.ts +210 -0
  20. package/dist/core/Chains.js +20 -0
  21. package/dist/core/Chains.js.map +1 -0
  22. package/dist/core/Dialog.d.ts +307 -0
  23. package/dist/core/Dialog.js +809 -0
  24. package/dist/core/Dialog.js.map +1 -0
  25. package/dist/core/Messenger.d.ts +164 -0
  26. package/dist/core/Messenger.js +207 -0
  27. package/dist/core/Messenger.js.map +1 -0
  28. package/dist/core/Mode.d.ts +4 -0
  29. package/dist/core/Mode.js +5 -0
  30. package/dist/core/Mode.js.map +1 -0
  31. package/dist/core/Porto.d.ts +1608 -0
  32. package/dist/core/Porto.js +105 -0
  33. package/dist/core/Porto.js.map +1 -0
  34. package/dist/core/RpcSchema.d.ts +81 -0
  35. package/dist/core/RpcSchema.js +2 -0
  36. package/dist/core/RpcSchema.js.map +1 -0
  37. package/dist/core/Storage.d.ts +14 -0
  38. package/dist/core/Storage.js +109 -0
  39. package/dist/core/Storage.js.map +1 -0
  40. package/dist/core/Transport.d.ts +22 -0
  41. package/dist/core/Transport.js +37 -0
  42. package/dist/core/Transport.js.map +1 -0
  43. package/dist/core/internal/_generated/chains.d.ts +1 -0
  44. package/dist/core/internal/_generated/chains.js +3 -0
  45. package/dist/core/internal/_generated/chains.js.map +1 -0
  46. package/dist/core/internal/_generated/contracts/IthacaAccount.d.ts +1120 -0
  47. package/dist/core/internal/_generated/contracts/IthacaAccount.js +1453 -0
  48. package/dist/core/internal/_generated/contracts/IthacaAccount.js.map +1 -0
  49. package/dist/core/internal/call.d.ts +163 -0
  50. package/dist/core/internal/call.js +115 -0
  51. package/dist/core/internal/call.js.map +1 -0
  52. package/dist/core/internal/erc8010.d.ts +17 -0
  53. package/dist/core/internal/erc8010.js +29 -0
  54. package/dist/core/internal/erc8010.js.map +1 -0
  55. package/dist/core/internal/intersectionObserver.d.ts +1 -0
  56. package/dist/core/internal/intersectionObserver.js +5 -0
  57. package/dist/core/internal/intersectionObserver.js.map +1 -0
  58. package/dist/core/internal/logger.d.ts +21 -0
  59. package/dist/core/internal/logger.js +24 -0
  60. package/dist/core/internal/logger.js.map +1 -0
  61. package/dist/core/internal/mode.d.ts +344 -0
  62. package/dist/core/internal/mode.js +110 -0
  63. package/dist/core/internal/mode.js.map +1 -0
  64. package/dist/core/internal/modes/dialog.d.ts +799 -0
  65. package/dist/core/internal/modes/dialog.js +760 -0
  66. package/dist/core/internal/modes/dialog.js.map +1 -0
  67. package/dist/core/internal/modes/reactNative.d.ts +1401 -0
  68. package/dist/core/internal/modes/reactNative.js +19 -0
  69. package/dist/core/internal/modes/reactNative.js.map +1 -0
  70. package/dist/core/internal/modes/relay.d.ts +684 -0
  71. package/dist/core/internal/modes/relay.js +708 -0
  72. package/dist/core/internal/modes/relay.js.map +1 -0
  73. package/dist/core/internal/permissions.d.ts +59 -0
  74. package/dist/core/internal/permissions.js +30 -0
  75. package/dist/core/internal/permissions.js.map +1 -0
  76. package/dist/core/internal/permissionsRequest.d.ts +71 -0
  77. package/dist/core/internal/permissionsRequest.js +58 -0
  78. package/dist/core/internal/permissionsRequest.js.map +1 -0
  79. package/dist/core/internal/porto.d.ts +13 -0
  80. package/dist/core/internal/porto.js +2 -0
  81. package/dist/core/internal/porto.js.map +1 -0
  82. package/dist/core/internal/promise.d.ts +8 -0
  83. package/dist/core/internal/promise.js +11 -0
  84. package/dist/core/internal/promise.js.map +1 -0
  85. package/dist/core/internal/provider.d.ts +29 -0
  86. package/dist/core/internal/provider.js +941 -0
  87. package/dist/core/internal/provider.js.map +1 -0
  88. package/dist/core/internal/relay/rpcSchema.d.ts +75 -0
  89. package/dist/core/internal/relay/rpcSchema.js +7 -0
  90. package/dist/core/internal/relay/rpcSchema.js.map +1 -0
  91. package/dist/core/internal/relay/schema/capabilities.d.ts +164 -0
  92. package/dist/core/internal/relay/schema/capabilities.js +112 -0
  93. package/dist/core/internal/relay/schema/capabilities.js.map +1 -0
  94. package/dist/core/internal/relay/schema/intent.d.ts +167 -0
  95. package/dist/core/internal/relay/schema/intent.js +170 -0
  96. package/dist/core/internal/relay/schema/intent.js.map +1 -0
  97. package/dist/core/internal/relay/schema/key.d.ts +43 -0
  98. package/dist/core/internal/relay/schema/key.js +30 -0
  99. package/dist/core/internal/relay/schema/key.js.map +1 -0
  100. package/dist/core/internal/relay/schema/permission.d.ts +39 -0
  101. package/dist/core/internal/relay/schema/permission.js +29 -0
  102. package/dist/core/internal/relay/schema/permission.js.map +1 -0
  103. package/dist/core/internal/relay/schema/preCall.d.ts +62 -0
  104. package/dist/core/internal/relay/schema/preCall.js +36 -0
  105. package/dist/core/internal/relay/schema/preCall.js.map +1 -0
  106. package/dist/core/internal/relay/schema/quotes.d.ts +369 -0
  107. package/dist/core/internal/relay/schema/quotes.js +89 -0
  108. package/dist/core/internal/relay/schema/quotes.js.map +1 -0
  109. package/dist/core/internal/relay/schema/rpc.d.ts +1528 -0
  110. package/dist/core/internal/relay/schema/rpc.js +638 -0
  111. package/dist/core/internal/relay/schema/rpc.js.map +1 -0
  112. package/dist/core/internal/relay/schema/token.d.ts +13 -0
  113. package/dist/core/internal/relay/schema/token.js +13 -0
  114. package/dist/core/internal/relay/schema/token.js.map +1 -0
  115. package/dist/core/internal/requiredFunds.d.ts +18 -0
  116. package/dist/core/internal/requiredFunds.js +25 -0
  117. package/dist/core/internal/requiredFunds.js.map +1 -0
  118. package/dist/core/internal/schema/capabilities.d.ts +313 -0
  119. package/dist/core/internal/schema/capabilities.js +133 -0
  120. package/dist/core/internal/schema/capabilities.js.map +1 -0
  121. package/dist/core/internal/schema/key.d.ts +164 -0
  122. package/dist/core/internal/schema/key.js +75 -0
  123. package/dist/core/internal/schema/key.js.map +1 -0
  124. package/dist/core/internal/schema/permissions.d.ts +102 -0
  125. package/dist/core/internal/schema/permissions.js +28 -0
  126. package/dist/core/internal/schema/permissions.js.map +1 -0
  127. package/dist/core/internal/schema/request.d.ts +937 -0
  128. package/dist/core/internal/schema/request.js +57 -0
  129. package/dist/core/internal/schema/request.js.map +1 -0
  130. package/dist/core/internal/schema/rpc.d.ts +3314 -0
  131. package/dist/core/internal/schema/rpc.js +599 -0
  132. package/dist/core/internal/schema/rpc.js.map +1 -0
  133. package/dist/core/internal/schema/token.d.ts +1 -0
  134. package/dist/core/internal/schema/token.js +2 -0
  135. package/dist/core/internal/schema/token.js.map +1 -0
  136. package/dist/core/internal/schema/utils.d.ts +18 -0
  137. package/dist/core/internal/schema/utils.js +213 -0
  138. package/dist/core/internal/schema/utils.js.map +1 -0
  139. package/dist/core/internal/siwe.d.ts +32 -0
  140. package/dist/core/internal/siwe.js +92 -0
  141. package/dist/core/internal/siwe.js.map +1 -0
  142. package/dist/core/internal/store.d.ts +2 -0
  143. package/dist/core/internal/store.js +9 -0
  144. package/dist/core/internal/store.js.map +1 -0
  145. package/dist/core/internal/tokens.d.ts +57 -0
  146. package/dist/core/internal/tokens.js +69 -0
  147. package/dist/core/internal/tokens.js.map +1 -0
  148. package/dist/core/internal/types.d.ts +298 -0
  149. package/dist/core/internal/types.js +2 -0
  150. package/dist/core/internal/types.js.map +1 -0
  151. package/dist/core/internal/urlString.d.ts +1 -0
  152. package/dist/core/internal/urlString.js +8 -0
  153. package/dist/core/internal/urlString.js.map +1 -0
  154. package/dist/core/internal/userAgent.d.ts +10 -0
  155. package/dist/core/internal/userAgent.js +19 -0
  156. package/dist/core/internal/userAgent.js.map +1 -0
  157. package/dist/core/internal/utils.d.ts +24 -0
  158. package/dist/core/internal/utils.js +62 -0
  159. package/dist/core/internal/utils.js.map +1 -0
  160. package/dist/core/react-native/Porto.d.ts +1480 -0
  161. package/dist/core/react-native/Porto.js +17 -0
  162. package/dist/core/react-native/Porto.js.map +1 -0
  163. package/dist/core/react-native/configure.d.ts +9 -0
  164. package/dist/core/react-native/configure.js +24 -0
  165. package/dist/core/react-native/configure.js.map +1 -0
  166. package/dist/core/react-native/environment.d.ts +26 -0
  167. package/dist/core/react-native/environment.js +13 -0
  168. package/dist/core/react-native/environment.js.map +1 -0
  169. package/dist/core/react-native/index.d.ts +4 -0
  170. package/dist/core/react-native/index.js +5 -0
  171. package/dist/core/react-native/index.js.map +1 -0
  172. package/dist/core/react-native/utils.d.ts +1 -0
  173. package/dist/core/react-native/utils.js +12 -0
  174. package/dist/core/react-native/utils.js.map +1 -0
  175. package/dist/index.d.ts +16 -2
  176. package/dist/index.js +15 -2
  177. package/dist/index.js.map +1 -0
  178. package/dist/internal/index.d.ts +3 -0
  179. package/dist/internal/index.js +4 -0
  180. package/dist/internal/index.js.map +1 -0
  181. package/dist/react-native/crypto.d.ts +1 -0
  182. package/dist/react-native/crypto.js +12 -0
  183. package/dist/react-native/crypto.js.map +1 -0
  184. package/dist/react-native/index.d.ts +7 -0
  185. package/dist/react-native/index.js +12 -0
  186. package/dist/react-native/index.js.map +1 -0
  187. package/dist/react-native/register.d.ts +2 -0
  188. package/dist/react-native/register.js +15 -0
  189. package/dist/react-native/register.js.map +1 -0
  190. package/dist/register/index.d.ts +14 -0
  191. package/dist/register/index.js +2 -0
  192. package/dist/register/index.js.map +1 -0
  193. package/dist/remote/Actions.d.ts +33 -0
  194. package/dist/remote/Actions.js +76 -0
  195. package/dist/remote/Actions.js.map +1 -0
  196. package/dist/remote/Events.d.ts +46 -0
  197. package/dist/remote/Events.js +132 -0
  198. package/dist/remote/Events.js.map +1 -0
  199. package/dist/remote/Hooks.d.ts +3800 -0
  200. package/dist/remote/Hooks.js +106 -0
  201. package/dist/remote/Hooks.js.map +1 -0
  202. package/dist/remote/Porto.d.ts +857 -0
  203. package/dist/remote/Porto.js +66 -0
  204. package/dist/remote/Porto.js.map +1 -0
  205. package/dist/remote/index.d.ts +4 -0
  206. package/dist/remote/index.js +5 -0
  207. package/dist/remote/index.js.map +1 -0
  208. package/dist/remote/internal/methodPolicies.d.ts +96 -0
  209. package/dist/remote/internal/methodPolicies.js +102 -0
  210. package/dist/remote/internal/methodPolicies.js.map +1 -0
  211. package/dist/server/Route.d.ts +87 -0
  212. package/dist/server/Route.js +189 -0
  213. package/dist/server/Route.js.map +1 -0
  214. package/dist/server/Router.d.ts +23 -0
  215. package/dist/server/Router.js +29 -0
  216. package/dist/server/Router.js.map +1 -0
  217. package/dist/server/index.d.ts +2 -0
  218. package/dist/server/index.js +3 -0
  219. package/dist/server/index.js.map +1 -0
  220. package/dist/server/internal/merchantSchema.d.ts +64 -0
  221. package/dist/server/internal/merchantSchema.js +7 -0
  222. package/dist/server/internal/merchantSchema.js.map +1 -0
  223. package/dist/server/internal/requestListener.d.ts +123 -0
  224. package/dist/server/internal/requestListener.js +172 -0
  225. package/dist/server/internal/requestListener.js.map +1 -0
  226. package/dist/theme/Theme.d.ts +121 -0
  227. package/dist/theme/Theme.js +18 -0
  228. package/dist/theme/Theme.js.map +1 -0
  229. package/dist/theme/index.d.ts +2 -0
  230. package/dist/theme/index.js +2 -0
  231. package/dist/theme/index.js.map +1 -0
  232. package/dist/trusted-hosts.d.ts +1 -0
  233. package/dist/trusted-hosts.js +41 -0
  234. package/dist/trusted-hosts.js.map +1 -0
  235. package/dist/viem/Account.d.ts +110 -0
  236. package/dist/viem/Account.js +132 -0
  237. package/dist/viem/Account.js.map +1 -0
  238. package/dist/viem/AccountActions.d.ts +10 -0
  239. package/dist/viem/AccountActions.js +14 -0
  240. package/dist/viem/AccountActions.js.map +1 -0
  241. package/dist/viem/CapabilitiesSchema.d.ts +14 -0
  242. package/dist/viem/CapabilitiesSchema.js +2 -0
  243. package/dist/viem/CapabilitiesSchema.js.map +1 -0
  244. package/dist/viem/ContractActions.d.ts +208 -0
  245. package/dist/viem/ContractActions.js +350 -0
  246. package/dist/viem/ContractActions.js.map +1 -0
  247. package/dist/viem/Key.d.ts +1155 -0
  248. package/dist/viem/Key.js +924 -0
  249. package/dist/viem/Key.js.map +1 -0
  250. package/dist/viem/RelayActions.d.ts +435 -0
  251. package/dist/viem/RelayActions.js +385 -0
  252. package/dist/viem/RelayActions.js.map +1 -0
  253. package/dist/viem/RelayClient.d.ts +26 -0
  254. package/dist/viem/RelayClient.js +44 -0
  255. package/dist/viem/RelayClient.js.map +1 -0
  256. package/dist/viem/RpcSchema.d.ts +22 -0
  257. package/dist/viem/RpcSchema.js +2 -0
  258. package/dist/viem/RpcSchema.js.map +1 -0
  259. package/dist/viem/WalletActions.d.ts +86 -0
  260. package/dist/viem/WalletActions.js +220 -0
  261. package/dist/viem/WalletActions.js.map +1 -0
  262. package/dist/viem/WalletClient.d.ts +20 -0
  263. package/dist/viem/WalletClient.js +23 -0
  264. package/dist/viem/WalletClient.js.map +1 -0
  265. package/dist/viem/index.d.ts +13 -0
  266. package/dist/viem/index.js +12 -0
  267. package/dist/viem/index.js.map +1 -0
  268. package/dist/viem/internal/relayActions.d.ts +364 -0
  269. package/dist/viem/internal/relayActions.js +783 -0
  270. package/dist/viem/internal/relayActions.js.map +1 -0
  271. package/dist/viem/internal/utils.d.ts +15 -0
  272. package/dist/viem/internal/utils.js +2 -0
  273. package/dist/viem/internal/utils.js.map +1 -0
  274. package/dist/wagmi/Actions.d.ts +1 -0
  275. package/dist/wagmi/Actions.js +2 -0
  276. package/dist/wagmi/Actions.js.map +1 -0
  277. package/dist/wagmi/Connector.d.ts +26 -0
  278. package/dist/wagmi/Connector.js +238 -0
  279. package/dist/wagmi/Connector.js.map +1 -0
  280. package/dist/wagmi/Hooks.d.ts +1 -0
  281. package/dist/wagmi/Hooks.js +2 -0
  282. package/dist/wagmi/Hooks.js.map +1 -0
  283. package/dist/wagmi/Query.d.ts +1 -0
  284. package/dist/wagmi/Query.js +2 -0
  285. package/dist/wagmi/Query.js.map +1 -0
  286. package/dist/wagmi/index.d.ts +4 -0
  287. package/dist/wagmi/index.js +5 -0
  288. package/dist/wagmi/index.js.map +1 -0
  289. package/dist/wagmi/internal/core.d.ts +83 -0
  290. package/dist/wagmi/internal/core.js +229 -0
  291. package/dist/wagmi/internal/core.js.map +1 -0
  292. package/dist/wagmi/internal/query.d.ts +32 -0
  293. package/dist/wagmi/internal/query.js +23 -0
  294. package/dist/wagmi/internal/query.js.map +1 -0
  295. package/dist/wagmi/internal/react.d.ts +90 -0
  296. package/dist/wagmi/internal/react.js +256 -0
  297. package/dist/wagmi/internal/react.js.map +1 -0
  298. package/dist/wagmi/internal/types.d.ts +10 -0
  299. package/dist/wagmi/internal/types.js +2 -0
  300. package/dist/wagmi/internal/types.js.map +1 -0
  301. package/dist/wagmi/internal/utils.d.ts +1 -0
  302. package/dist/wagmi/internal/utils.js +18 -0
  303. package/dist/wagmi/internal/utils.js.map +1 -0
  304. package/package.json +286 -34
  305. package/src/cli/Dialog.ts +75 -0
  306. package/src/cli/Messenger.ts +148 -0
  307. package/src/cli/bin/index.ts +37 -0
  308. package/src/cli/bin/tsconfig.json +8 -0
  309. package/src/cli/index.ts +2 -0
  310. package/src/cli/internal/commands.ts +212 -0
  311. package/src/cli/internal/context.ts +56 -0
  312. package/src/cli/internal/http.ts +28 -0
  313. package/src/cli/internal/utils.ts +28 -0
  314. package/src/cli/tsdown.config.ts +37 -0
  315. package/src/core/Chains.ts +25 -0
  316. package/src/core/Dialog.ts +1059 -0
  317. package/src/core/Messenger.ts +394 -0
  318. package/src/core/Mode.ts +4 -0
  319. package/src/core/Porto.ts +287 -0
  320. package/src/core/RpcSchema.ts +124 -0
  321. package/src/core/Storage.ts +122 -0
  322. package/src/core/Transport.ts +45 -0
  323. package/src/core/internal/_generated/chains.ts +2 -0
  324. package/src/core/internal/_generated/contracts/EIP7702Proxy.ts +25 -0
  325. package/src/core/internal/_generated/contracts/Escrow.ts +330 -0
  326. package/src/core/internal/_generated/contracts/ExperimentERC20.ts +569 -0
  327. package/src/core/internal/_generated/contracts/ExperimentERC721.ts +588 -0
  328. package/src/core/internal/_generated/contracts/GuardedExecutor.ts +623 -0
  329. package/src/core/internal/_generated/contracts/ICallChecker.ts +34 -0
  330. package/src/core/internal/_generated/contracts/ICommon.ts +4 -0
  331. package/src/core/internal/_generated/contracts/IEscrow.ts +114 -0
  332. package/src/core/internal/_generated/contracts/IFunder.ts +80 -0
  333. package/src/core/internal/_generated/contracts/IFunderV4.ts +45 -0
  334. package/src/core/internal/_generated/contracts/IIthacaAccount.ts +107 -0
  335. package/src/core/internal/_generated/contracts/IOAppCore.ts +142 -0
  336. package/src/core/internal/_generated/contracts/IOAppMsgInspector.ts +45 -0
  337. package/src/core/internal/_generated/contracts/IOAppReceiver.ts +161 -0
  338. package/src/core/internal/_generated/contracts/IOrchestrator.ts +95 -0
  339. package/src/core/internal/_generated/contracts/ISettler.ts +52 -0
  340. package/src/core/internal/_generated/contracts/ISigner.ts +34 -0
  341. package/src/core/internal/_generated/contracts/IthacaAccount.ts +1454 -0
  342. package/src/core/internal/_generated/contracts/IthacaAccountNew.ts +1454 -0
  343. package/src/core/internal/_generated/contracts/IthacaAccountOld.ts +1454 -0
  344. package/src/core/internal/_generated/contracts/LayerZeroSettler.ts +811 -0
  345. package/src/core/internal/_generated/contracts/LibNonce.ts +15 -0
  346. package/src/core/internal/_generated/contracts/LibTStack.ts +4 -0
  347. package/src/core/internal/_generated/contracts/MultiSigSigner.ts +203 -0
  348. package/src/core/internal/_generated/contracts/OApp.ts +412 -0
  349. package/src/core/internal/_generated/contracts/OAppCore.ts +229 -0
  350. package/src/core/internal/_generated/contracts/OAppReceiver.ts +396 -0
  351. package/src/core/internal/_generated/contracts/OAppSender.ts +245 -0
  352. package/src/core/internal/_generated/contracts/Orchestrator.ts +390 -0
  353. package/src/core/internal/_generated/contracts/SimpleFunder.ts +534 -0
  354. package/src/core/internal/_generated/contracts/SimpleSettler.ts +360 -0
  355. package/src/core/internal/_generated/contracts/Simulator.ts +170 -0
  356. package/src/core/internal/_generated/contracts/TokenTransferLib.ts +4 -0
  357. package/src/core/internal/_snapshots/provider.browser.test.ts.snap +119 -0
  358. package/src/core/internal/_snapshots/provider.test.ts.snap +1103 -0
  359. package/src/core/internal/call.test.ts +116 -0
  360. package/src/core/internal/call.ts +245 -0
  361. package/src/core/internal/erc8010.test.ts +74 -0
  362. package/src/core/internal/erc8010.ts +44 -0
  363. package/src/core/internal/intersectionObserver.ts +5 -0
  364. package/src/core/internal/logger.ts +42 -0
  365. package/src/core/internal/mode.ts +498 -0
  366. package/src/core/internal/modes/dialog.ts +1051 -0
  367. package/src/core/internal/modes/reactNative.ts +29 -0
  368. package/src/core/internal/modes/relay.ts +893 -0
  369. package/src/core/internal/permissions.ts +43 -0
  370. package/src/core/internal/permissionsRequest.ts +88 -0
  371. package/src/core/internal/porto.ts +16 -0
  372. package/src/core/internal/promise.ts +19 -0
  373. package/src/core/internal/provider.browser.test.ts +311 -0
  374. package/src/core/internal/provider.test.ts +3552 -0
  375. package/src/core/internal/provider.ts +1277 -0
  376. package/src/core/internal/relay/rpcSchema.ts +101 -0
  377. package/src/core/internal/relay/schema/capabilities.test.ts +663 -0
  378. package/src/core/internal/relay/schema/capabilities.ts +156 -0
  379. package/src/core/internal/relay/schema/intent.test.ts +433 -0
  380. package/src/core/internal/relay/schema/intent.ts +174 -0
  381. package/src/core/internal/relay/schema/key.test.ts +424 -0
  382. package/src/core/internal/relay/schema/key.ts +34 -0
  383. package/src/core/internal/relay/schema/permission.test.ts +499 -0
  384. package/src/core/internal/relay/schema/permission.ts +34 -0
  385. package/src/core/internal/relay/schema/preCall.ts +39 -0
  386. package/src/core/internal/relay/schema/quotes.test.ts +901 -0
  387. package/src/core/internal/relay/schema/quotes.ts +98 -0
  388. package/src/core/internal/relay/schema/rpc.ts +822 -0
  389. package/src/core/internal/relay/schema/token.ts +16 -0
  390. package/src/core/internal/requiredFunds.test.ts +141 -0
  391. package/src/core/internal/requiredFunds.ts +45 -0
  392. package/src/core/internal/schema/capabilities.test.ts +1334 -0
  393. package/src/core/internal/schema/capabilities.ts +162 -0
  394. package/src/core/internal/schema/key.test.ts +570 -0
  395. package/src/core/internal/schema/key.ts +98 -0
  396. package/src/core/internal/schema/permissions.test.ts +948 -0
  397. package/src/core/internal/schema/permissions.ts +31 -0
  398. package/src/core/internal/schema/request.bench.ts +35 -0
  399. package/src/core/internal/schema/request.ts +90 -0
  400. package/src/core/internal/schema/rpc.ts +821 -0
  401. package/src/core/internal/schema/token.ts +1 -0
  402. package/src/core/internal/schema/utils.test.ts +572 -0
  403. package/src/core/internal/schema/utils.ts +236 -0
  404. package/src/core/internal/siwe.test.ts +473 -0
  405. package/src/core/internal/siwe.ts +144 -0
  406. package/src/core/internal/store.ts +9 -0
  407. package/src/core/internal/tokens.test.ts +317 -0
  408. package/src/core/internal/tokens.ts +125 -0
  409. package/src/core/internal/types.ts +448 -0
  410. package/src/core/internal/urlString.ts +5 -0
  411. package/src/core/internal/userAgent.ts +35 -0
  412. package/src/core/internal/utils.test.ts +35 -0
  413. package/src/core/internal/utils.ts +67 -0
  414. package/src/core/react-native/Porto.ts +22 -0
  415. package/src/core/react-native/configure.ts +31 -0
  416. package/src/core/react-native/environment.ts +43 -0
  417. package/src/core/react-native/index.ts +4 -0
  418. package/src/core/react-native/utils.ts +18 -0
  419. package/src/index.ts +17 -0
  420. package/src/internal/index.ts +3 -0
  421. package/src/react-native/crypto.ts +19 -0
  422. package/src/react-native/index.ts +15 -0
  423. package/src/react-native/register.ts +24 -0
  424. package/src/register/index.ts +17 -0
  425. package/src/remote/Actions.ts +115 -0
  426. package/src/remote/Events.ts +193 -0
  427. package/src/remote/Hooks.ts +194 -0
  428. package/src/remote/Porto.ts +144 -0
  429. package/src/remote/index.ts +4 -0
  430. package/src/remote/internal/methodPolicies.ts +124 -0
  431. package/src/server/Route.test.ts +347 -0
  432. package/src/server/Route.ts +259 -0
  433. package/src/server/Router.test.ts +32 -0
  434. package/src/server/Router.ts +59 -0
  435. package/src/server/index.ts +2 -0
  436. package/src/server/internal/merchantSchema.ts +11 -0
  437. package/src/server/internal/requestListener.ts +284 -0
  438. package/src/theme/Theme.ts +163 -0
  439. package/src/theme/index.ts +2 -0
  440. package/src/trusted-hosts.ts +40 -0
  441. package/src/tsconfig.build.tsbuildinfo +1 -0
  442. package/src/tsconfig.json +15 -0
  443. package/src/viem/Account.test.ts +270 -0
  444. package/src/viem/Account.ts +278 -0
  445. package/src/viem/AccountActions.test.ts +3 -0
  446. package/src/viem/AccountActions.ts +30 -0
  447. package/src/viem/CapabilitiesSchema.ts +18 -0
  448. package/src/viem/ContractActions.test.ts +980 -0
  449. package/src/viem/ContractActions.ts +624 -0
  450. package/src/viem/Key.test.ts +1420 -0
  451. package/src/viem/Key.ts +1318 -0
  452. package/src/viem/RelayActions.test.ts +1730 -0
  453. package/src/viem/RelayActions.ts +1082 -0
  454. package/src/viem/RelayClient.test.ts +127 -0
  455. package/src/viem/RelayClient.ts +87 -0
  456. package/src/viem/RpcSchema.ts +27 -0
  457. package/src/viem/WalletActions.test.ts +646 -0
  458. package/src/viem/WalletActions.ts +476 -0
  459. package/src/viem/WalletClient.test.ts +36 -0
  460. package/src/viem/WalletClient.ts +74 -0
  461. package/src/viem/index.ts +13 -0
  462. package/src/viem/internal/relayActions.test.ts +1296 -0
  463. package/src/viem/internal/relayActions.ts +1222 -0
  464. package/src/viem/internal/utils.ts +27 -0
  465. package/src/wagmi/Actions.ts +13 -0
  466. package/src/wagmi/Connector.ts +304 -0
  467. package/src/wagmi/Hooks.ts +14 -0
  468. package/src/wagmi/Query.ts +5 -0
  469. package/src/wagmi/index.ts +4 -0
  470. package/src/wagmi/internal/core.test.ts +12 -0
  471. package/src/wagmi/internal/core.ts +468 -0
  472. package/src/wagmi/internal/query.ts +52 -0
  473. package/src/wagmi/internal/react.test.ts +12 -0
  474. package/src/wagmi/internal/react.ts +705 -0
  475. package/src/wagmi/internal/types.ts +21 -0
  476. package/src/wagmi/internal/utils.ts +25 -0
  477. package/dist/chain.cjs +0 -17
  478. package/dist/chain.d.cts +0 -41
  479. package/dist/chain.d.ts +0 -41
  480. package/dist/chain.js +0 -13
  481. package/dist/config.cjs +0 -19
  482. package/dist/config.d.cts +0 -3
  483. package/dist/config.d.ts +0 -3
  484. package/dist/config.js +0 -16
  485. package/dist/index.cjs +0 -18
  486. package/dist/index.d.cts +0 -2
@@ -0,0 +1,144 @@
1
+ import type * as RpcRequest from 'ox/RpcRequest'
2
+ import { createStore, type StoreApi } from 'zustand/vanilla'
3
+
4
+ import type * as Chains from '../core/Chains.js'
5
+ import type { ExactPartial, OneOf } from '../core/internal/types.js'
6
+ import * as Messenger from '../core/Messenger.js'
7
+ import * as Mode from '../core/Mode.js'
8
+ import * as Porto_ from '../core/Porto.js'
9
+ import type * as RpcSchema from '../core/RpcSchema.js'
10
+ import * as Storage from '../core/Storage.js'
11
+ import { hostnames } from '../trusted-hosts.js'
12
+ import * as MethodPolicies from './internal/methodPolicies.js'
13
+
14
+ const messenger = (() => {
15
+ if (typeof window === 'undefined') return Messenger.noop()
16
+
17
+ const url = new URL(window.location.href)
18
+ const relayUrl = url.searchParams.get('relayUrl')
19
+ if (relayUrl) return Messenger.cliRelay({ relayUrl })
20
+
21
+ return Messenger.bridge({
22
+ from: Messenger.fromWindow(window),
23
+ to: Messenger.fromWindow(window.opener ?? window.parent),
24
+ })
25
+ })() as Messenger.Bridge | Messenger.Messenger
26
+
27
+ export const defaultConfig = {
28
+ ...Porto_.defaultConfig,
29
+ messenger,
30
+ methodPolicies: MethodPolicies.methodPolicies,
31
+ mode: Mode.relay(),
32
+ storage: Storage.localStorage(),
33
+ trustedHosts: hostnames,
34
+ } as const satisfies Partial<Config>
35
+
36
+ /**
37
+ * Instantiates an Porto instance to be used in a remote context (e.g. an iframe or popup).
38
+ *
39
+ * @example
40
+ * ```ts twoslash
41
+ * import { Porto } from 'porto/remote'
42
+ * const porto = Porto.create()
43
+ * ```
44
+ */
45
+ export function create<
46
+ const chains extends readonly [
47
+ Chains.Chain,
48
+ ...Chains.Chain[],
49
+ ] = typeof defaultConfig.chains,
50
+ >(parameters?: ExactPartial<Config<chains>> | undefined): Porto<chains>
51
+ export function create(
52
+ parameters: ExactPartial<Config> | undefined = {},
53
+ ): Porto {
54
+ const {
55
+ chains = defaultConfig.chains,
56
+ feeToken,
57
+ mode = defaultConfig.mode,
58
+ messenger = defaultConfig.messenger,
59
+ methodPolicies = defaultConfig.methodPolicies,
60
+ merchantUrl,
61
+ relay = defaultConfig.relay,
62
+ storage = defaultConfig.storage,
63
+ storageKey = defaultConfig.storageKey,
64
+ transports,
65
+ trustedHosts = defaultConfig.trustedHosts,
66
+ } = parameters
67
+
68
+ const porto = Porto_.create({
69
+ announceProvider: false,
70
+ chains,
71
+ feeToken,
72
+ merchantUrl,
73
+ mode,
74
+ relay,
75
+ storage,
76
+ storageKey,
77
+ transports,
78
+ })
79
+
80
+ const remoteStore = createStore<RemoteState>(() => ({
81
+ requests: [],
82
+ }))
83
+
84
+ return {
85
+ ...porto,
86
+ _internal: {
87
+ ...porto._internal,
88
+ remoteStore,
89
+ },
90
+ messenger,
91
+ methodPolicies,
92
+ mode,
93
+ async ready() {
94
+ await porto._internal.store.persist.rehydrate()
95
+ const { chainIds } = porto._internal.store.getState()
96
+
97
+ if (!('ready' in messenger)) return
98
+ return (messenger as Messenger.WithReady).ready({
99
+ chainIds,
100
+ methodPolicies,
101
+ trustedHosts,
102
+ })
103
+ },
104
+ } as unknown as Porto
105
+ }
106
+
107
+ export type Porto<
108
+ chains extends readonly [Chains.Chain, ...Chains.Chain[]] = readonly [
109
+ Chains.Chain,
110
+ ...Chains.Chain[],
111
+ ],
112
+ > = Porto_.Porto<chains> & {
113
+ mode: Mode.Mode
114
+ messenger: OneOf<Messenger.WithReady | Messenger.Messenger>
115
+ methodPolicies?: MethodPolicies.MethodPolicies | undefined
116
+ ready: () => Promise<void>
117
+ _internal: Porto_.Porto<chains>['_internal'] & {
118
+ remoteStore: StoreApi<RemoteState>
119
+ }
120
+ }
121
+
122
+ export type Config<
123
+ chains extends readonly [Chains.Chain, ...Chains.Chain[]] = readonly [
124
+ Chains.Chain,
125
+ ...Chains.Chain[],
126
+ ],
127
+ > = Porto_.Config<chains> & {
128
+ messenger?: OneOf<Messenger.Bridge | Messenger.Messenger> | undefined
129
+ methodPolicies?: MethodPolicies.MethodPolicies | undefined
130
+ trustedHosts?: string[] | undefined
131
+ }
132
+
133
+ export type State<
134
+ chains extends readonly [Chains.Chain, ...Chains.Chain[]] = readonly [
135
+ Chains.Chain,
136
+ ...Chains.Chain[],
137
+ ],
138
+ > = Porto_.State<chains>
139
+
140
+ export type RemoteState = {
141
+ requests: readonly (Porto_.QueuedRequest & {
142
+ request: RpcRequest.RpcRequest<RpcSchema.Schema>
143
+ })[]
144
+ }
@@ -0,0 +1,4 @@
1
+ export * as Actions from './Actions.js'
2
+ export * as Events from './Events.js'
3
+ export * as Hooks from './Hooks.js'
4
+ export * as Porto from './Porto.js'
@@ -0,0 +1,124 @@
1
+ import * as UserAgent from '../../core/internal/userAgent.js'
2
+
3
+ export type MethodPolicy = {
4
+ method: string
5
+ modes?:
6
+ | {
7
+ headless?:
8
+ | true
9
+ | {
10
+ sameOrigin?: boolean | undefined
11
+ }
12
+ | undefined
13
+ dialog?:
14
+ | true
15
+ | {
16
+ sameOrigin?: boolean | undefined
17
+ }
18
+ | undefined
19
+ }
20
+ | undefined
21
+ requireConnection?: boolean | undefined
22
+ }
23
+ export type MethodPolicies = readonly MethodPolicy[]
24
+
25
+ export const methodPolicies = [
26
+ {
27
+ method: 'eth_requestAccounts',
28
+ modes: {
29
+ dialog: true,
30
+ headless: {
31
+ sameOrigin: true,
32
+ },
33
+ },
34
+ requireConnection: false,
35
+ },
36
+ {
37
+ method: 'wallet_getAccountVersion',
38
+ modes: {
39
+ headless: true,
40
+ },
41
+ },
42
+ {
43
+ method: 'wallet_getKeys',
44
+ modes: {
45
+ headless: true,
46
+ },
47
+ },
48
+ {
49
+ method: 'wallet_getPermissions',
50
+ modes: {
51
+ headless: true,
52
+ },
53
+ },
54
+ {
55
+ method: 'wallet_grantAdmin',
56
+ modes: {
57
+ dialog: {
58
+ sameOrigin: true,
59
+ },
60
+ },
61
+ },
62
+ {
63
+ method: 'wallet_revokeAdmin',
64
+ modes: {
65
+ dialog: {
66
+ sameOrigin: true,
67
+ },
68
+ },
69
+ },
70
+ {
71
+ method: 'wallet_upgradeAccount',
72
+ modes: {
73
+ headless: true,
74
+ },
75
+ },
76
+ {
77
+ method: 'wallet_connect',
78
+ modes: {
79
+ dialog: true,
80
+ headless: !UserAgent.isSafari()
81
+ ? {
82
+ sameOrigin: true,
83
+ }
84
+ : undefined,
85
+ },
86
+ requireConnection: false,
87
+ },
88
+ {
89
+ method: 'wallet_getAssets',
90
+ modes: {
91
+ headless: true,
92
+ },
93
+ },
94
+ {
95
+ method: 'wallet_getCallsStatus',
96
+ modes: {
97
+ headless: true,
98
+ },
99
+ },
100
+ {
101
+ method: 'wallet_getCapabilities',
102
+ modes: {
103
+ headless: true,
104
+ },
105
+ },
106
+ {
107
+ method: 'wallet_prepareCalls',
108
+ modes: {
109
+ headless: true,
110
+ },
111
+ },
112
+ {
113
+ method: 'wallet_sendPreparedCalls',
114
+ modes: {
115
+ headless: true,
116
+ },
117
+ },
118
+ {
119
+ method: 'wallet_switchEthereumChain',
120
+ modes: {
121
+ headless: true,
122
+ },
123
+ },
124
+ ] as const satisfies MethodPolicies
@@ -0,0 +1,347 @@
1
+ import { Hex, Value } from 'ox'
2
+ import { Key } from 'porto'
3
+ import { Route } from 'porto/server'
4
+ import { readContract, waitForCallsStatus } from 'viem/actions'
5
+ import { describe, expect, test } from 'vitest'
6
+ import * as TestActions from '../../test/src/actions.js'
7
+ import * as TestConfig from '../../test/src/config.js'
8
+ import * as Http from '../../test/src/http.js'
9
+ import type { ExactPartial } from '../core/internal/types.js'
10
+ import * as RelayActions from '../viem/RelayActions.js'
11
+
12
+ const porto = TestConfig.getPorto()
13
+ const client = TestConfig.getRelayClient(porto)
14
+ const contracts = await TestConfig.getContracts(porto)
15
+
16
+ describe('merchant', () => {
17
+ let server: Http.Server | undefined
18
+ async function setup(options: ExactPartial<Route.merchant.Options> = {}) {
19
+ const merchantKey = Key.createSecp256k1()
20
+ const merchantAccount = await TestActions.createAccount(client, {
21
+ deploy: true,
22
+ keys: [merchantKey],
23
+ })
24
+
25
+ const route = Route.merchant({
26
+ ...porto.config,
27
+ ...options,
28
+ address: merchantAccount.address,
29
+ key: merchantKey.privateKey!(),
30
+ })
31
+
32
+ if (server) await server.closeAsync()
33
+ server = await Http.createServer(route.listener)
34
+
35
+ return { merchantAccount, route, server }
36
+ }
37
+
38
+ test('behavior: simple sponsor', async () => {
39
+ const { server, merchantAccount } = await setup()
40
+
41
+ const userKey = Key.createHeadlessWebAuthnP256()
42
+ const userAccount = await TestActions.createAccount(client, {
43
+ keys: [userKey],
44
+ })
45
+
46
+ const userBalance_pre = await readContract(client, {
47
+ ...contracts.exp1,
48
+ args: [userAccount.address],
49
+ functionName: 'balanceOf',
50
+ })
51
+ const merchantBalance_pre = await readContract(client, {
52
+ ...contracts.exp1,
53
+ args: [merchantAccount.address],
54
+ functionName: 'balanceOf',
55
+ })
56
+
57
+ const result = await RelayActions.sendCalls(client, {
58
+ account: userAccount,
59
+ calls: [
60
+ {
61
+ abi: contracts.exp1.abi,
62
+ args: [userAccount.address, Value.fromEther('1')],
63
+ functionName: 'mint',
64
+ to: contracts.exp1.address,
65
+ },
66
+ ],
67
+ merchantUrl: server.url,
68
+ })
69
+
70
+ await waitForCallsStatus(client, {
71
+ id: result.id,
72
+ })
73
+
74
+ const userBalance_post = await readContract(client, {
75
+ ...contracts.exp1,
76
+ args: [userAccount.address],
77
+ functionName: 'balanceOf',
78
+ })
79
+ const merchantBalance_post = await readContract(client, {
80
+ ...contracts.exp1,
81
+ args: [merchantAccount.address],
82
+ functionName: 'balanceOf',
83
+ })
84
+
85
+ // Check if user was credited with 1 EXP.
86
+ expect(userBalance_post).toBe(userBalance_pre + Value.fromEther('1'))
87
+
88
+ // Check if merchant was debited the fee payment.
89
+ expect(merchantBalance_post).toBeLessThan(merchantBalance_pre)
90
+ })
91
+
92
+ test('behavior: conditional sponsoring', async () => {
93
+ const { server, merchantAccount } = await setup({
94
+ sponsor: (request) =>
95
+ // Only sponsor calls targeting the exp1Address
96
+ request.calls.every((call) => call.to === contracts.exp1.address),
97
+ })
98
+
99
+ const userKey = Key.createHeadlessWebAuthnP256()
100
+ const userAccount = await TestActions.createAccount(client, {
101
+ keys: [userKey],
102
+ })
103
+
104
+ {
105
+ // Test 1: Calls satisfy the sponsor condition.
106
+ const userBalance_pre = await readContract(client, {
107
+ ...contracts.exp1,
108
+ args: [userAccount.address],
109
+ functionName: 'balanceOf',
110
+ })
111
+ const merchantBalance_pre = await readContract(client, {
112
+ ...contracts.exp1,
113
+ args: [merchantAccount.address],
114
+ functionName: 'balanceOf',
115
+ })
116
+
117
+ const result = await RelayActions.sendCalls(client, {
118
+ account: userAccount,
119
+ calls: [
120
+ {
121
+ abi: contracts.exp1.abi,
122
+ args: [userAccount.address, Value.fromEther('1')],
123
+ functionName: 'mint',
124
+ to: contracts.exp1.address,
125
+ },
126
+ ],
127
+ merchantUrl: server.url,
128
+ })
129
+
130
+ await waitForCallsStatus(client, {
131
+ id: result.id,
132
+ })
133
+
134
+ const userBalance_post = await readContract(client, {
135
+ ...contracts.exp1,
136
+ args: [userAccount.address],
137
+ functionName: 'balanceOf',
138
+ })
139
+ const merchantBalance_post = await readContract(client, {
140
+ ...contracts.exp1,
141
+ args: [merchantAccount.address],
142
+ functionName: 'balanceOf',
143
+ })
144
+
145
+ // Check if user was credited with 1 EXP.
146
+ expect(userBalance_post).toBe(userBalance_pre + Value.fromEther('1'))
147
+
148
+ // Check if merchant was debited the fee payment.
149
+ expect(merchantBalance_post).toBeLessThan(merchantBalance_pre)
150
+ }
151
+
152
+ {
153
+ // Test 2: Calls do not satisfy the sponsor condition.
154
+ const userBalance_pre = await readContract(client, {
155
+ ...contracts.exp2,
156
+ args: [userAccount.address],
157
+ functionName: 'balanceOf',
158
+ })
159
+ const merchantBalance_pre = await readContract(client, {
160
+ ...contracts.exp1,
161
+ args: [merchantAccount.address],
162
+ functionName: 'balanceOf',
163
+ })
164
+
165
+ const result = await RelayActions.sendCalls(client, {
166
+ account: userAccount,
167
+ calls: [
168
+ {
169
+ abi: contracts.exp2.abi,
170
+ args: [userAccount.address, Value.fromEther('1')],
171
+ functionName: 'mint',
172
+ to: contracts.exp2.address,
173
+ },
174
+ ],
175
+ merchantUrl: server.url,
176
+ })
177
+
178
+ await waitForCallsStatus(client, {
179
+ id: result.id,
180
+ })
181
+
182
+ const userBalance_post = await readContract(client, {
183
+ ...contracts.exp2,
184
+ args: [userAccount.address],
185
+ functionName: 'balanceOf',
186
+ })
187
+ const merchantBalance_post = await readContract(client, {
188
+ ...contracts.exp1,
189
+ args: [merchantAccount.address],
190
+ functionName: 'balanceOf',
191
+ })
192
+
193
+ // Check if user was credited with 1 EXP.
194
+ expect(userBalance_post).toBe(userBalance_pre + Value.fromEther('1'))
195
+
196
+ // Check if merchant was NOT debited the fee payment.
197
+ expect(merchantBalance_post).toEqual(merchantBalance_pre)
198
+ }
199
+ })
200
+
201
+ // TODO: unskip when merchant account works with interop
202
+ test.skip('behavior: sponsor w/ required funds', async () => {
203
+ const { server, merchantAccount } = await setup()
204
+
205
+ const chain_dest = TestConfig.chains[1]
206
+ const client_dest = TestConfig.getRelayClient(porto, {
207
+ chainId: chain_dest!.id,
208
+ })
209
+
210
+ // Deploy merchant account on destination chain.
211
+ const { id } = await RelayActions.sendCalls(client_dest, {
212
+ account: merchantAccount,
213
+ calls: [],
214
+ })
215
+ await waitForCallsStatus(client_dest, {
216
+ id,
217
+ })
218
+
219
+ await TestActions.setBalance(client_dest, {
220
+ address: merchantAccount.address,
221
+ })
222
+
223
+ const userKey = Key.createHeadlessWebAuthnP256()
224
+ const userAccount = await TestActions.createAccount(client, {
225
+ keys: [userKey],
226
+ })
227
+
228
+ const userBalance_pre = await readContract(client, {
229
+ ...contracts.exp1,
230
+ args: [userAccount.address],
231
+ functionName: 'balanceOf',
232
+ })
233
+ const merchantBalance_pre = await readContract(client, {
234
+ ...contracts.exp1,
235
+ args: [merchantAccount.address],
236
+ functionName: 'balanceOf',
237
+ })
238
+
239
+ const alice = Hex.random(20)
240
+
241
+ const result = await RelayActions.sendCalls(client, {
242
+ account: userAccount,
243
+ calls: [
244
+ {
245
+ abi: contracts.exp1.abi,
246
+ args: [alice, Value.fromEther('50')],
247
+ functionName: 'transfer',
248
+ to: contracts.exp1.address,
249
+ },
250
+ ],
251
+ chain: chain_dest,
252
+ merchantUrl: server.url,
253
+ requiredFunds: [
254
+ {
255
+ address: contracts.exp1.address,
256
+ value: Value.fromEther('50'),
257
+ },
258
+ ],
259
+ })
260
+
261
+ await waitForCallsStatus(client, {
262
+ id: result.id,
263
+ })
264
+
265
+ const userBalance_post = await readContract(client, {
266
+ ...contracts.exp1,
267
+ args: [userAccount.address],
268
+ functionName: 'balanceOf',
269
+ })
270
+ const merchantBalance_post = await readContract(client, {
271
+ ...contracts.exp1,
272
+ args: [merchantAccount.address],
273
+ functionName: 'balanceOf',
274
+ })
275
+
276
+ // Check if user was credited with 1 EXP.
277
+ expect(userBalance_post).toBeLessThanOrEqual(
278
+ userBalance_pre - Value.fromEther('50'),
279
+ )
280
+
281
+ // Check if merchant was debited the fee payment.
282
+ expect(merchantBalance_post).toBeLessThan(merchantBalance_pre)
283
+ })
284
+
285
+ test('behavior: route response (GET)', async () => {
286
+ const { route } = await setup()
287
+
288
+ const response = await route.hono.request('http://localhost')
289
+ expect(response.status).toBe(200)
290
+ expect(response.headers.get('access-control-allow-origin')).toBe('*')
291
+ expect(await response.text()).toBe('ok')
292
+ })
293
+
294
+ test('error: contract error', async () => {
295
+ const { server } = await setup()
296
+
297
+ const userKey = Key.createHeadlessWebAuthnP256()
298
+ const userAccount = await TestActions.createAccount(client, {
299
+ keys: [userKey],
300
+ })
301
+
302
+ await expect(() =>
303
+ RelayActions.sendCalls(client, {
304
+ account: userAccount,
305
+ calls: [
306
+ {
307
+ abi: contracts.exp1.abi,
308
+ args: [
309
+ '0x0000000000000000000000000000000000000000',
310
+ userAccount.address,
311
+ Value.fromEther('1'),
312
+ ],
313
+ functionName: 'transferFrom',
314
+ to: contracts.exp1.address,
315
+ },
316
+ ],
317
+ merchantUrl: server.url,
318
+ }),
319
+ ).rejects.toThrowError('InsufficientAllowance')
320
+ })
321
+
322
+ test('error: invalid params', async () => {
323
+ const { server } = await setup()
324
+
325
+ const response = await fetch(server.url, {
326
+ body: JSON.stringify({
327
+ id: 1,
328
+ jsonrpc: '2.0',
329
+ method: 'wallet_prepareCalls',
330
+ params: ['foo'],
331
+ }),
332
+ method: 'POST',
333
+ }).then((r) => r.json())
334
+ expect(response).toMatchInlineSnapshot(`
335
+ {
336
+ "error": {
337
+ "code": -32602,
338
+ "message": "Validation failed with 1 error:
339
+
340
+ - at \`params[0]\`: Expected object. ",
341
+ },
342
+ "id": 1,
343
+ "jsonrpc": "2.0",
344
+ }
345
+ `)
346
+ })
347
+ })