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.
- package/README.md +64 -34
- package/dist/cli/Dialog.d.ts +34 -0
- package/dist/cli/Dialog.js +60 -0
- package/dist/cli/Dialog.js.map +1 -0
- package/dist/cli/Messenger.d.ts +7 -0
- package/dist/cli/Messenger.js +123 -0
- package/dist/cli/Messenger.js.map +1 -0
- package/dist/cli/bin/commands-D7N5ucUu.js +50 -0
- package/dist/cli/bin/index.js +9 -0
- package/dist/cli/index.d.ts +2 -0
- package/dist/cli/index.js +3 -0
- package/dist/cli/index.js.map +1 -0
- package/dist/cli/internal/http.d.ts +6 -0
- package/dist/cli/internal/http.js +17 -0
- package/dist/cli/internal/http.js.map +1 -0
- package/dist/cli/tsdown.config.d.ts +2 -0
- package/dist/cli/tsdown.config.js +28 -0
- package/dist/cli/tsdown.config.js.map +1 -0
- package/dist/core/Chains.d.ts +210 -0
- package/dist/core/Chains.js +20 -0
- package/dist/core/Chains.js.map +1 -0
- package/dist/core/Dialog.d.ts +307 -0
- package/dist/core/Dialog.js +809 -0
- package/dist/core/Dialog.js.map +1 -0
- package/dist/core/Messenger.d.ts +164 -0
- package/dist/core/Messenger.js +207 -0
- package/dist/core/Messenger.js.map +1 -0
- package/dist/core/Mode.d.ts +4 -0
- package/dist/core/Mode.js +5 -0
- package/dist/core/Mode.js.map +1 -0
- package/dist/core/Porto.d.ts +1608 -0
- package/dist/core/Porto.js +105 -0
- package/dist/core/Porto.js.map +1 -0
- package/dist/core/RpcSchema.d.ts +81 -0
- package/dist/core/RpcSchema.js +2 -0
- package/dist/core/RpcSchema.js.map +1 -0
- package/dist/core/Storage.d.ts +14 -0
- package/dist/core/Storage.js +109 -0
- package/dist/core/Storage.js.map +1 -0
- package/dist/core/Transport.d.ts +22 -0
- package/dist/core/Transport.js +37 -0
- package/dist/core/Transport.js.map +1 -0
- package/dist/core/internal/_generated/chains.d.ts +1 -0
- package/dist/core/internal/_generated/chains.js +3 -0
- package/dist/core/internal/_generated/chains.js.map +1 -0
- package/dist/core/internal/_generated/contracts/IthacaAccount.d.ts +1120 -0
- package/dist/core/internal/_generated/contracts/IthacaAccount.js +1453 -0
- package/dist/core/internal/_generated/contracts/IthacaAccount.js.map +1 -0
- package/dist/core/internal/call.d.ts +163 -0
- package/dist/core/internal/call.js +115 -0
- package/dist/core/internal/call.js.map +1 -0
- package/dist/core/internal/erc8010.d.ts +17 -0
- package/dist/core/internal/erc8010.js +29 -0
- package/dist/core/internal/erc8010.js.map +1 -0
- package/dist/core/internal/intersectionObserver.d.ts +1 -0
- package/dist/core/internal/intersectionObserver.js +5 -0
- package/dist/core/internal/intersectionObserver.js.map +1 -0
- package/dist/core/internal/logger.d.ts +21 -0
- package/dist/core/internal/logger.js +24 -0
- package/dist/core/internal/logger.js.map +1 -0
- package/dist/core/internal/mode.d.ts +344 -0
- package/dist/core/internal/mode.js +110 -0
- package/dist/core/internal/mode.js.map +1 -0
- package/dist/core/internal/modes/dialog.d.ts +799 -0
- package/dist/core/internal/modes/dialog.js +760 -0
- package/dist/core/internal/modes/dialog.js.map +1 -0
- package/dist/core/internal/modes/reactNative.d.ts +1401 -0
- package/dist/core/internal/modes/reactNative.js +19 -0
- package/dist/core/internal/modes/reactNative.js.map +1 -0
- package/dist/core/internal/modes/relay.d.ts +684 -0
- package/dist/core/internal/modes/relay.js +708 -0
- package/dist/core/internal/modes/relay.js.map +1 -0
- package/dist/core/internal/permissions.d.ts +59 -0
- package/dist/core/internal/permissions.js +30 -0
- package/dist/core/internal/permissions.js.map +1 -0
- package/dist/core/internal/permissionsRequest.d.ts +71 -0
- package/dist/core/internal/permissionsRequest.js +58 -0
- package/dist/core/internal/permissionsRequest.js.map +1 -0
- package/dist/core/internal/porto.d.ts +13 -0
- package/dist/core/internal/porto.js +2 -0
- package/dist/core/internal/porto.js.map +1 -0
- package/dist/core/internal/promise.d.ts +8 -0
- package/dist/core/internal/promise.js +11 -0
- package/dist/core/internal/promise.js.map +1 -0
- package/dist/core/internal/provider.d.ts +29 -0
- package/dist/core/internal/provider.js +941 -0
- package/dist/core/internal/provider.js.map +1 -0
- package/dist/core/internal/relay/rpcSchema.d.ts +75 -0
- package/dist/core/internal/relay/rpcSchema.js +7 -0
- package/dist/core/internal/relay/rpcSchema.js.map +1 -0
- package/dist/core/internal/relay/schema/capabilities.d.ts +164 -0
- package/dist/core/internal/relay/schema/capabilities.js +112 -0
- package/dist/core/internal/relay/schema/capabilities.js.map +1 -0
- package/dist/core/internal/relay/schema/intent.d.ts +167 -0
- package/dist/core/internal/relay/schema/intent.js +170 -0
- package/dist/core/internal/relay/schema/intent.js.map +1 -0
- package/dist/core/internal/relay/schema/key.d.ts +43 -0
- package/dist/core/internal/relay/schema/key.js +30 -0
- package/dist/core/internal/relay/schema/key.js.map +1 -0
- package/dist/core/internal/relay/schema/permission.d.ts +39 -0
- package/dist/core/internal/relay/schema/permission.js +29 -0
- package/dist/core/internal/relay/schema/permission.js.map +1 -0
- package/dist/core/internal/relay/schema/preCall.d.ts +62 -0
- package/dist/core/internal/relay/schema/preCall.js +36 -0
- package/dist/core/internal/relay/schema/preCall.js.map +1 -0
- package/dist/core/internal/relay/schema/quotes.d.ts +369 -0
- package/dist/core/internal/relay/schema/quotes.js +89 -0
- package/dist/core/internal/relay/schema/quotes.js.map +1 -0
- package/dist/core/internal/relay/schema/rpc.d.ts +1528 -0
- package/dist/core/internal/relay/schema/rpc.js +638 -0
- package/dist/core/internal/relay/schema/rpc.js.map +1 -0
- package/dist/core/internal/relay/schema/token.d.ts +13 -0
- package/dist/core/internal/relay/schema/token.js +13 -0
- package/dist/core/internal/relay/schema/token.js.map +1 -0
- package/dist/core/internal/requiredFunds.d.ts +18 -0
- package/dist/core/internal/requiredFunds.js +25 -0
- package/dist/core/internal/requiredFunds.js.map +1 -0
- package/dist/core/internal/schema/capabilities.d.ts +313 -0
- package/dist/core/internal/schema/capabilities.js +133 -0
- package/dist/core/internal/schema/capabilities.js.map +1 -0
- package/dist/core/internal/schema/key.d.ts +164 -0
- package/dist/core/internal/schema/key.js +75 -0
- package/dist/core/internal/schema/key.js.map +1 -0
- package/dist/core/internal/schema/permissions.d.ts +102 -0
- package/dist/core/internal/schema/permissions.js +28 -0
- package/dist/core/internal/schema/permissions.js.map +1 -0
- package/dist/core/internal/schema/request.d.ts +937 -0
- package/dist/core/internal/schema/request.js +57 -0
- package/dist/core/internal/schema/request.js.map +1 -0
- package/dist/core/internal/schema/rpc.d.ts +3314 -0
- package/dist/core/internal/schema/rpc.js +599 -0
- package/dist/core/internal/schema/rpc.js.map +1 -0
- package/dist/core/internal/schema/token.d.ts +1 -0
- package/dist/core/internal/schema/token.js +2 -0
- package/dist/core/internal/schema/token.js.map +1 -0
- package/dist/core/internal/schema/utils.d.ts +18 -0
- package/dist/core/internal/schema/utils.js +213 -0
- package/dist/core/internal/schema/utils.js.map +1 -0
- package/dist/core/internal/siwe.d.ts +32 -0
- package/dist/core/internal/siwe.js +92 -0
- package/dist/core/internal/siwe.js.map +1 -0
- package/dist/core/internal/store.d.ts +2 -0
- package/dist/core/internal/store.js +9 -0
- package/dist/core/internal/store.js.map +1 -0
- package/dist/core/internal/tokens.d.ts +57 -0
- package/dist/core/internal/tokens.js +69 -0
- package/dist/core/internal/tokens.js.map +1 -0
- package/dist/core/internal/types.d.ts +298 -0
- package/dist/core/internal/types.js +2 -0
- package/dist/core/internal/types.js.map +1 -0
- package/dist/core/internal/urlString.d.ts +1 -0
- package/dist/core/internal/urlString.js +8 -0
- package/dist/core/internal/urlString.js.map +1 -0
- package/dist/core/internal/userAgent.d.ts +10 -0
- package/dist/core/internal/userAgent.js +19 -0
- package/dist/core/internal/userAgent.js.map +1 -0
- package/dist/core/internal/utils.d.ts +24 -0
- package/dist/core/internal/utils.js +62 -0
- package/dist/core/internal/utils.js.map +1 -0
- package/dist/core/react-native/Porto.d.ts +1480 -0
- package/dist/core/react-native/Porto.js +17 -0
- package/dist/core/react-native/Porto.js.map +1 -0
- package/dist/core/react-native/configure.d.ts +9 -0
- package/dist/core/react-native/configure.js +24 -0
- package/dist/core/react-native/configure.js.map +1 -0
- package/dist/core/react-native/environment.d.ts +26 -0
- package/dist/core/react-native/environment.js +13 -0
- package/dist/core/react-native/environment.js.map +1 -0
- package/dist/core/react-native/index.d.ts +4 -0
- package/dist/core/react-native/index.js +5 -0
- package/dist/core/react-native/index.js.map +1 -0
- package/dist/core/react-native/utils.d.ts +1 -0
- package/dist/core/react-native/utils.js +12 -0
- package/dist/core/react-native/utils.js.map +1 -0
- package/dist/index.d.ts +16 -2
- package/dist/index.js +15 -2
- package/dist/index.js.map +1 -0
- package/dist/internal/index.d.ts +3 -0
- package/dist/internal/index.js +4 -0
- package/dist/internal/index.js.map +1 -0
- package/dist/react-native/crypto.d.ts +1 -0
- package/dist/react-native/crypto.js +12 -0
- package/dist/react-native/crypto.js.map +1 -0
- package/dist/react-native/index.d.ts +7 -0
- package/dist/react-native/index.js +12 -0
- package/dist/react-native/index.js.map +1 -0
- package/dist/react-native/register.d.ts +2 -0
- package/dist/react-native/register.js +15 -0
- package/dist/react-native/register.js.map +1 -0
- package/dist/register/index.d.ts +14 -0
- package/dist/register/index.js +2 -0
- package/dist/register/index.js.map +1 -0
- package/dist/remote/Actions.d.ts +33 -0
- package/dist/remote/Actions.js +76 -0
- package/dist/remote/Actions.js.map +1 -0
- package/dist/remote/Events.d.ts +46 -0
- package/dist/remote/Events.js +132 -0
- package/dist/remote/Events.js.map +1 -0
- package/dist/remote/Hooks.d.ts +3800 -0
- package/dist/remote/Hooks.js +106 -0
- package/dist/remote/Hooks.js.map +1 -0
- package/dist/remote/Porto.d.ts +857 -0
- package/dist/remote/Porto.js +66 -0
- package/dist/remote/Porto.js.map +1 -0
- package/dist/remote/index.d.ts +4 -0
- package/dist/remote/index.js +5 -0
- package/dist/remote/index.js.map +1 -0
- package/dist/remote/internal/methodPolicies.d.ts +96 -0
- package/dist/remote/internal/methodPolicies.js +102 -0
- package/dist/remote/internal/methodPolicies.js.map +1 -0
- package/dist/server/Route.d.ts +87 -0
- package/dist/server/Route.js +189 -0
- package/dist/server/Route.js.map +1 -0
- package/dist/server/Router.d.ts +23 -0
- package/dist/server/Router.js +29 -0
- package/dist/server/Router.js.map +1 -0
- package/dist/server/index.d.ts +2 -0
- package/dist/server/index.js +3 -0
- package/dist/server/index.js.map +1 -0
- package/dist/server/internal/merchantSchema.d.ts +64 -0
- package/dist/server/internal/merchantSchema.js +7 -0
- package/dist/server/internal/merchantSchema.js.map +1 -0
- package/dist/server/internal/requestListener.d.ts +123 -0
- package/dist/server/internal/requestListener.js +172 -0
- package/dist/server/internal/requestListener.js.map +1 -0
- package/dist/theme/Theme.d.ts +121 -0
- package/dist/theme/Theme.js +18 -0
- package/dist/theme/Theme.js.map +1 -0
- package/dist/theme/index.d.ts +2 -0
- package/dist/theme/index.js +2 -0
- package/dist/theme/index.js.map +1 -0
- package/dist/trusted-hosts.d.ts +1 -0
- package/dist/trusted-hosts.js +41 -0
- package/dist/trusted-hosts.js.map +1 -0
- package/dist/viem/Account.d.ts +110 -0
- package/dist/viem/Account.js +132 -0
- package/dist/viem/Account.js.map +1 -0
- package/dist/viem/AccountActions.d.ts +10 -0
- package/dist/viem/AccountActions.js +14 -0
- package/dist/viem/AccountActions.js.map +1 -0
- package/dist/viem/CapabilitiesSchema.d.ts +14 -0
- package/dist/viem/CapabilitiesSchema.js +2 -0
- package/dist/viem/CapabilitiesSchema.js.map +1 -0
- package/dist/viem/ContractActions.d.ts +208 -0
- package/dist/viem/ContractActions.js +350 -0
- package/dist/viem/ContractActions.js.map +1 -0
- package/dist/viem/Key.d.ts +1155 -0
- package/dist/viem/Key.js +924 -0
- package/dist/viem/Key.js.map +1 -0
- package/dist/viem/RelayActions.d.ts +435 -0
- package/dist/viem/RelayActions.js +385 -0
- package/dist/viem/RelayActions.js.map +1 -0
- package/dist/viem/RelayClient.d.ts +26 -0
- package/dist/viem/RelayClient.js +44 -0
- package/dist/viem/RelayClient.js.map +1 -0
- package/dist/viem/RpcSchema.d.ts +22 -0
- package/dist/viem/RpcSchema.js +2 -0
- package/dist/viem/RpcSchema.js.map +1 -0
- package/dist/viem/WalletActions.d.ts +86 -0
- package/dist/viem/WalletActions.js +220 -0
- package/dist/viem/WalletActions.js.map +1 -0
- package/dist/viem/WalletClient.d.ts +20 -0
- package/dist/viem/WalletClient.js +23 -0
- package/dist/viem/WalletClient.js.map +1 -0
- package/dist/viem/index.d.ts +13 -0
- package/dist/viem/index.js +12 -0
- package/dist/viem/index.js.map +1 -0
- package/dist/viem/internal/relayActions.d.ts +364 -0
- package/dist/viem/internal/relayActions.js +783 -0
- package/dist/viem/internal/relayActions.js.map +1 -0
- package/dist/viem/internal/utils.d.ts +15 -0
- package/dist/viem/internal/utils.js +2 -0
- package/dist/viem/internal/utils.js.map +1 -0
- package/dist/wagmi/Actions.d.ts +1 -0
- package/dist/wagmi/Actions.js +2 -0
- package/dist/wagmi/Actions.js.map +1 -0
- package/dist/wagmi/Connector.d.ts +26 -0
- package/dist/wagmi/Connector.js +238 -0
- package/dist/wagmi/Connector.js.map +1 -0
- package/dist/wagmi/Hooks.d.ts +1 -0
- package/dist/wagmi/Hooks.js +2 -0
- package/dist/wagmi/Hooks.js.map +1 -0
- package/dist/wagmi/Query.d.ts +1 -0
- package/dist/wagmi/Query.js +2 -0
- package/dist/wagmi/Query.js.map +1 -0
- package/dist/wagmi/index.d.ts +4 -0
- package/dist/wagmi/index.js +5 -0
- package/dist/wagmi/index.js.map +1 -0
- package/dist/wagmi/internal/core.d.ts +83 -0
- package/dist/wagmi/internal/core.js +229 -0
- package/dist/wagmi/internal/core.js.map +1 -0
- package/dist/wagmi/internal/query.d.ts +32 -0
- package/dist/wagmi/internal/query.js +23 -0
- package/dist/wagmi/internal/query.js.map +1 -0
- package/dist/wagmi/internal/react.d.ts +90 -0
- package/dist/wagmi/internal/react.js +256 -0
- package/dist/wagmi/internal/react.js.map +1 -0
- package/dist/wagmi/internal/types.d.ts +10 -0
- package/dist/wagmi/internal/types.js +2 -0
- package/dist/wagmi/internal/types.js.map +1 -0
- package/dist/wagmi/internal/utils.d.ts +1 -0
- package/dist/wagmi/internal/utils.js +18 -0
- package/dist/wagmi/internal/utils.js.map +1 -0
- package/package.json +286 -34
- package/src/cli/Dialog.ts +75 -0
- package/src/cli/Messenger.ts +148 -0
- package/src/cli/bin/index.ts +37 -0
- package/src/cli/bin/tsconfig.json +8 -0
- package/src/cli/index.ts +2 -0
- package/src/cli/internal/commands.ts +212 -0
- package/src/cli/internal/context.ts +56 -0
- package/src/cli/internal/http.ts +28 -0
- package/src/cli/internal/utils.ts +28 -0
- package/src/cli/tsdown.config.ts +37 -0
- package/src/core/Chains.ts +25 -0
- package/src/core/Dialog.ts +1059 -0
- package/src/core/Messenger.ts +394 -0
- package/src/core/Mode.ts +4 -0
- package/src/core/Porto.ts +287 -0
- package/src/core/RpcSchema.ts +124 -0
- package/src/core/Storage.ts +122 -0
- package/src/core/Transport.ts +45 -0
- package/src/core/internal/_generated/chains.ts +2 -0
- package/src/core/internal/_generated/contracts/EIP7702Proxy.ts +25 -0
- package/src/core/internal/_generated/contracts/Escrow.ts +330 -0
- package/src/core/internal/_generated/contracts/ExperimentERC20.ts +569 -0
- package/src/core/internal/_generated/contracts/ExperimentERC721.ts +588 -0
- package/src/core/internal/_generated/contracts/GuardedExecutor.ts +623 -0
- package/src/core/internal/_generated/contracts/ICallChecker.ts +34 -0
- package/src/core/internal/_generated/contracts/ICommon.ts +4 -0
- package/src/core/internal/_generated/contracts/IEscrow.ts +114 -0
- package/src/core/internal/_generated/contracts/IFunder.ts +80 -0
- package/src/core/internal/_generated/contracts/IFunderV4.ts +45 -0
- package/src/core/internal/_generated/contracts/IIthacaAccount.ts +107 -0
- package/src/core/internal/_generated/contracts/IOAppCore.ts +142 -0
- package/src/core/internal/_generated/contracts/IOAppMsgInspector.ts +45 -0
- package/src/core/internal/_generated/contracts/IOAppReceiver.ts +161 -0
- package/src/core/internal/_generated/contracts/IOrchestrator.ts +95 -0
- package/src/core/internal/_generated/contracts/ISettler.ts +52 -0
- package/src/core/internal/_generated/contracts/ISigner.ts +34 -0
- package/src/core/internal/_generated/contracts/IthacaAccount.ts +1454 -0
- package/src/core/internal/_generated/contracts/IthacaAccountNew.ts +1454 -0
- package/src/core/internal/_generated/contracts/IthacaAccountOld.ts +1454 -0
- package/src/core/internal/_generated/contracts/LayerZeroSettler.ts +811 -0
- package/src/core/internal/_generated/contracts/LibNonce.ts +15 -0
- package/src/core/internal/_generated/contracts/LibTStack.ts +4 -0
- package/src/core/internal/_generated/contracts/MultiSigSigner.ts +203 -0
- package/src/core/internal/_generated/contracts/OApp.ts +412 -0
- package/src/core/internal/_generated/contracts/OAppCore.ts +229 -0
- package/src/core/internal/_generated/contracts/OAppReceiver.ts +396 -0
- package/src/core/internal/_generated/contracts/OAppSender.ts +245 -0
- package/src/core/internal/_generated/contracts/Orchestrator.ts +390 -0
- package/src/core/internal/_generated/contracts/SimpleFunder.ts +534 -0
- package/src/core/internal/_generated/contracts/SimpleSettler.ts +360 -0
- package/src/core/internal/_generated/contracts/Simulator.ts +170 -0
- package/src/core/internal/_generated/contracts/TokenTransferLib.ts +4 -0
- package/src/core/internal/_snapshots/provider.browser.test.ts.snap +119 -0
- package/src/core/internal/_snapshots/provider.test.ts.snap +1103 -0
- package/src/core/internal/call.test.ts +116 -0
- package/src/core/internal/call.ts +245 -0
- package/src/core/internal/erc8010.test.ts +74 -0
- package/src/core/internal/erc8010.ts +44 -0
- package/src/core/internal/intersectionObserver.ts +5 -0
- package/src/core/internal/logger.ts +42 -0
- package/src/core/internal/mode.ts +498 -0
- package/src/core/internal/modes/dialog.ts +1051 -0
- package/src/core/internal/modes/reactNative.ts +29 -0
- package/src/core/internal/modes/relay.ts +893 -0
- package/src/core/internal/permissions.ts +43 -0
- package/src/core/internal/permissionsRequest.ts +88 -0
- package/src/core/internal/porto.ts +16 -0
- package/src/core/internal/promise.ts +19 -0
- package/src/core/internal/provider.browser.test.ts +311 -0
- package/src/core/internal/provider.test.ts +3552 -0
- package/src/core/internal/provider.ts +1277 -0
- package/src/core/internal/relay/rpcSchema.ts +101 -0
- package/src/core/internal/relay/schema/capabilities.test.ts +663 -0
- package/src/core/internal/relay/schema/capabilities.ts +156 -0
- package/src/core/internal/relay/schema/intent.test.ts +433 -0
- package/src/core/internal/relay/schema/intent.ts +174 -0
- package/src/core/internal/relay/schema/key.test.ts +424 -0
- package/src/core/internal/relay/schema/key.ts +34 -0
- package/src/core/internal/relay/schema/permission.test.ts +499 -0
- package/src/core/internal/relay/schema/permission.ts +34 -0
- package/src/core/internal/relay/schema/preCall.ts +39 -0
- package/src/core/internal/relay/schema/quotes.test.ts +901 -0
- package/src/core/internal/relay/schema/quotes.ts +98 -0
- package/src/core/internal/relay/schema/rpc.ts +822 -0
- package/src/core/internal/relay/schema/token.ts +16 -0
- package/src/core/internal/requiredFunds.test.ts +141 -0
- package/src/core/internal/requiredFunds.ts +45 -0
- package/src/core/internal/schema/capabilities.test.ts +1334 -0
- package/src/core/internal/schema/capabilities.ts +162 -0
- package/src/core/internal/schema/key.test.ts +570 -0
- package/src/core/internal/schema/key.ts +98 -0
- package/src/core/internal/schema/permissions.test.ts +948 -0
- package/src/core/internal/schema/permissions.ts +31 -0
- package/src/core/internal/schema/request.bench.ts +35 -0
- package/src/core/internal/schema/request.ts +90 -0
- package/src/core/internal/schema/rpc.ts +821 -0
- package/src/core/internal/schema/token.ts +1 -0
- package/src/core/internal/schema/utils.test.ts +572 -0
- package/src/core/internal/schema/utils.ts +236 -0
- package/src/core/internal/siwe.test.ts +473 -0
- package/src/core/internal/siwe.ts +144 -0
- package/src/core/internal/store.ts +9 -0
- package/src/core/internal/tokens.test.ts +317 -0
- package/src/core/internal/tokens.ts +125 -0
- package/src/core/internal/types.ts +448 -0
- package/src/core/internal/urlString.ts +5 -0
- package/src/core/internal/userAgent.ts +35 -0
- package/src/core/internal/utils.test.ts +35 -0
- package/src/core/internal/utils.ts +67 -0
- package/src/core/react-native/Porto.ts +22 -0
- package/src/core/react-native/configure.ts +31 -0
- package/src/core/react-native/environment.ts +43 -0
- package/src/core/react-native/index.ts +4 -0
- package/src/core/react-native/utils.ts +18 -0
- package/src/index.ts +17 -0
- package/src/internal/index.ts +3 -0
- package/src/react-native/crypto.ts +19 -0
- package/src/react-native/index.ts +15 -0
- package/src/react-native/register.ts +24 -0
- package/src/register/index.ts +17 -0
- package/src/remote/Actions.ts +115 -0
- package/src/remote/Events.ts +193 -0
- package/src/remote/Hooks.ts +194 -0
- package/src/remote/Porto.ts +144 -0
- package/src/remote/index.ts +4 -0
- package/src/remote/internal/methodPolicies.ts +124 -0
- package/src/server/Route.test.ts +347 -0
- package/src/server/Route.ts +259 -0
- package/src/server/Router.test.ts +32 -0
- package/src/server/Router.ts +59 -0
- package/src/server/index.ts +2 -0
- package/src/server/internal/merchantSchema.ts +11 -0
- package/src/server/internal/requestListener.ts +284 -0
- package/src/theme/Theme.ts +163 -0
- package/src/theme/index.ts +2 -0
- package/src/trusted-hosts.ts +40 -0
- package/src/tsconfig.build.tsbuildinfo +1 -0
- package/src/tsconfig.json +15 -0
- package/src/viem/Account.test.ts +270 -0
- package/src/viem/Account.ts +278 -0
- package/src/viem/AccountActions.test.ts +3 -0
- package/src/viem/AccountActions.ts +30 -0
- package/src/viem/CapabilitiesSchema.ts +18 -0
- package/src/viem/ContractActions.test.ts +980 -0
- package/src/viem/ContractActions.ts +624 -0
- package/src/viem/Key.test.ts +1420 -0
- package/src/viem/Key.ts +1318 -0
- package/src/viem/RelayActions.test.ts +1730 -0
- package/src/viem/RelayActions.ts +1082 -0
- package/src/viem/RelayClient.test.ts +127 -0
- package/src/viem/RelayClient.ts +87 -0
- package/src/viem/RpcSchema.ts +27 -0
- package/src/viem/WalletActions.test.ts +646 -0
- package/src/viem/WalletActions.ts +476 -0
- package/src/viem/WalletClient.test.ts +36 -0
- package/src/viem/WalletClient.ts +74 -0
- package/src/viem/index.ts +13 -0
- package/src/viem/internal/relayActions.test.ts +1296 -0
- package/src/viem/internal/relayActions.ts +1222 -0
- package/src/viem/internal/utils.ts +27 -0
- package/src/wagmi/Actions.ts +13 -0
- package/src/wagmi/Connector.ts +304 -0
- package/src/wagmi/Hooks.ts +14 -0
- package/src/wagmi/Query.ts +5 -0
- package/src/wagmi/index.ts +4 -0
- package/src/wagmi/internal/core.test.ts +12 -0
- package/src/wagmi/internal/core.ts +468 -0
- package/src/wagmi/internal/query.ts +52 -0
- package/src/wagmi/internal/react.test.ts +12 -0
- package/src/wagmi/internal/react.ts +705 -0
- package/src/wagmi/internal/types.ts +21 -0
- package/src/wagmi/internal/utils.ts +25 -0
- package/dist/chain.cjs +0 -17
- package/dist/chain.d.cts +0 -41
- package/dist/chain.d.ts +0 -41
- package/dist/chain.js +0 -13
- package/dist/config.cjs +0 -19
- package/dist/config.d.cts +0 -3
- package/dist/config.d.ts +0 -3
- package/dist/config.js +0 -16
- package/dist/index.cjs +0 -18
- package/dist/index.d.cts +0 -2
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Intent.
|
|
3
|
+
*
|
|
4
|
+
* @see https://github.com/ithacaxyz/relay/blob/main/src/types/intent.rs
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import * as z from 'zod/mini'
|
|
8
|
+
import * as u from '../../schema/utils.js'
|
|
9
|
+
|
|
10
|
+
export const Intent = z.union([
|
|
11
|
+
z.object({
|
|
12
|
+
combinedGas: u.bigint(),
|
|
13
|
+
encodedFundTransfers: z.readonly(z.array(u.hex())),
|
|
14
|
+
encodedPreCalls: z.readonly(z.array(u.hex())),
|
|
15
|
+
eoa: u.address(),
|
|
16
|
+
executionData: u.hex(),
|
|
17
|
+
expiry: u.bigint(),
|
|
18
|
+
funder: u.address(),
|
|
19
|
+
funderSignature: u.hex(),
|
|
20
|
+
isMultichain: z.boolean(),
|
|
21
|
+
nonce: u.bigint(),
|
|
22
|
+
payer: u.address(),
|
|
23
|
+
paymentAmount: u.bigint(),
|
|
24
|
+
paymentMaxAmount: u.bigint(),
|
|
25
|
+
paymentRecipient: u.address(),
|
|
26
|
+
paymentSignature: u.hex(),
|
|
27
|
+
paymentToken: u.address(),
|
|
28
|
+
settler: u.address(),
|
|
29
|
+
settlerContext: u.hex(),
|
|
30
|
+
signature: u.hex(),
|
|
31
|
+
supportedAccountImplementation: u.address(),
|
|
32
|
+
}),
|
|
33
|
+
z.object({
|
|
34
|
+
/** The combined gas limit for payment, verification, and calling the EOA. */
|
|
35
|
+
combinedGas: u.bigint(),
|
|
36
|
+
/** Only relevant for multi chain intents. */
|
|
37
|
+
encodedFundTransfers: z.readonly(z.array(u.hex())),
|
|
38
|
+
/**
|
|
39
|
+
* Optional array of encoded Intents that will be verified and executed
|
|
40
|
+
* before the validation of the overall Intent.
|
|
41
|
+
*
|
|
42
|
+
* A PreCall will NOT have its gas limit or payment applied.
|
|
43
|
+
* The overall Intent's gas limit and payment will be applied, encompassing all its PreCalls.
|
|
44
|
+
* The execution of a PreCall will check and increment the nonce in the PreCall.
|
|
45
|
+
* If at any point, any PreCall cannot be verified to be correct, or fails in execution,
|
|
46
|
+
* the overall Intent will revert before validation, and execute will return a non-zero error.
|
|
47
|
+
* A PreCall can contain PreCalls, forming a tree structure.
|
|
48
|
+
* The `executionData` tree will be executed in post-order (i.e. left -> right -> current).
|
|
49
|
+
* The `encodedPreCalls` are included in the EIP712 signature, which enables execution order
|
|
50
|
+
* to be enforced on-the-fly even if the nonces are from different sequences.
|
|
51
|
+
*/
|
|
52
|
+
encodedPreCalls: z.readonly(z.array(u.hex())),
|
|
53
|
+
/** Users address. */
|
|
54
|
+
eoa: u.address(),
|
|
55
|
+
/**
|
|
56
|
+
* An encoded array of calls, using ERC7579 batch execution encoding.
|
|
57
|
+
*
|
|
58
|
+
* The format is `abi.encode(calls)`, where `calls` is an array of type `Call[]`.
|
|
59
|
+
* This allows for more efficient safe forwarding to the EOA.
|
|
60
|
+
*/
|
|
61
|
+
executionData: u.hex(),
|
|
62
|
+
/** The expiration time of the intent. */
|
|
63
|
+
expiry: u.bigint(),
|
|
64
|
+
/** The funder address. */
|
|
65
|
+
funder: u.address(),
|
|
66
|
+
/** The funder's signature. */
|
|
67
|
+
funderSignature: u.hex(),
|
|
68
|
+
/** Whether the intent is a multi-chain intent. */
|
|
69
|
+
isMultichain: z.boolean(),
|
|
70
|
+
/** Per delegated EOA.
|
|
71
|
+
*
|
|
72
|
+
* # Memory layout
|
|
73
|
+
*
|
|
74
|
+
* Each nonce has the following memory layout:
|
|
75
|
+
*
|
|
76
|
+
* ,----------------------------------------------------.
|
|
77
|
+
* bits | 0-191 (192 bits) | 192-255 (64 bits)|
|
|
78
|
+
* |---------------------------------|------------------|
|
|
79
|
+
* desc | sequence key | sequential nonce |
|
|
80
|
+
* `----------------.----------------|------------------'
|
|
81
|
+
* |
|
|
82
|
+
* v
|
|
83
|
+
* ,-------------------------------------.
|
|
84
|
+
* bits | 0-15 (16 bits) | 16-191 (176 bits) |
|
|
85
|
+
* |-------------------------------------|
|
|
86
|
+
* desc | multichain flag | remainder |
|
|
87
|
+
* `-------------------------------------'
|
|
88
|
+
*
|
|
89
|
+
* If the upper 16 bits of the sequence key is `0xc1d0`, then the EIP-712 has
|
|
90
|
+
* of the Intent will exlude the chain ID.
|
|
91
|
+
*
|
|
92
|
+
* # Ordering
|
|
93
|
+
*
|
|
94
|
+
* Ordering matters within a sequence key, but not between sequence keys.
|
|
95
|
+
*
|
|
96
|
+
* This means that users who do not care about the order of specific intents
|
|
97
|
+
* can sign their intents using a random sequence key. On the other hand, if
|
|
98
|
+
* they do care about ordering, they would use the same sequence key.
|
|
99
|
+
*/
|
|
100
|
+
nonce: u.bigint(),
|
|
101
|
+
/**
|
|
102
|
+
* The account paying the payment token.
|
|
103
|
+
* If this is `address(0)`, it defaults to the `eoa`.
|
|
104
|
+
*/
|
|
105
|
+
payer: u.address(),
|
|
106
|
+
/**
|
|
107
|
+
* The payment recipient for the ERC20 token.
|
|
108
|
+
*
|
|
109
|
+
* Excluded from signature. The filler can replace this with their own address.
|
|
110
|
+
*
|
|
111
|
+
* This enables multiple fillers, allowing for competitive filling, better uptime.
|
|
112
|
+
* If `address(0)`, the payment will be accrued by the entry point.
|
|
113
|
+
*/
|
|
114
|
+
paymentRecipient: u.address(),
|
|
115
|
+
/**
|
|
116
|
+
* Optional payment signature to be passed into the `compensate` function
|
|
117
|
+
* on the `payer`. This signature is NOT included in the EIP712 signature.
|
|
118
|
+
*/
|
|
119
|
+
paymentSignature: u.hex(),
|
|
120
|
+
/** The ERC20 or native token used to pay for gas. */
|
|
121
|
+
paymentToken: u.address(),
|
|
122
|
+
/**
|
|
123
|
+
* The actual pre payment amount, requested by the filler.
|
|
124
|
+
* MUST be less than or equal to `prePaymentMaxAmount`.
|
|
125
|
+
*/
|
|
126
|
+
prePaymentAmount: u.bigint(),
|
|
127
|
+
/**
|
|
128
|
+
* The amount of the token to pay, before the call batch is executed.
|
|
129
|
+
* This will be required to be less than `totalPaymentMaxAmount`.
|
|
130
|
+
*/
|
|
131
|
+
prePaymentMaxAmount: u.bigint(),
|
|
132
|
+
/**
|
|
133
|
+
* The address of the settler.
|
|
134
|
+
*/
|
|
135
|
+
settler: u.address(),
|
|
136
|
+
/**
|
|
137
|
+
* Context data passed to the settler for processing attestations.
|
|
138
|
+
*
|
|
139
|
+
* This data is ABI-encoded and contains information needed by the settler
|
|
140
|
+
* to process the multichain intent (e.g., list of chain IDs).
|
|
141
|
+
*/
|
|
142
|
+
settlerContext: u.hex(),
|
|
143
|
+
/**
|
|
144
|
+
* The actual total payment amount, requested by the filler.
|
|
145
|
+
* MUST be less than or equal to `totalPaymentMaxAmount`
|
|
146
|
+
*/
|
|
147
|
+
signature: u.hex(),
|
|
148
|
+
/**
|
|
149
|
+
* Optional. If non-zero, the EOA must use `supportedAccountImplementation`.
|
|
150
|
+
* Otherwise, if left as `address(0)`, any EOA implementation will be supported.
|
|
151
|
+
* This field is NOT included in the EIP712 signature.
|
|
152
|
+
*/
|
|
153
|
+
supportedAccountImplementation: u.address(),
|
|
154
|
+
/**
|
|
155
|
+
* The wrapped signature.
|
|
156
|
+
*
|
|
157
|
+
* The format is `abi.encodePacked(innerSignature, keyHash, prehash)` for most signatures,
|
|
158
|
+
* except if it is signed by the EOA root key, in which case `abi.encodePacked(r, s, v)` is valid as well.
|
|
159
|
+
*/
|
|
160
|
+
totalPaymentAmount: u.bigint(),
|
|
161
|
+
/**
|
|
162
|
+
* The maximum amount of the token to pay.
|
|
163
|
+
*/
|
|
164
|
+
totalPaymentMaxAmount: u.bigint(),
|
|
165
|
+
}),
|
|
166
|
+
])
|
|
167
|
+
export type Intent = z.infer<typeof Intent>
|
|
168
|
+
|
|
169
|
+
export const Partial = z.object({
|
|
170
|
+
eoa: u.address(),
|
|
171
|
+
executionData: u.hex(),
|
|
172
|
+
nonce: u.bigint(),
|
|
173
|
+
})
|
|
174
|
+
export type Partial = z.infer<typeof Partial>
|
|
@@ -0,0 +1,424 @@
|
|
|
1
|
+
import { describe, expect, test } from 'vitest'
|
|
2
|
+
import * as z from 'zod/mini'
|
|
3
|
+
import * as u from '../../schema/utils.js'
|
|
4
|
+
import * as Key from './key.js'
|
|
5
|
+
|
|
6
|
+
describe('Key', () => {
|
|
7
|
+
test('param: validates required fields', () => {
|
|
8
|
+
expect(
|
|
9
|
+
u.toValidationError(z.safeParse(Key.Key, {}).error),
|
|
10
|
+
).toMatchInlineSnapshot(
|
|
11
|
+
`
|
|
12
|
+
[Schema.ValidationError: Validation failed with 4 errors:
|
|
13
|
+
|
|
14
|
+
- at \`expiry\`: Expected template_literal. Needs string in format ^0x[A-Fa-f0-9]+$.
|
|
15
|
+
- at \`publicKey\`: Expected template_literal. Needs string in format ^0x[A-Fa-f0-9]+$.
|
|
16
|
+
- at \`role\`: Invalid union value.
|
|
17
|
+
- Expected "admin"
|
|
18
|
+
- Expected "normal"
|
|
19
|
+
- at \`type\`: Invalid union value.
|
|
20
|
+
- Expected "p256"
|
|
21
|
+
- Expected "secp256k1"
|
|
22
|
+
- Expected "webauthnp256"]
|
|
23
|
+
`,
|
|
24
|
+
)
|
|
25
|
+
})
|
|
26
|
+
|
|
27
|
+
test('param: validates expiry as number', () => {
|
|
28
|
+
expect(
|
|
29
|
+
u.toValidationError(
|
|
30
|
+
z.safeParse(Key.Key, {
|
|
31
|
+
expiry: 'invalid',
|
|
32
|
+
publicKey: '0x1234',
|
|
33
|
+
role: 'admin',
|
|
34
|
+
type: 'secp256k1',
|
|
35
|
+
}).error,
|
|
36
|
+
),
|
|
37
|
+
).toMatchInlineSnapshot(
|
|
38
|
+
`
|
|
39
|
+
[Schema.ValidationError: Validation failed with 1 error:
|
|
40
|
+
|
|
41
|
+
- at \`expiry\`: Must match pattern: ^0x[\\s\\S]{0,}$]
|
|
42
|
+
`,
|
|
43
|
+
)
|
|
44
|
+
})
|
|
45
|
+
|
|
46
|
+
test('param: validates publicKey as hex', () => {
|
|
47
|
+
expect(
|
|
48
|
+
u.toValidationError(
|
|
49
|
+
z.safeParse(Key.Key, {
|
|
50
|
+
expiry: '0x499602d2',
|
|
51
|
+
publicKey: 'invalid-hex',
|
|
52
|
+
role: 'admin',
|
|
53
|
+
type: 'secp256k1',
|
|
54
|
+
}).error,
|
|
55
|
+
),
|
|
56
|
+
).toMatchInlineSnapshot(
|
|
57
|
+
`
|
|
58
|
+
[Schema.ValidationError: Validation failed with 1 error:
|
|
59
|
+
|
|
60
|
+
- at \`publicKey\`: Must match pattern: ^0x[\\s\\S]{0,}$]
|
|
61
|
+
`,
|
|
62
|
+
)
|
|
63
|
+
})
|
|
64
|
+
|
|
65
|
+
test('param: validates role enum', () => {
|
|
66
|
+
expect(
|
|
67
|
+
u.toValidationError(
|
|
68
|
+
z.safeParse(Key.Key, {
|
|
69
|
+
expiry: '0x499602d2',
|
|
70
|
+
publicKey: '0x1234',
|
|
71
|
+
role: 'invalid',
|
|
72
|
+
type: 'secp256k1',
|
|
73
|
+
}).error,
|
|
74
|
+
),
|
|
75
|
+
).toMatchInlineSnapshot(
|
|
76
|
+
`
|
|
77
|
+
[Schema.ValidationError: Validation failed with 1 error:
|
|
78
|
+
|
|
79
|
+
- at \`role\`: Invalid union value.
|
|
80
|
+
- Expected "admin"
|
|
81
|
+
- Expected "normal"]
|
|
82
|
+
`,
|
|
83
|
+
)
|
|
84
|
+
})
|
|
85
|
+
|
|
86
|
+
test('param: validates type enum', () => {
|
|
87
|
+
expect(
|
|
88
|
+
u.toValidationError(
|
|
89
|
+
z.safeParse(Key.Key, {
|
|
90
|
+
expiry: '0x499602d2',
|
|
91
|
+
publicKey: '0x1234',
|
|
92
|
+
role: 'admin',
|
|
93
|
+
type: 'invalid',
|
|
94
|
+
}).error,
|
|
95
|
+
),
|
|
96
|
+
).toMatchInlineSnapshot(
|
|
97
|
+
`
|
|
98
|
+
[Schema.ValidationError: Validation failed with 1 error:
|
|
99
|
+
|
|
100
|
+
- at \`type\`: Invalid union value.
|
|
101
|
+
- Expected "p256"
|
|
102
|
+
- Expected "secp256k1"
|
|
103
|
+
- Expected "webauthnp256"]
|
|
104
|
+
`,
|
|
105
|
+
)
|
|
106
|
+
})
|
|
107
|
+
|
|
108
|
+
test('param: validates prehash as boolean when provided', () => {
|
|
109
|
+
expect(
|
|
110
|
+
u.toValidationError(
|
|
111
|
+
z.safeParse(Key.Key, {
|
|
112
|
+
expiry: '0x499602d2',
|
|
113
|
+
prehash: 'invalid',
|
|
114
|
+
publicKey: '0x1234',
|
|
115
|
+
role: 'admin',
|
|
116
|
+
type: 'secp256k1',
|
|
117
|
+
}).error,
|
|
118
|
+
),
|
|
119
|
+
).toMatchInlineSnapshot(
|
|
120
|
+
`
|
|
121
|
+
[Schema.ValidationError: Validation failed with 1 error:
|
|
122
|
+
|
|
123
|
+
- at \`prehash\`: Expected boolean. ]
|
|
124
|
+
`,
|
|
125
|
+
)
|
|
126
|
+
})
|
|
127
|
+
|
|
128
|
+
test('behavior: accepts valid key with all required fields', () => {
|
|
129
|
+
const key = z.parse(Key.Key, {
|
|
130
|
+
expiry: '0x499602d2',
|
|
131
|
+
publicKey: '0x1234567890abcdef',
|
|
132
|
+
role: 'admin',
|
|
133
|
+
type: 'secp256k1',
|
|
134
|
+
})
|
|
135
|
+
|
|
136
|
+
expect(key).toMatchInlineSnapshot(`
|
|
137
|
+
{
|
|
138
|
+
"expiry": 1234567890,
|
|
139
|
+
"publicKey": "0x1234567890abcdef",
|
|
140
|
+
"role": "admin",
|
|
141
|
+
"type": "secp256k1",
|
|
142
|
+
}
|
|
143
|
+
`)
|
|
144
|
+
})
|
|
145
|
+
|
|
146
|
+
test('behavior: accepts valid key with optional prehash', () => {
|
|
147
|
+
const key = u.toValidationError(
|
|
148
|
+
z.safeParse(Key.Key, {
|
|
149
|
+
expiry: '0x 499602d2',
|
|
150
|
+
prehash: true,
|
|
151
|
+
publicKey: '0x1234567890abcdef',
|
|
152
|
+
role: 'normal',
|
|
153
|
+
type: 'p256',
|
|
154
|
+
}).error,
|
|
155
|
+
)
|
|
156
|
+
|
|
157
|
+
expect(key).toMatchInlineSnapshot(
|
|
158
|
+
`
|
|
159
|
+
[Schema.ValidationError: Validation failed with 1 error:
|
|
160
|
+
|
|
161
|
+
- at \`expiry\`: Expected number. ]
|
|
162
|
+
`,
|
|
163
|
+
)
|
|
164
|
+
})
|
|
165
|
+
|
|
166
|
+
test.each([
|
|
167
|
+
{ role: 'admin', type: 'secp256k1' },
|
|
168
|
+
{ role: 'normal', type: 'p256' },
|
|
169
|
+
{ role: 'admin', type: 'webauthnp256' },
|
|
170
|
+
])('behavior: accepts valid role $role and type $type', ({ role, type }) => {
|
|
171
|
+
const key = z.parse(Key.Key, {
|
|
172
|
+
expiry: '0x499602d2',
|
|
173
|
+
publicKey: '0x1234567890abcdef',
|
|
174
|
+
role,
|
|
175
|
+
type,
|
|
176
|
+
})
|
|
177
|
+
|
|
178
|
+
expect(key.role).toBe(role)
|
|
179
|
+
expect(key.type).toBe(type)
|
|
180
|
+
})
|
|
181
|
+
|
|
182
|
+
test('behavior: prehash is optional', () => {
|
|
183
|
+
const keyWithoutPrehash = z.parse(Key.Key, {
|
|
184
|
+
expiry: '0x499602d2',
|
|
185
|
+
publicKey: '0x1234567890abcdef',
|
|
186
|
+
role: 'admin',
|
|
187
|
+
type: 'secp256k1',
|
|
188
|
+
})
|
|
189
|
+
|
|
190
|
+
expect(keyWithoutPrehash.prehash).toBeUndefined()
|
|
191
|
+
})
|
|
192
|
+
|
|
193
|
+
test('error: rejects invalid role values', () => {
|
|
194
|
+
expect(
|
|
195
|
+
u.toValidationError(
|
|
196
|
+
z.safeParse(Key.Key, {
|
|
197
|
+
expiry: '0x499602d2',
|
|
198
|
+
publicKey: '0x1234567890abcdef',
|
|
199
|
+
role: 'superuser',
|
|
200
|
+
type: 'secp256k1',
|
|
201
|
+
}).error,
|
|
202
|
+
),
|
|
203
|
+
).toMatchInlineSnapshot(
|
|
204
|
+
`
|
|
205
|
+
[Schema.ValidationError: Validation failed with 1 error:
|
|
206
|
+
|
|
207
|
+
- at \`role\`: Invalid union value.
|
|
208
|
+
- Expected "admin"
|
|
209
|
+
- Expected "normal"]
|
|
210
|
+
`,
|
|
211
|
+
)
|
|
212
|
+
})
|
|
213
|
+
|
|
214
|
+
test('error: rejects invalid type values', () => {
|
|
215
|
+
expect(
|
|
216
|
+
u.toValidationError(
|
|
217
|
+
z.safeParse(Key.Key, {
|
|
218
|
+
expiry: '0x123',
|
|
219
|
+
publicKey: '0x1234567890abcdef',
|
|
220
|
+
role: 'admin',
|
|
221
|
+
type: 'rsa',
|
|
222
|
+
}).error,
|
|
223
|
+
),
|
|
224
|
+
).toMatchInlineSnapshot(
|
|
225
|
+
`
|
|
226
|
+
[Schema.ValidationError: Validation failed with 1 error:
|
|
227
|
+
|
|
228
|
+
- at \`type\`: Invalid union value.
|
|
229
|
+
- Expected "p256"
|
|
230
|
+
- Expected "secp256k1"
|
|
231
|
+
- Expected "webauthnp256"]
|
|
232
|
+
`,
|
|
233
|
+
)
|
|
234
|
+
})
|
|
235
|
+
|
|
236
|
+
test('misc: encodes key correctly', () => {
|
|
237
|
+
const key = {
|
|
238
|
+
expiry: 1234567890,
|
|
239
|
+
prehash: true,
|
|
240
|
+
publicKey: '0x1234567890abcdef',
|
|
241
|
+
role: 'admin' as const,
|
|
242
|
+
type: 'secp256k1' as const,
|
|
243
|
+
} as const
|
|
244
|
+
|
|
245
|
+
const encoded = z.encode(Key.Key, key)
|
|
246
|
+
expect(encoded).toMatchInlineSnapshot(`
|
|
247
|
+
{
|
|
248
|
+
"expiry": "0x499602d2",
|
|
249
|
+
"prehash": true,
|
|
250
|
+
"publicKey": "0x1234567890abcdef",
|
|
251
|
+
"role": "admin",
|
|
252
|
+
"type": "secp256k1",
|
|
253
|
+
}
|
|
254
|
+
`)
|
|
255
|
+
})
|
|
256
|
+
})
|
|
257
|
+
|
|
258
|
+
describe('WithPermissions', () => {
|
|
259
|
+
test('param: validates permissions array', () => {
|
|
260
|
+
expect(
|
|
261
|
+
u.toValidationError(
|
|
262
|
+
z.safeParse(Key.WithPermissions, {
|
|
263
|
+
expiry: '0x499602d2',
|
|
264
|
+
permissions: 'invalid',
|
|
265
|
+
publicKey: '0x1234567890abcdef',
|
|
266
|
+
role: 'admin',
|
|
267
|
+
type: 'secp256k1',
|
|
268
|
+
}).error,
|
|
269
|
+
),
|
|
270
|
+
).toMatchInlineSnapshot(
|
|
271
|
+
`
|
|
272
|
+
[Schema.ValidationError: Validation failed with 1 error:
|
|
273
|
+
|
|
274
|
+
- at \`permissions\`: Expected array. ]
|
|
275
|
+
`,
|
|
276
|
+
)
|
|
277
|
+
})
|
|
278
|
+
|
|
279
|
+
test('param: validates permission objects in array', () => {
|
|
280
|
+
expect(
|
|
281
|
+
u.toValidationError(
|
|
282
|
+
z.safeParse(Key.WithPermissions, {
|
|
283
|
+
expiry: '0x499602d2',
|
|
284
|
+
permissions: [{ invalid: 'permission' }],
|
|
285
|
+
publicKey: '0x1234567890abcdef',
|
|
286
|
+
role: 'admin',
|
|
287
|
+
type: 'secp256k1',
|
|
288
|
+
}).error,
|
|
289
|
+
),
|
|
290
|
+
).toMatchInlineSnapshot(
|
|
291
|
+
`
|
|
292
|
+
[Schema.ValidationError: Validation failed with 1 error:
|
|
293
|
+
|
|
294
|
+
- at \`permissions[0]\`: Invalid union value.
|
|
295
|
+
- at \`selector\`: Expected template_literal. Needs string in format ^0x[A-Fa-f0-9]+$.
|
|
296
|
+
- at \`to\`: Expected template_literal. Needs string in format ^0x[A-Fa-f0-9]{40}$.
|
|
297
|
+
- at \`type\`: Expected "call"
|
|
298
|
+
- at \`limit\`: Expected template_literal. Needs string in format ^0x[A-Fa-f0-9]+$.
|
|
299
|
+
- at \`period\`: Invalid union value.
|
|
300
|
+
- Expected "minute"
|
|
301
|
+
- Expected "hour"
|
|
302
|
+
- Expected "day"
|
|
303
|
+
- Expected "week"
|
|
304
|
+
- Expected "month"
|
|
305
|
+
- Expected "year"
|
|
306
|
+
- at \`type\`: Expected "spend"]
|
|
307
|
+
`,
|
|
308
|
+
)
|
|
309
|
+
})
|
|
310
|
+
|
|
311
|
+
test('behavior: accepts key with empty permissions array', () => {
|
|
312
|
+
const keyWithPermissions = z.parse(Key.WithPermissions, {
|
|
313
|
+
expiry: '0x499602d2',
|
|
314
|
+
permissions: [],
|
|
315
|
+
publicKey: '0x1234567890abcdef',
|
|
316
|
+
role: 'admin',
|
|
317
|
+
type: 'secp256k1',
|
|
318
|
+
})
|
|
319
|
+
|
|
320
|
+
expect(keyWithPermissions).toMatchInlineSnapshot(`
|
|
321
|
+
{
|
|
322
|
+
"expiry": 1234567890,
|
|
323
|
+
"permissions": [],
|
|
324
|
+
"publicKey": "0x1234567890abcdef",
|
|
325
|
+
"role": "admin",
|
|
326
|
+
"type": "secp256k1",
|
|
327
|
+
}
|
|
328
|
+
`)
|
|
329
|
+
})
|
|
330
|
+
|
|
331
|
+
test('behavior: accepts key with valid permissions', () => {
|
|
332
|
+
const keyWithPermissions = z.parse(Key.WithPermissions, {
|
|
333
|
+
expiry: '0x499602d2',
|
|
334
|
+
permissions: [
|
|
335
|
+
{
|
|
336
|
+
selector: '0xa9059cbb',
|
|
337
|
+
to: '0x742d35Cc6634C0532925a3b8D000B4e20200000e',
|
|
338
|
+
type: 'call',
|
|
339
|
+
},
|
|
340
|
+
],
|
|
341
|
+
publicKey: '0x1234567890abcdef',
|
|
342
|
+
role: 'admin',
|
|
343
|
+
type: 'secp256k1',
|
|
344
|
+
})
|
|
345
|
+
|
|
346
|
+
expect(keyWithPermissions.permissions).toHaveLength(1)
|
|
347
|
+
expect(keyWithPermissions.permissions[0]).toMatchInlineSnapshot(`
|
|
348
|
+
{
|
|
349
|
+
"selector": "0xa9059cbb",
|
|
350
|
+
"to": "0x742d35Cc6634C0532925a3b8D000B4e20200000e",
|
|
351
|
+
"type": "call",
|
|
352
|
+
}
|
|
353
|
+
`)
|
|
354
|
+
})
|
|
355
|
+
|
|
356
|
+
test('behavior: inherits all Key properties', () => {
|
|
357
|
+
const keyWithPermissions = z.parse(Key.WithPermissions, {
|
|
358
|
+
expiry: '0x499602d2',
|
|
359
|
+
permissions: [],
|
|
360
|
+
prehash: false,
|
|
361
|
+
publicKey: '0x1234567890abcdef',
|
|
362
|
+
role: 'normal',
|
|
363
|
+
type: 'p256',
|
|
364
|
+
})
|
|
365
|
+
|
|
366
|
+
expect(keyWithPermissions.expiry).toBe(1234567890)
|
|
367
|
+
expect(keyWithPermissions.publicKey).toBe('0x1234567890abcdef')
|
|
368
|
+
expect(keyWithPermissions.role).toBe('normal')
|
|
369
|
+
expect(keyWithPermissions.type).toBe('p256')
|
|
370
|
+
expect(keyWithPermissions.prehash).toBe(false)
|
|
371
|
+
})
|
|
372
|
+
|
|
373
|
+
test('error: rejects missing permissions field', () => {
|
|
374
|
+
expect(
|
|
375
|
+
u.toValidationError(
|
|
376
|
+
z.safeParse(Key.WithPermissions, {
|
|
377
|
+
expiry: '0x499602d2',
|
|
378
|
+
publicKey: '0x1234567890abcdef',
|
|
379
|
+
role: 'admin',
|
|
380
|
+
type: 'secp256k1',
|
|
381
|
+
}).error,
|
|
382
|
+
),
|
|
383
|
+
).toMatchInlineSnapshot(
|
|
384
|
+
`
|
|
385
|
+
[Schema.ValidationError: Validation failed with 1 error:
|
|
386
|
+
|
|
387
|
+
- at \`permissions\`: Expected array. ]
|
|
388
|
+
`,
|
|
389
|
+
)
|
|
390
|
+
})
|
|
391
|
+
|
|
392
|
+
test('misc: encodes key with permissions correctly', () => {
|
|
393
|
+
const keyWithPermissions = {
|
|
394
|
+
expiry: 1234567890,
|
|
395
|
+
permissions: [
|
|
396
|
+
{
|
|
397
|
+
selector: '0xa9059cbb',
|
|
398
|
+
to: '0x742d35Cc6634C0532925a3b8D000B4e20200000e',
|
|
399
|
+
type: 'call' as const,
|
|
400
|
+
},
|
|
401
|
+
],
|
|
402
|
+
publicKey: '0x1234567890abcdef',
|
|
403
|
+
role: 'admin' as const,
|
|
404
|
+
type: 'secp256k1' as const,
|
|
405
|
+
} as const
|
|
406
|
+
|
|
407
|
+
const encoded = z.encode(Key.WithPermissions, keyWithPermissions)
|
|
408
|
+
expect(encoded).toMatchInlineSnapshot(`
|
|
409
|
+
{
|
|
410
|
+
"expiry": "0x499602d2",
|
|
411
|
+
"permissions": [
|
|
412
|
+
{
|
|
413
|
+
"selector": "0xa9059cbb",
|
|
414
|
+
"to": "0x742d35Cc6634C0532925a3b8D000B4e20200000e",
|
|
415
|
+
"type": "call",
|
|
416
|
+
},
|
|
417
|
+
],
|
|
418
|
+
"publicKey": "0x1234567890abcdef",
|
|
419
|
+
"role": "admin",
|
|
420
|
+
"type": "secp256k1",
|
|
421
|
+
}
|
|
422
|
+
`)
|
|
423
|
+
})
|
|
424
|
+
})
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* RPC account key.
|
|
3
|
+
*
|
|
4
|
+
* @see https://github.com/ithacaxyz/relay/blob/main/src/types/key.rs
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import * as z from 'zod/mini'
|
|
8
|
+
import * as u from '../../schema/utils.js'
|
|
9
|
+
import * as Permission from './permission.js'
|
|
10
|
+
|
|
11
|
+
export const Key = z.object({
|
|
12
|
+
/** The expiry of the key. */
|
|
13
|
+
expiry: u.number(),
|
|
14
|
+
/** Whether the digest was prehashed. */
|
|
15
|
+
prehash: z.optional(z.boolean()),
|
|
16
|
+
/** Public key. */
|
|
17
|
+
publicKey: u.hex(),
|
|
18
|
+
/** Role. */
|
|
19
|
+
role: z.union([z.literal('admin'), z.literal('normal')]),
|
|
20
|
+
/** Key type. */
|
|
21
|
+
type: z.union([
|
|
22
|
+
z.literal('p256'),
|
|
23
|
+
z.literal('secp256k1'),
|
|
24
|
+
z.literal('webauthnp256'),
|
|
25
|
+
]),
|
|
26
|
+
})
|
|
27
|
+
export type Key = z.infer<typeof Key>
|
|
28
|
+
|
|
29
|
+
export const WithPermissions = z.object({
|
|
30
|
+
...Key.shape,
|
|
31
|
+
/** Represents key permissions. */
|
|
32
|
+
permissions: z.readonly(z.array(Permission.Permission)),
|
|
33
|
+
})
|
|
34
|
+
export type WithPermissions = z.infer<typeof WithPermissions>
|