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,808 +0,0 @@
|
|
|
1
|
-
import { Secp256k1 } from 'ox'
|
|
2
|
-
import type { TempoAddress } from 'ox/tempo'
|
|
3
|
-
import { TxEnvelopeTempo } from 'ox/tempo'
|
|
4
|
-
import type { Hex } from 'viem'
|
|
5
|
-
import type { Account } from 'viem'
|
|
6
|
-
import { decodeFunctionData, encodeFunctionData, maxUint256, toHex } from 'viem'
|
|
7
|
-
import { Abis, Addresses, Transaction } from 'viem/tempo'
|
|
8
|
-
|
|
9
|
-
import * as TempoAddress_internal from './address.js'
|
|
10
|
-
import * as defaults from './defaults.js'
|
|
11
|
-
import * as Selectors from './selectors.js'
|
|
12
|
-
|
|
13
|
-
/** Returns true if the serialized transaction has a Tempo envelope prefix. */
|
|
14
|
-
export function isTempoTransaction(serialized: string | undefined): boolean {
|
|
15
|
-
return (
|
|
16
|
-
serialized?.startsWith(TxEnvelopeTempo.serializedType) === true ||
|
|
17
|
-
serialized?.startsWith(TxEnvelopeTempo.feePayerMagic) === true
|
|
18
|
-
)
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
/**
|
|
22
|
-
* Allowed call patterns for fee-payer sponsored transactions.
|
|
23
|
-
* Each inner array is an ordered list of function selectors.
|
|
24
|
-
*/
|
|
25
|
-
export const callScopes = [
|
|
26
|
-
[Selectors.transfer],
|
|
27
|
-
[Selectors.transferWithMemo],
|
|
28
|
-
[Selectors.approve, Selectors.swapExactAmountOut, Selectors.transfer],
|
|
29
|
-
[Selectors.approve, Selectors.swapExactAmountOut, Selectors.transferWithMemo],
|
|
30
|
-
]
|
|
31
|
-
|
|
32
|
-
export type Policy = {
|
|
33
|
-
maxGas: bigint
|
|
34
|
-
maxFeePerGas: bigint
|
|
35
|
-
maxPriorityFeePerGas: bigint
|
|
36
|
-
maxTotalFee: bigint
|
|
37
|
-
maxValidityWindowSeconds: number
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
// Reuse the exact object shape returned by `Transaction.deserialize()`.
|
|
41
|
-
// `typeof Transaction` gets the module value type, `['deserialize']` picks the
|
|
42
|
-
// deserialize function off that module, and `ReturnType<...>` asks TypeScript
|
|
43
|
-
// for that function's return type so this helper stays aligned with upstream
|
|
44
|
-
// Tempo transaction fields.
|
|
45
|
-
type SponsoredTransaction = ReturnType<(typeof Transaction)['deserialize']>
|
|
46
|
-
|
|
47
|
-
type HostedFeePayerFillResponse = {
|
|
48
|
-
error?: { message?: string | undefined } | undefined
|
|
49
|
-
result?: {
|
|
50
|
-
tx?: {
|
|
51
|
-
feePayerSignature?: unknown
|
|
52
|
-
feeToken?: unknown
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
type ExpectedTransfer = {
|
|
58
|
-
amount: string
|
|
59
|
-
allowAnyMemo?: boolean | undefined
|
|
60
|
-
memo?: Hex | undefined
|
|
61
|
-
recipient: TempoAddress.Address
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
const preservedTransactionKeys = [
|
|
65
|
-
'accessList',
|
|
66
|
-
'calls',
|
|
67
|
-
'chainId',
|
|
68
|
-
'feeToken',
|
|
69
|
-
'from',
|
|
70
|
-
'gas',
|
|
71
|
-
'keyAuthorization',
|
|
72
|
-
'maxFeePerGas',
|
|
73
|
-
'maxPriorityFeePerGas',
|
|
74
|
-
'nonce',
|
|
75
|
-
'nonceKey',
|
|
76
|
-
'signature',
|
|
77
|
-
'validAfter',
|
|
78
|
-
'validBefore',
|
|
79
|
-
] as const satisfies readonly (keyof SponsoredTransaction)[]
|
|
80
|
-
|
|
81
|
-
const rejectedTransactionKeys = [
|
|
82
|
-
'blobVersionedHashes',
|
|
83
|
-
'blobs',
|
|
84
|
-
'data',
|
|
85
|
-
'feePayerSignature',
|
|
86
|
-
'gasPrice',
|
|
87
|
-
'kzg',
|
|
88
|
-
'maxFeePerBlobGas',
|
|
89
|
-
'r',
|
|
90
|
-
's',
|
|
91
|
-
'sidecars',
|
|
92
|
-
'to',
|
|
93
|
-
'v',
|
|
94
|
-
'value',
|
|
95
|
-
'yParity',
|
|
96
|
-
] as const
|
|
97
|
-
|
|
98
|
-
const rewrittenTransactionKeys = ['type'] as const
|
|
99
|
-
|
|
100
|
-
const supportedTransactionKeys = new Set<string>([
|
|
101
|
-
...preservedTransactionKeys,
|
|
102
|
-
...rejectedTransactionKeys,
|
|
103
|
-
...rewrittenTransactionKeys,
|
|
104
|
-
])
|
|
105
|
-
|
|
106
|
-
function pushAllowedFeeToken(tokens: TempoAddress.Address[], token: string | undefined) {
|
|
107
|
-
if (!token) return
|
|
108
|
-
const normalized = token as TempoAddress.Address
|
|
109
|
-
if (tokens.some((existing) => TempoAddress_internal.isEqual(existing, normalized))) return
|
|
110
|
-
tokens.push(normalized)
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
/** Returns fee tokens that mppx allows sponsored transactions to charge. */
|
|
114
|
-
export function defaultAllowedFeeTokens(chainId: number | undefined) {
|
|
115
|
-
const tokens: TempoAddress.Address[] = []
|
|
116
|
-
pushAllowedFeeToken(tokens, defaults.tokens.pathUsd)
|
|
117
|
-
pushAllowedFeeToken(tokens, defaults.currency[chainId as keyof typeof defaults.currency])
|
|
118
|
-
return tokens
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
/** Rejects a sponsored fee token outside the server's allowlist. */
|
|
122
|
-
export function assertAllowedFeeToken(
|
|
123
|
-
transaction: { feeToken?: unknown },
|
|
124
|
-
allowedFeeTokens: readonly TempoAddress.Address[],
|
|
125
|
-
) {
|
|
126
|
-
const { feeToken } = transaction
|
|
127
|
-
if (feeToken === undefined) return
|
|
128
|
-
if (typeof feeToken !== 'string')
|
|
129
|
-
throw new FeePayerValidationError('fee-sponsored transaction feeToken is invalid', {})
|
|
130
|
-
const normalized = feeToken as TempoAddress.Address
|
|
131
|
-
if (!allowedFeeTokens.some((allowed) => TempoAddress_internal.isEqual(allowed, normalized)))
|
|
132
|
-
throw new FeePayerValidationError('fee-sponsored transaction feeToken is not allowed', {
|
|
133
|
-
feeToken,
|
|
134
|
-
})
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
function hostedFeePayerRequest(transaction: SponsoredTransaction) {
|
|
138
|
-
return {
|
|
139
|
-
...(transaction.accessList?.length ? { accessList: transaction.accessList } : {}),
|
|
140
|
-
calls: transaction.calls.map(
|
|
141
|
-
(call: {
|
|
142
|
-
data?: `0x${string}` | undefined
|
|
143
|
-
to?: TempoAddress.Address | undefined
|
|
144
|
-
value?: bigint | undefined
|
|
145
|
-
}) => ({
|
|
146
|
-
...(call.to ? { to: call.to } : {}),
|
|
147
|
-
...(call.data ? { data: call.data } : {}),
|
|
148
|
-
value: call.value === undefined ? '0x' : toHex(call.value),
|
|
149
|
-
}),
|
|
150
|
-
),
|
|
151
|
-
feePayer: true,
|
|
152
|
-
from: transaction.from,
|
|
153
|
-
...(transaction.gas !== undefined ? { gas: toHex(transaction.gas) } : {}),
|
|
154
|
-
...(transaction.keyAuthorization !== undefined
|
|
155
|
-
? { keyAuthorization: transaction.keyAuthorization }
|
|
156
|
-
: {}),
|
|
157
|
-
...(transaction.maxFeePerGas !== undefined
|
|
158
|
-
? { maxFeePerGas: toHex(transaction.maxFeePerGas) }
|
|
159
|
-
: {}),
|
|
160
|
-
...(transaction.maxPriorityFeePerGas !== undefined
|
|
161
|
-
? { maxPriorityFeePerGas: toHex(transaction.maxPriorityFeePerGas) }
|
|
162
|
-
: {}),
|
|
163
|
-
nonce: toHex(transaction.nonce ?? 0),
|
|
164
|
-
...(transaction.nonceKey !== undefined ? { nonceKey: toHex(transaction.nonceKey) } : {}),
|
|
165
|
-
type: '0x76',
|
|
166
|
-
...(transaction.validAfter !== undefined ? { validAfter: toHex(transaction.validAfter) } : {}),
|
|
167
|
-
...(transaction.validBefore !== undefined
|
|
168
|
-
? { validBefore: toHex(transaction.validBefore) }
|
|
169
|
-
: {}),
|
|
170
|
-
}
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
/**
|
|
174
|
-
* Co-signs a sender-signed partial sponsorship envelope using a hosted
|
|
175
|
-
* fee-payer endpoint without letting the endpoint mutate sender-committed
|
|
176
|
-
* transaction fields.
|
|
177
|
-
*
|
|
178
|
-
* @returns The serialized co-signed transaction plus the sponsor's recovered
|
|
179
|
-
* `feePayer` address and chosen `feeToken`, so callers can pre-broadcast
|
|
180
|
-
* simulate the exact transaction the sponsor broadcasts.
|
|
181
|
-
*/
|
|
182
|
-
export async function fillHostedFeePayerTransaction(parameters: {
|
|
183
|
-
allowedFeeTokens: readonly TempoAddress.Address[]
|
|
184
|
-
challengeExpires?: string | undefined
|
|
185
|
-
chainId: number
|
|
186
|
-
details: Record<string, string>
|
|
187
|
-
policy?: Partial<Policy> | undefined
|
|
188
|
-
transaction: SponsoredTransaction
|
|
189
|
-
url: string
|
|
190
|
-
}) {
|
|
191
|
-
const { allowedFeeTokens, challengeExpires, chainId, details, policy, transaction, url } =
|
|
192
|
-
parameters
|
|
193
|
-
assertTransactionPolicy({
|
|
194
|
-
challengeExpires,
|
|
195
|
-
chainId,
|
|
196
|
-
details,
|
|
197
|
-
policy,
|
|
198
|
-
transaction,
|
|
199
|
-
})
|
|
200
|
-
const response = await fetch(url, {
|
|
201
|
-
body: JSON.stringify(
|
|
202
|
-
{
|
|
203
|
-
id: 1,
|
|
204
|
-
jsonrpc: '2.0',
|
|
205
|
-
method: 'eth_fillTransaction',
|
|
206
|
-
params: [hostedFeePayerRequest(transaction)],
|
|
207
|
-
},
|
|
208
|
-
(_key, value) => (typeof value === 'bigint' ? toHex(value) : value),
|
|
209
|
-
),
|
|
210
|
-
headers: { 'content-type': 'application/json' },
|
|
211
|
-
method: 'POST',
|
|
212
|
-
})
|
|
213
|
-
const payload = (await response.json().catch(async () => ({
|
|
214
|
-
error: { message: await response.text() },
|
|
215
|
-
}))) as HostedFeePayerFillResponse
|
|
216
|
-
const filled = payload.result?.tx
|
|
217
|
-
if (!response.ok || payload.error || !filled?.feePayerSignature)
|
|
218
|
-
throw new FeePayerValidationError(
|
|
219
|
-
payload.error?.message ?? 'hosted fee payer failed to sponsor transaction',
|
|
220
|
-
{},
|
|
221
|
-
)
|
|
222
|
-
if (typeof filled.feeToken !== 'string')
|
|
223
|
-
throw new FeePayerValidationError('hosted fee payer did not return a feeToken', {})
|
|
224
|
-
|
|
225
|
-
assertAllowedFeeToken({ feeToken: filled.feeToken }, allowedFeeTokens)
|
|
226
|
-
|
|
227
|
-
const feePayerSignature = {
|
|
228
|
-
...(filled.feePayerSignature as Record<string, unknown>),
|
|
229
|
-
yParity: Number((filled.feePayerSignature as { yParity?: unknown }).yParity),
|
|
230
|
-
}
|
|
231
|
-
const feeToken = filled.feeToken as TempoAddress.Address
|
|
232
|
-
|
|
233
|
-
// Recover the concrete sponsor address so the simulation can use a concrete
|
|
234
|
-
// `feePayer` (the node rejects `eth_call` with `feePayer: true`).
|
|
235
|
-
const feePayer = (() => {
|
|
236
|
-
try {
|
|
237
|
-
return Secp256k1.recoverAddress({
|
|
238
|
-
payload: TxEnvelopeTempo.getFeePayerSignPayload(
|
|
239
|
-
TxEnvelopeTempo.from({
|
|
240
|
-
...transaction,
|
|
241
|
-
feePayerSignature: undefined,
|
|
242
|
-
feeToken,
|
|
243
|
-
signature: undefined,
|
|
244
|
-
} as never),
|
|
245
|
-
{ sender: transaction.from as never },
|
|
246
|
-
),
|
|
247
|
-
signature: feePayerSignature as never,
|
|
248
|
-
})
|
|
249
|
-
} catch {
|
|
250
|
-
throw new FeePayerValidationError(
|
|
251
|
-
'hosted fee payer returned an invalid feePayerSignature',
|
|
252
|
-
{},
|
|
253
|
-
)
|
|
254
|
-
}
|
|
255
|
-
})()
|
|
256
|
-
|
|
257
|
-
return {
|
|
258
|
-
feePayer,
|
|
259
|
-
feeToken,
|
|
260
|
-
serializedTransaction: await Transaction.serialize({
|
|
261
|
-
...transaction,
|
|
262
|
-
feePayer: true,
|
|
263
|
-
feePayerSignature,
|
|
264
|
-
feeToken,
|
|
265
|
-
} as never),
|
|
266
|
-
}
|
|
267
|
-
}
|
|
268
|
-
|
|
269
|
-
/**
|
|
270
|
-
* Returns a transaction shape suitable for pre-broadcast simulation.
|
|
271
|
-
*
|
|
272
|
-
* Sponsored transactions are first simulated as calls from the sender with no
|
|
273
|
-
* fee fields or signatures. This checks call execution without requiring the
|
|
274
|
-
* sender to hold the fee token; transferred value and call-level balances are
|
|
275
|
-
* still checked by the RPC.
|
|
276
|
-
*/
|
|
277
|
-
export function simulationTransaction(
|
|
278
|
-
transaction: SponsoredTransaction,
|
|
279
|
-
options: { feePayer: boolean },
|
|
280
|
-
) {
|
|
281
|
-
if (options.feePayer)
|
|
282
|
-
return {
|
|
283
|
-
account: transaction.from,
|
|
284
|
-
calls: transaction.calls,
|
|
285
|
-
}
|
|
286
|
-
return {
|
|
287
|
-
...transaction,
|
|
288
|
-
account: transaction.from,
|
|
289
|
-
calls: transaction.calls,
|
|
290
|
-
feePayerSignature: undefined,
|
|
291
|
-
}
|
|
292
|
-
}
|
|
293
|
-
|
|
294
|
-
/**
|
|
295
|
-
* Returns the final fee-sponsored transaction shape for pre-broadcast
|
|
296
|
-
* simulation. RPC `eth_call` does not carry either transaction signature.
|
|
297
|
-
*/
|
|
298
|
-
export function sponsoredSimulationTransaction(
|
|
299
|
-
transaction: SponsoredTransaction,
|
|
300
|
-
options: { feePayer: TempoAddress.Address; feeToken?: TempoAddress.Address | undefined },
|
|
301
|
-
) {
|
|
302
|
-
const { feePayer, feeToken } = options
|
|
303
|
-
return {
|
|
304
|
-
...transaction,
|
|
305
|
-
account: transaction.from,
|
|
306
|
-
calls: transaction.calls,
|
|
307
|
-
feePayer,
|
|
308
|
-
feePayerSignature: undefined,
|
|
309
|
-
...(feeToken !== undefined ? { feeToken } : {}),
|
|
310
|
-
signature: undefined,
|
|
311
|
-
}
|
|
312
|
-
}
|
|
313
|
-
|
|
314
|
-
/** A completed sponsorship envelope that can be simulated before signing or broadcast. */
|
|
315
|
-
export type PreflightSponsorship = {
|
|
316
|
-
feePayer: TempoAddress.Address
|
|
317
|
-
feeToken?: TempoAddress.Address | undefined
|
|
318
|
-
transaction: SponsoredTransaction
|
|
319
|
-
}
|
|
320
|
-
|
|
321
|
-
/**
|
|
322
|
-
* Runs execution-only sender and final-envelope simulations around sponsorship.
|
|
323
|
-
*
|
|
324
|
-
* First, it simulates the calls with the sender as `from`, omitting fee fields
|
|
325
|
-
* and signatures so the sender's fee balance is irrelevant. Next, `complete`
|
|
326
|
-
* resolves the sponsor and produces the co-signed transaction. Finally, it
|
|
327
|
-
* simulates that transaction with its concrete fee payer and fee token.
|
|
328
|
-
*
|
|
329
|
-
* `complete` runs only after sender-context execution succeeds, so a reverting
|
|
330
|
-
* transaction never reaches a local signer or hosted fee-payer.
|
|
331
|
-
*/
|
|
332
|
-
export async function preflightSponsorship<sponsorship extends PreflightSponsorship>(parameters: {
|
|
333
|
-
complete: () => Promise<sponsorship>
|
|
334
|
-
simulate: (request: Record<string, unknown>) => Promise<unknown>
|
|
335
|
-
transaction: SponsoredTransaction
|
|
336
|
-
}): Promise<sponsorship> {
|
|
337
|
-
const { complete, simulate, transaction } = parameters
|
|
338
|
-
await simulate(simulationTransaction(transaction, { feePayer: true }))
|
|
339
|
-
const completed = await complete()
|
|
340
|
-
await simulate(
|
|
341
|
-
sponsoredSimulationTransaction(completed.transaction, {
|
|
342
|
-
feePayer: completed.feePayer,
|
|
343
|
-
feeToken: completed.feeToken,
|
|
344
|
-
}),
|
|
345
|
-
)
|
|
346
|
-
return completed
|
|
347
|
-
}
|
|
348
|
-
|
|
349
|
-
/**
|
|
350
|
-
* maxTotalFee must be high enough to cover `transferWithMemo` and
|
|
351
|
-
* swap transactions at peak gas prices. Bumped from 0.01 ETH in #327.
|
|
352
|
-
*/
|
|
353
|
-
const defaultPolicy: Policy = {
|
|
354
|
-
maxGas: 2_000_000n,
|
|
355
|
-
maxFeePerGas: 100_000_000_000n,
|
|
356
|
-
maxPriorityFeePerGas: 10_000_000_000n,
|
|
357
|
-
maxTotalFee: 50_000_000_000_000_000n,
|
|
358
|
-
maxValidityWindowSeconds: 15 * 60,
|
|
359
|
-
}
|
|
360
|
-
|
|
361
|
-
const policyByChainId = {
|
|
362
|
-
[defaults.chainId.mainnet]: defaultPolicy,
|
|
363
|
-
// Moderato regularly needs a higher priority fee than mainnet.
|
|
364
|
-
[defaults.chainId.testnet]: {
|
|
365
|
-
...defaultPolicy,
|
|
366
|
-
maxPriorityFeePerGas: 50_000_000_000n,
|
|
367
|
-
},
|
|
368
|
-
} as const satisfies Record<defaults.ChainId, Policy>
|
|
369
|
-
|
|
370
|
-
function getPolicy(chainId: number, overrides: Partial<Policy> | undefined): Policy {
|
|
371
|
-
const base = policyByChainId[chainId as defaults.ChainId] ?? defaultPolicy
|
|
372
|
-
if (!overrides) return base
|
|
373
|
-
|
|
374
|
-
return {
|
|
375
|
-
maxGas: overrides.maxGas ?? base.maxGas,
|
|
376
|
-
maxFeePerGas: overrides.maxFeePerGas ?? base.maxFeePerGas,
|
|
377
|
-
maxPriorityFeePerGas: overrides.maxPriorityFeePerGas ?? base.maxPriorityFeePerGas,
|
|
378
|
-
maxTotalFee: overrides.maxTotalFee ?? base.maxTotalFee,
|
|
379
|
-
maxValidityWindowSeconds: overrides.maxValidityWindowSeconds ?? base.maxValidityWindowSeconds,
|
|
380
|
-
}
|
|
381
|
-
}
|
|
382
|
-
|
|
383
|
-
function isExpiringNonceKey(nonceKey: SponsoredTransaction['nonceKey']): boolean {
|
|
384
|
-
return nonceKey === 'expiring' || nonceKey === maxUint256
|
|
385
|
-
}
|
|
386
|
-
|
|
387
|
-
const sponsoredCallAbi = [...Abis.tip20, ...Abis.stablecoinDex] as const
|
|
388
|
-
const sponsoredCallSelectors = new Set([
|
|
389
|
-
Selectors.approve,
|
|
390
|
-
Selectors.transfer,
|
|
391
|
-
Selectors.transferWithMemo,
|
|
392
|
-
Selectors.swapExactAmountOut,
|
|
393
|
-
])
|
|
394
|
-
|
|
395
|
-
function canonicalSponsoredCallData(
|
|
396
|
-
data: Hex,
|
|
397
|
-
call: string,
|
|
398
|
-
fail: (reason: string, extra?: Record<string, string>) => never,
|
|
399
|
-
) {
|
|
400
|
-
if (!sponsoredCallSelectors.has(data.slice(0, 10) as Hex)) return undefined
|
|
401
|
-
|
|
402
|
-
let decoded: ReturnType<typeof decodeFunctionData<typeof sponsoredCallAbi>>
|
|
403
|
-
try {
|
|
404
|
-
decoded = decodeFunctionData({ abi: sponsoredCallAbi, data })
|
|
405
|
-
} catch {
|
|
406
|
-
fail('fee-sponsored transaction call calldata is invalid', { call })
|
|
407
|
-
}
|
|
408
|
-
return encodeFunctionData({
|
|
409
|
-
abi: sponsoredCallAbi,
|
|
410
|
-
functionName: decoded.functionName,
|
|
411
|
-
args: decoded.args,
|
|
412
|
-
})
|
|
413
|
-
}
|
|
414
|
-
|
|
415
|
-
/**
|
|
416
|
-
* Rejects sponsored transaction fields that increase intrinsic gas without
|
|
417
|
-
* changing the decoded payment intent.
|
|
418
|
-
*/
|
|
419
|
-
function assertCanonicalSponsoredTransaction(
|
|
420
|
-
transaction: SponsoredTransaction,
|
|
421
|
-
fail: (reason: string, extra?: Record<string, string>) => never,
|
|
422
|
-
) {
|
|
423
|
-
if (transaction.accessList !== undefined && transaction.accessList.length > 0)
|
|
424
|
-
fail('fee-sponsored transaction accessList is not allowed', {
|
|
425
|
-
accessListEntries: String(transaction.accessList.length),
|
|
426
|
-
})
|
|
427
|
-
|
|
428
|
-
const calls = transaction.calls
|
|
429
|
-
if (!Array.isArray(calls) || calls.length === 0)
|
|
430
|
-
fail('fee-sponsored transaction must declare calls')
|
|
431
|
-
|
|
432
|
-
for (const [index, call] of calls.entries()) {
|
|
433
|
-
const callIndex = String(index)
|
|
434
|
-
const value = call.value
|
|
435
|
-
if (value !== undefined && value !== 0n)
|
|
436
|
-
fail('fee-sponsored transaction call value is not allowed', {
|
|
437
|
-
call: callIndex,
|
|
438
|
-
value: value.toString(),
|
|
439
|
-
})
|
|
440
|
-
|
|
441
|
-
const data = call.data
|
|
442
|
-
if (!data)
|
|
443
|
-
fail('fee-sponsored transaction call is missing calldata', {
|
|
444
|
-
call: callIndex,
|
|
445
|
-
})
|
|
446
|
-
|
|
447
|
-
const canonical = canonicalSponsoredCallData(data, callIndex, fail)
|
|
448
|
-
if (canonical && data.toLowerCase() !== canonical.toLowerCase())
|
|
449
|
-
fail('fee-sponsored transaction call calldata is not canonical', {
|
|
450
|
-
call: callIndex,
|
|
451
|
-
})
|
|
452
|
-
}
|
|
453
|
-
}
|
|
454
|
-
|
|
455
|
-
/** Validates that a set of transaction calls matches an allowed fee-payer pattern. */
|
|
456
|
-
export function validateCalls(
|
|
457
|
-
calls: readonly { data?: `0x${string}` | undefined; to?: TempoAddress.Address | undefined }[],
|
|
458
|
-
details: Record<string, string>,
|
|
459
|
-
options?: {
|
|
460
|
-
currency?: TempoAddress.Address | undefined
|
|
461
|
-
expectedTransfers?: readonly ExpectedTransfer[] | undefined
|
|
462
|
-
},
|
|
463
|
-
) {
|
|
464
|
-
if (calls.length === 0)
|
|
465
|
-
throw new FeePayerValidationError('disallowed call pattern in fee-payer transaction', details)
|
|
466
|
-
|
|
467
|
-
const callSelectors = calls.map((c) => c.data?.slice(0, 10))
|
|
468
|
-
const hasSwapPrefix = callSelectors[0] === Selectors.approve
|
|
469
|
-
|
|
470
|
-
if (hasSwapPrefix) {
|
|
471
|
-
if (callSelectors[1] !== Selectors.swapExactAmountOut)
|
|
472
|
-
throw new FeePayerValidationError('disallowed call pattern in fee-payer transaction', details)
|
|
473
|
-
} else if (callSelectors[0] === Selectors.swapExactAmountOut) {
|
|
474
|
-
throw new FeePayerValidationError('disallowed call pattern in fee-payer transaction', details)
|
|
475
|
-
}
|
|
476
|
-
|
|
477
|
-
const transferSelectors = callSelectors.slice(hasSwapPrefix ? 2 : 0)
|
|
478
|
-
if (transferSelectors.length === 0)
|
|
479
|
-
throw new FeePayerValidationError('disallowed call pattern in fee-payer transaction', details)
|
|
480
|
-
|
|
481
|
-
const expectedTransfers = options?.expectedTransfers
|
|
482
|
-
const transferLimit = expectedTransfers?.length ?? 11
|
|
483
|
-
if (
|
|
484
|
-
transferSelectors.length > transferLimit ||
|
|
485
|
-
transferSelectors.some(
|
|
486
|
-
(selector) => selector !== Selectors.transfer && selector !== Selectors.transferWithMemo,
|
|
487
|
-
) ||
|
|
488
|
-
(expectedTransfers && transferSelectors.length !== expectedTransfers.length)
|
|
489
|
-
)
|
|
490
|
-
throw new FeePayerValidationError('disallowed call pattern in fee-payer transaction', details)
|
|
491
|
-
|
|
492
|
-
// Bind the swap approval to the token the DEX call will actually spend.
|
|
493
|
-
const buyCall = calls.find((c) => c.data?.slice(0, 10) === Selectors.swapExactAmountOut)
|
|
494
|
-
const buyArgs = buyCall
|
|
495
|
-
? (decodeFunctionData({ abi: Abis.stablecoinDex, data: buyCall.data! }).args as [
|
|
496
|
-
`0x${string}`,
|
|
497
|
-
`0x${string}`,
|
|
498
|
-
bigint,
|
|
499
|
-
bigint,
|
|
500
|
-
])
|
|
501
|
-
: undefined
|
|
502
|
-
|
|
503
|
-
const approveCall = calls.find((c) => c.data?.slice(0, 10) === Selectors.approve)
|
|
504
|
-
if (approveCall) {
|
|
505
|
-
const { args } = decodeFunctionData({ abi: Abis.tip20, data: approveCall.data! })
|
|
506
|
-
const [spender, amount] = args as [`0x${string}`, bigint]
|
|
507
|
-
if (!approveCall.to || (buyArgs && !TempoAddress_internal.isEqual(approveCall.to, buyArgs[0])))
|
|
508
|
-
throw new FeePayerValidationError('approve target does not match swap tokenIn', details)
|
|
509
|
-
if (!TempoAddress_internal.isEqual(spender, Addresses.stablecoinDex))
|
|
510
|
-
throw new FeePayerValidationError('approve spender is not the DEX', details)
|
|
511
|
-
if (buyArgs && amount !== buyArgs[3])
|
|
512
|
-
throw new FeePayerValidationError('approve amount does not match swap max input', details)
|
|
513
|
-
}
|
|
514
|
-
if (
|
|
515
|
-
buyCall &&
|
|
516
|
-
(!buyCall.to || !TempoAddress_internal.isEqual(buyCall.to, Addresses.stablecoinDex))
|
|
517
|
-
)
|
|
518
|
-
throw new FeePayerValidationError('buy target is not the DEX', details)
|
|
519
|
-
|
|
520
|
-
if (!expectedTransfers) return
|
|
521
|
-
|
|
522
|
-
const currency = options?.currency ?? (details.currency as TempoAddress.Address | undefined)
|
|
523
|
-
if (!currency) throw new FeePayerValidationError('missing payment currency', details)
|
|
524
|
-
|
|
525
|
-
if (buyArgs) {
|
|
526
|
-
const [, tokenOut, amountOut] = buyArgs
|
|
527
|
-
const expectedAmountOut = expectedTransfers.reduce(
|
|
528
|
-
(sum, transfer) => sum + BigInt(transfer.amount),
|
|
529
|
-
0n,
|
|
530
|
-
)
|
|
531
|
-
if (!TempoAddress_internal.isEqual(tokenOut, currency))
|
|
532
|
-
throw new FeePayerValidationError('swap tokenOut does not match payment currency', details)
|
|
533
|
-
if (amountOut !== expectedAmountOut)
|
|
534
|
-
throw new FeePayerValidationError('swap output does not match payment amount', details)
|
|
535
|
-
}
|
|
536
|
-
|
|
537
|
-
const transferCalls = calls.slice(hasSwapPrefix ? 2 : 0)
|
|
538
|
-
const sorted = [...expectedTransfers].sort((a, b) => {
|
|
539
|
-
if (a.memo && !b.memo) return -1
|
|
540
|
-
if (!a.memo && b.memo) return 1
|
|
541
|
-
return 0
|
|
542
|
-
})
|
|
543
|
-
|
|
544
|
-
const used = new Set<number>()
|
|
545
|
-
for (const expected of sorted) {
|
|
546
|
-
const matchIndex = transferCalls.findIndex((call, index) => {
|
|
547
|
-
if (used.has(index)) return false
|
|
548
|
-
if (!call.to || !TempoAddress_internal.isEqual(call.to, currency) || !call.data) return false
|
|
549
|
-
|
|
550
|
-
try {
|
|
551
|
-
const selector = call.data.slice(0, 10)
|
|
552
|
-
const { args } = decodeFunctionData({ abi: Abis.tip20, data: call.data })
|
|
553
|
-
if (selector === Selectors.transfer) {
|
|
554
|
-
const [recipient, amount] = args as [`0x${string}`, bigint]
|
|
555
|
-
if (!TempoAddress_internal.isEqual(recipient, expected.recipient)) return false
|
|
556
|
-
if (amount.toString() !== expected.amount) return false
|
|
557
|
-
return expected.memo === undefined
|
|
558
|
-
}
|
|
559
|
-
|
|
560
|
-
if (selector === Selectors.transferWithMemo) {
|
|
561
|
-
const [recipient, amount, memo] = args as [`0x${string}`, bigint, Hex]
|
|
562
|
-
if (!TempoAddress_internal.isEqual(recipient, expected.recipient)) return false
|
|
563
|
-
if (amount.toString() !== expected.amount) return false
|
|
564
|
-
if (expected.memo) return memo.toLowerCase() === expected.memo.toLowerCase()
|
|
565
|
-
return expected.allowAnyMemo === true
|
|
566
|
-
}
|
|
567
|
-
} catch {
|
|
568
|
-
return false
|
|
569
|
-
}
|
|
570
|
-
|
|
571
|
-
return false
|
|
572
|
-
})
|
|
573
|
-
|
|
574
|
-
if (matchIndex === -1)
|
|
575
|
-
throw new FeePayerValidationError('payment transfer does not match challenge', details)
|
|
576
|
-
|
|
577
|
-
used.add(matchIndex)
|
|
578
|
-
}
|
|
579
|
-
}
|
|
580
|
-
|
|
581
|
-
/** Validates sponsor fee policy limits for a fee-payer transaction. */
|
|
582
|
-
export function assertTransactionPolicy(parameters: {
|
|
583
|
-
challengeExpires?: string | undefined
|
|
584
|
-
chainId: number
|
|
585
|
-
details: Record<string, string>
|
|
586
|
-
now?: Date | undefined
|
|
587
|
-
policy?: Partial<Policy> | undefined
|
|
588
|
-
transaction: SponsoredTransaction
|
|
589
|
-
}) {
|
|
590
|
-
const {
|
|
591
|
-
challengeExpires,
|
|
592
|
-
chainId,
|
|
593
|
-
details,
|
|
594
|
-
now = new Date(),
|
|
595
|
-
policy: policyOverrides,
|
|
596
|
-
transaction,
|
|
597
|
-
} = parameters
|
|
598
|
-
const policy = getPolicy(chainId, policyOverrides)
|
|
599
|
-
const {
|
|
600
|
-
chainId: transactionChainId,
|
|
601
|
-
gas,
|
|
602
|
-
maxFeePerGas,
|
|
603
|
-
maxPriorityFeePerGas,
|
|
604
|
-
nonceKey,
|
|
605
|
-
validBefore,
|
|
606
|
-
} = transaction
|
|
607
|
-
|
|
608
|
-
const fail = (reason: string, extra: Record<string, string> = {}) => {
|
|
609
|
-
throw new FeePayerValidationError(reason, { ...details, ...extra })
|
|
610
|
-
}
|
|
611
|
-
|
|
612
|
-
if (transaction.type !== undefined && transaction.type !== 'tempo')
|
|
613
|
-
fail('fee-sponsored transaction type is invalid', {
|
|
614
|
-
type: String(transaction.type),
|
|
615
|
-
})
|
|
616
|
-
|
|
617
|
-
if (transactionChainId !== chainId)
|
|
618
|
-
fail('fee-sponsored transaction chainId does not match challenge', {
|
|
619
|
-
chainId: String(transactionChainId),
|
|
620
|
-
})
|
|
621
|
-
|
|
622
|
-
assertCanonicalSponsoredTransaction(transaction, fail)
|
|
623
|
-
|
|
624
|
-
if (gas === undefined || gas <= 0n) fail('fee-sponsored transaction must declare gas')
|
|
625
|
-
const gasLimit = gas
|
|
626
|
-
if (gasLimit > policy.maxGas)
|
|
627
|
-
fail('fee-sponsored transaction gas exceeds sponsor policy', {
|
|
628
|
-
gas: gasLimit.toString(),
|
|
629
|
-
})
|
|
630
|
-
|
|
631
|
-
if (maxFeePerGas === undefined || maxFeePerGas <= 0n)
|
|
632
|
-
fail('fee-sponsored transaction must declare maxFeePerGas')
|
|
633
|
-
const maxFeePerGasValue = maxFeePerGas
|
|
634
|
-
if (maxFeePerGasValue > policy.maxFeePerGas)
|
|
635
|
-
fail('fee-sponsored transaction maxFeePerGas exceeds sponsor policy', {
|
|
636
|
-
maxFeePerGas: maxFeePerGasValue.toString(),
|
|
637
|
-
})
|
|
638
|
-
|
|
639
|
-
const maxTotalFee = BigInt(gasLimit) * BigInt(maxFeePerGasValue)
|
|
640
|
-
if (maxTotalFee > policy.maxTotalFee)
|
|
641
|
-
fail('fee-sponsored transaction total fee budget exceeds sponsor policy', {
|
|
642
|
-
gas: gasLimit.toString(),
|
|
643
|
-
maxFeePerGas: maxFeePerGasValue.toString(),
|
|
644
|
-
totalFee: maxTotalFee.toString(),
|
|
645
|
-
})
|
|
646
|
-
if (maxPriorityFeePerGas !== undefined && maxPriorityFeePerGas > maxFeePerGasValue)
|
|
647
|
-
fail('fee-sponsored transaction maxPriorityFeePerGas exceeds maxFeePerGas', {
|
|
648
|
-
maxFeePerGas: maxFeePerGasValue.toString(),
|
|
649
|
-
maxPriorityFeePerGas: maxPriorityFeePerGas.toString(),
|
|
650
|
-
})
|
|
651
|
-
if (maxPriorityFeePerGas !== undefined && maxPriorityFeePerGas > policy.maxPriorityFeePerGas)
|
|
652
|
-
fail('fee-sponsored transaction maxPriorityFeePerGas exceeds sponsor policy', {
|
|
653
|
-
maxPriorityFeePerGas: maxPriorityFeePerGas.toString(),
|
|
654
|
-
})
|
|
655
|
-
|
|
656
|
-
if (!isExpiringNonceKey(nonceKey)) fail('fee-sponsored transaction must use an expiring nonce')
|
|
657
|
-
if (validBefore === undefined)
|
|
658
|
-
fail('fee-sponsored transaction must declare validBefore for the expiring nonce')
|
|
659
|
-
const validBeforeValue = validBefore
|
|
660
|
-
|
|
661
|
-
const nowSeconds = Math.floor(now.getTime() / 1_000)
|
|
662
|
-
if (validBeforeValue <= nowSeconds)
|
|
663
|
-
fail('fee-sponsored transaction has already expired', {
|
|
664
|
-
validBefore: String(validBeforeValue),
|
|
665
|
-
})
|
|
666
|
-
|
|
667
|
-
const challengeExpirySeconds = challengeExpires
|
|
668
|
-
? Math.floor(new Date(challengeExpires).getTime() / 1_000)
|
|
669
|
-
: undefined
|
|
670
|
-
const maxValidBefore = Math.min(
|
|
671
|
-
nowSeconds + policy.maxValidityWindowSeconds,
|
|
672
|
-
challengeExpirySeconds ? challengeExpirySeconds + 60 : Number.MAX_SAFE_INTEGER,
|
|
673
|
-
)
|
|
674
|
-
if (validBeforeValue > maxValidBefore)
|
|
675
|
-
fail('fee-sponsored transaction validity window exceeds sponsor policy', {
|
|
676
|
-
validBefore: String(validBeforeValue),
|
|
677
|
-
})
|
|
678
|
-
|
|
679
|
-
return {
|
|
680
|
-
gasLimit,
|
|
681
|
-
maxFeePerGasValue,
|
|
682
|
-
totalFee: maxTotalFee,
|
|
683
|
-
validBeforeValue,
|
|
684
|
-
}
|
|
685
|
-
}
|
|
686
|
-
|
|
687
|
-
export function prepareSponsoredTransaction(parameters: {
|
|
688
|
-
account: Account
|
|
689
|
-
allowedFeeTokens?: readonly TempoAddress.Address[] | undefined
|
|
690
|
-
challengeExpires?: string | undefined
|
|
691
|
-
chainId: number
|
|
692
|
-
details: Record<string, string>
|
|
693
|
-
now?: Date | undefined
|
|
694
|
-
policy?: Partial<Policy> | undefined
|
|
695
|
-
transaction: SponsoredTransaction
|
|
696
|
-
}) {
|
|
697
|
-
const {
|
|
698
|
-
account,
|
|
699
|
-
allowedFeeTokens,
|
|
700
|
-
challengeExpires,
|
|
701
|
-
chainId,
|
|
702
|
-
details,
|
|
703
|
-
now = new Date(),
|
|
704
|
-
policy: policyOverrides,
|
|
705
|
-
transaction,
|
|
706
|
-
} = parameters
|
|
707
|
-
const transactionRecord = transaction as Record<string, unknown>
|
|
708
|
-
|
|
709
|
-
const {
|
|
710
|
-
accessList,
|
|
711
|
-
calls,
|
|
712
|
-
chainId: transactionChainId,
|
|
713
|
-
feeToken,
|
|
714
|
-
from,
|
|
715
|
-
keyAuthorization,
|
|
716
|
-
maxPriorityFeePerGas,
|
|
717
|
-
nonce,
|
|
718
|
-
nonceKey,
|
|
719
|
-
signature,
|
|
720
|
-
validAfter,
|
|
721
|
-
} = transaction
|
|
722
|
-
|
|
723
|
-
const fail = (reason: string, extra: Record<string, string> = {}) => {
|
|
724
|
-
throw new FeePayerValidationError(reason, { ...details, ...extra })
|
|
725
|
-
}
|
|
726
|
-
|
|
727
|
-
const unsupportedKeys = Object.entries(transaction).flatMap(([key, value]) => {
|
|
728
|
-
if (value === undefined) return []
|
|
729
|
-
if (supportedTransactionKeys.has(key)) return []
|
|
730
|
-
return [key]
|
|
731
|
-
})
|
|
732
|
-
if (unsupportedKeys.length > 0)
|
|
733
|
-
fail('fee-sponsored transaction contains unsupported fields', {
|
|
734
|
-
unsupportedFields: unsupportedKeys.join(', '),
|
|
735
|
-
})
|
|
736
|
-
|
|
737
|
-
const rejectedKeys = rejectedTransactionKeys.filter((key) => {
|
|
738
|
-
const value = transactionRecord[key]
|
|
739
|
-
return value !== undefined && value !== null
|
|
740
|
-
})
|
|
741
|
-
if (rejectedKeys.length > 0)
|
|
742
|
-
fail('fee-sponsored transaction contains rejected fields', {
|
|
743
|
-
rejectedFields: rejectedKeys.join(', '),
|
|
744
|
-
})
|
|
745
|
-
|
|
746
|
-
const { gasLimit, maxFeePerGasValue, validBeforeValue } = assertTransactionPolicy({
|
|
747
|
-
challengeExpires,
|
|
748
|
-
chainId,
|
|
749
|
-
details,
|
|
750
|
-
now,
|
|
751
|
-
policy: policyOverrides,
|
|
752
|
-
transaction,
|
|
753
|
-
})
|
|
754
|
-
|
|
755
|
-
const normalizedFeeToken = (() => {
|
|
756
|
-
if (feeToken === undefined) return undefined
|
|
757
|
-
if (typeof feeToken !== 'string') fail('fee-sponsored transaction feeToken is invalid')
|
|
758
|
-
return feeToken
|
|
759
|
-
})()
|
|
760
|
-
|
|
761
|
-
if (normalizedFeeToken !== undefined) {
|
|
762
|
-
if (
|
|
763
|
-
allowedFeeTokens &&
|
|
764
|
-
!allowedFeeTokens.some((allowed) =>
|
|
765
|
-
TempoAddress_internal.isEqual(normalizedFeeToken, allowed),
|
|
766
|
-
)
|
|
767
|
-
)
|
|
768
|
-
fail('fee-sponsored transaction feeToken is not allowed', {
|
|
769
|
-
feeToken: normalizedFeeToken,
|
|
770
|
-
})
|
|
771
|
-
}
|
|
772
|
-
|
|
773
|
-
return {
|
|
774
|
-
accessList,
|
|
775
|
-
account,
|
|
776
|
-
calls,
|
|
777
|
-
chainId: transactionChainId,
|
|
778
|
-
feePayer: account,
|
|
779
|
-
...(normalizedFeeToken ? { feeToken: normalizedFeeToken } : {}),
|
|
780
|
-
...(from ? { from } : {}),
|
|
781
|
-
gas: gasLimit,
|
|
782
|
-
...(keyAuthorization !== undefined ? { keyAuthorization } : {}),
|
|
783
|
-
...(nonce !== undefined ? { nonce } : {}),
|
|
784
|
-
maxFeePerGas: maxFeePerGasValue,
|
|
785
|
-
...(maxPriorityFeePerGas !== undefined ? { maxPriorityFeePerGas } : {}),
|
|
786
|
-
nonceKey,
|
|
787
|
-
...(signature ? { signature } : {}),
|
|
788
|
-
type: 'tempo' as const,
|
|
789
|
-
...(validAfter !== undefined ? { validAfter } : {}),
|
|
790
|
-
validBefore: validBeforeValue,
|
|
791
|
-
} satisfies ReturnType<(typeof Transaction)['deserialize']> & {
|
|
792
|
-
account: Account
|
|
793
|
-
feePayer: Account
|
|
794
|
-
}
|
|
795
|
-
}
|
|
796
|
-
|
|
797
|
-
export class FeePayerValidationError extends Error {
|
|
798
|
-
override readonly name = 'FeePayerValidationError'
|
|
799
|
-
|
|
800
|
-
constructor(reason: string, details: Record<string, string>) {
|
|
801
|
-
super(
|
|
802
|
-
[
|
|
803
|
-
`Invalid transaction: ${reason}`,
|
|
804
|
-
...Object.entries(details).map(([k, v]) => ` - ${k}: ${v}`),
|
|
805
|
-
].join('\n'),
|
|
806
|
-
)
|
|
807
|
-
}
|
|
808
|
-
}
|