rise-wallet 0.1.4-beta.2 → 0.2.29-beta.1
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 +56 -34
- package/dist/cli/Dialog.d.ts +35 -0
- package/dist/cli/Dialog.d.ts.map +1 -0
- package/dist/cli/Dialog.js +60 -0
- package/dist/cli/Dialog.js.map +1 -0
- package/dist/cli/Messenger.d.ts +8 -0
- package/dist/cli/Messenger.d.ts.map +1 -0
- package/dist/cli/Messenger.js +123 -0
- package/dist/cli/Messenger.js.map +1 -0
- package/dist/cli/bin/commands-BWkYsY2L.js +50 -0
- package/dist/cli/bin/index.js +9 -0
- package/dist/cli/index.d.ts +3 -0
- package/dist/cli/index.d.ts.map +1 -0
- package/dist/cli/index.js +3 -0
- package/dist/cli/index.js.map +1 -0
- package/dist/cli/internal/commands.d.ts +13 -0
- package/dist/cli/internal/commands.d.ts.map +1 -0
- package/dist/cli/internal/commands.js +180 -0
- package/dist/cli/internal/commands.js.map +1 -0
- package/dist/cli/internal/context.d.ts +521 -0
- package/dist/cli/internal/context.d.ts.map +1 -0
- package/dist/cli/internal/context.js +38 -0
- package/dist/cli/internal/context.js.map +1 -0
- package/dist/cli/internal/http.d.ts +7 -0
- package/dist/cli/internal/http.d.ts.map +1 -0
- package/dist/cli/internal/http.js +17 -0
- package/dist/cli/internal/http.js.map +1 -0
- package/dist/cli/internal/utils.d.ts +7 -0
- package/dist/cli/internal/utils.d.ts.map +1 -0
- package/dist/cli/internal/utils.js +24 -0
- package/dist/cli/internal/utils.js.map +1 -0
- package/dist/core/Chains.d.ts +211 -0
- package/dist/core/Chains.d.ts.map +1 -0
- package/dist/core/Chains.js +20 -0
- package/dist/core/Chains.js.map +1 -0
- package/dist/core/Dialog.d.ts +308 -0
- package/dist/core/Dialog.d.ts.map +1 -0
- package/dist/core/Dialog.js +809 -0
- package/dist/core/Dialog.js.map +1 -0
- package/dist/core/Messenger.d.ts +165 -0
- package/dist/core/Messenger.d.ts.map +1 -0
- package/dist/core/Messenger.js +207 -0
- package/dist/core/Messenger.js.map +1 -0
- package/dist/core/Mode.d.ts +5 -0
- package/dist/core/Mode.d.ts.map +1 -0
- package/dist/core/Mode.js +5 -0
- package/dist/core/Mode.js.map +1 -0
- package/dist/core/Porto.d.ts +1609 -0
- package/dist/core/Porto.d.ts.map +1 -0
- package/dist/core/Porto.js +105 -0
- package/dist/core/Porto.js.map +1 -0
- package/dist/core/RpcSchema.d.ts +82 -0
- package/dist/core/RpcSchema.d.ts.map +1 -0
- package/dist/core/RpcSchema.js +2 -0
- package/dist/core/RpcSchema.js.map +1 -0
- package/dist/core/Storage.d.ts +15 -0
- package/dist/core/Storage.d.ts.map +1 -0
- package/dist/core/Storage.js +109 -0
- package/dist/core/Storage.js.map +1 -0
- package/dist/core/Transport.d.ts +23 -0
- package/dist/core/Transport.d.ts.map +1 -0
- package/dist/core/Transport.js +37 -0
- package/dist/core/Transport.js.map +1 -0
- package/dist/core/internal/_generated/chains.d.ts +2 -0
- package/dist/core/internal/_generated/chains.d.ts.map +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/EIP7702Proxy.d.ts +18 -0
- package/dist/core/internal/_generated/contracts/EIP7702Proxy.d.ts.map +1 -0
- package/dist/core/internal/_generated/contracts/EIP7702Proxy.js +24 -0
- package/dist/core/internal/_generated/contracts/EIP7702Proxy.js.map +1 -0
- package/dist/core/internal/_generated/contracts/Escrow.d.ts +256 -0
- package/dist/core/internal/_generated/contracts/Escrow.d.ts.map +1 -0
- package/dist/core/internal/_generated/contracts/Escrow.js +329 -0
- package/dist/core/internal/_generated/contracts/Escrow.js.map +1 -0
- package/dist/core/internal/_generated/contracts/ExperimentERC20.d.ts +440 -0
- package/dist/core/internal/_generated/contracts/ExperimentERC20.d.ts.map +1 -0
- package/dist/core/internal/_generated/contracts/ExperimentERC20.js +568 -0
- package/dist/core/internal/_generated/contracts/ExperimentERC20.js.map +1 -0
- package/dist/core/internal/_generated/contracts/ExperimentERC721.d.ts +456 -0
- package/dist/core/internal/_generated/contracts/ExperimentERC721.d.ts.map +1 -0
- package/dist/core/internal/_generated/contracts/ExperimentERC721.js +587 -0
- package/dist/core/internal/_generated/contracts/ExperimentERC721.js.map +1 -0
- package/dist/core/internal/_generated/contracts/GuardedExecutor.d.ts +482 -0
- package/dist/core/internal/_generated/contracts/GuardedExecutor.d.ts.map +1 -0
- package/dist/core/internal/_generated/contracts/GuardedExecutor.js +622 -0
- package/dist/core/internal/_generated/contracts/GuardedExecutor.js.map +1 -0
- package/dist/core/internal/_generated/contracts/ICallChecker.d.ts +25 -0
- package/dist/core/internal/_generated/contracts/ICallChecker.d.ts.map +1 -0
- package/dist/core/internal/_generated/contracts/ICallChecker.js +33 -0
- package/dist/core/internal/_generated/contracts/ICallChecker.js.map +1 -0
- package/dist/core/internal/_generated/contracts/ICommon.d.ts +3 -0
- package/dist/core/internal/_generated/contracts/ICommon.d.ts.map +1 -0
- package/dist/core/internal/_generated/contracts/ICommon.js +3 -0
- package/dist/core/internal/_generated/contracts/ICommon.js.map +1 -0
- package/dist/core/internal/_generated/contracts/IEscrow.d.ts +88 -0
- package/dist/core/internal/_generated/contracts/IEscrow.d.ts.map +1 -0
- package/dist/core/internal/_generated/contracts/IEscrow.js +113 -0
- package/dist/core/internal/_generated/contracts/IEscrow.js.map +1 -0
- package/dist/core/internal/_generated/contracts/IFunder.d.ts +61 -0
- package/dist/core/internal/_generated/contracts/IFunder.d.ts.map +1 -0
- package/dist/core/internal/_generated/contracts/IFunder.js +79 -0
- package/dist/core/internal/_generated/contracts/IFunder.js.map +1 -0
- package/dist/core/internal/_generated/contracts/IFunderV4.d.ts +34 -0
- package/dist/core/internal/_generated/contracts/IFunderV4.d.ts.map +1 -0
- package/dist/core/internal/_generated/contracts/IFunderV4.js +44 -0
- package/dist/core/internal/_generated/contracts/IFunderV4.js.map +1 -0
- package/dist/core/internal/_generated/contracts/IIthacaAccount.d.ts +81 -0
- package/dist/core/internal/_generated/contracts/IIthacaAccount.d.ts.map +1 -0
- package/dist/core/internal/_generated/contracts/IIthacaAccount.js +106 -0
- package/dist/core/internal/_generated/contracts/IIthacaAccount.js.map +1 -0
- package/dist/core/internal/_generated/contracts/IOAppCore.d.ts +108 -0
- package/dist/core/internal/_generated/contracts/IOAppCore.d.ts.map +1 -0
- package/dist/core/internal/_generated/contracts/IOAppCore.js +141 -0
- package/dist/core/internal/_generated/contracts/IOAppCore.js.map +1 -0
- package/dist/core/internal/_generated/contracts/IOAppMsgInspector.d.ts +33 -0
- package/dist/core/internal/_generated/contracts/IOAppMsgInspector.d.ts.map +1 -0
- package/dist/core/internal/_generated/contracts/IOAppMsgInspector.js +44 -0
- package/dist/core/internal/_generated/contracts/IOAppMsgInspector.js.map +1 -0
- package/dist/core/internal/_generated/contracts/IOAppReceiver.d.ts +122 -0
- package/dist/core/internal/_generated/contracts/IOAppReceiver.d.ts.map +1 -0
- package/dist/core/internal/_generated/contracts/IOAppReceiver.js +160 -0
- package/dist/core/internal/_generated/contracts/IOAppReceiver.js.map +1 -0
- package/dist/core/internal/_generated/contracts/IOrchestrator.d.ts +71 -0
- package/dist/core/internal/_generated/contracts/IOrchestrator.d.ts.map +1 -0
- package/dist/core/internal/_generated/contracts/IOrchestrator.js +94 -0
- package/dist/core/internal/_generated/contracts/IOrchestrator.js.map +1 -0
- package/dist/core/internal/_generated/contracts/ISettler.d.ts +39 -0
- package/dist/core/internal/_generated/contracts/ISettler.d.ts.map +1 -0
- package/dist/core/internal/_generated/contracts/ISettler.js +51 -0
- package/dist/core/internal/_generated/contracts/ISettler.js.map +1 -0
- package/dist/core/internal/_generated/contracts/ISigner.d.ts +25 -0
- package/dist/core/internal/_generated/contracts/ISigner.d.ts.map +1 -0
- package/dist/core/internal/_generated/contracts/ISigner.js +33 -0
- package/dist/core/internal/_generated/contracts/ISigner.js.map +1 -0
- package/dist/core/internal/_generated/contracts/IthacaAccount.d.ts +1121 -0
- package/dist/core/internal/_generated/contracts/IthacaAccount.d.ts.map +1 -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/_generated/contracts/IthacaAccountNew.d.ts +1121 -0
- package/dist/core/internal/_generated/contracts/IthacaAccountNew.d.ts.map +1 -0
- package/dist/core/internal/_generated/contracts/IthacaAccountNew.js +1453 -0
- package/dist/core/internal/_generated/contracts/IthacaAccountNew.js.map +1 -0
- package/dist/core/internal/_generated/contracts/IthacaAccountOld.d.ts +1121 -0
- package/dist/core/internal/_generated/contracts/IthacaAccountOld.d.ts.map +1 -0
- package/dist/core/internal/_generated/contracts/IthacaAccountOld.js +1453 -0
- package/dist/core/internal/_generated/contracts/IthacaAccountOld.js.map +1 -0
- package/dist/core/internal/_generated/contracts/LayerZeroSettler.d.ts +621 -0
- package/dist/core/internal/_generated/contracts/LayerZeroSettler.d.ts.map +1 -0
- package/dist/core/internal/_generated/contracts/LayerZeroSettler.js +810 -0
- package/dist/core/internal/_generated/contracts/LayerZeroSettler.js.map +1 -0
- package/dist/core/internal/_generated/contracts/LibNonce.d.ts +11 -0
- package/dist/core/internal/_generated/contracts/LibNonce.d.ts.map +1 -0
- package/dist/core/internal/_generated/contracts/LibNonce.js +14 -0
- package/dist/core/internal/_generated/contracts/LibNonce.js.map +1 -0
- package/dist/core/internal/_generated/contracts/LibTStack.d.ts +3 -0
- package/dist/core/internal/_generated/contracts/LibTStack.d.ts.map +1 -0
- package/dist/core/internal/_generated/contracts/LibTStack.js +3 -0
- package/dist/core/internal/_generated/contracts/LibTStack.js.map +1 -0
- package/dist/core/internal/_generated/contracts/MultiSigSigner.d.ts +157 -0
- package/dist/core/internal/_generated/contracts/MultiSigSigner.d.ts.map +1 -0
- package/dist/core/internal/_generated/contracts/MultiSigSigner.js +202 -0
- package/dist/core/internal/_generated/contracts/MultiSigSigner.js.map +1 -0
- package/dist/core/internal/_generated/contracts/OApp.d.ts +314 -0
- package/dist/core/internal/_generated/contracts/OApp.d.ts.map +1 -0
- package/dist/core/internal/_generated/contracts/OApp.js +411 -0
- package/dist/core/internal/_generated/contracts/OApp.js.map +1 -0
- package/dist/core/internal/_generated/contracts/OAppCore.d.ts +175 -0
- package/dist/core/internal/_generated/contracts/OAppCore.d.ts.map +1 -0
- package/dist/core/internal/_generated/contracts/OAppCore.js +228 -0
- package/dist/core/internal/_generated/contracts/OAppCore.js.map +1 -0
- package/dist/core/internal/_generated/contracts/OAppReceiver.d.ts +302 -0
- package/dist/core/internal/_generated/contracts/OAppReceiver.d.ts.map +1 -0
- package/dist/core/internal/_generated/contracts/OAppReceiver.js +395 -0
- package/dist/core/internal/_generated/contracts/OAppReceiver.js.map +1 -0
- package/dist/core/internal/_generated/contracts/OAppSender.d.ts +187 -0
- package/dist/core/internal/_generated/contracts/OAppSender.d.ts.map +1 -0
- package/dist/core/internal/_generated/contracts/OAppSender.js +244 -0
- package/dist/core/internal/_generated/contracts/OAppSender.js.map +1 -0
- package/dist/core/internal/_generated/contracts/Orchestrator.d.ts +302 -0
- package/dist/core/internal/_generated/contracts/Orchestrator.d.ts.map +1 -0
- package/dist/core/internal/_generated/contracts/Orchestrator.js +389 -0
- package/dist/core/internal/_generated/contracts/Orchestrator.js.map +1 -0
- package/dist/core/internal/_generated/contracts/SimpleFunder.d.ts +413 -0
- package/dist/core/internal/_generated/contracts/SimpleFunder.d.ts.map +1 -0
- package/dist/core/internal/_generated/contracts/SimpleFunder.js +533 -0
- package/dist/core/internal/_generated/contracts/SimpleFunder.js.map +1 -0
- package/dist/core/internal/_generated/contracts/SimpleSettler.d.ts +280 -0
- package/dist/core/internal/_generated/contracts/SimpleSettler.d.ts.map +1 -0
- package/dist/core/internal/_generated/contracts/SimpleSettler.js +359 -0
- package/dist/core/internal/_generated/contracts/SimpleSettler.js.map +1 -0
- package/dist/core/internal/_generated/contracts/Simulator.d.ts +131 -0
- package/dist/core/internal/_generated/contracts/Simulator.d.ts.map +1 -0
- package/dist/core/internal/_generated/contracts/Simulator.js +169 -0
- package/dist/core/internal/_generated/contracts/Simulator.js.map +1 -0
- package/dist/core/internal/_generated/contracts/TokenTransferLib.d.ts +3 -0
- package/dist/core/internal/_generated/contracts/TokenTransferLib.d.ts.map +1 -0
- package/dist/core/internal/_generated/contracts/TokenTransferLib.js +3 -0
- package/dist/core/internal/_generated/contracts/TokenTransferLib.js.map +1 -0
- package/dist/core/internal/call.d.ts +164 -0
- package/dist/core/internal/call.d.ts.map +1 -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 +18 -0
- package/dist/core/internal/erc8010.d.ts.map +1 -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 +2 -0
- package/dist/core/internal/intersectionObserver.d.ts.map +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 +22 -0
- package/dist/core/internal/logger.d.ts.map +1 -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 +345 -0
- package/dist/core/internal/mode.d.ts.map +1 -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 +800 -0
- package/dist/core/internal/modes/dialog.d.ts.map +1 -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 +1402 -0
- package/dist/core/internal/modes/reactNative.d.ts.map +1 -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 +685 -0
- package/dist/core/internal/modes/relay.d.ts.map +1 -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 +60 -0
- package/dist/core/internal/permissions.d.ts.map +1 -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 +72 -0
- package/dist/core/internal/permissionsRequest.d.ts.map +1 -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 +14 -0
- package/dist/core/internal/porto.d.ts.map +1 -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 +9 -0
- package/dist/core/internal/promise.d.ts.map +1 -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 +30 -0
- package/dist/core/internal/provider.d.ts.map +1 -0
- package/dist/core/internal/provider.js +944 -0
- package/dist/core/internal/provider.js.map +1 -0
- package/dist/core/internal/relay/rpcSchema.d.ts +76 -0
- package/dist/core/internal/relay/rpcSchema.d.ts.map +1 -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 +165 -0
- package/dist/core/internal/relay/schema/capabilities.d.ts.map +1 -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 +168 -0
- package/dist/core/internal/relay/schema/intent.d.ts.map +1 -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 +44 -0
- package/dist/core/internal/relay/schema/key.d.ts.map +1 -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 +40 -0
- package/dist/core/internal/relay/schema/permission.d.ts.map +1 -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 +63 -0
- package/dist/core/internal/relay/schema/preCall.d.ts.map +1 -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 +370 -0
- package/dist/core/internal/relay/schema/quotes.d.ts.map +1 -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 +1529 -0
- package/dist/core/internal/relay/schema/rpc.d.ts.map +1 -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 +14 -0
- package/dist/core/internal/relay/schema/token.d.ts.map +1 -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 +19 -0
- package/dist/core/internal/requiredFunds.d.ts.map +1 -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 +314 -0
- package/dist/core/internal/schema/capabilities.d.ts.map +1 -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 +165 -0
- package/dist/core/internal/schema/key.d.ts.map +1 -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 +103 -0
- package/dist/core/internal/schema/permissions.d.ts.map +1 -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 +938 -0
- package/dist/core/internal/schema/request.d.ts.map +1 -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 +3315 -0
- package/dist/core/internal/schema/rpc.d.ts.map +1 -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 +2 -0
- package/dist/core/internal/schema/token.d.ts.map +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 +19 -0
- package/dist/core/internal/schema/utils.d.ts.map +1 -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 +33 -0
- package/dist/core/internal/siwe.d.ts.map +1 -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 +3 -0
- package/dist/core/internal/store.d.ts.map +1 -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 +58 -0
- package/dist/core/internal/tokens.d.ts.map +1 -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 +299 -0
- package/dist/core/internal/types.d.ts.map +1 -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 +2 -0
- package/dist/core/internal/urlString.d.ts.map +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 +11 -0
- package/dist/core/internal/userAgent.d.ts.map +1 -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 +25 -0
- package/dist/core/internal/utils.d.ts.map +1 -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 +1481 -0
- package/dist/core/react-native/Porto.d.ts.map +1 -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 +10 -0
- package/dist/core/react-native/configure.d.ts.map +1 -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 +27 -0
- package/dist/core/react-native/environment.d.ts.map +1 -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 +5 -0
- package/dist/core/react-native/index.d.ts.map +1 -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 +2 -0
- package/dist/core/react-native/utils.d.ts.map +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 +17 -2
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +15 -2
- package/dist/index.js.map +1 -0
- package/dist/index.native.d.ts +8 -0
- package/dist/index.native.d.ts.map +1 -0
- package/dist/index.native.js +12 -0
- package/dist/index.native.js.map +1 -0
- package/dist/internal/index.d.ts +4 -0
- package/dist/internal/index.d.ts.map +1 -0
- package/dist/internal/index.js +4 -0
- package/dist/internal/index.js.map +1 -0
- package/dist/react-native/crypto.d.ts +2 -0
- package/dist/react-native/crypto.d.ts.map +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 +8 -0
- package/dist/react-native/index.d.ts.map +1 -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 +3 -0
- package/dist/react-native/register.d.ts.map +1 -0
- package/dist/react-native/register.js +15 -0
- package/dist/react-native/register.js.map +1 -0
- package/dist/register/index.d.ts +15 -0
- package/dist/register/index.d.ts.map +1 -0
- package/dist/register/index.js +2 -0
- package/dist/register/index.js.map +1 -0
- package/dist/remote/Actions.d.ts +34 -0
- package/dist/remote/Actions.d.ts.map +1 -0
- package/dist/remote/Actions.js +76 -0
- package/dist/remote/Actions.js.map +1 -0
- package/dist/remote/Events.d.ts +47 -0
- package/dist/remote/Events.d.ts.map +1 -0
- package/dist/remote/Events.js +132 -0
- package/dist/remote/Events.js.map +1 -0
- package/dist/remote/Hooks.d.ts +3801 -0
- package/dist/remote/Hooks.d.ts.map +1 -0
- package/dist/remote/Hooks.js +106 -0
- package/dist/remote/Hooks.js.map +1 -0
- package/dist/remote/Porto.d.ts +858 -0
- package/dist/remote/Porto.d.ts.map +1 -0
- package/dist/remote/Porto.js +66 -0
- package/dist/remote/Porto.js.map +1 -0
- package/dist/remote/index.d.ts +5 -0
- package/dist/remote/index.d.ts.map +1 -0
- package/dist/remote/index.js +5 -0
- package/dist/remote/index.js.map +1 -0
- package/dist/remote/internal/methodPolicies.d.ts +97 -0
- package/dist/remote/internal/methodPolicies.d.ts.map +1 -0
- package/dist/remote/internal/methodPolicies.js +102 -0
- package/dist/remote/internal/methodPolicies.js.map +1 -0
- package/dist/server/Route.d.ts +88 -0
- package/dist/server/Route.d.ts.map +1 -0
- package/dist/server/Route.js +189 -0
- package/dist/server/Route.js.map +1 -0
- package/dist/server/Router.d.ts +24 -0
- package/dist/server/Router.d.ts.map +1 -0
- package/dist/server/Router.js +29 -0
- package/dist/server/Router.js.map +1 -0
- package/dist/server/index.d.ts +3 -0
- package/dist/server/index.d.ts.map +1 -0
- package/dist/server/index.js +3 -0
- package/dist/server/index.js.map +1 -0
- package/dist/server/internal/merchantSchema.d.ts +65 -0
- package/dist/server/internal/merchantSchema.d.ts.map +1 -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 +124 -0
- package/dist/server/internal/requestListener.d.ts.map +1 -0
- package/dist/server/internal/requestListener.js +172 -0
- package/dist/server/internal/requestListener.js.map +1 -0
- package/dist/theme/Theme.d.ts +122 -0
- package/dist/theme/Theme.d.ts.map +1 -0
- package/dist/theme/Theme.js +18 -0
- package/dist/theme/Theme.js.map +1 -0
- package/dist/theme/index.d.ts +3 -0
- package/dist/theme/index.d.ts.map +1 -0
- package/dist/theme/index.js +2 -0
- package/dist/theme/index.js.map +1 -0
- package/dist/trusted-hosts.d.ts +2 -0
- package/dist/trusted-hosts.d.ts.map +1 -0
- package/dist/trusted-hosts.js +44 -0
- package/dist/trusted-hosts.js.map +1 -0
- package/dist/tsconfig.tmp.tsbuildinfo +1 -0
- package/dist/viem/Account.d.ts +111 -0
- package/dist/viem/Account.d.ts.map +1 -0
- package/dist/viem/Account.js +132 -0
- package/dist/viem/Account.js.map +1 -0
- package/dist/viem/AccountActions.d.ts +11 -0
- package/dist/viem/AccountActions.d.ts.map +1 -0
- package/dist/viem/AccountActions.js +14 -0
- package/dist/viem/AccountActions.js.map +1 -0
- package/dist/viem/CapabilitiesSchema.d.ts +15 -0
- package/dist/viem/CapabilitiesSchema.d.ts.map +1 -0
- package/dist/viem/CapabilitiesSchema.js +2 -0
- package/dist/viem/CapabilitiesSchema.js.map +1 -0
- package/dist/viem/ContractActions.d.ts +209 -0
- package/dist/viem/ContractActions.d.ts.map +1 -0
- package/dist/viem/ContractActions.js +350 -0
- package/dist/viem/ContractActions.js.map +1 -0
- package/dist/viem/Key.d.ts +1156 -0
- package/dist/viem/Key.d.ts.map +1 -0
- package/dist/viem/Key.js +924 -0
- package/dist/viem/Key.js.map +1 -0
- package/dist/viem/RelayActions.d.ts +436 -0
- package/dist/viem/RelayActions.d.ts.map +1 -0
- package/dist/viem/RelayActions.js +385 -0
- package/dist/viem/RelayActions.js.map +1 -0
- package/dist/viem/RelayClient.d.ts +27 -0
- package/dist/viem/RelayClient.d.ts.map +1 -0
- package/dist/viem/RelayClient.js +44 -0
- package/dist/viem/RelayClient.js.map +1 -0
- package/dist/viem/RpcSchema.d.ts +23 -0
- package/dist/viem/RpcSchema.d.ts.map +1 -0
- package/dist/viem/RpcSchema.js +2 -0
- package/dist/viem/RpcSchema.js.map +1 -0
- package/dist/viem/WalletActions.d.ts +87 -0
- package/dist/viem/WalletActions.d.ts.map +1 -0
- package/dist/viem/WalletActions.js +220 -0
- package/dist/viem/WalletActions.js.map +1 -0
- package/dist/viem/WalletClient.d.ts +21 -0
- package/dist/viem/WalletClient.d.ts.map +1 -0
- package/dist/viem/WalletClient.js +23 -0
- package/dist/viem/WalletClient.js.map +1 -0
- package/dist/viem/index.d.ts +14 -0
- package/dist/viem/index.d.ts.map +1 -0
- package/dist/viem/index.js +12 -0
- package/dist/viem/index.js.map +1 -0
- package/dist/viem/internal/relayActions.d.ts +365 -0
- package/dist/viem/internal/relayActions.d.ts.map +1 -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 +16 -0
- package/dist/viem/internal/utils.d.ts.map +1 -0
- package/dist/viem/internal/utils.js +2 -0
- package/dist/viem/internal/utils.js.map +1 -0
- package/dist/wagmi/Actions.d.ts +2 -0
- package/dist/wagmi/Actions.d.ts.map +1 -0
- package/dist/wagmi/Actions.js +2 -0
- package/dist/wagmi/Actions.js.map +1 -0
- package/dist/wagmi/Connector.d.ts +28 -0
- package/dist/wagmi/Connector.d.ts.map +1 -0
- package/dist/wagmi/Connector.js +238 -0
- package/dist/wagmi/Connector.js.map +1 -0
- package/dist/wagmi/Hooks.d.ts +2 -0
- package/dist/wagmi/Hooks.d.ts.map +1 -0
- package/dist/wagmi/Hooks.js +2 -0
- package/dist/wagmi/Hooks.js.map +1 -0
- package/dist/wagmi/Hooks.native.d.ts +3 -0
- package/dist/wagmi/Hooks.native.d.ts.map +1 -0
- package/dist/wagmi/Hooks.native.js +3 -0
- package/dist/wagmi/Hooks.native.js.map +1 -0
- package/dist/wagmi/Query.d.ts +2 -0
- package/dist/wagmi/Query.d.ts.map +1 -0
- package/dist/wagmi/Query.js +2 -0
- package/dist/wagmi/Query.js.map +1 -0
- package/dist/wagmi/index.d.ts +5 -0
- package/dist/wagmi/index.d.ts.map +1 -0
- package/dist/wagmi/index.js +5 -0
- package/dist/wagmi/index.js.map +1 -0
- package/dist/wagmi/index.native.d.ts +6 -0
- package/dist/wagmi/index.native.d.ts.map +1 -0
- package/dist/wagmi/index.native.js +6 -0
- package/dist/wagmi/index.native.js.map +1 -0
- package/dist/wagmi/internal/core.d.ts +84 -0
- package/dist/wagmi/internal/core.d.ts.map +1 -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 +33 -0
- package/dist/wagmi/internal/query.d.ts.map +1 -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 +91 -0
- package/dist/wagmi/internal/react.d.ts.map +1 -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 +11 -0
- package/dist/wagmi/internal/types.d.ts.map +1 -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 +2 -0
- package/dist/wagmi/internal/utils.d.ts.map +1 -0
- package/dist/wagmi/internal/utils.js +18 -0
- package/dist/wagmi/internal/utils.js.map +1 -0
- package/package.json +287 -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 +216 -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 +4 -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 +1278 -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.native.ts +15 -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 +43 -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 +306 -0
- package/src/wagmi/Hooks.native.ts +16 -0
- package/src/wagmi/Hooks.ts +14 -0
- package/src/wagmi/Query.ts +5 -0
- package/src/wagmi/index.native.ts +6 -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,1334 @@
|
|
|
1
|
+
import { describe, expect, test } from 'vitest'
|
|
2
|
+
import * as z from 'zod/mini'
|
|
3
|
+
import * as Capabilities from './capabilities.js'
|
|
4
|
+
import * as u from './utils.js'
|
|
5
|
+
|
|
6
|
+
describe('atomic', () => {
|
|
7
|
+
describe('GetCapabilitiesResponse', () => {
|
|
8
|
+
test('behavior: parse supported status', () => {
|
|
9
|
+
const result = z.parse(Capabilities.atomic.GetCapabilitiesResponse, {
|
|
10
|
+
status: 'supported',
|
|
11
|
+
})
|
|
12
|
+
expect(result).toMatchInlineSnapshot(`
|
|
13
|
+
{
|
|
14
|
+
"status": "supported",
|
|
15
|
+
}
|
|
16
|
+
`)
|
|
17
|
+
})
|
|
18
|
+
|
|
19
|
+
test('behavior: parse unsupported status', () => {
|
|
20
|
+
const result = z.parse(Capabilities.atomic.GetCapabilitiesResponse, {
|
|
21
|
+
status: 'unsupported',
|
|
22
|
+
})
|
|
23
|
+
expect(result).toMatchInlineSnapshot(`
|
|
24
|
+
{
|
|
25
|
+
"status": "unsupported",
|
|
26
|
+
}
|
|
27
|
+
`)
|
|
28
|
+
})
|
|
29
|
+
|
|
30
|
+
test('error: reject invalid status', () => {
|
|
31
|
+
expect(
|
|
32
|
+
u.toValidationError(
|
|
33
|
+
z.safeParse(Capabilities.atomic.GetCapabilitiesResponse, {
|
|
34
|
+
status: 'invalid',
|
|
35
|
+
}).error,
|
|
36
|
+
),
|
|
37
|
+
).toMatchInlineSnapshot(
|
|
38
|
+
`
|
|
39
|
+
[Schema.ValidationError: Validation failed with 1 error:
|
|
40
|
+
|
|
41
|
+
- at \`status\`: Invalid union value.
|
|
42
|
+
- Expected "supported"
|
|
43
|
+
- Expected "unsupported"]
|
|
44
|
+
`,
|
|
45
|
+
)
|
|
46
|
+
})
|
|
47
|
+
|
|
48
|
+
test('behavior: encode supported status', () => {
|
|
49
|
+
const decoded = z.parse(Capabilities.atomic.GetCapabilitiesResponse, {
|
|
50
|
+
status: 'supported',
|
|
51
|
+
})
|
|
52
|
+
const encoded = z.encode(
|
|
53
|
+
Capabilities.atomic.GetCapabilitiesResponse,
|
|
54
|
+
decoded,
|
|
55
|
+
)
|
|
56
|
+
expect(encoded).toMatchInlineSnapshot(`
|
|
57
|
+
{
|
|
58
|
+
"status": "supported",
|
|
59
|
+
}
|
|
60
|
+
`)
|
|
61
|
+
})
|
|
62
|
+
|
|
63
|
+
test('behavior: encode unsupported status', () => {
|
|
64
|
+
const decoded = z.parse(Capabilities.atomic.GetCapabilitiesResponse, {
|
|
65
|
+
status: 'unsupported',
|
|
66
|
+
})
|
|
67
|
+
const encoded = z.encode(
|
|
68
|
+
Capabilities.atomic.GetCapabilitiesResponse,
|
|
69
|
+
decoded,
|
|
70
|
+
)
|
|
71
|
+
expect(encoded).toMatchInlineSnapshot(`
|
|
72
|
+
{
|
|
73
|
+
"status": "unsupported",
|
|
74
|
+
}
|
|
75
|
+
`)
|
|
76
|
+
})
|
|
77
|
+
|
|
78
|
+
test('behavior: round-trip encoding/decoding preserves data', () => {
|
|
79
|
+
const originalData = { status: 'supported' as const }
|
|
80
|
+
const decoded = z.parse(
|
|
81
|
+
Capabilities.atomic.GetCapabilitiesResponse,
|
|
82
|
+
originalData,
|
|
83
|
+
)
|
|
84
|
+
const encoded = z.encode(
|
|
85
|
+
Capabilities.atomic.GetCapabilitiesResponse,
|
|
86
|
+
decoded,
|
|
87
|
+
)
|
|
88
|
+
const reDecoded = z.parse(
|
|
89
|
+
Capabilities.atomic.GetCapabilitiesResponse,
|
|
90
|
+
encoded,
|
|
91
|
+
)
|
|
92
|
+
expect(reDecoded).toEqual(decoded)
|
|
93
|
+
})
|
|
94
|
+
|
|
95
|
+
test('error: reject missing status', () => {
|
|
96
|
+
expect(
|
|
97
|
+
u.toValidationError(
|
|
98
|
+
z.safeParse(Capabilities.atomic.GetCapabilitiesResponse, {}).error,
|
|
99
|
+
),
|
|
100
|
+
).toMatchInlineSnapshot(
|
|
101
|
+
`
|
|
102
|
+
[Schema.ValidationError: Validation failed with 1 error:
|
|
103
|
+
|
|
104
|
+
- at \`status\`: Invalid union value.
|
|
105
|
+
- Expected "supported"
|
|
106
|
+
- Expected "unsupported"]
|
|
107
|
+
`,
|
|
108
|
+
)
|
|
109
|
+
})
|
|
110
|
+
})
|
|
111
|
+
})
|
|
112
|
+
|
|
113
|
+
describe('createAccount', () => {
|
|
114
|
+
describe('Request', () => {
|
|
115
|
+
test('behavior: parse boolean true', () => {
|
|
116
|
+
const result = z.parse(Capabilities.createAccount.Request, true)
|
|
117
|
+
expect(result).toBe(true)
|
|
118
|
+
})
|
|
119
|
+
|
|
120
|
+
test('behavior: parse boolean false', () => {
|
|
121
|
+
const result = z.parse(Capabilities.createAccount.Request, false)
|
|
122
|
+
expect(result).toBe(false)
|
|
123
|
+
})
|
|
124
|
+
|
|
125
|
+
test('behavior: parse object with chainId', () => {
|
|
126
|
+
const result = z.parse(Capabilities.createAccount.Request, {
|
|
127
|
+
chainId: '0x1',
|
|
128
|
+
})
|
|
129
|
+
expect(result).toMatchInlineSnapshot(`
|
|
130
|
+
{
|
|
131
|
+
"chainId": 1,
|
|
132
|
+
}
|
|
133
|
+
`)
|
|
134
|
+
})
|
|
135
|
+
|
|
136
|
+
test('behavior: parse object with label', () => {
|
|
137
|
+
const result = z.parse(Capabilities.createAccount.Request, {
|
|
138
|
+
label: 'My Account',
|
|
139
|
+
})
|
|
140
|
+
expect(result).toMatchInlineSnapshot(`
|
|
141
|
+
{
|
|
142
|
+
"label": "My Account",
|
|
143
|
+
}
|
|
144
|
+
`)
|
|
145
|
+
})
|
|
146
|
+
|
|
147
|
+
test('behavior: parse object with both chainId and label', () => {
|
|
148
|
+
const result = z.parse(Capabilities.createAccount.Request, {
|
|
149
|
+
chainId: '0xa',
|
|
150
|
+
label: 'Test Account',
|
|
151
|
+
})
|
|
152
|
+
expect(result).toMatchInlineSnapshot(`
|
|
153
|
+
{
|
|
154
|
+
"chainId": 10,
|
|
155
|
+
"label": "Test Account",
|
|
156
|
+
}
|
|
157
|
+
`)
|
|
158
|
+
})
|
|
159
|
+
|
|
160
|
+
test('behavior: parse empty object', () => {
|
|
161
|
+
const result = z.parse(Capabilities.createAccount.Request, {})
|
|
162
|
+
expect(result).toMatchInlineSnapshot('{}')
|
|
163
|
+
})
|
|
164
|
+
|
|
165
|
+
test('behavior: encode boolean true', () => {
|
|
166
|
+
const decoded = z.parse(Capabilities.createAccount.Request, true)
|
|
167
|
+
const encoded = z.encode(Capabilities.createAccount.Request, decoded)
|
|
168
|
+
expect(encoded).toBe(true)
|
|
169
|
+
})
|
|
170
|
+
|
|
171
|
+
test('behavior: encode boolean false', () => {
|
|
172
|
+
const decoded = z.parse(Capabilities.createAccount.Request, false)
|
|
173
|
+
const encoded = z.encode(Capabilities.createAccount.Request, decoded)
|
|
174
|
+
expect(encoded).toBe(false)
|
|
175
|
+
})
|
|
176
|
+
|
|
177
|
+
test('behavior: encode object with chainId back to hex', () => {
|
|
178
|
+
const originalData = { chainId: '0xa' }
|
|
179
|
+
const decoded = z.parse(Capabilities.createAccount.Request, originalData)
|
|
180
|
+
const encoded = z.encode(Capabilities.createAccount.Request, decoded)
|
|
181
|
+
expect(encoded).toMatchInlineSnapshot(`
|
|
182
|
+
{
|
|
183
|
+
"chainId": "0xa",
|
|
184
|
+
}
|
|
185
|
+
`)
|
|
186
|
+
})
|
|
187
|
+
|
|
188
|
+
test('behavior: encode object with label', () => {
|
|
189
|
+
const originalData = { label: 'My Account' }
|
|
190
|
+
const decoded = z.parse(Capabilities.createAccount.Request, originalData)
|
|
191
|
+
const encoded = z.encode(Capabilities.createAccount.Request, decoded)
|
|
192
|
+
expect(encoded).toMatchInlineSnapshot(`
|
|
193
|
+
{
|
|
194
|
+
"label": "My Account",
|
|
195
|
+
}
|
|
196
|
+
`)
|
|
197
|
+
})
|
|
198
|
+
|
|
199
|
+
test('behavior: encode object with both chainId and label', () => {
|
|
200
|
+
const originalData = { chainId: '0x1', label: 'Test Account' }
|
|
201
|
+
const decoded = z.parse(Capabilities.createAccount.Request, originalData)
|
|
202
|
+
const encoded = z.encode(Capabilities.createAccount.Request, decoded)
|
|
203
|
+
expect(encoded).toMatchInlineSnapshot(`
|
|
204
|
+
{
|
|
205
|
+
"chainId": "0x1",
|
|
206
|
+
"label": "Test Account",
|
|
207
|
+
}
|
|
208
|
+
`)
|
|
209
|
+
})
|
|
210
|
+
|
|
211
|
+
test('behavior: encode empty object', () => {
|
|
212
|
+
const decoded = z.parse(Capabilities.createAccount.Request, {})
|
|
213
|
+
const encoded = z.encode(Capabilities.createAccount.Request, decoded)
|
|
214
|
+
expect(encoded).toMatchInlineSnapshot('{}')
|
|
215
|
+
})
|
|
216
|
+
|
|
217
|
+
test.each([
|
|
218
|
+
{ case: 'boolean true', expected: true, input: true },
|
|
219
|
+
{ case: 'boolean false', expected: false, input: false },
|
|
220
|
+
{ case: 'empty object', expected: {}, input: {} },
|
|
221
|
+
{
|
|
222
|
+
case: 'object with label',
|
|
223
|
+
expected: { label: 'Test' },
|
|
224
|
+
input: { label: 'Test' },
|
|
225
|
+
},
|
|
226
|
+
{
|
|
227
|
+
case: 'object with chainId number to hex',
|
|
228
|
+
expected: { chainId: '0xa' },
|
|
229
|
+
input: { chainId: 10 },
|
|
230
|
+
},
|
|
231
|
+
{
|
|
232
|
+
case: 'object with both fields',
|
|
233
|
+
expected: { chainId: '0x1', label: 'Both Fields' },
|
|
234
|
+
input: { chainId: 1, label: 'Both Fields' },
|
|
235
|
+
},
|
|
236
|
+
])('behavior: encodes $case correctly', ({ input, expected }) => {
|
|
237
|
+
const encoded = z.encode(Capabilities.createAccount.Request, input)
|
|
238
|
+
expect(encoded).toEqual(expected)
|
|
239
|
+
})
|
|
240
|
+
|
|
241
|
+
test('error: reject invalid type', () => {
|
|
242
|
+
expect(
|
|
243
|
+
u.toValidationError(
|
|
244
|
+
z.safeParse(Capabilities.createAccount.Request, 'string').error,
|
|
245
|
+
),
|
|
246
|
+
).toMatchInlineSnapshot(
|
|
247
|
+
`
|
|
248
|
+
[Schema.ValidationError: Validation failed with 1 error:
|
|
249
|
+
|
|
250
|
+
- Invalid union value.
|
|
251
|
+
- Expected boolean.
|
|
252
|
+
- Expected object. ]
|
|
253
|
+
`,
|
|
254
|
+
)
|
|
255
|
+
})
|
|
256
|
+
})
|
|
257
|
+
})
|
|
258
|
+
|
|
259
|
+
describe('signInWithEthereum', () => {
|
|
260
|
+
describe('Request', () => {
|
|
261
|
+
test('behavior: parse struct with nonce and no authUrl', () => {
|
|
262
|
+
const result = z.parse(Capabilities.signInWithEthereum.Request, {
|
|
263
|
+
nonce: 'abc123',
|
|
264
|
+
})
|
|
265
|
+
expect(result).toMatchInlineSnapshot(`
|
|
266
|
+
{
|
|
267
|
+
"nonce": "abc123",
|
|
268
|
+
}
|
|
269
|
+
`)
|
|
270
|
+
})
|
|
271
|
+
|
|
272
|
+
test('behavior: parse struct with authUrl string', () => {
|
|
273
|
+
const result = z.parse(Capabilities.signInWithEthereum.Request, {
|
|
274
|
+
authUrl: 'https://example.com/auth',
|
|
275
|
+
nonce: 'xyz789',
|
|
276
|
+
})
|
|
277
|
+
expect(result).toMatchInlineSnapshot(`
|
|
278
|
+
{
|
|
279
|
+
"nonce": "xyz789",
|
|
280
|
+
}
|
|
281
|
+
`)
|
|
282
|
+
})
|
|
283
|
+
|
|
284
|
+
test('behavior: parse struct with all optional fields', () => {
|
|
285
|
+
const result = z.parse(Capabilities.signInWithEthereum.Request, {
|
|
286
|
+
authUrl: undefined,
|
|
287
|
+
chainId: 1,
|
|
288
|
+
domain: 'example.com',
|
|
289
|
+
expirationTime: new Date('2024-12-31T00:00:00.000Z'),
|
|
290
|
+
issuedAt: new Date('2024-01-01T00:00:00.000Z'),
|
|
291
|
+
nonce: 'test123',
|
|
292
|
+
notBefore: new Date('2024-06-01T00:00:00.000Z'),
|
|
293
|
+
requestId: 'req123',
|
|
294
|
+
resources: ['https://example.com/resource1'],
|
|
295
|
+
scheme: 'https',
|
|
296
|
+
statement: 'Sign in to example.com',
|
|
297
|
+
uri: 'https://example.com',
|
|
298
|
+
version: '1',
|
|
299
|
+
})
|
|
300
|
+
expect(result).toMatchInlineSnapshot(`
|
|
301
|
+
{
|
|
302
|
+
"chainId": 1,
|
|
303
|
+
"domain": "example.com",
|
|
304
|
+
"expirationTime": 2024-12-31T00:00:00.000Z,
|
|
305
|
+
"issuedAt": 2024-01-01T00:00:00.000Z,
|
|
306
|
+
"nonce": "test123",
|
|
307
|
+
"notBefore": 2024-06-01T00:00:00.000Z,
|
|
308
|
+
"requestId": "req123",
|
|
309
|
+
"resources": [
|
|
310
|
+
"https://example.com/resource1",
|
|
311
|
+
],
|
|
312
|
+
"scheme": "https",
|
|
313
|
+
"statement": "Sign in to example.com",
|
|
314
|
+
"uri": "https://example.com",
|
|
315
|
+
"version": "1",
|
|
316
|
+
}
|
|
317
|
+
`)
|
|
318
|
+
})
|
|
319
|
+
|
|
320
|
+
test('error: reject struct without nonce', () => {
|
|
321
|
+
expect(
|
|
322
|
+
u.toValidationError(
|
|
323
|
+
z.safeParse(Capabilities.signInWithEthereum.Request, {
|
|
324
|
+
domain: 'example.com',
|
|
325
|
+
}).error,
|
|
326
|
+
),
|
|
327
|
+
).toMatchInlineSnapshot(
|
|
328
|
+
`
|
|
329
|
+
[Schema.ValidationError: Validation failed with 1 error:
|
|
330
|
+
|
|
331
|
+
- Invalid union value.
|
|
332
|
+
- at \`nonce\`: Expected string.
|
|
333
|
+
- at \`authUrl\`: Invalid union value.
|
|
334
|
+
- Expected string.
|
|
335
|
+
- Expected object. ]
|
|
336
|
+
`,
|
|
337
|
+
)
|
|
338
|
+
})
|
|
339
|
+
|
|
340
|
+
test('behavior: encode struct with nonce', () => {
|
|
341
|
+
const originalData = { nonce: 'abc123' }
|
|
342
|
+
const decoded = z.parse(
|
|
343
|
+
Capabilities.signInWithEthereum.Request,
|
|
344
|
+
originalData,
|
|
345
|
+
)
|
|
346
|
+
const encoded = z.encode(Capabilities.signInWithEthereum.Request, decoded)
|
|
347
|
+
expect(encoded).toMatchInlineSnapshot(`
|
|
348
|
+
{
|
|
349
|
+
"nonce": "abc123",
|
|
350
|
+
}
|
|
351
|
+
`)
|
|
352
|
+
})
|
|
353
|
+
|
|
354
|
+
test('behavior: encode struct with authUrl', () => {
|
|
355
|
+
const originalData = {
|
|
356
|
+
authUrl: 'https://example.com/auth',
|
|
357
|
+
nonce: 'xyz789',
|
|
358
|
+
}
|
|
359
|
+
const decoded = z.parse(
|
|
360
|
+
Capabilities.signInWithEthereum.Request,
|
|
361
|
+
originalData,
|
|
362
|
+
)
|
|
363
|
+
const encoded = z.encode(Capabilities.signInWithEthereum.Request, decoded)
|
|
364
|
+
expect(encoded).toMatchInlineSnapshot(`
|
|
365
|
+
{
|
|
366
|
+
"nonce": "xyz789",
|
|
367
|
+
}
|
|
368
|
+
`)
|
|
369
|
+
})
|
|
370
|
+
|
|
371
|
+
test('behavior: encode struct with all fields including dates', () => {
|
|
372
|
+
const originalData = {
|
|
373
|
+
authUrl: undefined,
|
|
374
|
+
chainId: 1,
|
|
375
|
+
domain: 'example.com',
|
|
376
|
+
expirationTime: new Date('2024-12-31T00:00:00.000Z'),
|
|
377
|
+
issuedAt: new Date('2024-01-01T00:00:00.000Z'),
|
|
378
|
+
nonce: 'test123',
|
|
379
|
+
notBefore: new Date('2024-06-01T00:00:00.000Z'),
|
|
380
|
+
requestId: 'req123',
|
|
381
|
+
resources: ['https://example.com/resource1'],
|
|
382
|
+
scheme: 'https',
|
|
383
|
+
statement: 'Sign in to example.com',
|
|
384
|
+
uri: 'https://example.com',
|
|
385
|
+
version: '1' as const,
|
|
386
|
+
}
|
|
387
|
+
const decoded = z.parse(
|
|
388
|
+
Capabilities.signInWithEthereum.Request,
|
|
389
|
+
originalData,
|
|
390
|
+
)
|
|
391
|
+
const encoded = z.encode(Capabilities.signInWithEthereum.Request, decoded)
|
|
392
|
+
expect(encoded).toMatchInlineSnapshot(`
|
|
393
|
+
{
|
|
394
|
+
"chainId": 1,
|
|
395
|
+
"domain": "example.com",
|
|
396
|
+
"expirationTime": 2024-12-31T00:00:00.000Z,
|
|
397
|
+
"issuedAt": 2024-01-01T00:00:00.000Z,
|
|
398
|
+
"nonce": "test123",
|
|
399
|
+
"notBefore": 2024-06-01T00:00:00.000Z,
|
|
400
|
+
"requestId": "req123",
|
|
401
|
+
"resources": [
|
|
402
|
+
"https://example.com/resource1",
|
|
403
|
+
],
|
|
404
|
+
"scheme": "https",
|
|
405
|
+
"statement": "Sign in to example.com",
|
|
406
|
+
"uri": "https://example.com",
|
|
407
|
+
"version": "1",
|
|
408
|
+
}
|
|
409
|
+
`)
|
|
410
|
+
})
|
|
411
|
+
|
|
412
|
+
test.each([
|
|
413
|
+
{
|
|
414
|
+
case: 'nonce only',
|
|
415
|
+
expected: { nonce: 'test1' },
|
|
416
|
+
input: { nonce: 'test1' },
|
|
417
|
+
},
|
|
418
|
+
{
|
|
419
|
+
case: 'authUrl only',
|
|
420
|
+
expected: { authUrl: 'https://test.com' },
|
|
421
|
+
input: { authUrl: 'https://test.com' },
|
|
422
|
+
},
|
|
423
|
+
{
|
|
424
|
+
case: 'authUrl with properties',
|
|
425
|
+
expected: {
|
|
426
|
+
authUrl: {
|
|
427
|
+
logout: 'https://test.com/logout',
|
|
428
|
+
nonce: 'https://test.com/nonce',
|
|
429
|
+
verify: 'https://test.com/verify',
|
|
430
|
+
},
|
|
431
|
+
},
|
|
432
|
+
input: {
|
|
433
|
+
authUrl: {
|
|
434
|
+
logout: 'https://test.com/logout',
|
|
435
|
+
nonce: 'https://test.com/nonce',
|
|
436
|
+
verify: 'https://test.com/verify',
|
|
437
|
+
},
|
|
438
|
+
},
|
|
439
|
+
},
|
|
440
|
+
{
|
|
441
|
+
case: 'multiple fields with undefined authUrl',
|
|
442
|
+
expected: {
|
|
443
|
+
chainId: 5,
|
|
444
|
+
domain: 'test.com',
|
|
445
|
+
nonce: 'test3',
|
|
446
|
+
version: '1',
|
|
447
|
+
},
|
|
448
|
+
input: {
|
|
449
|
+
chainId: 5,
|
|
450
|
+
domain: 'test.com',
|
|
451
|
+
nonce: 'test3',
|
|
452
|
+
version: '1' as const,
|
|
453
|
+
},
|
|
454
|
+
},
|
|
455
|
+
])('behavior: encodes $case correctly', ({ input, expected }) => {
|
|
456
|
+
const encoded = z.encode(Capabilities.signInWithEthereum.Request, input)
|
|
457
|
+
expect(encoded).toEqual(expected)
|
|
458
|
+
})
|
|
459
|
+
|
|
460
|
+
test('error: reject invalid version', () => {
|
|
461
|
+
expect(
|
|
462
|
+
u.toValidationError(
|
|
463
|
+
z.safeParse(Capabilities.signInWithEthereum.Request, {
|
|
464
|
+
nonce: 'test',
|
|
465
|
+
version: '2',
|
|
466
|
+
}).error,
|
|
467
|
+
),
|
|
468
|
+
).toMatchInlineSnapshot(
|
|
469
|
+
`
|
|
470
|
+
[Schema.ValidationError: Validation failed with 1 error:
|
|
471
|
+
|
|
472
|
+
- Invalid union value.
|
|
473
|
+
- at \`version\`: Expected "1"
|
|
474
|
+
- at \`authUrl\`: Invalid union value.
|
|
475
|
+
- Expected string.
|
|
476
|
+
- Expected object.
|
|
477
|
+
- at \`version\`: Expected "1"]
|
|
478
|
+
`,
|
|
479
|
+
)
|
|
480
|
+
})
|
|
481
|
+
})
|
|
482
|
+
|
|
483
|
+
describe('Response', () => {
|
|
484
|
+
test('behavior: parse valid response', () => {
|
|
485
|
+
const result = z.parse(Capabilities.signInWithEthereum.Response, {
|
|
486
|
+
message: 'Sign in to example.com',
|
|
487
|
+
signature: '0xdeadbeef',
|
|
488
|
+
})
|
|
489
|
+
expect(result).toMatchInlineSnapshot(`
|
|
490
|
+
{
|
|
491
|
+
"message": "Sign in to example.com",
|
|
492
|
+
"signature": "0xdeadbeef",
|
|
493
|
+
}
|
|
494
|
+
`)
|
|
495
|
+
})
|
|
496
|
+
|
|
497
|
+
test('error: reject missing message', () => {
|
|
498
|
+
expect(
|
|
499
|
+
u.toValidationError(
|
|
500
|
+
z.safeParse(Capabilities.signInWithEthereum.Response, {
|
|
501
|
+
signature: '0xdeadbeef',
|
|
502
|
+
}).error,
|
|
503
|
+
),
|
|
504
|
+
).toMatchInlineSnapshot(
|
|
505
|
+
`
|
|
506
|
+
[Schema.ValidationError: Validation failed with 1 error:
|
|
507
|
+
|
|
508
|
+
- at \`message\`: Expected string. ]
|
|
509
|
+
`,
|
|
510
|
+
)
|
|
511
|
+
})
|
|
512
|
+
|
|
513
|
+
test('error: reject missing signature', () => {
|
|
514
|
+
expect(
|
|
515
|
+
u.toValidationError(
|
|
516
|
+
z.safeParse(Capabilities.signInWithEthereum.Response, {
|
|
517
|
+
message: 'Sign in',
|
|
518
|
+
}).error,
|
|
519
|
+
),
|
|
520
|
+
).toMatchInlineSnapshot(
|
|
521
|
+
`
|
|
522
|
+
[Schema.ValidationError: Validation failed with 1 error:
|
|
523
|
+
|
|
524
|
+
- at \`signature\`: Expected template_literal. Needs string in format ^0x[A-Fa-f0-9]+$.]
|
|
525
|
+
`,
|
|
526
|
+
)
|
|
527
|
+
})
|
|
528
|
+
|
|
529
|
+
test('behavior: encode valid response', () => {
|
|
530
|
+
const originalData = {
|
|
531
|
+
message: 'Sign in to example.com',
|
|
532
|
+
signature: '0xdeadbeef',
|
|
533
|
+
}
|
|
534
|
+
const decoded = z.parse(
|
|
535
|
+
Capabilities.signInWithEthereum.Response,
|
|
536
|
+
originalData,
|
|
537
|
+
)
|
|
538
|
+
const encoded = z.encode(
|
|
539
|
+
Capabilities.signInWithEthereum.Response,
|
|
540
|
+
decoded,
|
|
541
|
+
)
|
|
542
|
+
expect(encoded).toMatchInlineSnapshot(`
|
|
543
|
+
{
|
|
544
|
+
"message": "Sign in to example.com",
|
|
545
|
+
"signature": "0xdeadbeef",
|
|
546
|
+
}
|
|
547
|
+
`)
|
|
548
|
+
})
|
|
549
|
+
|
|
550
|
+
test('behavior: encodes response preserving signature format', () => {
|
|
551
|
+
const input = { message: 'Test message', signature: '0x123456789abcdef' }
|
|
552
|
+
const decoded = z.parse(Capabilities.signInWithEthereum.Response, input)
|
|
553
|
+
const encoded = z.encode(
|
|
554
|
+
Capabilities.signInWithEthereum.Response,
|
|
555
|
+
decoded,
|
|
556
|
+
)
|
|
557
|
+
expect(encoded).toEqual({
|
|
558
|
+
message: 'Test message',
|
|
559
|
+
signature: '0x123456789abcdef',
|
|
560
|
+
})
|
|
561
|
+
})
|
|
562
|
+
|
|
563
|
+
test('error: reject invalid signature format', () => {
|
|
564
|
+
expect(
|
|
565
|
+
u.toValidationError(
|
|
566
|
+
z.safeParse(Capabilities.signInWithEthereum.Response, {
|
|
567
|
+
message: 'Sign in',
|
|
568
|
+
signature: 'invalid',
|
|
569
|
+
}).error,
|
|
570
|
+
),
|
|
571
|
+
).toMatchInlineSnapshot(
|
|
572
|
+
`
|
|
573
|
+
[Schema.ValidationError: Validation failed with 1 error:
|
|
574
|
+
|
|
575
|
+
- at \`signature\`: Must match pattern: ^0x[\\s\\S]{0,}$]
|
|
576
|
+
`,
|
|
577
|
+
)
|
|
578
|
+
})
|
|
579
|
+
})
|
|
580
|
+
})
|
|
581
|
+
|
|
582
|
+
describe('feeToken', () => {
|
|
583
|
+
describe('GetCapabilitiesResponse', () => {
|
|
584
|
+
test('behavior: parse response with empty tokens', () => {
|
|
585
|
+
const result = z.parse(Capabilities.feeToken.GetCapabilitiesResponse, {
|
|
586
|
+
supported: true,
|
|
587
|
+
tokens: [],
|
|
588
|
+
})
|
|
589
|
+
expect(result).toMatchInlineSnapshot(`
|
|
590
|
+
{
|
|
591
|
+
"supported": true,
|
|
592
|
+
"tokens": [],
|
|
593
|
+
}
|
|
594
|
+
`)
|
|
595
|
+
})
|
|
596
|
+
|
|
597
|
+
test('behavior: parse response with tokens', () => {
|
|
598
|
+
const result = z.parse(Capabilities.feeToken.GetCapabilitiesResponse, {
|
|
599
|
+
supported: true,
|
|
600
|
+
tokens: [
|
|
601
|
+
{
|
|
602
|
+
address: '0x1234567890abcdef',
|
|
603
|
+
decimals: 18,
|
|
604
|
+
interop: true,
|
|
605
|
+
symbol: 'USDC',
|
|
606
|
+
uid: 'usdc',
|
|
607
|
+
},
|
|
608
|
+
{
|
|
609
|
+
address: '0xfedcba0987654321',
|
|
610
|
+
decimals: 6,
|
|
611
|
+
interop: true,
|
|
612
|
+
nativeRate: '0x1000',
|
|
613
|
+
symbol: 'USDT',
|
|
614
|
+
uid: 'usdt',
|
|
615
|
+
},
|
|
616
|
+
],
|
|
617
|
+
})
|
|
618
|
+
expect(result).toMatchInlineSnapshot(`
|
|
619
|
+
{
|
|
620
|
+
"supported": true,
|
|
621
|
+
"tokens": [
|
|
622
|
+
{
|
|
623
|
+
"address": "0x1234567890abcdef",
|
|
624
|
+
"decimals": 18,
|
|
625
|
+
"interop": true,
|
|
626
|
+
"symbol": "USDC",
|
|
627
|
+
"uid": "usdc",
|
|
628
|
+
},
|
|
629
|
+
{
|
|
630
|
+
"address": "0xfedcba0987654321",
|
|
631
|
+
"decimals": 6,
|
|
632
|
+
"interop": true,
|
|
633
|
+
"nativeRate": 4096n,
|
|
634
|
+
"symbol": "USDT",
|
|
635
|
+
"uid": "usdt",
|
|
636
|
+
},
|
|
637
|
+
],
|
|
638
|
+
}
|
|
639
|
+
`)
|
|
640
|
+
})
|
|
641
|
+
|
|
642
|
+
test('error: reject missing supported field', () => {
|
|
643
|
+
expect(
|
|
644
|
+
u.toValidationError(
|
|
645
|
+
z.safeParse(Capabilities.feeToken.GetCapabilitiesResponse, {
|
|
646
|
+
tokens: [],
|
|
647
|
+
}).error,
|
|
648
|
+
),
|
|
649
|
+
).toMatchInlineSnapshot(
|
|
650
|
+
`
|
|
651
|
+
[Schema.ValidationError: Validation failed with 1 error:
|
|
652
|
+
|
|
653
|
+
- at \`supported\`: Expected boolean. ]
|
|
654
|
+
`,
|
|
655
|
+
)
|
|
656
|
+
})
|
|
657
|
+
|
|
658
|
+
test('behavior: encode response with empty tokens', () => {
|
|
659
|
+
const originalData = { supported: true, tokens: [] }
|
|
660
|
+
const decoded = z.parse(
|
|
661
|
+
Capabilities.feeToken.GetCapabilitiesResponse,
|
|
662
|
+
originalData,
|
|
663
|
+
)
|
|
664
|
+
const encoded = z.encode(
|
|
665
|
+
Capabilities.feeToken.GetCapabilitiesResponse,
|
|
666
|
+
decoded,
|
|
667
|
+
)
|
|
668
|
+
expect(encoded).toMatchInlineSnapshot(`
|
|
669
|
+
{
|
|
670
|
+
"supported": true,
|
|
671
|
+
"tokens": [],
|
|
672
|
+
}
|
|
673
|
+
`)
|
|
674
|
+
})
|
|
675
|
+
|
|
676
|
+
test('behavior: encode response with tokens and BigInt nativeRate', () => {
|
|
677
|
+
const originalData = {
|
|
678
|
+
supported: true,
|
|
679
|
+
tokens: [
|
|
680
|
+
{
|
|
681
|
+
address: '0x1234567890abcdef',
|
|
682
|
+
decimals: 18,
|
|
683
|
+
interop: true,
|
|
684
|
+
symbol: 'USDC',
|
|
685
|
+
uid: 'usdc',
|
|
686
|
+
},
|
|
687
|
+
{
|
|
688
|
+
address: '0xfedcba0987654321',
|
|
689
|
+
decimals: 6,
|
|
690
|
+
interop: true,
|
|
691
|
+
nativeRate: '0x1000',
|
|
692
|
+
symbol: 'USDT',
|
|
693
|
+
uid: 'usdt',
|
|
694
|
+
},
|
|
695
|
+
],
|
|
696
|
+
}
|
|
697
|
+
const decoded = z.parse(
|
|
698
|
+
Capabilities.feeToken.GetCapabilitiesResponse,
|
|
699
|
+
originalData,
|
|
700
|
+
)
|
|
701
|
+
const encoded = z.encode(
|
|
702
|
+
Capabilities.feeToken.GetCapabilitiesResponse,
|
|
703
|
+
decoded,
|
|
704
|
+
)
|
|
705
|
+
expect(encoded).toMatchInlineSnapshot(`
|
|
706
|
+
{
|
|
707
|
+
"supported": true,
|
|
708
|
+
"tokens": [
|
|
709
|
+
{
|
|
710
|
+
"address": "0x1234567890abcdef",
|
|
711
|
+
"decimals": 18,
|
|
712
|
+
"interop": true,
|
|
713
|
+
"symbol": "USDC",
|
|
714
|
+
"uid": "usdc",
|
|
715
|
+
},
|
|
716
|
+
{
|
|
717
|
+
"address": "0xfedcba0987654321",
|
|
718
|
+
"decimals": 6,
|
|
719
|
+
"interop": true,
|
|
720
|
+
"nativeRate": "0x1000",
|
|
721
|
+
"symbol": "USDT",
|
|
722
|
+
"uid": "usdt",
|
|
723
|
+
},
|
|
724
|
+
],
|
|
725
|
+
}
|
|
726
|
+
`)
|
|
727
|
+
})
|
|
728
|
+
|
|
729
|
+
test.each([
|
|
730
|
+
{
|
|
731
|
+
case: 'unsupported with empty tokens',
|
|
732
|
+
expected: { supported: false, tokens: [] },
|
|
733
|
+
input: { supported: false, tokens: [] },
|
|
734
|
+
},
|
|
735
|
+
{
|
|
736
|
+
case: 'supported with empty tokens',
|
|
737
|
+
expected: { supported: true, tokens: [] },
|
|
738
|
+
input: { supported: true, tokens: [] },
|
|
739
|
+
},
|
|
740
|
+
{
|
|
741
|
+
case: 'supported with token including BigInt nativeRate conversion',
|
|
742
|
+
expected: {
|
|
743
|
+
supported: true,
|
|
744
|
+
tokens: [
|
|
745
|
+
{
|
|
746
|
+
address: '0x123',
|
|
747
|
+
decimals: 18,
|
|
748
|
+
interop: true,
|
|
749
|
+
nativeRate: '0xff',
|
|
750
|
+
symbol: 'TEST',
|
|
751
|
+
uid: 'test',
|
|
752
|
+
},
|
|
753
|
+
],
|
|
754
|
+
},
|
|
755
|
+
input: {
|
|
756
|
+
supported: true,
|
|
757
|
+
tokens: [
|
|
758
|
+
{
|
|
759
|
+
address: '0x123',
|
|
760
|
+
decimals: 18,
|
|
761
|
+
interop: true,
|
|
762
|
+
nativeRate: 255n,
|
|
763
|
+
symbol: 'TEST',
|
|
764
|
+
uid: 'test',
|
|
765
|
+
},
|
|
766
|
+
] as const,
|
|
767
|
+
},
|
|
768
|
+
},
|
|
769
|
+
])(
|
|
770
|
+
'behavior: encodes feeToken data correctly for $case',
|
|
771
|
+
({ input, expected }) => {
|
|
772
|
+
const encoded = z.encode(
|
|
773
|
+
Capabilities.feeToken.GetCapabilitiesResponse,
|
|
774
|
+
input,
|
|
775
|
+
)
|
|
776
|
+
expect(encoded).toEqual(expected)
|
|
777
|
+
},
|
|
778
|
+
)
|
|
779
|
+
|
|
780
|
+
test('error: reject invalid token structure', () => {
|
|
781
|
+
expect(
|
|
782
|
+
u.toValidationError(
|
|
783
|
+
z.safeParse(Capabilities.feeToken.GetCapabilitiesResponse, {
|
|
784
|
+
supported: false,
|
|
785
|
+
tokens: [{ invalid: 'token' }],
|
|
786
|
+
}).error,
|
|
787
|
+
),
|
|
788
|
+
).toMatchInlineSnapshot(
|
|
789
|
+
`
|
|
790
|
+
[Schema.ValidationError: Validation failed with 4 errors:
|
|
791
|
+
|
|
792
|
+
- at \`tokens[0].address\`: Expected template_literal. Needs string in format ^0x[A-Fa-f0-9]{40}$.
|
|
793
|
+
- at \`tokens[0].decimals\`: Expected number.
|
|
794
|
+
- at \`tokens[0].symbol\`: Expected string.
|
|
795
|
+
- at \`tokens[0].uid\`: Expected string. ]
|
|
796
|
+
`,
|
|
797
|
+
)
|
|
798
|
+
})
|
|
799
|
+
})
|
|
800
|
+
|
|
801
|
+
describe('Request', () => {
|
|
802
|
+
test('behavior: parse string symbol', () => {
|
|
803
|
+
const result = z.parse(Capabilities.feeToken.Request, 'USDC')
|
|
804
|
+
expect(result).toBe('USDC')
|
|
805
|
+
})
|
|
806
|
+
|
|
807
|
+
test('behavior: parse address', () => {
|
|
808
|
+
const result = z.parse(
|
|
809
|
+
Capabilities.feeToken.Request,
|
|
810
|
+
'0x1234567890abcdef',
|
|
811
|
+
)
|
|
812
|
+
expect(result).toBe('0x1234567890abcdef')
|
|
813
|
+
})
|
|
814
|
+
|
|
815
|
+
test('behavior: encode string symbol', () => {
|
|
816
|
+
const decoded = z.parse(Capabilities.feeToken.Request, 'USDC')
|
|
817
|
+
const encoded = z.encode(Capabilities.feeToken.Request, decoded)
|
|
818
|
+
expect(encoded).toBe('USDC')
|
|
819
|
+
})
|
|
820
|
+
|
|
821
|
+
test('behavior: encode address', () => {
|
|
822
|
+
const decoded = z.parse(
|
|
823
|
+
Capabilities.feeToken.Request,
|
|
824
|
+
'0x1234567890abcdef',
|
|
825
|
+
)
|
|
826
|
+
const encoded = z.encode(Capabilities.feeToken.Request, decoded)
|
|
827
|
+
expect(encoded).toBe('0x1234567890abcdef')
|
|
828
|
+
})
|
|
829
|
+
|
|
830
|
+
test.each([
|
|
831
|
+
{ case: 'symbol USDC', expected: 'USDC', input: 'USDC' },
|
|
832
|
+
{ case: 'symbol ETH', expected: 'ETH', input: 'ETH' },
|
|
833
|
+
{
|
|
834
|
+
case: 'hex address',
|
|
835
|
+
expected: '0x123456789abcdef',
|
|
836
|
+
input: '0x123456789abcdef',
|
|
837
|
+
},
|
|
838
|
+
{
|
|
839
|
+
case: 'zero address',
|
|
840
|
+
expected: '0x0000000000000000000000000000000000000000',
|
|
841
|
+
input: '0x0000000000000000000000000000000000000000',
|
|
842
|
+
},
|
|
843
|
+
])(
|
|
844
|
+
'behavior: encodes feeToken request data correctly for $case',
|
|
845
|
+
({ input, expected }) => {
|
|
846
|
+
const encoded = z.encode(Capabilities.feeToken.Request, input)
|
|
847
|
+
expect(encoded).toBe(expected)
|
|
848
|
+
},
|
|
849
|
+
)
|
|
850
|
+
|
|
851
|
+
test('error: reject invalid address format', () => {
|
|
852
|
+
expect(
|
|
853
|
+
u.toValidationError(
|
|
854
|
+
z.safeParse(Capabilities.feeToken.Request, 123).error,
|
|
855
|
+
),
|
|
856
|
+
).toMatchInlineSnapshot(
|
|
857
|
+
`
|
|
858
|
+
[Schema.ValidationError: Validation failed with 1 error:
|
|
859
|
+
|
|
860
|
+
- Invalid union value.
|
|
861
|
+
- Expected string.
|
|
862
|
+
- Expected template_literal. Needs string in format ^0x[A-Fa-f0-9]{40}$.]
|
|
863
|
+
`,
|
|
864
|
+
)
|
|
865
|
+
})
|
|
866
|
+
})
|
|
867
|
+
})
|
|
868
|
+
|
|
869
|
+
describe('merchant', () => {
|
|
870
|
+
describe('GetCapabilitiesResponse', () => {
|
|
871
|
+
test('behavior: parse supported true', () => {
|
|
872
|
+
const result = z.parse(Capabilities.merchant.GetCapabilitiesResponse, {
|
|
873
|
+
supported: true,
|
|
874
|
+
})
|
|
875
|
+
expect(result).toMatchInlineSnapshot(`
|
|
876
|
+
{
|
|
877
|
+
"supported": true,
|
|
878
|
+
}
|
|
879
|
+
`)
|
|
880
|
+
})
|
|
881
|
+
|
|
882
|
+
test('behavior: parse supported false', () => {
|
|
883
|
+
const result = z.parse(Capabilities.merchant.GetCapabilitiesResponse, {
|
|
884
|
+
supported: false,
|
|
885
|
+
})
|
|
886
|
+
expect(result).toMatchInlineSnapshot(`
|
|
887
|
+
{
|
|
888
|
+
"supported": false,
|
|
889
|
+
}
|
|
890
|
+
`)
|
|
891
|
+
})
|
|
892
|
+
|
|
893
|
+
test('behavior: encode supported true', () => {
|
|
894
|
+
const decoded = z.parse(Capabilities.merchant.GetCapabilitiesResponse, {
|
|
895
|
+
supported: true,
|
|
896
|
+
})
|
|
897
|
+
const encoded = z.encode(
|
|
898
|
+
Capabilities.merchant.GetCapabilitiesResponse,
|
|
899
|
+
decoded,
|
|
900
|
+
)
|
|
901
|
+
expect(encoded).toMatchInlineSnapshot(`
|
|
902
|
+
{
|
|
903
|
+
"supported": true,
|
|
904
|
+
}
|
|
905
|
+
`)
|
|
906
|
+
})
|
|
907
|
+
|
|
908
|
+
test('behavior: encode supported false', () => {
|
|
909
|
+
const decoded = z.parse(Capabilities.merchant.GetCapabilitiesResponse, {
|
|
910
|
+
supported: false,
|
|
911
|
+
})
|
|
912
|
+
const encoded = z.encode(
|
|
913
|
+
Capabilities.merchant.GetCapabilitiesResponse,
|
|
914
|
+
decoded,
|
|
915
|
+
)
|
|
916
|
+
expect(encoded).toMatchInlineSnapshot(`
|
|
917
|
+
{
|
|
918
|
+
"supported": false,
|
|
919
|
+
}
|
|
920
|
+
`)
|
|
921
|
+
})
|
|
922
|
+
|
|
923
|
+
test.each([
|
|
924
|
+
{
|
|
925
|
+
case: 'supported true',
|
|
926
|
+
expected: { supported: true },
|
|
927
|
+
input: { supported: true },
|
|
928
|
+
},
|
|
929
|
+
{
|
|
930
|
+
case: 'supported false',
|
|
931
|
+
expected: { supported: false },
|
|
932
|
+
input: { supported: false },
|
|
933
|
+
},
|
|
934
|
+
])(
|
|
935
|
+
'behavior: encodes merchant data correctly for $case',
|
|
936
|
+
({ input, expected }) => {
|
|
937
|
+
const encoded = z.encode(
|
|
938
|
+
Capabilities.merchant.GetCapabilitiesResponse,
|
|
939
|
+
input,
|
|
940
|
+
)
|
|
941
|
+
expect(encoded).toEqual(expected)
|
|
942
|
+
},
|
|
943
|
+
)
|
|
944
|
+
|
|
945
|
+
test('error: reject missing supported field', () => {
|
|
946
|
+
expect(
|
|
947
|
+
u.toValidationError(
|
|
948
|
+
z.safeParse(Capabilities.merchant.GetCapabilitiesResponse, {}).error,
|
|
949
|
+
),
|
|
950
|
+
).toMatchInlineSnapshot(
|
|
951
|
+
`
|
|
952
|
+
[Schema.ValidationError: Validation failed with 1 error:
|
|
953
|
+
|
|
954
|
+
- at \`supported\`: Expected boolean. ]
|
|
955
|
+
`,
|
|
956
|
+
)
|
|
957
|
+
})
|
|
958
|
+
})
|
|
959
|
+
})
|
|
960
|
+
|
|
961
|
+
describe('permissions', () => {
|
|
962
|
+
describe('GetCapabilitiesResponse', () => {
|
|
963
|
+
test('behavior: parse response', () => {
|
|
964
|
+
const result = z.parse(Capabilities.permissions.GetCapabilitiesResponse, {
|
|
965
|
+
supported: true,
|
|
966
|
+
})
|
|
967
|
+
expect(result).toMatchInlineSnapshot(`
|
|
968
|
+
{
|
|
969
|
+
"supported": true,
|
|
970
|
+
}
|
|
971
|
+
`)
|
|
972
|
+
})
|
|
973
|
+
|
|
974
|
+
test('behavior: encode permissions response', () => {
|
|
975
|
+
const decoded = z.parse(
|
|
976
|
+
Capabilities.permissions.GetCapabilitiesResponse,
|
|
977
|
+
{ supported: true },
|
|
978
|
+
)
|
|
979
|
+
const encoded = z.encode(
|
|
980
|
+
Capabilities.permissions.GetCapabilitiesResponse,
|
|
981
|
+
decoded,
|
|
982
|
+
)
|
|
983
|
+
expect(encoded).toMatchInlineSnapshot(`
|
|
984
|
+
{
|
|
985
|
+
"supported": true,
|
|
986
|
+
}
|
|
987
|
+
`)
|
|
988
|
+
})
|
|
989
|
+
|
|
990
|
+
test.each([
|
|
991
|
+
{
|
|
992
|
+
case: 'supported true',
|
|
993
|
+
expected: { supported: true },
|
|
994
|
+
input: { supported: true },
|
|
995
|
+
},
|
|
996
|
+
{
|
|
997
|
+
case: 'supported false',
|
|
998
|
+
expected: { supported: false },
|
|
999
|
+
input: { supported: false },
|
|
1000
|
+
},
|
|
1001
|
+
])(
|
|
1002
|
+
'behavior: encodes permissions response data correctly for $case',
|
|
1003
|
+
({ input, expected }) => {
|
|
1004
|
+
const encoded = z.encode(
|
|
1005
|
+
Capabilities.permissions.GetCapabilitiesResponse,
|
|
1006
|
+
input,
|
|
1007
|
+
)
|
|
1008
|
+
expect(encoded).toEqual(expected)
|
|
1009
|
+
},
|
|
1010
|
+
)
|
|
1011
|
+
|
|
1012
|
+
test('error: reject invalid type', () => {
|
|
1013
|
+
expect(
|
|
1014
|
+
u.toValidationError(
|
|
1015
|
+
z.safeParse(Capabilities.permissions.GetCapabilitiesResponse, {
|
|
1016
|
+
supported: 'yes',
|
|
1017
|
+
}).error,
|
|
1018
|
+
),
|
|
1019
|
+
).toMatchInlineSnapshot(
|
|
1020
|
+
`
|
|
1021
|
+
[Schema.ValidationError: Validation failed with 1 error:
|
|
1022
|
+
|
|
1023
|
+
- at \`supported\`: Expected boolean. ]
|
|
1024
|
+
`,
|
|
1025
|
+
)
|
|
1026
|
+
})
|
|
1027
|
+
})
|
|
1028
|
+
|
|
1029
|
+
describe('Request', () => {
|
|
1030
|
+
test('behavior: parse empty object', () => {
|
|
1031
|
+
const result = z.parse(Capabilities.permissions.Request, {})
|
|
1032
|
+
expect(result).toMatchInlineSnapshot('{}')
|
|
1033
|
+
})
|
|
1034
|
+
|
|
1035
|
+
test('behavior: parse with id', () => {
|
|
1036
|
+
const result = z.parse(Capabilities.permissions.Request, {
|
|
1037
|
+
id: '0xabc123',
|
|
1038
|
+
})
|
|
1039
|
+
expect(result).toMatchInlineSnapshot(`
|
|
1040
|
+
{
|
|
1041
|
+
"id": "0xabc123",
|
|
1042
|
+
}
|
|
1043
|
+
`)
|
|
1044
|
+
})
|
|
1045
|
+
|
|
1046
|
+
test('behavior: encode empty object', () => {
|
|
1047
|
+
const decoded = z.parse(Capabilities.permissions.Request, {})
|
|
1048
|
+
const encoded = z.encode(Capabilities.permissions.Request, decoded)
|
|
1049
|
+
expect(encoded).toMatchInlineSnapshot('{}')
|
|
1050
|
+
})
|
|
1051
|
+
|
|
1052
|
+
test('behavior: encode with id', () => {
|
|
1053
|
+
const originalData = { id: '0xabc123' }
|
|
1054
|
+
const decoded = z.parse(Capabilities.permissions.Request, originalData)
|
|
1055
|
+
const encoded = z.encode(Capabilities.permissions.Request, decoded)
|
|
1056
|
+
expect(encoded).toMatchInlineSnapshot(`
|
|
1057
|
+
{
|
|
1058
|
+
"id": "0xabc123",
|
|
1059
|
+
}
|
|
1060
|
+
`)
|
|
1061
|
+
})
|
|
1062
|
+
|
|
1063
|
+
test.each([
|
|
1064
|
+
{ case: 'empty object', expected: {}, input: {} },
|
|
1065
|
+
{
|
|
1066
|
+
case: 'with short id',
|
|
1067
|
+
expected: { id: '0x123' },
|
|
1068
|
+
input: { id: '0x123' },
|
|
1069
|
+
},
|
|
1070
|
+
{
|
|
1071
|
+
case: 'with long id',
|
|
1072
|
+
expected: { id: '0xdeadbeef' },
|
|
1073
|
+
input: { id: '0xdeadbeef' },
|
|
1074
|
+
},
|
|
1075
|
+
] as const)(
|
|
1076
|
+
'behavior: encodes permissions request data correctly for $case',
|
|
1077
|
+
({ input, expected }) => {
|
|
1078
|
+
const encoded = z.encode(Capabilities.permissions.Request, input)
|
|
1079
|
+
expect(encoded).toEqual(expected)
|
|
1080
|
+
},
|
|
1081
|
+
)
|
|
1082
|
+
|
|
1083
|
+
test('error: reject invalid id format', () => {
|
|
1084
|
+
expect(
|
|
1085
|
+
u.toValidationError(
|
|
1086
|
+
z.safeParse(Capabilities.permissions.Request, {
|
|
1087
|
+
id: 'not-hex',
|
|
1088
|
+
}).error,
|
|
1089
|
+
),
|
|
1090
|
+
).toMatchInlineSnapshot(
|
|
1091
|
+
`
|
|
1092
|
+
[Schema.ValidationError: Validation failed with 1 error:
|
|
1093
|
+
|
|
1094
|
+
- at \`id\`: Invalid union value.
|
|
1095
|
+
- Must match pattern: ^0x[\\s\\S]{0,}$
|
|
1096
|
+
- Expected null. ]
|
|
1097
|
+
`,
|
|
1098
|
+
)
|
|
1099
|
+
})
|
|
1100
|
+
})
|
|
1101
|
+
})
|
|
1102
|
+
|
|
1103
|
+
describe('preCalls', () => {
|
|
1104
|
+
describe('Request', () => {
|
|
1105
|
+
test('behavior: parse empty array', () => {
|
|
1106
|
+
const result = z.parse(Capabilities.preCalls.Request, [])
|
|
1107
|
+
expect(result).toMatchInlineSnapshot('[]')
|
|
1108
|
+
})
|
|
1109
|
+
|
|
1110
|
+
test('behavior: parse array with entries', () => {
|
|
1111
|
+
const result = z.parse(Capabilities.preCalls.Request, [
|
|
1112
|
+
{
|
|
1113
|
+
context: { foo: 'bar' },
|
|
1114
|
+
signature: '0xdeadbeef',
|
|
1115
|
+
},
|
|
1116
|
+
{
|
|
1117
|
+
context: 123,
|
|
1118
|
+
signature: '0xfeedface',
|
|
1119
|
+
},
|
|
1120
|
+
])
|
|
1121
|
+
expect(result).toMatchInlineSnapshot(`
|
|
1122
|
+
[
|
|
1123
|
+
{
|
|
1124
|
+
"context": {
|
|
1125
|
+
"foo": "bar",
|
|
1126
|
+
},
|
|
1127
|
+
"signature": "0xdeadbeef",
|
|
1128
|
+
},
|
|
1129
|
+
{
|
|
1130
|
+
"context": 123,
|
|
1131
|
+
"signature": "0xfeedface",
|
|
1132
|
+
},
|
|
1133
|
+
]
|
|
1134
|
+
`)
|
|
1135
|
+
})
|
|
1136
|
+
|
|
1137
|
+
test('error: reject entry without signature', () => {
|
|
1138
|
+
expect(
|
|
1139
|
+
u.toValidationError(
|
|
1140
|
+
z.safeParse(Capabilities.preCalls.Request, [{ context: {} }]).error,
|
|
1141
|
+
),
|
|
1142
|
+
).toMatchInlineSnapshot(
|
|
1143
|
+
`
|
|
1144
|
+
[Schema.ValidationError: Validation failed with 1 error:
|
|
1145
|
+
|
|
1146
|
+
- at \`[0].signature\`: Expected template_literal. Needs string in format ^0x[A-Fa-f0-9]+$.]
|
|
1147
|
+
`,
|
|
1148
|
+
)
|
|
1149
|
+
})
|
|
1150
|
+
|
|
1151
|
+
test('behavior: encode empty array', () => {
|
|
1152
|
+
const decoded = z.parse(Capabilities.preCalls.Request, [])
|
|
1153
|
+
const encoded = z.encode(Capabilities.preCalls.Request, decoded)
|
|
1154
|
+
expect(encoded).toMatchInlineSnapshot('[]')
|
|
1155
|
+
})
|
|
1156
|
+
|
|
1157
|
+
test('behavior: encode array with entries', () => {
|
|
1158
|
+
const originalData = [
|
|
1159
|
+
{
|
|
1160
|
+
context: { foo: 'bar' },
|
|
1161
|
+
signature: '0xdeadbeef',
|
|
1162
|
+
},
|
|
1163
|
+
{
|
|
1164
|
+
context: 123,
|
|
1165
|
+
signature: '0xfeedface',
|
|
1166
|
+
},
|
|
1167
|
+
]
|
|
1168
|
+
const decoded = z.parse(Capabilities.preCalls.Request, originalData)
|
|
1169
|
+
const encoded = z.encode(Capabilities.preCalls.Request, decoded)
|
|
1170
|
+
expect(encoded).toMatchInlineSnapshot(`
|
|
1171
|
+
[
|
|
1172
|
+
{
|
|
1173
|
+
"context": {
|
|
1174
|
+
"foo": "bar",
|
|
1175
|
+
},
|
|
1176
|
+
"signature": "0xdeadbeef",
|
|
1177
|
+
},
|
|
1178
|
+
{
|
|
1179
|
+
"context": 123,
|
|
1180
|
+
"signature": "0xfeedface",
|
|
1181
|
+
},
|
|
1182
|
+
]
|
|
1183
|
+
`)
|
|
1184
|
+
})
|
|
1185
|
+
|
|
1186
|
+
test('behavior: encode array with various context types', () => {
|
|
1187
|
+
const originalData = [
|
|
1188
|
+
{ context: null, signature: '0x123' },
|
|
1189
|
+
{ context: 'string', signature: '0x456' },
|
|
1190
|
+
{ context: true, signature: '0x789' },
|
|
1191
|
+
{ context: { nested: { object: 'value' } }, signature: '0xabc' },
|
|
1192
|
+
]
|
|
1193
|
+
const decoded = z.parse(Capabilities.preCalls.Request, originalData)
|
|
1194
|
+
const encoded = z.encode(Capabilities.preCalls.Request, decoded)
|
|
1195
|
+
expect(encoded).toMatchInlineSnapshot(`
|
|
1196
|
+
[
|
|
1197
|
+
{
|
|
1198
|
+
"context": null,
|
|
1199
|
+
"signature": "0x123",
|
|
1200
|
+
},
|
|
1201
|
+
{
|
|
1202
|
+
"context": "string",
|
|
1203
|
+
"signature": "0x456",
|
|
1204
|
+
},
|
|
1205
|
+
{
|
|
1206
|
+
"context": true,
|
|
1207
|
+
"signature": "0x789",
|
|
1208
|
+
},
|
|
1209
|
+
{
|
|
1210
|
+
"context": {
|
|
1211
|
+
"nested": {
|
|
1212
|
+
"object": "value",
|
|
1213
|
+
},
|
|
1214
|
+
},
|
|
1215
|
+
"signature": "0xabc",
|
|
1216
|
+
},
|
|
1217
|
+
]
|
|
1218
|
+
`)
|
|
1219
|
+
})
|
|
1220
|
+
|
|
1221
|
+
test.each([
|
|
1222
|
+
{ case: 'empty array', expected: [], input: [] },
|
|
1223
|
+
{
|
|
1224
|
+
case: 'single entry with empty context',
|
|
1225
|
+
expected: [{ context: {}, signature: '0x123' }],
|
|
1226
|
+
input: [{ context: {}, signature: '0x123' }],
|
|
1227
|
+
},
|
|
1228
|
+
{
|
|
1229
|
+
case: 'multiple entries with different context types',
|
|
1230
|
+
expected: [
|
|
1231
|
+
{ context: 'test', signature: '0xabc' },
|
|
1232
|
+
{ context: null, signature: '0xdef' },
|
|
1233
|
+
],
|
|
1234
|
+
input: [
|
|
1235
|
+
{ context: 'test', signature: '0xabc' },
|
|
1236
|
+
{ context: null, signature: '0xdef' },
|
|
1237
|
+
],
|
|
1238
|
+
},
|
|
1239
|
+
] as const)(
|
|
1240
|
+
'behavior: encodes preCalls data correctly for $case',
|
|
1241
|
+
({ input, expected }) => {
|
|
1242
|
+
const encoded = z.encode(Capabilities.preCalls.Request, input)
|
|
1243
|
+
expect(encoded).toEqual(expected)
|
|
1244
|
+
},
|
|
1245
|
+
)
|
|
1246
|
+
|
|
1247
|
+
test('error: reject invalid signature format', () => {
|
|
1248
|
+
expect(
|
|
1249
|
+
u.toValidationError(
|
|
1250
|
+
z.safeParse(Capabilities.preCalls.Request, [
|
|
1251
|
+
{ context: null, signature: 'invalid' },
|
|
1252
|
+
]).error,
|
|
1253
|
+
),
|
|
1254
|
+
).toMatchInlineSnapshot(
|
|
1255
|
+
`
|
|
1256
|
+
[Schema.ValidationError: Validation failed with 1 error:
|
|
1257
|
+
|
|
1258
|
+
- at \`[0].signature\`: Must match pattern: ^0x[\\s\\S]{0,}$]
|
|
1259
|
+
`,
|
|
1260
|
+
)
|
|
1261
|
+
})
|
|
1262
|
+
})
|
|
1263
|
+
})
|
|
1264
|
+
|
|
1265
|
+
describe('merchantUrl', () => {
|
|
1266
|
+
describe('Request', () => {
|
|
1267
|
+
test('behavior: parse string url', () => {
|
|
1268
|
+
const result = z.parse(
|
|
1269
|
+
Capabilities.merchantUrl.Request,
|
|
1270
|
+
'https://rpc.example.com',
|
|
1271
|
+
)
|
|
1272
|
+
expect(result).toBe('https://rpc.example.com')
|
|
1273
|
+
})
|
|
1274
|
+
|
|
1275
|
+
test('behavior: parse empty string', () => {
|
|
1276
|
+
const result = z.parse(Capabilities.merchantUrl.Request, '')
|
|
1277
|
+
expect(result).toBe('')
|
|
1278
|
+
})
|
|
1279
|
+
|
|
1280
|
+
test('behavior: encode string url', () => {
|
|
1281
|
+
const decoded = z.parse(
|
|
1282
|
+
Capabilities.merchantUrl.Request,
|
|
1283
|
+
'https://rpc.example.com',
|
|
1284
|
+
)
|
|
1285
|
+
const encoded = z.encode(Capabilities.merchantUrl.Request, decoded)
|
|
1286
|
+
expect(encoded).toBe('https://rpc.example.com')
|
|
1287
|
+
})
|
|
1288
|
+
|
|
1289
|
+
test('behavior: encode empty string', () => {
|
|
1290
|
+
const decoded = z.parse(Capabilities.merchantUrl.Request, '')
|
|
1291
|
+
const encoded = z.encode(Capabilities.merchantUrl.Request, decoded)
|
|
1292
|
+
expect(encoded).toBe('')
|
|
1293
|
+
})
|
|
1294
|
+
|
|
1295
|
+
test.each([
|
|
1296
|
+
{ case: 'empty string', expected: '', input: '' },
|
|
1297
|
+
{
|
|
1298
|
+
case: 'https URL',
|
|
1299
|
+
expected: 'https://rpc.example.com',
|
|
1300
|
+
input: 'https://rpc.example.com',
|
|
1301
|
+
},
|
|
1302
|
+
{
|
|
1303
|
+
case: 'localhost URL',
|
|
1304
|
+
expected: 'http://localhost:8545',
|
|
1305
|
+
input: 'http://localhost:8545',
|
|
1306
|
+
},
|
|
1307
|
+
{
|
|
1308
|
+
case: 'websocket URL',
|
|
1309
|
+
expected: 'wss://eth-mainnet.alchemyapi.io/v2/demo',
|
|
1310
|
+
input: 'wss://eth-mainnet.alchemyapi.io/v2/demo',
|
|
1311
|
+
},
|
|
1312
|
+
])(
|
|
1313
|
+
'behavior: encodes merchantUrl data correctly for $case',
|
|
1314
|
+
({ input, expected }) => {
|
|
1315
|
+
const encoded = z.encode(Capabilities.merchantUrl.Request, input)
|
|
1316
|
+
expect(encoded).toBe(expected)
|
|
1317
|
+
},
|
|
1318
|
+
)
|
|
1319
|
+
|
|
1320
|
+
test('error: reject non-string', () => {
|
|
1321
|
+
expect(
|
|
1322
|
+
u.toValidationError(
|
|
1323
|
+
z.safeParse(Capabilities.merchantUrl.Request, 123).error,
|
|
1324
|
+
),
|
|
1325
|
+
).toMatchInlineSnapshot(
|
|
1326
|
+
`
|
|
1327
|
+
[Schema.ValidationError: Validation failed with 1 error:
|
|
1328
|
+
|
|
1329
|
+
- Expected string. ]
|
|
1330
|
+
`,
|
|
1331
|
+
)
|
|
1332
|
+
})
|
|
1333
|
+
})
|
|
1334
|
+
})
|