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,116 @@
1
+ import { describe, expect, test } from 'vitest'
2
+ import * as Key from '../../viem/Key.js'
3
+ import * as Call from './call.js'
4
+
5
+ describe('authorize', () => {
6
+ test('default', () => {
7
+ const key = Key.fromP256({
8
+ privateKey:
9
+ '0x59ff6b8de3b3b39e94b6f9fc0590cf4e3eaa9b6736e6a49c9a6b324c4f58cb9f',
10
+ })
11
+
12
+ const call = Call.authorize({
13
+ key,
14
+ })
15
+
16
+ expect(call).toMatchInlineSnapshot(`
17
+ {
18
+ "data": "0xcebfe336000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000040ec0effa5f2f378cbf7fd2fa7ca1e8dc51cf777c129fa1c00a0e9a9205f2e511ff3f20b34a4e0b50587d055c0e0fad33d32cf1147d3bb2538fbab0d15d8e65008",
19
+ "to": "0x2323232323232323232323232323232323232323",
20
+ }
21
+ `)
22
+ })
23
+ })
24
+
25
+ describe('setCanExecute', () => {
26
+ test('default', () => {
27
+ const call = Call.setCanExecute()
28
+
29
+ expect(call).toMatchInlineSnapshot(`
30
+ {
31
+ "data": "0x136a12f73232323232323232323232323232323232323232323232323232323232323232000000000000000000000000323232323232323232323232323232323232323232323232000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001",
32
+ "to": "0x2323232323232323232323232323232323232323",
33
+ }
34
+ `)
35
+ })
36
+
37
+ test('args: enabled', () => {
38
+ const call = Call.setCanExecute({ enabled: false })
39
+
40
+ expect(call).toMatchInlineSnapshot(`
41
+ {
42
+ "data": "0x136a12f73232323232323232323232323232323232323232323232323232323232323232000000000000000000000000323232323232323232323232323232323232323232323232000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
43
+ "to": "0x2323232323232323232323232323232323232323",
44
+ }
45
+ `)
46
+ })
47
+
48
+ test('args: key', () => {
49
+ const key = Key.fromP256({
50
+ privateKey:
51
+ '0x59ff6b8de3b3b39e94b6f9fc0590cf4e3eaa9b6736e6a49c9a6b324c4f58cb9f',
52
+ })
53
+
54
+ const call = Call.setCanExecute({ key })
55
+
56
+ expect(call).toMatchInlineSnapshot(`
57
+ {
58
+ "data": "0x136a12f7ed7ac7c7b35b77e97be67b84f5889e0ab3ecc69ab65d57db191e11f8811e9965000000000000000000000000323232323232323232323232323232323232323232323232000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001",
59
+ "to": "0x2323232323232323232323232323232323232323",
60
+ }
61
+ `)
62
+ })
63
+
64
+ test('args: to', () => {
65
+ const key = Key.fromP256({
66
+ privateKey:
67
+ '0x59ff6b8de3b3b39e94b6f9fc0590cf4e3eaa9b6736e6a49c9a6b324c4f58cb9f',
68
+ })
69
+
70
+ const call = Call.setCanExecute({
71
+ key,
72
+ to: '0x0000000000000000000000000000000000000000',
73
+ })
74
+
75
+ expect(call).toMatchInlineSnapshot(`
76
+ {
77
+ "data": "0x136a12f7ed7ac7c7b35b77e97be67b84f5889e0ab3ecc69ab65d57db191e11f8811e9965000000000000000000000000000000000000000000000000000000000000000032323232000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001",
78
+ "to": "0x2323232323232323232323232323232323232323",
79
+ }
80
+ `)
81
+ })
82
+
83
+ test('args: selector', () => {
84
+ const key = Key.fromP256({
85
+ privateKey:
86
+ '0x59ff6b8de3b3b39e94b6f9fc0590cf4e3eaa9b6736e6a49c9a6b324c4f58cb9f',
87
+ })
88
+
89
+ const call = Call.setCanExecute({
90
+ key,
91
+ selector: '0xdeadbeef',
92
+ })
93
+
94
+ expect(call).toMatchInlineSnapshot(`
95
+ {
96
+ "data": "0x136a12f7ed7ac7c7b35b77e97be67b84f5889e0ab3ecc69ab65d57db191e11f8811e99650000000000000000000000003232323232323232323232323232323232323232deadbeef000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001",
97
+ "to": "0x2323232323232323232323232323232323232323",
98
+ }
99
+ `)
100
+ })
101
+ })
102
+
103
+ describe('setLabel', () => {
104
+ test('default', () => {
105
+ const call = Call.setLabel({
106
+ label: 'test',
107
+ })
108
+
109
+ expect(call).toMatchInlineSnapshot(`
110
+ {
111
+ "data": "0xbf530969000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000047465737400000000000000000000000000000000000000000000000000000000",
112
+ "to": "0x2323232323232323232323232323232323232323",
113
+ }
114
+ `)
115
+ })
116
+ })
@@ -0,0 +1,245 @@
1
+ import * as AbiFunction from 'ox/AbiFunction'
2
+ import type * as Address from 'ox/Address'
3
+ import type * as Hex from 'ox/Hex'
4
+ import * as Key from '../../viem/Key.js'
5
+ import * as IthacaAccount from './_generated/contracts/IthacaAccount.js'
6
+
7
+ /** Stub address for self-execution. */
8
+ export const selfAddress = '0x2323232323232323232323232323232323232323'
9
+
10
+ export type Call = {
11
+ to: Address.Address
12
+ value?: bigint | undefined
13
+ data?: Hex.Hex | undefined
14
+ }
15
+
16
+ /**
17
+ * Instantiates values to populate a call to authorize a key.
18
+ *
19
+ * @param parameters - Parameters.
20
+ * @returns Instantiated values.
21
+ */
22
+ export function authorize(parameters: authorize.Parameters) {
23
+ const { key } = parameters
24
+ return {
25
+ data: AbiFunction.encodeData(
26
+ AbiFunction.fromAbi(IthacaAccount.abi, 'authorize'),
27
+ [Key.serialize(key)],
28
+ ),
29
+ to: selfAddress,
30
+ } as const satisfies Call
31
+ }
32
+
33
+ export declare namespace authorize {
34
+ export type Parameters = {
35
+ /** Key to authorize. */
36
+ key: Key.Key
37
+ }
38
+ }
39
+
40
+ export const anyHash =
41
+ '0x3232323232323232323232323232323232323232323232323232323232323232'
42
+ export const anyTarget = '0x3232323232323232323232323232323232323232'
43
+ export const anySelector = '0x32323232'
44
+
45
+ /**
46
+ * Instantiates values to populate a call to set the label of a delegated account.
47
+ *
48
+ * @param parameters - Parameters.
49
+ * @returns Instantiated values.
50
+ */
51
+ export function setCanExecute(parameters: setCanExecute.Parameters = {}) {
52
+ const {
53
+ enabled = true,
54
+ key,
55
+ selector = anySelector,
56
+ to = anyTarget,
57
+ } = parameters
58
+ const hash = key ? key.hash : anyHash
59
+
60
+ return {
61
+ data: AbiFunction.encodeData(
62
+ AbiFunction.fromAbi(IthacaAccount.abi, 'setCanExecute'),
63
+ [hash, to, selector, enabled],
64
+ ),
65
+ to: selfAddress,
66
+ } as const satisfies Call
67
+ }
68
+
69
+ export declare namespace setCanExecute {
70
+ export type Parameters = {
71
+ /** Whether to enable execution. */
72
+ enabled?: boolean | undefined
73
+ /** Key to authorize. */
74
+ key?: Key.Key | undefined
75
+ /** Target to authorize. */
76
+ to?: Address.Address | undefined
77
+ /** Function selector to authorize. */
78
+ selector?: Hex.Hex | undefined
79
+ }
80
+ }
81
+
82
+ /**
83
+ * Instantiates values to populate a call to set the label of a delegated account.
84
+ *
85
+ * @param parameters - Parameters.
86
+ * @returns Instantiated values.
87
+ */
88
+ export function setLabel(parameters: setLabel.Parameters) {
89
+ const { label } = parameters
90
+ return {
91
+ data: AbiFunction.encodeData(
92
+ AbiFunction.fromAbi(IthacaAccount.abi, 'setLabel'),
93
+ [label],
94
+ ),
95
+ to: selfAddress,
96
+ } as const satisfies Call
97
+ }
98
+
99
+ export declare namespace setLabel {
100
+ export type Parameters = {
101
+ /** Label to set. */
102
+ label: string
103
+ }
104
+ }
105
+
106
+ /**
107
+ * Instantiates values to populate a call to set the spend limit of a key.
108
+ *
109
+ * @param parameters - Parameters.
110
+ * @returns Instantiated values.
111
+ */
112
+ export function setSpendLimit(parameters: setSpendLimit.Parameters) {
113
+ const { key, period, limit } = parameters
114
+ const token = parameters.token ?? '0x0000000000000000000000000000000000000000'
115
+ return {
116
+ data: AbiFunction.encodeData(
117
+ AbiFunction.fromAbi(IthacaAccount.abi, 'setSpendLimit'),
118
+ [key.hash, token, Key.toSerializedSpendPeriod[period], limit],
119
+ ),
120
+ to: selfAddress,
121
+ } as const satisfies Call
122
+ }
123
+
124
+ export declare namespace setSpendLimit {
125
+ export type Parameters = {
126
+ /** Key to set the spend limit of. */
127
+ key: Key.Key
128
+ /** Limit to set. */
129
+ limit: bigint
130
+ /** Period to set. */
131
+ period: 'minute' | 'hour' | 'day' | 'week' | 'month' | 'year'
132
+ /** Token to set. */
133
+ token?: Address.Address | undefined
134
+ }
135
+ }
136
+
137
+ /**
138
+ * Instantiates values to populate a call to set the signature checker approval of a key.
139
+ *
140
+ * @param parameters - Parameters.
141
+ * @returns Instantiated values.
142
+ */
143
+ export function setSignatureCheckerApproval(
144
+ parameters: setSignatureCheckerApproval.Parameters,
145
+ ) {
146
+ const { address, key, enabled } = parameters
147
+ return {
148
+ data: AbiFunction.encodeData(
149
+ AbiFunction.fromAbi(IthacaAccount.abi, 'setSignatureCheckerApproval'),
150
+ [key.hash, address, enabled],
151
+ ),
152
+ to: selfAddress,
153
+ } as const satisfies Call
154
+ }
155
+
156
+ export declare namespace setSignatureCheckerApproval {
157
+ export type Parameters = {
158
+ /** Contract address to authorize. */
159
+ address: Address.Address
160
+ /** Whether the key can verify signatures. */
161
+ enabled: boolean
162
+ /** Key to apply the signature verification to. */
163
+ key: Key.Key
164
+ }
165
+ }
166
+
167
+ /**
168
+ * Instantiates values to populate a call to remove the spend limit of a key.
169
+ *
170
+ * @param parameters - Parameters.
171
+ * @returns Instantiated values.
172
+ */
173
+ export function removeSpendLimit(parameters: removeSpendLimit.Parameters) {
174
+ const { key, token, period } = parameters
175
+ return {
176
+ data: AbiFunction.encodeData(
177
+ AbiFunction.fromAbi(IthacaAccount.abi, 'removeSpendLimit'),
178
+ [key.hash, token, Key.toSerializedSpendPeriod[period]],
179
+ ),
180
+ to: selfAddress,
181
+ } as const satisfies Call
182
+ }
183
+
184
+ export declare namespace removeSpendLimit {
185
+ export type Parameters = {
186
+ /** Key to set the spend limit of. */
187
+ key: Key.Key
188
+ /** Period to set. */
189
+ period: 'minute' | 'hour' | 'day' | 'week' | 'month' | 'year'
190
+ /** Token to set. */
191
+ token: Address.Address
192
+ }
193
+ }
194
+
195
+ /**
196
+ * Instantiates values to populate a call to revoke a key.
197
+ *
198
+ * @param parameters - Parameters.
199
+ * @returns Instantiated values.
200
+ */
201
+ export function revoke(parameters: revoke.Parameters) {
202
+ const { keyHash } = parameters
203
+ return {
204
+ data: AbiFunction.encodeData(
205
+ AbiFunction.fromAbi(IthacaAccount.abi, 'revoke'),
206
+ [keyHash],
207
+ ),
208
+ to: selfAddress,
209
+ } as const satisfies Call
210
+ }
211
+
212
+ export declare namespace revoke {
213
+ export type Parameters = {
214
+ /** Key hash to revoke. */
215
+ keyHash: Hex.Hex
216
+ }
217
+ }
218
+
219
+ /**
220
+ * Instantiates values to populate a call to upgrade the proxy account.
221
+ *
222
+ * @param parameters - Parameters.
223
+ * @returns Instantiated values.
224
+ */
225
+ export function upgradeProxyAccount(
226
+ parameters: upgradeProxyAccount.Parameters,
227
+ ) {
228
+ const { address, to = selfAddress } = parameters
229
+ return {
230
+ data: AbiFunction.encodeData(
231
+ AbiFunction.fromAbi(IthacaAccount.abi, 'upgradeProxyAccount'),
232
+ [address],
233
+ ),
234
+ to,
235
+ } as const satisfies Call
236
+ }
237
+
238
+ export declare namespace upgradeProxyAccount {
239
+ export type Parameters = {
240
+ /** The account to upgrade to. */
241
+ address: Address.Address
242
+ /** The address to upgrade the address to. */
243
+ to?: Address.Address | undefined
244
+ }
245
+ }
@@ -0,0 +1,74 @@
1
+ import { Hex } from 'ox'
2
+ import { SignatureErc8010 } from 'ox/erc8010'
3
+ import { verifyHash } from 'viem/actions'
4
+ import { describe, expect, test } from 'vitest'
5
+ import * as TestActions from '../../../test/src/actions.js'
6
+ import * as TestConfig from '../../../test/src/config.js'
7
+ import * as Account from '../../viem/Account.js'
8
+ import * as Key from '../../viem/Key.js'
9
+ import * as Erc8010 from './erc8010.js'
10
+
11
+ const porto = TestConfig.getPorto()
12
+ const client = TestConfig.getRelayClient(porto)
13
+
14
+ describe('wrap', () => {
15
+ test('default', async () => {
16
+ const key = Key.createHeadlessWebAuthnP256()
17
+ const account = await TestActions.createAccount(client, {
18
+ keys: [key],
19
+ })
20
+
21
+ const digest = Hex.random(32)
22
+
23
+ const signature = await Account.sign(account, {
24
+ payload: digest,
25
+ })
26
+
27
+ const wrapped = await Erc8010.wrap(client, {
28
+ address: account.address,
29
+ signature,
30
+ })
31
+ expect(SignatureErc8010.validate(wrapped)).toBe(true)
32
+ })
33
+ })
34
+
35
+ describe('e2e', async () => {
36
+ test.each([
37
+ {
38
+ delegated: false,
39
+ key: Key.createHeadlessWebAuthnP256(),
40
+ type: 'webauthn-p256',
41
+ },
42
+ {
43
+ delegated: true,
44
+ key: Key.createHeadlessWebAuthnP256(),
45
+ type: 'webauthn-p256',
46
+ },
47
+ { delegated: false, key: Key.createSecp256k1(), type: 'secp256k1' },
48
+ { delegated: true, key: Key.createSecp256k1(), type: 'secp256k1' },
49
+ ])('type: $type, delegated: $delegated', async ({ key, delegated }) => {
50
+ const account = await TestActions.createAccount(client, {
51
+ deploy: delegated,
52
+ keys: [key],
53
+ })
54
+
55
+ const digest = Hex.random(32)
56
+
57
+ const signature = await Account.sign(account, {
58
+ payload: digest,
59
+ })
60
+
61
+ const wrapped = await Erc8010.wrap(client, {
62
+ address: account.address,
63
+ signature,
64
+ })
65
+ expect(SignatureErc8010.validate(wrapped)).toBe(true)
66
+
67
+ const valid = await verifyHash(client, {
68
+ address: account.address,
69
+ hash: digest,
70
+ signature: wrapped,
71
+ })
72
+ expect(valid).toBe(true)
73
+ })
74
+ })
@@ -0,0 +1,44 @@
1
+ import type * as Address from 'ox/Address'
2
+ import * as SignatureErc8010 from 'ox/erc8010/SignatureErc8010'
3
+ import type * as Hex from 'ox/Hex'
4
+ import type { Client } from 'viem'
5
+ import * as RelayActions from '../../viem/RelayActions.js'
6
+
7
+ /**
8
+ * Wraps a signature in ERC-8010 format to enable pre-delegated signature verification.
9
+ *
10
+ * @param client - The client to use.
11
+ * @param parameters - The parameters for the wrap function.
12
+ * @returns The wrapped signature.
13
+ */
14
+ export async function wrap(client: Client, parameters: wrap.Parameters) {
15
+ const { address } = parameters
16
+
17
+ // Obtain the account's authorization and init data.
18
+ const { authorization, data, to } = await RelayActions.getAuthorization(
19
+ client,
20
+ {
21
+ address,
22
+ },
23
+ )
24
+
25
+ // Wrap the signature.
26
+ return SignatureErc8010.wrap({
27
+ authorization: {
28
+ ...authorization,
29
+ nonce: BigInt(authorization.nonce),
30
+ r: BigInt(authorization.r),
31
+ s: BigInt(authorization.s),
32
+ },
33
+ data,
34
+ signature: parameters.signature,
35
+ to,
36
+ })
37
+ }
38
+
39
+ export namespace wrap {
40
+ export type Parameters = {
41
+ address: Address.Address
42
+ signature: Hex.Hex
43
+ }
44
+ }
@@ -0,0 +1,5 @@
1
+ export const supported = () =>
2
+ 'IntersectionObserver' in window &&
3
+ 'IntersectionObserverEntry' in window &&
4
+ 'intersectionRatio' in IntersectionObserverEntry.prototype &&
5
+ 'isVisible' in IntersectionObserverEntry.prototype
@@ -0,0 +1,42 @@
1
+ export function create(options: create.Options = {}) {
2
+ const { prefix = '[Porto]' } = options
3
+
4
+ const memo = new Set<string>()
5
+
6
+ return {
7
+ error: createLogFn(console.error, { prefix }),
8
+ errorOnce: createLogFn(console.error, { memo, prefix }),
9
+ log: createLogFn(console.log, { prefix }),
10
+ logOnce: createLogFn(console.log, { memo, prefix }),
11
+ warn: createLogFn(console.warn, { prefix }),
12
+ warnOnce: createLogFn(console.warn, { memo, prefix }),
13
+ }
14
+ }
15
+
16
+ export declare namespace create {
17
+ type Options = {
18
+ prefix?: string
19
+ }
20
+ }
21
+
22
+ export const logger = create()
23
+
24
+ function createLogFn<fn extends (...args: any[]) => void>(
25
+ fn: fn,
26
+ options: createLogFn.Options = {},
27
+ ) {
28
+ const { memo, prefix } = options
29
+ return (...messages: string[]) => {
30
+ const message = messages.join(' ')
31
+ if (memo?.has(message)) return
32
+ memo?.add(message)
33
+ fn(`${prefix} ${message}`)
34
+ }
35
+ }
36
+
37
+ declare namespace createLogFn {
38
+ type Options = {
39
+ memo?: Set<string> | undefined
40
+ prefix?: string
41
+ }
42
+ }