mppx 0.8.15 → 0.8.18
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/CHANGELOG.md +91 -0
- package/README.md +15 -0
- package/dist/Challenge.js +61 -39
- package/dist/Constants.d.ts +17 -17
- package/dist/Errors.d.ts +3 -3
- package/dist/Method.d.ts +35 -5
- package/dist/Method.js +7 -22
- package/dist/Store.d.ts +19 -0
- package/dist/Store.js +43 -0
- package/dist/attestation/Client.d.ts +17 -0
- package/dist/attestation/Client.js +28 -0
- package/dist/attestation/Constants.d.ts +15 -0
- package/dist/attestation/Constants.js +15 -0
- package/dist/attestation/Server.d.ts +4 -0
- package/dist/attestation/Server.js +8 -0
- package/dist/attestation/Types.d.ts +76 -0
- package/dist/attestation/Types.js +2 -0
- package/dist/attestation/index.d.ts +6 -0
- package/dist/attestation/index.js +6 -0
- package/dist/attestation/internal/HttpMessageSignature.d.ts +73 -0
- package/dist/attestation/internal/HttpMessageSignature.js +320 -0
- package/dist/attestation/internal/SigningContext.d.ts +4 -0
- package/dist/attestation/internal/SigningContext.js +11 -0
- package/dist/bin.js +3 -3
- package/dist/cli/THIRD-PARTY-LICENSES.txt +328 -0
- package/dist/cli/account.d.ts +14 -14
- package/dist/cli/cli.d.ts +6 -6
- package/dist/cli/cli.js +253 -1504
- package/dist/cli/plugins/index.js +19 -5
- package/dist/cli/plugins/tempo.js +7 -3
- package/dist/cli/sessions/Manager.js +7 -4
- package/dist/cli/sessions/commands.d.ts +4 -4
- package/dist/cli/sessions/request.d.ts +2 -0
- package/dist/cli/sessions/request.js +18 -0
- package/dist/cli/sessions/store.js +28 -14
- package/dist/cli/utils.d.ts +1 -1
- package/dist/cli/validate/index.d.ts +3 -3
- package/dist/client/Mppx.d.ts +3 -0
- package/dist/client/Mppx.js +13 -5
- package/dist/client/Transport.d.ts +3 -5
- package/dist/client/Transport.js +1 -17
- package/dist/client/internal/Fetch.js +2 -6
- package/dist/discovery/Discovery.js +2 -1
- package/dist/discovery/OpenApi.d.ts +3 -5
- package/dist/discovery/OpenApi.js +13 -34
- package/dist/discovery/internal/Metadata.d.ts +20 -0
- package/dist/discovery/internal/Metadata.js +36 -0
- package/dist/evm/Methods.d.ts +11 -11
- package/dist/evm/Types.d.ts +17 -17
- package/dist/evm/client/Charge.d.ts +11 -11
- package/dist/evm/client/Charge.js +8 -0
- package/dist/evm/client/Methods.d.ts +11 -11
- package/dist/evm/server/Charge.d.ts +1 -1
- package/dist/evm/server/Charge.js +2 -0
- package/dist/evm/server/Methods.d.ts +11 -11
- package/dist/internal/HeaderCodec.d.ts +2 -2
- package/dist/internal/types.d.ts +6 -0
- package/dist/proxy/Proxy.d.ts +2 -0
- package/dist/proxy/Proxy.js +117 -9
- package/dist/proxy/Service.d.ts +36 -1
- package/dist/proxy/Service.js +9 -8
- package/dist/proxy/services/anthropic.js +1 -0
- package/dist/proxy/services/openai.js +1 -0
- package/dist/proxy/services/stripe.js +1 -0
- package/dist/server/Mppx.d.ts +75 -13
- package/dist/server/Mppx.js +201 -23
- package/dist/server/core.d.ts +9 -0
- package/dist/server/core.js +9 -0
- package/dist/server/internal/html/config.d.ts +9 -9
- package/dist/server/internal/html/constants.d.ts +17 -17
- package/dist/stripe/Methods.d.ts +10 -10
- package/dist/stripe/client/Charge.d.ts +10 -10
- package/dist/stripe/client/Methods.d.ts +10 -10
- package/dist/stripe/internal/constants.d.ts +1 -1
- package/dist/stripe/internal/constants.js +1 -1
- package/dist/stripe/internal/types.d.ts +1 -0
- package/dist/stripe/server/Charge.d.ts +11 -11
- package/dist/stripe/server/Charge.js +51 -5
- package/dist/stripe/server/Methods.d.ts +137 -48
- package/dist/stripe/server/Methods.js +265 -4
- package/dist/stripe/server/internal/deposit-address.d.ts +13 -0
- package/dist/stripe/server/internal/deposit-address.js +28 -0
- package/dist/stripe/server/internal/html.gen.d.ts +1 -1
- package/dist/stripe/server/internal/html.gen.js +1 -1
- package/dist/stripe/server/internal/record-payment.d.ts +15 -0
- package/dist/stripe/server/internal/record-payment.js +42 -0
- package/dist/stripe/server/internal/request.d.ts +25 -0
- package/dist/stripe/server/internal/request.js +29 -0
- package/dist/stripe/server/spt.d.ts +8 -0
- package/dist/stripe/server/spt.js +8 -0
- package/dist/tap/Constants.d.ts +28 -0
- package/dist/tap/Constants.js +32 -0
- package/dist/tap/Types.d.ts +11 -0
- package/dist/tap/Types.js +2 -0
- package/dist/tap/client/index.d.ts +26 -0
- package/dist/tap/client/index.js +33 -0
- package/dist/tap/index.d.ts +5 -0
- package/dist/tap/index.js +5 -0
- package/dist/tap/server/index.d.ts +20 -0
- package/dist/tap/server/index.js +36 -0
- package/dist/tempo/Attribution.d.ts +1 -1
- package/dist/tempo/Methods.d.ts +73 -60
- package/dist/tempo/Methods.js +14 -3
- package/dist/tempo/Proof.d.ts +16 -16
- package/dist/tempo/client/Charge.d.ts +22 -19
- package/dist/tempo/client/Charge.js +32 -16
- package/dist/tempo/client/Methods.d.ts +51 -38
- package/dist/tempo/client/Subscription.d.ts +23 -23
- package/dist/tempo/internal/address.d.ts +2 -1
- package/dist/tempo/internal/address.js +3 -1
- package/dist/tempo/internal/auto-swap.js +4 -19
- package/dist/tempo/internal/defaults.d.ts +17 -6
- package/dist/tempo/internal/defaults.js +11 -0
- package/dist/tempo/internal/fee-payer.d.ts +12 -12
- package/dist/tempo/internal/machine-token-charge.d.ts +51 -0
- package/dist/tempo/internal/machine-token-charge.js +113 -0
- package/dist/tempo/internal/machine-token-session.d.ts +88 -0
- package/dist/tempo/internal/machine-token-session.js +173 -0
- package/dist/tempo/internal/proof.d.ts +17 -17
- package/dist/tempo/internal/signature-envelope.d.ts +14 -0
- package/dist/tempo/internal/signature-envelope.js +28 -0
- package/dist/tempo/legacy/client/ChannelOps.d.ts +2 -2
- package/dist/tempo/legacy/client/ChannelOps.js +11 -5
- package/dist/tempo/legacy/client/Session.d.ts +33 -21
- package/dist/tempo/legacy/client/Session.js +3 -3
- package/dist/tempo/legacy/client/SessionManager.d.ts +3 -1
- package/dist/tempo/legacy/client/SessionManager.js +2 -0
- package/dist/tempo/legacy/index.d.ts +1 -3
- package/dist/tempo/legacy/index.js +1 -3
- package/dist/tempo/legacy/session/escrow.abi.d.ts +374 -374
- package/dist/tempo/server/Charge.d.ts +28 -11
- package/dist/tempo/server/Charge.js +101 -55
- package/dist/tempo/server/Methods.d.ts +58 -56
- package/dist/tempo/server/Methods.js +8 -18
- package/dist/tempo/server/Relay.d.ts +1 -1
- package/dist/tempo/server/Relay.js +2 -2
- package/dist/tempo/server/Subscription.d.ts +25 -25
- package/dist/tempo/server/Subscription.js +2 -0
- package/dist/tempo/server/index.d.ts +1 -1
- package/dist/tempo/server/index.js +1 -1
- package/dist/tempo/server/internal/html.gen.d.ts +1 -1
- package/dist/tempo/server/internal/html.gen.js +1 -1
- package/dist/tempo/server/internal/transport.d.ts +2 -0
- package/dist/tempo/server/internal/transport.js +9 -2
- package/dist/tempo/session/client/ChannelOps.d.ts +18 -3
- package/dist/tempo/session/client/ChannelOps.js +35 -6
- package/dist/tempo/session/client/ChannelStore.d.ts +0 -5
- package/dist/tempo/session/client/ChannelStore.js +2 -2
- package/dist/tempo/session/client/CredentialState.d.ts +18 -3
- package/dist/tempo/session/client/CredentialState.js +77 -76
- package/dist/tempo/session/client/Runtime.d.ts +4 -2
- package/dist/tempo/session/client/Runtime.js +21 -5
- package/dist/tempo/session/client/Session.d.ts +34 -22
- package/dist/tempo/session/client/Session.js +186 -63
- package/dist/tempo/session/client/SessionManager.d.ts +3 -1
- package/dist/tempo/session/client/SessionManager.js +35 -11
- package/dist/tempo/session/client/Transports.d.ts +2 -0
- package/dist/tempo/session/client/Transports.js +12 -2
- package/dist/tempo/session/precompile/Chain.d.ts +37 -2
- package/dist/tempo/session/precompile/Chain.js +116 -15
- package/dist/tempo/session/precompile/Protocol.d.ts +15 -0
- package/dist/tempo/session/precompile/Protocol.js +7 -0
- package/dist/tempo/session/precompile/Voucher.d.ts +7 -5
- package/dist/tempo/session/precompile/Voucher.js +6 -12
- package/dist/tempo/session/precompile/escrow.abi.d.ts +306 -306
- package/dist/tempo/session/server/ChannelStore.d.ts +15 -0
- package/dist/tempo/session/server/ChannelStore.js +27 -12
- package/dist/tempo/session/server/CredentialVerification.d.ts +39 -20
- package/dist/tempo/session/server/CredentialVerification.js +359 -89
- package/dist/tempo/session/server/MeteredStream.d.ts +4 -1
- package/dist/tempo/session/server/MeteredStream.js +8 -5
- package/dist/tempo/session/server/RequestState.d.ts +19 -0
- package/dist/tempo/session/server/RequestState.js +61 -15
- package/dist/tempo/session/server/Session.d.ts +46 -23
- package/dist/tempo/session/server/Session.js +150 -56
- package/dist/tempo/session/server/Settlement.d.ts +11 -4
- package/dist/tempo/session/server/Settlement.js +53 -21
- package/dist/tempo/session/server/Sse.d.ts +3 -1
- package/dist/tempo/session/server/Sse.js +2 -1
- package/dist/tempo/session/server/Transports.d.ts +1 -1
- package/dist/tempo/session/server/Transports.js +1 -0
- package/dist/tempo/session/server/Ws.d.ts +6 -1
- package/dist/tempo/session/server/Ws.js +1 -0
- package/dist/tempo/subscription/KeyAuthorization.d.ts +39 -39
- package/dist/web-bot-auth/Constants.d.ts +20 -0
- package/dist/web-bot-auth/Constants.js +24 -0
- package/dist/web-bot-auth/Types.d.ts +10 -0
- package/dist/web-bot-auth/Types.js +2 -0
- package/dist/web-bot-auth/client/index.d.ts +29 -0
- package/dist/web-bot-auth/client/index.js +64 -0
- package/dist/web-bot-auth/index.d.ts +7 -0
- package/dist/web-bot-auth/index.js +7 -0
- package/dist/web-bot-auth/internal/JwkThumbprint.d.ts +5 -0
- package/dist/web-bot-auth/internal/JwkThumbprint.js +20 -0
- package/dist/web-bot-auth/internal/SignatureAgent.d.ts +3 -0
- package/dist/web-bot-auth/internal/SignatureAgent.js +18 -0
- package/dist/web-bot-auth/server/index.d.ts +35 -0
- package/dist/web-bot-auth/server/index.js +88 -0
- package/dist/x402/Types.d.ts +6 -6
- package/dist/x402/client/Exact.d.ts +8 -0
- package/dist/x402/client/Exact.js +40 -10
- package/dist/x402/server/EvmCharge.d.ts +22 -0
- package/dist/x402/server/EvmCharge.js +54 -20
- package/package.json +28 -34
- package/dist/BodyDigest.d.ts.map +0 -1
- package/dist/BodyDigest.js.map +0 -1
- package/dist/Challenge.d.ts.map +0 -1
- package/dist/Challenge.js.map +0 -1
- package/dist/Constants.d.ts.map +0 -1
- package/dist/Constants.js.map +0 -1
- package/dist/Credential.d.ts.map +0 -1
- package/dist/Credential.js.map +0 -1
- package/dist/Errors.d.ts.map +0 -1
- package/dist/Errors.js.map +0 -1
- package/dist/Expires.d.ts.map +0 -1
- package/dist/Expires.js.map +0 -1
- package/dist/Html.d.ts.map +0 -1
- package/dist/Html.js.map +0 -1
- package/dist/Mcp.d.ts.map +0 -1
- package/dist/Mcp.js.map +0 -1
- package/dist/Method.d.ts.map +0 -1
- package/dist/Method.js.map +0 -1
- package/dist/PaymentRequest.d.ts.map +0 -1
- package/dist/PaymentRequest.js.map +0 -1
- package/dist/Receipt.d.ts.map +0 -1
- package/dist/Receipt.js.map +0 -1
- package/dist/Store.d.ts.map +0 -1
- package/dist/Store.js.map +0 -1
- package/dist/bin.d.ts.map +0 -1
- package/dist/bin.js.map +0 -1
- package/dist/cli/account.d.ts.map +0 -1
- package/dist/cli/account.js.map +0 -1
- package/dist/cli/cli.d.ts.map +0 -1
- package/dist/cli/cli.js.map +0 -1
- package/dist/cli/config.d.ts.map +0 -1
- package/dist/cli/config.js.map +0 -1
- package/dist/cli/internal.d.ts.map +0 -1
- package/dist/cli/internal.js.map +0 -1
- package/dist/cli/plugins/evm.d.ts.map +0 -1
- package/dist/cli/plugins/evm.js.map +0 -1
- package/dist/cli/plugins/index.d.ts.map +0 -1
- package/dist/cli/plugins/index.js.map +0 -1
- package/dist/cli/plugins/plugin.d.ts.map +0 -1
- package/dist/cli/plugins/plugin.js.map +0 -1
- package/dist/cli/plugins/stripe.d.ts.map +0 -1
- package/dist/cli/plugins/stripe.js.map +0 -1
- package/dist/cli/plugins/tempo.d.ts.map +0 -1
- package/dist/cli/plugins/tempo.js.map +0 -1
- package/dist/cli/sessions/Manager.d.ts.map +0 -1
- package/dist/cli/sessions/Manager.js.map +0 -1
- package/dist/cli/sessions/commands.d.ts.map +0 -1
- package/dist/cli/sessions/commands.js.map +0 -1
- package/dist/cli/sessions/request.d.ts.map +0 -1
- package/dist/cli/sessions/request.js.map +0 -1
- package/dist/cli/sessions/store.d.ts.map +0 -1
- package/dist/cli/sessions/store.js.map +0 -1
- package/dist/cli/utils.d.ts.map +0 -1
- package/dist/cli/utils.js.map +0 -1
- package/dist/cli/validate/challenge.d.ts.map +0 -1
- package/dist/cli/validate/challenge.js.map +0 -1
- package/dist/cli/validate/discovery.d.ts.map +0 -1
- package/dist/cli/validate/discovery.js.map +0 -1
- package/dist/cli/validate/helpers.d.ts.map +0 -1
- package/dist/cli/validate/helpers.js.map +0 -1
- package/dist/cli/validate/index.d.ts.map +0 -1
- package/dist/cli/validate/index.js.map +0 -1
- package/dist/cli/validate/messages.d.ts.map +0 -1
- package/dist/cli/validate/messages.js.map +0 -1
- package/dist/cli/validate/payment.d.ts.map +0 -1
- package/dist/cli/validate/payment.js.map +0 -1
- package/dist/client/Methods.d.ts.map +0 -1
- package/dist/client/Methods.js.map +0 -1
- package/dist/client/Mppx.d.ts.map +0 -1
- package/dist/client/Mppx.js.map +0 -1
- package/dist/client/Transport.d.ts.map +0 -1
- package/dist/client/Transport.js.map +0 -1
- package/dist/client/index.d.ts.map +0 -1
- package/dist/client/index.js.map +0 -1
- package/dist/client/internal/Fetch.d.ts.map +0 -1
- package/dist/client/internal/Fetch.js.map +0 -1
- package/dist/client/internal/MethodChallenge.d.ts.map +0 -1
- package/dist/client/internal/MethodChallenge.js.map +0 -1
- package/dist/client/internal/MethodResponse.d.ts.map +0 -1
- package/dist/client/internal/MethodResponse.js.map +0 -1
- package/dist/client/internal/protocols/Mcp.d.ts.map +0 -1
- package/dist/client/internal/protocols/Mcp.js.map +0 -1
- package/dist/client/internal/protocols/Mpp.d.ts.map +0 -1
- package/dist/client/internal/protocols/Mpp.js.map +0 -1
- package/dist/client/internal/protocols/Protocol.d.ts.map +0 -1
- package/dist/client/internal/protocols/Protocol.js.map +0 -1
- package/dist/client/internal/protocols/Shared.d.ts.map +0 -1
- package/dist/client/internal/protocols/Shared.js.map +0 -1
- package/dist/client/internal/protocols/X402.d.ts.map +0 -1
- package/dist/client/internal/protocols/X402.js.map +0 -1
- package/dist/client/node.d.ts.map +0 -1
- package/dist/client/node.js.map +0 -1
- package/dist/discovery/Discovery.d.ts.map +0 -1
- package/dist/discovery/Discovery.js.map +0 -1
- package/dist/discovery/OpenApi.d.ts.map +0 -1
- package/dist/discovery/OpenApi.js.map +0 -1
- package/dist/discovery/Validate.d.ts.map +0 -1
- package/dist/discovery/Validate.js.map +0 -1
- package/dist/discovery/index.d.ts.map +0 -1
- package/dist/discovery/index.js.map +0 -1
- package/dist/evm/Assets.d.ts.map +0 -1
- package/dist/evm/Assets.js.map +0 -1
- package/dist/evm/Chains.d.ts.map +0 -1
- package/dist/evm/Chains.js.map +0 -1
- package/dist/evm/Methods.d.ts.map +0 -1
- package/dist/evm/Methods.js.map +0 -1
- package/dist/evm/Types.d.ts.map +0 -1
- package/dist/evm/Types.js.map +0 -1
- package/dist/evm/client/Charge.d.ts.map +0 -1
- package/dist/evm/client/Charge.js.map +0 -1
- package/dist/evm/client/Methods.d.ts.map +0 -1
- package/dist/evm/client/Methods.js.map +0 -1
- package/dist/evm/client/index.d.ts.map +0 -1
- package/dist/evm/client/index.js.map +0 -1
- package/dist/evm/index.d.ts.map +0 -1
- package/dist/evm/index.js.map +0 -1
- package/dist/evm/server/Charge.d.ts.map +0 -1
- package/dist/evm/server/Charge.js.map +0 -1
- package/dist/evm/server/Methods.d.ts.map +0 -1
- package/dist/evm/server/Methods.js.map +0 -1
- package/dist/evm/server/index.d.ts.map +0 -1
- package/dist/evm/server/index.js.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/internal/AcceptPayment.d.ts.map +0 -1
- package/dist/internal/AcceptPayment.js.map +0 -1
- package/dist/internal/HeaderCodec.d.ts.map +0 -1
- package/dist/internal/HeaderCodec.js.map +0 -1
- package/dist/internal/constantTimeEqual.d.ts.map +0 -1
- package/dist/internal/constantTimeEqual.js.map +0 -1
- package/dist/internal/env.d.ts.map +0 -1
- package/dist/internal/env.js.map +0 -1
- package/dist/internal/types.d.ts.map +0 -1
- package/dist/internal/types.js.map +0 -1
- package/dist/mcp/client/McpClient.d.ts.map +0 -1
- package/dist/mcp/client/McpClient.js.map +0 -1
- package/dist/mcp/client/index.d.ts.map +0 -1
- package/dist/mcp/client/index.js.map +0 -1
- package/dist/mcp/server/Transport.d.ts.map +0 -1
- package/dist/mcp/server/Transport.js.map +0 -1
- package/dist/mcp/server/index.d.ts.map +0 -1
- package/dist/mcp/server/index.js.map +0 -1
- package/dist/middlewares/elysia.d.ts.map +0 -1
- package/dist/middlewares/elysia.js.map +0 -1
- package/dist/middlewares/express.d.ts.map +0 -1
- package/dist/middlewares/express.js.map +0 -1
- package/dist/middlewares/hono.d.ts.map +0 -1
- package/dist/middlewares/hono.js.map +0 -1
- package/dist/middlewares/internal/mppx.d.ts.map +0 -1
- package/dist/middlewares/internal/mppx.js.map +0 -1
- package/dist/middlewares/nextjs.d.ts.map +0 -1
- package/dist/middlewares/nextjs.js.map +0 -1
- package/dist/proxy/Proxy.d.ts.map +0 -1
- package/dist/proxy/Proxy.js.map +0 -1
- package/dist/proxy/Service.d.ts.map +0 -1
- package/dist/proxy/Service.js.map +0 -1
- package/dist/proxy/index.d.ts.map +0 -1
- package/dist/proxy/index.js.map +0 -1
- package/dist/proxy/internal/Headers.d.ts.map +0 -1
- package/dist/proxy/internal/Headers.js.map +0 -1
- package/dist/proxy/internal/Route.d.ts.map +0 -1
- package/dist/proxy/internal/Route.js.map +0 -1
- package/dist/proxy/services/anthropic.d.ts.map +0 -1
- package/dist/proxy/services/anthropic.js.map +0 -1
- package/dist/proxy/services/openai.d.ts.map +0 -1
- package/dist/proxy/services/openai.js.map +0 -1
- package/dist/proxy/services/stripe.d.ts.map +0 -1
- package/dist/proxy/services/stripe.js.map +0 -1
- package/dist/server/Methods.d.ts.map +0 -1
- package/dist/server/Methods.js.map +0 -1
- package/dist/server/Mppx.d.ts.map +0 -1
- package/dist/server/Mppx.js.map +0 -1
- package/dist/server/NodeListener.d.ts.map +0 -1
- package/dist/server/NodeListener.js.map +0 -1
- package/dist/server/Request.d.ts.map +0 -1
- package/dist/server/Request.js.map +0 -1
- package/dist/server/Response.d.ts.map +0 -1
- package/dist/server/Response.js.map +0 -1
- package/dist/server/Transport.d.ts.map +0 -1
- package/dist/server/Transport.js.map +0 -1
- package/dist/server/index.d.ts.map +0 -1
- package/dist/server/index.js.map +0 -1
- package/dist/server/internal/html/compose.main.gen.d.ts.map +0 -1
- package/dist/server/internal/html/compose.main.gen.js.map +0 -1
- package/dist/server/internal/html/config.d.ts.map +0 -1
- package/dist/server/internal/html/config.js.map +0 -1
- package/dist/server/internal/html/constants.d.ts.map +0 -1
- package/dist/server/internal/html/constants.js.map +0 -1
- package/dist/server/internal/html/serviceWorker.client.d.ts.map +0 -1
- package/dist/server/internal/html/serviceWorker.client.js.map +0 -1
- package/dist/server/internal/html/serviceWorker.gen.d.ts.map +0 -1
- package/dist/server/internal/html/serviceWorker.gen.js.map +0 -1
- package/dist/server/internal/scope.d.ts.map +0 -1
- package/dist/server/internal/scope.js.map +0 -1
- package/dist/stripe/Methods.d.ts.map +0 -1
- package/dist/stripe/Methods.js.map +0 -1
- package/dist/stripe/client/Charge.d.ts.map +0 -1
- package/dist/stripe/client/Charge.js.map +0 -1
- package/dist/stripe/client/Methods.d.ts.map +0 -1
- package/dist/stripe/client/Methods.js.map +0 -1
- package/dist/stripe/client/index.d.ts.map +0 -1
- package/dist/stripe/client/index.js.map +0 -1
- package/dist/stripe/index.d.ts.map +0 -1
- package/dist/stripe/index.js.map +0 -1
- package/dist/stripe/internal/constants.d.ts.map +0 -1
- package/dist/stripe/internal/constants.js.map +0 -1
- package/dist/stripe/internal/types.d.ts.map +0 -1
- package/dist/stripe/internal/types.js.map +0 -1
- package/dist/stripe/server/Charge.d.ts.map +0 -1
- package/dist/stripe/server/Charge.js.map +0 -1
- package/dist/stripe/server/Methods.d.ts.map +0 -1
- package/dist/stripe/server/Methods.js.map +0 -1
- package/dist/stripe/server/index.d.ts.map +0 -1
- package/dist/stripe/server/index.js.map +0 -1
- package/dist/stripe/server/internal/html/types.d.ts.map +0 -1
- package/dist/stripe/server/internal/html/types.js.map +0 -1
- package/dist/stripe/server/internal/html.gen.d.ts.map +0 -1
- package/dist/stripe/server/internal/html.gen.js.map +0 -1
- package/dist/tempo/Attribution.d.ts.map +0 -1
- package/dist/tempo/Attribution.js.map +0 -1
- package/dist/tempo/Methods.d.ts.map +0 -1
- package/dist/tempo/Methods.js.map +0 -1
- package/dist/tempo/Proof.d.ts.map +0 -1
- package/dist/tempo/Proof.js.map +0 -1
- package/dist/tempo/client/Charge.d.ts.map +0 -1
- package/dist/tempo/client/Charge.js.map +0 -1
- package/dist/tempo/client/Methods.d.ts.map +0 -1
- package/dist/tempo/client/Methods.js.map +0 -1
- package/dist/tempo/client/ResolveAccount.d.ts.map +0 -1
- package/dist/tempo/client/ResolveAccount.js.map +0 -1
- package/dist/tempo/client/Subscription.d.ts.map +0 -1
- package/dist/tempo/client/Subscription.js.map +0 -1
- package/dist/tempo/client/index.d.ts.map +0 -1
- package/dist/tempo/client/index.js.map +0 -1
- package/dist/tempo/index.d.ts.map +0 -1
- package/dist/tempo/index.js.map +0 -1
- package/dist/tempo/internal/account.d.ts.map +0 -1
- package/dist/tempo/internal/account.js.map +0 -1
- package/dist/tempo/internal/address.d.ts.map +0 -1
- package/dist/tempo/internal/address.js.map +0 -1
- package/dist/tempo/internal/auto-swap.d.ts.map +0 -1
- package/dist/tempo/internal/auto-swap.js.map +0 -1
- package/dist/tempo/internal/charge.d.ts.map +0 -1
- package/dist/tempo/internal/charge.js.map +0 -1
- package/dist/tempo/internal/defaults.d.ts.map +0 -1
- package/dist/tempo/internal/defaults.js.map +0 -1
- package/dist/tempo/internal/fee-payer.d.ts.map +0 -1
- package/dist/tempo/internal/fee-payer.js.map +0 -1
- package/dist/tempo/internal/fee-token.d.ts.map +0 -1
- package/dist/tempo/internal/fee-token.js.map +0 -1
- package/dist/tempo/internal/proof.d.ts.map +0 -1
- package/dist/tempo/internal/proof.js.map +0 -1
- package/dist/tempo/internal/selectors.d.ts.map +0 -1
- package/dist/tempo/internal/selectors.js.map +0 -1
- package/dist/tempo/internal/types.d.ts.map +0 -1
- package/dist/tempo/internal/types.js.map +0 -1
- package/dist/tempo/legacy/client/ChannelOps.d.ts.map +0 -1
- package/dist/tempo/legacy/client/ChannelOps.js.map +0 -1
- package/dist/tempo/legacy/client/Session.d.ts.map +0 -1
- package/dist/tempo/legacy/client/Session.js.map +0 -1
- package/dist/tempo/legacy/client/SessionManager.d.ts.map +0 -1
- package/dist/tempo/legacy/client/SessionManager.js.map +0 -1
- package/dist/tempo/legacy/client/index.d.ts.map +0 -1
- package/dist/tempo/legacy/client/index.js.map +0 -1
- package/dist/tempo/legacy/index.d.ts.map +0 -1
- package/dist/tempo/legacy/index.js.map +0 -1
- package/dist/tempo/legacy/server/Session.d.ts +0 -208
- package/dist/tempo/legacy/server/Session.d.ts.map +0 -1
- package/dist/tempo/legacy/server/Session.js +0 -698
- package/dist/tempo/legacy/server/Session.js.map +0 -1
- package/dist/tempo/legacy/server/index.d.ts +0 -5
- package/dist/tempo/legacy/server/index.d.ts.map +0 -1
- package/dist/tempo/legacy/server/index.js +0 -5
- package/dist/tempo/legacy/server/index.js.map +0 -1
- package/dist/tempo/legacy/session/Chain.d.ts.map +0 -1
- package/dist/tempo/legacy/session/Chain.js.map +0 -1
- package/dist/tempo/legacy/session/Channel.d.ts.map +0 -1
- package/dist/tempo/legacy/session/Channel.js.map +0 -1
- package/dist/tempo/legacy/session/ChannelStore.d.ts +0 -22
- package/dist/tempo/legacy/session/ChannelStore.d.ts.map +0 -1
- package/dist/tempo/legacy/session/ChannelStore.js +0 -6
- package/dist/tempo/legacy/session/ChannelStore.js.map +0 -1
- package/dist/tempo/legacy/session/Types.d.ts.map +0 -1
- package/dist/tempo/legacy/session/Types.js.map +0 -1
- package/dist/tempo/legacy/session/Voucher.d.ts.map +0 -1
- package/dist/tempo/legacy/session/Voucher.js.map +0 -1
- package/dist/tempo/legacy/session/escrow.abi.d.ts.map +0 -1
- package/dist/tempo/legacy/session/escrow.abi.js.map +0 -1
- package/dist/tempo/legacy/session/index.d.ts.map +0 -1
- package/dist/tempo/legacy/session/index.js.map +0 -1
- package/dist/tempo/server/Charge.d.ts.map +0 -1
- package/dist/tempo/server/Charge.js.map +0 -1
- package/dist/tempo/server/Methods.d.ts.map +0 -1
- package/dist/tempo/server/Methods.js.map +0 -1
- package/dist/tempo/server/Relay.d.ts.map +0 -1
- package/dist/tempo/server/Relay.js.map +0 -1
- package/dist/tempo/server/SponsorBudget.d.ts.map +0 -1
- package/dist/tempo/server/SponsorBudget.js.map +0 -1
- package/dist/tempo/server/Subscription.d.ts.map +0 -1
- package/dist/tempo/server/Subscription.js.map +0 -1
- package/dist/tempo/server/index.d.ts.map +0 -1
- package/dist/tempo/server/index.js.map +0 -1
- package/dist/tempo/server/internal/html.gen.d.ts.map +0 -1
- package/dist/tempo/server/internal/html.gen.js.map +0 -1
- package/dist/tempo/server/internal/request-body.d.ts.map +0 -1
- package/dist/tempo/server/internal/request-body.js.map +0 -1
- package/dist/tempo/server/internal/transport.d.ts.map +0 -1
- package/dist/tempo/server/internal/transport.js.map +0 -1
- package/dist/tempo/session/Snapshot.d.ts.map +0 -1
- package/dist/tempo/session/Snapshot.js.map +0 -1
- package/dist/tempo/session/client/ChannelOps.d.ts.map +0 -1
- package/dist/tempo/session/client/ChannelOps.js.map +0 -1
- package/dist/tempo/session/client/ChannelStore.d.ts.map +0 -1
- package/dist/tempo/session/client/ChannelStore.js.map +0 -1
- package/dist/tempo/session/client/CredentialState.d.ts.map +0 -1
- package/dist/tempo/session/client/CredentialState.js.map +0 -1
- package/dist/tempo/session/client/ReceiptCoordinator.d.ts.map +0 -1
- package/dist/tempo/session/client/ReceiptCoordinator.js.map +0 -1
- package/dist/tempo/session/client/Runtime.d.ts.map +0 -1
- package/dist/tempo/session/client/Runtime.js.map +0 -1
- package/dist/tempo/session/client/Session.d.ts.map +0 -1
- package/dist/tempo/session/client/Session.js.map +0 -1
- package/dist/tempo/session/client/SessionManager.d.ts.map +0 -1
- package/dist/tempo/session/client/SessionManager.js.map +0 -1
- package/dist/tempo/session/client/Transports.d.ts.map +0 -1
- package/dist/tempo/session/client/Transports.js.map +0 -1
- package/dist/tempo/session/client/index.d.ts.map +0 -1
- package/dist/tempo/session/client/index.js.map +0 -1
- package/dist/tempo/session/client/internal/SessionManager.d.ts.map +0 -1
- package/dist/tempo/session/client/internal/SessionManager.js.map +0 -1
- package/dist/tempo/session/index.d.ts.map +0 -1
- package/dist/tempo/session/index.js.map +0 -1
- package/dist/tempo/session/precompile/Chain.d.ts.map +0 -1
- package/dist/tempo/session/precompile/Chain.js.map +0 -1
- package/dist/tempo/session/precompile/Channel.d.ts.map +0 -1
- package/dist/tempo/session/precompile/Channel.js.map +0 -1
- package/dist/tempo/session/precompile/Protocol.d.ts.map +0 -1
- package/dist/tempo/session/precompile/Protocol.js.map +0 -1
- package/dist/tempo/session/precompile/Voucher.d.ts.map +0 -1
- package/dist/tempo/session/precompile/Voucher.js.map +0 -1
- package/dist/tempo/session/precompile/escrow.abi.d.ts.map +0 -1
- package/dist/tempo/session/precompile/escrow.abi.js.map +0 -1
- package/dist/tempo/session/precompile/index.d.ts.map +0 -1
- package/dist/tempo/session/precompile/index.js.map +0 -1
- package/dist/tempo/session/server/ChannelOps.d.ts.map +0 -1
- package/dist/tempo/session/server/ChannelOps.js.map +0 -1
- package/dist/tempo/session/server/ChannelStore.d.ts.map +0 -1
- package/dist/tempo/session/server/ChannelStore.js.map +0 -1
- package/dist/tempo/session/server/CredentialVerification.d.ts.map +0 -1
- package/dist/tempo/session/server/CredentialVerification.js.map +0 -1
- package/dist/tempo/session/server/MeteredStream.d.ts.map +0 -1
- package/dist/tempo/session/server/MeteredStream.js.map +0 -1
- package/dist/tempo/session/server/RequestState.d.ts.map +0 -1
- package/dist/tempo/session/server/RequestState.js.map +0 -1
- package/dist/tempo/session/server/Session.d.ts.map +0 -1
- package/dist/tempo/session/server/Session.js.map +0 -1
- package/dist/tempo/session/server/Settlement.d.ts.map +0 -1
- package/dist/tempo/session/server/Settlement.js.map +0 -1
- package/dist/tempo/session/server/Sse.d.ts.map +0 -1
- package/dist/tempo/session/server/Sse.js.map +0 -1
- package/dist/tempo/session/server/Transports.d.ts.map +0 -1
- package/dist/tempo/session/server/Transports.js.map +0 -1
- package/dist/tempo/session/server/Ws.d.ts.map +0 -1
- package/dist/tempo/session/server/Ws.js.map +0 -1
- package/dist/tempo/session/server/index.d.ts.map +0 -1
- package/dist/tempo/session/server/index.js.map +0 -1
- package/dist/tempo/subscription/KeyAuthorization.d.ts.map +0 -1
- package/dist/tempo/subscription/KeyAuthorization.js.map +0 -1
- package/dist/tempo/subscription/Receipt.d.ts.map +0 -1
- package/dist/tempo/subscription/Receipt.js.map +0 -1
- package/dist/tempo/subscription/Store.d.ts.map +0 -1
- package/dist/tempo/subscription/Store.js.map +0 -1
- package/dist/tempo/subscription/Types.d.ts.map +0 -1
- package/dist/tempo/subscription/Types.js.map +0 -1
- package/dist/tempo/subscription/index.d.ts.map +0 -1
- package/dist/tempo/subscription/index.js.map +0 -1
- package/dist/validation/core.d.ts.map +0 -1
- package/dist/validation/core.js.map +0 -1
- package/dist/validation/index.d.ts.map +0 -1
- package/dist/validation/index.js.map +0 -1
- package/dist/viem/Account.d.ts.map +0 -1
- package/dist/viem/Account.js.map +0 -1
- package/dist/viem/Client.d.ts.map +0 -1
- package/dist/viem/Client.js.map +0 -1
- package/dist/x402/Assets.d.ts.map +0 -1
- package/dist/x402/Assets.js.map +0 -1
- package/dist/x402/Header.d.ts.map +0 -1
- package/dist/x402/Header.js.map +0 -1
- package/dist/x402/Types.d.ts.map +0 -1
- package/dist/x402/Types.js.map +0 -1
- package/dist/x402/client/Exact.d.ts.map +0 -1
- package/dist/x402/client/Exact.js.map +0 -1
- package/dist/x402/index.d.ts.map +0 -1
- package/dist/x402/index.js.map +0 -1
- package/dist/x402/internal/ChallengeBrand.d.ts.map +0 -1
- package/dist/x402/internal/ChallengeBrand.js.map +0 -1
- package/dist/x402/internal/RouteBinding.d.ts.map +0 -1
- package/dist/x402/internal/RouteBinding.js.map +0 -1
- package/dist/x402/server/EvmCharge.d.ts.map +0 -1
- package/dist/x402/server/EvmCharge.js.map +0 -1
- package/dist/x402/server/Facilitator.d.ts.map +0 -1
- package/dist/x402/server/Facilitator.js.map +0 -1
- package/dist/zod.d.ts.map +0 -1
- package/dist/zod.js.map +0 -1
- package/src/BodyDigest.test.ts +0 -43
- package/src/BodyDigest.ts +0 -55
- package/src/Challenge.fuzz.test.ts +0 -121
- package/src/Challenge.test-d.ts +0 -82
- package/src/Challenge.test.ts +0 -995
- package/src/Challenge.ts +0 -683
- package/src/Constants.ts +0 -58
- package/src/Credential.fuzz.test.ts +0 -62
- package/src/Credential.test.ts +0 -378
- package/src/Credential.ts +0 -217
- package/src/Errors.test.ts +0 -520
- package/src/Errors.ts +0 -448
- package/src/Expires.test.ts +0 -112
- package/src/Expires.ts +0 -59
- package/src/Html.ts +0 -67
- package/src/Mcp.ts +0 -85
- package/src/Method.test.ts +0 -177
- package/src/Method.ts +0 -617
- package/src/PaymentRequest.test.ts +0 -147
- package/src/PaymentRequest.ts +0 -108
- package/src/Receipt.test.ts +0 -151
- package/src/Receipt.ts +0 -146
- package/src/Store.test-d.ts +0 -195
- package/src/Store.test.ts +0 -357
- package/src/Store.ts +0 -329
- package/src/bin.ts +0 -4
- package/src/cli/account.ts +0 -269
- package/src/cli/cli.test.ts +0 -2221
- package/src/cli/cli.ts +0 -1649
- package/src/cli/config.test.ts +0 -89
- package/src/cli/config.ts +0 -50
- package/src/cli/internal.ts +0 -114
- package/src/cli/mcp.test.ts +0 -262
- package/src/cli/plugins/evm.ts +0 -55
- package/src/cli/plugins/index.ts +0 -4
- package/src/cli/plugins/plugin.ts +0 -84
- package/src/cli/plugins/stripe.ts +0 -174
- package/src/cli/plugins/tempo.ts +0 -1102
- package/src/cli/sessions/Manager.test.ts +0 -249
- package/src/cli/sessions/Manager.ts +0 -93
- package/src/cli/sessions/commands.ts +0 -444
- package/src/cli/sessions/request.test.ts +0 -51
- package/src/cli/sessions/request.ts +0 -353
- package/src/cli/sessions/store.test.ts +0 -581
- package/src/cli/sessions/store.ts +0 -940
- package/src/cli/utils.test.ts +0 -156
- package/src/cli/utils.ts +0 -394
- package/src/cli/validate/challenge.ts +0 -565
- package/src/cli/validate/discovery.test.ts +0 -435
- package/src/cli/validate/discovery.ts +0 -221
- package/src/cli/validate/helpers.ts +0 -166
- package/src/cli/validate/index.ts +0 -229
- package/src/cli/validate/messages.ts +0 -7
- package/src/cli/validate/payment.ts +0 -774
- package/src/cli/validate.test.ts +0 -843
- package/src/client/Methods.ts +0 -8
- package/src/client/Mppx.test-d.ts +0 -270
- package/src/client/Mppx.test.ts +0 -1065
- package/src/client/Mppx.ts +0 -466
- package/src/client/Transport.test.ts +0 -619
- package/src/client/Transport.ts +0 -191
- package/src/client/index.ts +0 -29
- package/src/client/internal/Fetch.browser.test.ts +0 -197
- package/src/client/internal/Fetch.test-d.ts +0 -109
- package/src/client/internal/Fetch.test.ts +0 -2336
- package/src/client/internal/Fetch.ts +0 -1079
- package/src/client/internal/MethodChallenge.ts +0 -35
- package/src/client/internal/MethodResponse.ts +0 -67
- package/src/client/internal/protocols/Mcp.test.ts +0 -220
- package/src/client/internal/protocols/Mcp.ts +0 -186
- package/src/client/internal/protocols/Mpp.ts +0 -21
- package/src/client/internal/protocols/Protocol.ts +0 -10
- package/src/client/internal/protocols/Shared.ts +0 -25
- package/src/client/internal/protocols/X402.ts +0 -46
- package/src/client/node.test.ts +0 -115
- package/src/client/node.ts +0 -247
- package/src/discovery/Discovery.test.ts +0 -214
- package/src/discovery/Discovery.ts +0 -105
- package/src/discovery/OpenApi.test.ts +0 -453
- package/src/discovery/OpenApi.ts +0 -224
- package/src/discovery/Validate.test.ts +0 -305
- package/src/discovery/Validate.ts +0 -77
- package/src/discovery/index.ts +0 -3
- package/src/env.d.ts +0 -12
- package/src/evm/Assets.ts +0 -1
- package/src/evm/Chains.ts +0 -11
- package/src/evm/Methods.ts +0 -44
- package/src/evm/PublicInterface.test-d.ts +0 -134
- package/src/evm/Types.ts +0 -140
- package/src/evm/client/Charge.test.ts +0 -347
- package/src/evm/client/Charge.ts +0 -187
- package/src/evm/client/Methods.ts +0 -19
- package/src/evm/client/index.ts +0 -6
- package/src/evm/index.ts +0 -16
- package/src/evm/server/Charge.test.ts +0 -339
- package/src/evm/server/Charge.ts +0 -290
- package/src/evm/server/Methods.ts +0 -22
- package/src/evm/server/index.ts +0 -6
- package/src/index.ts +0 -14
- package/src/internal/AcceptPayment.test.ts +0 -343
- package/src/internal/AcceptPayment.ts +0 -366
- package/src/internal/HeaderCodec.ts +0 -36
- package/src/internal/changeset.test.ts +0 -106
- package/src/internal/constantTimeEqual.test.ts +0 -47
- package/src/internal/constantTimeEqual.ts +0 -10
- package/src/internal/env.test.ts +0 -42
- package/src/internal/env.ts +0 -49
- package/src/internal/types.test-d.ts +0 -21
- package/src/internal/types.ts +0 -470
- package/src/mcp/client/McpClient.integration.test.ts +0 -652
- package/src/mcp/client/McpClient.test-d.ts +0 -144
- package/src/mcp/client/McpClient.test.ts +0 -463
- package/src/mcp/client/McpClient.ts +0 -307
- package/src/mcp/client/McpClient.unit.test.ts +0 -135
- package/src/mcp/client/index.ts +0 -2
- package/src/mcp/server/Transport.test.ts +0 -191
- package/src/mcp/server/Transport.ts +0 -111
- package/src/mcp/server/index.ts +0 -1
- package/src/middlewares/elysia.test.ts +0 -295
- package/src/middlewares/elysia.ts +0 -116
- package/src/middlewares/express.test.ts +0 -371
- package/src/middlewares/express.ts +0 -140
- package/src/middlewares/hono.test.ts +0 -476
- package/src/middlewares/hono.ts +0 -153
- package/src/middlewares/internal/mppx.test.ts +0 -177
- package/src/middlewares/internal/mppx.ts +0 -67
- package/src/middlewares/nextjs.test.ts +0 -369
- package/src/middlewares/nextjs.ts +0 -107
- package/src/proxy/Proxy.test.ts +0 -1031
- package/src/proxy/Proxy.ts +0 -345
- package/src/proxy/Service.test.ts +0 -182
- package/src/proxy/Service.ts +0 -253
- package/src/proxy/index.ts +0 -6
- package/src/proxy/internal/Headers.test.ts +0 -139
- package/src/proxy/internal/Headers.ts +0 -66
- package/src/proxy/internal/Route.test.ts +0 -217
- package/src/proxy/internal/Route.ts +0 -64
- package/src/proxy/services/anthropic.test.ts +0 -132
- package/src/proxy/services/anthropic.ts +0 -52
- package/src/proxy/services/openai.test.ts +0 -157
- package/src/proxy/services/openai.ts +0 -59
- package/src/proxy/services/stripe.test.ts +0 -175
- package/src/proxy/services/stripe.ts +0 -58
- package/src/server/Methods.ts +0 -3
- package/src/server/Mppx.authorize.test.ts +0 -210
- package/src/server/Mppx.test-d.ts +0 -360
- package/src/server/Mppx.test.ts +0 -5813
- package/src/server/Mppx.ts +0 -2623
- package/src/server/NodeListener.test.ts +0 -293
- package/src/server/NodeListener.ts +0 -45
- package/src/server/Request.test.ts +0 -255
- package/src/server/Request.ts +0 -155
- package/src/server/Response.test.ts +0 -32
- package/src/server/Response.ts +0 -45
- package/src/server/Transport.test.ts +0 -598
- package/src/server/Transport.ts +0 -320
- package/src/server/index.ts +0 -9
- package/src/server/internal/html/compose.main.gen.ts +0 -2
- package/src/server/internal/html/compose.main.ts +0 -88
- package/src/server/internal/html/config.ts +0 -672
- package/src/server/internal/html/constants.ts +0 -28
- package/src/server/internal/html/serviceWorker.client.ts +0 -28
- package/src/server/internal/html/serviceWorker.gen.ts +0 -2
- package/src/server/internal/html/serviceWorker.ts +0 -27
- package/src/server/internal/html/tsconfig.compose.json +0 -8
- package/src/server/internal/html/tsconfig.worker.client.json +0 -8
- package/src/server/internal/html/tsconfig.worker.json +0 -8
- package/src/server/internal/scope.ts +0 -43
- package/src/stripe/Charge.integration.test.ts +0 -329
- package/src/stripe/Methods.test.ts +0 -62
- package/src/stripe/Methods.ts +0 -44
- package/src/stripe/client/Charge.test.ts +0 -205
- package/src/stripe/client/Charge.ts +0 -132
- package/src/stripe/client/Methods.ts +0 -37
- package/src/stripe/client/index.ts +0 -2
- package/src/stripe/index.ts +0 -1
- package/src/stripe/internal/constants.ts +0 -7
- package/src/stripe/internal/types.ts +0 -46
- package/src/stripe/server/Charge.test-d.ts +0 -66
- package/src/stripe/server/Charge.test.ts +0 -621
- package/src/stripe/server/Charge.ts +0 -434
- package/src/stripe/server/Methods.ts +0 -24
- package/src/stripe/server/index.ts +0 -2
- package/src/stripe/server/internal/html/main.ts +0 -165
- package/src/stripe/server/internal/html/node_modules/.bin/mppx +0 -22
- package/src/stripe/server/internal/html/node_modules/.bin/mppx.src +0 -22
- package/src/stripe/server/internal/html/package.json +0 -9
- package/src/stripe/server/internal/html/stripe-js-pure.d.ts +0 -7
- package/src/stripe/server/internal/html/tsconfig.json +0 -8
- package/src/stripe/server/internal/html/types.ts +0 -5
- package/src/stripe/server/internal/html.gen.ts +0 -2
- package/src/tempo/AccessKeyAuthorization.test.ts +0 -141
- package/src/tempo/Attribution.test.ts +0 -294
- package/src/tempo/Attribution.ts +0 -185
- package/src/tempo/Methods.test.ts +0 -425
- package/src/tempo/Methods.ts +0 -367
- package/src/tempo/Proof.conformance.test.ts +0 -146
- package/src/tempo/Proof.test-d.ts +0 -32
- package/src/tempo/Proof.test.ts +0 -40
- package/src/tempo/Proof.ts +0 -69
- package/src/tempo/PublicExports.test-d.ts +0 -130
- package/src/tempo/Subscription.integration.test.ts +0 -591
- package/src/tempo/client/Charge.test.ts +0 -501
- package/src/tempo/client/Charge.ts +0 -289
- package/src/tempo/client/Methods.ts +0 -45
- package/src/tempo/client/ResolveAccount.ts +0 -46
- package/src/tempo/client/Subscription.test.ts +0 -180
- package/src/tempo/client/Subscription.ts +0 -156
- package/src/tempo/client/index.ts +0 -17
- package/src/tempo/index.ts +0 -5
- package/src/tempo/internal/account.ts +0 -56
- package/src/tempo/internal/address.ts +0 -6
- package/src/tempo/internal/auto-swap.test.ts +0 -198
- package/src/tempo/internal/auto-swap.ts +0 -188
- package/src/tempo/internal/charge.test.ts +0 -66
- package/src/tempo/internal/charge.ts +0 -43
- package/src/tempo/internal/defaults.test.ts +0 -95
- package/src/tempo/internal/defaults.ts +0 -53
- package/src/tempo/internal/fee-payer.test.ts +0 -1177
- package/src/tempo/internal/fee-payer.ts +0 -808
- package/src/tempo/internal/fee-token.test.ts +0 -165
- package/src/tempo/internal/fee-token.ts +0 -72
- package/src/tempo/internal/proof.test.ts +0 -97
- package/src/tempo/internal/proof.ts +0 -87
- package/src/tempo/internal/selectors.ts +0 -10
- package/src/tempo/internal/types.ts +0 -19
- package/src/tempo/legacy/AccessKeyAuthorization.test.ts +0 -162
- package/src/tempo/legacy/README.md +0 -9
- package/src/tempo/legacy/client/ChannelOps.test.ts +0 -379
- package/src/tempo/legacy/client/ChannelOps.ts +0 -271
- package/src/tempo/legacy/client/Session.test.ts +0 -800
- package/src/tempo/legacy/client/Session.ts +0 -397
- package/src/tempo/legacy/client/SessionManager.test.ts +0 -468
- package/src/tempo/legacy/client/SessionManager.ts +0 -909
- package/src/tempo/legacy/client/index.ts +0 -6
- package/src/tempo/legacy/index.ts +0 -6
- package/src/tempo/legacy/server/Defaults.test-d.ts +0 -9
- package/src/tempo/legacy/server/Session.test.ts +0 -6370
- package/src/tempo/legacy/server/Session.ts +0 -1024
- package/src/tempo/legacy/server/index.ts +0 -4
- package/src/tempo/legacy/session/Chain.test.ts +0 -1349
- package/src/tempo/legacy/session/Chain.ts +0 -830
- package/src/tempo/legacy/session/Channel.test.ts +0 -109
- package/src/tempo/legacy/session/Channel.ts +0 -51
- package/src/tempo/legacy/session/ChannelStore.test.ts +0 -58
- package/src/tempo/legacy/session/ChannelStore.ts +0 -39
- package/src/tempo/legacy/session/Types.ts +0 -91
- package/src/tempo/legacy/session/Voucher.test.ts +0 -410
- package/src/tempo/legacy/session/Voucher.ts +0 -183
- package/src/tempo/legacy/session/escrow.abi.ts +0 -760
- package/src/tempo/legacy/session/index.ts +0 -8
- package/src/tempo/server/AtomicStore.test-d.ts +0 -50
- package/src/tempo/server/Charge.test.ts +0 -6121
- package/src/tempo/server/Charge.ts +0 -1351
- package/src/tempo/server/Methods.ts +0 -106
- package/src/tempo/server/Relay.test.ts +0 -677
- package/src/tempo/server/Relay.ts +0 -297
- package/src/tempo/server/SponsorBudget.test.ts +0 -154
- package/src/tempo/server/SponsorBudget.ts +0 -219
- package/src/tempo/server/Sse.test.ts +0 -321
- package/src/tempo/server/Subscription.test.ts +0 -1944
- package/src/tempo/server/Subscription.ts +0 -1333
- package/src/tempo/server/index.ts +0 -12
- package/src/tempo/server/internal/html/main.ts +0 -115
- package/src/tempo/server/internal/html/node_modules/.bin/mppx +0 -22
- package/src/tempo/server/internal/html/node_modules/.bin/mppx.src +0 -22
- package/src/tempo/server/internal/html/package.json +0 -10
- package/src/tempo/server/internal/html/tsconfig.json +0 -8
- package/src/tempo/server/internal/html.gen.ts +0 -2
- package/src/tempo/server/internal/request-body.test.ts +0 -210
- package/src/tempo/server/internal/request-body.ts +0 -61
- package/src/tempo/server/internal/transport.test.ts +0 -903
- package/src/tempo/server/internal/transport.ts +0 -310
- package/src/tempo/session/README.md +0 -208
- package/src/tempo/session/Snapshot.test.ts +0 -41
- package/src/tempo/session/Snapshot.ts +0 -95
- package/src/tempo/session/client/ChannelOps.test.ts +0 -218
- package/src/tempo/session/client/ChannelOps.ts +0 -348
- package/src/tempo/session/client/ChannelStore.ts +0 -111
- package/src/tempo/session/client/CredentialState.test.ts +0 -789
- package/src/tempo/session/client/CredentialState.ts +0 -942
- package/src/tempo/session/client/ReceiptCoordinator.ts +0 -95
- package/src/tempo/session/client/Runtime.test.ts +0 -1104
- package/src/tempo/session/client/Runtime.ts +0 -1008
- package/src/tempo/session/client/Session.test.ts +0 -1355
- package/src/tempo/session/client/Session.ts +0 -420
- package/src/tempo/session/client/SessionManager.test.ts +0 -1899
- package/src/tempo/session/client/SessionManager.ts +0 -996
- package/src/tempo/session/client/Transports.test.ts +0 -1141
- package/src/tempo/session/client/Transports.ts +0 -1534
- package/src/tempo/session/client/index.ts +0 -40
- package/src/tempo/session/client/internal/SessionManager.ts +0 -36
- package/src/tempo/session/index.ts +0 -7
- package/src/tempo/session/precompile/Chain.integration.test.ts +0 -339
- package/src/tempo/session/precompile/Chain.test.ts +0 -1641
- package/src/tempo/session/precompile/Chain.ts +0 -1149
- package/src/tempo/session/precompile/Channel.test.ts +0 -147
- package/src/tempo/session/precompile/Channel.ts +0 -108
- package/src/tempo/session/precompile/Protocol.test.ts +0 -358
- package/src/tempo/session/precompile/Protocol.ts +0 -520
- package/src/tempo/session/precompile/Voucher.test.ts +0 -354
- package/src/tempo/session/precompile/Voucher.ts +0 -162
- package/src/tempo/session/precompile/escrow.abi.ts +0 -226
- package/src/tempo/session/precompile/index.ts +0 -33
- package/src/tempo/session/server/ChannelOps.test.ts +0 -129
- package/src/tempo/session/server/ChannelOps.ts +0 -157
- package/src/tempo/session/server/ChannelStore.test.ts +0 -1093
- package/src/tempo/session/server/ChannelStore.ts +0 -835
- package/src/tempo/session/server/CredentialVerification.test.ts +0 -299
- package/src/tempo/session/server/CredentialVerification.ts +0 -775
- package/src/tempo/session/server/MeteredStream.ts +0 -95
- package/src/tempo/session/server/RequestState.test.ts +0 -574
- package/src/tempo/session/server/RequestState.ts +0 -507
- package/src/tempo/session/server/Session.integration.test.ts +0 -449
- package/src/tempo/session/server/Session.test.ts +0 -3862
- package/src/tempo/session/server/Session.ts +0 -570
- package/src/tempo/session/server/Settlement.test.ts +0 -345
- package/src/tempo/session/server/Settlement.ts +0 -527
- package/src/tempo/session/server/Sse.fuzz.test.ts +0 -138
- package/src/tempo/session/server/Sse.test.ts +0 -557
- package/src/tempo/session/server/Sse.ts +0 -254
- package/src/tempo/session/server/Transports.test.ts +0 -346
- package/src/tempo/session/server/Transports.ts +0 -255
- package/src/tempo/session/server/Ws.test.ts +0 -594
- package/src/tempo/session/server/Ws.ts +0 -385
- package/src/tempo/session/server/index.ts +0 -12
- package/src/tempo/subscription/KeyAuthorization.test.ts +0 -282
- package/src/tempo/subscription/KeyAuthorization.ts +0 -396
- package/src/tempo/subscription/Receipt.ts +0 -28
- package/src/tempo/subscription/Store.test.ts +0 -609
- package/src/tempo/subscription/Store.ts +0 -449
- package/src/tempo/subscription/Types.ts +0 -68
- package/src/tempo/subscription/index.ts +0 -23
- package/src/tsconfig.json +0 -10
- package/src/validation/core.ts +0 -386
- package/src/validation/index.ts +0 -11
- package/src/viem/Account.test.ts +0 -72
- package/src/viem/Account.ts +0 -30
- package/src/viem/Client.test.ts +0 -366
- package/src/viem/Client.ts +0 -93
- package/src/x402/Assets.test.ts +0 -253
- package/src/x402/Assets.ts +0 -221
- package/src/x402/Exact.e2e.test.ts +0 -448
- package/src/x402/Exact.localnet.test.ts +0 -475
- package/src/x402/Header.test.ts +0 -73
- package/src/x402/Header.ts +0 -79
- package/src/x402/PublicInterface.test-d.ts +0 -39
- package/src/x402/Types.ts +0 -248
- package/src/x402/client/Exact.test.ts +0 -309
- package/src/x402/client/Exact.ts +0 -186
- package/src/x402/index.ts +0 -6
- package/src/x402/internal/ChallengeBrand.ts +0 -14
- package/src/x402/internal/RouteBinding.ts +0 -18
- package/src/x402/server/EvmCharge.ts +0 -394
- package/src/x402/server/Facilitator.test.ts +0 -111
- package/src/x402/server/Facilitator.ts +0 -56
- package/src/zod.test.ts +0 -169
- package/src/zod.ts +0 -71
|
@@ -1,1177 +0,0 @@
|
|
|
1
|
-
import { Address, Secp256k1 } from 'ox'
|
|
2
|
-
import { TxEnvelopeTempo } from 'ox/tempo'
|
|
3
|
-
import { encodeFunctionData, maxUint256, toHex } from 'viem'
|
|
4
|
-
import { Abis, Addresses, Transaction } from 'viem/tempo'
|
|
5
|
-
import { afterEach, describe, expect, test, vi } from 'vp/test'
|
|
6
|
-
|
|
7
|
-
import * as defaults from './defaults.js'
|
|
8
|
-
import {
|
|
9
|
-
assertAllowedFeeToken,
|
|
10
|
-
callScopes,
|
|
11
|
-
defaultAllowedFeeTokens,
|
|
12
|
-
FeePayerValidationError,
|
|
13
|
-
fillHostedFeePayerTransaction,
|
|
14
|
-
preflightSponsorship,
|
|
15
|
-
prepareSponsoredTransaction,
|
|
16
|
-
simulationTransaction,
|
|
17
|
-
sponsoredSimulationTransaction,
|
|
18
|
-
validateCalls,
|
|
19
|
-
} from './fee-payer.js'
|
|
20
|
-
import * as Selectors from './selectors.js'
|
|
21
|
-
|
|
22
|
-
const details = { amount: '1', currency: '0x01', recipient: '0x02' }
|
|
23
|
-
const bogus = '0x0000000000000000000000000000000000000001' as const
|
|
24
|
-
const swapTokenIn = '0x0000000000000000000000000000000000000003' as const
|
|
25
|
-
const swapTokenOut = '0x0000000000000000000000000000000000000004' as const
|
|
26
|
-
const swapData = encodeFunctionData({
|
|
27
|
-
abi: Abis.stablecoinDex,
|
|
28
|
-
functionName: 'swapExactAmountOut',
|
|
29
|
-
args: [swapTokenIn, swapTokenOut, 100n, 100n],
|
|
30
|
-
})
|
|
31
|
-
const feePayerSignature = {
|
|
32
|
-
r: '0x0000000000000000000000000000000000000000000000000000000000000002',
|
|
33
|
-
s: '0x0000000000000000000000000000000000000000000000000000000000000003',
|
|
34
|
-
yParity: 1,
|
|
35
|
-
}
|
|
36
|
-
const sponsor = { address: bogus, type: 'local' } as any
|
|
37
|
-
|
|
38
|
-
afterEach(() => {
|
|
39
|
-
vi.unstubAllGlobals()
|
|
40
|
-
})
|
|
41
|
-
|
|
42
|
-
describe('callScopes', () => {
|
|
43
|
-
test('has 4 allowed patterns', () => {
|
|
44
|
-
expect(callScopes).toHaveLength(4)
|
|
45
|
-
})
|
|
46
|
-
|
|
47
|
-
test('patterns use correct selectors', () => {
|
|
48
|
-
expect(callScopes).toEqual([
|
|
49
|
-
[Selectors.transfer],
|
|
50
|
-
[Selectors.transferWithMemo],
|
|
51
|
-
[Selectors.approve, Selectors.swapExactAmountOut, Selectors.transfer],
|
|
52
|
-
[Selectors.approve, Selectors.swapExactAmountOut, Selectors.transferWithMemo],
|
|
53
|
-
])
|
|
54
|
-
})
|
|
55
|
-
})
|
|
56
|
-
|
|
57
|
-
describe('validateCalls', () => {
|
|
58
|
-
test('accepts single transfer', () => {
|
|
59
|
-
expect(() =>
|
|
60
|
-
validateCalls(
|
|
61
|
-
[
|
|
62
|
-
{
|
|
63
|
-
data: encodeFunctionData({
|
|
64
|
-
abi: Abis.tip20,
|
|
65
|
-
functionName: 'transfer',
|
|
66
|
-
args: [bogus, 100n],
|
|
67
|
-
}),
|
|
68
|
-
},
|
|
69
|
-
],
|
|
70
|
-
details,
|
|
71
|
-
),
|
|
72
|
-
).not.toThrow()
|
|
73
|
-
})
|
|
74
|
-
|
|
75
|
-
test('accepts approve + buy + transfer', () => {
|
|
76
|
-
expect(() =>
|
|
77
|
-
validateCalls(
|
|
78
|
-
[
|
|
79
|
-
{
|
|
80
|
-
to: swapTokenIn,
|
|
81
|
-
data: encodeFunctionData({
|
|
82
|
-
abi: Abis.tip20,
|
|
83
|
-
functionName: 'approve',
|
|
84
|
-
args: [Addresses.stablecoinDex, 100n],
|
|
85
|
-
}),
|
|
86
|
-
},
|
|
87
|
-
{
|
|
88
|
-
to: Addresses.stablecoinDex,
|
|
89
|
-
data: swapData,
|
|
90
|
-
},
|
|
91
|
-
{
|
|
92
|
-
data: encodeFunctionData({
|
|
93
|
-
abi: Abis.tip20,
|
|
94
|
-
functionName: 'transfer',
|
|
95
|
-
args: [bogus, 100n],
|
|
96
|
-
}),
|
|
97
|
-
},
|
|
98
|
-
],
|
|
99
|
-
details,
|
|
100
|
-
),
|
|
101
|
-
).not.toThrow()
|
|
102
|
-
})
|
|
103
|
-
|
|
104
|
-
test('accepts multiple transfers after swap prefix', () => {
|
|
105
|
-
expect(() =>
|
|
106
|
-
validateCalls(
|
|
107
|
-
[
|
|
108
|
-
{
|
|
109
|
-
to: swapTokenIn,
|
|
110
|
-
data: encodeFunctionData({
|
|
111
|
-
abi: Abis.tip20,
|
|
112
|
-
functionName: 'approve',
|
|
113
|
-
args: [Addresses.stablecoinDex, 100n],
|
|
114
|
-
}),
|
|
115
|
-
},
|
|
116
|
-
{
|
|
117
|
-
to: Addresses.stablecoinDex,
|
|
118
|
-
data: swapData,
|
|
119
|
-
},
|
|
120
|
-
{
|
|
121
|
-
data: encodeFunctionData({
|
|
122
|
-
abi: Abis.tip20,
|
|
123
|
-
functionName: 'transfer',
|
|
124
|
-
args: [bogus, 90n],
|
|
125
|
-
}),
|
|
126
|
-
},
|
|
127
|
-
{
|
|
128
|
-
data: encodeFunctionData({
|
|
129
|
-
abi: Abis.tip20,
|
|
130
|
-
functionName: 'transferWithMemo',
|
|
131
|
-
args: [
|
|
132
|
-
'0x0000000000000000000000000000000000000002',
|
|
133
|
-
10n,
|
|
134
|
-
'0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef',
|
|
135
|
-
],
|
|
136
|
-
}),
|
|
137
|
-
},
|
|
138
|
-
],
|
|
139
|
-
details,
|
|
140
|
-
),
|
|
141
|
-
).not.toThrow()
|
|
142
|
-
})
|
|
143
|
-
|
|
144
|
-
test('accepts approve + buy + exact expected split transfers', () => {
|
|
145
|
-
expect(() =>
|
|
146
|
-
validateCalls(
|
|
147
|
-
[
|
|
148
|
-
{
|
|
149
|
-
to: swapTokenIn,
|
|
150
|
-
data: encodeFunctionData({
|
|
151
|
-
abi: Abis.tip20,
|
|
152
|
-
functionName: 'approve',
|
|
153
|
-
args: [Addresses.stablecoinDex, 100n],
|
|
154
|
-
}),
|
|
155
|
-
},
|
|
156
|
-
{
|
|
157
|
-
to: Addresses.stablecoinDex,
|
|
158
|
-
data: swapData,
|
|
159
|
-
},
|
|
160
|
-
{
|
|
161
|
-
to: swapTokenOut,
|
|
162
|
-
data: encodeFunctionData({
|
|
163
|
-
abi: Abis.tip20,
|
|
164
|
-
functionName: 'transfer',
|
|
165
|
-
args: [bogus, 90n],
|
|
166
|
-
}),
|
|
167
|
-
},
|
|
168
|
-
{
|
|
169
|
-
to: swapTokenOut,
|
|
170
|
-
data: encodeFunctionData({
|
|
171
|
-
abi: Abis.tip20,
|
|
172
|
-
functionName: 'transferWithMemo',
|
|
173
|
-
args: [
|
|
174
|
-
'0x0000000000000000000000000000000000000002',
|
|
175
|
-
10n,
|
|
176
|
-
'0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef',
|
|
177
|
-
],
|
|
178
|
-
}),
|
|
179
|
-
},
|
|
180
|
-
],
|
|
181
|
-
details,
|
|
182
|
-
{
|
|
183
|
-
currency: swapTokenOut,
|
|
184
|
-
expectedTransfers: [
|
|
185
|
-
{ amount: '90', recipient: bogus },
|
|
186
|
-
{
|
|
187
|
-
amount: '10',
|
|
188
|
-
memo: '0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef',
|
|
189
|
-
recipient: '0x0000000000000000000000000000000000000002',
|
|
190
|
-
},
|
|
191
|
-
],
|
|
192
|
-
},
|
|
193
|
-
),
|
|
194
|
-
).not.toThrow()
|
|
195
|
-
})
|
|
196
|
-
|
|
197
|
-
test('error: rejects extra transfers when expected payments are supplied', () => {
|
|
198
|
-
expect(() =>
|
|
199
|
-
validateCalls(
|
|
200
|
-
[
|
|
201
|
-
{
|
|
202
|
-
to: swapTokenOut,
|
|
203
|
-
data: encodeFunctionData({
|
|
204
|
-
abi: Abis.tip20,
|
|
205
|
-
functionName: 'transfer',
|
|
206
|
-
args: [bogus, 100n],
|
|
207
|
-
}),
|
|
208
|
-
},
|
|
209
|
-
{
|
|
210
|
-
to: swapTokenOut,
|
|
211
|
-
data: encodeFunctionData({
|
|
212
|
-
abi: Abis.tip20,
|
|
213
|
-
functionName: 'transfer',
|
|
214
|
-
args: ['0x0000000000000000000000000000000000000002', 1n],
|
|
215
|
-
}),
|
|
216
|
-
},
|
|
217
|
-
],
|
|
218
|
-
details,
|
|
219
|
-
{
|
|
220
|
-
currency: swapTokenOut,
|
|
221
|
-
expectedTransfers: [{ amount: '100', recipient: bogus }],
|
|
222
|
-
},
|
|
223
|
-
),
|
|
224
|
-
).toThrow('disallowed call pattern')
|
|
225
|
-
})
|
|
226
|
-
|
|
227
|
-
test('error: rejects expected transfers to the wrong token', () => {
|
|
228
|
-
expect(() =>
|
|
229
|
-
validateCalls(
|
|
230
|
-
[
|
|
231
|
-
{
|
|
232
|
-
to: swapTokenIn,
|
|
233
|
-
data: encodeFunctionData({
|
|
234
|
-
abi: Abis.tip20,
|
|
235
|
-
functionName: 'transfer',
|
|
236
|
-
args: [bogus, 100n],
|
|
237
|
-
}),
|
|
238
|
-
},
|
|
239
|
-
],
|
|
240
|
-
details,
|
|
241
|
-
{
|
|
242
|
-
currency: swapTokenOut,
|
|
243
|
-
expectedTransfers: [{ amount: '100', recipient: bogus }],
|
|
244
|
-
},
|
|
245
|
-
),
|
|
246
|
-
).toThrow('payment transfer does not match challenge')
|
|
247
|
-
})
|
|
248
|
-
|
|
249
|
-
test('error: rejects swaps whose output token does not fund the payment', () => {
|
|
250
|
-
expect(() =>
|
|
251
|
-
validateCalls(
|
|
252
|
-
[
|
|
253
|
-
{
|
|
254
|
-
to: swapTokenIn,
|
|
255
|
-
data: encodeFunctionData({
|
|
256
|
-
abi: Abis.tip20,
|
|
257
|
-
functionName: 'approve',
|
|
258
|
-
args: [Addresses.stablecoinDex, 100n],
|
|
259
|
-
}),
|
|
260
|
-
},
|
|
261
|
-
{
|
|
262
|
-
to: Addresses.stablecoinDex,
|
|
263
|
-
data: swapData,
|
|
264
|
-
},
|
|
265
|
-
{
|
|
266
|
-
to: bogus,
|
|
267
|
-
data: encodeFunctionData({
|
|
268
|
-
abi: Abis.tip20,
|
|
269
|
-
functionName: 'transfer',
|
|
270
|
-
args: [bogus, 100n],
|
|
271
|
-
}),
|
|
272
|
-
},
|
|
273
|
-
],
|
|
274
|
-
details,
|
|
275
|
-
{
|
|
276
|
-
currency: bogus,
|
|
277
|
-
expectedTransfers: [{ amount: '100', recipient: bogus }],
|
|
278
|
-
},
|
|
279
|
-
),
|
|
280
|
-
).toThrow('swap tokenOut does not match payment currency')
|
|
281
|
-
})
|
|
282
|
-
|
|
283
|
-
test('error: rejects empty calls', () => {
|
|
284
|
-
expect(() => validateCalls([], details)).toThrow(FeePayerValidationError)
|
|
285
|
-
})
|
|
286
|
-
|
|
287
|
-
test('error: rejects unknown selector', () => {
|
|
288
|
-
expect(() => validateCalls([{ data: '0xdeadbeef' as `0x${string}` }], details)).toThrow(
|
|
289
|
-
'disallowed call pattern',
|
|
290
|
-
)
|
|
291
|
-
})
|
|
292
|
-
|
|
293
|
-
test('error: rejects more than 11 transfers', () => {
|
|
294
|
-
expect(() =>
|
|
295
|
-
validateCalls(
|
|
296
|
-
Array.from({ length: 12 }, (_, index) => ({
|
|
297
|
-
data: encodeFunctionData({
|
|
298
|
-
abi: Abis.tip20,
|
|
299
|
-
functionName: 'transfer',
|
|
300
|
-
args: [`0x${(index + 1).toString(16).padStart(40, '0')}`, 100n],
|
|
301
|
-
}),
|
|
302
|
-
})),
|
|
303
|
-
details,
|
|
304
|
-
),
|
|
305
|
-
).toThrow('disallowed call pattern')
|
|
306
|
-
})
|
|
307
|
-
|
|
308
|
-
test('error: rejects wrong order (transfer before approve + buy)', () => {
|
|
309
|
-
expect(() =>
|
|
310
|
-
validateCalls(
|
|
311
|
-
[
|
|
312
|
-
{
|
|
313
|
-
data: encodeFunctionData({
|
|
314
|
-
abi: Abis.tip20,
|
|
315
|
-
functionName: 'transfer',
|
|
316
|
-
args: [bogus, 100n],
|
|
317
|
-
}),
|
|
318
|
-
},
|
|
319
|
-
{
|
|
320
|
-
to: swapTokenIn,
|
|
321
|
-
data: encodeFunctionData({
|
|
322
|
-
abi: Abis.tip20,
|
|
323
|
-
functionName: 'approve',
|
|
324
|
-
args: [Addresses.stablecoinDex, 100n],
|
|
325
|
-
}),
|
|
326
|
-
},
|
|
327
|
-
{
|
|
328
|
-
to: Addresses.stablecoinDex,
|
|
329
|
-
data: swapData,
|
|
330
|
-
},
|
|
331
|
-
],
|
|
332
|
-
details,
|
|
333
|
-
),
|
|
334
|
-
).toThrow('disallowed call pattern')
|
|
335
|
-
})
|
|
336
|
-
|
|
337
|
-
test('error: rejects approve with non-DEX spender', () => {
|
|
338
|
-
expect(() =>
|
|
339
|
-
validateCalls(
|
|
340
|
-
[
|
|
341
|
-
{
|
|
342
|
-
to: swapTokenIn,
|
|
343
|
-
data: encodeFunctionData({
|
|
344
|
-
abi: Abis.tip20,
|
|
345
|
-
functionName: 'approve',
|
|
346
|
-
args: [bogus, 100n],
|
|
347
|
-
}),
|
|
348
|
-
},
|
|
349
|
-
{
|
|
350
|
-
to: Addresses.stablecoinDex,
|
|
351
|
-
data: swapData,
|
|
352
|
-
},
|
|
353
|
-
{
|
|
354
|
-
data: encodeFunctionData({
|
|
355
|
-
abi: Abis.tip20,
|
|
356
|
-
functionName: 'transfer',
|
|
357
|
-
args: [bogus, 100n],
|
|
358
|
-
}),
|
|
359
|
-
},
|
|
360
|
-
],
|
|
361
|
-
details,
|
|
362
|
-
),
|
|
363
|
-
).toThrow('approve spender is not the DEX')
|
|
364
|
-
})
|
|
365
|
-
|
|
366
|
-
test('behavior: rejects approve targeting a non-token contract', () => {
|
|
367
|
-
expect(() =>
|
|
368
|
-
validateCalls(
|
|
369
|
-
[
|
|
370
|
-
{
|
|
371
|
-
to: bogus,
|
|
372
|
-
data: encodeFunctionData({
|
|
373
|
-
abi: Abis.tip20,
|
|
374
|
-
functionName: 'approve',
|
|
375
|
-
args: [Addresses.stablecoinDex, 100n],
|
|
376
|
-
}),
|
|
377
|
-
},
|
|
378
|
-
{
|
|
379
|
-
to: Addresses.stablecoinDex,
|
|
380
|
-
data: swapData,
|
|
381
|
-
},
|
|
382
|
-
{
|
|
383
|
-
data: encodeFunctionData({
|
|
384
|
-
abi: Abis.tip20,
|
|
385
|
-
functionName: 'transfer',
|
|
386
|
-
args: [bogus, 100n],
|
|
387
|
-
}),
|
|
388
|
-
},
|
|
389
|
-
],
|
|
390
|
-
details,
|
|
391
|
-
),
|
|
392
|
-
).toThrow(FeePayerValidationError)
|
|
393
|
-
})
|
|
394
|
-
|
|
395
|
-
test('error: rejects buy targeting non-DEX address', () => {
|
|
396
|
-
expect(() =>
|
|
397
|
-
validateCalls(
|
|
398
|
-
[
|
|
399
|
-
{
|
|
400
|
-
to: swapTokenIn,
|
|
401
|
-
data: encodeFunctionData({
|
|
402
|
-
abi: Abis.tip20,
|
|
403
|
-
functionName: 'approve',
|
|
404
|
-
args: [Addresses.stablecoinDex, 100n],
|
|
405
|
-
}),
|
|
406
|
-
},
|
|
407
|
-
{ to: bogus, data: swapData },
|
|
408
|
-
{
|
|
409
|
-
data: encodeFunctionData({
|
|
410
|
-
abi: Abis.tip20,
|
|
411
|
-
functionName: 'transfer',
|
|
412
|
-
args: [bogus, 100n],
|
|
413
|
-
}),
|
|
414
|
-
},
|
|
415
|
-
],
|
|
416
|
-
details,
|
|
417
|
-
),
|
|
418
|
-
).toThrow('buy target is not the DEX')
|
|
419
|
-
})
|
|
420
|
-
|
|
421
|
-
test('error: rejects approve + buy without transfer', () => {
|
|
422
|
-
expect(() =>
|
|
423
|
-
validateCalls(
|
|
424
|
-
[
|
|
425
|
-
{
|
|
426
|
-
to: swapTokenIn,
|
|
427
|
-
data: encodeFunctionData({
|
|
428
|
-
abi: Abis.tip20,
|
|
429
|
-
functionName: 'approve',
|
|
430
|
-
args: [Addresses.stablecoinDex, 100n],
|
|
431
|
-
}),
|
|
432
|
-
},
|
|
433
|
-
{
|
|
434
|
-
to: Addresses.stablecoinDex,
|
|
435
|
-
data: swapData,
|
|
436
|
-
},
|
|
437
|
-
],
|
|
438
|
-
details,
|
|
439
|
-
),
|
|
440
|
-
).toThrow('disallowed call pattern')
|
|
441
|
-
})
|
|
442
|
-
})
|
|
443
|
-
|
|
444
|
-
describe('fee token allowlist', () => {
|
|
445
|
-
test('includes pathUSD and the chain default currency', () => {
|
|
446
|
-
expect(defaultAllowedFeeTokens(defaults.chainId.mainnet)).toEqual([
|
|
447
|
-
defaults.tokens.pathUsd,
|
|
448
|
-
defaults.tokens.usdc,
|
|
449
|
-
])
|
|
450
|
-
})
|
|
451
|
-
|
|
452
|
-
test('dedupes when pathUSD is the chain default currency', () => {
|
|
453
|
-
expect(defaultAllowedFeeTokens(defaults.chainId.testnet)).toEqual([defaults.tokens.pathUsd])
|
|
454
|
-
})
|
|
455
|
-
|
|
456
|
-
test('accepts allowlisted fee tokens', () => {
|
|
457
|
-
expect(() =>
|
|
458
|
-
assertAllowedFeeToken(
|
|
459
|
-
{ feeToken: defaults.tokens.usdc },
|
|
460
|
-
defaultAllowedFeeTokens(defaults.chainId.mainnet),
|
|
461
|
-
),
|
|
462
|
-
).not.toThrow()
|
|
463
|
-
})
|
|
464
|
-
|
|
465
|
-
test('error: rejects non-string fee tokens', () => {
|
|
466
|
-
expect(() =>
|
|
467
|
-
assertAllowedFeeToken({ feeToken: 1n }, defaultAllowedFeeTokens(defaults.chainId.mainnet)),
|
|
468
|
-
).toThrow('feeToken is invalid')
|
|
469
|
-
})
|
|
470
|
-
|
|
471
|
-
test('error: rejects fee tokens outside the allowlist', () => {
|
|
472
|
-
expect(() =>
|
|
473
|
-
assertAllowedFeeToken(
|
|
474
|
-
{ feeToken: swapTokenIn },
|
|
475
|
-
defaultAllowedFeeTokens(defaults.chainId.mainnet),
|
|
476
|
-
),
|
|
477
|
-
).toThrow('feeToken is not allowed')
|
|
478
|
-
})
|
|
479
|
-
})
|
|
480
|
-
|
|
481
|
-
describe('fillHostedFeePayerTransaction', () => {
|
|
482
|
-
const hostedTransaction = {
|
|
483
|
-
accessList: [],
|
|
484
|
-
calls: [
|
|
485
|
-
{
|
|
486
|
-
data: encodeFunctionData({
|
|
487
|
-
abi: Abis.tip20,
|
|
488
|
-
functionName: 'transfer',
|
|
489
|
-
args: [bogus, 100n],
|
|
490
|
-
}),
|
|
491
|
-
to: bogus,
|
|
492
|
-
},
|
|
493
|
-
],
|
|
494
|
-
chainId: defaults.chainId.mainnet,
|
|
495
|
-
from: bogus,
|
|
496
|
-
gas: 150_000n,
|
|
497
|
-
maxFeePerGas: 1_000_000_000n,
|
|
498
|
-
maxPriorityFeePerGas: 0n,
|
|
499
|
-
nonce: 1n,
|
|
500
|
-
nonceKey: maxUint256,
|
|
501
|
-
signature: { r: 1n, s: 1n, yParity: 0 } as any,
|
|
502
|
-
validBefore: Math.floor(Date.now() / 1_000) + 300,
|
|
503
|
-
} as const
|
|
504
|
-
const hostedContext = {
|
|
505
|
-
chainId: defaults.chainId.mainnet,
|
|
506
|
-
details,
|
|
507
|
-
} as const
|
|
508
|
-
|
|
509
|
-
test('uses hosted fillTransaction and preserves sender-committed fields', async () => {
|
|
510
|
-
// Sign over the payload built from the actual RPC request body so this
|
|
511
|
-
// verifies recovery parity with the real request shape.
|
|
512
|
-
const sponsorPrivateKey =
|
|
513
|
-
'0x0000000000000000000000000000000000000000000000000000000000000042' as const
|
|
514
|
-
const sponsorAddress = Address.fromPublicKey(
|
|
515
|
-
Secp256k1.getPublicKey({ privateKey: sponsorPrivateKey }),
|
|
516
|
-
)
|
|
517
|
-
let realFeePayerSignature: ReturnType<typeof Secp256k1.sign> | undefined
|
|
518
|
-
|
|
519
|
-
const calls: { init?: RequestInit | undefined; input: RequestInfo | URL }[] = []
|
|
520
|
-
const fetchMock = vi.fn(async (input: RequestInfo | URL, init?: RequestInit) => {
|
|
521
|
-
calls.push({ init, input })
|
|
522
|
-
const rpc = JSON.parse(init!.body as string).params[0]
|
|
523
|
-
const quantity = (value: unknown) =>
|
|
524
|
-
value === undefined ? undefined : BigInt(value as string)
|
|
525
|
-
realFeePayerSignature = Secp256k1.sign({
|
|
526
|
-
payload: TxEnvelopeTempo.getFeePayerSignPayload(
|
|
527
|
-
TxEnvelopeTempo.from({
|
|
528
|
-
accessList: rpc.accessList,
|
|
529
|
-
calls: rpc.calls.map(({ value, ...call }: any) => ({
|
|
530
|
-
...call,
|
|
531
|
-
...(value && value !== '0x' ? { value: BigInt(value) } : {}),
|
|
532
|
-
})),
|
|
533
|
-
chainId: hostedTransaction.chainId,
|
|
534
|
-
feeToken: defaults.tokens.pathUsd,
|
|
535
|
-
from: rpc.from,
|
|
536
|
-
...(quantity(rpc.gas) !== undefined ? { gas: quantity(rpc.gas) } : {}),
|
|
537
|
-
...(rpc.keyAuthorization !== undefined
|
|
538
|
-
? { keyAuthorization: rpc.keyAuthorization }
|
|
539
|
-
: {}),
|
|
540
|
-
...(quantity(rpc.maxFeePerGas) !== undefined
|
|
541
|
-
? { maxFeePerGas: quantity(rpc.maxFeePerGas) }
|
|
542
|
-
: {}),
|
|
543
|
-
...(quantity(rpc.maxPriorityFeePerGas) !== undefined
|
|
544
|
-
? { maxPriorityFeePerGas: quantity(rpc.maxPriorityFeePerGas) }
|
|
545
|
-
: {}),
|
|
546
|
-
...(quantity(rpc.nonce) !== undefined ? { nonce: quantity(rpc.nonce) } : {}),
|
|
547
|
-
...(quantity(rpc.nonceKey) !== undefined ? { nonceKey: quantity(rpc.nonceKey) } : {}),
|
|
548
|
-
type: 'tempo',
|
|
549
|
-
...(rpc.validAfter !== undefined ? { validAfter: Number(BigInt(rpc.validAfter)) } : {}),
|
|
550
|
-
...(rpc.validBefore !== undefined
|
|
551
|
-
? { validBefore: Number(BigInt(rpc.validBefore)) }
|
|
552
|
-
: {}),
|
|
553
|
-
} as any) as any,
|
|
554
|
-
{ sender: rpc.from },
|
|
555
|
-
),
|
|
556
|
-
privateKey: sponsorPrivateKey,
|
|
557
|
-
})
|
|
558
|
-
return new Response(
|
|
559
|
-
JSON.stringify(
|
|
560
|
-
{
|
|
561
|
-
result: {
|
|
562
|
-
tx: {
|
|
563
|
-
feePayerSignature: realFeePayerSignature,
|
|
564
|
-
feeToken: defaults.tokens.pathUsd,
|
|
565
|
-
gas: '0x1',
|
|
566
|
-
maxFeePerGas: '0x2',
|
|
567
|
-
},
|
|
568
|
-
},
|
|
569
|
-
},
|
|
570
|
-
(key, value) => {
|
|
571
|
-
if (key === 'yParity') return toHex(value)
|
|
572
|
-
return typeof value === 'bigint' ? toHex(value) : value
|
|
573
|
-
},
|
|
574
|
-
),
|
|
575
|
-
)
|
|
576
|
-
})
|
|
577
|
-
vi.stubGlobal('fetch', fetchMock)
|
|
578
|
-
|
|
579
|
-
const result = await fillHostedFeePayerTransaction({
|
|
580
|
-
allowedFeeTokens: defaultAllowedFeeTokens(defaults.chainId.mainnet),
|
|
581
|
-
...hostedContext,
|
|
582
|
-
transaction: hostedTransaction as any,
|
|
583
|
-
url: 'https://sponsor.example/tp_key',
|
|
584
|
-
})
|
|
585
|
-
|
|
586
|
-
expect(result.feeToken).toBe(defaults.tokens.pathUsd)
|
|
587
|
-
expect(result.feePayer.toLowerCase()).toBe(sponsorAddress.toLowerCase())
|
|
588
|
-
const serialized = result.serializedTransaction
|
|
589
|
-
|
|
590
|
-
expect(fetchMock).toHaveBeenCalledOnce()
|
|
591
|
-
expect(calls[0]!.input).toBe('https://sponsor.example/tp_key')
|
|
592
|
-
const body = JSON.parse(calls[0]!.init!.body as string)
|
|
593
|
-
expect(body).toMatchObject({
|
|
594
|
-
jsonrpc: '2.0',
|
|
595
|
-
method: 'eth_fillTransaction',
|
|
596
|
-
})
|
|
597
|
-
expect(body.params[0]).toMatchObject({
|
|
598
|
-
calls: hostedTransaction.calls.map((call) => ({
|
|
599
|
-
data: call.data,
|
|
600
|
-
to: call.to,
|
|
601
|
-
value: '0x',
|
|
602
|
-
})),
|
|
603
|
-
feePayer: true,
|
|
604
|
-
from: hostedTransaction.from,
|
|
605
|
-
gas: toHex(hostedTransaction.gas),
|
|
606
|
-
maxFeePerGas: toHex(hostedTransaction.maxFeePerGas),
|
|
607
|
-
maxPriorityFeePerGas: toHex(hostedTransaction.maxPriorityFeePerGas),
|
|
608
|
-
nonce: toHex(hostedTransaction.nonce),
|
|
609
|
-
nonceKey: toHex(hostedTransaction.nonceKey),
|
|
610
|
-
type: '0x76',
|
|
611
|
-
validBefore: toHex(hostedTransaction.validBefore),
|
|
612
|
-
})
|
|
613
|
-
|
|
614
|
-
const transaction: Transaction.TransactionSerializableTempo = Transaction.deserialize(
|
|
615
|
-
serialized as Transaction.TransactionSerializedTempo,
|
|
616
|
-
)
|
|
617
|
-
expect(transaction.gas).toBe(hostedTransaction.gas)
|
|
618
|
-
expect(transaction.maxFeePerGas).toBe(hostedTransaction.maxFeePerGas)
|
|
619
|
-
expect(transaction.calls).toEqual(hostedTransaction.calls)
|
|
620
|
-
expect(transaction.feeToken).toBe(defaults.tokens.pathUsd)
|
|
621
|
-
expect(BigInt(transaction.feePayerSignature!.r)).toBe(realFeePayerSignature!.r)
|
|
622
|
-
expect(BigInt(transaction.feePayerSignature!.s)).toBe(realFeePayerSignature!.s)
|
|
623
|
-
})
|
|
624
|
-
|
|
625
|
-
test('error: requires hosted fee payer to return a feeToken', async () => {
|
|
626
|
-
vi.stubGlobal(
|
|
627
|
-
'fetch',
|
|
628
|
-
vi.fn(async () => new Response(JSON.stringify({ result: { tx: { feePayerSignature } } }))),
|
|
629
|
-
)
|
|
630
|
-
|
|
631
|
-
await expect(
|
|
632
|
-
fillHostedFeePayerTransaction({
|
|
633
|
-
allowedFeeTokens: defaultAllowedFeeTokens(defaults.chainId.mainnet),
|
|
634
|
-
...hostedContext,
|
|
635
|
-
transaction: hostedTransaction as any,
|
|
636
|
-
url: 'https://sponsor.example/tp_key',
|
|
637
|
-
}),
|
|
638
|
-
).rejects.toThrow('did not return a feeToken')
|
|
639
|
-
})
|
|
640
|
-
|
|
641
|
-
test('error: rejects hosted feeToken outside the allowlist', async () => {
|
|
642
|
-
vi.stubGlobal(
|
|
643
|
-
'fetch',
|
|
644
|
-
vi.fn(
|
|
645
|
-
async () =>
|
|
646
|
-
new Response(
|
|
647
|
-
JSON.stringify({
|
|
648
|
-
result: { tx: { feePayerSignature, feeToken: swapTokenIn } },
|
|
649
|
-
}),
|
|
650
|
-
),
|
|
651
|
-
),
|
|
652
|
-
)
|
|
653
|
-
|
|
654
|
-
await expect(
|
|
655
|
-
fillHostedFeePayerTransaction({
|
|
656
|
-
allowedFeeTokens: defaultAllowedFeeTokens(defaults.chainId.mainnet),
|
|
657
|
-
...hostedContext,
|
|
658
|
-
transaction: hostedTransaction as any,
|
|
659
|
-
url: 'https://sponsor.example/tp_key',
|
|
660
|
-
}),
|
|
661
|
-
).rejects.toThrow('feeToken is not allowed')
|
|
662
|
-
})
|
|
663
|
-
|
|
664
|
-
test('error: surfaces hosted fee payer errors', async () => {
|
|
665
|
-
vi.stubGlobal(
|
|
666
|
-
'fetch',
|
|
667
|
-
vi.fn(
|
|
668
|
-
async () =>
|
|
669
|
-
new Response(JSON.stringify({ error: { message: 'Invalid or revoked API key' } }), {
|
|
670
|
-
status: 401,
|
|
671
|
-
}),
|
|
672
|
-
),
|
|
673
|
-
)
|
|
674
|
-
|
|
675
|
-
await expect(
|
|
676
|
-
fillHostedFeePayerTransaction({
|
|
677
|
-
allowedFeeTokens: defaultAllowedFeeTokens(defaults.chainId.mainnet),
|
|
678
|
-
...hostedContext,
|
|
679
|
-
transaction: hostedTransaction as any,
|
|
680
|
-
url: 'https://sponsor.example/tp_key',
|
|
681
|
-
}),
|
|
682
|
-
).rejects.toThrow('Invalid or revoked API key')
|
|
683
|
-
})
|
|
684
|
-
|
|
685
|
-
test('error: enforces sponsor policy before requesting hosted fill', async () => {
|
|
686
|
-
const fetchMock = vi.fn()
|
|
687
|
-
vi.stubGlobal('fetch', fetchMock)
|
|
688
|
-
|
|
689
|
-
await expect(
|
|
690
|
-
fillHostedFeePayerTransaction({
|
|
691
|
-
allowedFeeTokens: defaultAllowedFeeTokens(defaults.chainId.mainnet),
|
|
692
|
-
...hostedContext,
|
|
693
|
-
policy: { maxGas: hostedTransaction.gas - 1n },
|
|
694
|
-
transaction: hostedTransaction as any,
|
|
695
|
-
url: 'https://sponsor.example/tp_key',
|
|
696
|
-
}),
|
|
697
|
-
).rejects.toThrow('gas exceeds sponsor policy')
|
|
698
|
-
expect(fetchMock).not.toHaveBeenCalled()
|
|
699
|
-
})
|
|
700
|
-
|
|
701
|
-
test('error: rejects non-empty access lists before requesting hosted fill', async () => {
|
|
702
|
-
const fetchMock = vi.fn()
|
|
703
|
-
vi.stubGlobal('fetch', fetchMock)
|
|
704
|
-
|
|
705
|
-
await expect(
|
|
706
|
-
fillHostedFeePayerTransaction({
|
|
707
|
-
allowedFeeTokens: defaultAllowedFeeTokens(defaults.chainId.mainnet),
|
|
708
|
-
...hostedContext,
|
|
709
|
-
transaction: {
|
|
710
|
-
...hostedTransaction,
|
|
711
|
-
accessList: [{ address: bogus, storageKeys: [] }],
|
|
712
|
-
} as any,
|
|
713
|
-
url: 'https://sponsor.example/tp_key',
|
|
714
|
-
}),
|
|
715
|
-
).rejects.toThrow('accessList is not allowed')
|
|
716
|
-
expect(fetchMock).not.toHaveBeenCalled()
|
|
717
|
-
})
|
|
718
|
-
|
|
719
|
-
test('error: rejects padded calldata before requesting hosted fill', async () => {
|
|
720
|
-
const fetchMock = vi.fn()
|
|
721
|
-
vi.stubGlobal('fetch', fetchMock)
|
|
722
|
-
|
|
723
|
-
await expect(
|
|
724
|
-
fillHostedFeePayerTransaction({
|
|
725
|
-
allowedFeeTokens: defaultAllowedFeeTokens(defaults.chainId.mainnet),
|
|
726
|
-
...hostedContext,
|
|
727
|
-
transaction: {
|
|
728
|
-
...hostedTransaction,
|
|
729
|
-
calls: [
|
|
730
|
-
{
|
|
731
|
-
...hostedTransaction.calls[0],
|
|
732
|
-
data: `${hostedTransaction.calls[0]!.data}01`,
|
|
733
|
-
},
|
|
734
|
-
],
|
|
735
|
-
} as any,
|
|
736
|
-
url: 'https://sponsor.example/tp_key',
|
|
737
|
-
}),
|
|
738
|
-
).rejects.toThrow('calldata is not canonical')
|
|
739
|
-
expect(fetchMock).not.toHaveBeenCalled()
|
|
740
|
-
})
|
|
741
|
-
})
|
|
742
|
-
|
|
743
|
-
describe('simulationTransaction', () => {
|
|
744
|
-
test('strips signed fee-payer fields for sponsored preflight simulation', () => {
|
|
745
|
-
const transaction = {
|
|
746
|
-
calls: [{ to: bogus }],
|
|
747
|
-
feePayerSignature,
|
|
748
|
-
from: bogus,
|
|
749
|
-
}
|
|
750
|
-
|
|
751
|
-
expect(simulationTransaction(transaction as any, { feePayer: true })).toEqual({
|
|
752
|
-
account: bogus,
|
|
753
|
-
calls: transaction.calls,
|
|
754
|
-
})
|
|
755
|
-
})
|
|
756
|
-
|
|
757
|
-
test('preserves non-sponsored transaction fields except feePayerSignature', () => {
|
|
758
|
-
const transaction = {
|
|
759
|
-
calls: [{ to: bogus }],
|
|
760
|
-
feePayerSignature,
|
|
761
|
-
from: bogus,
|
|
762
|
-
gas: 1n,
|
|
763
|
-
}
|
|
764
|
-
|
|
765
|
-
expect(simulationTransaction(transaction as any, { feePayer: false })).toEqual({
|
|
766
|
-
account: bogus,
|
|
767
|
-
calls: transaction.calls,
|
|
768
|
-
from: bogus,
|
|
769
|
-
gas: 1n,
|
|
770
|
-
feePayerSignature: undefined,
|
|
771
|
-
})
|
|
772
|
-
})
|
|
773
|
-
|
|
774
|
-
test('builds the final sponsored envelope without either signature', () => {
|
|
775
|
-
const transaction = {
|
|
776
|
-
calls: [{ to: bogus }],
|
|
777
|
-
feePayerSignature,
|
|
778
|
-
feeToken: swapTokenIn,
|
|
779
|
-
from: bogus,
|
|
780
|
-
signature: { r: 1n, s: 2n, yParity: 0 },
|
|
781
|
-
}
|
|
782
|
-
|
|
783
|
-
expect(
|
|
784
|
-
sponsoredSimulationTransaction(transaction as any, {
|
|
785
|
-
feePayer: swapTokenOut,
|
|
786
|
-
feeToken: bogus,
|
|
787
|
-
}),
|
|
788
|
-
).toEqual({
|
|
789
|
-
...transaction,
|
|
790
|
-
account: bogus,
|
|
791
|
-
calls: transaction.calls,
|
|
792
|
-
feePayer: swapTokenOut,
|
|
793
|
-
feePayerSignature: undefined,
|
|
794
|
-
feeToken: bogus,
|
|
795
|
-
signature: undefined,
|
|
796
|
-
})
|
|
797
|
-
})
|
|
798
|
-
})
|
|
799
|
-
|
|
800
|
-
describe('preflightSponsorship', () => {
|
|
801
|
-
const transaction = {
|
|
802
|
-
calls: [{ to: bogus }],
|
|
803
|
-
feeToken: swapTokenIn,
|
|
804
|
-
from: bogus,
|
|
805
|
-
}
|
|
806
|
-
|
|
807
|
-
test('simulates the sender before completion and the completed envelope after', async () => {
|
|
808
|
-
const simulations: Record<string, unknown>[] = []
|
|
809
|
-
let completions = 0
|
|
810
|
-
|
|
811
|
-
const result = await preflightSponsorship({
|
|
812
|
-
transaction: transaction as any,
|
|
813
|
-
async simulate(request) {
|
|
814
|
-
simulations.push(request)
|
|
815
|
-
},
|
|
816
|
-
async complete() {
|
|
817
|
-
completions += 1
|
|
818
|
-
return { feePayer: swapTokenOut, transaction: transaction as any }
|
|
819
|
-
},
|
|
820
|
-
})
|
|
821
|
-
|
|
822
|
-
expect(completions).toBe(1)
|
|
823
|
-
expect(result.feePayer).toBe(swapTokenOut)
|
|
824
|
-
expect(simulations).toEqual([
|
|
825
|
-
{ account: bogus, calls: transaction.calls },
|
|
826
|
-
{
|
|
827
|
-
...transaction,
|
|
828
|
-
account: bogus,
|
|
829
|
-
calls: transaction.calls,
|
|
830
|
-
feePayer: swapTokenOut,
|
|
831
|
-
feePayerSignature: undefined,
|
|
832
|
-
signature: undefined,
|
|
833
|
-
},
|
|
834
|
-
])
|
|
835
|
-
})
|
|
836
|
-
|
|
837
|
-
test.each([
|
|
838
|
-
{ completeCalls: 0, failingSimulation: 1, simulationCalls: 1 },
|
|
839
|
-
{ completeCalls: 1, failingSimulation: 2, simulationCalls: 2 },
|
|
840
|
-
])(
|
|
841
|
-
'stops at simulation $failingSimulation',
|
|
842
|
-
async ({ completeCalls, failingSimulation, simulationCalls }) => {
|
|
843
|
-
let completions = 0
|
|
844
|
-
let simulations = 0
|
|
845
|
-
|
|
846
|
-
await expect(
|
|
847
|
-
preflightSponsorship({
|
|
848
|
-
transaction: transaction as any,
|
|
849
|
-
async simulate() {
|
|
850
|
-
simulations += 1
|
|
851
|
-
if (simulations === failingSimulation) throw new Error('simulation failed')
|
|
852
|
-
},
|
|
853
|
-
async complete() {
|
|
854
|
-
completions += 1
|
|
855
|
-
return { feePayer: swapTokenOut, transaction: transaction as any }
|
|
856
|
-
},
|
|
857
|
-
}),
|
|
858
|
-
).rejects.toThrow('simulation failed')
|
|
859
|
-
|
|
860
|
-
expect(completions).toBe(completeCalls)
|
|
861
|
-
expect(simulations).toBe(simulationCalls)
|
|
862
|
-
},
|
|
863
|
-
)
|
|
864
|
-
})
|
|
865
|
-
|
|
866
|
-
describe('prepareSponsoredTransaction', () => {
|
|
867
|
-
const baseTransaction = {
|
|
868
|
-
accessList: [],
|
|
869
|
-
calls: [
|
|
870
|
-
{
|
|
871
|
-
data: encodeFunctionData({
|
|
872
|
-
abi: Abis.tip20,
|
|
873
|
-
functionName: 'transfer',
|
|
874
|
-
args: [bogus, 100n],
|
|
875
|
-
}),
|
|
876
|
-
to: bogus,
|
|
877
|
-
},
|
|
878
|
-
],
|
|
879
|
-
chainId: 42431,
|
|
880
|
-
feeToken: bogus,
|
|
881
|
-
from: bogus,
|
|
882
|
-
gas: 150_000n,
|
|
883
|
-
maxFeePerGas: 1_000_000_000n,
|
|
884
|
-
maxPriorityFeePerGas: 1_000_000_000n,
|
|
885
|
-
nonce: 1n,
|
|
886
|
-
nonceKey: 'expiring',
|
|
887
|
-
signature: { r: 1n, s: 1n, yParity: 0 } as any,
|
|
888
|
-
validBefore: Math.floor(Date.now() / 1_000) + 300,
|
|
889
|
-
} as const
|
|
890
|
-
|
|
891
|
-
test('accepts bounded sponsored transaction fields', () => {
|
|
892
|
-
expect(() =>
|
|
893
|
-
prepareSponsoredTransaction({
|
|
894
|
-
account: sponsor,
|
|
895
|
-
chainId: 42431,
|
|
896
|
-
details,
|
|
897
|
-
allowedFeeTokens: [bogus],
|
|
898
|
-
transaction: baseTransaction as any,
|
|
899
|
-
}),
|
|
900
|
-
).not.toThrow()
|
|
901
|
-
})
|
|
902
|
-
|
|
903
|
-
test('accepts serialized expiring nonce key', () => {
|
|
904
|
-
expect(() =>
|
|
905
|
-
prepareSponsoredTransaction({
|
|
906
|
-
account: sponsor,
|
|
907
|
-
chainId: 42431,
|
|
908
|
-
details,
|
|
909
|
-
allowedFeeTokens: [bogus],
|
|
910
|
-
transaction: {
|
|
911
|
-
...baseTransaction,
|
|
912
|
-
nonceKey: maxUint256,
|
|
913
|
-
} as any,
|
|
914
|
-
}),
|
|
915
|
-
).not.toThrow()
|
|
916
|
-
})
|
|
917
|
-
|
|
918
|
-
test('error: rejects non-expiring nonce keys', () => {
|
|
919
|
-
expect(() =>
|
|
920
|
-
prepareSponsoredTransaction({
|
|
921
|
-
account: sponsor,
|
|
922
|
-
chainId: 42431,
|
|
923
|
-
details,
|
|
924
|
-
allowedFeeTokens: [bogus],
|
|
925
|
-
transaction: {
|
|
926
|
-
...baseTransaction,
|
|
927
|
-
nonceKey: 1n,
|
|
928
|
-
} as any,
|
|
929
|
-
}),
|
|
930
|
-
).toThrow('must use an expiring nonce')
|
|
931
|
-
})
|
|
932
|
-
|
|
933
|
-
test('accepts higher Moderato priority fees by default', () => {
|
|
934
|
-
expect(() =>
|
|
935
|
-
prepareSponsoredTransaction({
|
|
936
|
-
account: sponsor,
|
|
937
|
-
chainId: 42431,
|
|
938
|
-
details,
|
|
939
|
-
allowedFeeTokens: [bogus],
|
|
940
|
-
transaction: {
|
|
941
|
-
...baseTransaction,
|
|
942
|
-
gas: 626_497n,
|
|
943
|
-
maxFeePerGas: 24_000_000_000n,
|
|
944
|
-
maxPriorityFeePerGas: 24_000_000_000n,
|
|
945
|
-
} as any,
|
|
946
|
-
}),
|
|
947
|
-
).not.toThrow()
|
|
948
|
-
})
|
|
949
|
-
|
|
950
|
-
test('accepts fee-payer policy overrides', () => {
|
|
951
|
-
expect(() =>
|
|
952
|
-
prepareSponsoredTransaction({
|
|
953
|
-
account: sponsor,
|
|
954
|
-
chainId: 4217,
|
|
955
|
-
details,
|
|
956
|
-
allowedFeeTokens: [bogus],
|
|
957
|
-
policy: { maxPriorityFeePerGas: 50_000_000_000n },
|
|
958
|
-
transaction: {
|
|
959
|
-
...baseTransaction,
|
|
960
|
-
chainId: 4217,
|
|
961
|
-
gas: 626_497n,
|
|
962
|
-
maxFeePerGas: 24_000_000_000n,
|
|
963
|
-
maxPriorityFeePerGas: 24_000_000_000n,
|
|
964
|
-
} as any,
|
|
965
|
-
}),
|
|
966
|
-
).not.toThrow()
|
|
967
|
-
})
|
|
968
|
-
|
|
969
|
-
test('error: rejects excessive priority fee under a custom policy override', () => {
|
|
970
|
-
expect(() =>
|
|
971
|
-
prepareSponsoredTransaction({
|
|
972
|
-
account: sponsor,
|
|
973
|
-
chainId: 4217,
|
|
974
|
-
details,
|
|
975
|
-
allowedFeeTokens: [bogus],
|
|
976
|
-
policy: { maxPriorityFeePerGas: 20_000_000_000n },
|
|
977
|
-
transaction: {
|
|
978
|
-
...baseTransaction,
|
|
979
|
-
chainId: 4217,
|
|
980
|
-
gas: 626_497n,
|
|
981
|
-
maxFeePerGas: 24_000_000_000n,
|
|
982
|
-
maxPriorityFeePerGas: 24_000_000_000n,
|
|
983
|
-
} as any,
|
|
984
|
-
}),
|
|
985
|
-
).toThrow('maxPriorityFeePerGas exceeds sponsor policy')
|
|
986
|
-
})
|
|
987
|
-
|
|
988
|
-
test('ignores undefined policy override values', () => {
|
|
989
|
-
expect(() =>
|
|
990
|
-
prepareSponsoredTransaction({
|
|
991
|
-
account: sponsor,
|
|
992
|
-
chainId: 4217,
|
|
993
|
-
details,
|
|
994
|
-
allowedFeeTokens: [bogus],
|
|
995
|
-
policy: { maxPriorityFeePerGas: undefined } as any,
|
|
996
|
-
transaction: {
|
|
997
|
-
...baseTransaction,
|
|
998
|
-
chainId: 4217,
|
|
999
|
-
gas: 626_497n,
|
|
1000
|
-
maxFeePerGas: 24_000_000_000n,
|
|
1001
|
-
maxPriorityFeePerGas: 24_000_000_000n,
|
|
1002
|
-
} as any,
|
|
1003
|
-
}),
|
|
1004
|
-
).toThrow('maxPriorityFeePerGas exceeds sponsor policy')
|
|
1005
|
-
})
|
|
1006
|
-
|
|
1007
|
-
test('preserves keyAuthorization', () => {
|
|
1008
|
-
const keyAuthorization = {
|
|
1009
|
-
address: bogus,
|
|
1010
|
-
chainId: 42431,
|
|
1011
|
-
nonce: 1n,
|
|
1012
|
-
r: 1n,
|
|
1013
|
-
s: 2n,
|
|
1014
|
-
yParity: 0,
|
|
1015
|
-
}
|
|
1016
|
-
|
|
1017
|
-
const sponsored = prepareSponsoredTransaction({
|
|
1018
|
-
account: sponsor,
|
|
1019
|
-
chainId: 42431,
|
|
1020
|
-
details,
|
|
1021
|
-
allowedFeeTokens: [bogus],
|
|
1022
|
-
transaction: { ...baseTransaction, keyAuthorization } as any,
|
|
1023
|
-
}) as { keyAuthorization?: unknown }
|
|
1024
|
-
|
|
1025
|
-
expect(sponsored.keyAuthorization).toEqual(keyAuthorization)
|
|
1026
|
-
})
|
|
1027
|
-
|
|
1028
|
-
test('error: rejects unknown top-level fields from the sponsored transaction', () => {
|
|
1029
|
-
expect(() =>
|
|
1030
|
-
prepareSponsoredTransaction({
|
|
1031
|
-
account: sponsor,
|
|
1032
|
-
chainId: 42431,
|
|
1033
|
-
details,
|
|
1034
|
-
allowedFeeTokens: [bogus],
|
|
1035
|
-
transaction: { ...baseTransaction, unexpectedField: 'ignored' } as any,
|
|
1036
|
-
}),
|
|
1037
|
-
).toThrow('contains unsupported fields')
|
|
1038
|
-
})
|
|
1039
|
-
|
|
1040
|
-
test('error: rejects feePayerSignature on client-submitted transactions', () => {
|
|
1041
|
-
expect(() =>
|
|
1042
|
-
prepareSponsoredTransaction({
|
|
1043
|
-
account: sponsor,
|
|
1044
|
-
chainId: 42431,
|
|
1045
|
-
details,
|
|
1046
|
-
allowedFeeTokens: [bogus],
|
|
1047
|
-
transaction: {
|
|
1048
|
-
...baseTransaction,
|
|
1049
|
-
feePayerSignature: { r: 2n, s: 3n, yParity: 1 },
|
|
1050
|
-
} as any,
|
|
1051
|
-
}),
|
|
1052
|
-
).toThrow('contains rejected fields')
|
|
1053
|
-
})
|
|
1054
|
-
|
|
1055
|
-
test('error: rejects excessive maxFeePerGas', () => {
|
|
1056
|
-
expect(() =>
|
|
1057
|
-
prepareSponsoredTransaction({
|
|
1058
|
-
account: sponsor,
|
|
1059
|
-
chainId: 42431,
|
|
1060
|
-
details,
|
|
1061
|
-
allowedFeeTokens: [bogus],
|
|
1062
|
-
transaction: {
|
|
1063
|
-
...baseTransaction,
|
|
1064
|
-
maxFeePerGas: 200_000_000_000n,
|
|
1065
|
-
} as any,
|
|
1066
|
-
}),
|
|
1067
|
-
).toThrow('maxFeePerGas exceeds sponsor policy')
|
|
1068
|
-
})
|
|
1069
|
-
|
|
1070
|
-
test('error: rejects combined gas and fee budget outside policy', () => {
|
|
1071
|
-
expect(() =>
|
|
1072
|
-
prepareSponsoredTransaction({
|
|
1073
|
-
account: sponsor,
|
|
1074
|
-
chainId: 42431,
|
|
1075
|
-
details,
|
|
1076
|
-
allowedFeeTokens: [bogus],
|
|
1077
|
-
transaction: {
|
|
1078
|
-
...baseTransaction,
|
|
1079
|
-
gas: 1_500_000n,
|
|
1080
|
-
maxFeePerGas: 50_000_000_000n,
|
|
1081
|
-
} as any,
|
|
1082
|
-
}),
|
|
1083
|
-
).toThrow('total fee budget exceeds sponsor policy')
|
|
1084
|
-
})
|
|
1085
|
-
|
|
1086
|
-
test('error: rejects mismatched feeToken', () => {
|
|
1087
|
-
expect(() =>
|
|
1088
|
-
prepareSponsoredTransaction({
|
|
1089
|
-
account: sponsor,
|
|
1090
|
-
chainId: 42431,
|
|
1091
|
-
details,
|
|
1092
|
-
allowedFeeTokens: ['0x0000000000000000000000000000000000000002'],
|
|
1093
|
-
transaction: baseTransaction as any,
|
|
1094
|
-
}),
|
|
1095
|
-
).toThrow('feeToken is not allowed')
|
|
1096
|
-
})
|
|
1097
|
-
|
|
1098
|
-
test('error: rejects long-lived sponsored transactions', () => {
|
|
1099
|
-
expect(() =>
|
|
1100
|
-
prepareSponsoredTransaction({
|
|
1101
|
-
account: sponsor,
|
|
1102
|
-
chainId: 42431,
|
|
1103
|
-
details,
|
|
1104
|
-
allowedFeeTokens: [bogus],
|
|
1105
|
-
transaction: {
|
|
1106
|
-
...baseTransaction,
|
|
1107
|
-
validBefore: Math.floor(Date.now() / 1_000) + 3_600,
|
|
1108
|
-
} as any,
|
|
1109
|
-
}),
|
|
1110
|
-
).toThrow('validity window exceeds sponsor policy')
|
|
1111
|
-
})
|
|
1112
|
-
|
|
1113
|
-
test('error: rejects non-empty access lists', () => {
|
|
1114
|
-
expect(() =>
|
|
1115
|
-
prepareSponsoredTransaction({
|
|
1116
|
-
account: sponsor,
|
|
1117
|
-
chainId: 42431,
|
|
1118
|
-
details,
|
|
1119
|
-
allowedFeeTokens: [bogus],
|
|
1120
|
-
transaction: {
|
|
1121
|
-
...baseTransaction,
|
|
1122
|
-
accessList: [{ address: bogus, storageKeys: [] }],
|
|
1123
|
-
} as any,
|
|
1124
|
-
}),
|
|
1125
|
-
).toThrow('accessList is not allowed')
|
|
1126
|
-
})
|
|
1127
|
-
|
|
1128
|
-
test('error: rejects padded calldata', () => {
|
|
1129
|
-
expect(() =>
|
|
1130
|
-
prepareSponsoredTransaction({
|
|
1131
|
-
account: sponsor,
|
|
1132
|
-
chainId: 42431,
|
|
1133
|
-
details,
|
|
1134
|
-
allowedFeeTokens: [bogus],
|
|
1135
|
-
transaction: {
|
|
1136
|
-
...baseTransaction,
|
|
1137
|
-
calls: [
|
|
1138
|
-
{
|
|
1139
|
-
...baseTransaction.calls[0],
|
|
1140
|
-
data: `${baseTransaction.calls[0]!.data}01`,
|
|
1141
|
-
},
|
|
1142
|
-
],
|
|
1143
|
-
} as any,
|
|
1144
|
-
}),
|
|
1145
|
-
).toThrow('calldata is not canonical')
|
|
1146
|
-
})
|
|
1147
|
-
|
|
1148
|
-
test('error: rejects missing calls', () => {
|
|
1149
|
-
expect(() =>
|
|
1150
|
-
prepareSponsoredTransaction({
|
|
1151
|
-
account: sponsor,
|
|
1152
|
-
chainId: 42431,
|
|
1153
|
-
details,
|
|
1154
|
-
allowedFeeTokens: [bogus],
|
|
1155
|
-
transaction: {
|
|
1156
|
-
...baseTransaction,
|
|
1157
|
-
calls: undefined,
|
|
1158
|
-
} as any,
|
|
1159
|
-
}),
|
|
1160
|
-
).toThrow('must declare calls')
|
|
1161
|
-
})
|
|
1162
|
-
|
|
1163
|
-
test('error: rejects nonzero call value', () => {
|
|
1164
|
-
expect(() =>
|
|
1165
|
-
prepareSponsoredTransaction({
|
|
1166
|
-
account: sponsor,
|
|
1167
|
-
chainId: 42431,
|
|
1168
|
-
details,
|
|
1169
|
-
allowedFeeTokens: [bogus],
|
|
1170
|
-
transaction: {
|
|
1171
|
-
...baseTransaction,
|
|
1172
|
-
calls: [{ ...baseTransaction.calls[0], value: 1n }],
|
|
1173
|
-
} as any,
|
|
1174
|
-
}),
|
|
1175
|
-
).toThrow('call value is not allowed')
|
|
1176
|
-
})
|
|
1177
|
-
})
|