tapimo 0.13.0 → 0.15.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +7 -4
- package/dist/ApiKey.js +1 -1
- package/dist/ApiKey.js.map +1 -1
- package/dist/ApiKeys.d.ts +95 -14
- package/dist/ApiKeys.d.ts.map +1 -1
- package/dist/ApiKeys.js +360 -49
- package/dist/ApiKeys.js.map +1 -1
- package/dist/App.d.ts +21383 -18056
- package/dist/App.d.ts.map +1 -1
- package/dist/App.js +301 -22
- package/dist/App.js.map +1 -1
- package/dist/Assets.d.ts.map +1 -1
- package/dist/Assets.js +2 -1
- package/dist/Assets.js.map +1 -1
- package/dist/Handler.d.ts +0 -1
- package/dist/Handler.d.ts.map +1 -1
- package/dist/Handler.js +0 -1
- package/dist/Handler.js.map +1 -1
- package/dist/Scope.d.ts +13 -5
- package/dist/Scope.d.ts.map +1 -1
- package/dist/Scope.js +16 -5
- package/dist/Scope.js.map +1 -1
- package/dist/Webhooks.js +2 -2
- package/dist/Webhooks.js.map +1 -1
- package/dist/admin/App.d.ts +3936 -1337
- package/dist/admin/App.d.ts.map +1 -1
- package/dist/admin/App.js +26 -5
- package/dist/admin/App.js.map +1 -1
- package/dist/admin/apps/api-keys.d.ts +159 -7
- package/dist/admin/apps/api-keys.d.ts.map +1 -1
- package/dist/admin/apps/api-keys.js +95 -43
- package/dist/admin/apps/api-keys.js.map +1 -1
- package/dist/admin/apps/earn-vaults.d.ts +1446 -0
- package/dist/admin/apps/earn-vaults.d.ts.map +1 -1
- package/dist/admin/apps/earn-vaults.js +465 -8
- package/dist/admin/apps/earn-vaults.js.map +1 -1
- package/dist/admin/apps/organizations.d.ts +344 -3
- package/dist/admin/apps/organizations.d.ts.map +1 -1
- package/dist/admin/apps/organizations.js +288 -10
- package/dist/admin/apps/organizations.js.map +1 -1
- package/dist/admin/apps/routes-support.d.ts +95 -0
- package/dist/admin/apps/routes-support.d.ts.map +1 -0
- package/dist/admin/apps/routes-support.js +151 -0
- package/dist/admin/apps/routes-support.js.map +1 -0
- package/dist/admin/apps/routes.d.ts +2764 -0
- package/dist/admin/apps/routes.d.ts.map +1 -0
- package/dist/admin/apps/routes.js +728 -0
- package/dist/admin/apps/routes.js.map +1 -0
- package/dist/admin/apps/subsidies.d.ts +501 -0
- package/dist/admin/apps/subsidies.d.ts.map +1 -0
- package/dist/admin/apps/subsidies.js +384 -0
- package/dist/admin/apps/subsidies.js.map +1 -0
- package/dist/admin/apps/verified-tokens.d.ts +16 -16
- package/dist/admin/apps/verified-tokens.d.ts.map +1 -1
- package/dist/admin/apps/verified-tokens.js +3 -3
- package/dist/admin/apps/verified-tokens.js.map +1 -1
- package/dist/admin/ui.generated.d.ts +1 -1
- package/dist/admin/ui.generated.d.ts.map +1 -1
- package/dist/admin/ui.generated.js +129 -69
- package/dist/admin/ui.generated.js.map +1 -1
- package/dist/analytics/Analytics.d.ts +5 -2
- package/dist/analytics/Analytics.d.ts.map +1 -1
- package/dist/analytics/Analytics.js +31 -1
- package/dist/analytics/Analytics.js.map +1 -1
- package/dist/analytics/tables/requestEvents.d.ts +2 -1
- package/dist/analytics/tables/requestEvents.d.ts.map +1 -1
- package/dist/analytics/tables/requestEvents.js +10 -1
- package/dist/analytics/tables/requestEvents.js.map +1 -1
- package/dist/analytics/tables/routesLifecycleIntervals.d.ts +72 -0
- package/dist/analytics/tables/routesLifecycleIntervals.d.ts.map +1 -0
- package/dist/analytics/tables/routesLifecycleIntervals.js +56 -0
- package/dist/analytics/tables/routesLifecycleIntervals.js.map +1 -0
- package/dist/apps/Zones.d.ts +21 -12526
- package/dist/apps/Zones.d.ts.map +1 -1
- package/dist/apps/Zones.js +40 -8
- package/dist/apps/Zones.js.map +1 -1
- package/dist/apps/data/App.d.ts +4310 -2548
- package/dist/apps/data/App.d.ts.map +1 -1
- package/dist/apps/data/App.js +86 -26
- package/dist/apps/data/App.js.map +1 -1
- package/dist/apps/data/routes/activities.d.ts +364 -34
- package/dist/apps/data/routes/activities.d.ts.map +1 -1
- package/dist/apps/data/routes/activities.js +495 -190
- package/dist/apps/data/routes/activities.js.map +1 -1
- package/dist/apps/data/routes/addresses.d.ts +94 -22
- package/dist/apps/data/routes/addresses.d.ts.map +1 -1
- package/dist/apps/data/routes/blocks.d.ts +37 -37
- package/dist/apps/data/routes/coingecko.d.ts.map +1 -1
- package/dist/apps/data/routes/coingecko.js +47 -21
- package/dist/apps/data/routes/coingecko.js.map +1 -1
- package/dist/apps/data/routes/earn.d.ts +1641 -352
- package/dist/apps/data/routes/earn.d.ts.map +1 -1
- package/dist/apps/data/routes/earn.js +1561 -120
- package/dist/apps/data/routes/earn.js.map +1 -1
- package/dist/apps/data/routes/exchanges.d.ts +15 -0
- package/dist/apps/data/routes/exchanges.d.ts.map +1 -1
- package/dist/apps/data/routes/exchanges.js +180 -114
- package/dist/apps/data/routes/exchanges.js.map +1 -1
- package/dist/apps/data/routes/fee-amm.d.ts +5 -0
- package/dist/apps/data/routes/fee-amm.d.ts.map +1 -1
- package/dist/apps/data/routes/fee-amm.js +49 -38
- package/dist/apps/data/routes/fee-amm.js.map +1 -1
- package/dist/apps/data/routes/indexer.d.ts +125 -0
- package/dist/apps/data/routes/indexer.d.ts.map +1 -1
- package/dist/apps/data/routes/indexer.js +83 -27
- package/dist/apps/data/routes/indexer.js.map +1 -1
- package/dist/apps/data/routes/rpc.d.ts +507 -33
- package/dist/apps/data/routes/rpc.d.ts.map +1 -1
- package/dist/apps/data/routes/rpc.js +266 -156
- package/dist/apps/data/routes/rpc.js.map +1 -1
- package/dist/apps/data/routes/tokenlist.d.ts +47 -15
- package/dist/apps/data/routes/tokenlist.d.ts.map +1 -1
- package/dist/apps/data/routes/tokenlist.js +68 -11
- package/dist/apps/data/routes/tokenlist.js.map +1 -1
- package/dist/apps/data/routes/tokens.d.ts +95 -93
- package/dist/apps/data/routes/tokens.d.ts.map +1 -1
- package/dist/apps/data/routes/tokens.js +26 -14
- package/dist/apps/data/routes/tokens.js.map +1 -1
- package/dist/apps/data/routes/transfers.d.ts +16 -0
- package/dist/apps/data/routes/transfers.d.ts.map +1 -1
- package/dist/apps/data/routes/transfers.js +9 -7
- package/dist/apps/data/routes/transfers.js.map +1 -1
- package/dist/apps/data/routes/verified-tokens.d.ts +4 -4
- package/dist/apps/data/routes/verified-tokens.d.ts.map +1 -1
- package/dist/apps/data/routes/verified-tokens.js +64 -20
- package/dist/apps/data/routes/verified-tokens.js.map +1 -1
- package/dist/apps/data/routes/webhooks.d.ts +1210 -70
- package/dist/apps/data/routes/webhooks.d.ts.map +1 -1
- package/dist/apps/data/routes/webhooks.js +301 -163
- package/dist/apps/data/routes/webhooks.js.map +1 -1
- package/dist/apps/data/routes/zones.d.ts.map +1 -1
- package/dist/apps/data/routes/zones.js +20 -12
- package/dist/apps/data/routes/zones.js.map +1 -1
- package/dist/apps/docs/reference.js +2 -2
- package/dist/apps/docs/reference.js.map +1 -1
- package/dist/apps/index.d.ts +1 -1
- package/dist/apps/index.d.ts.map +1 -1
- package/dist/apps/index.js +1 -1
- package/dist/apps/index.js.map +1 -1
- package/dist/apps/management/App.d.ts +4119 -3297
- package/dist/apps/management/App.d.ts.map +1 -1
- package/dist/apps/management/App.js +5 -14
- package/dist/apps/management/App.js.map +1 -1
- package/dist/apps/management/Billing.d.ts +49 -8
- package/dist/apps/management/Billing.d.ts.map +1 -1
- package/dist/apps/management/Billing.js +221 -26
- package/dist/apps/management/Billing.js.map +1 -1
- package/dist/apps/management/routes/api-keys.d.ts +174 -72
- package/dist/apps/management/routes/api-keys.d.ts.map +1 -1
- package/dist/apps/management/routes/api-keys.js +43 -15
- package/dist/apps/management/routes/api-keys.js.map +1 -1
- package/dist/apps/management/routes/billing.d.ts +364 -78
- package/dist/apps/management/routes/billing.d.ts.map +1 -1
- package/dist/apps/management/routes/billing.js +274 -49
- package/dist/apps/management/routes/billing.js.map +1 -1
- package/dist/apps/management/routes/faucet.d.ts +6 -6
- package/dist/apps/management/routes/faucet.js +1 -1
- package/dist/apps/management/routes/faucet.js.map +1 -1
- package/dist/apps/management/routes/invitations.d.ts +99 -24
- package/dist/apps/management/routes/invitations.d.ts.map +1 -1
- package/dist/apps/management/routes/invitations.js +117 -13
- package/dist/apps/management/routes/invitations.js.map +1 -1
- package/dist/apps/management/routes/invite-links.d.ts +42 -42
- package/dist/apps/management/routes/me.d.ts.map +1 -1
- package/dist/apps/management/routes/me.js +6 -2
- package/dist/apps/management/routes/me.js.map +1 -1
- package/dist/apps/management/routes/members.d.ts +16 -16
- package/dist/apps/management/routes/orgs.d.ts +36 -20
- package/dist/apps/management/routes/orgs.d.ts.map +1 -1
- package/dist/apps/management/routes/orgs.js +52 -12
- package/dist/apps/management/routes/orgs.js.map +1 -1
- package/dist/apps/management/routes/projects.d.ts +40 -40
- package/dist/apps/management/routes/projects.d.ts.map +1 -1
- package/dist/apps/management/routes/projects.js +6 -1
- package/dist/apps/management/routes/projects.js.map +1 -1
- package/dist/apps/management/routes/scopes.d.ts.map +1 -1
- package/dist/apps/management/routes/scopes.js +4 -1
- package/dist/apps/management/routes/scopes.js.map +1 -1
- package/dist/apps/management/routes/usage.d.ts +8 -8
- package/dist/apps/management/routes/usage.js +21 -4
- package/dist/apps/management/routes/usage.js.map +1 -1
- package/dist/apps/management/routes/verified-token-requests.d.ts +16 -16
- package/dist/apps/management/routes/webhooks.d.ts +931 -215
- package/dist/apps/management/routes/webhooks.d.ts.map +1 -1
- package/dist/apps/management/routes/webhooks.js +71 -25
- package/dist/apps/management/routes/webhooks.js.map +1 -1
- package/dist/apps/mcp.d.ts +1 -1
- package/dist/apps/mcp.js +7 -7
- package/dist/apps/mcp.js.map +1 -1
- package/dist/apps/mpp/App.d.ts.map +1 -1
- package/dist/apps/mpp/App.js +35 -7
- package/dist/apps/mpp/App.js.map +1 -1
- package/dist/apps/mpp/internal/Adapter.d.ts +2 -0
- package/dist/apps/mpp/internal/Adapter.d.ts.map +1 -1
- package/dist/apps/mpp/internal/Adapter.js +30 -1
- package/dist/apps/mpp/internal/Adapter.js.map +1 -1
- package/dist/apps/mpp/internal/Policy.d.ts +22 -4
- package/dist/apps/mpp/internal/Policy.d.ts.map +1 -1
- package/dist/apps/mpp/internal/Policy.js +24 -6
- package/dist/apps/mpp/internal/Policy.js.map +1 -1
- package/dist/apps/mpp/internal/Sponsorship.d.ts +3 -0
- package/dist/apps/mpp/internal/Sponsorship.d.ts.map +1 -1
- package/dist/apps/mpp/internal/Sponsorship.js +6 -3
- package/dist/apps/mpp/internal/Sponsorship.js.map +1 -1
- package/dist/apps/relay/App.d.ts +2 -0
- package/dist/apps/relay/App.d.ts.map +1 -1
- package/dist/apps/relay/App.js +177 -26
- package/dist/apps/relay/App.js.map +1 -1
- package/dist/apps/relay/Sponsorships.d.ts +5 -3
- package/dist/apps/relay/Sponsorships.d.ts.map +1 -1
- package/dist/apps/relay/Sponsorships.js +232 -25
- package/dist/apps/relay/Sponsorships.js.map +1 -1
- package/dist/apps/{funding → routes}/Access.d.ts +4 -4
- package/dist/apps/routes/Access.d.ts.map +1 -0
- package/dist/apps/{funding → routes}/Access.js +4 -4
- package/dist/apps/routes/Access.js.map +1 -0
- package/dist/apps/{funding → routes}/App.d.ts +841 -136
- package/dist/apps/{funding → routes}/App.d.ts.map +1 -1
- package/dist/apps/{funding → routes}/App.js +17 -17
- package/dist/apps/routes/App.js.map +1 -0
- package/dist/apps/routes/Inventory.d.ts.map +1 -0
- package/dist/apps/{funding → routes}/Inventory.js +2 -2
- package/dist/apps/routes/Inventory.js.map +1 -0
- package/dist/apps/routes/index.d.ts +2 -0
- package/dist/apps/routes/index.d.ts.map +1 -0
- package/dist/apps/routes/index.js +2 -0
- package/dist/apps/routes/index.js.map +1 -0
- package/dist/apps/{funding → routes}/routes/chains.d.ts +7 -7
- package/dist/apps/routes/routes/chains.d.ts.map +1 -0
- package/dist/apps/{funding → routes}/routes/chains.js +25 -25
- package/dist/apps/routes/routes/chains.js.map +1 -0
- package/dist/apps/{funding → routes}/routes/deposit-addresses.d.ts +123 -59
- package/dist/apps/routes/routes/deposit-addresses.d.ts.map +1 -0
- package/dist/apps/{funding → routes}/routes/deposit-addresses.js +498 -223
- package/dist/apps/routes/routes/deposit-addresses.js.map +1 -0
- package/dist/apps/{funding → routes}/routes/providers.d.ts +8 -8
- package/dist/apps/routes/routes/providers.d.ts.map +1 -0
- package/dist/apps/routes/routes/providers.js +57 -0
- package/dist/apps/routes/routes/providers.js.map +1 -0
- package/dist/apps/{funding → routes}/routes/quotes.d.ts +19 -16
- package/dist/apps/routes/routes/quotes.d.ts.map +1 -0
- package/dist/apps/{funding → routes}/routes/quotes.js +55 -38
- package/dist/apps/routes/routes/quotes.js.map +1 -0
- package/dist/apps/{funding → routes}/routes/transfers.d.ts +957 -71
- package/dist/apps/routes/routes/transfers.d.ts.map +1 -0
- package/dist/apps/routes/routes/transfers.js +1140 -0
- package/dist/apps/routes/routes/transfers.js.map +1 -0
- package/dist/cli/Cli.d.ts +30 -0
- package/dist/cli/Cli.d.ts.map +1 -1
- package/dist/cli/commands/admin.d.ts +36 -0
- package/dist/cli/commands/admin.d.ts.map +1 -1
- package/dist/cli/commands/admin.js +273 -0
- package/dist/cli/commands/admin.js.map +1 -1
- package/dist/cloudflare.d.ts +16 -14
- package/dist/cloudflare.d.ts.map +1 -1
- package/dist/cloudflare.js +26 -21
- package/dist/cloudflare.js.map +1 -1
- package/dist/db/Db.d.ts +63 -21
- package/dist/db/Db.d.ts.map +1 -1
- package/dist/db/Db.js +1052 -15
- package/dist/db/Db.js.map +1 -1
- package/dist/db/Schema.d.ts +785 -133
- package/dist/db/Schema.d.ts.map +1 -1
- package/dist/db/Schema.js +590 -162
- package/dist/db/Schema.js.map +1 -1
- package/dist/db/tables/apiKeyAdmissionBootstraps.d.ts +4 -0
- package/dist/db/tables/apiKeyAdmissionBootstraps.d.ts.map +1 -0
- package/dist/db/tables/apiKeyAdmissionBootstraps.js +2 -0
- package/dist/db/tables/apiKeyAdmissionBootstraps.js.map +1 -0
- package/dist/db/tables/apiKeyAdmissions.d.ts +73 -0
- package/dist/db/tables/apiKeyAdmissions.d.ts.map +1 -0
- package/dist/db/tables/apiKeyAdmissions.js +142 -0
- package/dist/db/tables/apiKeyAdmissions.js.map +1 -0
- package/dist/db/tables/apiKeyOwnerAdmissions.d.ts +4 -0
- package/dist/db/tables/apiKeyOwnerAdmissions.d.ts.map +1 -0
- package/dist/db/tables/apiKeyOwnerAdmissions.js +2 -0
- package/dist/db/tables/apiKeyOwnerAdmissions.js.map +1 -0
- package/dist/db/tables/apiKeyOwnerTombstones.d.ts +20 -0
- package/dist/db/tables/apiKeyOwnerTombstones.d.ts.map +1 -0
- package/dist/db/tables/apiKeyOwnerTombstones.js +57 -0
- package/dist/db/tables/apiKeyOwnerTombstones.js.map +1 -0
- package/dist/db/tables/apiKeyRevocations.d.ts +21 -0
- package/dist/db/tables/apiKeyRevocations.d.ts.map +1 -0
- package/dist/db/tables/apiKeyRevocations.js +98 -0
- package/dist/db/tables/apiKeyRevocations.js.map +1 -0
- package/dist/db/tables/authAccounts.d.ts +47 -0
- package/dist/db/tables/authAccounts.d.ts.map +1 -0
- package/dist/db/tables/authAccounts.js +72 -0
- package/dist/db/tables/authAccounts.js.map +1 -0
- package/dist/db/tables/authSessions.d.ts +12 -0
- package/dist/db/tables/authSessions.d.ts.map +1 -0
- package/dist/db/tables/authSessions.js +2 -0
- package/dist/db/tables/authSessions.js.map +1 -0
- package/dist/db/tables/authVerifications.d.ts +12 -0
- package/dist/db/tables/authVerifications.d.ts.map +1 -0
- package/dist/db/tables/authVerifications.js +2 -0
- package/dist/db/tables/authVerifications.js.map +1 -0
- package/dist/db/tables/invitations.d.ts +17 -1
- package/dist/db/tables/invitations.d.ts.map +1 -1
- package/dist/db/tables/invitations.js +123 -43
- package/dist/db/tables/invitations.js.map +1 -1
- package/dist/db/tables/memberships.d.ts +8 -0
- package/dist/db/tables/memberships.d.ts.map +1 -1
- package/dist/db/tables/memberships.js +51 -2
- package/dist/db/tables/memberships.js.map +1 -1
- package/dist/db/tables/organizations.d.ts +51 -5
- package/dist/db/tables/organizations.d.ts.map +1 -1
- package/dist/db/tables/organizations.js +135 -47
- package/dist/db/tables/organizations.js.map +1 -1
- package/dist/db/tables/projects.d.ts +27 -1
- package/dist/db/tables/projects.d.ts.map +1 -1
- package/dist/db/tables/projects.js +38 -3
- package/dist/db/tables/projects.js.map +1 -1
- package/dist/db/tables/requestUsage.d.ts.map +1 -1
- package/dist/db/tables/requestUsage.js.map +1 -1
- package/dist/db/tables/rewardAccounts.d.ts +86 -0
- package/dist/db/tables/rewardAccounts.d.ts.map +1 -0
- package/dist/db/tables/rewardAccounts.js +88 -0
- package/dist/db/tables/rewardAccounts.js.map +1 -0
- package/dist/db/tables/rewardCampaignDistributors.d.ts +36 -0
- package/dist/db/tables/rewardCampaignDistributors.d.ts.map +1 -0
- package/dist/db/tables/rewardCampaignDistributors.js +30 -0
- package/dist/db/tables/rewardCampaignDistributors.js.map +1 -0
- package/dist/db/tables/rewardCampaigns.d.ts +171 -0
- package/dist/db/tables/rewardCampaigns.d.ts.map +1 -0
- package/dist/db/tables/rewardCampaigns.js +392 -0
- package/dist/db/tables/rewardCampaigns.js.map +1 -0
- package/dist/db/tables/rewardCredits.d.ts +53 -0
- package/dist/db/tables/rewardCredits.d.ts.map +1 -0
- package/dist/db/tables/rewardCredits.js +63 -0
- package/dist/db/tables/rewardCredits.js.map +1 -0
- package/dist/db/tables/rewardEligibilityAssociations.d.ts +61 -0
- package/dist/db/tables/rewardEligibilityAssociations.d.ts.map +1 -0
- package/dist/db/tables/rewardEligibilityAssociations.js +103 -0
- package/dist/db/tables/rewardEligibilityAssociations.js.map +1 -0
- package/dist/db/tables/rewardRuns.d.ts +188 -0
- package/dist/db/tables/rewardRuns.d.ts.map +1 -0
- package/dist/db/tables/rewardRuns.js +278 -0
- package/dist/db/tables/rewardRuns.js.map +1 -0
- package/dist/db/tables/rewardTransactionAttempts.d.ts +100 -0
- package/dist/db/tables/rewardTransactionAttempts.d.ts.map +1 -0
- package/dist/db/tables/rewardTransactionAttempts.js +163 -0
- package/dist/db/tables/rewardTransactionAttempts.js.map +1 -0
- package/dist/db/tables/routesCatalog.d.ts +58 -0
- package/dist/db/tables/routesCatalog.d.ts.map +1 -0
- package/dist/db/tables/{fundingCatalog.js → routesCatalog.js} +19 -19
- package/dist/db/tables/routesCatalog.js.map +1 -0
- package/dist/db/tables/routesDepositAddresses.d.ts +476 -0
- package/dist/db/tables/routesDepositAddresses.d.ts.map +1 -0
- package/dist/db/tables/routesDepositAddresses.js +587 -0
- package/dist/db/tables/routesDepositAddresses.js.map +1 -0
- package/dist/db/tables/{fundingDepositRequestObservations.d.ts → routesDepositRequestObservations.d.ts} +6 -6
- package/dist/db/tables/routesDepositRequestObservations.d.ts.map +1 -0
- package/dist/db/tables/{fundingDepositRequestObservations.js → routesDepositRequestObservations.js} +6 -6
- package/dist/db/tables/routesDepositRequestObservations.js.map +1 -0
- package/dist/db/tables/{fundingDeposits.d.ts → routesDeposits.d.ts} +210 -22
- package/dist/db/tables/routesDeposits.d.ts.map +1 -0
- package/dist/db/tables/routesDeposits.js +576 -0
- package/dist/db/tables/routesDeposits.js.map +1 -0
- package/dist/db/tables/routesIdempotency.d.ts +166 -0
- package/dist/db/tables/routesIdempotency.d.ts.map +1 -0
- package/dist/db/tables/routesIdempotency.js +330 -0
- package/dist/db/tables/routesIdempotency.js.map +1 -0
- package/dist/db/tables/routesSubsidies.d.ts +27 -0
- package/dist/db/tables/routesSubsidies.d.ts.map +1 -0
- package/dist/db/tables/routesSubsidies.js +45 -0
- package/dist/db/tables/routesSubsidies.js.map +1 -0
- package/dist/db/tables/{fundingTransferEvents.d.ts → routesTransferEvents.d.ts} +3 -3
- package/dist/db/tables/routesTransferEvents.d.ts.map +1 -0
- package/dist/db/tables/{fundingTransferEvents.js → routesTransferEvents.js} +3 -3
- package/dist/db/tables/routesTransferEvents.js.map +1 -0
- package/dist/db/tables/routesTransferSubsidies.d.ts +19 -0
- package/dist/db/tables/routesTransferSubsidies.d.ts.map +1 -0
- package/dist/db/tables/routesTransferSubsidies.js +17 -0
- package/dist/db/tables/routesTransferSubsidies.js.map +1 -0
- package/dist/db/tables/routesTransferSubsidyNonces.d.ts +51 -0
- package/dist/db/tables/routesTransferSubsidyNonces.d.ts.map +1 -0
- package/dist/db/tables/routesTransferSubsidyNonces.js +82 -0
- package/dist/db/tables/routesTransferSubsidyNonces.js.map +1 -0
- package/dist/db/tables/routesTransferTransactions.d.ts +77 -0
- package/dist/db/tables/routesTransferTransactions.d.ts.map +1 -0
- package/dist/db/tables/routesTransferTransactions.js +86 -0
- package/dist/db/tables/routesTransferTransactions.js.map +1 -0
- package/dist/db/tables/routesTransfers.d.ts +319 -0
- package/dist/db/tables/routesTransfers.d.ts.map +1 -0
- package/dist/db/tables/routesTransfers.js +372 -0
- package/dist/db/tables/routesTransfers.js.map +1 -0
- package/dist/db/tables/sponsoredTransactions.d.ts +112 -13
- package/dist/db/tables/sponsoredTransactions.d.ts.map +1 -1
- package/dist/db/tables/sponsoredTransactions.js +241 -38
- package/dist/db/tables/sponsoredTransactions.js.map +1 -1
- package/dist/db/tables/sponsorshipAttributions.d.ts +69 -0
- package/dist/db/tables/sponsorshipAttributions.d.ts.map +1 -0
- package/dist/db/tables/sponsorshipAttributions.js +77 -0
- package/dist/db/tables/sponsorshipAttributions.js.map +1 -0
- package/dist/db/tables/sponsorshipReconciliationCursors.d.ts +22 -0
- package/dist/db/tables/sponsorshipReconciliationCursors.d.ts.map +1 -0
- package/dist/db/tables/sponsorshipReconciliationCursors.js +45 -0
- package/dist/db/tables/sponsorshipReconciliationCursors.js.map +1 -0
- package/dist/db/tables/stripeCustomers.d.ts +11 -0
- package/dist/db/tables/stripeCustomers.d.ts.map +1 -1
- package/dist/db/tables/stripeCustomers.js +13 -0
- package/dist/db/tables/stripeCustomers.js.map +1 -1
- package/dist/db/tables/users.d.ts +17 -1
- package/dist/db/tables/users.d.ts.map +1 -1
- package/dist/db/tables/users.js +47 -2
- package/dist/db/tables/users.js.map +1 -1
- package/dist/db/tables/webhookQueueEvents.d.ts.map +1 -1
- package/dist/db/tables/webhookQueueEvents.js +5 -1
- package/dist/db/tables/webhookQueueEvents.js.map +1 -1
- package/dist/db/tables/webhookSubscriptions.d.ts +22 -10
- package/dist/db/tables/webhookSubscriptions.d.ts.map +1 -1
- package/dist/db/tables/webhookSubscriptions.js +50 -15
- package/dist/db/tables/webhookSubscriptions.js.map +1 -1
- package/dist/handlers/internal/executionError.d.ts +2 -2
- package/dist/handlers/internal/executionError.d.ts.map +1 -1
- package/dist/handlers/internal/executionError.js +1 -2
- package/dist/handlers/internal/executionError.js.map +1 -1
- package/dist/handlers/internal/multisig.d.ts +4 -232
- package/dist/handlers/internal/multisig.d.ts.map +1 -1
- package/dist/handlers/internal/multisig.js +11 -537
- package/dist/handlers/internal/multisig.js.map +1 -1
- package/dist/handlers/internal/sponsorship.d.ts +19 -8
- package/dist/handlers/internal/sponsorship.d.ts.map +1 -1
- package/dist/handlers/internal/sponsorship.js +13 -9
- package/dist/handlers/internal/sponsorship.js.map +1 -1
- package/dist/handlers/relay.d.ts +9 -12
- package/dist/handlers/relay.d.ts.map +1 -1
- package/dist/handlers/relay.js +81 -85
- package/dist/handlers/relay.js.map +1 -1
- package/dist/index.d.ts +0 -17
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +0 -17
- package/dist/index.js.map +1 -1
- package/dist/internal/AssetResponse.d.ts +12 -0
- package/dist/internal/AssetResponse.d.ts.map +1 -0
- package/dist/internal/AssetResponse.js +21 -0
- package/dist/internal/AssetResponse.js.map +1 -0
- package/dist/internal/Auth.d.ts +48 -12
- package/dist/internal/Auth.d.ts.map +1 -1
- package/dist/internal/Auth.js +603 -175
- package/dist/internal/Auth.js.map +1 -1
- package/dist/internal/BetterAuth.d.ts +1488 -0
- package/dist/internal/BetterAuth.d.ts.map +1 -0
- package/dist/internal/BetterAuth.js +253 -0
- package/dist/internal/BetterAuth.js.map +1 -0
- package/dist/internal/Cache.d.ts +2 -0
- package/dist/internal/Cache.d.ts.map +1 -1
- package/dist/internal/Cache.js +2 -0
- package/dist/internal/Cache.js.map +1 -1
- package/dist/internal/EarnRates.d.ts +26 -3
- package/dist/internal/EarnRates.d.ts.map +1 -1
- package/dist/internal/EarnRates.js +84 -19
- package/dist/internal/EarnRates.js.map +1 -1
- package/dist/internal/EarnSharePrices.d.ts +120 -0
- package/dist/internal/EarnSharePrices.d.ts.map +1 -0
- package/dist/internal/EarnSharePrices.js +179 -0
- package/dist/internal/EarnSharePrices.js.map +1 -0
- package/dist/internal/EarnVaults.d.ts +4 -0
- package/dist/internal/EarnVaults.d.ts.map +1 -1
- package/dist/internal/EarnVaults.js +31 -14
- package/dist/internal/EarnVaults.js.map +1 -1
- package/dist/internal/Email.d.ts +37 -0
- package/dist/internal/Email.d.ts.map +1 -0
- package/dist/internal/Email.js +16 -0
- package/dist/internal/Email.js.map +1 -0
- package/dist/internal/Log.d.ts +32 -28
- package/dist/internal/Log.d.ts.map +1 -1
- package/dist/internal/Log.js +18 -11
- package/dist/internal/Log.js.map +1 -1
- package/dist/internal/MetricSink.d.ts +3 -0
- package/dist/internal/MetricSink.d.ts.map +1 -1
- package/dist/internal/MetricSink.js +67 -8
- package/dist/internal/MetricSink.js.map +1 -1
- package/dist/internal/Mpp.d.ts.map +1 -1
- package/dist/internal/Mpp.js +20 -25
- package/dist/internal/Mpp.js.map +1 -1
- package/dist/internal/OpenApi.d.ts +26 -3
- package/dist/internal/OpenApi.d.ts.map +1 -1
- package/dist/internal/OpenApi.js +25 -10
- package/dist/internal/OpenApi.js.map +1 -1
- package/dist/internal/Provider.d.ts +1 -1
- package/dist/internal/Provider.d.ts.map +1 -1
- package/dist/internal/RateLimit.d.ts.map +1 -1
- package/dist/internal/RateLimit.js +13 -1
- package/dist/internal/RateLimit.js.map +1 -1
- package/dist/internal/Store.d.ts +16 -0
- package/dist/internal/Store.d.ts.map +1 -1
- package/dist/internal/Store.js +59 -8
- package/dist/internal/Store.js.map +1 -1
- package/dist/internal/Tidx.d.ts +9 -2
- package/dist/internal/Tidx.d.ts.map +1 -1
- package/dist/internal/Tidx.js +78 -11
- package/dist/internal/Tidx.js.map +1 -1
- package/dist/internal/Timing.d.ts +26 -0
- package/dist/internal/Timing.d.ts.map +1 -1
- package/dist/internal/Timing.js +63 -5
- package/dist/internal/Timing.js.map +1 -1
- package/dist/internal/VercelOidc.d.ts +94 -0
- package/dist/internal/VercelOidc.d.ts.map +1 -0
- package/dist/internal/VercelOidc.js +128 -0
- package/dist/internal/VercelOidc.js.map +1 -0
- package/dist/internal/VerifiedTokens.d.ts +2 -8
- package/dist/internal/VerifiedTokens.d.ts.map +1 -1
- package/dist/internal/VerifiedTokens.js +24 -24
- package/dist/internal/VerifiedTokens.js.map +1 -1
- package/dist/internal/Viem.d.ts +46 -2068
- package/dist/internal/Viem.d.ts.map +1 -1
- package/dist/internal/Viem.js +171 -11
- package/dist/internal/Viem.js.map +1 -1
- package/dist/internal/Webhooks.d.ts +12 -4
- package/dist/internal/Webhooks.d.ts.map +1 -1
- package/dist/internal/Webhooks.js +9 -3
- package/dist/internal/Webhooks.js.map +1 -1
- package/dist/internal/ZoneRpc.d.ts +7 -0
- package/dist/internal/ZoneRpc.d.ts.map +1 -0
- package/dist/internal/ZoneRpc.js +49 -0
- package/dist/internal/ZoneRpc.js.map +1 -0
- package/dist/internal/index.d.ts +3 -1
- package/dist/internal/index.d.ts.map +1 -1
- package/dist/internal/index.js +3 -1
- package/dist/internal/index.js.map +1 -1
- package/dist/internal/rewards/Audit.d.ts +88 -0
- package/dist/internal/rewards/Audit.d.ts.map +1 -0
- package/dist/internal/rewards/Audit.js +134 -0
- package/dist/internal/rewards/Audit.js.map +1 -0
- package/dist/internal/rewards/Campaigns.d.ts +572 -0
- package/dist/internal/rewards/Campaigns.d.ts.map +1 -0
- package/dist/internal/rewards/Campaigns.js +531 -0
- package/dist/internal/rewards/Campaigns.js.map +1 -0
- package/dist/internal/rewards/Credits.d.ts +76 -0
- package/dist/internal/rewards/Credits.d.ts.map +1 -0
- package/dist/internal/rewards/Credits.js +95 -0
- package/dist/internal/rewards/Credits.js.map +1 -0
- package/dist/internal/rewards/Events.d.ts +100 -0
- package/dist/internal/rewards/Events.d.ts.map +1 -0
- package/dist/internal/rewards/Events.js +340 -0
- package/dist/internal/rewards/Events.js.map +1 -0
- package/dist/internal/rewards/Projection.d.ts +237 -0
- package/dist/internal/rewards/Projection.d.ts.map +1 -0
- package/dist/internal/rewards/Projection.js +616 -0
- package/dist/internal/rewards/Projection.js.map +1 -0
- package/dist/internal/rewards/Rates.d.ts +44 -0
- package/dist/internal/rewards/Rates.d.ts.map +1 -0
- package/dist/internal/rewards/Rates.js +60 -0
- package/dist/internal/rewards/Rates.js.map +1 -0
- package/dist/internal/rewards/Read.d.ts +158 -0
- package/dist/internal/rewards/Read.d.ts.map +1 -0
- package/dist/internal/rewards/Read.js +292 -0
- package/dist/internal/rewards/Read.js.map +1 -0
- package/dist/internal/rewards/Runner.d.ts +164 -0
- package/dist/internal/rewards/Runner.d.ts.map +1 -0
- package/dist/internal/rewards/Runner.js +1778 -0
- package/dist/internal/rewards/Runner.js.map +1 -0
- package/dist/internal/rewards/Signer.d.ts +224 -0
- package/dist/internal/rewards/Signer.d.ts.map +1 -0
- package/dist/internal/rewards/Signer.js +135 -0
- package/dist/internal/rewards/Signer.js.map +1 -0
- package/dist/internal/rewards/index.d.ts +15 -0
- package/dist/internal/rewards/index.d.ts.map +1 -0
- package/dist/internal/rewards/index.js +15 -0
- package/dist/internal/rewards/index.js.map +1 -0
- package/dist/internal/{funding → routes}/Action.d.ts +12 -1
- package/dist/internal/routes/Action.d.ts.map +1 -0
- package/dist/internal/{funding → routes}/Action.js +17 -9
- package/dist/internal/routes/Action.js.map +1 -0
- package/dist/internal/{funding → routes}/Catalog.d.ts +20 -20
- package/dist/internal/routes/Catalog.d.ts.map +1 -0
- package/dist/internal/{funding → routes}/Catalog.js +29 -29
- package/dist/internal/routes/Catalog.js.map +1 -0
- package/dist/internal/{funding → routes}/Chain.d.ts +10 -10
- package/dist/internal/routes/Chain.d.ts.map +1 -0
- package/dist/internal/{funding → routes}/Chain.js +3 -3
- package/dist/internal/routes/Chain.js.map +1 -0
- package/dist/internal/{funding → routes}/Deposit.d.ts +45 -23
- package/dist/internal/routes/Deposit.d.ts.map +1 -0
- package/dist/internal/{funding → routes}/Deposit.js +60 -27
- package/dist/internal/routes/Deposit.js.map +1 -0
- package/dist/internal/{funding → routes}/DepositAddress.d.ts +56 -27
- package/dist/internal/routes/DepositAddress.d.ts.map +1 -0
- package/dist/internal/{funding → routes}/DepositAddress.js +95 -33
- package/dist/internal/routes/DepositAddress.js.map +1 -0
- package/dist/internal/{funding → routes}/DepositWebhook.d.ts +4 -4
- package/dist/internal/routes/DepositWebhook.d.ts.map +1 -0
- package/dist/internal/{funding → routes}/DepositWebhook.js +4 -3
- package/dist/internal/routes/DepositWebhook.js.map +1 -0
- package/dist/internal/routes/Economics.d.ts +25 -0
- package/dist/internal/routes/Economics.d.ts.map +1 -0
- package/dist/internal/routes/Economics.js +28 -0
- package/dist/internal/routes/Economics.js.map +1 -0
- package/dist/internal/{funding → routes}/Evidence.d.ts +3 -3
- package/dist/internal/routes/Evidence.d.ts.map +1 -0
- package/dist/internal/{funding → routes}/Evidence.js +9 -17
- package/dist/internal/routes/Evidence.js.map +1 -0
- package/dist/internal/routes/Observability.d.ts +154 -0
- package/dist/internal/routes/Observability.d.ts.map +1 -0
- package/dist/internal/routes/Observability.js +389 -0
- package/dist/internal/routes/Observability.js.map +1 -0
- package/dist/internal/{funding → routes}/Provider.d.ts +350 -104
- package/dist/internal/routes/Provider.d.ts.map +1 -0
- package/dist/internal/{funding → routes}/Provider.js +233 -97
- package/dist/internal/routes/Provider.js.map +1 -0
- package/dist/internal/{funding → routes}/Reconciliation.d.ts +11 -6
- package/dist/internal/routes/Reconciliation.d.ts.map +1 -0
- package/dist/internal/{funding → routes}/Reconciliation.js +408 -158
- package/dist/internal/routes/Reconciliation.js.map +1 -0
- package/dist/internal/routes/Route.d.ts +21 -0
- package/dist/internal/routes/Route.d.ts.map +1 -0
- package/dist/internal/{funding → routes}/Route.js +1 -1
- package/dist/internal/routes/Route.js.map +1 -0
- package/dist/internal/{funding → routes}/SourceObservation.d.ts +6 -6
- package/dist/internal/routes/SourceObservation.d.ts.map +1 -0
- package/dist/internal/{funding → routes}/SourceObservation.js +13 -15
- package/dist/internal/routes/SourceObservation.js.map +1 -0
- package/dist/internal/{funding → routes}/Subsidy.d.ts +48 -3
- package/dist/internal/routes/Subsidy.d.ts.map +1 -0
- package/dist/internal/{funding → routes}/Subsidy.js +43 -3
- package/dist/internal/routes/Subsidy.js.map +1 -0
- package/dist/internal/{funding → routes}/Token.d.ts +4 -4
- package/dist/internal/routes/Token.d.ts.map +1 -0
- package/dist/internal/{funding → routes}/Token.js +3 -3
- package/dist/internal/routes/Token.js.map +1 -0
- package/dist/internal/{funding → routes}/Transfer.d.ts +324 -34
- package/dist/internal/routes/Transfer.d.ts.map +1 -0
- package/dist/internal/routes/Transfer.js +728 -0
- package/dist/internal/routes/Transfer.js.map +1 -0
- package/dist/internal/routes/TransferReconciliation.d.ts +55 -0
- package/dist/internal/routes/TransferReconciliation.d.ts.map +1 -0
- package/dist/internal/routes/TransferReconciliation.js +422 -0
- package/dist/internal/routes/TransferReconciliation.js.map +1 -0
- package/dist/internal/routes/TransferSubsidy.d.ts +201 -0
- package/dist/internal/routes/TransferSubsidy.d.ts.map +1 -0
- package/dist/internal/routes/TransferSubsidy.js +256 -0
- package/dist/internal/routes/TransferSubsidy.js.map +1 -0
- package/dist/internal/routes/TransferWebhook.d.ts +21 -0
- package/dist/internal/routes/TransferWebhook.d.ts.map +1 -0
- package/dist/internal/routes/TransferWebhook.js +43 -0
- package/dist/internal/routes/TransferWebhook.js.map +1 -0
- package/dist/internal/{funding → routes}/index.d.ts +3 -0
- package/dist/internal/routes/index.d.ts.map +1 -0
- package/dist/internal/{funding → routes}/index.js +3 -0
- package/dist/internal/routes/index.js.map +1 -0
- package/dist/internal/{funding → routes}/providers/across.d.ts +4 -4
- package/dist/internal/routes/providers/across.d.ts.map +1 -0
- package/dist/internal/{funding → routes}/providers/across.js +13 -13
- package/dist/internal/routes/providers/across.js.map +1 -0
- package/dist/internal/{funding → routes}/providers/relay.d.ts +21 -12
- package/dist/internal/routes/providers/relay.d.ts.map +1 -0
- package/dist/internal/{funding → routes}/providers/relay.js +197 -122
- package/dist/internal/routes/providers/relay.js.map +1 -0
- package/dist/internal/{funding → routes}/providers/rhino.d.ts +4 -4
- package/dist/internal/routes/providers/rhino.d.ts.map +1 -0
- package/dist/internal/{funding → routes}/providers/rhino.js +10 -10
- package/dist/internal/routes/providers/rhino.js.map +1 -0
- package/dist/internal/{funding → routes}/providers/squid.d.ts +4 -4
- package/dist/internal/routes/providers/squid.d.ts.map +1 -0
- package/dist/internal/{funding → routes}/providers/squid.js +14 -14
- package/dist/internal/routes/providers/squid.js.map +1 -0
- package/dist/internal/routes/providers/stargate.d.ts +165 -0
- package/dist/internal/routes/providers/stargate.d.ts.map +1 -0
- package/dist/internal/routes/providers/stargate.js +898 -0
- package/dist/internal/routes/providers/stargate.js.map +1 -0
- package/dist/internal/{funding → routes}/providers/symbiosis.d.ts +4 -4
- package/dist/internal/routes/providers/symbiosis.d.ts.map +1 -0
- package/dist/internal/{funding → routes}/providers/symbiosis.js +30 -20
- package/dist/internal/routes/providers/symbiosis.js.map +1 -0
- package/dist/internal/webhookDestinations/slack.d.ts.map +1 -1
- package/dist/internal/webhookDestinations/slack.js +22 -6
- package/dist/internal/webhookDestinations/slack.js.map +1 -1
- package/dist/providers/index.d.ts +12 -12
- package/dist/providers/index.d.ts.map +1 -1
- package/dist/providers/index.js +12 -12
- package/dist/providers/index.js.map +1 -1
- package/dist/server.d.ts +19 -0
- package/dist/server.d.ts.map +1 -0
- package/dist/server.js +19 -0
- package/dist/server.js.map +1 -0
- package/package.json +15 -4
- package/src/ApiKey.ts +1 -1
- package/src/ApiKeys.test.ts +1033 -3
- package/src/ApiKeys.ts +489 -48
- package/src/App.test-d.ts +1 -1
- package/src/App.test.ts +216 -25
- package/src/App.ts +335 -31
- package/src/Assets.test.ts +2 -2
- package/src/Assets.ts +3 -1
- package/src/Auth.test-d.ts +1 -1
- package/src/Client.test-d.ts +611 -101
- package/src/Handler.ts +0 -1
- package/src/OpenApi.contract.test.ts +195 -0
- package/src/Scope.ts +17 -5
- package/src/Webhooks.ts +2 -2
- package/src/admin/App.test.ts +30 -2
- package/src/admin/App.ts +42 -6
- package/src/admin/apps/api-keys.test.ts +267 -5
- package/src/admin/apps/api-keys.ts +100 -50
- package/src/admin/apps/earn-vaults.test.ts +158 -0
- package/src/admin/apps/earn-vaults.ts +681 -7
- package/src/admin/apps/organizations.test.ts +342 -1
- package/src/admin/apps/organizations.ts +368 -8
- package/src/admin/apps/routes-support.test.ts +200 -0
- package/src/admin/apps/routes-support.ts +201 -0
- package/src/admin/apps/routes.test.ts +450 -0
- package/src/admin/apps/routes.ts +896 -0
- package/src/admin/apps/scopes.test.ts +15 -5
- package/src/admin/apps/subsidies.test.ts +306 -0
- package/src/admin/apps/subsidies.ts +457 -0
- package/src/admin/apps/verified-tokens.test.ts +8 -3
- package/src/admin/apps/verified-tokens.ts +3 -3
- package/src/admin/ui/plugin.ts +1 -2
- package/src/admin/ui/src/components/RewardCampaignForm.tsx +1009 -0
- package/src/admin/ui/src/lib/config.ts +11 -2
- package/src/admin/ui/src/lib/earn-vaults.ts +2 -2
- package/src/admin/ui/src/lib/organizations.test.ts +147 -3
- package/src/admin/ui/src/lib/organizations.ts +136 -0
- package/src/admin/ui/src/lib/query-client.ts +1 -1
- package/src/admin/ui/src/lib/reward-campaigns.ts +136 -0
- package/src/admin/ui/src/lib/routes.test.ts +88 -0
- package/src/admin/ui/src/lib/routes.ts +304 -0
- package/src/admin/ui/src/lib/subsidies.ts +75 -0
- package/src/admin/ui/src/routeTree.gen.ts +63 -0
- package/src/admin/ui/src/routes/__root.tsx +12 -1
- package/src/admin/ui/src/routes/api-keys.tsx +196 -84
- package/src/admin/ui/src/routes/earn.vaults_.$vaultId.edit.tsx +105 -70
- package/src/admin/ui/src/routes/organizations_.$orgId.tsx +334 -2
- package/src/admin/ui/src/routes/routes.tsx +1615 -0
- package/src/admin/ui/src/routes/routes_.support.tsx +248 -0
- package/src/admin/ui/src/routes/subsidies.tsx +799 -0
- package/src/admin/ui.generated.ts +144 -69
- package/src/analytics/Analytics.test.ts +108 -18
- package/src/analytics/Analytics.ts +38 -6
- package/src/analytics/tables/requestEvents.test.ts +100 -0
- package/src/analytics/tables/requestEvents.ts +10 -1
- package/src/analytics/tables/routesLifecycleIntervals.ts +140 -0
- package/src/apps/Zones.test.ts +18 -3
- package/src/apps/Zones.ts +55 -8
- package/src/apps/composition.test.ts +68 -59
- package/src/apps/data/App.test.ts +154 -2
- package/src/apps/data/App.ts +102 -33
- package/src/apps/data/routes/activities.test.ts +419 -7
- package/src/apps/data/routes/activities.ts +683 -216
- package/src/apps/data/routes/balances.test.ts +2 -2
- package/src/apps/data/routes/blocks.test.ts +46 -1
- package/src/apps/data/routes/coingecko.test.ts +419 -1
- package/src/apps/data/routes/coingecko.ts +309 -253
- package/src/apps/data/routes/earn.discovery.test.ts +274 -0
- package/src/apps/data/routes/earn.test.ts +1661 -29
- package/src/apps/data/routes/earn.ts +2314 -328
- package/src/apps/data/routes/exchanges.test.ts +752 -30
- package/src/apps/data/routes/exchanges.ts +954 -753
- package/src/apps/data/routes/fee-amm.test.ts +224 -0
- package/src/apps/data/routes/fee-amm.ts +208 -178
- package/src/apps/data/routes/indexer.test.ts +389 -0
- package/src/apps/data/routes/indexer.ts +165 -69
- package/src/apps/data/routes/receipts.test.ts +1 -1
- package/src/apps/data/routes/rpc.test.ts +352 -8
- package/src/apps/data/routes/rpc.ts +407 -219
- package/src/apps/data/routes/rpc.zone.test.ts +340 -0
- package/src/apps/data/routes/tokenlist.test.ts +285 -0
- package/src/apps/data/routes/tokenlist.ts +173 -88
- package/src/apps/data/routes/tokens.test.ts +93 -3
- package/src/apps/data/routes/tokens.ts +39 -23
- package/src/apps/data/routes/transactions.test.ts +1 -1
- package/src/apps/data/routes/transfers.test.ts +56 -24
- package/src/apps/data/routes/transfers.ts +19 -8
- package/src/apps/data/routes/valuation.test.ts +1 -1
- package/src/apps/data/routes/verified-tokens.test.ts +345 -0
- package/src/apps/data/routes/verified-tokens.ts +99 -29
- package/src/apps/data/routes/webhooks.test.ts +659 -81
- package/src/apps/data/routes/webhooks.ts +1104 -817
- package/src/apps/data/routes/zones.test.ts +148 -71
- package/src/apps/data/routes/zones.ts +71 -55
- package/src/apps/docs/reference.ts +2 -2
- package/src/apps/index.ts +1 -1
- package/src/apps/management/App.ts +9 -51
- package/src/apps/management/Billing.test.ts +375 -14
- package/src/apps/management/Billing.ts +283 -34
- package/src/apps/management/routes/api-keys.test.ts +269 -7
- package/src/apps/management/routes/api-keys.ts +61 -20
- package/src/apps/management/routes/billing.test.ts +477 -15
- package/src/apps/management/routes/billing.ts +377 -50
- package/src/apps/management/routes/faucet.test.ts +1 -1
- package/src/apps/management/routes/faucet.ts +1 -1
- package/src/apps/management/routes/invitations.test.ts +270 -3
- package/src/apps/management/routes/invitations.ts +185 -15
- package/src/apps/management/routes/invoicePreview.test.ts +549 -0
- package/src/apps/management/routes/me.test.ts +246 -5
- package/src/apps/management/routes/me.ts +7 -2
- package/src/apps/management/routes/members.test.ts +108 -0
- package/src/apps/management/routes/orgs.test.ts +191 -3
- package/src/apps/management/routes/orgs.ts +58 -11
- package/src/apps/management/routes/projects.test.ts +33 -3
- package/src/apps/management/routes/projects.ts +6 -1
- package/src/apps/management/routes/scopes.test.ts +30 -2
- package/src/apps/management/routes/scopes.ts +4 -1
- package/src/apps/management/routes/usage.test.ts +32 -0
- package/src/apps/management/routes/usage.ts +22 -4
- package/src/apps/management/routes/webhooks.test.ts +49 -26
- package/src/apps/management/routes/webhooks.ts +93 -38
- package/src/apps/mcp.test.ts +6 -6
- package/src/apps/mcp.ts +7 -7
- package/src/apps/mpp/App.ts +37 -7
- package/src/apps/mpp/Mpp.test.ts +49 -8
- package/src/apps/mpp/Mpp.zone.test.ts +219 -0
- package/src/apps/mpp/internal/Adapter.ts +34 -0
- package/src/apps/mpp/internal/Policy.test.ts +86 -31
- package/src/apps/mpp/internal/Policy.ts +49 -7
- package/src/apps/mpp/internal/Sponsorship.test.ts +207 -0
- package/src/apps/mpp/internal/Sponsorship.ts +9 -3
- package/src/apps/relay/App.test.ts +1024 -38
- package/src/apps/relay/App.ts +228 -32
- package/src/apps/relay/App.zone-billing.test.ts +257 -0
- package/src/apps/relay/Sponsorships.test.ts +67 -4
- package/src/apps/relay/Sponsorships.ts +253 -29
- package/src/apps/relay/Sponsorships.zone.test.ts +102 -0
- package/src/apps/{funding → routes}/Access.ts +6 -6
- package/src/apps/routes/App.test.ts +165 -0
- package/src/apps/routes/App.ts +96 -0
- package/src/apps/{funding → routes}/Inventory.ts +2 -2
- package/src/apps/routes/index.ts +1 -0
- package/src/apps/{funding → routes}/routes/chains.test.ts +66 -66
- package/src/apps/{funding → routes}/routes/chains.ts +23 -23
- package/src/apps/{funding → routes}/routes/deposit-addresses.test.ts +1362 -462
- package/src/apps/{funding → routes}/routes/deposit-addresses.ts +568 -248
- package/src/apps/{funding → routes}/routes/providers.test.ts +27 -33
- package/src/apps/{funding → routes}/routes/providers.ts +23 -23
- package/src/apps/{funding → routes}/routes/quotes.test.ts +298 -41
- package/src/apps/{funding → routes}/routes/quotes.ts +57 -40
- package/src/apps/routes/routes/transfers.test.ts +2876 -0
- package/src/apps/routes/routes/transfers.ts +1332 -0
- package/src/cli/Cli.test.ts +1 -1
- package/src/cli/commands/admin.test.ts +748 -1
- package/src/cli/commands/admin.ts +278 -0
- package/src/cloudflare.ts +52 -47
- package/src/db/Db.test.ts +245 -2
- package/src/db/Db.ts +1511 -34
- package/src/db/Schema.ts +744 -228
- package/src/db/tables/apiKeyAdmissionBootstraps.ts +4 -0
- package/src/db/tables/apiKeyAdmissions.ts +218 -0
- package/src/db/tables/apiKeyOwnerAdmissions.ts +4 -0
- package/src/db/tables/apiKeyOwnerTombstones.ts +81 -0
- package/src/db/tables/apiKeyRevocations.test.ts +74 -0
- package/src/db/tables/apiKeyRevocations.ts +121 -0
- package/src/db/tables/authAccounts.ts +105 -0
- package/src/db/tables/authSessions.ts +13 -0
- package/src/db/tables/authVerifications.ts +13 -0
- package/src/db/tables/invitations.ts +142 -45
- package/src/db/tables/memberships.ts +79 -3
- package/src/db/tables/organizations.test.ts +725 -7
- package/src/db/tables/organizations.ts +182 -49
- package/src/db/tables/projects.test.ts +71 -0
- package/src/db/tables/projects.ts +59 -4
- package/src/db/tables/requestUsage.ts +4 -1
- package/src/db/tables/rewardAccounts.ts +178 -0
- package/src/db/tables/rewardCampaignDistributors.ts +68 -0
- package/src/db/tables/rewardCampaigns.test.ts +1388 -0
- package/src/db/tables/rewardCampaigns.ts +647 -0
- package/src/db/tables/rewardCredits.ts +110 -0
- package/src/db/tables/rewardEligibilityAssociations.test.ts +271 -0
- package/src/db/tables/rewardEligibilityAssociations.ts +184 -0
- package/src/db/tables/rewardRuns.ts +514 -0
- package/src/db/tables/rewardTransactionAttempts.ts +272 -0
- package/src/db/tables/routesCatalog.test.ts +185 -0
- package/src/db/tables/routesCatalog.ts +163 -0
- package/src/db/tables/routesDepositAddresses.test.ts +1048 -0
- package/src/db/tables/routesDepositAddresses.ts +1008 -0
- package/src/db/tables/{fundingDepositRequestObservations.test.ts → routesDepositRequestObservations.test.ts} +13 -14
- package/src/db/tables/{fundingDepositRequestObservations.ts → routesDepositRequestObservations.ts} +10 -10
- package/src/db/tables/{fundingDeposits.test.ts → routesDeposits.test.ts} +316 -46
- package/src/db/tables/routesDeposits.ts +1062 -0
- package/src/db/tables/routesIdempotency.test.ts +796 -0
- package/src/db/tables/routesIdempotency.ts +496 -0
- package/src/db/tables/routesSubsidies.test.ts +120 -0
- package/src/db/tables/routesSubsidies.ts +71 -0
- package/src/db/tables/{fundingTransferEvents.ts → routesTransferEvents.ts} +4 -4
- package/src/db/tables/routesTransferSubsidies.ts +38 -0
- package/src/db/tables/routesTransferSubsidyNonces.ts +124 -0
- package/src/db/tables/routesTransferTransactions.test.ts +195 -0
- package/src/db/tables/routesTransferTransactions.ts +158 -0
- package/src/db/tables/routesTransfers.test.ts +338 -0
- package/src/db/tables/routesTransfers.ts +662 -0
- package/src/db/tables/sponsoredTransactions.test.ts +563 -1
- package/src/db/tables/sponsoredTransactions.ts +386 -42
- package/src/db/tables/sponsorshipAttributions.test.ts +160 -0
- package/src/db/tables/sponsorshipAttributions.ts +168 -0
- package/src/db/tables/sponsorshipReconciliationCursors.test.ts +115 -0
- package/src/db/tables/sponsorshipReconciliationCursors.ts +67 -0
- package/src/db/tables/stripeCustomers.test.ts +85 -0
- package/src/db/tables/stripeCustomers.ts +24 -0
- package/src/db/tables/users.test.ts +129 -0
- package/src/db/tables/users.ts +49 -3
- package/src/db/tables/webhookQueueEvents.ts +8 -1
- package/src/db/tables/webhookSubscriptions.ts +103 -21
- package/src/handlers/internal/executionError.ts +3 -4
- package/src/handlers/internal/multisig.ts +13 -816
- package/src/handlers/internal/sponsorship.ts +26 -10
- package/src/handlers/relay.test-d.ts +9 -1
- package/src/handlers/relay.test.ts +823 -3
- package/src/handlers/relay.ts +127 -107
- package/src/index.test-d.ts +7 -0
- package/src/index.ts +0 -17
- package/src/internal/AssetResponse.ts +26 -0
- package/src/internal/Auth.test.ts +1564 -9
- package/src/internal/Auth.ts +833 -239
- package/src/internal/BetterAuth.test.ts +242 -0
- package/src/internal/BetterAuth.ts +349 -0
- package/src/internal/Cache.ts +2 -0
- package/src/internal/EarnRates.test.ts +17 -0
- package/src/internal/EarnRates.ts +124 -31
- package/src/internal/EarnSharePrices.test.ts +182 -0
- package/src/internal/EarnSharePrices.ts +313 -0
- package/src/internal/EarnVaults.test.ts +21 -0
- package/src/internal/EarnVaults.ts +37 -15
- package/src/internal/Email.ts +54 -0
- package/src/internal/Idempotency.test.ts +2 -2
- package/src/internal/Log.test-d.ts +10 -7
- package/src/internal/Log.test.ts +114 -16
- package/src/internal/Log.ts +55 -40
- package/src/internal/MetricSink.test.ts +313 -26
- package/src/internal/MetricSink.ts +73 -8
- package/src/internal/Mpp.test.ts +31 -0
- package/src/internal/Mpp.ts +21 -24
- package/src/internal/OpenApi.ts +45 -12
- package/src/internal/Provider.test.ts +1 -1
- package/src/internal/Provider.ts +1 -1
- package/src/internal/RateLimit.test.ts +21 -3
- package/src/internal/RateLimit.ts +12 -1
- package/src/internal/Store.test-d.ts +1 -1
- package/src/internal/Store.test.ts +151 -8
- package/src/internal/Store.ts +76 -9
- package/src/internal/Tidx.test.ts +59 -8
- package/src/internal/Tidx.ts +86 -14
- package/src/internal/Timing.test.ts +77 -0
- package/src/internal/Timing.ts +83 -6
- package/src/internal/VercelOidc.test.ts +188 -0
- package/src/internal/VercelOidc.ts +193 -0
- package/src/internal/VerifiedTokens.test.ts +60 -6
- package/src/internal/VerifiedTokens.ts +21 -24
- package/src/internal/Viem.batch.test.ts +80 -0
- package/src/internal/Viem.test.ts +201 -2
- package/src/internal/Viem.ts +249 -17
- package/src/internal/Webhooks.test.ts +125 -1
- package/src/internal/Webhooks.ts +22 -4
- package/src/internal/ZoneRpc.ts +50 -0
- package/src/internal/exchange/Provider.test.ts +2 -2
- package/src/internal/index.test.ts +3 -1
- package/src/internal/index.ts +3 -1
- package/src/internal/rewards/Audit.ts +231 -0
- package/src/internal/rewards/Campaigns.test.ts +1234 -0
- package/src/internal/rewards/Campaigns.ts +1205 -0
- package/src/internal/rewards/Credits.ts +165 -0
- package/src/internal/rewards/Events.local.test.ts +113 -0
- package/src/internal/rewards/Events.test.ts +152 -0
- package/src/internal/rewards/Events.ts +468 -0
- package/src/internal/rewards/Projection.test.ts +681 -0
- package/src/internal/rewards/Projection.ts +987 -0
- package/src/internal/rewards/Rates.test.ts +171 -0
- package/src/internal/rewards/Rates.ts +110 -0
- package/src/internal/rewards/Read.test.ts +501 -0
- package/src/internal/rewards/Read.ts +476 -0
- package/src/internal/rewards/Runner.checkpoint.test.ts +80 -0
- package/src/internal/rewards/Runner.states.test.ts +188 -0
- package/src/internal/rewards/Runner.test.ts +90 -0
- package/src/internal/rewards/Runner.ts +2229 -0
- package/src/internal/rewards/Signer.test.ts +79 -0
- package/src/internal/rewards/Signer.ts +180 -0
- package/src/internal/rewards/index.ts +14 -0
- package/src/internal/{funding → routes}/Action.test.ts +63 -14
- package/src/internal/{funding → routes}/Action.ts +35 -8
- package/src/internal/{funding → routes}/Catalog.test.ts +3 -3
- package/src/internal/{funding → routes}/Catalog.ts +39 -39
- package/src/internal/{funding → routes}/Chain.test.ts +1 -1
- package/src/internal/{funding → routes}/Chain.ts +11 -11
- package/src/internal/{funding → routes}/Deposit.test.ts +1 -1
- package/src/internal/{funding → routes}/Deposit.ts +93 -45
- package/src/internal/{funding → routes}/DepositAddress.test.ts +11 -3
- package/src/internal/{funding → routes}/DepositAddress.ts +132 -53
- package/src/internal/{funding → routes}/DepositWebhook.test.ts +61 -18
- package/src/internal/{funding → routes}/DepositWebhook.ts +9 -8
- package/src/internal/routes/Economics.test.ts +42 -0
- package/src/internal/routes/Economics.ts +47 -0
- package/src/internal/{funding → routes}/Evidence.test.ts +6 -6
- package/src/internal/{funding → routes}/Evidence.ts +11 -22
- package/src/internal/routes/Observability.test.ts +636 -0
- package/src/internal/routes/Observability.ts +668 -0
- package/src/internal/{funding → routes}/Provider.test.ts +489 -153
- package/src/internal/{funding → routes}/Provider.ts +531 -185
- package/src/internal/{funding → routes}/Reconciliation.local.test.ts +84 -12
- package/src/internal/{funding → routes}/Reconciliation.test.ts +1213 -279
- package/src/internal/{funding → routes}/Reconciliation.ts +501 -203
- package/src/internal/routes/Reconciliation.unattributed.test.ts +250 -0
- package/src/internal/{funding → routes}/Route.ts +7 -7
- package/src/internal/{funding → routes}/SourceObservation.test.ts +13 -14
- package/src/internal/{funding → routes}/SourceObservation.ts +18 -22
- package/src/internal/{funding → routes}/Subsidy.local.test.ts +7 -7
- package/src/internal/routes/Subsidy.test.ts +169 -0
- package/src/internal/{funding → routes}/Subsidy.ts +86 -6
- package/src/internal/{funding → routes}/Token.test.ts +1 -1
- package/src/internal/{funding → routes}/Token.ts +5 -5
- package/src/internal/routes/Transfer.test.ts +1199 -0
- package/src/internal/routes/Transfer.ts +1206 -0
- package/src/internal/routes/TransferReconciliation.test.ts +731 -0
- package/src/internal/routes/TransferReconciliation.ts +527 -0
- package/src/internal/routes/TransferSubsidy.test.ts +172 -0
- package/src/internal/routes/TransferSubsidy.ts +447 -0
- package/src/internal/routes/TransferWebhook.test.ts +128 -0
- package/src/internal/routes/TransferWebhook.ts +67 -0
- package/src/internal/{funding → routes}/index.test.ts +6 -3
- package/src/internal/{funding → routes}/index.ts +3 -0
- package/src/internal/{funding → routes}/providers/across.ts +16 -16
- package/src/internal/{funding → routes}/providers/index.test.ts +157 -44
- package/src/internal/{funding → routes}/providers/relay.test.ts +165 -32
- package/src/internal/{funding → routes}/providers/relay.ts +231 -136
- package/src/internal/{funding → routes}/providers/rhino.ts +16 -16
- package/src/internal/{funding → routes}/providers/squid.ts +17 -17
- package/src/internal/routes/providers/stargate.test.ts +728 -0
- package/src/internal/routes/providers/stargate.ts +1276 -0
- package/src/internal/{funding → routes}/providers/symbiosis.ts +64 -24
- package/src/internal/webhookDestinations/slack.ts +20 -5
- package/src/providers/index.ts +13 -13
- package/src/server.ts +18 -0
- package/dist/apps/funding/Access.d.ts.map +0 -1
- package/dist/apps/funding/Access.js.map +0 -1
- package/dist/apps/funding/App.js.map +0 -1
- package/dist/apps/funding/Inventory.d.ts.map +0 -1
- package/dist/apps/funding/Inventory.js.map +0 -1
- package/dist/apps/funding/ProviderAttempts.d.ts +0 -5
- package/dist/apps/funding/ProviderAttempts.d.ts.map +0 -1
- package/dist/apps/funding/ProviderAttempts.js +0 -24
- package/dist/apps/funding/ProviderAttempts.js.map +0 -1
- package/dist/apps/funding/index.d.ts +0 -2
- package/dist/apps/funding/index.d.ts.map +0 -1
- package/dist/apps/funding/index.js +0 -2
- package/dist/apps/funding/index.js.map +0 -1
- package/dist/apps/funding/routes/chains.d.ts.map +0 -1
- package/dist/apps/funding/routes/chains.js.map +0 -1
- package/dist/apps/funding/routes/deposit-addresses.d.ts.map +0 -1
- package/dist/apps/funding/routes/deposit-addresses.js.map +0 -1
- package/dist/apps/funding/routes/providers.d.ts.map +0 -1
- package/dist/apps/funding/routes/providers.js +0 -57
- package/dist/apps/funding/routes/providers.js.map +0 -1
- package/dist/apps/funding/routes/quotes.d.ts.map +0 -1
- package/dist/apps/funding/routes/quotes.js.map +0 -1
- package/dist/apps/funding/routes/transfers.d.ts.map +0 -1
- package/dist/apps/funding/routes/transfers.js +0 -622
- package/dist/apps/funding/routes/transfers.js.map +0 -1
- package/dist/db/tables/fundingCatalog.d.ts +0 -58
- package/dist/db/tables/fundingCatalog.d.ts.map +0 -1
- package/dist/db/tables/fundingCatalog.js.map +0 -1
- package/dist/db/tables/fundingDepositAddresses.d.ts +0 -192
- package/dist/db/tables/fundingDepositAddresses.d.ts.map +0 -1
- package/dist/db/tables/fundingDepositAddresses.js +0 -235
- package/dist/db/tables/fundingDepositAddresses.js.map +0 -1
- package/dist/db/tables/fundingDepositRequestObservations.d.ts.map +0 -1
- package/dist/db/tables/fundingDepositRequestObservations.js.map +0 -1
- package/dist/db/tables/fundingDeposits.d.ts.map +0 -1
- package/dist/db/tables/fundingDeposits.js +0 -295
- package/dist/db/tables/fundingDeposits.js.map +0 -1
- package/dist/db/tables/fundingIdempotency.d.ts +0 -91
- package/dist/db/tables/fundingIdempotency.d.ts.map +0 -1
- package/dist/db/tables/fundingIdempotency.js +0 -103
- package/dist/db/tables/fundingIdempotency.js.map +0 -1
- package/dist/db/tables/fundingTransferEvents.d.ts.map +0 -1
- package/dist/db/tables/fundingTransferEvents.js.map +0 -1
- package/dist/db/tables/fundingTransferTransactions.d.ts +0 -15
- package/dist/db/tables/fundingTransferTransactions.d.ts.map +0 -1
- package/dist/db/tables/fundingTransferTransactions.js +0 -27
- package/dist/db/tables/fundingTransferTransactions.js.map +0 -1
- package/dist/db/tables/fundingTransfers.d.ts +0 -82
- package/dist/db/tables/fundingTransfers.d.ts.map +0 -1
- package/dist/db/tables/fundingTransfers.js +0 -89
- package/dist/db/tables/fundingTransfers.js.map +0 -1
- package/dist/internal/funding/Action.d.ts.map +0 -1
- package/dist/internal/funding/Action.js.map +0 -1
- package/dist/internal/funding/Catalog.d.ts.map +0 -1
- package/dist/internal/funding/Catalog.js.map +0 -1
- package/dist/internal/funding/Chain.d.ts.map +0 -1
- package/dist/internal/funding/Chain.js.map +0 -1
- package/dist/internal/funding/Deposit.d.ts.map +0 -1
- package/dist/internal/funding/Deposit.js.map +0 -1
- package/dist/internal/funding/DepositAddress.d.ts.map +0 -1
- package/dist/internal/funding/DepositAddress.js.map +0 -1
- package/dist/internal/funding/DepositWebhook.d.ts.map +0 -1
- package/dist/internal/funding/DepositWebhook.js.map +0 -1
- package/dist/internal/funding/Evidence.d.ts.map +0 -1
- package/dist/internal/funding/Evidence.js.map +0 -1
- package/dist/internal/funding/Provider.d.ts.map +0 -1
- package/dist/internal/funding/Provider.js.map +0 -1
- package/dist/internal/funding/Reconciliation.d.ts.map +0 -1
- package/dist/internal/funding/Reconciliation.js.map +0 -1
- package/dist/internal/funding/Route.d.ts +0 -21
- package/dist/internal/funding/Route.d.ts.map +0 -1
- package/dist/internal/funding/Route.js.map +0 -1
- package/dist/internal/funding/SourceObservation.d.ts.map +0 -1
- package/dist/internal/funding/SourceObservation.js.map +0 -1
- package/dist/internal/funding/Subsidy.d.ts.map +0 -1
- package/dist/internal/funding/Subsidy.js.map +0 -1
- package/dist/internal/funding/Token.d.ts.map +0 -1
- package/dist/internal/funding/Token.js.map +0 -1
- package/dist/internal/funding/Transfer.d.ts.map +0 -1
- package/dist/internal/funding/Transfer.js +0 -334
- package/dist/internal/funding/Transfer.js.map +0 -1
- package/dist/internal/funding/index.d.ts.map +0 -1
- package/dist/internal/funding/index.js.map +0 -1
- package/dist/internal/funding/providers/across.d.ts.map +0 -1
- package/dist/internal/funding/providers/across.js.map +0 -1
- package/dist/internal/funding/providers/relay.d.ts.map +0 -1
- package/dist/internal/funding/providers/relay.js.map +0 -1
- package/dist/internal/funding/providers/rhino.d.ts.map +0 -1
- package/dist/internal/funding/providers/rhino.js.map +0 -1
- package/dist/internal/funding/providers/squid.d.ts.map +0 -1
- package/dist/internal/funding/providers/squid.js.map +0 -1
- package/dist/internal/funding/providers/stargate.d.ts +0 -38
- package/dist/internal/funding/providers/stargate.d.ts.map +0 -1
- package/dist/internal/funding/providers/stargate.js +0 -277
- package/dist/internal/funding/providers/stargate.js.map +0 -1
- package/dist/internal/funding/providers/symbiosis.d.ts.map +0 -1
- package/dist/internal/funding/providers/symbiosis.js.map +0 -1
- package/src/apps/funding/App.test.ts +0 -78
- package/src/apps/funding/App.ts +0 -78
- package/src/apps/funding/ProviderAttempts.ts +0 -26
- package/src/apps/funding/index.ts +0 -1
- package/src/apps/funding/routes/transfers.test.ts +0 -1638
- package/src/apps/funding/routes/transfers.ts +0 -721
- package/src/db/tables/fundingCatalog.test.ts +0 -122
- package/src/db/tables/fundingCatalog.ts +0 -163
- package/src/db/tables/fundingDepositAddresses.test.ts +0 -608
- package/src/db/tables/fundingDepositAddresses.ts +0 -443
- package/src/db/tables/fundingDeposits.ts +0 -572
- package/src/db/tables/fundingIdempotency.test.ts +0 -182
- package/src/db/tables/fundingIdempotency.ts +0 -180
- package/src/db/tables/fundingTransferTransactions.test.ts +0 -69
- package/src/db/tables/fundingTransferTransactions.ts +0 -37
- package/src/db/tables/fundingTransfers.test.ts +0 -89
- package/src/db/tables/fundingTransfers.ts +0 -153
- package/src/handlers/internal/multisig.test.ts +0 -818
- package/src/internal/funding/Subsidy.test.ts +0 -75
- package/src/internal/funding/Transfer.test.ts +0 -369
- package/src/internal/funding/Transfer.ts +0 -545
- package/src/internal/funding/providers/stargate.test.ts +0 -163
- package/src/internal/funding/providers/stargate.ts +0 -409
- /package/dist/apps/{funding → routes}/Inventory.d.ts +0 -0
- /package/src/internal/{funding → routes}/Route.test.ts +0 -0
|
@@ -0,0 +1,2876 @@
|
|
|
1
|
+
import { AbiFunction, Hex, Value } from 'ox'
|
|
2
|
+
import { decodeFunctionData, erc20Abi, maxUint256 } from 'viem'
|
|
3
|
+
import { base } from 'viem/chains'
|
|
4
|
+
import { tempoMainnet } from 'viem/tempo/chains'
|
|
5
|
+
|
|
6
|
+
import * as Anvil from '../../../../test/Anvil.js'
|
|
7
|
+
import * as TestApp from '../../../../test/App.js'
|
|
8
|
+
import * as TestRoutes from '../../../../test/Routes.js'
|
|
9
|
+
import * as RoutesIdempotencyTable from '../../../db/tables/routesIdempotency.js'
|
|
10
|
+
import * as Organizations from '../../../db/tables/organizations.js'
|
|
11
|
+
import * as RoutesSubsidies from '../../../db/tables/routesSubsidies.js'
|
|
12
|
+
import * as StripeCustomers from '../../../db/tables/stripeCustomers.js'
|
|
13
|
+
import * as Cache from '../../../internal/Cache.js'
|
|
14
|
+
import type * as RoutesAction from '../../../internal/routes/Action.js'
|
|
15
|
+
import * as RoutesCatalog from '../../../internal/routes/Catalog.js'
|
|
16
|
+
import * as RoutesChain from '../../../internal/routes/Chain.js'
|
|
17
|
+
import type * as RoutesObservability from '../../../internal/routes/Observability.js'
|
|
18
|
+
import * as RoutesProvider from '../../../internal/routes/Provider.js'
|
|
19
|
+
import * as RoutesTransfer from '../../../internal/routes/Transfer.js'
|
|
20
|
+
import * as RoutesTransferReconciliation from '../../../internal/routes/TransferReconciliation.js'
|
|
21
|
+
import * as RoutesTransferSubsidy from '../../../internal/routes/TransferSubsidy.js'
|
|
22
|
+
import * as Idempotency from '../../../internal/Idempotency.js'
|
|
23
|
+
import type * as Log from '../../../internal/Log.js'
|
|
24
|
+
import * as Relay from '../../../internal/routes/providers/relay.js'
|
|
25
|
+
import * as Stargate from '../../../internal/routes/providers/stargate.js'
|
|
26
|
+
import * as Webhooks from '../../../internal/Webhooks.js'
|
|
27
|
+
import * as Routes from './transfers.js'
|
|
28
|
+
|
|
29
|
+
const db = TestApp.database()
|
|
30
|
+
const destinationTransactionHash =
|
|
31
|
+
'0x3dfaba0a78b8f4bc09e55e05211c8120729e7b6879efe32613883befbca666da'
|
|
32
|
+
|
|
33
|
+
/** Providers exercised against executable calls on a forked source chain. */
|
|
34
|
+
const executableProviders = [
|
|
35
|
+
{
|
|
36
|
+
create: (_sender: string) =>
|
|
37
|
+
Relay.relay(process.env.RELAY_API_KEY ? { apiKey: process.env.RELAY_API_KEY } : {}),
|
|
38
|
+
destinationToken: 'pathusd',
|
|
39
|
+
id: 'relay',
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
create: (_sender: string) => Stargate.stargate(),
|
|
43
|
+
destinationToken: 'usdce',
|
|
44
|
+
id: 'stargate',
|
|
45
|
+
},
|
|
46
|
+
] as const
|
|
47
|
+
const stargateConfiguration = TestRoutes.snapshot.routesByProvider
|
|
48
|
+
.get('stargate')!
|
|
49
|
+
.find((candidate) => candidate.route.source.chain.id === 'eip155:8453')!.configuration!
|
|
50
|
+
|
|
51
|
+
beforeAll(() => TestRoutes.publish(db))
|
|
52
|
+
|
|
53
|
+
function create(options: TestApp.create.Options = {}) {
|
|
54
|
+
return TestApp.create({ ...options, db: options.db ?? db })
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
type ContractResponse = {
|
|
58
|
+
$ref?: string | undefined
|
|
59
|
+
content?: Record<string, { schema: unknown }> | undefined
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
type JsonSchema = {
|
|
63
|
+
$ref?: string | undefined
|
|
64
|
+
additionalProperties?: boolean | undefined
|
|
65
|
+
description?: string | undefined
|
|
66
|
+
examples?: readonly unknown[] | undefined
|
|
67
|
+
properties?: Record<string, JsonSchema> | undefined
|
|
68
|
+
required?: readonly string[] | undefined
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
type ComponentSpec = {
|
|
72
|
+
components: { schemas: Record<string, JsonSchema> }
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
function dereference(spec: ComponentSpec, schema: JsonSchema): JsonSchema {
|
|
76
|
+
if (!schema.$ref) return schema
|
|
77
|
+
const name = schema.$ref.split('/').at(-1)!
|
|
78
|
+
return spec.components.schemas[name]!
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
describe('GET /routes/transfers', () => {
|
|
82
|
+
test('requires the routes:read scope', async () => {
|
|
83
|
+
const app = transfersApp()
|
|
84
|
+
expect((await app.request('/v1/routes/transfers')).status).toBe(401)
|
|
85
|
+
const forbidden = await app.request('/v1/routes/transfers', as(TestApp.key))
|
|
86
|
+
expect(forbidden.status).toBe(403)
|
|
87
|
+
})
|
|
88
|
+
|
|
89
|
+
test('pages own transfers newest-first', async () => {
|
|
90
|
+
const app = transfersApp()
|
|
91
|
+
const first = await seedTransfer()
|
|
92
|
+
const second = await seedTransfer()
|
|
93
|
+
const third = await seedTransfer()
|
|
94
|
+
await seedTransfer({ orgId: routesForeign.orgId })
|
|
95
|
+
|
|
96
|
+
const response = await app.request('/v1/routes/transfers?limit=5', {
|
|
97
|
+
headers: { 'tempo-api-key': routesReader.token },
|
|
98
|
+
})
|
|
99
|
+
expect(response.status).toBe(200)
|
|
100
|
+
expect(response.headers.get('cache-control')).toBe(Cache.policies.feed)
|
|
101
|
+
const etag = response.headers.get('etag') ?? ''
|
|
102
|
+
expect(etag).not.toBe('')
|
|
103
|
+
expect(response.headers.get('vary')).toBe(
|
|
104
|
+
'Accept-Encoding, Authorization, Tempo-API-Key, X-API-Key',
|
|
105
|
+
)
|
|
106
|
+
const body = await TestApp.json(response, Routes.schema.listRoutesTransfers.Response)
|
|
107
|
+
expect(body.data.map((transfer) => transfer.id)).toEqual([third.id, second.id, first.id])
|
|
108
|
+
expect(body.nextCursor).toBeNull()
|
|
109
|
+
expect(body.meta).toBeUndefined()
|
|
110
|
+
|
|
111
|
+
const unchanged = await app.request('/v1/routes/transfers?limit=5', {
|
|
112
|
+
headers: { 'if-none-match': etag, 'tempo-api-key': routesReader.token },
|
|
113
|
+
})
|
|
114
|
+
expect(unchanged.status).toBe(304)
|
|
115
|
+
expect(unchanged.headers.get('cache-control')).toBe(Cache.policies.feed)
|
|
116
|
+
expect(unchanged.headers.get('vary')).toBe(
|
|
117
|
+
'Accept-Encoding, Authorization, Tempo-API-Key, X-API-Key',
|
|
118
|
+
)
|
|
119
|
+
|
|
120
|
+
const paged = await TestApp.json(
|
|
121
|
+
await app.request(`/v1/routes/transfers?limit=5&cursor=${second.id}`, as(routesReader)),
|
|
122
|
+
Routes.schema.listRoutesTransfers.Response,
|
|
123
|
+
)
|
|
124
|
+
expect(paged.data.map((transfer) => transfer.id)).toEqual([first.id])
|
|
125
|
+
})
|
|
126
|
+
|
|
127
|
+
test('filters by status and embeds the capped count on request', async () => {
|
|
128
|
+
const app = transfersApp()
|
|
129
|
+
const expired = await seedTransfer()
|
|
130
|
+
await RoutesTransfer.transition(db, {
|
|
131
|
+
expectedVersion: 1,
|
|
132
|
+
id: expired.id,
|
|
133
|
+
status: 'expired',
|
|
134
|
+
})
|
|
135
|
+
|
|
136
|
+
const response = await app.request(
|
|
137
|
+
'/v1/routes/transfers?status=expired&include=totalCount',
|
|
138
|
+
as(routesReader),
|
|
139
|
+
)
|
|
140
|
+
const body = await TestApp.json(response, Routes.schema.listRoutesTransfers.Response)
|
|
141
|
+
expect(body.data.map((transfer) => transfer.id)).toEqual([expired.id])
|
|
142
|
+
expect(body.data[0]?.status).toBe('expired')
|
|
143
|
+
expect(body.meta).toEqual({ totalCount: 1, totalCountCapped: false })
|
|
144
|
+
})
|
|
145
|
+
|
|
146
|
+
test('narrows project-attributed keys to their project', async () => {
|
|
147
|
+
const app = transfersApp()
|
|
148
|
+
const scoped = await seedTransfer({ projectId: routesProjectReader.projectId })
|
|
149
|
+
|
|
150
|
+
const body = await TestApp.json(
|
|
151
|
+
await app.request('/v1/routes/transfers?limit=200', as(routesProjectReader)),
|
|
152
|
+
Routes.schema.listRoutesTransfers.Response,
|
|
153
|
+
)
|
|
154
|
+
expect(body.data.map((transfer) => transfer.id)).toEqual([scoped.id])
|
|
155
|
+
|
|
156
|
+
// The organization-attributed key sees the project row too.
|
|
157
|
+
const orgBody = await TestApp.json(
|
|
158
|
+
await app.request('/v1/routes/transfers?limit=200', as(routesReader)),
|
|
159
|
+
Routes.schema.listRoutesTransfers.Response,
|
|
160
|
+
)
|
|
161
|
+
expect(orgBody.data.map((transfer) => transfer.id)).toContain(scoped.id)
|
|
162
|
+
})
|
|
163
|
+
|
|
164
|
+
test('rejects invalid query parameters', async () => {
|
|
165
|
+
const app = transfersApp()
|
|
166
|
+
const response = await app.request('/v1/routes/transfers?status=bogus', as(routesReader))
|
|
167
|
+
expect(response.status).toBe(400)
|
|
168
|
+
})
|
|
169
|
+
})
|
|
170
|
+
|
|
171
|
+
describe('GET /routes/transfers/:id', () => {
|
|
172
|
+
test('returns the owned transfer directly, without an action', async () => {
|
|
173
|
+
const app = transfersApp()
|
|
174
|
+
const record = await seedTransfer()
|
|
175
|
+
const response = await app.request(`/v1/routes/transfers/${record.id}`, {
|
|
176
|
+
headers: { 'tempo-api-key': routesReader.token },
|
|
177
|
+
})
|
|
178
|
+
expect(response.status).toBe(200)
|
|
179
|
+
expect({
|
|
180
|
+
cacheControl: response.headers.get('cache-control'),
|
|
181
|
+
etag: response.headers.get('etag'),
|
|
182
|
+
}).toMatchInlineSnapshot(`
|
|
183
|
+
{
|
|
184
|
+
"cacheControl": "no-store",
|
|
185
|
+
"etag": null,
|
|
186
|
+
}
|
|
187
|
+
`)
|
|
188
|
+
expect(response.headers.get('vary')).toBe(
|
|
189
|
+
'Accept-Encoding, Authorization, Tempo-API-Key, X-API-Key',
|
|
190
|
+
)
|
|
191
|
+
const body = await TestApp.json(response, Routes.schema.getRoutesTransfer.Response)
|
|
192
|
+
expect(body).toEqual(RoutesTransfer.toPublic(record))
|
|
193
|
+
expect('action' in body).toBe(false)
|
|
194
|
+
|
|
195
|
+
const repeated = await app.request(`/v1/routes/transfers/${record.id}`, {
|
|
196
|
+
headers: { 'if-none-match': '"stale"', 'tempo-api-key': routesReader.token },
|
|
197
|
+
})
|
|
198
|
+
expect({
|
|
199
|
+
cacheControl: repeated.headers.get('cache-control'),
|
|
200
|
+
etag: repeated.headers.get('etag'),
|
|
201
|
+
status: repeated.status,
|
|
202
|
+
}).toMatchInlineSnapshot(`
|
|
203
|
+
{
|
|
204
|
+
"cacheControl": "no-store",
|
|
205
|
+
"etag": null,
|
|
206
|
+
"status": 200,
|
|
207
|
+
}
|
|
208
|
+
`)
|
|
209
|
+
})
|
|
210
|
+
|
|
211
|
+
test('hides foreign and absent transfers behind the same 404', async () => {
|
|
212
|
+
const app = transfersApp()
|
|
213
|
+
const record = await seedTransfer()
|
|
214
|
+
|
|
215
|
+
const foreign = await app.request(`/v1/routes/transfers/${record.id}`, as(routesForeign))
|
|
216
|
+
expect(foreign.status).toBe(404)
|
|
217
|
+
expect(((await foreign.json()) as { error: { code: string } }).error.code).toBe(
|
|
218
|
+
'routes_transfer_not_found',
|
|
219
|
+
)
|
|
220
|
+
|
|
221
|
+
const project = await app.request(`/v1/routes/transfers/${record.id}`, as(routesProjectReader))
|
|
222
|
+
expect(project.status).toBe(404)
|
|
223
|
+
|
|
224
|
+
const absent = await app.request(
|
|
225
|
+
'/v1/routes/transfers/rtr_000000000000000_000000000000000000000000',
|
|
226
|
+
as(routesReader),
|
|
227
|
+
)
|
|
228
|
+
expect(absent.status).toBe(404)
|
|
229
|
+
})
|
|
230
|
+
})
|
|
231
|
+
|
|
232
|
+
describe('POST /routes/transfers/:id/source-transactions', () => {
|
|
233
|
+
test('requires routes write access and validates the transaction hash array', async () => {
|
|
234
|
+
const app = transfersApp()
|
|
235
|
+
const transfer = await seedTransfer()
|
|
236
|
+
const path = `/v1/routes/transfers/${transfer.id}/source-transactions`
|
|
237
|
+
expect((await app.request(path, { method: 'POST' })).status).toBe(401)
|
|
238
|
+
expect((await app.request(path, { ...as(routesReader), method: 'POST' })).status).toBe(403)
|
|
239
|
+
for (const body of [
|
|
240
|
+
{ transactionHashes: [] },
|
|
241
|
+
{ transactionHashes: ['0xinvalid'] },
|
|
242
|
+
{
|
|
243
|
+
transactionHashes: Array.from(
|
|
244
|
+
{ length: 11 },
|
|
245
|
+
(_, index) => `0x${index.toString(16).padStart(64, '0')}`,
|
|
246
|
+
),
|
|
247
|
+
},
|
|
248
|
+
])
|
|
249
|
+
expect(
|
|
250
|
+
(
|
|
251
|
+
await app.request(path, {
|
|
252
|
+
body: JSON.stringify(body),
|
|
253
|
+
headers: { ...as(routesWriter).headers, 'content-type': 'application/json' },
|
|
254
|
+
method: 'POST',
|
|
255
|
+
})
|
|
256
|
+
).status,
|
|
257
|
+
).toBe(400)
|
|
258
|
+
})
|
|
259
|
+
|
|
260
|
+
test('accepts singular and plural requests before reporting missing reconciliation', async () => {
|
|
261
|
+
const app = transfersApp()
|
|
262
|
+
const transfer = await seedTransfer()
|
|
263
|
+
const transactionHash = `0x${'aa'.repeat(32)}`
|
|
264
|
+
for (const body of [{ transactionHash }, { transactionHashes: [transactionHash] }]) {
|
|
265
|
+
const response = await app.request(
|
|
266
|
+
`/v1/routes/transfers/${transfer.id}/source-transactions`,
|
|
267
|
+
{
|
|
268
|
+
body: JSON.stringify(body),
|
|
269
|
+
headers: { ...as(routesWriter).headers, 'content-type': 'application/json' },
|
|
270
|
+
method: 'POST',
|
|
271
|
+
},
|
|
272
|
+
)
|
|
273
|
+
expect(response.status).toBe(501)
|
|
274
|
+
}
|
|
275
|
+
})
|
|
276
|
+
|
|
277
|
+
test('records source routes and dispatches reconciliation once', async () => {
|
|
278
|
+
const database = TestApp.databaseFactory()
|
|
279
|
+
const setup = database()
|
|
280
|
+
await TestRoutes.publish(setup)
|
|
281
|
+
const firstVerified = Promise.withResolvers<void>()
|
|
282
|
+
const intervals: RoutesObservability.LifecycleInterval[] = []
|
|
283
|
+
const messages: RoutesTransferReconciliation.Message[] = []
|
|
284
|
+
const releaseFirst = Promise.withResolvers<void>()
|
|
285
|
+
const secondVerified = Promise.withResolvers<void>()
|
|
286
|
+
let verifications = 0
|
|
287
|
+
const provider = RoutesProvider.from({
|
|
288
|
+
...Stargate.stargate(),
|
|
289
|
+
async verifySourceTransaction({ transactionHash }) {
|
|
290
|
+
verifications++
|
|
291
|
+
if (verifications === 1) {
|
|
292
|
+
firstVerified.resolve()
|
|
293
|
+
await releaseFirst.promise
|
|
294
|
+
} else secondVerified.resolve()
|
|
295
|
+
return {
|
|
296
|
+
destinationAmount: '980000',
|
|
297
|
+
providerState: {},
|
|
298
|
+
transactionHash,
|
|
299
|
+
type: 'verified',
|
|
300
|
+
}
|
|
301
|
+
},
|
|
302
|
+
})
|
|
303
|
+
const app = transfersApp({
|
|
304
|
+
db: database,
|
|
305
|
+
routes: {
|
|
306
|
+
async dispatchTransferReconciliation(message) {
|
|
307
|
+
messages.push(message)
|
|
308
|
+
},
|
|
309
|
+
async recordLifecycleInterval(interval) {
|
|
310
|
+
intervals.push(interval)
|
|
311
|
+
},
|
|
312
|
+
},
|
|
313
|
+
providers: [provider],
|
|
314
|
+
})
|
|
315
|
+
const transfer = await RoutesTransfer.create(setup, {
|
|
316
|
+
apiKeyId: routesReader.id,
|
|
317
|
+
environment: 'production',
|
|
318
|
+
id: RoutesTransfer.generateId(new Date(Date.UTC(2026, 0, 2, 0, 0, seedSecond++))),
|
|
319
|
+
orgId: routesReader.orgId,
|
|
320
|
+
snapshot: TestRoutes.transferSnapshot({ provider: { id: 'stargate', name: 'Stargate' } }),
|
|
321
|
+
})
|
|
322
|
+
const request = {
|
|
323
|
+
body: JSON.stringify({ transactionHashes: [`0x${'aa'.repeat(32)}`] }),
|
|
324
|
+
headers: { ...as(routesWriter).headers, 'content-type': 'application/json' },
|
|
325
|
+
method: 'POST',
|
|
326
|
+
} as const
|
|
327
|
+
const path = `/v1/routes/transfers/${transfer.id}/source-transactions`
|
|
328
|
+
|
|
329
|
+
const first = app.request(path, request)
|
|
330
|
+
await firstVerified.promise
|
|
331
|
+
const second = app.request(path, request)
|
|
332
|
+
await secondVerified.promise
|
|
333
|
+
releaseFirst.resolve()
|
|
334
|
+
const [response, replay] = await Promise.all([first, second])
|
|
335
|
+
expect(response.status).toBe(200)
|
|
336
|
+
expect(await response.json()).toMatchObject({ destinationAmount: { baseUnits: '980000' } })
|
|
337
|
+
expect(replay.status).toBe(200)
|
|
338
|
+
expect(intervals).toEqual([
|
|
339
|
+
expect.objectContaining({
|
|
340
|
+
routesEnvironment: 'production',
|
|
341
|
+
method: 'transaction',
|
|
342
|
+
provider: 'stargate',
|
|
343
|
+
resourceId: transfer.id,
|
|
344
|
+
stage: 'source_routes',
|
|
345
|
+
}),
|
|
346
|
+
])
|
|
347
|
+
expect(messages).toEqual([{ transferId: transfer.id, type: 'routes:transfer:reconcile' }])
|
|
348
|
+
})
|
|
349
|
+
|
|
350
|
+
test('does not expose a transfer owned by another organization', async () => {
|
|
351
|
+
const tracker = RoutesTransferReconciliation.createTracker({
|
|
352
|
+
db,
|
|
353
|
+
providers: [Stargate.stargate()],
|
|
354
|
+
})
|
|
355
|
+
const app = transfersApp({
|
|
356
|
+
routes: {
|
|
357
|
+
async dispatchTransferReconciliation(message) {
|
|
358
|
+
await tracker.reconcile(message)
|
|
359
|
+
},
|
|
360
|
+
},
|
|
361
|
+
})
|
|
362
|
+
const transfer = await seedTransfer()
|
|
363
|
+
const response = await app.request(`/v1/routes/transfers/${transfer.id}/source-transactions`, {
|
|
364
|
+
body: JSON.stringify({ transactionHashes: [`0x${'aa'.repeat(32)}`] }),
|
|
365
|
+
headers: { ...as(routesForeign).headers, 'content-type': 'application/json' },
|
|
366
|
+
method: 'POST',
|
|
367
|
+
})
|
|
368
|
+
expect(response.status).toBe(404)
|
|
369
|
+
})
|
|
370
|
+
|
|
371
|
+
test('waits for every source verification before reporting provider attempts', async () => {
|
|
372
|
+
const entries: Log.Entry[] = []
|
|
373
|
+
const transactionHashes = [`0x${'aa'.repeat(32)}`, `0x${'bb'.repeat(32)}`]
|
|
374
|
+
const provider = RoutesProvider.from({
|
|
375
|
+
...Stargate.stargate(),
|
|
376
|
+
async verifySourceTransaction({ transactionHash }) {
|
|
377
|
+
if (transactionHash === transactionHashes[0]) throw new Error('upstream unavailable')
|
|
378
|
+
await new Promise((resolve) => setTimeout(resolve, 0))
|
|
379
|
+
return { type: 'pending' }
|
|
380
|
+
},
|
|
381
|
+
})
|
|
382
|
+
const app = transfersApp({
|
|
383
|
+
routes: { async dispatchTransferReconciliation() {} },
|
|
384
|
+
logger: (entry) => void entries.push(entry),
|
|
385
|
+
providers: [provider],
|
|
386
|
+
})
|
|
387
|
+
const transfer = await seedTransfer({
|
|
388
|
+
snapshot: TestRoutes.transferSnapshot({ provider: { id: 'stargate', name: 'Stargate' } }),
|
|
389
|
+
})
|
|
390
|
+
|
|
391
|
+
const response = await app.request(`/v1/routes/transfers/${transfer.id}/source-transactions`, {
|
|
392
|
+
body: JSON.stringify({ transactionHashes }),
|
|
393
|
+
headers: { ...as(routesWriter).headers, 'content-type': 'application/json' },
|
|
394
|
+
method: 'POST',
|
|
395
|
+
})
|
|
396
|
+
|
|
397
|
+
expect(response.status).toBe(502)
|
|
398
|
+
expect(
|
|
399
|
+
entries[0]?.routesProviderAttempts?.map(({ operation, outcome }) => ({
|
|
400
|
+
operation,
|
|
401
|
+
outcome,
|
|
402
|
+
})),
|
|
403
|
+
).toEqual([
|
|
404
|
+
{ operation: 'verifySourceTransaction', outcome: 'failed' },
|
|
405
|
+
{ operation: 'verifySourceTransaction', outcome: 'success' },
|
|
406
|
+
])
|
|
407
|
+
})
|
|
408
|
+
})
|
|
409
|
+
|
|
410
|
+
const createBody = {
|
|
411
|
+
amount: '1000000',
|
|
412
|
+
destinationToken: '0x20c0000000000000000000000000000000000000',
|
|
413
|
+
mode: 'exactSource',
|
|
414
|
+
recipient: `0x${'11'.repeat(20)}`,
|
|
415
|
+
sender: `0x${'22'.repeat(20)}`,
|
|
416
|
+
slippageBps: 300,
|
|
417
|
+
sourceChain: 'base',
|
|
418
|
+
sourceToken: '0x833589fcd6edb6e08f4c7c32d4f71b54bda02913',
|
|
419
|
+
}
|
|
420
|
+
|
|
421
|
+
const vaultTransferBody = {
|
|
422
|
+
amount: createBody.amount,
|
|
423
|
+
mode: createBody.mode,
|
|
424
|
+
recipient: createBody.recipient,
|
|
425
|
+
sender: createBody.sender,
|
|
426
|
+
slippageBps: createBody.slippageBps,
|
|
427
|
+
sourceChain: createBody.sourceChain,
|
|
428
|
+
sourceToken: createBody.sourceToken,
|
|
429
|
+
vaultAddress: `0x${'f4'.repeat(20)}`,
|
|
430
|
+
}
|
|
431
|
+
|
|
432
|
+
const zoneTransferBody = {
|
|
433
|
+
amount: createBody.amount,
|
|
434
|
+
destinationChain: 'eip155:421700001',
|
|
435
|
+
destinationToken: createBody.destinationToken,
|
|
436
|
+
mode: createBody.mode,
|
|
437
|
+
recipient: createBody.recipient,
|
|
438
|
+
recipientFallback: `0x${'33'.repeat(20)}`,
|
|
439
|
+
sender: createBody.sender,
|
|
440
|
+
slippageBps: createBody.slippageBps,
|
|
441
|
+
sourceChain: createBody.sourceChain,
|
|
442
|
+
sourceToken: createBody.sourceToken,
|
|
443
|
+
}
|
|
444
|
+
|
|
445
|
+
function postTransfer(
|
|
446
|
+
app: ReturnType<typeof create>,
|
|
447
|
+
options: { body?: unknown; idempotencyKey?: string | undefined; key?: { token: string } } = {},
|
|
448
|
+
) {
|
|
449
|
+
return app.request('/v1/routes/transfers', {
|
|
450
|
+
body: JSON.stringify(options.body ?? createBody),
|
|
451
|
+
headers: {
|
|
452
|
+
authorization: `Bearer ${(options.key ?? routesWriter).token}`,
|
|
453
|
+
'content-type': 'application/json',
|
|
454
|
+
...(options.idempotencyKey === undefined
|
|
455
|
+
? {}
|
|
456
|
+
: { 'idempotency-key': options.idempotencyKey }),
|
|
457
|
+
},
|
|
458
|
+
method: 'POST',
|
|
459
|
+
})
|
|
460
|
+
}
|
|
461
|
+
|
|
462
|
+
describe('POST /routes/transfers', () => {
|
|
463
|
+
function providerResponse(
|
|
464
|
+
options: { sourceToken?: string | undefined } = {},
|
|
465
|
+
): RoutesProvider.prepareTransfer.ReturnType {
|
|
466
|
+
const spender = `0x${'44'.repeat(20)}`
|
|
467
|
+
return {
|
|
468
|
+
action: {
|
|
469
|
+
calls: [
|
|
470
|
+
{
|
|
471
|
+
data: `0x095ea7b3${spender.slice(2).padStart(64, '0')}${(1_000_000).toString(16).padStart(64, '0')}`,
|
|
472
|
+
to: options.sourceToken ?? createBody.sourceToken,
|
|
473
|
+
value: '0x0',
|
|
474
|
+
},
|
|
475
|
+
{ data: '0xe8017952', to: spender, value: '0x0' },
|
|
476
|
+
],
|
|
477
|
+
type: 'evm:calls',
|
|
478
|
+
},
|
|
479
|
+
correlation: { requestId: `0x${'ab'.repeat(32)}` },
|
|
480
|
+
fees: [{ amount: '21050', side: 'source' }],
|
|
481
|
+
destinationAmountMin: '980000',
|
|
482
|
+
destinationAmount: '990000',
|
|
483
|
+
quality: {
|
|
484
|
+
estimatedSeconds: 4,
|
|
485
|
+
liquiditySource: 'providerQuote',
|
|
486
|
+
sourceDetail: 'relay:quote-v2',
|
|
487
|
+
tier: 'liquid',
|
|
488
|
+
},
|
|
489
|
+
sampledAt: '2099-01-01T00:00:00.000Z',
|
|
490
|
+
}
|
|
491
|
+
}
|
|
492
|
+
|
|
493
|
+
function provider(
|
|
494
|
+
prepareTransfer: NonNullable<RoutesProvider.Provider['prepareTransfer']> = async () =>
|
|
495
|
+
providerResponse(),
|
|
496
|
+
) {
|
|
497
|
+
return RoutesProvider.from({
|
|
498
|
+
...Relay.relay(),
|
|
499
|
+
prepareTransfer,
|
|
500
|
+
})
|
|
501
|
+
}
|
|
502
|
+
|
|
503
|
+
let idempotencySequence = 0
|
|
504
|
+
function nextIdempotencyKey() {
|
|
505
|
+
return `routes_test_${idempotencySequence++}`
|
|
506
|
+
}
|
|
507
|
+
|
|
508
|
+
test('requires routes:write and an Idempotency-Key', async () => {
|
|
509
|
+
const app = transfersApp({
|
|
510
|
+
providers: [provider()],
|
|
511
|
+
})
|
|
512
|
+
const forbidden = await postTransfer(app, {
|
|
513
|
+
idempotencyKey: nextIdempotencyKey(),
|
|
514
|
+
key: routesReader,
|
|
515
|
+
})
|
|
516
|
+
expect(forbidden.status).toBe(403)
|
|
517
|
+
|
|
518
|
+
const missing = await postTransfer(app)
|
|
519
|
+
expect(missing.status).toBe(400)
|
|
520
|
+
expect(((await missing.json()) as { error: { code: string } }).error.code).toBe(
|
|
521
|
+
'idempotency_key_required',
|
|
522
|
+
)
|
|
523
|
+
})
|
|
524
|
+
|
|
525
|
+
test('creates a transfer with the selected executable quote', async () => {
|
|
526
|
+
const inputs: RoutesProvider.prepareTransfer.Parameters[] = []
|
|
527
|
+
const app = transfersApp({
|
|
528
|
+
providers: [
|
|
529
|
+
provider(async (input) => {
|
|
530
|
+
inputs.push(input)
|
|
531
|
+
return providerResponse()
|
|
532
|
+
}),
|
|
533
|
+
],
|
|
534
|
+
})
|
|
535
|
+
const response = await postTransfer(app, {
|
|
536
|
+
body: { ...createBody, destinationToken: 'pathusd', sourceToken: 'usdc' },
|
|
537
|
+
idempotencyKey: nextIdempotencyKey(),
|
|
538
|
+
})
|
|
539
|
+
expect(response.status).toBe(200)
|
|
540
|
+
expect(response.headers.get('cache-control')).toBe('no-store')
|
|
541
|
+
const body = await TestApp.json(response, Routes.schema.createRoutesTransfer.Response)
|
|
542
|
+
|
|
543
|
+
expect(inputs[0]).toMatchObject({
|
|
544
|
+
method: 'transaction',
|
|
545
|
+
mode: 'exactSource',
|
|
546
|
+
recipient: createBody.recipient,
|
|
547
|
+
sender: createBody.sender,
|
|
548
|
+
slippageBps: 300,
|
|
549
|
+
})
|
|
550
|
+
expect(body).toMatchObject({
|
|
551
|
+
action: { type: 'evm:calls' },
|
|
552
|
+
destinationAmountMin: { baseUnits: '980000' },
|
|
553
|
+
method: 'transaction',
|
|
554
|
+
mode: 'exactSource',
|
|
555
|
+
provider: { id: 'relay' },
|
|
556
|
+
// The provider returned no expiry, so the default validity window applies.
|
|
557
|
+
quote: { expiresAt: '2099-01-01T00:01:00.000Z', sampledAt: '2099-01-01T00:00:00.000Z' },
|
|
558
|
+
sourceAmount: { baseUnits: '1000000' },
|
|
559
|
+
status: 'awaiting-source',
|
|
560
|
+
version: 1,
|
|
561
|
+
})
|
|
562
|
+
expect(body.fees[0]).toMatchObject({ side: 'source', token: { symbol: 'USDC' } })
|
|
563
|
+
|
|
564
|
+
// Reads return the same transfer without the action; the private
|
|
565
|
+
// correlation never leaves the row.
|
|
566
|
+
const read = await app.request(`/v1/routes/transfers/${body.id}`, as(routesWriter))
|
|
567
|
+
const readBody = await TestApp.json(read, Routes.schema.getRoutesTransfer.Response)
|
|
568
|
+
expect('action' in readBody).toBe(false)
|
|
569
|
+
expect(JSON.stringify(readBody)).not.toContain('ab'.repeat(32))
|
|
570
|
+
const row = await db.kysely
|
|
571
|
+
.selectFrom('routes_transfers')
|
|
572
|
+
.select(['providerState'])
|
|
573
|
+
.where('id', '=', body.id)
|
|
574
|
+
.executeTakeFirstOrThrow()
|
|
575
|
+
expect(row.providerState).toEqual({ requestId: `0x${'ab'.repeat(32)}` })
|
|
576
|
+
})
|
|
577
|
+
|
|
578
|
+
test('rejects completion when the owner is deleted after the initial claim', async () => {
|
|
579
|
+
const suffix = nextIdempotencyKey()
|
|
580
|
+
const key = {
|
|
581
|
+
id: `key_${suffix}`,
|
|
582
|
+
orgId: `org_${suffix}`,
|
|
583
|
+
scopes: ['routes:write'],
|
|
584
|
+
token: `secret_${suffix}`,
|
|
585
|
+
} satisfies TestApp.kvStore.Key
|
|
586
|
+
await Organizations.create(db, { id: key.orgId, name: 'Transfer deletion race' })
|
|
587
|
+
const entered = Promise.withResolvers<void>()
|
|
588
|
+
const release = Promise.withResolvers<void>()
|
|
589
|
+
const app = create({
|
|
590
|
+
auth: { keys: [key] },
|
|
591
|
+
defaultChainId: tempoMainnet.id,
|
|
592
|
+
providers: [
|
|
593
|
+
provider(async () => {
|
|
594
|
+
entered.resolve()
|
|
595
|
+
await release.promise
|
|
596
|
+
return providerResponse()
|
|
597
|
+
}),
|
|
598
|
+
],
|
|
599
|
+
})
|
|
600
|
+
const idempotencyKey = nextIdempotencyKey()
|
|
601
|
+
const creation = postTransfer(app, { idempotencyKey, key })
|
|
602
|
+
await entered.promise
|
|
603
|
+
|
|
604
|
+
await expect(
|
|
605
|
+
db.kysely
|
|
606
|
+
.selectFrom('routes_idempotency_requests')
|
|
607
|
+
.select('status')
|
|
608
|
+
.where('apiKeyId', '=', key.id)
|
|
609
|
+
.where('keyHash', '=', Idempotency.inputHash(idempotencyKey))
|
|
610
|
+
.executeTakeFirstOrThrow(),
|
|
611
|
+
).resolves.toEqual({ status: 'pending' })
|
|
612
|
+
expect(await Organizations.deleteOrganization(db, key.orgId)).toBe(true)
|
|
613
|
+
release.resolve()
|
|
614
|
+
const response = await creation
|
|
615
|
+
|
|
616
|
+
expect(response.status).toBe(403)
|
|
617
|
+
await expect(response.json()).resolves.toMatchObject({
|
|
618
|
+
error: {
|
|
619
|
+
code: 'api_key_forbidden',
|
|
620
|
+
message: 'API key organization no longer exists.',
|
|
621
|
+
},
|
|
622
|
+
})
|
|
623
|
+
await expect(
|
|
624
|
+
db.kysely
|
|
625
|
+
.selectFrom('routes_transfers')
|
|
626
|
+
.select('id')
|
|
627
|
+
.where('orgId', '=', key.orgId)
|
|
628
|
+
.execute(),
|
|
629
|
+
).resolves.toEqual([])
|
|
630
|
+
await expect(
|
|
631
|
+
db.kysely
|
|
632
|
+
.selectFrom('routes_idempotency_requests')
|
|
633
|
+
.select(['response', 'status', 'transferId'])
|
|
634
|
+
.where('apiKeyId', '=', key.id)
|
|
635
|
+
.where('keyHash', '=', Idempotency.inputHash(idempotencyKey))
|
|
636
|
+
.execute(),
|
|
637
|
+
).resolves.toEqual([])
|
|
638
|
+
})
|
|
639
|
+
|
|
640
|
+
test('requires configuration and records normalized subsidy terms', async () => {
|
|
641
|
+
const request = {
|
|
642
|
+
...createBody,
|
|
643
|
+
destinationChain: 'base',
|
|
644
|
+
destinationToken: '0x833589fcd6edb6e08f4c7c32d4f71b54bda02913',
|
|
645
|
+
sourceChain: 'tempo',
|
|
646
|
+
sourceToken: '0x20c000000000000000000000b9537d11c60e8b50',
|
|
647
|
+
subsidize: true,
|
|
648
|
+
}
|
|
649
|
+
const outbound = RoutesProvider.from({
|
|
650
|
+
...Relay.relay(),
|
|
651
|
+
id: 'stargate',
|
|
652
|
+
name: 'Stargate',
|
|
653
|
+
async prepareTransfer() {
|
|
654
|
+
return providerResponse({ sourceToken: request.sourceToken })
|
|
655
|
+
},
|
|
656
|
+
})
|
|
657
|
+
const idempotencyKey = nextIdempotencyKey()
|
|
658
|
+
const unavailable = await postTransfer(transfersApp({ providers: [outbound] }), {
|
|
659
|
+
body: request,
|
|
660
|
+
idempotencyKey,
|
|
661
|
+
})
|
|
662
|
+
expect(unavailable.status).toBe(501)
|
|
663
|
+
|
|
664
|
+
await Organizations.create(db, { id: routesWriter.orgId, name: routesWriter.orgId })
|
|
665
|
+
await RoutesSubsidies.upsertOrganization(db, {
|
|
666
|
+
frequency: 'tx',
|
|
667
|
+
maxAmount: '5',
|
|
668
|
+
orgId: routesWriter.orgId,
|
|
669
|
+
})
|
|
670
|
+
await StripeCustomers.create(db, {
|
|
671
|
+
orgId: routesWriter.orgId,
|
|
672
|
+
stripeCustomerId: 'cus_routes_transfer_subsidy',
|
|
673
|
+
})
|
|
674
|
+
await StripeCustomers.setStatus(db, routesWriter.orgId, 'active')
|
|
675
|
+
const upstream = await postTransfer(
|
|
676
|
+
transfersApp({
|
|
677
|
+
providers: [outbound],
|
|
678
|
+
routes: {
|
|
679
|
+
transferSubsidy: {
|
|
680
|
+
account: `0x${'77'.repeat(20)}`,
|
|
681
|
+
async check() {
|
|
682
|
+
throw new RoutesTransferSubsidy.InventoryUpstreamError(
|
|
683
|
+
new Error('Destination RPC unavailable.'),
|
|
684
|
+
)
|
|
685
|
+
},
|
|
686
|
+
policy: { maxAmount: '5' },
|
|
687
|
+
},
|
|
688
|
+
},
|
|
689
|
+
}),
|
|
690
|
+
{ body: request, idempotencyKey: nextIdempotencyKey() },
|
|
691
|
+
)
|
|
692
|
+
expect(upstream.status).toBe(502)
|
|
693
|
+
await expect(upstream.json()).resolves.toMatchObject({ error: { code: 'upstream_error' } })
|
|
694
|
+
const limited = await postTransfer(
|
|
695
|
+
transfersApp({
|
|
696
|
+
providers: [outbound],
|
|
697
|
+
routes: { transferSubsidy: transferSubsidy('0.015') },
|
|
698
|
+
}),
|
|
699
|
+
{ body: request, idempotencyKey: nextIdempotencyKey() },
|
|
700
|
+
)
|
|
701
|
+
expect(limited.status).toBe(403)
|
|
702
|
+
await expect(limited.json()).resolves.toMatchObject({
|
|
703
|
+
error: { code: 'routes_subsidy_limit_exceeded' },
|
|
704
|
+
})
|
|
705
|
+
const response = await postTransfer(
|
|
706
|
+
transfersApp({
|
|
707
|
+
providers: [outbound],
|
|
708
|
+
routes: { transferSubsidy: transferSubsidy('5') },
|
|
709
|
+
}),
|
|
710
|
+
{
|
|
711
|
+
body: request,
|
|
712
|
+
idempotencyKey,
|
|
713
|
+
},
|
|
714
|
+
)
|
|
715
|
+
expect(response.status).toBe(200)
|
|
716
|
+
const body = await TestApp.json(response, Routes.schema.createRoutesTransfer.Response)
|
|
717
|
+
expect(body).toMatchObject({
|
|
718
|
+
destinationAmount: { baseUnits: '990000' },
|
|
719
|
+
destinationAmountRequired: { baseUnits: '1000000' },
|
|
720
|
+
subsidize: true,
|
|
721
|
+
})
|
|
722
|
+
const row = await db.kysely
|
|
723
|
+
.selectFrom('routes_transfers')
|
|
724
|
+
.select([
|
|
725
|
+
'providerState',
|
|
726
|
+
'subsidyAccount',
|
|
727
|
+
'subsidyChainId',
|
|
728
|
+
'subsidyCommitmentAmount',
|
|
729
|
+
'subsidyNativeAmount',
|
|
730
|
+
'subsidyTokenAddress',
|
|
731
|
+
])
|
|
732
|
+
.where('id', '=', body.id)
|
|
733
|
+
.executeTakeFirstOrThrow()
|
|
734
|
+
expect(row.providerState).not.toHaveProperty('transferSubsidyPolicy')
|
|
735
|
+
expect(row).toMatchObject({
|
|
736
|
+
subsidyAccount: `0x${'77'.repeat(20)}`,
|
|
737
|
+
subsidyChainId: 'eip155:8453',
|
|
738
|
+
subsidyCommitmentAmount: { baseUnits: '20000' },
|
|
739
|
+
subsidyNativeAmount: '100',
|
|
740
|
+
subsidyTokenAddress: request.destinationToken,
|
|
741
|
+
})
|
|
742
|
+
const replay = await postTransfer(transfersApp({ providers: [outbound] }), {
|
|
743
|
+
body: request,
|
|
744
|
+
idempotencyKey,
|
|
745
|
+
})
|
|
746
|
+
expect(replay.status).toBe(200)
|
|
747
|
+
await expect(replay.json()).resolves.toMatchObject({ id: body.id })
|
|
748
|
+
const mismatch = await postTransfer(transfersApp({ providers: [outbound] }), {
|
|
749
|
+
body: { ...request, amount: '2000000' },
|
|
750
|
+
idempotencyKey,
|
|
751
|
+
})
|
|
752
|
+
expect(mismatch.status).toBe(409)
|
|
753
|
+
await expect(mismatch.json()).resolves.toMatchObject({
|
|
754
|
+
error: { code: 'idempotency_conflict' },
|
|
755
|
+
})
|
|
756
|
+
|
|
757
|
+
await RoutesCatalog.publish(db, {
|
|
758
|
+
...TestRoutes.data,
|
|
759
|
+
tokens: TestRoutes.data.tokens.map((token) =>
|
|
760
|
+
token.id === 'usdce' ? { ...token, currency: 'EUR' } : token,
|
|
761
|
+
),
|
|
762
|
+
})
|
|
763
|
+
try {
|
|
764
|
+
const incompatible = await postTransfer(
|
|
765
|
+
transfersApp({
|
|
766
|
+
providers: [outbound],
|
|
767
|
+
routes: { transferSubsidy: transferSubsidy('5') },
|
|
768
|
+
}),
|
|
769
|
+
{ body: request, idempotencyKey: nextIdempotencyKey() },
|
|
770
|
+
)
|
|
771
|
+
expect(incompatible.status).toBe(400)
|
|
772
|
+
await expect(incompatible.json()).resolves.toMatchObject({
|
|
773
|
+
error: { code: 'body_invalid' },
|
|
774
|
+
})
|
|
775
|
+
} finally {
|
|
776
|
+
await TestRoutes.publish(db)
|
|
777
|
+
}
|
|
778
|
+
})
|
|
779
|
+
|
|
780
|
+
test('dispatches staged webhook updates after creation commits', async () => {
|
|
781
|
+
const subscription = await Webhooks.createSubscription(db, {
|
|
782
|
+
chainId: tempoMainnet.id,
|
|
783
|
+
destination: { type: 'url', url: 'https://example.com/webhooks/routes-transfers' },
|
|
784
|
+
environment: 'production',
|
|
785
|
+
eventType: 'routes:transfer.updated',
|
|
786
|
+
filters: { status: 'awaiting-source' },
|
|
787
|
+
owner: { orgId: routesWriter.orgId, type: 'api_key' },
|
|
788
|
+
})
|
|
789
|
+
const references: Webhooks.QueueReference[] = []
|
|
790
|
+
const app = transfersApp({
|
|
791
|
+
routes: {
|
|
792
|
+
async dispatchTransferUpdates(staged) {
|
|
793
|
+
const reference = staged[0]!
|
|
794
|
+
const queued = await db.kysely
|
|
795
|
+
.selectFrom('webhook_queue_events')
|
|
796
|
+
.select('eventId')
|
|
797
|
+
.where('eventId', '=', reference.eventId)
|
|
798
|
+
.where('subscriptionId', '=', reference.subscriptionId)
|
|
799
|
+
.executeTakeFirst()
|
|
800
|
+
expect(queued).toBeDefined()
|
|
801
|
+
references.push(...staged)
|
|
802
|
+
return staged.length
|
|
803
|
+
},
|
|
804
|
+
},
|
|
805
|
+
providers: [provider()],
|
|
806
|
+
})
|
|
807
|
+
|
|
808
|
+
const response = await postTransfer(app, { idempotencyKey: nextIdempotencyKey() })
|
|
809
|
+
|
|
810
|
+
expect(response.status).toBe(200)
|
|
811
|
+
expect(references).toEqual([{ eventId: expect.any(String), subscriptionId: subscription.id }])
|
|
812
|
+
})
|
|
813
|
+
|
|
814
|
+
test('creates a transfer with the requested provider', async () => {
|
|
815
|
+
const app = transfersApp({ providers: [provider()] })
|
|
816
|
+
const response = await postTransfer(app, {
|
|
817
|
+
body: { ...createBody, provider: 'relay' },
|
|
818
|
+
idempotencyKey: nextIdempotencyKey(),
|
|
819
|
+
})
|
|
820
|
+
|
|
821
|
+
expect(response.status).toBe(200)
|
|
822
|
+
const body = await TestApp.json(response, Routes.schema.createRoutesTransfer.Response)
|
|
823
|
+
expect(body.provider.id).toBe('relay')
|
|
824
|
+
})
|
|
825
|
+
|
|
826
|
+
test('rejects an unsupported provider', async () => {
|
|
827
|
+
const app = transfersApp({ providers: [provider()] })
|
|
828
|
+
const response = await postTransfer(app, {
|
|
829
|
+
body: { ...createBody, provider: 'bridge' },
|
|
830
|
+
idempotencyKey: nextIdempotencyKey(),
|
|
831
|
+
})
|
|
832
|
+
|
|
833
|
+
expect(response.status).toBe(400)
|
|
834
|
+
expect(((await response.json()) as { error: { code: string } }).error.code).toBe('body_invalid')
|
|
835
|
+
})
|
|
836
|
+
|
|
837
|
+
test('preserves a provider-specified native fee token', async () => {
|
|
838
|
+
const app = transfersApp({
|
|
839
|
+
providers: [
|
|
840
|
+
provider(async () => ({
|
|
841
|
+
...providerResponse(),
|
|
842
|
+
fees: [
|
|
843
|
+
{
|
|
844
|
+
amount: '1000000000000000',
|
|
845
|
+
side: 'source',
|
|
846
|
+
token: {
|
|
847
|
+
address: '0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee',
|
|
848
|
+
currency: 'ETH',
|
|
849
|
+
decimals: 18,
|
|
850
|
+
name: 'Ether',
|
|
851
|
+
standard: 'native',
|
|
852
|
+
symbol: 'ETH',
|
|
853
|
+
tokenKey: 'eip155:8453/slip44:60',
|
|
854
|
+
verified: true,
|
|
855
|
+
},
|
|
856
|
+
},
|
|
857
|
+
],
|
|
858
|
+
})),
|
|
859
|
+
],
|
|
860
|
+
})
|
|
861
|
+
const response = await postTransfer(app, {
|
|
862
|
+
body: { ...createBody, destinationToken: 'pathusd', sourceToken: 'usdc' },
|
|
863
|
+
idempotencyKey: nextIdempotencyKey(),
|
|
864
|
+
})
|
|
865
|
+
expect(response.status).toBe(200)
|
|
866
|
+
const body = await TestApp.json(response, Routes.schema.createRoutesTransfer.Response)
|
|
867
|
+
|
|
868
|
+
expect(body.fees).toMatchObject([
|
|
869
|
+
{
|
|
870
|
+
amount: { baseUnits: '1000000000000000', formatted: '0.001' },
|
|
871
|
+
side: 'source',
|
|
872
|
+
token: { standard: 'native', symbol: 'ETH' },
|
|
873
|
+
},
|
|
874
|
+
])
|
|
875
|
+
})
|
|
876
|
+
|
|
877
|
+
test('resolves token identifiers through the composed route', async () => {
|
|
878
|
+
const app = transfersApp({ providers: [provider()] })
|
|
879
|
+
const identifiers = [
|
|
880
|
+
{ destinationToken: 'pathusd', name: 'alias', sourceToken: 'usdc' },
|
|
881
|
+
{
|
|
882
|
+
destinationToken: createBody.destinationToken,
|
|
883
|
+
name: 'address',
|
|
884
|
+
sourceToken: createBody.sourceToken,
|
|
885
|
+
},
|
|
886
|
+
{
|
|
887
|
+
destinationToken: 'eip155:4217/erc20:0x20c0000000000000000000000000000000000000',
|
|
888
|
+
name: 'token key',
|
|
889
|
+
sourceToken: 'eip155:8453/erc20:0x833589fcd6edb6e08f4c7c32d4f71b54bda02913',
|
|
890
|
+
},
|
|
891
|
+
] as const
|
|
892
|
+
const results = []
|
|
893
|
+
for (const identifier of identifiers) {
|
|
894
|
+
const response = await postTransfer(app, {
|
|
895
|
+
body: {
|
|
896
|
+
...createBody,
|
|
897
|
+
destinationToken: identifier.destinationToken,
|
|
898
|
+
sourceToken: identifier.sourceToken,
|
|
899
|
+
},
|
|
900
|
+
idempotencyKey: nextIdempotencyKey(),
|
|
901
|
+
})
|
|
902
|
+
const body = await TestApp.json(response, Routes.schema.createRoutesTransfer.Response)
|
|
903
|
+
results.push({
|
|
904
|
+
destinationToken: body.destinationToken.symbol,
|
|
905
|
+
name: identifier.name,
|
|
906
|
+
sourceToken: body.sourceToken.symbol,
|
|
907
|
+
status: response.status,
|
|
908
|
+
})
|
|
909
|
+
}
|
|
910
|
+
|
|
911
|
+
expect(results).toMatchInlineSnapshot(`
|
|
912
|
+
[
|
|
913
|
+
{
|
|
914
|
+
"destinationToken": "pathUSD",
|
|
915
|
+
"name": "alias",
|
|
916
|
+
"sourceToken": "USDC",
|
|
917
|
+
"status": 200,
|
|
918
|
+
},
|
|
919
|
+
{
|
|
920
|
+
"destinationToken": "pathUSD",
|
|
921
|
+
"name": "address",
|
|
922
|
+
"sourceToken": "USDC",
|
|
923
|
+
"status": 200,
|
|
924
|
+
},
|
|
925
|
+
{
|
|
926
|
+
"destinationToken": "pathUSD",
|
|
927
|
+
"name": "token key",
|
|
928
|
+
"sourceToken": "USDC",
|
|
929
|
+
"status": 200,
|
|
930
|
+
},
|
|
931
|
+
]
|
|
932
|
+
`)
|
|
933
|
+
})
|
|
934
|
+
|
|
935
|
+
test('replays the exact response for the same key and body', async () => {
|
|
936
|
+
const app = transfersApp({
|
|
937
|
+
providers: [provider()],
|
|
938
|
+
})
|
|
939
|
+
const idempotencyKey = nextIdempotencyKey()
|
|
940
|
+
const first = await postTransfer(app, { idempotencyKey })
|
|
941
|
+
const second = await postTransfer(app, { idempotencyKey })
|
|
942
|
+
expect(second.status).toBe(200)
|
|
943
|
+
expect(await second.json()).toEqual(await first.json())
|
|
944
|
+
})
|
|
945
|
+
|
|
946
|
+
test('rejects a reused key with different input', async () => {
|
|
947
|
+
const app = transfersApp({
|
|
948
|
+
providers: [provider()],
|
|
949
|
+
})
|
|
950
|
+
const idempotencyKey = nextIdempotencyKey()
|
|
951
|
+
await postTransfer(app, { idempotencyKey })
|
|
952
|
+
const conflict = await postTransfer(app, {
|
|
953
|
+
body: { ...createBody, amount: '2000000' },
|
|
954
|
+
idempotencyKey,
|
|
955
|
+
})
|
|
956
|
+
expect(conflict.status).toBe(409)
|
|
957
|
+
expect(((await conflict.json()) as { error: { code: string } }).error.code).toBe(
|
|
958
|
+
'idempotency_conflict',
|
|
959
|
+
)
|
|
960
|
+
})
|
|
961
|
+
|
|
962
|
+
test('rejects an equivalent request while the first is running', async () => {
|
|
963
|
+
const app = transfersApp({
|
|
964
|
+
providers: [provider()],
|
|
965
|
+
})
|
|
966
|
+
const idempotencyKey = nextIdempotencyKey()
|
|
967
|
+
await RoutesIdempotencyTable.claim(db, {
|
|
968
|
+
apiKeyId: routesWriter.id,
|
|
969
|
+
irrevocable: false,
|
|
970
|
+
keyHash: Idempotency.inputHash(idempotencyKey),
|
|
971
|
+
operation: RoutesIdempotencyTable.operations.transfer,
|
|
972
|
+
orgId: routesWriter.orgId,
|
|
973
|
+
requestHash: Idempotency.inputHash(createBody),
|
|
974
|
+
ttlMs: 60_000,
|
|
975
|
+
})
|
|
976
|
+
const pending = await postTransfer(app, { idempotencyKey })
|
|
977
|
+
expect(pending.status).toBe(409)
|
|
978
|
+
expect(((await pending.json()) as { error: { code: string } }).error.code).toBe(
|
|
979
|
+
'idempotency_in_progress',
|
|
980
|
+
)
|
|
981
|
+
})
|
|
982
|
+
|
|
983
|
+
test('rolls back creation after losing the idempotency lease', async () => {
|
|
984
|
+
const idempotencyKey = nextIdempotencyKey()
|
|
985
|
+
const keyHash = Idempotency.inputHash(idempotencyKey)
|
|
986
|
+
const before = await db.kysely
|
|
987
|
+
.selectFrom('routes_transfers')
|
|
988
|
+
.select(({ fn }) => fn.countAll<number>().as('count'))
|
|
989
|
+
.executeTakeFirstOrThrow()
|
|
990
|
+
const app = transfersApp({
|
|
991
|
+
providers: [
|
|
992
|
+
provider(async () => {
|
|
993
|
+
await db.kysely
|
|
994
|
+
.updateTable('routes_idempotency_requests')
|
|
995
|
+
.set({ expiresAt: new Date(0).toISOString() })
|
|
996
|
+
.where('apiKeyId', '=', routesWriter.id)
|
|
997
|
+
.where('keyHash', '=', keyHash)
|
|
998
|
+
.execute()
|
|
999
|
+
await RoutesIdempotencyTable.claim(db, {
|
|
1000
|
+
apiKeyId: routesWriter.id,
|
|
1001
|
+
irrevocable: false,
|
|
1002
|
+
keyHash,
|
|
1003
|
+
operation: RoutesIdempotencyTable.operations.transfer,
|
|
1004
|
+
orgId: routesWriter.orgId,
|
|
1005
|
+
requestHash: Idempotency.inputHash(createBody),
|
|
1006
|
+
ttlMs: 60_000,
|
|
1007
|
+
})
|
|
1008
|
+
return providerResponse()
|
|
1009
|
+
}),
|
|
1010
|
+
],
|
|
1011
|
+
})
|
|
1012
|
+
|
|
1013
|
+
const response = await postTransfer(app, { idempotencyKey })
|
|
1014
|
+
expect(response.status).toBe(500)
|
|
1015
|
+
const after = await db.kysely
|
|
1016
|
+
.selectFrom('routes_transfers')
|
|
1017
|
+
.select(({ fn }) => fn.countAll<number>().as('count'))
|
|
1018
|
+
.executeTakeFirstOrThrow()
|
|
1019
|
+
expect(after.count).toBe(before.count)
|
|
1020
|
+
})
|
|
1021
|
+
|
|
1022
|
+
test('rejects non-account fields and gates disabled corridors and methods', async () => {
|
|
1023
|
+
const app = transfersApp({
|
|
1024
|
+
providers: [provider()],
|
|
1025
|
+
})
|
|
1026
|
+
|
|
1027
|
+
const ignoredRefund = await postTransfer(app, {
|
|
1028
|
+
body: { ...createBody, refundAddress: createBody.sender },
|
|
1029
|
+
idempotencyKey: nextIdempotencyKey(),
|
|
1030
|
+
})
|
|
1031
|
+
expect(ignoredRefund.status).toBe(400)
|
|
1032
|
+
expect(((await ignoredRefund.json()) as { error: { code: string } }).error.code).toBe(
|
|
1033
|
+
'body_invalid',
|
|
1034
|
+
)
|
|
1035
|
+
|
|
1036
|
+
const unsupportedDestination = await postTransfer(app, {
|
|
1037
|
+
body: { ...createBody, destinationVault: `0x${'f4'.repeat(20)}`, type: 'vault' },
|
|
1038
|
+
idempotencyKey: nextIdempotencyKey(),
|
|
1039
|
+
})
|
|
1040
|
+
expect(unsupportedDestination.status).toBe(400)
|
|
1041
|
+
expect(((await unsupportedDestination.json()) as { error: { code: string } }).error.code).toBe(
|
|
1042
|
+
'body_invalid',
|
|
1043
|
+
)
|
|
1044
|
+
|
|
1045
|
+
const unknownToken = await postTransfer(app, {
|
|
1046
|
+
body: { ...createBody, destinationToken: `0x${'99'.repeat(20)}` },
|
|
1047
|
+
idempotencyKey: nextIdempotencyKey(),
|
|
1048
|
+
})
|
|
1049
|
+
expect(unknownToken.status).toBe(404)
|
|
1050
|
+
|
|
1051
|
+
const unknownChain = await postTransfer(app, {
|
|
1052
|
+
body: { ...createBody, destinationChain: 'bitcoin' },
|
|
1053
|
+
idempotencyKey: nextIdempotencyKey(),
|
|
1054
|
+
})
|
|
1055
|
+
expect(unknownChain.status).toBe(404)
|
|
1056
|
+
})
|
|
1057
|
+
|
|
1058
|
+
test.each([
|
|
1059
|
+
['recipient', { recipient: 'invalid' }],
|
|
1060
|
+
['sender', { sender: 'invalid' }],
|
|
1061
|
+
] as const)('rejects a route-invalid %s before calling the provider', async (_field, body) => {
|
|
1062
|
+
let calls = 0
|
|
1063
|
+
const app = transfersApp({
|
|
1064
|
+
providers: [
|
|
1065
|
+
provider(async () => {
|
|
1066
|
+
calls++
|
|
1067
|
+
return providerResponse()
|
|
1068
|
+
}),
|
|
1069
|
+
],
|
|
1070
|
+
})
|
|
1071
|
+
const response = await postTransfer(app, {
|
|
1072
|
+
body: { ...createBody, ...body },
|
|
1073
|
+
idempotencyKey: nextIdempotencyKey(),
|
|
1074
|
+
})
|
|
1075
|
+
|
|
1076
|
+
expect(response.status).toBe(400)
|
|
1077
|
+
expect(((await response.json()) as { error: { code: string } }).error.code).toBe('body_invalid')
|
|
1078
|
+
expect(calls).toBe(0)
|
|
1079
|
+
})
|
|
1080
|
+
|
|
1081
|
+
test('releases the claim after a provider failure', async () => {
|
|
1082
|
+
const failing = transfersApp({
|
|
1083
|
+
providers: [
|
|
1084
|
+
provider(async () => {
|
|
1085
|
+
throw new Error('upstream unavailable')
|
|
1086
|
+
}),
|
|
1087
|
+
],
|
|
1088
|
+
})
|
|
1089
|
+
const idempotencyKey = nextIdempotencyKey()
|
|
1090
|
+
const failed = await postTransfer(failing, { idempotencyKey })
|
|
1091
|
+
expect(failed.status).toBe(502)
|
|
1092
|
+
expect(((await failed.json()) as { error: { code: string } }).error.code).toBe('upstream_error')
|
|
1093
|
+
|
|
1094
|
+
// The key was released, so the same request retries successfully.
|
|
1095
|
+
const working = transfersApp({
|
|
1096
|
+
providers: [provider()],
|
|
1097
|
+
})
|
|
1098
|
+
expect((await postTransfer(working, { idempotencyKey })).status).toBe(200)
|
|
1099
|
+
})
|
|
1100
|
+
|
|
1101
|
+
test('rejects preparations with unbounded approvals', async () => {
|
|
1102
|
+
const app = transfersApp({
|
|
1103
|
+
providers: [
|
|
1104
|
+
provider(async () => {
|
|
1105
|
+
const result = providerResponse()
|
|
1106
|
+
const spender = `0x${'44'.repeat(20)}`
|
|
1107
|
+
return {
|
|
1108
|
+
...result,
|
|
1109
|
+
action: {
|
|
1110
|
+
calls: [
|
|
1111
|
+
{
|
|
1112
|
+
data: `0x095ea7b3${spender.slice(2).padStart(64, '0')}${'f'.repeat(64)}`,
|
|
1113
|
+
to: createBody.sourceToken,
|
|
1114
|
+
value: '0x0',
|
|
1115
|
+
},
|
|
1116
|
+
],
|
|
1117
|
+
type: 'evm:calls',
|
|
1118
|
+
},
|
|
1119
|
+
}
|
|
1120
|
+
}),
|
|
1121
|
+
],
|
|
1122
|
+
})
|
|
1123
|
+
const response = await postTransfer(app, { idempotencyKey: nextIdempotencyKey() })
|
|
1124
|
+
expect(response.status).toBe(502)
|
|
1125
|
+
})
|
|
1126
|
+
})
|
|
1127
|
+
|
|
1128
|
+
describe.skipIf(!Anvil.available)('POST /routes/transfers (forked localnet)', () => {
|
|
1129
|
+
/**
|
|
1130
|
+
* Storage slot of Circle FiatToken's `balanceAndBlacklistStates` mapping.
|
|
1131
|
+
* `anvil_dealERC20` cannot probe it because balances pack a blacklist bit,
|
|
1132
|
+
* so the fork suite writes the slot directly. Every curated USDC is a
|
|
1133
|
+
* FiatToken.
|
|
1134
|
+
*/
|
|
1135
|
+
const fiatTokenBalanceSlot = 9n
|
|
1136
|
+
|
|
1137
|
+
for (const executable of executableProviders) {
|
|
1138
|
+
describe(executable.id, () => {
|
|
1139
|
+
const route = TestRoutes.snapshot.routes.find(
|
|
1140
|
+
(entry) =>
|
|
1141
|
+
entry.route.source.chain.id === `eip155:${base.id}` &&
|
|
1142
|
+
entry.route.source.symbol === 'USDC' &&
|
|
1143
|
+
entry.route.destination.slug === executable.destinationToken,
|
|
1144
|
+
)!
|
|
1145
|
+
const usdc = route.route.source
|
|
1146
|
+
const amount = Value.from('10', usdc.decimals)
|
|
1147
|
+
const sender = Anvil.getAccount(0)
|
|
1148
|
+
|
|
1149
|
+
let anvil: Anvil.start.ReturnType
|
|
1150
|
+
|
|
1151
|
+
beforeAll(async () => {
|
|
1152
|
+
anvil = await Anvil.start({ chain: base, forkUrl: base.rpcUrls.default.http[0]! })
|
|
1153
|
+
})
|
|
1154
|
+
|
|
1155
|
+
afterAll(async () => {
|
|
1156
|
+
await anvil?.stop()
|
|
1157
|
+
})
|
|
1158
|
+
|
|
1159
|
+
function createTransfer(idempotencyKey: string) {
|
|
1160
|
+
const app = transfersApp({ providers: [executable.create(sender.address)] })
|
|
1161
|
+
return postTransfer(app, {
|
|
1162
|
+
body: {
|
|
1163
|
+
...createBody,
|
|
1164
|
+
amount: amount.toString(),
|
|
1165
|
+
destinationToken: executable.destinationToken,
|
|
1166
|
+
sender: sender.address,
|
|
1167
|
+
},
|
|
1168
|
+
idempotencyKey,
|
|
1169
|
+
})
|
|
1170
|
+
}
|
|
1171
|
+
|
|
1172
|
+
test('executes the prepared calls and returns successful receipts', async () => {
|
|
1173
|
+
const { client } = anvil
|
|
1174
|
+
await Anvil.setErc20Balance(client, {
|
|
1175
|
+
address: sender.address,
|
|
1176
|
+
amount,
|
|
1177
|
+
slot: fiatTokenBalanceSlot,
|
|
1178
|
+
token: usdc.address as `0x${string}`,
|
|
1179
|
+
})
|
|
1180
|
+
|
|
1181
|
+
const response = await createTransfer(`bridge_${executable.id}_${sender.address}`)
|
|
1182
|
+
expect(response.status).toBe(200)
|
|
1183
|
+
const transfer = await TestApp.json(response, Routes.schema.createRoutesTransfer.Response)
|
|
1184
|
+
expect(transfer.action.type).toBe('evm:calls')
|
|
1185
|
+
if (transfer.action.type !== 'evm:calls') return
|
|
1186
|
+
expect(transfer.action.calls.length).toBeGreaterThan(0)
|
|
1187
|
+
if (executable.id === 'stargate') {
|
|
1188
|
+
expect(transfer.fees).toMatchObject([
|
|
1189
|
+
{
|
|
1190
|
+
amount: { baseUnits: BigInt(transfer.action.calls.at(-1)!.value).toString() },
|
|
1191
|
+
side: 'source',
|
|
1192
|
+
token: { standard: 'native', symbol: 'ETH' },
|
|
1193
|
+
},
|
|
1194
|
+
])
|
|
1195
|
+
const row = await db.kysely
|
|
1196
|
+
.selectFrom('routes_transfers')
|
|
1197
|
+
.select('providerState')
|
|
1198
|
+
.where('id', '=', transfer.id)
|
|
1199
|
+
.executeTakeFirstOrThrow()
|
|
1200
|
+
expect(row.providerState).toEqual({
|
|
1201
|
+
destinationBlockNumber: expect.stringMatching(/^\d+$/),
|
|
1202
|
+
routeConfiguration: stargateConfiguration,
|
|
1203
|
+
})
|
|
1204
|
+
}
|
|
1205
|
+
|
|
1206
|
+
const receipts = []
|
|
1207
|
+
for (const call of transfer.action.calls) {
|
|
1208
|
+
receipts.push(
|
|
1209
|
+
await client.sendTransactionSync({
|
|
1210
|
+
account: sender,
|
|
1211
|
+
data: call.data as `0x${string}`,
|
|
1212
|
+
to: call.to as `0x${string}`,
|
|
1213
|
+
value: BigInt(call.value),
|
|
1214
|
+
}),
|
|
1215
|
+
)
|
|
1216
|
+
}
|
|
1217
|
+
|
|
1218
|
+
expect(receipts.map((receipt) => receipt.status)).toEqual(
|
|
1219
|
+
transfer.action.calls.map(() => 'success'),
|
|
1220
|
+
)
|
|
1221
|
+
// The deposit is the last call and must emit; an approval alone proves nothing.
|
|
1222
|
+
expect(receipts.at(-1)!.logs.length).toBeGreaterThan(0)
|
|
1223
|
+
if (executable.id === 'stargate') {
|
|
1224
|
+
const receipt = receipts.at(-1)!
|
|
1225
|
+
const finalized = await client.getBlock({ blockTag: 'finalized' })
|
|
1226
|
+
expect(receipt.blockNumber).toBeGreaterThan(finalized.number)
|
|
1227
|
+
await expect(
|
|
1228
|
+
Stargate.verifySourceTransaction({
|
|
1229
|
+
configuration: stargateConfiguration,
|
|
1230
|
+
destinationAmountMin: transfer.destinationAmountMin!.baseUnits,
|
|
1231
|
+
destinationChain: RoutesChain.from({
|
|
1232
|
+
id: 'eip155:4217',
|
|
1233
|
+
name: 'Tempo',
|
|
1234
|
+
rpcUrls: [tempoMainnet.rpcUrls.default.http[0]!],
|
|
1235
|
+
slug: 'tempo',
|
|
1236
|
+
}),
|
|
1237
|
+
destinationTokenAddress: transfer.destinationToken.address,
|
|
1238
|
+
recipient: transfer.recipient,
|
|
1239
|
+
sender: sender.address,
|
|
1240
|
+
sourceAmount: transfer.sourceAmount.baseUnits,
|
|
1241
|
+
sourceChain: RoutesChain.from({
|
|
1242
|
+
id: 'eip155:8453',
|
|
1243
|
+
name: 'Base',
|
|
1244
|
+
rpcUrls: [anvil.rpcUrl],
|
|
1245
|
+
slug: 'base',
|
|
1246
|
+
}),
|
|
1247
|
+
sourceTokenAddress: transfer.sourceToken.address,
|
|
1248
|
+
transactionHash: receipt.transactionHash,
|
|
1249
|
+
validAfter: transfer.quote.sampledAt,
|
|
1250
|
+
}),
|
|
1251
|
+
).resolves.toMatchObject({ type: 'verified' })
|
|
1252
|
+
}
|
|
1253
|
+
})
|
|
1254
|
+
|
|
1255
|
+
if (executable.id === 'stargate')
|
|
1256
|
+
test('registers non-atomic calls and reopens them after an execution reorg', async () => {
|
|
1257
|
+
await Anvil.setErc20Balance(anvil.client, {
|
|
1258
|
+
address: sender.address,
|
|
1259
|
+
amount,
|
|
1260
|
+
slot: fiatTokenBalanceSlot,
|
|
1261
|
+
token: usdc.address as `0x${string}`,
|
|
1262
|
+
})
|
|
1263
|
+
const response = await createTransfer(`bridge_reorg_${sender.address}`)
|
|
1264
|
+
expect(response.status).toBe(200)
|
|
1265
|
+
const transfer = await TestApp.json(response, Routes.schema.createRoutesTransfer.Response)
|
|
1266
|
+
expect(transfer.action.type).toBe('evm:calls')
|
|
1267
|
+
if (transfer.action.type !== 'evm:calls') return
|
|
1268
|
+
|
|
1269
|
+
const checkpoint = await anvil.client.snapshot()
|
|
1270
|
+
// Anvil increments fork timestamps instead of following wall time between tests.
|
|
1271
|
+
const block = await anvil.client.getBlock()
|
|
1272
|
+
const sampledAt = BigInt(Math.floor(Date.parse(transfer.quote.sampledAt) / 1_000))
|
|
1273
|
+
if (block.timestamp < sampledAt)
|
|
1274
|
+
await anvil.client.setNextBlockTimestamp({ timestamp: sampledAt })
|
|
1275
|
+
let reverted = false
|
|
1276
|
+
try {
|
|
1277
|
+
const receipts = []
|
|
1278
|
+
for (const call of transfer.action.calls)
|
|
1279
|
+
receipts.push(
|
|
1280
|
+
await anvil.client.sendTransactionSync({
|
|
1281
|
+
account: sender,
|
|
1282
|
+
data: call.data as `0x${string}`,
|
|
1283
|
+
to: call.to as `0x${string}`,
|
|
1284
|
+
value: BigInt(call.value),
|
|
1285
|
+
}),
|
|
1286
|
+
)
|
|
1287
|
+
const sourceReceipt = receipts.at(-1)!
|
|
1288
|
+
const transactionHash = sourceReceipt.transactionHash
|
|
1289
|
+
await RoutesCatalog.publish(db, {
|
|
1290
|
+
...TestRoutes.data,
|
|
1291
|
+
chains: TestRoutes.data.chains.map((chain) =>
|
|
1292
|
+
chain.id === 'eip155:8453' ? { ...chain, rpcUrls: [anvil.rpcUrl] } : chain,
|
|
1293
|
+
),
|
|
1294
|
+
})
|
|
1295
|
+
const messages: RoutesTransferReconciliation.Message[] = []
|
|
1296
|
+
const app = transfersApp({
|
|
1297
|
+
routes: {
|
|
1298
|
+
async dispatchTransferReconciliation(message) {
|
|
1299
|
+
messages.push(message)
|
|
1300
|
+
},
|
|
1301
|
+
},
|
|
1302
|
+
providers: [Stargate.stargate()],
|
|
1303
|
+
})
|
|
1304
|
+
const registered = await app.request(
|
|
1305
|
+
`/v1/routes/transfers/${transfer.id}/source-transactions`,
|
|
1306
|
+
{
|
|
1307
|
+
body: JSON.stringify({
|
|
1308
|
+
transactionHashes: receipts.map((receipt) => receipt.transactionHash),
|
|
1309
|
+
}),
|
|
1310
|
+
headers: { ...as(routesWriter).headers, 'content-type': 'application/json' },
|
|
1311
|
+
method: 'POST',
|
|
1312
|
+
},
|
|
1313
|
+
)
|
|
1314
|
+
expect(registered.status).toBe(200)
|
|
1315
|
+
expect(messages).toEqual([
|
|
1316
|
+
{ transferId: transfer.id, type: 'routes:transfer:reconcile' },
|
|
1317
|
+
])
|
|
1318
|
+
|
|
1319
|
+
await anvil.client.revert({ id: checkpoint })
|
|
1320
|
+
reverted = true
|
|
1321
|
+
const tracker = RoutesTransferReconciliation.createTracker({
|
|
1322
|
+
db,
|
|
1323
|
+
async dispatch(message) {
|
|
1324
|
+
messages.push(message)
|
|
1325
|
+
},
|
|
1326
|
+
providers: [Stargate.stargate()],
|
|
1327
|
+
})
|
|
1328
|
+
await expect(tracker.reconcile(messages[0]!)).resolves.toEqual({ type: 'pending' })
|
|
1329
|
+
expect(messages[1]).toEqual({
|
|
1330
|
+
attempt: 1,
|
|
1331
|
+
transferId: transfer.id,
|
|
1332
|
+
type: 'routes:transfer:reconcile',
|
|
1333
|
+
})
|
|
1334
|
+
|
|
1335
|
+
const pending = await db.kysely
|
|
1336
|
+
.selectFrom('routes_transfers')
|
|
1337
|
+
.select(['snapshot', 'status', 'version'])
|
|
1338
|
+
.where('id', '=', transfer.id)
|
|
1339
|
+
.executeTakeFirstOrThrow()
|
|
1340
|
+
expect({
|
|
1341
|
+
sourceTransactionHashes: pending.snapshot.sourceTransactionHashes,
|
|
1342
|
+
status: pending.status,
|
|
1343
|
+
version: pending.version,
|
|
1344
|
+
}).toEqual({
|
|
1345
|
+
sourceTransactionHashes: [transactionHash, receipts[0]!.transactionHash],
|
|
1346
|
+
status: 'processing',
|
|
1347
|
+
version: 2,
|
|
1348
|
+
})
|
|
1349
|
+
|
|
1350
|
+
await anvil.client.mine({ blocks: 128 })
|
|
1351
|
+
const finalized = await anvil.client.getBlock({ blockTag: 'finalized' })
|
|
1352
|
+
expect(finalized.number).toBeGreaterThanOrEqual(sourceReceipt.blockNumber)
|
|
1353
|
+
await expect(tracker.reconcile(messages[1]!)).resolves.toEqual({ type: 'reopened' })
|
|
1354
|
+
|
|
1355
|
+
const record = await db.kysely
|
|
1356
|
+
.selectFrom('routes_transfers')
|
|
1357
|
+
.select(['snapshot', 'status', 'version'])
|
|
1358
|
+
.where('id', '=', transfer.id)
|
|
1359
|
+
.executeTakeFirstOrThrow()
|
|
1360
|
+
expect({
|
|
1361
|
+
sourceTransactionHashes: record.snapshot.sourceTransactionHashes,
|
|
1362
|
+
status: record.status,
|
|
1363
|
+
version: record.version,
|
|
1364
|
+
}).toEqual({
|
|
1365
|
+
sourceTransactionHashes: undefined,
|
|
1366
|
+
status: 'awaiting-source',
|
|
1367
|
+
version: 3,
|
|
1368
|
+
})
|
|
1369
|
+
expect(
|
|
1370
|
+
await db.kysely
|
|
1371
|
+
.selectFrom('routes_transfer_transactions')
|
|
1372
|
+
.selectAll()
|
|
1373
|
+
.where('transferId', '=', transfer.id)
|
|
1374
|
+
.execute(),
|
|
1375
|
+
).toEqual([])
|
|
1376
|
+
} finally {
|
|
1377
|
+
if (!reverted) await anvil.client.revert({ id: checkpoint })
|
|
1378
|
+
await TestRoutes.publish(db)
|
|
1379
|
+
}
|
|
1380
|
+
})
|
|
1381
|
+
|
|
1382
|
+
test('bounds the approval to the quoted source spend', async () => {
|
|
1383
|
+
const response = await createTransfer(`bridge_bounds_${executable.id}_${sender.address}`)
|
|
1384
|
+
expect(response.status).toBe(200)
|
|
1385
|
+
const transfer = await TestApp.json(response, Routes.schema.createRoutesTransfer.Response)
|
|
1386
|
+
if (transfer.action.type !== 'evm:calls') return
|
|
1387
|
+
|
|
1388
|
+
const approval = transfer.action.calls.find((call) =>
|
|
1389
|
+
call.data.toLowerCase().startsWith('0x095ea7b3'),
|
|
1390
|
+
)
|
|
1391
|
+
expect(approval).toBeDefined()
|
|
1392
|
+
if (!approval) return
|
|
1393
|
+
|
|
1394
|
+
// Decoded from the live action, so a provider that starts returning
|
|
1395
|
+
// an unlimited allowance fails here.
|
|
1396
|
+
const decoded = decodeFunctionData({ abi: erc20Abi, data: approval.data as `0x${string}` })
|
|
1397
|
+
expect(decoded.functionName).toBe('approve')
|
|
1398
|
+
if (decoded.functionName !== 'approve') return
|
|
1399
|
+
const [, approved] = decoded.args
|
|
1400
|
+
expect(approved).toBeLessThanOrEqual(BigInt(transfer.sourceAmount.baseUnits))
|
|
1401
|
+
expect(approved).toBeLessThan(maxUint256)
|
|
1402
|
+
})
|
|
1403
|
+
})
|
|
1404
|
+
}
|
|
1405
|
+
})
|
|
1406
|
+
|
|
1407
|
+
describe.skipIf(!Anvil.available)(
|
|
1408
|
+
'POST /routes/transfers/:id/source-transactions (forked localnet)',
|
|
1409
|
+
() => {
|
|
1410
|
+
const trackingDb = TestApp.database()
|
|
1411
|
+
let destination: Anvil.start.ReturnType
|
|
1412
|
+
let source: Anvil.start.ReturnType
|
|
1413
|
+
|
|
1414
|
+
beforeAll(async () => {
|
|
1415
|
+
;[destination, source] = await Promise.all([
|
|
1416
|
+
Anvil.start({ chain: tempoMainnet, forkUrl: tempoMainnet.rpcUrls.default.http[0]! }),
|
|
1417
|
+
Anvil.start({ chain: base, forkUrl: base.rpcUrls.default.http[0]! }),
|
|
1418
|
+
])
|
|
1419
|
+
await RoutesCatalog.publish(trackingDb, {
|
|
1420
|
+
...TestRoutes.data,
|
|
1421
|
+
chains: TestRoutes.data.chains.map((chain) => {
|
|
1422
|
+
if (chain.id === 'eip155:4217') return { ...chain, rpcUrls: [destination.rpcUrl] }
|
|
1423
|
+
if (chain.id === 'eip155:8453') return { ...chain, rpcUrls: [source.rpcUrl] }
|
|
1424
|
+
return chain
|
|
1425
|
+
}),
|
|
1426
|
+
})
|
|
1427
|
+
})
|
|
1428
|
+
|
|
1429
|
+
afterAll(async () => {
|
|
1430
|
+
await Promise.all([destination?.stop(), source?.stop()])
|
|
1431
|
+
})
|
|
1432
|
+
|
|
1433
|
+
test('backfills legacy state and completes despite a foreign source claim', async () => {
|
|
1434
|
+
const destinationReceipt = await destination.client.getTransactionReceipt({
|
|
1435
|
+
hash: destinationTransactionHash,
|
|
1436
|
+
})
|
|
1437
|
+
const sourceTransactionHash =
|
|
1438
|
+
'0xfd71359adf5095f2ab512a19e0a2df6c8cc0db14ac8a52286d61287daabdccd4'
|
|
1439
|
+
const sourceReceipt = await source.client.getTransactionReceipt({
|
|
1440
|
+
hash: sourceTransactionHash,
|
|
1441
|
+
})
|
|
1442
|
+
const sourceBlock = await source.client.getBlock({ blockNumber: sourceReceipt.blockNumber })
|
|
1443
|
+
const sampledAt = new Date(Number(sourceBlock.timestamp - 1n) * 1_000).toISOString()
|
|
1444
|
+
const amount = {
|
|
1445
|
+
baseUnits: '200000',
|
|
1446
|
+
currency: 'USD',
|
|
1447
|
+
decimals: 6,
|
|
1448
|
+
formatted: '0.2',
|
|
1449
|
+
} as const
|
|
1450
|
+
const snapshot = {
|
|
1451
|
+
...TestRoutes.transferSnapshot({
|
|
1452
|
+
destinationAmount: amount,
|
|
1453
|
+
destinationAmountMin: amount,
|
|
1454
|
+
provider: { id: 'stargate', name: 'Stargate' },
|
|
1455
|
+
recipient: '0x7212623e4cff9ad010d28aa065fad2bf58578783',
|
|
1456
|
+
sender: '0x52b650a62e384f68880d0a1dc2b84dfed47d5660',
|
|
1457
|
+
sourceAmount: amount,
|
|
1458
|
+
}),
|
|
1459
|
+
quote: {
|
|
1460
|
+
expiresAt: new Date(Date.parse(sampledAt) + 60_000).toISOString(),
|
|
1461
|
+
sampledAt,
|
|
1462
|
+
},
|
|
1463
|
+
}
|
|
1464
|
+
const subscriptions = await Promise.all(
|
|
1465
|
+
[routesForeign, routesWriter].map((key) =>
|
|
1466
|
+
Webhooks.createSubscription(trackingDb, {
|
|
1467
|
+
chainId: 4217,
|
|
1468
|
+
destination: { type: 'url', url: 'https://example.com/routes' },
|
|
1469
|
+
environment: 'production',
|
|
1470
|
+
eventType: 'routes:transfer.updated',
|
|
1471
|
+
owner: { orgId: key.orgId, type: 'api_key' },
|
|
1472
|
+
}),
|
|
1473
|
+
),
|
|
1474
|
+
)
|
|
1475
|
+
const transfer = await RoutesTransfer.create(trackingDb, {
|
|
1476
|
+
apiKeyId: routesWriter.id,
|
|
1477
|
+
environment: 'production',
|
|
1478
|
+
orgId: routesWriter.orgId,
|
|
1479
|
+
snapshot,
|
|
1480
|
+
})
|
|
1481
|
+
const foreign = await RoutesTransfer.create(trackingDb, {
|
|
1482
|
+
apiKeyId: routesForeign.id,
|
|
1483
|
+
environment: 'production',
|
|
1484
|
+
orgId: routesForeign.orgId,
|
|
1485
|
+
snapshot,
|
|
1486
|
+
})
|
|
1487
|
+
const tracker = RoutesTransferReconciliation.createTracker({
|
|
1488
|
+
db: trackingDb,
|
|
1489
|
+
providers: [Stargate.stargate()],
|
|
1490
|
+
})
|
|
1491
|
+
const messages: RoutesTransferReconciliation.Message[] = []
|
|
1492
|
+
let dispatchEnabled = true
|
|
1493
|
+
const app = TestApp.create({
|
|
1494
|
+
auth: { keys: [routesForeign, routesWriter] },
|
|
1495
|
+
db: trackingDb,
|
|
1496
|
+
defaultChainId: tempoMainnet.id,
|
|
1497
|
+
routes: {
|
|
1498
|
+
async dispatchTransferReconciliation(message) {
|
|
1499
|
+
if (!dispatchEnabled) throw new Error('reconciliation unavailable')
|
|
1500
|
+
messages.push(message)
|
|
1501
|
+
},
|
|
1502
|
+
},
|
|
1503
|
+
providers: [Stargate.stargate()],
|
|
1504
|
+
})
|
|
1505
|
+
const path = `/v1/routes/transfers/${transfer.id}/source-transactions`
|
|
1506
|
+
const registration = {
|
|
1507
|
+
body: JSON.stringify({
|
|
1508
|
+
transactionHashes: [sourceTransactionHash],
|
|
1509
|
+
}),
|
|
1510
|
+
headers: { ...as(routesWriter).headers, 'content-type': 'application/json' },
|
|
1511
|
+
method: 'POST',
|
|
1512
|
+
}
|
|
1513
|
+
const foreignResponse = await app.request(
|
|
1514
|
+
`/v1/routes/transfers/${foreign.id}/source-transactions`,
|
|
1515
|
+
{
|
|
1516
|
+
...registration,
|
|
1517
|
+
headers: { ...as(routesForeign).headers, 'content-type': 'application/json' },
|
|
1518
|
+
},
|
|
1519
|
+
)
|
|
1520
|
+
expect(foreignResponse.status).toBe(200)
|
|
1521
|
+
expect(
|
|
1522
|
+
(await app.request(`/v1/routes/transfers/${foreign.id}`, as(routesWriter))).status,
|
|
1523
|
+
).toBe(404)
|
|
1524
|
+
expect(await tracker.reconcile(messages[0]!)).toEqual({ type: 'completed' })
|
|
1525
|
+
|
|
1526
|
+
const response = await app.request(path, registration)
|
|
1527
|
+
expect(response.status).toBe(200)
|
|
1528
|
+
const registered = await TestApp.json(
|
|
1529
|
+
response,
|
|
1530
|
+
Routes.schema.registerRoutesTransferSourceTransaction.Response,
|
|
1531
|
+
)
|
|
1532
|
+
expect({
|
|
1533
|
+
sourceTransactionHashes: registered.sourceTransactionHashes,
|
|
1534
|
+
status: registered.status,
|
|
1535
|
+
version: registered.version,
|
|
1536
|
+
}).toEqual({
|
|
1537
|
+
sourceTransactionHashes: [
|
|
1538
|
+
'0xfd71359adf5095f2ab512a19e0a2df6c8cc0db14ac8a52286d61287daabdccd4',
|
|
1539
|
+
],
|
|
1540
|
+
status: 'processing',
|
|
1541
|
+
version: 2,
|
|
1542
|
+
})
|
|
1543
|
+
const stored = await trackingDb.kysely
|
|
1544
|
+
.selectFrom('routes_transfers')
|
|
1545
|
+
.select('providerState')
|
|
1546
|
+
.where('id', '=', transfer.id)
|
|
1547
|
+
.executeTakeFirstOrThrow()
|
|
1548
|
+
expect(stored).toEqual({
|
|
1549
|
+
providerState: {
|
|
1550
|
+
destinationBlockNumber: expect.stringMatching(/^\d+$/),
|
|
1551
|
+
routeConfiguration: stargateConfiguration,
|
|
1552
|
+
stargate: {
|
|
1553
|
+
guid: '0x5549d117c8b23f0ecdf05c2604ed989cf0034f378707bd81319e93834f2f85f2',
|
|
1554
|
+
sourceBlock: {
|
|
1555
|
+
hash: sourceReceipt.blockHash,
|
|
1556
|
+
number: sourceReceipt.blockNumber.toString(),
|
|
1557
|
+
},
|
|
1558
|
+
sourceEid: 30_184,
|
|
1559
|
+
},
|
|
1560
|
+
},
|
|
1561
|
+
})
|
|
1562
|
+
const destinationBlockNumber = stored.providerState?.['destinationBlockNumber']
|
|
1563
|
+
if (typeof destinationBlockNumber !== 'string')
|
|
1564
|
+
throw new Error('Expected a backfilled destination block number.')
|
|
1565
|
+
expect(BigInt(destinationBlockNumber)).toBeLessThanOrEqual(destinationReceipt.blockNumber)
|
|
1566
|
+
expect(messages).toEqual([
|
|
1567
|
+
{ transferId: foreign.id, type: 'routes:transfer:reconcile' },
|
|
1568
|
+
{ transferId: transfer.id, type: 'routes:transfer:reconcile' },
|
|
1569
|
+
])
|
|
1570
|
+
await tracker.reconcile(messages[1]!)
|
|
1571
|
+
|
|
1572
|
+
const completed = await TestApp.json(
|
|
1573
|
+
await app.request(`/v1/routes/transfers/${transfer.id}`, as(routesWriter)),
|
|
1574
|
+
Routes.schema.getRoutesTransfer.Response,
|
|
1575
|
+
)
|
|
1576
|
+
expect({
|
|
1577
|
+
destinationTransactionHashes: completed.destinationTransactionHashes,
|
|
1578
|
+
status: completed.status,
|
|
1579
|
+
version: completed.version,
|
|
1580
|
+
}).toEqual({
|
|
1581
|
+
destinationTransactionHashes: [destinationTransactionHash],
|
|
1582
|
+
status: 'completed',
|
|
1583
|
+
version: 3,
|
|
1584
|
+
})
|
|
1585
|
+
|
|
1586
|
+
const events = await trackingDb.kysely
|
|
1587
|
+
.selectFrom('webhook_queue_events')
|
|
1588
|
+
.select(['envelope', 'subscriptionId'])
|
|
1589
|
+
.where(
|
|
1590
|
+
'subscriptionId',
|
|
1591
|
+
'in',
|
|
1592
|
+
subscriptions.map(({ id }) => id),
|
|
1593
|
+
)
|
|
1594
|
+
.execute()
|
|
1595
|
+
for (const [index, record] of [foreign, transfer].entries()) {
|
|
1596
|
+
const own = events.filter(
|
|
1597
|
+
({ subscriptionId }) => subscriptionId === subscriptions[index]!.id,
|
|
1598
|
+
)
|
|
1599
|
+
expect(own.map(({ envelope }) => envelope.data)).toEqual(
|
|
1600
|
+
expect.arrayContaining([
|
|
1601
|
+
expect.objectContaining({ id: record.id, status: 'awaiting-source', version: 1 }),
|
|
1602
|
+
expect.objectContaining({ id: record.id, status: 'processing', version: 2 }),
|
|
1603
|
+
expect.objectContaining({ id: record.id, status: 'completed', version: 3 }),
|
|
1604
|
+
]),
|
|
1605
|
+
)
|
|
1606
|
+
expect(own).toHaveLength(3)
|
|
1607
|
+
}
|
|
1608
|
+
|
|
1609
|
+
dispatchEnabled = false
|
|
1610
|
+
const replayed = await TestApp.json(
|
|
1611
|
+
await app.request(path, registration),
|
|
1612
|
+
Routes.schema.registerRoutesTransferSourceTransaction.Response,
|
|
1613
|
+
)
|
|
1614
|
+
expect({ status: replayed.status, version: replayed.version }).toEqual({
|
|
1615
|
+
status: 'completed',
|
|
1616
|
+
version: 3,
|
|
1617
|
+
})
|
|
1618
|
+
|
|
1619
|
+
const other = await RoutesTransfer.create(trackingDb, {
|
|
1620
|
+
apiKeyId: routesWriter.id,
|
|
1621
|
+
environment: 'production',
|
|
1622
|
+
orgId: routesWriter.orgId,
|
|
1623
|
+
snapshot,
|
|
1624
|
+
})
|
|
1625
|
+
const conflict = await app.request(
|
|
1626
|
+
`/v1/routes/transfers/${other.id}/source-transactions`,
|
|
1627
|
+
registration,
|
|
1628
|
+
)
|
|
1629
|
+
expect(conflict.status).toBe(409)
|
|
1630
|
+
expect(((await conflict.json()) as { error: { code: string } }).error.code).toBe(
|
|
1631
|
+
'source_transaction_conflict',
|
|
1632
|
+
)
|
|
1633
|
+
|
|
1634
|
+
const pending = await RoutesTransfer.create(trackingDb, {
|
|
1635
|
+
apiKeyId: routesWriter.id,
|
|
1636
|
+
environment: 'production',
|
|
1637
|
+
orgId: routesWriter.orgId,
|
|
1638
|
+
snapshot,
|
|
1639
|
+
})
|
|
1640
|
+
const pendingResponse = await app.request(
|
|
1641
|
+
`/v1/routes/transfers/${pending.id}/source-transactions`,
|
|
1642
|
+
{
|
|
1643
|
+
...registration,
|
|
1644
|
+
body: JSON.stringify({ transactionHashes: [`0x${'99'.repeat(32)}`] }),
|
|
1645
|
+
},
|
|
1646
|
+
)
|
|
1647
|
+
expect(pendingResponse.status).toBe(409)
|
|
1648
|
+
expect(((await pendingResponse.json()) as { error: { code: string } }).error.code).toBe(
|
|
1649
|
+
'source_transaction_pending',
|
|
1650
|
+
)
|
|
1651
|
+
})
|
|
1652
|
+
|
|
1653
|
+
test('registers all five Tempo Stargate calls and rejects mismatched fee terms', async () => {
|
|
1654
|
+
const sourceTransactionHashes = [
|
|
1655
|
+
'0xec00883936af1eb22402c471cf05827ac161d78e832ea771ff3b936d4e5d7517',
|
|
1656
|
+
'0x55e22e5308d6261bb3ef04233cf29d85f342b5bf7ab2db0e34382be52a029b7e',
|
|
1657
|
+
'0x75761272e9a8365636b0f4038f9908f18461d4f7083c6aa610831b81db681812',
|
|
1658
|
+
'0xe840e103cfe4d62f9de0439f14f1010bae8f455585797577cb85fef3a77bc56b',
|
|
1659
|
+
'0x56c9ad54ea6213b2091434efa82dcc072a800876c85c1a2068d1202af18e73b6',
|
|
1660
|
+
]
|
|
1661
|
+
const routeConfiguration = {
|
|
1662
|
+
destinationPoolAddress: '0x27a16dc786820B16E5c9028b75B99F6f604b5d26',
|
|
1663
|
+
poolAddress: '0x8c76e2F6C5ceDA9AA7772e7efF30280226c44392',
|
|
1664
|
+
}
|
|
1665
|
+
const amount = {
|
|
1666
|
+
baseUnits: '200000',
|
|
1667
|
+
currency: 'USD',
|
|
1668
|
+
decimals: 6,
|
|
1669
|
+
formatted: '0.2',
|
|
1670
|
+
} as const
|
|
1671
|
+
const fee = {
|
|
1672
|
+
amount: { baseUnits: '500000', currency: 'USD', decimals: 6, formatted: '0.5' },
|
|
1673
|
+
side: 'source',
|
|
1674
|
+
token: {
|
|
1675
|
+
address: '0x20c0000000000000000000000000000000000000',
|
|
1676
|
+
currency: 'USD',
|
|
1677
|
+
decimals: 6,
|
|
1678
|
+
name: 'pathUSD',
|
|
1679
|
+
standard: 'TIP-20',
|
|
1680
|
+
symbol: 'pathUSD',
|
|
1681
|
+
tokenKey: 'eip155:4217/erc20:0x20c0000000000000000000000000000000000000',
|
|
1682
|
+
verified: true,
|
|
1683
|
+
},
|
|
1684
|
+
type: 'provider',
|
|
1685
|
+
} as const
|
|
1686
|
+
const snapshot = TestRoutes.transferSnapshot({
|
|
1687
|
+
destinationAmount: {
|
|
1688
|
+
baseUnits: '199979',
|
|
1689
|
+
currency: 'USD',
|
|
1690
|
+
decimals: 6,
|
|
1691
|
+
formatted: '0.199979',
|
|
1692
|
+
},
|
|
1693
|
+
destinationAmountMin: {
|
|
1694
|
+
baseUnits: '199979',
|
|
1695
|
+
currency: 'USD',
|
|
1696
|
+
decimals: 6,
|
|
1697
|
+
formatted: '0.199979',
|
|
1698
|
+
},
|
|
1699
|
+
destinationChain: {
|
|
1700
|
+
addressFormat: 'hex',
|
|
1701
|
+
id: 'eip155:8453',
|
|
1702
|
+
kind: 'evm',
|
|
1703
|
+
name: 'Base',
|
|
1704
|
+
},
|
|
1705
|
+
destinationToken: {
|
|
1706
|
+
address: '0x833589fcd6edb6e08f4c7c32d4f71b54bda02913',
|
|
1707
|
+
currency: 'USD',
|
|
1708
|
+
decimals: 6,
|
|
1709
|
+
name: 'USD Coin',
|
|
1710
|
+
standard: 'ERC-20',
|
|
1711
|
+
symbol: 'USDC',
|
|
1712
|
+
tokenKey: 'eip155:8453/erc20:0x833589fcd6edb6e08f4c7c32d4f71b54bda02913',
|
|
1713
|
+
verified: true,
|
|
1714
|
+
},
|
|
1715
|
+
fees: [fee],
|
|
1716
|
+
provider: { id: 'stargate', name: 'Stargate' },
|
|
1717
|
+
quote: {
|
|
1718
|
+
expiresAt: '2026-09-03T16:04:31.000Z',
|
|
1719
|
+
sampledAt: '2026-09-03T16:03:31.000Z',
|
|
1720
|
+
},
|
|
1721
|
+
recipient: '0xa8a89a017cd431c31af421f7d829e9418a5016ba',
|
|
1722
|
+
sender: '0x3063088c6f4ac4dd3f96a411d5fb68173d113def',
|
|
1723
|
+
sourceAmount: amount,
|
|
1724
|
+
sourceChain: {
|
|
1725
|
+
addressFormat: 'hex',
|
|
1726
|
+
id: 'eip155:4217',
|
|
1727
|
+
kind: 'evm',
|
|
1728
|
+
name: 'Tempo',
|
|
1729
|
+
},
|
|
1730
|
+
sourceToken: {
|
|
1731
|
+
address: '0x20c000000000000000000000b9537d11c60e8b50',
|
|
1732
|
+
currency: 'USD',
|
|
1733
|
+
decimals: 6,
|
|
1734
|
+
name: 'Bridged USDC (Stargate)',
|
|
1735
|
+
standard: 'TIP-20',
|
|
1736
|
+
symbol: 'USDC.e',
|
|
1737
|
+
tokenKey: 'eip155:4217/erc20:0x20c000000000000000000000b9537d11c60e8b50',
|
|
1738
|
+
verified: true,
|
|
1739
|
+
},
|
|
1740
|
+
})
|
|
1741
|
+
const app = TestApp.create({
|
|
1742
|
+
auth: { keys: [routesWriter] },
|
|
1743
|
+
db: trackingDb,
|
|
1744
|
+
defaultChainId: tempoMainnet.id,
|
|
1745
|
+
providers: [
|
|
1746
|
+
Stargate.stargate({
|
|
1747
|
+
fetch(input, init) {
|
|
1748
|
+
// Anvil cannot decode Tempo type-0x76 receipts, so immutable source evidence is read from production.
|
|
1749
|
+
return globalThis.fetch(
|
|
1750
|
+
typeof input === 'string' && input.startsWith(destination.rpcUrl)
|
|
1751
|
+
? tempoMainnet.rpcUrls.default.http[0]!
|
|
1752
|
+
: input,
|
|
1753
|
+
init,
|
|
1754
|
+
)
|
|
1755
|
+
},
|
|
1756
|
+
}),
|
|
1757
|
+
],
|
|
1758
|
+
routes: { async dispatchTransferReconciliation() {} },
|
|
1759
|
+
})
|
|
1760
|
+
const transfer = await RoutesTransfer.create(trackingDb, {
|
|
1761
|
+
apiKeyId: routesWriter.id,
|
|
1762
|
+
environment: 'production',
|
|
1763
|
+
orgId: routesWriter.orgId,
|
|
1764
|
+
providerState: { destinationBlockNumber: '0', routeConfiguration },
|
|
1765
|
+
snapshot,
|
|
1766
|
+
})
|
|
1767
|
+
const response = await app.request(
|
|
1768
|
+
`/v1/routes/transfers/${transfer.id}/source-transactions`,
|
|
1769
|
+
{
|
|
1770
|
+
body: JSON.stringify({ transactionHashes: sourceTransactionHashes }),
|
|
1771
|
+
headers: { ...as(routesWriter).headers, 'content-type': 'application/json' },
|
|
1772
|
+
method: 'POST',
|
|
1773
|
+
},
|
|
1774
|
+
)
|
|
1775
|
+
expect(response.status).toBe(200)
|
|
1776
|
+
const registered = await TestApp.json(
|
|
1777
|
+
response,
|
|
1778
|
+
Routes.schema.registerRoutesTransferSourceTransaction.Response,
|
|
1779
|
+
)
|
|
1780
|
+
expect(registered.sourceTransactionHashes).toEqual([
|
|
1781
|
+
sourceTransactionHashes[4],
|
|
1782
|
+
...sourceTransactionHashes.slice(0, 4),
|
|
1783
|
+
])
|
|
1784
|
+
|
|
1785
|
+
const malformed = await RoutesTransfer.create(trackingDb, {
|
|
1786
|
+
apiKeyId: routesWriter.id,
|
|
1787
|
+
environment: 'production',
|
|
1788
|
+
orgId: routesWriter.orgId,
|
|
1789
|
+
providerState: { destinationBlockNumber: '0', routeConfiguration },
|
|
1790
|
+
snapshot: {
|
|
1791
|
+
...snapshot,
|
|
1792
|
+
fees: [
|
|
1793
|
+
{
|
|
1794
|
+
...fee,
|
|
1795
|
+
amount: { ...fee.amount, baseUnits: '500001', formatted: '0.500001' },
|
|
1796
|
+
},
|
|
1797
|
+
],
|
|
1798
|
+
},
|
|
1799
|
+
})
|
|
1800
|
+
const rejected = await app.request(
|
|
1801
|
+
`/v1/routes/transfers/${malformed.id}/source-transactions`,
|
|
1802
|
+
{
|
|
1803
|
+
body: JSON.stringify({ transactionHashes: sourceTransactionHashes }),
|
|
1804
|
+
headers: { ...as(routesWriter).headers, 'content-type': 'application/json' },
|
|
1805
|
+
method: 'POST',
|
|
1806
|
+
},
|
|
1807
|
+
)
|
|
1808
|
+
expect(rejected.status).toBe(400)
|
|
1809
|
+
expect(((await rejected.json()) as { error: { code: string } }).error.code).toBe(
|
|
1810
|
+
'source_transaction_invalid',
|
|
1811
|
+
)
|
|
1812
|
+
})
|
|
1813
|
+
},
|
|
1814
|
+
)
|
|
1815
|
+
|
|
1816
|
+
describe('POST /routes/transfers/{destination}', () => {
|
|
1817
|
+
test.each([
|
|
1818
|
+
{ body: vaultTransferBody, destination: 'vault' },
|
|
1819
|
+
{ body: zoneTransferBody, destination: 'zone' },
|
|
1820
|
+
] as const)('validates and returns 501 for $destination transfers', async (options) => {
|
|
1821
|
+
const app = transfersApp()
|
|
1822
|
+
const before = await db.kysely
|
|
1823
|
+
.selectFrom('routes_transfers')
|
|
1824
|
+
.select(({ fn }) => fn.countAll<number>().as('count'))
|
|
1825
|
+
.executeTakeFirstOrThrow()
|
|
1826
|
+
const response = await app.request(`/v1/routes/transfers/${options.destination}`, {
|
|
1827
|
+
body: JSON.stringify(options.body),
|
|
1828
|
+
headers: {
|
|
1829
|
+
authorization: `Bearer ${routesWriter.token}`,
|
|
1830
|
+
'content-type': 'application/json',
|
|
1831
|
+
'idempotency-key': `routes_${options.destination}_unimplemented`,
|
|
1832
|
+
},
|
|
1833
|
+
method: 'POST',
|
|
1834
|
+
})
|
|
1835
|
+
|
|
1836
|
+
expect(response.status).toBe(501)
|
|
1837
|
+
expect(response.headers.get('cache-control')).toBe('no-store')
|
|
1838
|
+
expect(((await response.json()) as { error: { code: string } }).error.code).toBe(
|
|
1839
|
+
'not_implemented',
|
|
1840
|
+
)
|
|
1841
|
+
const after = await db.kysely
|
|
1842
|
+
.selectFrom('routes_transfers')
|
|
1843
|
+
.select(({ fn }) => fn.countAll<number>().as('count'))
|
|
1844
|
+
.executeTakeFirstOrThrow()
|
|
1845
|
+
expect(after.count).toBe(before.count)
|
|
1846
|
+
})
|
|
1847
|
+
|
|
1848
|
+
test('requires the header and validates destination fields', async () => {
|
|
1849
|
+
const app = transfersApp()
|
|
1850
|
+
const missingHeader = await app.request('/v1/routes/transfers/vault', {
|
|
1851
|
+
body: JSON.stringify(vaultTransferBody),
|
|
1852
|
+
headers: {
|
|
1853
|
+
authorization: `Bearer ${routesWriter.token}`,
|
|
1854
|
+
'content-type': 'application/json',
|
|
1855
|
+
},
|
|
1856
|
+
method: 'POST',
|
|
1857
|
+
})
|
|
1858
|
+
expect(missingHeader.status).toBe(400)
|
|
1859
|
+
expect(((await missingHeader.json()) as { error: { code: string } }).error.code).toBe(
|
|
1860
|
+
'idempotency_key_required',
|
|
1861
|
+
)
|
|
1862
|
+
|
|
1863
|
+
const invalidZone = await app.request('/v1/routes/transfers/zone', {
|
|
1864
|
+
body: JSON.stringify({ ...zoneTransferBody, destinationChain: '421700001' }),
|
|
1865
|
+
headers: {
|
|
1866
|
+
authorization: `Bearer ${routesWriter.token}`,
|
|
1867
|
+
'content-type': 'application/json',
|
|
1868
|
+
'idempotency-key': 'routes_zone_invalid',
|
|
1869
|
+
},
|
|
1870
|
+
method: 'POST',
|
|
1871
|
+
})
|
|
1872
|
+
expect(invalidZone.status).toBe(400)
|
|
1873
|
+
expect(((await invalidZone.json()) as { error: { code: string } }).error.code).toBe(
|
|
1874
|
+
'body_invalid',
|
|
1875
|
+
)
|
|
1876
|
+
})
|
|
1877
|
+
})
|
|
1878
|
+
|
|
1879
|
+
describe('route transfers OpenAPI', () => {
|
|
1880
|
+
test('publishes generator-ready transfer contracts', async () => {
|
|
1881
|
+
const spec = await (await create({ auth: false }).request('/openapi.json')).json()
|
|
1882
|
+
const detailPath = Object.keys(spec.paths).find(
|
|
1883
|
+
(path) => path.includes('/v1/routes/transfers/{') && !path.endsWith('/source-transactions'),
|
|
1884
|
+
)!
|
|
1885
|
+
const sourceTransactionPath = Object.keys(spec.paths).find((path) =>
|
|
1886
|
+
path.endsWith('/source-transactions'),
|
|
1887
|
+
)!
|
|
1888
|
+
const operations = {
|
|
1889
|
+
create: spec.paths['/v1/routes/transfers'].post,
|
|
1890
|
+
createVault: spec.paths['/v1/routes/transfers/vault'].post,
|
|
1891
|
+
createZone: spec.paths['/v1/routes/transfers/zone'].post,
|
|
1892
|
+
get: spec.paths[detailPath].get,
|
|
1893
|
+
list: spec.paths['/v1/routes/transfers'].get,
|
|
1894
|
+
registerSourceTransaction: spec.paths[sourceTransactionPath].post,
|
|
1895
|
+
}
|
|
1896
|
+
const summarize = (operation: (typeof operations)[keyof typeof operations]) => ({
|
|
1897
|
+
errors: Object.fromEntries(
|
|
1898
|
+
(Object.entries(operation.responses) as [string, ContractResponse][])
|
|
1899
|
+
.filter(([status]) => Number(status) >= 400)
|
|
1900
|
+
.map(([status, response]) => [
|
|
1901
|
+
status,
|
|
1902
|
+
response.$ref ?? response.content?.['application/json']?.schema,
|
|
1903
|
+
]),
|
|
1904
|
+
),
|
|
1905
|
+
operationId: operation.operationId,
|
|
1906
|
+
request: operation.requestBody?.content['application/json'].schema,
|
|
1907
|
+
response: operation.responses[200]?.content?.['application/json']?.schema,
|
|
1908
|
+
})
|
|
1909
|
+
|
|
1910
|
+
expect({
|
|
1911
|
+
components: [
|
|
1912
|
+
'CreateRoutesTransferRequest',
|
|
1913
|
+
'CreateRoutesTransferVaultRequest',
|
|
1914
|
+
'CreateRoutesTransferZoneRequest',
|
|
1915
|
+
'CreatedRoutesTransfer',
|
|
1916
|
+
'RoutesAction',
|
|
1917
|
+
'RoutesActionCall',
|
|
1918
|
+
'RoutesEvmCallsAction',
|
|
1919
|
+
'RoutesTransfer',
|
|
1920
|
+
'RoutesTransferFee',
|
|
1921
|
+
'RoutesTransferList',
|
|
1922
|
+
'RoutesTransferQuote',
|
|
1923
|
+
'RoutesTransferStatusReason',
|
|
1924
|
+
'RegisterRoutesTransferSourceTransactionRequest',
|
|
1925
|
+
].filter((name) => spec.components.schemas[name]),
|
|
1926
|
+
formats: {
|
|
1927
|
+
createdAt: spec.components.schemas.RoutesTransfer.properties.createdAt.format,
|
|
1928
|
+
quoteExpiresAt: spec.components.schemas.RoutesTransferQuote.properties.expiresAt.format,
|
|
1929
|
+
quoteSampledAt: spec.components.schemas.RoutesTransferQuote.properties.sampledAt.format,
|
|
1930
|
+
updatedAt: spec.components.schemas.RoutesTransfer.properties.updatedAt.format,
|
|
1931
|
+
},
|
|
1932
|
+
models: {
|
|
1933
|
+
action: spec.components.schemas.RoutesAction.oneOf,
|
|
1934
|
+
createdAction: spec.components.schemas.CreatedRoutesTransfer.properties.action,
|
|
1935
|
+
evmCall: spec.components.schemas.RoutesEvmCallsAction.properties.calls.items,
|
|
1936
|
+
feeToken: spec.components.schemas.RoutesTransferFee.properties.token,
|
|
1937
|
+
list: spec.components.schemas.RoutesTransferList.properties.data.items,
|
|
1938
|
+
quote: spec.components.schemas.RoutesTransfer.properties.quote,
|
|
1939
|
+
statusReason: spec.components.schemas.RoutesTransfer.properties.statusReason,
|
|
1940
|
+
},
|
|
1941
|
+
operations: {
|
|
1942
|
+
create: summarize(operations.create),
|
|
1943
|
+
createVault: summarize(operations.createVault),
|
|
1944
|
+
createZone: summarize(operations.createZone),
|
|
1945
|
+
get: summarize(operations.get),
|
|
1946
|
+
list: summarize(operations.list),
|
|
1947
|
+
registerSourceTransaction: summarize(operations.registerSourceTransaction),
|
|
1948
|
+
},
|
|
1949
|
+
operationErrorCodes: {
|
|
1950
|
+
createInvalid:
|
|
1951
|
+
spec.components.schemas.ApiKeyMalformedOrBodyInvalidOrIdempotencyKeyRequiredError
|
|
1952
|
+
.properties.error.properties.code.enum,
|
|
1953
|
+
idempotencyConflict:
|
|
1954
|
+
spec.components.schemas.IdempotencyConflictOrIdempotencyInProgressError.properties.error
|
|
1955
|
+
.properties.code.enum,
|
|
1956
|
+
notImplemented:
|
|
1957
|
+
spec.components.schemas.NotImplemented501Error.properties.error.properties.code.enum,
|
|
1958
|
+
parametersInvalid:
|
|
1959
|
+
spec.components.schemas.ApiKeyMalformedOrParamInvalidError.properties.error.properties
|
|
1960
|
+
.code.enum,
|
|
1961
|
+
queryInvalid:
|
|
1962
|
+
spec.components.schemas.ApiKeyMalformedOrQueryInvalidError.properties.error.properties
|
|
1963
|
+
.code.enum,
|
|
1964
|
+
quoteNotAvailable:
|
|
1965
|
+
spec.components.schemas.QuoteNotAvailableError.properties.error.properties.code.enum,
|
|
1966
|
+
transferNotFound:
|
|
1967
|
+
spec.components.schemas.RoutesTransferNotFoundError.properties.error.properties.code.enum,
|
|
1968
|
+
},
|
|
1969
|
+
}).toMatchInlineSnapshot(`
|
|
1970
|
+
{
|
|
1971
|
+
"components": [
|
|
1972
|
+
"CreateRoutesTransferRequest",
|
|
1973
|
+
"CreateRoutesTransferVaultRequest",
|
|
1974
|
+
"CreateRoutesTransferZoneRequest",
|
|
1975
|
+
"CreatedRoutesTransfer",
|
|
1976
|
+
"RoutesAction",
|
|
1977
|
+
"RoutesActionCall",
|
|
1978
|
+
"RoutesEvmCallsAction",
|
|
1979
|
+
"RoutesTransfer",
|
|
1980
|
+
"RoutesTransferFee",
|
|
1981
|
+
"RoutesTransferList",
|
|
1982
|
+
"RoutesTransferQuote",
|
|
1983
|
+
"RoutesTransferStatusReason",
|
|
1984
|
+
"RegisterRoutesTransferSourceTransactionRequest",
|
|
1985
|
+
],
|
|
1986
|
+
"formats": {
|
|
1987
|
+
"createdAt": "date-time",
|
|
1988
|
+
"quoteExpiresAt": "date-time",
|
|
1989
|
+
"quoteSampledAt": "date-time",
|
|
1990
|
+
"updatedAt": "date-time",
|
|
1991
|
+
},
|
|
1992
|
+
"models": {
|
|
1993
|
+
"action": [
|
|
1994
|
+
{
|
|
1995
|
+
"$ref": "#/components/schemas/RoutesEvmCallsAction",
|
|
1996
|
+
},
|
|
1997
|
+
],
|
|
1998
|
+
"createdAction": {
|
|
1999
|
+
"$ref": "#/components/schemas/RoutesAction",
|
|
2000
|
+
},
|
|
2001
|
+
"evmCall": {
|
|
2002
|
+
"$ref": "#/components/schemas/RoutesActionCall",
|
|
2003
|
+
},
|
|
2004
|
+
"feeToken": {
|
|
2005
|
+
"$ref": "#/components/schemas/RoutesToken",
|
|
2006
|
+
},
|
|
2007
|
+
"list": {
|
|
2008
|
+
"$ref": "#/components/schemas/RoutesTransfer",
|
|
2009
|
+
},
|
|
2010
|
+
"quote": {
|
|
2011
|
+
"$ref": "#/components/schemas/RoutesTransferQuote",
|
|
2012
|
+
},
|
|
2013
|
+
"statusReason": {
|
|
2014
|
+
"$ref": "#/components/schemas/RoutesTransferStatusReason",
|
|
2015
|
+
},
|
|
2016
|
+
},
|
|
2017
|
+
"operationErrorCodes": {
|
|
2018
|
+
"createInvalid": [
|
|
2019
|
+
"api_key_malformed",
|
|
2020
|
+
"body_invalid",
|
|
2021
|
+
"idempotency_key_required",
|
|
2022
|
+
],
|
|
2023
|
+
"idempotencyConflict": [
|
|
2024
|
+
"idempotency_conflict",
|
|
2025
|
+
"idempotency_in_progress",
|
|
2026
|
+
],
|
|
2027
|
+
"notImplemented": [
|
|
2028
|
+
"not_implemented",
|
|
2029
|
+
],
|
|
2030
|
+
"parametersInvalid": [
|
|
2031
|
+
"api_key_malformed",
|
|
2032
|
+
"param_invalid",
|
|
2033
|
+
],
|
|
2034
|
+
"queryInvalid": [
|
|
2035
|
+
"api_key_malformed",
|
|
2036
|
+
"query_invalid",
|
|
2037
|
+
],
|
|
2038
|
+
"quoteNotAvailable": [
|
|
2039
|
+
"quote_not_available",
|
|
2040
|
+
],
|
|
2041
|
+
"transferNotFound": [
|
|
2042
|
+
"routes_transfer_not_found",
|
|
2043
|
+
],
|
|
2044
|
+
},
|
|
2045
|
+
"operations": {
|
|
2046
|
+
"create": {
|
|
2047
|
+
"errors": {
|
|
2048
|
+
"400": {
|
|
2049
|
+
"$ref": "#/components/schemas/ApiKeyMalformedOrBodyInvalidOrIdempotencyKeyRequiredError",
|
|
2050
|
+
},
|
|
2051
|
+
"401": {
|
|
2052
|
+
"$ref": "#/components/schemas/AuthenticationError",
|
|
2053
|
+
},
|
|
2054
|
+
"403": {
|
|
2055
|
+
"$ref": "#/components/schemas/ApiKeyForbiddenOrApiKeyIpForbiddenOrBillingPastDueOrBillingRequiredOrForbiddenOrRoutesSubsidyLimitExceededOrRoutesSubsidyNotEnabledError",
|
|
2056
|
+
},
|
|
2057
|
+
"404": {
|
|
2058
|
+
"$ref": "#/components/schemas/QuoteNotAvailableError",
|
|
2059
|
+
},
|
|
2060
|
+
"409": {
|
|
2061
|
+
"$ref": "#/components/schemas/IdempotencyConflictOrIdempotencyInProgressError",
|
|
2062
|
+
},
|
|
2063
|
+
"429": "#/components/responses/RateLimited",
|
|
2064
|
+
"500": "#/components/responses/InternalError",
|
|
2065
|
+
"501": {
|
|
2066
|
+
"$ref": "#/components/schemas/NotImplemented501Error",
|
|
2067
|
+
},
|
|
2068
|
+
"502": {
|
|
2069
|
+
"$ref": "#/components/schemas/UpstreamError",
|
|
2070
|
+
},
|
|
2071
|
+
"503": {
|
|
2072
|
+
"$ref": "#/components/schemas/SubsidyInventoryUnavailableOrSubsidySignerUnavailableError",
|
|
2073
|
+
},
|
|
2074
|
+
"504": "#/components/responses/RequestTimeout",
|
|
2075
|
+
},
|
|
2076
|
+
"operationId": "createRoutesTransfer",
|
|
2077
|
+
"request": {
|
|
2078
|
+
"$ref": "#/components/schemas/CreateRoutesTransferRequest",
|
|
2079
|
+
},
|
|
2080
|
+
"response": {
|
|
2081
|
+
"$ref": "#/components/schemas/CreatedRoutesTransfer",
|
|
2082
|
+
},
|
|
2083
|
+
},
|
|
2084
|
+
"createVault": {
|
|
2085
|
+
"errors": {
|
|
2086
|
+
"400": {
|
|
2087
|
+
"$ref": "#/components/schemas/ApiKeyMalformedOrBodyInvalidOrIdempotencyKeyRequiredError",
|
|
2088
|
+
},
|
|
2089
|
+
"401": {
|
|
2090
|
+
"$ref": "#/components/schemas/AuthenticationError",
|
|
2091
|
+
},
|
|
2092
|
+
"403": {
|
|
2093
|
+
"$ref": "#/components/schemas/ForbiddenError",
|
|
2094
|
+
},
|
|
2095
|
+
"429": "#/components/responses/RateLimited",
|
|
2096
|
+
"500": "#/components/responses/InternalError",
|
|
2097
|
+
"501": {
|
|
2098
|
+
"$ref": "#/components/schemas/NotImplemented501Error",
|
|
2099
|
+
},
|
|
2100
|
+
"504": "#/components/responses/RequestTimeout",
|
|
2101
|
+
},
|
|
2102
|
+
"operationId": "createRoutesTransferVault",
|
|
2103
|
+
"request": {
|
|
2104
|
+
"$ref": "#/components/schemas/CreateRoutesTransferVaultRequest",
|
|
2105
|
+
},
|
|
2106
|
+
"response": undefined,
|
|
2107
|
+
},
|
|
2108
|
+
"createZone": {
|
|
2109
|
+
"errors": {
|
|
2110
|
+
"400": {
|
|
2111
|
+
"$ref": "#/components/schemas/ApiKeyMalformedOrBodyInvalidOrIdempotencyKeyRequiredError",
|
|
2112
|
+
},
|
|
2113
|
+
"401": {
|
|
2114
|
+
"$ref": "#/components/schemas/AuthenticationError",
|
|
2115
|
+
},
|
|
2116
|
+
"403": {
|
|
2117
|
+
"$ref": "#/components/schemas/ForbiddenError",
|
|
2118
|
+
},
|
|
2119
|
+
"429": "#/components/responses/RateLimited",
|
|
2120
|
+
"500": "#/components/responses/InternalError",
|
|
2121
|
+
"501": {
|
|
2122
|
+
"$ref": "#/components/schemas/NotImplemented501Error",
|
|
2123
|
+
},
|
|
2124
|
+
"504": "#/components/responses/RequestTimeout",
|
|
2125
|
+
},
|
|
2126
|
+
"operationId": "createRoutesTransferZone",
|
|
2127
|
+
"request": {
|
|
2128
|
+
"$ref": "#/components/schemas/CreateRoutesTransferZoneRequest",
|
|
2129
|
+
},
|
|
2130
|
+
"response": undefined,
|
|
2131
|
+
},
|
|
2132
|
+
"get": {
|
|
2133
|
+
"errors": {
|
|
2134
|
+
"400": {
|
|
2135
|
+
"$ref": "#/components/schemas/ApiKeyMalformedOrParamInvalidError",
|
|
2136
|
+
},
|
|
2137
|
+
"401": {
|
|
2138
|
+
"$ref": "#/components/schemas/AuthenticationError",
|
|
2139
|
+
},
|
|
2140
|
+
"403": {
|
|
2141
|
+
"$ref": "#/components/schemas/ForbiddenError",
|
|
2142
|
+
},
|
|
2143
|
+
"404": {
|
|
2144
|
+
"$ref": "#/components/schemas/RoutesTransferNotFoundError",
|
|
2145
|
+
},
|
|
2146
|
+
"429": "#/components/responses/RateLimited",
|
|
2147
|
+
"500": "#/components/responses/InternalError",
|
|
2148
|
+
"502": {
|
|
2149
|
+
"$ref": "#/components/schemas/UpstreamError",
|
|
2150
|
+
},
|
|
2151
|
+
"504": "#/components/responses/RequestTimeout",
|
|
2152
|
+
},
|
|
2153
|
+
"operationId": "getRoutesTransfer",
|
|
2154
|
+
"request": undefined,
|
|
2155
|
+
"response": {
|
|
2156
|
+
"$ref": "#/components/schemas/RoutesTransfer",
|
|
2157
|
+
},
|
|
2158
|
+
},
|
|
2159
|
+
"list": {
|
|
2160
|
+
"errors": {
|
|
2161
|
+
"400": {
|
|
2162
|
+
"$ref": "#/components/schemas/ApiKeyMalformedOrQueryInvalidError",
|
|
2163
|
+
},
|
|
2164
|
+
"401": {
|
|
2165
|
+
"$ref": "#/components/schemas/AuthenticationError",
|
|
2166
|
+
},
|
|
2167
|
+
"403": {
|
|
2168
|
+
"$ref": "#/components/schemas/ForbiddenError",
|
|
2169
|
+
},
|
|
2170
|
+
"429": "#/components/responses/RateLimited",
|
|
2171
|
+
"500": "#/components/responses/InternalError",
|
|
2172
|
+
"502": {
|
|
2173
|
+
"$ref": "#/components/schemas/UpstreamError",
|
|
2174
|
+
},
|
|
2175
|
+
"504": "#/components/responses/RequestTimeout",
|
|
2176
|
+
},
|
|
2177
|
+
"operationId": "listRoutesTransfers",
|
|
2178
|
+
"request": undefined,
|
|
2179
|
+
"response": {
|
|
2180
|
+
"$ref": "#/components/schemas/RoutesTransferList",
|
|
2181
|
+
},
|
|
2182
|
+
},
|
|
2183
|
+
"registerSourceTransaction": {
|
|
2184
|
+
"errors": {
|
|
2185
|
+
"400": {
|
|
2186
|
+
"$ref": "#/components/schemas/ApiKeyMalformedOrBodyInvalidOrParamInvalidOrSourceTransactionInvalidError",
|
|
2187
|
+
},
|
|
2188
|
+
"401": {
|
|
2189
|
+
"$ref": "#/components/schemas/AuthenticationError",
|
|
2190
|
+
},
|
|
2191
|
+
"403": {
|
|
2192
|
+
"$ref": "#/components/schemas/ForbiddenError",
|
|
2193
|
+
},
|
|
2194
|
+
"404": {
|
|
2195
|
+
"$ref": "#/components/schemas/RoutesTransferNotFoundError",
|
|
2196
|
+
},
|
|
2197
|
+
"409": {
|
|
2198
|
+
"$ref": "#/components/schemas/RoutesTransferNotAwaitingSourceOrSourceTransactionConflictOrSourceTransactionPendingError",
|
|
2199
|
+
},
|
|
2200
|
+
"429": "#/components/responses/RateLimited",
|
|
2201
|
+
"500": "#/components/responses/InternalError",
|
|
2202
|
+
"501": {
|
|
2203
|
+
"$ref": "#/components/schemas/NotImplemented501Error",
|
|
2204
|
+
},
|
|
2205
|
+
"502": {
|
|
2206
|
+
"$ref": "#/components/schemas/UpstreamError",
|
|
2207
|
+
},
|
|
2208
|
+
"504": "#/components/responses/RequestTimeout",
|
|
2209
|
+
},
|
|
2210
|
+
"operationId": "registerRoutesTransferSourceTransaction",
|
|
2211
|
+
"request": {
|
|
2212
|
+
"$ref": "#/components/schemas/RegisterRoutesTransferSourceTransactionRequest",
|
|
2213
|
+
},
|
|
2214
|
+
"response": {
|
|
2215
|
+
"$ref": "#/components/schemas/RoutesTransfer",
|
|
2216
|
+
},
|
|
2217
|
+
},
|
|
2218
|
+
},
|
|
2219
|
+
}
|
|
2220
|
+
`)
|
|
2221
|
+
})
|
|
2222
|
+
|
|
2223
|
+
test('publishes an executable account transfer example', async () => {
|
|
2224
|
+
const app = create({ auth: false })
|
|
2225
|
+
type TransferExample = {
|
|
2226
|
+
action: RoutesAction.EvmCalls
|
|
2227
|
+
destinationAmountMin: { baseUnits: string }
|
|
2228
|
+
destinationAmountRequired: { baseUnits: string }
|
|
2229
|
+
destinationChain: { id: string }
|
|
2230
|
+
destinationToken: { address: string }
|
|
2231
|
+
fees: readonly {
|
|
2232
|
+
amount: { baseUnits: string }
|
|
2233
|
+
side: string
|
|
2234
|
+
token: { address?: string | undefined; standard: string; symbol: string }
|
|
2235
|
+
}[]
|
|
2236
|
+
recipient: string
|
|
2237
|
+
sender: string
|
|
2238
|
+
sourceAmount: { baseUnits: string }
|
|
2239
|
+
sourceChain: { id: string }
|
|
2240
|
+
sourceToken: { address: string }
|
|
2241
|
+
subsidize: boolean
|
|
2242
|
+
}
|
|
2243
|
+
type Operation = {
|
|
2244
|
+
requestBody: {
|
|
2245
|
+
content: Record<string, { schema: JsonSchema }>
|
|
2246
|
+
}
|
|
2247
|
+
responses: Record<string, { content: Record<string, { example: TransferExample }> }>
|
|
2248
|
+
}
|
|
2249
|
+
type Spec = ComponentSpec & { paths: Record<string, { post: Operation }> }
|
|
2250
|
+
const spec = (await (await app.request('/openapi.json')).json()) as Spec
|
|
2251
|
+
const operation = spec.paths['/v1/routes/transfers']!.post
|
|
2252
|
+
const request = dereference(spec, operation.requestBody.content['application/json']!.schema)
|
|
2253
|
+
const response = operation.responses['200']!.content['application/json']!.example
|
|
2254
|
+
|
|
2255
|
+
expect({
|
|
2256
|
+
request: {
|
|
2257
|
+
destinationChain: request.properties!['destinationChain']!.examples,
|
|
2258
|
+
destinationToken: request.properties!['destinationToken']!.examples,
|
|
2259
|
+
sourceChain: request.properties!['sourceChain']!.examples,
|
|
2260
|
+
sourceToken: request.properties!['sourceToken']!.examples,
|
|
2261
|
+
subsidyDescription: request.properties!['subsidize']!.description,
|
|
2262
|
+
subsidize: request.properties!['subsidize']!.examples,
|
|
2263
|
+
},
|
|
2264
|
+
response,
|
|
2265
|
+
}).toEqual({
|
|
2266
|
+
request: {
|
|
2267
|
+
destinationChain: ['base', 'ethereum', 'tempo', 'eip155:8453'],
|
|
2268
|
+
destinationToken: ['usdc', 'pathusd'],
|
|
2269
|
+
sourceChain: ['tempo', 'base', 'ethereum', 'eip155:4217'],
|
|
2270
|
+
sourceToken: ['usdce', 'usdc'],
|
|
2271
|
+
subsidyDescription:
|
|
2272
|
+
'Guarantees normalized 1:1 delivery for exact-source Tempo USD transfers to Base or Ethereum. A Tempo Admin must enable subsidies for the organization.',
|
|
2273
|
+
subsidize: [true],
|
|
2274
|
+
},
|
|
2275
|
+
response: expect.objectContaining({
|
|
2276
|
+
action: expect.objectContaining({ type: 'evm:calls' }),
|
|
2277
|
+
destinationAmountMin: expect.objectContaining({ baseUnits: '974398' }),
|
|
2278
|
+
destinationAmountRequired: expect.objectContaining({ baseUnits: '1000000' }),
|
|
2279
|
+
destinationChain: expect.objectContaining({ id: 'eip155:8453' }),
|
|
2280
|
+
destinationToken: expect.objectContaining({
|
|
2281
|
+
address: '0x833589fcd6edb6e08f4c7c32d4f71b54bda02913',
|
|
2282
|
+
}),
|
|
2283
|
+
fees: [
|
|
2284
|
+
expect.objectContaining({
|
|
2285
|
+
amount: expect.objectContaining({ baseUnits: '10000' }),
|
|
2286
|
+
side: 'source',
|
|
2287
|
+
token: expect.objectContaining({
|
|
2288
|
+
address: '0x20c0000000000000000000000000000000000000',
|
|
2289
|
+
standard: 'TIP-20',
|
|
2290
|
+
symbol: 'pathUSD',
|
|
2291
|
+
}),
|
|
2292
|
+
}),
|
|
2293
|
+
],
|
|
2294
|
+
sourceChain: expect.objectContaining({ id: 'eip155:4217' }),
|
|
2295
|
+
sourceToken: expect.objectContaining({
|
|
2296
|
+
address: '0x20c000000000000000000000b9537d11c60e8b50',
|
|
2297
|
+
}),
|
|
2298
|
+
subsidize: true,
|
|
2299
|
+
}),
|
|
2300
|
+
})
|
|
2301
|
+
const calls = response.action.calls
|
|
2302
|
+
expect(calls).toHaveLength(5)
|
|
2303
|
+
expect(calls.map((call) => ({ to: call.to, value: call.value }))).toEqual([
|
|
2304
|
+
{ to: response.sourceToken.address, value: '0x0' },
|
|
2305
|
+
{ to: response.fees[0]!.token.address, value: '0x0' },
|
|
2306
|
+
{ to: '0x0cEb237E109eE22374a567c6b09F373C73FA4cBb', value: '0x0' },
|
|
2307
|
+
{ to: '0x0cEb237E109eE22374a567c6b09F373C73FA4cBb', value: '0x0' },
|
|
2308
|
+
{ to: '0x8c76e2f6c5ceda9aa7772e7eff30280226c44392', value: '0x0' },
|
|
2309
|
+
])
|
|
2310
|
+
const approve = AbiFunction.from('function approve(address spender, uint256 amount)')
|
|
2311
|
+
const wrap = AbiFunction.from('function wrap(address token, address to, uint256 amount)')
|
|
2312
|
+
const send = AbiFunction.from(
|
|
2313
|
+
'function send((uint32 dstEid, bytes32 to, uint256 amountLD, uint256 minAmountLD, bytes extraOptions, bytes composeMsg, bytes oftCmd) sendParam, (uint256 nativeFee, uint256 lzTokenFee) fee, address refundAddress) payable returns ((bytes32 guid, uint64 nonce, (uint256 nativeFee, uint256 lzTokenFee) fee) msgReceipt, (uint256 amountSentLD, uint256 amountReceivedLD) oftReceipt)',
|
|
2314
|
+
)
|
|
2315
|
+
expect(AbiFunction.decodeData(approve, calls[0]!.data as Hex.Hex)).toEqual([
|
|
2316
|
+
'0x8c76e2f6c5ceda9aa7772e7eff30280226c44392',
|
|
2317
|
+
1_000_000n,
|
|
2318
|
+
])
|
|
2319
|
+
expect(AbiFunction.decodeData(approve, calls[1]!.data as Hex.Hex)).toEqual([
|
|
2320
|
+
'0x0ceb237e109ee22374a567c6b09f373c73fa4cbb',
|
|
2321
|
+
10_000n,
|
|
2322
|
+
])
|
|
2323
|
+
expect(AbiFunction.decodeData(wrap, calls[2]!.data as Hex.Hex)).toEqual([
|
|
2324
|
+
'0x20c0000000000000000000000000000000000000',
|
|
2325
|
+
response.sender,
|
|
2326
|
+
10_000n,
|
|
2327
|
+
])
|
|
2328
|
+
expect(AbiFunction.decodeData(approve, calls[3]!.data as Hex.Hex)).toEqual([
|
|
2329
|
+
'0x8c76e2f6c5ceda9aa7772e7eff30280226c44392',
|
|
2330
|
+
10_000n,
|
|
2331
|
+
])
|
|
2332
|
+
const [sendParameters, messagingFee, refundAddress] = AbiFunction.decodeData(
|
|
2333
|
+
send,
|
|
2334
|
+
calls[4]!.data as Hex.Hex,
|
|
2335
|
+
)
|
|
2336
|
+
expect(sendParameters).toMatchObject({
|
|
2337
|
+
amountLD: 1_000_000n,
|
|
2338
|
+
dstEid: 30_184,
|
|
2339
|
+
minAmountLD: 974_398n,
|
|
2340
|
+
})
|
|
2341
|
+
expect(messagingFee).toEqual({ lzTokenFee: 0n, nativeFee: 10_000n })
|
|
2342
|
+
expect(refundAddress).toBe(response.sender)
|
|
2343
|
+
expect(
|
|
2344
|
+
Stargate.validateAction({
|
|
2345
|
+
action: response.action,
|
|
2346
|
+
configuration: {
|
|
2347
|
+
destinationPoolAddress: '0x27a16dc786820b16e5c9028b75b99f6f604b5d26',
|
|
2348
|
+
poolAddress: '0x8c76e2f6c5ceda9aa7772e7eff30280226c44392',
|
|
2349
|
+
},
|
|
2350
|
+
destinationAmountMin: response.destinationAmountMin.baseUnits,
|
|
2351
|
+
destinationChainId: response.destinationChain.id,
|
|
2352
|
+
destinationTokenAddress: response.destinationToken.address,
|
|
2353
|
+
recipient: response.recipient,
|
|
2354
|
+
sender: response.sender,
|
|
2355
|
+
sourceAmount: response.sourceAmount.baseUnits,
|
|
2356
|
+
sourceChainId: response.sourceChain.id,
|
|
2357
|
+
sourceTokenAddress: response.sourceToken.address,
|
|
2358
|
+
}),
|
|
2359
|
+
).toEqual({
|
|
2360
|
+
tokenApprovals: [
|
|
2361
|
+
{
|
|
2362
|
+
amount: '10000',
|
|
2363
|
+
spender: '0x0cEb237E109eE22374a567c6b09F373C73FA4cBb',
|
|
2364
|
+
token: '0x20C0000000000000000000000000000000000000',
|
|
2365
|
+
},
|
|
2366
|
+
{
|
|
2367
|
+
amount: '10000',
|
|
2368
|
+
spender: '0x8c76e2F6C5ceDA9AA7772e7efF30280226c44392',
|
|
2369
|
+
token: '0x0cEb237E109eE22374a567c6b09F373C73FA4cBb',
|
|
2370
|
+
},
|
|
2371
|
+
],
|
|
2372
|
+
})
|
|
2373
|
+
})
|
|
2374
|
+
|
|
2375
|
+
test('publishes human-readable deposit address route examples', async () => {
|
|
2376
|
+
const app = create({ auth: false })
|
|
2377
|
+
type Operation = {
|
|
2378
|
+
requestBody: {
|
|
2379
|
+
content: Record<string, { schema: JsonSchema }>
|
|
2380
|
+
}
|
|
2381
|
+
}
|
|
2382
|
+
type Spec = ComponentSpec & { paths: Record<string, { post: Operation }> }
|
|
2383
|
+
const spec = (await (await app.request('/openapi.json')).json()) as Spec
|
|
2384
|
+
const properties = dereference(
|
|
2385
|
+
spec,
|
|
2386
|
+
spec.paths['/v1/routes/deposit-addresses']!.post.requestBody.content['application/json']!
|
|
2387
|
+
.schema,
|
|
2388
|
+
).properties!
|
|
2389
|
+
|
|
2390
|
+
expect({
|
|
2391
|
+
destinationToken: properties['destinationToken']!.examples,
|
|
2392
|
+
sourceChain: properties['sourceChain']!.examples,
|
|
2393
|
+
sourceToken: properties['sourceToken']!.examples,
|
|
2394
|
+
}).toMatchInlineSnapshot(`
|
|
2395
|
+
{
|
|
2396
|
+
"destinationToken": [
|
|
2397
|
+
"usdt0",
|
|
2398
|
+
],
|
|
2399
|
+
"sourceChain": [
|
|
2400
|
+
"tron",
|
|
2401
|
+
"tron:0x2b6653dc",
|
|
2402
|
+
],
|
|
2403
|
+
"sourceToken": [
|
|
2404
|
+
"usdt",
|
|
2405
|
+
],
|
|
2406
|
+
}
|
|
2407
|
+
`)
|
|
2408
|
+
})
|
|
2409
|
+
|
|
2410
|
+
test('publishes concise operation documentation', async () => {
|
|
2411
|
+
const app = create({ auth: false })
|
|
2412
|
+
type Operation = { description: string; summary: string; tags: string[] }
|
|
2413
|
+
type Spec = {
|
|
2414
|
+
paths: Record<string, { get?: Operation; post?: Operation }>
|
|
2415
|
+
tags: { description?: string; name: string }[]
|
|
2416
|
+
'x-tagGroups': { name: string; tags: string[] }[]
|
|
2417
|
+
}
|
|
2418
|
+
const spec = (await (await app.request('/openapi.json')).json()) as Spec
|
|
2419
|
+
const detailPath = Object.keys(spec.paths).find(
|
|
2420
|
+
(path) => path.includes('/v1/routes/transfers/{') && !path.endsWith('/source-transactions'),
|
|
2421
|
+
)!
|
|
2422
|
+
const sourceTransactionPath = Object.keys(spec.paths).find((path) =>
|
|
2423
|
+
path.endsWith('/source-transactions'),
|
|
2424
|
+
)!
|
|
2425
|
+
const depositAddressPath = Object.keys(spec.paths).find(
|
|
2426
|
+
(path) =>
|
|
2427
|
+
path.includes('/v1/routes/deposit-addresses/{') &&
|
|
2428
|
+
!path.endsWith('/deposits') &&
|
|
2429
|
+
!path.endsWith('/reconcile'),
|
|
2430
|
+
)!
|
|
2431
|
+
const depositPath = Object.keys(spec.paths).find((path) =>
|
|
2432
|
+
path.includes('/v1/routes/deposits/{'),
|
|
2433
|
+
)!
|
|
2434
|
+
const reconcilePath = Object.keys(spec.paths).find((path) => path.endsWith('/reconcile'))!
|
|
2435
|
+
const summarize = (operation: Operation) => ({
|
|
2436
|
+
description: operation.description,
|
|
2437
|
+
summary: operation.summary,
|
|
2438
|
+
})
|
|
2439
|
+
const operations = {
|
|
2440
|
+
account: summarize(spec.paths['/v1/routes/transfers']!.post!),
|
|
2441
|
+
chains: summarize(spec.paths['/v1/routes/chains']!.get!),
|
|
2442
|
+
deposit: summarize(spec.paths[depositPath]!.get!),
|
|
2443
|
+
depositAddress: summarize(spec.paths[depositAddressPath]!.get!),
|
|
2444
|
+
depositAddressCreate: summarize(spec.paths['/v1/routes/deposit-addresses']!.post!),
|
|
2445
|
+
depositAddressList: summarize(spec.paths['/v1/routes/deposit-addresses']!.get!),
|
|
2446
|
+
depositAddressReconcile: summarize(spec.paths[reconcilePath]!.post!),
|
|
2447
|
+
deposits: summarize(spec.paths['/v1/routes/deposits']!.get!),
|
|
2448
|
+
detail: summarize(spec.paths[detailPath]!.get!),
|
|
2449
|
+
list: summarize(spec.paths['/v1/routes/transfers']!.get!),
|
|
2450
|
+
providers: summarize(spec.paths['/v1/routes/providers']!.get!),
|
|
2451
|
+
quotes: summarize(spec.paths['/v1/routes/quotes']!.get!),
|
|
2452
|
+
sourceTransaction: summarize(spec.paths[sourceTransactionPath]!.post!),
|
|
2453
|
+
vault: summarize(spec.paths['/v1/routes/transfers/vault']!.post!),
|
|
2454
|
+
zone: summarize(spec.paths['/v1/routes/transfers/zone']!.post!),
|
|
2455
|
+
}
|
|
2456
|
+
const category = spec['x-tagGroups'].find((group) => group.name === 'Routes API')
|
|
2457
|
+
const categoryTags = new Set(category?.tags)
|
|
2458
|
+
const sidebar = Object.values(spec.paths).flatMap((path) =>
|
|
2459
|
+
[path.get, path.post].flatMap((operation) =>
|
|
2460
|
+
operation?.tags.some((tag) => categoryTags.has(tag)) ? [operation.summary] : [],
|
|
2461
|
+
),
|
|
2462
|
+
)
|
|
2463
|
+
|
|
2464
|
+
for (const operation of Object.values(operations))
|
|
2465
|
+
expect(operation.description.split(/\s+/).length).toBeLessThan(15)
|
|
2466
|
+
|
|
2467
|
+
expect({
|
|
2468
|
+
category: category?.name,
|
|
2469
|
+
operations,
|
|
2470
|
+
sidebar,
|
|
2471
|
+
}).toMatchInlineSnapshot(`
|
|
2472
|
+
{
|
|
2473
|
+
"category": "Routes API",
|
|
2474
|
+
"operations": {
|
|
2475
|
+
"account": {
|
|
2476
|
+
"description": "Creates a durable transfer between supported chains, including optional normalized destination subsidies.",
|
|
2477
|
+
"summary": "Create transfer",
|
|
2478
|
+
},
|
|
2479
|
+
"chains": {
|
|
2480
|
+
"description": "Lists supported source chains and tokens.",
|
|
2481
|
+
"summary": "Get chains",
|
|
2482
|
+
},
|
|
2483
|
+
"deposit": {
|
|
2484
|
+
"description": "Returns one detected deposit and its delivery status.",
|
|
2485
|
+
"summary": "Get deposit",
|
|
2486
|
+
},
|
|
2487
|
+
"depositAddress": {
|
|
2488
|
+
"description": "Returns one reusable route deposit address.",
|
|
2489
|
+
"summary": "Get deposit address",
|
|
2490
|
+
},
|
|
2491
|
+
"depositAddressCreate": {
|
|
2492
|
+
"description": "Creates or returns a reusable deposit address for routes a Tempo account.",
|
|
2493
|
+
"summary": "Create deposit address",
|
|
2494
|
+
},
|
|
2495
|
+
"depositAddressList": {
|
|
2496
|
+
"description": "Lists reusable route deposit addresses, newest first.",
|
|
2497
|
+
"summary": "List deposit addresses",
|
|
2498
|
+
},
|
|
2499
|
+
"depositAddressReconcile": {
|
|
2500
|
+
"description": "Queues an immediate provider reconciliation for one reusable route deposit address.",
|
|
2501
|
+
"summary": "Reconcile deposit address",
|
|
2502
|
+
},
|
|
2503
|
+
"deposits": {
|
|
2504
|
+
"description": "Lists visible deposits, optionally filtered, newest first.",
|
|
2505
|
+
"summary": "List deposits",
|
|
2506
|
+
},
|
|
2507
|
+
"detail": {
|
|
2508
|
+
"description": "Returns a transfer by ID.",
|
|
2509
|
+
"summary": "Get transfer",
|
|
2510
|
+
},
|
|
2511
|
+
"list": {
|
|
2512
|
+
"description": "Lists transfers from newest to oldest.",
|
|
2513
|
+
"summary": "List transfers",
|
|
2514
|
+
},
|
|
2515
|
+
"providers": {
|
|
2516
|
+
"description": "Lists available transfer providers.",
|
|
2517
|
+
"summary": "Get providers",
|
|
2518
|
+
},
|
|
2519
|
+
"quotes": {
|
|
2520
|
+
"description": "Returns live quotes for transferring stablecoins between supported chains.",
|
|
2521
|
+
"summary": "Get quotes",
|
|
2522
|
+
},
|
|
2523
|
+
"sourceTransaction": {
|
|
2524
|
+
"description": "Registers verified source transactions once per organization, environment, and project.",
|
|
2525
|
+
"summary": "Register source transaction",
|
|
2526
|
+
},
|
|
2527
|
+
"vault": {
|
|
2528
|
+
"description": "Creates a transfer into a Tempo Earn vault.",
|
|
2529
|
+
"summary": "Create transfer into vault",
|
|
2530
|
+
},
|
|
2531
|
+
"zone": {
|
|
2532
|
+
"description": "Creates a transfer into a Tempo Zone.",
|
|
2533
|
+
"summary": "Create transfer into zone",
|
|
2534
|
+
},
|
|
2535
|
+
},
|
|
2536
|
+
"sidebar": [
|
|
2537
|
+
"Get quotes",
|
|
2538
|
+
"Get chains",
|
|
2539
|
+
"Get providers",
|
|
2540
|
+
"List deposit addresses",
|
|
2541
|
+
"Create deposit address",
|
|
2542
|
+
"Register source transaction",
|
|
2543
|
+
"List transfers",
|
|
2544
|
+
"Create transfer",
|
|
2545
|
+
"Create transfer into vault",
|
|
2546
|
+
"Create transfer into zone",
|
|
2547
|
+
"Reconcile deposit address",
|
|
2548
|
+
"Get deposit address",
|
|
2549
|
+
"Get transfer",
|
|
2550
|
+
"Get deposit",
|
|
2551
|
+
"List deposits",
|
|
2552
|
+
],
|
|
2553
|
+
}
|
|
2554
|
+
`)
|
|
2555
|
+
})
|
|
2556
|
+
|
|
2557
|
+
test('publishes concrete creation schemas', async () => {
|
|
2558
|
+
const app = create({ auth: false })
|
|
2559
|
+
type Spec = ComponentSpec & {
|
|
2560
|
+
paths: Record<
|
|
2561
|
+
string,
|
|
2562
|
+
{
|
|
2563
|
+
post?: {
|
|
2564
|
+
requestBody: {
|
|
2565
|
+
content: Record<string, { schema: JsonSchema }>
|
|
2566
|
+
}
|
|
2567
|
+
responses: Record<string, unknown>
|
|
2568
|
+
}
|
|
2569
|
+
}
|
|
2570
|
+
>
|
|
2571
|
+
}
|
|
2572
|
+
const spec = (await (await app.request('/openapi.json')).json()) as Spec
|
|
2573
|
+
const creationSchema = (path: string) =>
|
|
2574
|
+
dereference(spec, spec.paths[path]!.post!.requestBody.content['application/json']!.schema)
|
|
2575
|
+
expect(
|
|
2576
|
+
creationSchema('/v1/routes/deposit-addresses').required?.includes('subsidize') ?? false,
|
|
2577
|
+
).toMatchInlineSnapshot(`false`)
|
|
2578
|
+
const summarize = (path: string) => {
|
|
2579
|
+
const schema = creationSchema(path)
|
|
2580
|
+
return {
|
|
2581
|
+
additionalProperties: schema.additionalProperties,
|
|
2582
|
+
properties: Object.keys(schema.properties!),
|
|
2583
|
+
}
|
|
2584
|
+
}
|
|
2585
|
+
|
|
2586
|
+
expect({
|
|
2587
|
+
account: summarize('/v1/routes/transfers'),
|
|
2588
|
+
depositAddress: summarize('/v1/routes/deposit-addresses'),
|
|
2589
|
+
depositAddressResponses: Object.keys(
|
|
2590
|
+
spec.paths['/v1/routes/deposit-addresses']!.post!.responses,
|
|
2591
|
+
),
|
|
2592
|
+
vault: summarize('/v1/routes/transfers/vault'),
|
|
2593
|
+
vaultResponses: Object.keys(spec.paths['/v1/routes/transfers/vault']!.post!.responses),
|
|
2594
|
+
zone: summarize('/v1/routes/transfers/zone'),
|
|
2595
|
+
zoneResponses: Object.keys(spec.paths['/v1/routes/transfers/zone']!.post!.responses),
|
|
2596
|
+
}).toMatchInlineSnapshot(`
|
|
2597
|
+
{
|
|
2598
|
+
"account": {
|
|
2599
|
+
"additionalProperties": false,
|
|
2600
|
+
"properties": [
|
|
2601
|
+
"amount",
|
|
2602
|
+
"destinationChain",
|
|
2603
|
+
"destinationToken",
|
|
2604
|
+
"mode",
|
|
2605
|
+
"provider",
|
|
2606
|
+
"recipient",
|
|
2607
|
+
"sender",
|
|
2608
|
+
"slippageBps",
|
|
2609
|
+
"sourceChain",
|
|
2610
|
+
"sourceToken",
|
|
2611
|
+
"subsidize",
|
|
2612
|
+
],
|
|
2613
|
+
},
|
|
2614
|
+
"depositAddress": {
|
|
2615
|
+
"additionalProperties": false,
|
|
2616
|
+
"properties": [
|
|
2617
|
+
"amount",
|
|
2618
|
+
"destinationToken",
|
|
2619
|
+
"recipient",
|
|
2620
|
+
"refundAddress",
|
|
2621
|
+
"sourceChain",
|
|
2622
|
+
"sourceToken",
|
|
2623
|
+
"subsidize",
|
|
2624
|
+
],
|
|
2625
|
+
},
|
|
2626
|
+
"depositAddressResponses": [
|
|
2627
|
+
"200",
|
|
2628
|
+
"400",
|
|
2629
|
+
"401",
|
|
2630
|
+
"403",
|
|
2631
|
+
"404",
|
|
2632
|
+
"409",
|
|
2633
|
+
"429",
|
|
2634
|
+
"500",
|
|
2635
|
+
"502",
|
|
2636
|
+
"504",
|
|
2637
|
+
],
|
|
2638
|
+
"vault": {
|
|
2639
|
+
"additionalProperties": false,
|
|
2640
|
+
"properties": [
|
|
2641
|
+
"amount",
|
|
2642
|
+
"mode",
|
|
2643
|
+
"recipient",
|
|
2644
|
+
"sender",
|
|
2645
|
+
"slippageBps",
|
|
2646
|
+
"sourceChain",
|
|
2647
|
+
"sourceToken",
|
|
2648
|
+
"vaultAddress",
|
|
2649
|
+
],
|
|
2650
|
+
},
|
|
2651
|
+
"vaultResponses": [
|
|
2652
|
+
"400",
|
|
2653
|
+
"401",
|
|
2654
|
+
"403",
|
|
2655
|
+
"429",
|
|
2656
|
+
"500",
|
|
2657
|
+
"501",
|
|
2658
|
+
"504",
|
|
2659
|
+
],
|
|
2660
|
+
"zone": {
|
|
2661
|
+
"additionalProperties": false,
|
|
2662
|
+
"properties": [
|
|
2663
|
+
"amount",
|
|
2664
|
+
"destinationChain",
|
|
2665
|
+
"destinationToken",
|
|
2666
|
+
"mode",
|
|
2667
|
+
"recipient",
|
|
2668
|
+
"recipientFallback",
|
|
2669
|
+
"sender",
|
|
2670
|
+
"slippageBps",
|
|
2671
|
+
"sourceChain",
|
|
2672
|
+
"sourceToken",
|
|
2673
|
+
],
|
|
2674
|
+
},
|
|
2675
|
+
"zoneResponses": [
|
|
2676
|
+
"400",
|
|
2677
|
+
"401",
|
|
2678
|
+
"403",
|
|
2679
|
+
"429",
|
|
2680
|
+
"500",
|
|
2681
|
+
"501",
|
|
2682
|
+
"504",
|
|
2683
|
+
],
|
|
2684
|
+
}
|
|
2685
|
+
`)
|
|
2686
|
+
})
|
|
2687
|
+
|
|
2688
|
+
test('publishes alphabetically ordered example fields and parameter examples', async () => {
|
|
2689
|
+
const app = create({ auth: false })
|
|
2690
|
+
const spec = (await (await app.request('/openapi.json')).json()) as {
|
|
2691
|
+
paths: Record<
|
|
2692
|
+
string,
|
|
2693
|
+
{
|
|
2694
|
+
get: {
|
|
2695
|
+
parameters?: { example?: unknown; name: string; schema?: { examples?: unknown } }[]
|
|
2696
|
+
responses: Record<string, { content: Record<string, { example: { data: {}[] } }> }>
|
|
2697
|
+
}
|
|
2698
|
+
}
|
|
2699
|
+
>
|
|
2700
|
+
}
|
|
2701
|
+
const operation = spec.paths['/v1/routes/transfers']!.get
|
|
2702
|
+
const fields = Object.keys(operation.responses['200']!.content['application/json']!.example.data[0]!) // prettier-ignore
|
|
2703
|
+
expect(fields).toEqual([...fields].sort())
|
|
2704
|
+
for (const route of [
|
|
2705
|
+
operation,
|
|
2706
|
+
spec.paths['/v1/routes/deposit-addresses']!.get,
|
|
2707
|
+
spec.paths['/v1/routes/deposits']!.get,
|
|
2708
|
+
])
|
|
2709
|
+
for (const parameter of route.parameters ?? [])
|
|
2710
|
+
expect(parameter.example ?? parameter.schema?.examples, parameter.name).toBeDefined()
|
|
2711
|
+
})
|
|
2712
|
+
|
|
2713
|
+
test('publishes operation ids and required scopes', async () => {
|
|
2714
|
+
const app = create({ auth: false })
|
|
2715
|
+
const spec = (await (await app.request('/openapi.json')).json()) as {
|
|
2716
|
+
paths: Record<
|
|
2717
|
+
string,
|
|
2718
|
+
{
|
|
2719
|
+
get: { operationId: string; 'x-required-scopes': string[] }
|
|
2720
|
+
post?: {
|
|
2721
|
+
operationId: string
|
|
2722
|
+
parameters: { in: string; name: string; required: boolean }[]
|
|
2723
|
+
'x-required-scopes': string[]
|
|
2724
|
+
}
|
|
2725
|
+
}
|
|
2726
|
+
>
|
|
2727
|
+
}
|
|
2728
|
+
const detailPath = Object.keys(spec.paths).find(
|
|
2729
|
+
(path) => path.includes('/v1/routes/transfers/{') && !path.endsWith('/source-transactions'),
|
|
2730
|
+
)
|
|
2731
|
+
const sourceTransactionPath = Object.keys(spec.paths).find((path) =>
|
|
2732
|
+
path.endsWith('/source-transactions'),
|
|
2733
|
+
)
|
|
2734
|
+
const depositAddressPath = Object.keys(spec.paths).find(
|
|
2735
|
+
(path) =>
|
|
2736
|
+
path.includes('/v1/routes/deposit-addresses/{') &&
|
|
2737
|
+
!path.endsWith('/deposits') &&
|
|
2738
|
+
!path.endsWith('/reconcile'),
|
|
2739
|
+
)
|
|
2740
|
+
const depositPath = Object.keys(spec.paths).find((path) =>
|
|
2741
|
+
path.includes('/v1/routes/deposits/{'),
|
|
2742
|
+
)
|
|
2743
|
+
const reconcilePath = Object.keys(spec.paths).find((path) => path.endsWith('/reconcile'))
|
|
2744
|
+
expect({
|
|
2745
|
+
deposit: depositPath && spec.paths[depositPath]?.get.operationId,
|
|
2746
|
+
depositAddress: depositAddressPath && spec.paths[depositAddressPath]?.get.operationId,
|
|
2747
|
+
depositAddressCreate: spec.paths['/v1/routes/deposit-addresses']?.post?.operationId,
|
|
2748
|
+
depositAddressCreateScopes:
|
|
2749
|
+
spec.paths['/v1/routes/deposit-addresses']?.post?.['x-required-scopes'],
|
|
2750
|
+
depositAddressList: spec.paths['/v1/routes/deposit-addresses']?.get.operationId,
|
|
2751
|
+
depositAddressListScopes:
|
|
2752
|
+
spec.paths['/v1/routes/deposit-addresses']?.get['x-required-scopes'],
|
|
2753
|
+
depositAddressReconcile: reconcilePath && spec.paths[reconcilePath]?.post?.operationId,
|
|
2754
|
+
depositAddressReconcileScopes:
|
|
2755
|
+
reconcilePath && spec.paths[reconcilePath]?.post?.['x-required-scopes'],
|
|
2756
|
+
depositAddressScopes:
|
|
2757
|
+
depositAddressPath && spec.paths[depositAddressPath]?.get['x-required-scopes'],
|
|
2758
|
+
depositScopes: depositPath && spec.paths[depositPath]?.get['x-required-scopes'],
|
|
2759
|
+
deposits: spec.paths['/v1/routes/deposits']?.get.operationId,
|
|
2760
|
+
depositsScopes: spec.paths['/v1/routes/deposits']?.get['x-required-scopes'],
|
|
2761
|
+
detail: detailPath && spec.paths[detailPath]?.get.operationId,
|
|
2762
|
+
detailScopes: detailPath && spec.paths[detailPath]?.get['x-required-scopes'],
|
|
2763
|
+
list: spec.paths['/v1/routes/transfers']?.get.operationId,
|
|
2764
|
+
listScopes: spec.paths['/v1/routes/transfers']?.get['x-required-scopes'],
|
|
2765
|
+
requiredCreateHeader: spec.paths['/v1/routes/transfers']?.post?.parameters.find(
|
|
2766
|
+
(parameter) => parameter.name === 'idempotency-key',
|
|
2767
|
+
),
|
|
2768
|
+
sourceTransaction:
|
|
2769
|
+
sourceTransactionPath && spec.paths[sourceTransactionPath]?.post?.operationId,
|
|
2770
|
+
sourceTransactionScopes:
|
|
2771
|
+
sourceTransactionPath && spec.paths[sourceTransactionPath]?.post?.['x-required-scopes'],
|
|
2772
|
+
vault: spec.paths['/v1/routes/transfers/vault']?.post?.operationId,
|
|
2773
|
+
vaultScopes: spec.paths['/v1/routes/transfers/vault']?.post?.['x-required-scopes'],
|
|
2774
|
+
zone: spec.paths['/v1/routes/transfers/zone']?.post?.operationId,
|
|
2775
|
+
zoneScopes: spec.paths['/v1/routes/transfers/zone']?.post?.['x-required-scopes'],
|
|
2776
|
+
}).toEqual({
|
|
2777
|
+
deposit: 'getRoutesDeposit',
|
|
2778
|
+
depositAddress: 'getRoutesDepositAddress',
|
|
2779
|
+
depositAddressCreate: 'createRoutesDepositAddress',
|
|
2780
|
+
depositAddressCreateScopes: ['routes:write'],
|
|
2781
|
+
depositAddressList: 'listRoutesDepositAddresses',
|
|
2782
|
+
depositAddressListScopes: ['routes:read'],
|
|
2783
|
+
depositAddressReconcile: 'reconcileRoutesDepositAddress',
|
|
2784
|
+
depositAddressReconcileScopes: ['routes:write'],
|
|
2785
|
+
depositAddressScopes: ['routes:read'],
|
|
2786
|
+
depositScopes: ['routes:read'],
|
|
2787
|
+
deposits: 'listRoutesDeposits',
|
|
2788
|
+
depositsScopes: ['routes:read'],
|
|
2789
|
+
detail: 'getRoutesTransfer',
|
|
2790
|
+
detailScopes: ['routes:read'],
|
|
2791
|
+
list: 'listRoutesTransfers',
|
|
2792
|
+
listScopes: ['routes:read'],
|
|
2793
|
+
requiredCreateHeader: expect.objectContaining({
|
|
2794
|
+
description: expect.stringContaining('24 hours'),
|
|
2795
|
+
in: 'header',
|
|
2796
|
+
name: 'idempotency-key',
|
|
2797
|
+
required: true,
|
|
2798
|
+
schema: expect.any(Object),
|
|
2799
|
+
}),
|
|
2800
|
+
sourceTransaction: 'registerRoutesTransferSourceTransaction',
|
|
2801
|
+
sourceTransactionScopes: ['routes:write'],
|
|
2802
|
+
vault: 'createRoutesTransferVault',
|
|
2803
|
+
vaultScopes: ['routes:write'],
|
|
2804
|
+
zone: 'createRoutesTransferZone',
|
|
2805
|
+
zoneScopes: ['routes:write'],
|
|
2806
|
+
})
|
|
2807
|
+
})
|
|
2808
|
+
})
|
|
2809
|
+
|
|
2810
|
+
const routesReader = {
|
|
2811
|
+
id: 'key_routes',
|
|
2812
|
+
orgId: 'org_routes',
|
|
2813
|
+
scopes: ['routes:read'],
|
|
2814
|
+
token: 'secret_routes_reader',
|
|
2815
|
+
} satisfies TestApp.kvStore.Key
|
|
2816
|
+
|
|
2817
|
+
const routesProjectReader = {
|
|
2818
|
+
id: 'key_routes_project',
|
|
2819
|
+
orgId: 'org_routes',
|
|
2820
|
+
projectId: 'prj_routes',
|
|
2821
|
+
scopes: ['routes:read'],
|
|
2822
|
+
token: 'secret_routes_project',
|
|
2823
|
+
} satisfies TestApp.kvStore.Key
|
|
2824
|
+
|
|
2825
|
+
const routesForeign = {
|
|
2826
|
+
id: 'key_routes_other',
|
|
2827
|
+
orgId: 'org_routes_other',
|
|
2828
|
+
scopes: ['routes:read', 'routes:write'],
|
|
2829
|
+
token: 'secret_routes_other',
|
|
2830
|
+
} satisfies TestApp.kvStore.Key
|
|
2831
|
+
|
|
2832
|
+
const routesWriter = {
|
|
2833
|
+
id: 'key_routes_writer',
|
|
2834
|
+
orgId: 'org_routes',
|
|
2835
|
+
scopes: ['routes:read', 'routes:write'],
|
|
2836
|
+
token: 'secret_routes_writer',
|
|
2837
|
+
} satisfies TestApp.kvStore.Key
|
|
2838
|
+
|
|
2839
|
+
function transfersApp(options: TestApp.create.Options = {}) {
|
|
2840
|
+
return create({
|
|
2841
|
+
...options,
|
|
2842
|
+
auth: {
|
|
2843
|
+
keys: [TestApp.key, routesReader, routesProjectReader, routesForeign, routesWriter],
|
|
2844
|
+
},
|
|
2845
|
+
db: options.db ?? db,
|
|
2846
|
+
defaultChainId: options.defaultChainId ?? tempoMainnet.id,
|
|
2847
|
+
})
|
|
2848
|
+
}
|
|
2849
|
+
|
|
2850
|
+
function transferSubsidy(maxAmount: string): RoutesTransferSubsidy.Inventory {
|
|
2851
|
+
return {
|
|
2852
|
+
account: `0x${'77'.repeat(20)}`,
|
|
2853
|
+
async check() {
|
|
2854
|
+
return { nativeAmount: '100' }
|
|
2855
|
+
},
|
|
2856
|
+
policy: { maxAmount },
|
|
2857
|
+
}
|
|
2858
|
+
}
|
|
2859
|
+
|
|
2860
|
+
function as(key: { token: string }) {
|
|
2861
|
+
return { headers: { authorization: `Bearer ${key.token}` } } as const
|
|
2862
|
+
}
|
|
2863
|
+
|
|
2864
|
+
let seedSecond = 0
|
|
2865
|
+
|
|
2866
|
+
function seedTransfer(input: Partial<RoutesTransfer.create.Input> = {}) {
|
|
2867
|
+
// Distinct create times keep ids strictly ordered for paging assertions.
|
|
2868
|
+
return RoutesTransfer.create(db, {
|
|
2869
|
+
apiKeyId: routesReader.id,
|
|
2870
|
+
environment: 'production',
|
|
2871
|
+
id: RoutesTransfer.generateId(new Date(Date.UTC(2026, 0, 2, 0, 0, seedSecond++))),
|
|
2872
|
+
orgId: routesReader.orgId,
|
|
2873
|
+
snapshot: TestRoutes.transferSnapshot(),
|
|
2874
|
+
...input,
|
|
2875
|
+
})
|
|
2876
|
+
}
|