tapimo 0.14.0 → 0.15.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +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 +12466 -10374
- package/dist/App.d.ts.map +1 -1
- package/dist/App.js +300 -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 +1 -1
- package/dist/Webhooks.js.map +1 -1
- package/dist/admin/App.d.ts +3057 -546
- 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 +179 -27
- 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 +1398 -0
- package/dist/admin/apps/earn-vaults.d.ts.map +1 -1
- package/dist/admin/apps/earn-vaults.js +463 -7
- package/dist/admin/apps/earn-vaults.js.map +1 -1
- package/dist/admin/apps/organizations.d.ts +267 -15
- package/dist/admin/apps/organizations.d.ts.map +1 -1
- package/dist/admin/apps/organizations.js +241 -25
- 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 +166 -160
- package/dist/admin/apps/verified-tokens.d.ts.map +1 -1
- package/dist/admin/apps/verified-tokens.js +27 -7
- 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 +201 -149
- 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 +37 -5
- package/dist/apps/Zones.js.map +1 -1
- package/dist/apps/data/App.d.ts +3971 -2595
- package/dist/apps/data/App.d.ts.map +1 -1
- package/dist/apps/data/App.js +76 -21
- package/dist/apps/data/App.js.map +1 -1
- package/dist/apps/data/routes/activities.d.ts +629 -299
- 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 +72 -0
- package/dist/apps/data/routes/addresses.d.ts.map +1 -1
- package/dist/apps/data/routes/blocks.d.ts +116 -116
- 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 +1450 -337
- package/dist/apps/data/routes/earn.d.ts.map +1 -1
- package/dist/apps/data/routes/earn.js +1226 -144
- package/dist/apps/data/routes/earn.js.map +1 -1
- package/dist/apps/data/routes/fee-amm.d.ts +113 -108
- package/dist/apps/data/routes/fee-amm.d.ts.map +1 -1
- package/dist/apps/data/routes/fee-amm.js +41 -21
- package/dist/apps/data/routes/fee-amm.js.map +1 -1
- package/dist/apps/data/routes/indexer.d.ts +142 -17
- 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/receipts.d.ts +235 -235
- 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 +309 -165
- 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 +2 -0
- 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 +93 -77
- 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/valuation.d.ts +32 -32
- package/dist/apps/data/routes/verified-tokens.d.ts +88 -88
- 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 +614 -177
- package/dist/apps/data/routes/webhooks.d.ts.map +1 -1
- package/dist/apps/data/routes/webhooks.js +308 -205
- package/dist/apps/data/routes/webhooks.js.map +1 -1
- package/dist/apps/data/routes/zones.d.ts +31 -31
- 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 +3780 -3402
- 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 +48 -7
- package/dist/apps/management/Billing.d.ts.map +1 -1
- package/dist/apps/management/Billing.js +204 -25
- package/dist/apps/management/Billing.js.map +1 -1
- package/dist/apps/management/routes/api-keys.d.ts +317 -215
- 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 +290 -4
- 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 +213 -138
- 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 +166 -166
- 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 +30 -30
- package/dist/apps/management/routes/orgs.d.ts +103 -87
- 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 +125 -125
- 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 +24 -24
- 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 +95 -95
- package/dist/apps/management/routes/verified-token-requests.d.ts.map +1 -1
- package/dist/apps/management/routes/verified-token-requests.js +7 -9
- package/dist/apps/management/routes/verified-token-requests.js.map +1 -1
- package/dist/apps/management/routes/webhooks.d.ts +682 -616
- package/dist/apps/management/routes/webhooks.d.ts.map +1 -1
- package/dist/apps/management/routes/webhooks.js +58 -12
- package/dist/apps/management/routes/webhooks.js.map +1 -1
- package/dist/apps/mcp.d.ts +1 -1
- package/dist/apps/mcp.d.ts.map +1 -1
- package/dist/apps/mcp.js +23 -10
- package/dist/apps/mcp.js.map +1 -1
- package/dist/apps/mpp/App.d.ts +44 -44
- 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 +134 -75
- 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 +209 -28
- 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 +418 -124
- package/dist/apps/{funding → routes}/App.d.ts.map +1 -1
- package/dist/apps/{funding → routes}/App.js +16 -16
- 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 +32 -32
- 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 +107 -43
- package/dist/apps/routes/routes/deposit-addresses.d.ts.map +1 -0
- package/dist/apps/{funding → routes}/routes/deposit-addresses.js +497 -222
- 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 +106 -103
- 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 +733 -428
- 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 +1035 -15
- package/dist/db/Db.js.map +1 -1
- package/dist/db/Schema.d.ts +780 -133
- package/dist/db/Schema.d.ts.map +1 -1
- package/dist/db/Schema.js +575 -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 +32 -10
- package/dist/db/tables/organizations.d.ts.map +1 -1
- package/dist/db/tables/organizations.js +110 -49
- package/dist/db/tables/organizations.js.map +1 -1
- package/dist/db/tables/projects.d.ts +2 -0
- package/dist/db/tables/projects.d.ts.map +1 -1
- package/dist/db/tables/projects.js +12 -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/{fundingTransferTransactions.js → routesTransferTransactions.js} +31 -13
- 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 +75 -20
- package/dist/db/tables/sponsoredTransactions.d.ts.map +1 -1
- package/dist/db/tables/sponsoredTransactions.js +124 -54
- 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/verifiedTokenRequests.d.ts +21 -4
- package/dist/db/tables/verifiedTokenRequests.d.ts.map +1 -1
- package/dist/db/tables/verifiedTokenRequests.js +65 -44
- package/dist/db/tables/verifiedTokenRequests.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 +19 -11
- package/dist/db/tables/webhookSubscriptions.d.ts.map +1 -1
- package/dist/db/tables/webhookSubscriptions.js +45 -13
- 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 +64 -12
- package/dist/internal/Auth.d.ts.map +1 -1
- package/dist/internal/Auth.js +631 -180
- 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 +27 -10
- 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 +30 -2067
- package/dist/internal/Viem.d.ts.map +1 -1
- package/dist/internal/Viem.js +167 -17
- 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 -4
- 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 +7 -7
- 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 +311 -105
- package/dist/internal/routes/Provider.d.ts.map +1 -0
- package/dist/internal/{funding → routes}/Provider.js +229 -98
- 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 +8 -8
- 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 +241 -46
- 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/{funding → routes}/TransferReconciliation.d.ts +13 -10
- 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/{funding → routes}/TransferWebhook.d.ts +5 -5
- package/dist/internal/routes/TransferWebhook.d.ts.map +1 -0
- package/dist/internal/{funding → routes}/TransferWebhook.js +3 -3
- package/dist/internal/routes/TransferWebhook.js.map +1 -0
- package/dist/internal/{funding → routes}/index.d.ts +2 -0
- package/dist/internal/routes/index.d.ts.map +1 -0
- package/dist/internal/{funding → routes}/index.js +2 -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 +194 -110
- 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/{funding → routes}/providers/stargate.d.ts +46 -18
- 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.js +12 -12
- 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 +334 -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 +539 -110
- package/src/Handler.ts +0 -1
- package/src/OpenApi.contract.test.ts +195 -0
- package/src/Scope.ts +17 -5
- package/src/Webhooks.ts +1 -1
- 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 +679 -6
- package/src/admin/apps/organizations.test.ts +306 -17
- package/src/admin/apps/organizations.ts +299 -24
- 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 +40 -3
- package/src/admin/apps/verified-tokens.ts +33 -7
- 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 +83 -50
- package/src/admin/ui/src/lib/organizations.ts +106 -25
- 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/lib/verified-tokens.ts +24 -9
- package/src/admin/ui/src/routeTree.gen.ts +63 -0
- package/src/admin/ui/src/routes/__root.tsx +13 -2
- 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.tsx +34 -4
- package/src/admin/ui/src/routes/organizations_.$orgId.tsx +239 -23
- 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/src/routes/verified-tokens.tsx +64 -20
- package/src/admin/ui.generated.ts +202 -188
- 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 +15 -0
- package/src/apps/Zones.ts +52 -5
- package/src/apps/composition.test.ts +68 -60
- package/src/apps/data/App.test.ts +180 -2
- package/src/apps/data/App.ts +88 -28
- 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 +1294 -17
- package/src/apps/data/routes/earn.ts +1838 -321
- package/src/apps/data/routes/exchanges.test.ts +12 -15
- package/src/apps/data/routes/fee-amm.test.ts +243 -0
- package/src/apps/data/routes/fee-amm.ts +201 -162
- 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 +384 -8
- package/src/apps/data/routes/rpc.ts +452 -227
- 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.scan.test.ts +29 -0
- package/src/apps/data/routes/webhooks.test.ts +651 -83
- package/src/apps/data/routes/webhooks.ts +1113 -868
- 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 +265 -29
- 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/verified-token-requests.test.ts +16 -2
- package/src/apps/management/routes/verified-token-requests.ts +7 -10
- package/src/apps/management/routes/webhooks.test.ts +49 -26
- package/src/apps/management/routes/webhooks.ts +78 -22
- package/src/apps/mcp.test.ts +113 -30
- package/src/apps/mcp.ts +22 -10
- 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 +839 -64
- package/src/apps/relay/App.ts +148 -81
- 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 +233 -32
- 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 +1358 -458
- package/src/apps/{funding → routes}/routes/deposit-addresses.ts +566 -246
- 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/{funding → routes}/routes/transfers.test.ts +1100 -353
- 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 +1485 -34
- package/src/db/Schema.ts +729 -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 +690 -13
- package/src/db/tables/organizations.ts +139 -55
- package/src/db/tables/projects.test.ts +16 -0
- package/src/db/tables/projects.ts +13 -3
- 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} +388 -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/{fundingTransferTransactions.ts → routesTransferTransactions.ts} +63 -18
- package/src/db/tables/routesTransfers.test.ts +338 -0
- package/src/db/tables/routesTransfers.ts +662 -0
- package/src/db/tables/sponsoredTransactions.test.ts +269 -45
- package/src/db/tables/sponsoredTransactions.ts +225 -65
- 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/verifiedTokenRequests.test.ts +39 -20
- package/src/db/tables/verifiedTokenRequests.ts +80 -44
- package/src/db/tables/webhookQueueEvents.ts +8 -1
- package/src/db/tables/webhookSubscriptions.ts +95 -20
- 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 +1656 -9
- package/src/internal/Auth.ts +880 -244
- 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 +33 -11
- package/src/internal/Email.ts +54 -0
- package/src/internal/Idempotency.test.ts +2 -2
- package/src/internal/Log.test-d.ts +8 -7
- package/src/internal/Log.test.ts +114 -16
- package/src/internal/Log.ts +53 -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 +221 -25
- package/src/internal/Webhooks.test.ts +85 -6
- 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 -9
- 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 +9 -9
- 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 +489 -186
- 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 +13 -13
- 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/{funding → routes}/TransferWebhook.test.ts +13 -13
- package/src/internal/{funding → routes}/TransferWebhook.ts +7 -7
- package/src/internal/{funding → routes}/index.test.ts +5 -3
- package/src/internal/{funding → routes}/index.ts +2 -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 +224 -32
- package/src/internal/{funding → routes}/providers/relay.ts +228 -121
- 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 +10 -10
- 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 -828
- 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 -53
- package/dist/db/tables/fundingTransferTransactions.d.ts.map +0 -1
- package/dist/db/tables/fundingTransferTransactions.js.map +0 -1
- package/dist/db/tables/fundingTransfers.d.ts +0 -99
- package/dist/db/tables/fundingTransfers.d.ts.map +0 -1
- package/dist/db/tables/fundingTransfers.js +0 -110
- 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 -462
- package/dist/internal/funding/Transfer.js.map +0 -1
- package/dist/internal/funding/TransferReconciliation.d.ts.map +0 -1
- package/dist/internal/funding/TransferReconciliation.js +0 -192
- package/dist/internal/funding/TransferReconciliation.js.map +0 -1
- package/dist/internal/funding/TransferWebhook.d.ts.map +0 -1
- package/dist/internal/funding/TransferWebhook.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.map +0 -1
- package/dist/internal/funding/providers/stargate.js +0 -579
- 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 -88
- package/src/apps/funding/ProviderAttempts.ts +0 -26
- package/src/apps/funding/index.ts +0 -1
- package/src/apps/funding/routes/transfers.ts +0 -987
- 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 -112
- package/src/db/tables/fundingTransfers.test.ts +0 -115
- package/src/db/tables/fundingTransfers.ts +0 -189
- 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 -524
- package/src/internal/funding/Transfer.ts +0 -762
- package/src/internal/funding/TransferReconciliation.test.ts +0 -147
- package/src/internal/funding/TransferReconciliation.ts +0 -264
- package/src/internal/funding/providers/stargate.test.ts +0 -328
- package/src/internal/funding/providers/stargate.ts +0 -856
- /package/dist/apps/{funding → routes}/Inventory.d.ts +0 -0
- /package/src/internal/{funding → routes}/Route.test.ts +0 -0
|
@@ -0,0 +1,1206 @@
|
|
|
1
|
+
import * as z from 'zod/mini'
|
|
2
|
+
|
|
3
|
+
import type * as Db from '../../db/Db.js'
|
|
4
|
+
import * as Organizations from '../../db/tables/organizations.js'
|
|
5
|
+
import * as RoutesTransferEvents from '../../db/tables/routesTransferEvents.js'
|
|
6
|
+
import * as RoutesSubsidies from '../../db/tables/routesSubsidies.js'
|
|
7
|
+
import * as RoutesTransferSubsidies from '../../db/tables/routesTransferSubsidies.js'
|
|
8
|
+
import * as RoutesTransferSubsidyNonces from '../../db/tables/routesTransferSubsidyNonces.js'
|
|
9
|
+
import * as RoutesTransferTransactions from '../../db/tables/routesTransferTransactions.js'
|
|
10
|
+
import * as RoutesTransfers from '../../db/tables/routesTransfers.js'
|
|
11
|
+
import * as Id from '../Id.js'
|
|
12
|
+
import * as OpenApi from '../OpenApi.js'
|
|
13
|
+
import * as Schema from '../Schema.js'
|
|
14
|
+
import type * as Webhooks from '../Webhooks.js'
|
|
15
|
+
import * as Action from './Action.js'
|
|
16
|
+
import * as Provider from './Provider.js'
|
|
17
|
+
import * as TransferSubsidy from './TransferSubsidy.js'
|
|
18
|
+
import * as TransferWebhook from './TransferWebhook.js'
|
|
19
|
+
|
|
20
|
+
/** Public route transfer statuses, in the order documented by the API. */
|
|
21
|
+
export const statuses = [
|
|
22
|
+
'awaiting-source',
|
|
23
|
+
'processing',
|
|
24
|
+
'refunding',
|
|
25
|
+
'completed',
|
|
26
|
+
'refunded',
|
|
27
|
+
'action-required',
|
|
28
|
+
'expired',
|
|
29
|
+
] as const
|
|
30
|
+
|
|
31
|
+
/** Lifecycle status of a route transfer. */
|
|
32
|
+
export type Status = (typeof statuses)[number]
|
|
33
|
+
|
|
34
|
+
/** Statuses that never change again after verified chain evidence. */
|
|
35
|
+
export const terminalStatuses = ['completed', 'expired', 'refunded'] as const satisfies readonly Status[] // prettier-ignore
|
|
36
|
+
|
|
37
|
+
/** Route methods a caller can select at creation. */
|
|
38
|
+
export const methods = ['depositAddress', 'transaction'] as const
|
|
39
|
+
|
|
40
|
+
/** Route method selected at creation. */
|
|
41
|
+
export type Method = (typeof methods)[number]
|
|
42
|
+
|
|
43
|
+
/** Amount modes a caller can select at creation. */
|
|
44
|
+
export const modes = ['exactDestination', 'exactSource'] as const
|
|
45
|
+
|
|
46
|
+
/** Amount mode selected at creation. */
|
|
47
|
+
export type Mode = (typeof modes)[number]
|
|
48
|
+
|
|
49
|
+
/** Customer-safe codes explaining an `action-required` or refund outcome. */
|
|
50
|
+
export const statusReasonCodes = [
|
|
51
|
+
'billing_past_due',
|
|
52
|
+
'billing_required',
|
|
53
|
+
'destination_amount_below_minimum',
|
|
54
|
+
'destination_recovered',
|
|
55
|
+
'manual_recovery_required',
|
|
56
|
+
'refund_failed',
|
|
57
|
+
'routes_subsidy_limit_exceeded',
|
|
58
|
+
'routes_subsidy_not_enabled',
|
|
59
|
+
'source_amount_above_maximum',
|
|
60
|
+
'source_amount_below_minimum',
|
|
61
|
+
'source_chain_mismatch',
|
|
62
|
+
'source_token_mismatch',
|
|
63
|
+
'subsidy_balance_unavailable',
|
|
64
|
+
'subsidy_failed',
|
|
65
|
+
] as const
|
|
66
|
+
|
|
67
|
+
/** Stable customer-safe status reason code. */
|
|
68
|
+
export type StatusReasonCode = (typeof statusReasonCodes)[number]
|
|
69
|
+
|
|
70
|
+
// The public state chart has no exits from `action-required`, but late chain
|
|
71
|
+
// evidence or operator-triggered reconciliation may still resolve one, so
|
|
72
|
+
// evidence-driven exits stay allowed.
|
|
73
|
+
const transitions: Record<Status, readonly Status[]> = {
|
|
74
|
+
'action-required': ['completed', 'processing', 'refunded', 'refunding'],
|
|
75
|
+
'awaiting-source': ['action-required', 'expired', 'processing'],
|
|
76
|
+
completed: [],
|
|
77
|
+
expired: [],
|
|
78
|
+
processing: ['action-required', 'awaiting-source', 'completed', 'refunding'],
|
|
79
|
+
refunded: [],
|
|
80
|
+
refunding: ['action-required', 'refunded'],
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/** Returns whether a status is terminal. */
|
|
84
|
+
export function isTerminal(status: Status): boolean {
|
|
85
|
+
return (terminalStatuses as readonly Status[]).includes(status)
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/** Returns whether the lifecycle allows moving from one status to another. */
|
|
89
|
+
export function canTransition(from: Status, to: Status): boolean {
|
|
90
|
+
return transitions[from].includes(to)
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
/** Generates a route transfer id (`rtr_…`, lexically time-ordered). */
|
|
94
|
+
export function generateId(now: Date = new Date()): string {
|
|
95
|
+
return Id.generateSortable('rtr', now)
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
/** Zod schemas owned by the route transfer resource. */
|
|
99
|
+
export namespace schema {
|
|
100
|
+
/** Route transfer lifecycle status. */
|
|
101
|
+
export const Status = z
|
|
102
|
+
.enum(statuses)
|
|
103
|
+
.check(
|
|
104
|
+
z.describe('Lifecycle status of the route transfer.'),
|
|
105
|
+
z.meta({ examples: ['awaiting-source'] }),
|
|
106
|
+
)
|
|
107
|
+
|
|
108
|
+
/** Customer-safe explanation of a status that needs context. */
|
|
109
|
+
export const StatusReason = OpenApi.component(
|
|
110
|
+
z
|
|
111
|
+
.object({
|
|
112
|
+
code: z
|
|
113
|
+
.enum(statusReasonCodes)
|
|
114
|
+
.check(
|
|
115
|
+
z.describe('Stable machine-readable reason code.'),
|
|
116
|
+
z.meta({ examples: ['destination_amount_below_minimum'] }),
|
|
117
|
+
),
|
|
118
|
+
message: z.string().check(
|
|
119
|
+
z.describe('Human-readable explanation of the reason.'),
|
|
120
|
+
z.meta({
|
|
121
|
+
examples: ['The verified destination amount did not satisfy the quoted minimum.'],
|
|
122
|
+
}),
|
|
123
|
+
),
|
|
124
|
+
})
|
|
125
|
+
.check(z.describe('Why the transfer is in its current status, when context is needed.')),
|
|
126
|
+
'RoutesTransferStatusReason',
|
|
127
|
+
)
|
|
128
|
+
|
|
129
|
+
/** Route method selected at creation. */
|
|
130
|
+
export const Method = z
|
|
131
|
+
.enum(methods)
|
|
132
|
+
.check(z.describe('How the caller funds the transfer.'), z.meta({ examples: ['transaction'] }))
|
|
133
|
+
|
|
134
|
+
/** Amount mode selected at creation. */
|
|
135
|
+
export const Mode = z
|
|
136
|
+
.enum(modes)
|
|
137
|
+
.check(
|
|
138
|
+
z.describe('Which side of the transfer the quoted amount fixes.'),
|
|
139
|
+
z.meta({ examples: ['exactSource'] }),
|
|
140
|
+
)
|
|
141
|
+
|
|
142
|
+
/** One fee applied to the transfer. */
|
|
143
|
+
export const Fee = OpenApi.component(
|
|
144
|
+
z
|
|
145
|
+
.object({
|
|
146
|
+
amount: Schema.TokenAmount,
|
|
147
|
+
side: z
|
|
148
|
+
.enum(['destination', 'source'])
|
|
149
|
+
.check(
|
|
150
|
+
z.describe('Which side of the transfer the fee is taken from.'),
|
|
151
|
+
z.meta({ examples: ['destination'] }),
|
|
152
|
+
),
|
|
153
|
+
token: Provider.schema.TokenRef,
|
|
154
|
+
type: z
|
|
155
|
+
.enum(['provider'])
|
|
156
|
+
.check(z.describe('What the fee pays for.'), z.meta({ examples: ['provider'] })),
|
|
157
|
+
})
|
|
158
|
+
.check(z.describe('One fee applied to the transfer.')),
|
|
159
|
+
'RoutesTransferFee',
|
|
160
|
+
)
|
|
161
|
+
|
|
162
|
+
/** Freshness and validity window of the selected quote. */
|
|
163
|
+
export const Quote = OpenApi.component(
|
|
164
|
+
z
|
|
165
|
+
.object({
|
|
166
|
+
expiresAt: z.iso
|
|
167
|
+
.datetime()
|
|
168
|
+
.check(
|
|
169
|
+
z.describe('When the quoted terms stop being executable (ISO 8601).'),
|
|
170
|
+
z.meta({ examples: ['2026-07-30T04:01:00.000Z'] }),
|
|
171
|
+
),
|
|
172
|
+
sampledAt: z.iso
|
|
173
|
+
.datetime()
|
|
174
|
+
.check(
|
|
175
|
+
z.describe('When the provider produced the quote (ISO 8601).'),
|
|
176
|
+
z.meta({ examples: ['2026-07-30T04:00:00.000Z'] }),
|
|
177
|
+
),
|
|
178
|
+
})
|
|
179
|
+
.check(z.describe('Freshness and validity window of the selected quote.')),
|
|
180
|
+
'RoutesTransferQuote',
|
|
181
|
+
)
|
|
182
|
+
|
|
183
|
+
const hashesCheck = (description: string) => [
|
|
184
|
+
z.describe(description),
|
|
185
|
+
z.meta({ examples: [[`0x${'aa'.repeat(32)}`]] }),
|
|
186
|
+
]
|
|
187
|
+
|
|
188
|
+
const snapshotFields = {
|
|
189
|
+
destinationAmount: z
|
|
190
|
+
.optional(Schema.TokenAmount)
|
|
191
|
+
.check(
|
|
192
|
+
z.describe('Expected amount received after provider deductions, including pool fees.'),
|
|
193
|
+
),
|
|
194
|
+
destinationAmountMin: z
|
|
195
|
+
.optional(Schema.TokenAmount)
|
|
196
|
+
.check(z.describe('Minimum destination amount encoded in the transfer action.')),
|
|
197
|
+
destinationAmountRequired: z
|
|
198
|
+
.optional(Schema.TokenAmount)
|
|
199
|
+
.check(z.describe('Destination amount required for normalized 1:1 delivery, when enabled.')),
|
|
200
|
+
destinationChain: Provider.schema.ChainRef,
|
|
201
|
+
destinationToken: Provider.schema.TokenRef,
|
|
202
|
+
destinationTransactionHashes: z.optional(
|
|
203
|
+
z.array(z.string()).check(...hashesCheck('Verified destination transaction references.')),
|
|
204
|
+
),
|
|
205
|
+
fees: z
|
|
206
|
+
.array(Fee)
|
|
207
|
+
.check(
|
|
208
|
+
z.describe(
|
|
209
|
+
'Explicit fees charged separately from the routed amount; deductions reflected in `destinationAmount` are omitted.',
|
|
210
|
+
),
|
|
211
|
+
),
|
|
212
|
+
method: Method,
|
|
213
|
+
mode: Mode,
|
|
214
|
+
provider: Provider.schema.ProviderRef,
|
|
215
|
+
quote: Quote,
|
|
216
|
+
recipient: z
|
|
217
|
+
.string()
|
|
218
|
+
.check(
|
|
219
|
+
z.describe('Final beneficiary of the transfer.'),
|
|
220
|
+
z.meta({ examples: [`0x${'11'.repeat(20)}`] }),
|
|
221
|
+
),
|
|
222
|
+
refundAddress: z.optional(
|
|
223
|
+
z
|
|
224
|
+
.string()
|
|
225
|
+
.check(
|
|
226
|
+
z.describe('Source-chain refund recipient (deposit-address method).'),
|
|
227
|
+
z.meta({ examples: [`0x${'22'.repeat(20)}`] }),
|
|
228
|
+
),
|
|
229
|
+
),
|
|
230
|
+
refundAmount: z.optional(Schema.TokenAmount),
|
|
231
|
+
refundTransactionHashes: z.optional(
|
|
232
|
+
z.array(z.string()).check(...hashesCheck('Verified refund transaction references.')),
|
|
233
|
+
),
|
|
234
|
+
sender: z.optional(
|
|
235
|
+
z
|
|
236
|
+
.string()
|
|
237
|
+
.check(
|
|
238
|
+
z.describe('Source-chain account that signs the route action (transaction method).'),
|
|
239
|
+
z.meta({ examples: [`0x${'22'.repeat(20)}`] }),
|
|
240
|
+
),
|
|
241
|
+
),
|
|
242
|
+
sourceAmount: Schema.TokenAmount,
|
|
243
|
+
sourceAmountMax: z.optional(Schema.TokenAmount),
|
|
244
|
+
sourceChain: Provider.schema.ChainRef,
|
|
245
|
+
sourceToken: Provider.schema.TokenRef,
|
|
246
|
+
sourceTransactionHashes: z.optional(
|
|
247
|
+
z.array(z.string()).check(...hashesCheck('Verified source transaction references.')),
|
|
248
|
+
),
|
|
249
|
+
subsidize: z
|
|
250
|
+
._default(z.boolean(), false)
|
|
251
|
+
.check(
|
|
252
|
+
z.describe('Whether Tempo guarantees normalized 1:1 destination delivery.'),
|
|
253
|
+
z.meta({ examples: [false] }),
|
|
254
|
+
),
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
/**
|
|
258
|
+
* The stored public snapshot: every transfer field except lifecycle columns
|
|
259
|
+
* (`id`, `status`, `statusReason`, `version`, `createdAt`, `updatedAt`),
|
|
260
|
+
* which live in typed columns and merge in at serialization.
|
|
261
|
+
*/
|
|
262
|
+
export const Snapshot = z
|
|
263
|
+
.object(snapshotFields)
|
|
264
|
+
.check(z.describe('Quote terms and reconciled public fields of a route transfer.'))
|
|
265
|
+
|
|
266
|
+
const routesTransferFields = {
|
|
267
|
+
createdAt: z.iso
|
|
268
|
+
.datetime()
|
|
269
|
+
.check(
|
|
270
|
+
z.describe('When the transfer was created (ISO 8601).'),
|
|
271
|
+
z.meta({ examples: ['2026-07-30T04:00:00.000Z'] }),
|
|
272
|
+
),
|
|
273
|
+
destinationAmount: snapshotFields.destinationAmount,
|
|
274
|
+
destinationAmountMin: snapshotFields.destinationAmountMin,
|
|
275
|
+
destinationAmountRequired: snapshotFields.destinationAmountRequired,
|
|
276
|
+
destinationChain: snapshotFields.destinationChain,
|
|
277
|
+
destinationToken: snapshotFields.destinationToken,
|
|
278
|
+
destinationTransactionHashes: snapshotFields.destinationTransactionHashes,
|
|
279
|
+
fees: snapshotFields.fees,
|
|
280
|
+
id: z
|
|
281
|
+
.string()
|
|
282
|
+
.check(
|
|
283
|
+
z.describe('Route transfer id (`rtr_…`, lexically time-ordered).'),
|
|
284
|
+
z.meta({ examples: ['rtr_001785729600000_2ZPE2gvateYEQ0dQslgvkhjx'] }),
|
|
285
|
+
),
|
|
286
|
+
method: snapshotFields.method,
|
|
287
|
+
mode: snapshotFields.mode,
|
|
288
|
+
provider: snapshotFields.provider,
|
|
289
|
+
quote: snapshotFields.quote,
|
|
290
|
+
recipient: snapshotFields.recipient,
|
|
291
|
+
refundAddress: snapshotFields.refundAddress,
|
|
292
|
+
refundAmount: snapshotFields.refundAmount,
|
|
293
|
+
refundTransactionHashes: snapshotFields.refundTransactionHashes,
|
|
294
|
+
sender: snapshotFields.sender,
|
|
295
|
+
sourceAmount: snapshotFields.sourceAmount,
|
|
296
|
+
sourceAmountMax: snapshotFields.sourceAmountMax,
|
|
297
|
+
sourceChain: snapshotFields.sourceChain,
|
|
298
|
+
sourceToken: snapshotFields.sourceToken,
|
|
299
|
+
sourceTransactionHashes: snapshotFields.sourceTransactionHashes,
|
|
300
|
+
subsidize: snapshotFields.subsidize,
|
|
301
|
+
status: Status,
|
|
302
|
+
statusReason: z.optional(StatusReason),
|
|
303
|
+
updatedAt: z.iso
|
|
304
|
+
.datetime()
|
|
305
|
+
.check(
|
|
306
|
+
z.describe('When the transfer last materially changed (ISO 8601).'),
|
|
307
|
+
z.meta({ examples: ['2026-07-30T04:00:20.000Z'] }),
|
|
308
|
+
),
|
|
309
|
+
version: z
|
|
310
|
+
.number()
|
|
311
|
+
.check(
|
|
312
|
+
z.int(),
|
|
313
|
+
z.positive(),
|
|
314
|
+
z.describe('Monotonic revision that increments whenever the transfer materially changes.'),
|
|
315
|
+
z.meta({ examples: [1] }),
|
|
316
|
+
),
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
/** A route transfer as returned by reads. Reads never include `action`. */
|
|
320
|
+
export const RoutesTransfer = OpenApi.component(
|
|
321
|
+
z.object(routesTransferFields).check(z.describe('One durable route transfer.')),
|
|
322
|
+
'RoutesTransfer',
|
|
323
|
+
)
|
|
324
|
+
|
|
325
|
+
/** A created route transfer: the read shape plus the executable action. */
|
|
326
|
+
export const CreatedRoutesTransfer = OpenApi.component(
|
|
327
|
+
z
|
|
328
|
+
.object({ action: Action.schema.Action, ...routesTransferFields })
|
|
329
|
+
.check(z.describe('The created route transfer, including its one-time executable action.')),
|
|
330
|
+
'CreatedRoutesTransfer',
|
|
331
|
+
)
|
|
332
|
+
|
|
333
|
+
/** Request body accepted by route transfer creation. */
|
|
334
|
+
export const CreateRequest = OpenApi.component(
|
|
335
|
+
z
|
|
336
|
+
.strictObject({
|
|
337
|
+
amount: z
|
|
338
|
+
.string()
|
|
339
|
+
.check(
|
|
340
|
+
z.regex(/^[1-9]\d*$/),
|
|
341
|
+
z.describe('Amount in base units of the token the mode fixes.'),
|
|
342
|
+
z.meta({ examples: ['1000000'] }),
|
|
343
|
+
),
|
|
344
|
+
destinationChain: z
|
|
345
|
+
.optional(z.string().check(z.minLength(1)))
|
|
346
|
+
.check(
|
|
347
|
+
z.describe('Destination chain CAIP-2 id, slug, or alias. Defaults to Tempo.'),
|
|
348
|
+
z.meta({ examples: ['base', 'ethereum', 'tempo', 'eip155:8453'] }),
|
|
349
|
+
),
|
|
350
|
+
destinationToken: z
|
|
351
|
+
.string()
|
|
352
|
+
.check(
|
|
353
|
+
z.minLength(1),
|
|
354
|
+
z.describe('Destination token symbol, contract address, or token key.'),
|
|
355
|
+
z.meta({ examples: ['usdc', 'pathusd'] }),
|
|
356
|
+
),
|
|
357
|
+
mode: Mode,
|
|
358
|
+
provider: z
|
|
359
|
+
.optional(z.string().check(z.minLength(1)))
|
|
360
|
+
.check(
|
|
361
|
+
z.describe('Route provider ID. Omit to select the best available provider.'),
|
|
362
|
+
z.meta({ examples: ['stargate', 'relay'] }),
|
|
363
|
+
),
|
|
364
|
+
recipient: z
|
|
365
|
+
.string()
|
|
366
|
+
.check(
|
|
367
|
+
z.minLength(1),
|
|
368
|
+
z.describe('Destination-chain account that receives the transfer.'),
|
|
369
|
+
z.meta({ examples: [`0x${'11'.repeat(20)}`] }),
|
|
370
|
+
),
|
|
371
|
+
sender: z
|
|
372
|
+
.string()
|
|
373
|
+
.check(
|
|
374
|
+
z.minLength(1),
|
|
375
|
+
z.describe('Source-chain account that signs the route action.'),
|
|
376
|
+
z.meta({ examples: [`0x${'22'.repeat(20)}`] }),
|
|
377
|
+
),
|
|
378
|
+
slippageBps: z.optional(
|
|
379
|
+
z
|
|
380
|
+
.number()
|
|
381
|
+
.check(
|
|
382
|
+
z.int(),
|
|
383
|
+
z.gte(0),
|
|
384
|
+
z.lte(10_000),
|
|
385
|
+
z.describe('Maximum acceptable slippage in basis points.'),
|
|
386
|
+
z.meta({ examples: [50] }),
|
|
387
|
+
),
|
|
388
|
+
),
|
|
389
|
+
sourceChain: z
|
|
390
|
+
.string()
|
|
391
|
+
.check(
|
|
392
|
+
z.describe('Source chain CAIP-2 id, slug, or alias.'),
|
|
393
|
+
z.meta({ examples: ['tempo', 'base', 'ethereum', 'eip155:4217'] }),
|
|
394
|
+
),
|
|
395
|
+
sourceToken: z
|
|
396
|
+
.string()
|
|
397
|
+
.check(
|
|
398
|
+
z.minLength(1),
|
|
399
|
+
z.describe('Source token symbol, contract address, or token key.'),
|
|
400
|
+
z.meta({ examples: ['usdce', 'usdc'] }),
|
|
401
|
+
),
|
|
402
|
+
subsidize: z
|
|
403
|
+
.optional(z.boolean())
|
|
404
|
+
.check(
|
|
405
|
+
z.describe(
|
|
406
|
+
'Guarantees normalized 1:1 delivery for exact-source Tempo USD transfers to Base or Ethereum. A Tempo Admin must enable subsidies for the organization.',
|
|
407
|
+
),
|
|
408
|
+
z.meta({ examples: [true] }),
|
|
409
|
+
),
|
|
410
|
+
})
|
|
411
|
+
.check(z.describe('Route transfer creation request.')),
|
|
412
|
+
'CreateRoutesTransferRequest',
|
|
413
|
+
)
|
|
414
|
+
}
|
|
415
|
+
|
|
416
|
+
/** Stored public snapshot of a route transfer (see {@link schema.Snapshot}). */
|
|
417
|
+
export type Snapshot = z.output<typeof schema.Snapshot>
|
|
418
|
+
|
|
419
|
+
/** Customer-safe status reason (see {@link schema.StatusReason}). */
|
|
420
|
+
export type StatusReason = z.output<typeof schema.StatusReason>
|
|
421
|
+
|
|
422
|
+
/** A route transfer as returned by reads (see {@link schema.RoutesTransfer}). */
|
|
423
|
+
export type Public = z.output<typeof schema.RoutesTransfer>
|
|
424
|
+
|
|
425
|
+
/** A created route transfer (see {@link schema.CreatedRoutesTransfer}). */
|
|
426
|
+
export type Created = z.output<typeof schema.CreatedRoutesTransfer>
|
|
427
|
+
|
|
428
|
+
/** A validated creation request (see {@link schema.CreateRequest}). */
|
|
429
|
+
export type CreateRequest = z.output<typeof schema.CreateRequest>
|
|
430
|
+
|
|
431
|
+
/** What an associated transaction reference evidences. */
|
|
432
|
+
export const transactionRoles = ['destination', 'refund', 'source'] as const
|
|
433
|
+
|
|
434
|
+
/** Role of a verified transaction reference on a transfer. */
|
|
435
|
+
export type TransactionRole = (typeof transactionRoles)[number]
|
|
436
|
+
|
|
437
|
+
/** Bounded private provider state retained for transfer reconciliation. */
|
|
438
|
+
export type ProviderState = Record<string, unknown>
|
|
439
|
+
|
|
440
|
+
type Staged = {
|
|
441
|
+
/** Route transfer record committed with the webhook obligations. */
|
|
442
|
+
record: RoutesTransfers.Record
|
|
443
|
+
/** Webhook queue references committed with the transfer. */
|
|
444
|
+
references: Webhooks.QueueReference[]
|
|
445
|
+
}
|
|
446
|
+
|
|
447
|
+
/**
|
|
448
|
+
* Creates a durable route transfer: the row plus its version-1 event commit
|
|
449
|
+
* in one transaction, so every stored version has an immutable public record.
|
|
450
|
+
*/
|
|
451
|
+
export async function create(db: Db.Db, input: create.Input): Promise<RoutesTransfers.Record> {
|
|
452
|
+
return db.transaction(async (tx) => (await createIn(tx, input)).record)
|
|
453
|
+
}
|
|
454
|
+
|
|
455
|
+
/**
|
|
456
|
+
* Creates the transfer row and its version-1 event inside the caller's
|
|
457
|
+
* transaction, for writes that must commit atomically with sibling state
|
|
458
|
+
* (idempotency completion).
|
|
459
|
+
*/
|
|
460
|
+
export async function createIn(tx: Db.Db, input: create.Input): Promise<createIn.Result> {
|
|
461
|
+
const now = new Date()
|
|
462
|
+
const snapshot = parseSnapshot(input.snapshot)
|
|
463
|
+
const record: RoutesTransfers.Record = {
|
|
464
|
+
apiKeyId: input.apiKeyId,
|
|
465
|
+
createdAt: now.toISOString(),
|
|
466
|
+
environment: input.environment,
|
|
467
|
+
id: input.id ?? generateId(now),
|
|
468
|
+
method: snapshot.method,
|
|
469
|
+
mode: snapshot.mode,
|
|
470
|
+
orgId: input.orgId,
|
|
471
|
+
projectId: input.projectId ?? null,
|
|
472
|
+
providerDeliveredAt: null,
|
|
473
|
+
providerId: snapshot.provider.id,
|
|
474
|
+
providerState: input.providerState ?? null,
|
|
475
|
+
quoteExpiresAt: snapshot.quote.expiresAt,
|
|
476
|
+
snapshot,
|
|
477
|
+
status: 'awaiting-source',
|
|
478
|
+
statusReason: null,
|
|
479
|
+
statusUpdatedAt: now.toISOString(),
|
|
480
|
+
subsidyAccount: input.subsidyCommitment?.account.toLowerCase() ?? null,
|
|
481
|
+
subsidyAmount: null,
|
|
482
|
+
subsidyChainId: input.subsidyCommitment?.chainId ?? null,
|
|
483
|
+
subsidyCommitmentAmount: input.subsidyCommitment?.amount ?? null,
|
|
484
|
+
subsidyMeterReportedAt: null,
|
|
485
|
+
subsidyNativeAmount: input.subsidyCommitment?.nativeAmount ?? null,
|
|
486
|
+
subsidyTokenAddress: input.subsidyCommitment?.tokenAddress.toLowerCase() ?? null,
|
|
487
|
+
subsidyTransactionHash: null,
|
|
488
|
+
updatedAt: now.toISOString(),
|
|
489
|
+
version: 1,
|
|
490
|
+
}
|
|
491
|
+
const created = await RoutesTransfers.insert(tx, record)
|
|
492
|
+
const event = await RoutesTransferEvents.insert(tx, {
|
|
493
|
+
createdAt: record.createdAt,
|
|
494
|
+
snapshot: toPublic(created),
|
|
495
|
+
status: created.status,
|
|
496
|
+
transferId: created.id,
|
|
497
|
+
version: created.version,
|
|
498
|
+
})
|
|
499
|
+
const { references } = await TransferWebhook.stage(tx, {
|
|
500
|
+
changes: [{ event, record: created }],
|
|
501
|
+
})
|
|
502
|
+
return { record: created, references }
|
|
503
|
+
}
|
|
504
|
+
|
|
505
|
+
export declare namespace createIn {
|
|
506
|
+
/** Created transfer and webhook queue references committed with it. */
|
|
507
|
+
type Result = Staged
|
|
508
|
+
}
|
|
509
|
+
|
|
510
|
+
export declare namespace create {
|
|
511
|
+
/** Fields required to create a route transfer. */
|
|
512
|
+
type Input = {
|
|
513
|
+
/** API key that created the transfer. */
|
|
514
|
+
apiKeyId: string
|
|
515
|
+
/** Key environment the transfer belongs to. */
|
|
516
|
+
environment: 'production' | 'sandbox'
|
|
517
|
+
/** Transfer id override for deterministic tests. */
|
|
518
|
+
id?: string | undefined
|
|
519
|
+
/** Owning organization id (`org_…`). */
|
|
520
|
+
orgId: string
|
|
521
|
+
/** Attributed project id, when the creating key is project-attributed. */
|
|
522
|
+
projectId?: string | undefined
|
|
523
|
+
/** Private provider correlation retained for reconciliation. */
|
|
524
|
+
providerState?: ProviderState | undefined
|
|
525
|
+
/** The public snapshot captured from the selected quote. */
|
|
526
|
+
snapshot: Snapshot
|
|
527
|
+
/** Inventory commitment approved atomically with the executable action. */
|
|
528
|
+
subsidyCommitment?: create.SubsidyCommitment | undefined
|
|
529
|
+
}
|
|
530
|
+
|
|
531
|
+
/** Private inventory promised before returning an executable action. */
|
|
532
|
+
type SubsidyCommitment = {
|
|
533
|
+
/** Destination subsidy signer address. */
|
|
534
|
+
account: string
|
|
535
|
+
/** Maximum destination token amount promised by Tempo. */
|
|
536
|
+
amount: NonNullable<Snapshot['destinationAmountRequired']>
|
|
537
|
+
/** Destination EVM chain CAIP-2 id. */
|
|
538
|
+
chainId: string
|
|
539
|
+
/** Worst-case native gas amount reserved for settlement. */
|
|
540
|
+
nativeAmount: string
|
|
541
|
+
/** Destination ERC-20 token address. */
|
|
542
|
+
tokenAddress: string
|
|
543
|
+
}
|
|
544
|
+
}
|
|
545
|
+
|
|
546
|
+
/** Checks and persists a creation-time subsidy commitment under the signer lock. */
|
|
547
|
+
export async function reserveSubsidyCommitmentIn(
|
|
548
|
+
tx: Db.Db,
|
|
549
|
+
input: create.Input,
|
|
550
|
+
options: reserveSubsidyCommitmentIn.Options,
|
|
551
|
+
): Promise<createIn.Result> {
|
|
552
|
+
await RoutesSubsidies.lockOrganization(tx, input.orgId)
|
|
553
|
+
if (!(await Organizations.get(tx, input.orgId))) throw new OrganizationNotFoundError()
|
|
554
|
+
await RoutesTransferSubsidyNonces.lockAvailableIn(tx, options).catch((cause) => {
|
|
555
|
+
if (cause instanceof RoutesTransferSubsidyNonces.BlockedError)
|
|
556
|
+
throw new SubsidySignerBlockedError()
|
|
557
|
+
throw cause
|
|
558
|
+
})
|
|
559
|
+
const reservations = await RoutesTransfers.subsidyReservations(tx, {
|
|
560
|
+
account: options.account,
|
|
561
|
+
chainId: options.chainId,
|
|
562
|
+
tokenAddress: options.tokenAddress,
|
|
563
|
+
})
|
|
564
|
+
const checked = await options.check({ reservations })
|
|
565
|
+
if (Date.parse(input.snapshot.quote.expiresAt) <= Date.now()) throw new QuoteExpiredError()
|
|
566
|
+
return createIn(tx, {
|
|
567
|
+
...input,
|
|
568
|
+
subsidyCommitment: {
|
|
569
|
+
account: options.account,
|
|
570
|
+
amount: options.subsidyCommitmentAmount,
|
|
571
|
+
chainId: options.chainId,
|
|
572
|
+
nativeAmount: checked.nativeAmount,
|
|
573
|
+
tokenAddress: options.tokenAddress,
|
|
574
|
+
},
|
|
575
|
+
})
|
|
576
|
+
}
|
|
577
|
+
|
|
578
|
+
export declare namespace reserveSubsidyCommitmentIn {
|
|
579
|
+
/** Creation-time subsidy commitment inputs. */
|
|
580
|
+
type Options = {
|
|
581
|
+
/** Destination subsidy signer address. */
|
|
582
|
+
account: string
|
|
583
|
+
/** Verifies aggregate inventory while the signer lane is locked. */
|
|
584
|
+
check: (options: CheckOptions) => Promise<{ nativeAmount: string }>
|
|
585
|
+
/** Destination EVM chain CAIP-2 id. */
|
|
586
|
+
chainId: string
|
|
587
|
+
/** Maximum destination token amount promised by Tempo. */
|
|
588
|
+
subsidyCommitmentAmount: NonNullable<Snapshot['destinationAmountRequired']>
|
|
589
|
+
/** Destination ERC-20 token address. */
|
|
590
|
+
tokenAddress: string
|
|
591
|
+
}
|
|
592
|
+
|
|
593
|
+
/** Active inventory already promised by other transfers. */
|
|
594
|
+
type CheckOptions = {
|
|
595
|
+
/** Existing token and native reservations. */
|
|
596
|
+
reservations: RoutesTransfers.subsidyReservations.Result
|
|
597
|
+
}
|
|
598
|
+
}
|
|
599
|
+
|
|
600
|
+
/** Atomically assigns verified source transactions and starts reconciliation. */
|
|
601
|
+
export async function registerSourceTransactions(
|
|
602
|
+
db: Db.Db,
|
|
603
|
+
options: registerSourceTransactions.Options,
|
|
604
|
+
): Promise<registerSourceTransactions.Result> {
|
|
605
|
+
try {
|
|
606
|
+
return await db.transaction(async (tx) => {
|
|
607
|
+
const current = await RoutesTransfers.getForUpdate(tx, options.id)
|
|
608
|
+
if (!current) return { type: 'not_found' }
|
|
609
|
+
if (options.transactionHashes.length === 0) return { current, type: 'invalid' }
|
|
610
|
+
|
|
611
|
+
const existing = await Promise.all(
|
|
612
|
+
options.transactionHashes.map((transactionRef) =>
|
|
613
|
+
RoutesTransferTransactions.getSource(tx, {
|
|
614
|
+
chainId: options.chainId,
|
|
615
|
+
transactionRef,
|
|
616
|
+
transferId: current.id,
|
|
617
|
+
}),
|
|
618
|
+
),
|
|
619
|
+
)
|
|
620
|
+
if (
|
|
621
|
+
existing.some(
|
|
622
|
+
(transaction) => transaction !== undefined && transaction.transferId !== current.id,
|
|
623
|
+
)
|
|
624
|
+
)
|
|
625
|
+
return { type: 'conflict' }
|
|
626
|
+
if (current.status !== 'awaiting-source') {
|
|
627
|
+
if (
|
|
628
|
+
existing.every((transaction) => transaction?.transferId === current.id) &&
|
|
629
|
+
(current.status === 'processing' || current.status === 'completed')
|
|
630
|
+
)
|
|
631
|
+
return { record: current, type: 'replayed' }
|
|
632
|
+
return { current, type: 'invalid' }
|
|
633
|
+
}
|
|
634
|
+
if (RoutesTransfers.isSubsidyCommitmentExpired(current)) return { current, type: 'invalid' }
|
|
635
|
+
|
|
636
|
+
const ordered = options.transactionHashes.toSorted((left, right) =>
|
|
637
|
+
RoutesTransferTransactions.normalize(options.chainId, left).localeCompare(
|
|
638
|
+
RoutesTransferTransactions.normalize(options.chainId, right),
|
|
639
|
+
),
|
|
640
|
+
)
|
|
641
|
+
for (const transactionRef of ordered) {
|
|
642
|
+
const result = await RoutesTransferTransactions.claimSource(tx, {
|
|
643
|
+
chainId: options.chainId,
|
|
644
|
+
createdAt: new Date().toISOString(),
|
|
645
|
+
role: 'source',
|
|
646
|
+
transactionRef,
|
|
647
|
+
transferId: options.id,
|
|
648
|
+
})
|
|
649
|
+
if (result.type === 'conflict') throw new SourceTransactionConflictError()
|
|
650
|
+
}
|
|
651
|
+
|
|
652
|
+
const result = await transitionIn(tx, {
|
|
653
|
+
current,
|
|
654
|
+
expectedVersion: current.version,
|
|
655
|
+
id: current.id,
|
|
656
|
+
providerState: { ...current.providerState, ...options.providerState },
|
|
657
|
+
snapshot: {
|
|
658
|
+
...current.snapshot,
|
|
659
|
+
...(options.destinationAmount ? { destinationAmount: options.destinationAmount } : {}),
|
|
660
|
+
sourceTransactionHashes: options.transactionHashes.map((transactionRef) =>
|
|
661
|
+
RoutesTransferTransactions.normalize(options.chainId, transactionRef),
|
|
662
|
+
),
|
|
663
|
+
},
|
|
664
|
+
status: 'processing',
|
|
665
|
+
})
|
|
666
|
+
if (result.type !== 'applied') throw new AtomicTransitionError()
|
|
667
|
+
return { record: result.record, references: result.references, type: 'registered' }
|
|
668
|
+
})
|
|
669
|
+
} catch (cause) {
|
|
670
|
+
if (cause instanceof SourceTransactionConflictError) return { type: 'conflict' }
|
|
671
|
+
throw cause
|
|
672
|
+
}
|
|
673
|
+
}
|
|
674
|
+
|
|
675
|
+
export declare namespace registerSourceTransactions {
|
|
676
|
+
/** Verified source evidence and private provider correlation. */
|
|
677
|
+
type Options = {
|
|
678
|
+
/** Source chain CAIP-2 id. */
|
|
679
|
+
chainId: string
|
|
680
|
+
/** Exact destination amount observed while verifying the source transaction. */
|
|
681
|
+
destinationAmount?: NonNullable<Snapshot['destinationAmount']> | undefined
|
|
682
|
+
/** Transfer id (`rtr_…`). */
|
|
683
|
+
id: string
|
|
684
|
+
/** Private state added for destination reconciliation. */
|
|
685
|
+
providerState: ProviderState
|
|
686
|
+
/** Verified source transaction hashes, with the execution hash first. */
|
|
687
|
+
transactionHashes: readonly [string, ...string[]]
|
|
688
|
+
}
|
|
689
|
+
|
|
690
|
+
/** Source transaction registration outcome. */
|
|
691
|
+
type Result =
|
|
692
|
+
| { type: 'conflict' }
|
|
693
|
+
| { current: RoutesTransfers.Record; type: 'invalid' }
|
|
694
|
+
| (Staged & { type: 'registered' })
|
|
695
|
+
| { record: RoutesTransfers.Record; type: 'replayed' }
|
|
696
|
+
| { type: 'not_found' }
|
|
697
|
+
}
|
|
698
|
+
|
|
699
|
+
/** Atomically removes invalidated source evidence and accepts a replacement. */
|
|
700
|
+
export async function reopenSourceTransaction(
|
|
701
|
+
db: Db.Db,
|
|
702
|
+
options: reopenSourceTransaction.Options,
|
|
703
|
+
): Promise<reopenSourceTransaction.Result> {
|
|
704
|
+
return db.transaction(async (tx) => {
|
|
705
|
+
const current = await RoutesTransfers.getForUpdate(tx, options.id)
|
|
706
|
+
if (!current) return { type: 'not_found' }
|
|
707
|
+
if (current.status !== 'processing') return { current, type: 'invalid' }
|
|
708
|
+
|
|
709
|
+
const removed = await RoutesTransferTransactions.removeSource(tx, {
|
|
710
|
+
chainId: options.chainId,
|
|
711
|
+
transactionHash: options.transactionHash,
|
|
712
|
+
transferId: current.id,
|
|
713
|
+
})
|
|
714
|
+
if (!removed) return { current, type: 'invalid' }
|
|
715
|
+
await RoutesTransferTransactions.removeSources(tx, { transferId: current.id })
|
|
716
|
+
const { sourceTransactionHashes: _sourceTransactionHashes, ...snapshot } = current.snapshot
|
|
717
|
+
const result = await transitionIn(tx, {
|
|
718
|
+
current,
|
|
719
|
+
expectedVersion: current.version,
|
|
720
|
+
id: current.id,
|
|
721
|
+
providerState: options.providerState,
|
|
722
|
+
snapshot,
|
|
723
|
+
status: 'awaiting-source',
|
|
724
|
+
})
|
|
725
|
+
if (result.type !== 'applied') throw new AtomicTransitionError()
|
|
726
|
+
return { record: result.record, references: result.references, type: 'reopened' }
|
|
727
|
+
})
|
|
728
|
+
}
|
|
729
|
+
|
|
730
|
+
export declare namespace reopenSourceTransaction {
|
|
731
|
+
/** Source evidence to remove after it disappears from the canonical chain. */
|
|
732
|
+
type Options = {
|
|
733
|
+
/** Source chain CAIP-2 id. */
|
|
734
|
+
chainId: string
|
|
735
|
+
/** Transfer id (`rtr_…`). */
|
|
736
|
+
id: string
|
|
737
|
+
/** Private provider state retained while awaiting replacement evidence. */
|
|
738
|
+
providerState: ProviderState
|
|
739
|
+
/** Invalidated source transaction hash. */
|
|
740
|
+
transactionHash: string
|
|
741
|
+
}
|
|
742
|
+
|
|
743
|
+
/** Source transaction reopening outcome. */
|
|
744
|
+
type Result =
|
|
745
|
+
| { current: RoutesTransfers.Record; type: 'invalid' }
|
|
746
|
+
| (Staged & { type: 'reopened' })
|
|
747
|
+
| { type: 'not_found' }
|
|
748
|
+
}
|
|
749
|
+
|
|
750
|
+
/** Atomically reserves a signer nonce and persists the signed subsidy before broadcast. */
|
|
751
|
+
export async function reserveSubsidy(
|
|
752
|
+
db: Db.Db,
|
|
753
|
+
options: reserveSubsidy.Options,
|
|
754
|
+
): Promise<reserveSubsidy.Result> {
|
|
755
|
+
return db.transaction(async (tx) => {
|
|
756
|
+
await RoutesSubsidies.lockOrganization(tx, options.orgId)
|
|
757
|
+
const current = await RoutesTransfers.getForUpdate(tx, options.id)
|
|
758
|
+
if (!current) return { type: 'not_found' }
|
|
759
|
+
if (current.orgId !== options.orgId || current.status !== 'processing')
|
|
760
|
+
return { current, type: 'invalid' }
|
|
761
|
+
const existing = TransferSubsidy.read(current.providerState?.['transferSubsidy'])
|
|
762
|
+
if (existing) return { record: current, transaction: existing, type: 'replayed' }
|
|
763
|
+
if (
|
|
764
|
+
!current.subsidyCommitmentAmount ||
|
|
765
|
+
BigInt(options.subsidyAmount.baseUnits) > BigInt(current.subsidyCommitmentAmount.baseUnits)
|
|
766
|
+
)
|
|
767
|
+
throw new SubsidyCommitmentExceededError()
|
|
768
|
+
const transactionRef = current.snapshot.sourceTransactionHashes?.[0]
|
|
769
|
+
const source = transactionRef
|
|
770
|
+
? await RoutesTransferTransactions.getSource(tx, {
|
|
771
|
+
chainId: current.snapshot.sourceChain.id,
|
|
772
|
+
transactionRef,
|
|
773
|
+
transferId: current.id,
|
|
774
|
+
})
|
|
775
|
+
: undefined
|
|
776
|
+
if (source?.transferId !== current.id) throw new SubsidyEvidenceError()
|
|
777
|
+
const settlement = await RoutesTransferSubsidies.getForUpdateIn(tx, {
|
|
778
|
+
sourceChainId: source.chainId,
|
|
779
|
+
transactionRef: source.transactionRef,
|
|
780
|
+
})
|
|
781
|
+
if (settlement) {
|
|
782
|
+
const transaction = TransferSubsidy.read(settlement.transaction)
|
|
783
|
+
if (
|
|
784
|
+
!transaction ||
|
|
785
|
+
settlement.destinationChainId !== options.chainId ||
|
|
786
|
+
settlement.recipient !== current.snapshot.recipient.toLowerCase() ||
|
|
787
|
+
settlement.tokenAddress !== options.tokenAddress.toLowerCase() ||
|
|
788
|
+
BigInt(transaction.amount) !== BigInt(options.subsidyAmount.baseUnits)
|
|
789
|
+
)
|
|
790
|
+
throw new SubsidyEvidenceError()
|
|
791
|
+
const result = await transitionIn(tx, {
|
|
792
|
+
current,
|
|
793
|
+
expectedVersion: current.version,
|
|
794
|
+
id: current.id,
|
|
795
|
+
providerState: {
|
|
796
|
+
...current.providerState,
|
|
797
|
+
transferSubsidy: transaction,
|
|
798
|
+
transferSubsidyOwnerId: settlement.transferId,
|
|
799
|
+
},
|
|
800
|
+
subsidyAccount: transaction.account,
|
|
801
|
+
subsidyAmount: null,
|
|
802
|
+
subsidyChainId: transaction.chainId,
|
|
803
|
+
subsidyCommitmentAmount: null,
|
|
804
|
+
subsidyNativeAmount: null,
|
|
805
|
+
subsidyTokenAddress: settlement.tokenAddress,
|
|
806
|
+
subsidyTransactionHash: transaction.hash,
|
|
807
|
+
})
|
|
808
|
+
if (result.type !== 'applied') throw new AtomicTransitionError()
|
|
809
|
+
return { record: result.record, references: result.references, transaction, type: 'shared' }
|
|
810
|
+
}
|
|
811
|
+
const nonce = await RoutesTransferSubsidyNonces.reserve(tx, {
|
|
812
|
+
account: options.account,
|
|
813
|
+
chainId: options.chainId,
|
|
814
|
+
pendingNonce: options.pendingNonce,
|
|
815
|
+
}).catch((cause) => {
|
|
816
|
+
if (cause instanceof RoutesTransferSubsidyNonces.BlockedError)
|
|
817
|
+
throw new SubsidySignerBlockedError()
|
|
818
|
+
throw cause
|
|
819
|
+
})
|
|
820
|
+
const reservations = await RoutesTransfers.subsidyReservations(tx, {
|
|
821
|
+
account: options.account,
|
|
822
|
+
chainId: options.chainId,
|
|
823
|
+
excludeId: current.id,
|
|
824
|
+
tokenAddress: options.tokenAddress,
|
|
825
|
+
})
|
|
826
|
+
const transaction = await options.prepare({ nonce, reservations })
|
|
827
|
+
const result = await transitionIn(tx, {
|
|
828
|
+
current,
|
|
829
|
+
expectedVersion: current.version,
|
|
830
|
+
id: current.id,
|
|
831
|
+
providerState: { ...current.providerState, transferSubsidy: transaction },
|
|
832
|
+
subsidyAccount: options.account.toLowerCase(),
|
|
833
|
+
subsidyAmount: options.subsidyAmount,
|
|
834
|
+
subsidyChainId: options.chainId,
|
|
835
|
+
subsidyNativeAmount: transaction.nativeAmount ?? null,
|
|
836
|
+
subsidyTokenAddress: options.tokenAddress.toLowerCase(),
|
|
837
|
+
subsidyTransactionHash: transaction.hash,
|
|
838
|
+
})
|
|
839
|
+
if (result.type !== 'applied') throw new AtomicTransitionError()
|
|
840
|
+
return {
|
|
841
|
+
record: result.record,
|
|
842
|
+
references: result.references,
|
|
843
|
+
transaction,
|
|
844
|
+
type: 'reserved',
|
|
845
|
+
}
|
|
846
|
+
})
|
|
847
|
+
}
|
|
848
|
+
|
|
849
|
+
/** Persists the first verified provider-delivery boundary exactly once. */
|
|
850
|
+
export async function recordProviderDelivery(
|
|
851
|
+
db: Db.Db,
|
|
852
|
+
options: recordProviderDelivery.Options,
|
|
853
|
+
): Promise<recordProviderDelivery.Result> {
|
|
854
|
+
return db.transaction(async (tx) => {
|
|
855
|
+
const current = await RoutesTransfers.getForUpdate(tx, options.id)
|
|
856
|
+
if (!current) return { type: 'not_found' }
|
|
857
|
+
if (current.providerDeliveredAt) return { record: current, type: 'replayed' }
|
|
858
|
+
if (current.status !== 'processing') return { current, type: 'invalid' }
|
|
859
|
+
const record = await RoutesTransfers.recordProviderDelivery(tx, {
|
|
860
|
+
deliveredAt: new Date().toISOString(),
|
|
861
|
+
id: current.id,
|
|
862
|
+
})
|
|
863
|
+
if (!record) throw new AtomicTransitionError()
|
|
864
|
+
return { record, type: 'recorded' }
|
|
865
|
+
})
|
|
866
|
+
}
|
|
867
|
+
|
|
868
|
+
export declare namespace recordProviderDelivery {
|
|
869
|
+
/** Provider delivery boundary input. */
|
|
870
|
+
type Options = { id: string }
|
|
871
|
+
|
|
872
|
+
/** Provider delivery boundary outcome. */
|
|
873
|
+
type Result =
|
|
874
|
+
| { current: RoutesTransfers.Record; type: 'invalid' }
|
|
875
|
+
| { record: RoutesTransfers.Record; type: 'recorded' }
|
|
876
|
+
| { record: RoutesTransfers.Record; type: 'replayed' }
|
|
877
|
+
| { type: 'not_found' }
|
|
878
|
+
}
|
|
879
|
+
|
|
880
|
+
/** Blocks a rejected signer lane and marks the owning transfer for recovery. */
|
|
881
|
+
export async function blockSubsidy(
|
|
882
|
+
db: Db.Db,
|
|
883
|
+
options: blockSubsidy.Options,
|
|
884
|
+
): Promise<transition.Result> {
|
|
885
|
+
return db.transaction(async (tx) => {
|
|
886
|
+
const current = await RoutesTransfers.getForUpdate(tx, options.id)
|
|
887
|
+
if (!current) return { type: 'not_found' }
|
|
888
|
+
if (current.status !== 'processing' || !current.subsidyAccount || !current.subsidyChainId)
|
|
889
|
+
return { current, type: 'invalid' }
|
|
890
|
+
await RoutesTransferSubsidyNonces.blockIn(tx, {
|
|
891
|
+
account: current.subsidyAccount,
|
|
892
|
+
chainId: current.subsidyChainId,
|
|
893
|
+
reason: 'broadcast_rejected',
|
|
894
|
+
transferId:
|
|
895
|
+
typeof current.providerState?.['transferSubsidyOwnerId'] === 'string'
|
|
896
|
+
? current.providerState['transferSubsidyOwnerId']
|
|
897
|
+
: current.id,
|
|
898
|
+
})
|
|
899
|
+
return transitionIn(tx, {
|
|
900
|
+
current,
|
|
901
|
+
expectedVersion: current.version,
|
|
902
|
+
id: current.id,
|
|
903
|
+
status: 'action-required',
|
|
904
|
+
statusReason: options.statusReason,
|
|
905
|
+
})
|
|
906
|
+
})
|
|
907
|
+
}
|
|
908
|
+
|
|
909
|
+
export declare namespace blockSubsidy {
|
|
910
|
+
/** Rejected subsidy transfer and customer-safe reason. */
|
|
911
|
+
type Options = {
|
|
912
|
+
/** Route transfer id (`rtr_…`). */
|
|
913
|
+
id: string
|
|
914
|
+
/** Customer-safe recovery reason. */
|
|
915
|
+
statusReason: StatusReason
|
|
916
|
+
}
|
|
917
|
+
}
|
|
918
|
+
|
|
919
|
+
export declare namespace reserveSubsidy {
|
|
920
|
+
/** Destination signer and transaction preparation inputs. */
|
|
921
|
+
type Options = {
|
|
922
|
+
/** Destination subsidy signer address. */
|
|
923
|
+
account: string
|
|
924
|
+
/** Destination EVM chain CAIP-2 id. */
|
|
925
|
+
chainId: string
|
|
926
|
+
/** Route transfer id (`rtr_…`). */
|
|
927
|
+
id: string
|
|
928
|
+
/** Owning organization serialized with subsidy liability persistence. */
|
|
929
|
+
orgId: string
|
|
930
|
+
/** Pending signer nonce observed before entering the database lock. */
|
|
931
|
+
pendingNonce: number
|
|
932
|
+
/** Prepares the signed transaction after inventory and nonce serialization. */
|
|
933
|
+
prepare: (options: reserveSubsidy.PrepareOptions) => Promise<TransferSubsidy.Transaction>
|
|
934
|
+
/** Destination token amount reserved for subsidy settlement. */
|
|
935
|
+
subsidyAmount: NonNullable<Snapshot['destinationAmountRequired']>
|
|
936
|
+
/** Destination ERC-20 token address. */
|
|
937
|
+
tokenAddress: string
|
|
938
|
+
}
|
|
939
|
+
|
|
940
|
+
/** Values resolved while holding the destination signer lock. */
|
|
941
|
+
type PrepareOptions = {
|
|
942
|
+
/** EOA nonce reserved for this transaction. */
|
|
943
|
+
nonce: number
|
|
944
|
+
/** Inventory already reserved by unsettled transfers. */
|
|
945
|
+
reservations: RoutesTransfers.subsidyReservations.Result
|
|
946
|
+
}
|
|
947
|
+
|
|
948
|
+
/** Durable transaction reservation outcome. */
|
|
949
|
+
type Result =
|
|
950
|
+
| { current: RoutesTransfers.Record; type: 'invalid' }
|
|
951
|
+
| (Staged & { transaction: TransferSubsidy.Transaction; type: 'reserved' })
|
|
952
|
+
| (Staged & { transaction: TransferSubsidy.Transaction; type: 'shared' })
|
|
953
|
+
| { record: RoutesTransfers.Record; transaction: TransferSubsidy.Transaction; type: 'replayed' }
|
|
954
|
+
| { type: 'not_found' }
|
|
955
|
+
}
|
|
956
|
+
|
|
957
|
+
/** Atomically records a verified destination transaction and completes a transfer. */
|
|
958
|
+
export async function complete(db: Db.Db, options: complete.Options): Promise<complete.Result> {
|
|
959
|
+
return db.transaction(async (tx) => {
|
|
960
|
+
const current = await RoutesTransfers.getForUpdate(tx, options.id)
|
|
961
|
+
if (!current) return { type: 'not_found' }
|
|
962
|
+
if (current.status === 'completed') {
|
|
963
|
+
const transactions = await RoutesTransferTransactions.listByTransfer(tx, current.id)
|
|
964
|
+
const existing = options.transactionHashes.every((transactionHash) =>
|
|
965
|
+
transactions.some(
|
|
966
|
+
(transaction) =>
|
|
967
|
+
transaction.chainId === options.chainId &&
|
|
968
|
+
transaction.role === 'destination' &&
|
|
969
|
+
transaction.transactionRef === transactionHash.toLowerCase(),
|
|
970
|
+
),
|
|
971
|
+
)
|
|
972
|
+
return existing ? { record: current, type: 'replayed' } : { current, type: 'invalid' }
|
|
973
|
+
}
|
|
974
|
+
if (current.status !== 'processing') return { current, type: 'invalid' }
|
|
975
|
+
|
|
976
|
+
const transactions = await Promise.all(
|
|
977
|
+
options.transactionHashes.map((transactionRef) =>
|
|
978
|
+
RoutesTransferTransactions.insert(tx, {
|
|
979
|
+
chainId: options.chainId,
|
|
980
|
+
createdAt: new Date().toISOString(),
|
|
981
|
+
role: 'destination',
|
|
982
|
+
transactionRef,
|
|
983
|
+
transferId: options.id,
|
|
984
|
+
}),
|
|
985
|
+
),
|
|
986
|
+
)
|
|
987
|
+
if (transactions.some((transaction) => !transaction)) throw new AtomicTransitionError()
|
|
988
|
+
const result = await transitionIn(tx, {
|
|
989
|
+
current,
|
|
990
|
+
expectedVersion: current.version,
|
|
991
|
+
id: current.id,
|
|
992
|
+
snapshot: {
|
|
993
|
+
...current.snapshot,
|
|
994
|
+
destinationAmount: options.destinationAmount,
|
|
995
|
+
destinationTransactionHashes: transactions.map(
|
|
996
|
+
(transaction) => transaction!.transactionRef,
|
|
997
|
+
),
|
|
998
|
+
},
|
|
999
|
+
status: 'completed',
|
|
1000
|
+
})
|
|
1001
|
+
if (result.type !== 'applied') throw new AtomicTransitionError()
|
|
1002
|
+
return { record: result.record, references: result.references, type: 'completed' }
|
|
1003
|
+
})
|
|
1004
|
+
}
|
|
1005
|
+
|
|
1006
|
+
export declare namespace complete {
|
|
1007
|
+
/** Verified destination evidence for one processing transfer. */
|
|
1008
|
+
type Options = {
|
|
1009
|
+
/** Destination chain CAIP-2 id. */
|
|
1010
|
+
chainId: string
|
|
1011
|
+
/** Exact verified destination amount. */
|
|
1012
|
+
destinationAmount: NonNullable<Snapshot['destinationAmount']>
|
|
1013
|
+
/** Transfer id (`rtr_…`). */
|
|
1014
|
+
id: string
|
|
1015
|
+
/** Verified destination transaction hashes, provider delivery first. */
|
|
1016
|
+
transactionHashes: readonly [string, ...string[]]
|
|
1017
|
+
}
|
|
1018
|
+
|
|
1019
|
+
/** Transfer completion outcome. */
|
|
1020
|
+
type Result =
|
|
1021
|
+
| { current: RoutesTransfers.Record; type: 'invalid' }
|
|
1022
|
+
| (Staged & { type: 'completed' })
|
|
1023
|
+
| { record: RoutesTransfers.Record; type: 'replayed' }
|
|
1024
|
+
| { type: 'not_found' }
|
|
1025
|
+
}
|
|
1026
|
+
|
|
1027
|
+
/**
|
|
1028
|
+
* Applies a version-guarded material change: a status transition, a snapshot
|
|
1029
|
+
* update, or both. The row update and its immutable event commit in one
|
|
1030
|
+
* transaction; a stale `expectedVersion` or disallowed transition applies
|
|
1031
|
+
* nothing, so concurrent observations cannot overwrite newer evidence.
|
|
1032
|
+
*/
|
|
1033
|
+
export async function transition(
|
|
1034
|
+
db: Db.Db,
|
|
1035
|
+
options: transition.Options,
|
|
1036
|
+
): Promise<transition.Result> {
|
|
1037
|
+
return db.transaction((tx) => transitionIn(tx, options))
|
|
1038
|
+
}
|
|
1039
|
+
|
|
1040
|
+
async function transitionIn(
|
|
1041
|
+
tx: Db.Db,
|
|
1042
|
+
options: transition.Options & { current?: RoutesTransfers.Record | undefined },
|
|
1043
|
+
): Promise<transition.Result> {
|
|
1044
|
+
const now = new Date()
|
|
1045
|
+
const current = options.current ?? (await RoutesTransfers.get(tx, options.id))
|
|
1046
|
+
if (!current) return { type: 'not_found' }
|
|
1047
|
+
if (current.version !== options.expectedVersion) return { current, type: 'stale' }
|
|
1048
|
+
const status = options.status ?? current.status
|
|
1049
|
+
if (status !== current.status && !canTransition(current.status, status))
|
|
1050
|
+
return { current, type: 'invalid' }
|
|
1051
|
+
|
|
1052
|
+
const updated = await RoutesTransfers.update(tx, {
|
|
1053
|
+
expectedVersion: options.expectedVersion,
|
|
1054
|
+
id: options.id,
|
|
1055
|
+
providerDeliveredAt: current.providerDeliveredAt,
|
|
1056
|
+
providerState:
|
|
1057
|
+
options.providerState === undefined ? current.providerState : options.providerState,
|
|
1058
|
+
snapshot: options.snapshot === undefined ? current.snapshot : parseSnapshot(options.snapshot),
|
|
1059
|
+
status,
|
|
1060
|
+
statusReason: options.statusReason ?? (status === current.status ? current.statusReason : null),
|
|
1061
|
+
statusUpdatedAt:
|
|
1062
|
+
status === current.status
|
|
1063
|
+
? (current.statusUpdatedAt ?? current.updatedAt)
|
|
1064
|
+
: now.toISOString(),
|
|
1065
|
+
subsidyAccount:
|
|
1066
|
+
options.subsidyAccount === undefined ? current.subsidyAccount : options.subsidyAccount,
|
|
1067
|
+
subsidyAmount:
|
|
1068
|
+
options.subsidyAmount === undefined ? current.subsidyAmount : options.subsidyAmount,
|
|
1069
|
+
subsidyChainId:
|
|
1070
|
+
options.subsidyChainId === undefined ? current.subsidyChainId : options.subsidyChainId,
|
|
1071
|
+
subsidyCommitmentAmount:
|
|
1072
|
+
options.subsidyCommitmentAmount === undefined
|
|
1073
|
+
? current.subsidyCommitmentAmount
|
|
1074
|
+
: options.subsidyCommitmentAmount,
|
|
1075
|
+
subsidyNativeAmount:
|
|
1076
|
+
options.subsidyNativeAmount === undefined
|
|
1077
|
+
? current.subsidyNativeAmount
|
|
1078
|
+
: options.subsidyNativeAmount,
|
|
1079
|
+
subsidyTokenAddress:
|
|
1080
|
+
options.subsidyTokenAddress === undefined
|
|
1081
|
+
? current.subsidyTokenAddress
|
|
1082
|
+
: options.subsidyTokenAddress,
|
|
1083
|
+
subsidyTransactionHash:
|
|
1084
|
+
options.subsidyTransactionHash === undefined
|
|
1085
|
+
? current.subsidyTransactionHash
|
|
1086
|
+
: options.subsidyTransactionHash,
|
|
1087
|
+
updatedAt: now.toISOString(),
|
|
1088
|
+
version: current.version + 1,
|
|
1089
|
+
})
|
|
1090
|
+
if (!updated) {
|
|
1091
|
+
const latest = await RoutesTransfers.get(tx, options.id)
|
|
1092
|
+
return latest ? { current: latest, type: 'stale' } : { type: 'not_found' }
|
|
1093
|
+
}
|
|
1094
|
+
const event = await RoutesTransferEvents.insert(tx, {
|
|
1095
|
+
createdAt: updated.updatedAt,
|
|
1096
|
+
snapshot: toPublic(updated),
|
|
1097
|
+
status: updated.status,
|
|
1098
|
+
transferId: updated.id,
|
|
1099
|
+
version: updated.version,
|
|
1100
|
+
})
|
|
1101
|
+
const { references } = await TransferWebhook.stage(tx, {
|
|
1102
|
+
changes: [{ event, record: updated }],
|
|
1103
|
+
})
|
|
1104
|
+
return { record: updated, references, type: 'applied' }
|
|
1105
|
+
}
|
|
1106
|
+
|
|
1107
|
+
export declare namespace transition {
|
|
1108
|
+
/** Fields describing a material change to apply. */
|
|
1109
|
+
type Options = {
|
|
1110
|
+
/** The version the change was computed against. */
|
|
1111
|
+
expectedVersion: number
|
|
1112
|
+
/** Transfer id (`rtr_…`). */
|
|
1113
|
+
id: string
|
|
1114
|
+
/** Replacement private provider state; omitted keeps the stored value. */
|
|
1115
|
+
providerState?: ProviderState | null | undefined
|
|
1116
|
+
/** Replacement public snapshot; omitted keeps the stored snapshot. */
|
|
1117
|
+
snapshot?: Snapshot | undefined
|
|
1118
|
+
/** New status; omitted keeps the current status (snapshot-only change). */
|
|
1119
|
+
status?: Status | undefined
|
|
1120
|
+
/** Customer-safe reason attached to the new status. */
|
|
1121
|
+
statusReason?: StatusReason | undefined
|
|
1122
|
+
/** Destination subsidy signer; omitted keeps the stored value. */
|
|
1123
|
+
subsidyAccount?: RoutesTransfers.Record['subsidyAccount'] | undefined
|
|
1124
|
+
/** Tempo-funded destination amount; omitted keeps the stored value. */
|
|
1125
|
+
subsidyAmount?: RoutesTransfers.Record['subsidyAmount'] | undefined
|
|
1126
|
+
/** Destination subsidy chain; omitted keeps the stored value. */
|
|
1127
|
+
subsidyChainId?: RoutesTransfers.Record['subsidyChainId'] | undefined
|
|
1128
|
+
/** Creation-time subsidy commitment; omitted keeps the stored value. */
|
|
1129
|
+
subsidyCommitmentAmount?: RoutesTransfers.Record['subsidyCommitmentAmount'] | undefined
|
|
1130
|
+
/** Native gas reservation; omitted keeps the stored value. */
|
|
1131
|
+
subsidyNativeAmount?: RoutesTransfers.Record['subsidyNativeAmount'] | undefined
|
|
1132
|
+
/** Destination subsidy token; omitted keeps the stored value. */
|
|
1133
|
+
subsidyTokenAddress?: RoutesTransfers.Record['subsidyTokenAddress'] | undefined
|
|
1134
|
+
/** Destination subsidy transaction hash; omitted keeps the stored value. */
|
|
1135
|
+
subsidyTransactionHash?: RoutesTransfers.Record['subsidyTransactionHash'] | undefined
|
|
1136
|
+
}
|
|
1137
|
+
|
|
1138
|
+
/** Outcome of a guarded transition. */
|
|
1139
|
+
type Result =
|
|
1140
|
+
| (Staged & { type: 'applied' })
|
|
1141
|
+
| { current: RoutesTransfers.Record; type: 'invalid' }
|
|
1142
|
+
| { current: RoutesTransfers.Record; type: 'stale' }
|
|
1143
|
+
| { type: 'not_found' }
|
|
1144
|
+
}
|
|
1145
|
+
|
|
1146
|
+
/** Serializes a created row with its one-time executable action. */
|
|
1147
|
+
export function toCreated(record: RoutesTransfers.Record, action: Action.Action): Created {
|
|
1148
|
+
return schema.CreatedRoutesTransfer.parse({ action, ...toPublic(record) })
|
|
1149
|
+
}
|
|
1150
|
+
|
|
1151
|
+
/** Serializes a stored row to the public read shape. Never includes actions. */
|
|
1152
|
+
export function toPublic(record: RoutesTransfers.Record): Public {
|
|
1153
|
+
return schema.RoutesTransfer.parse({
|
|
1154
|
+
...record.snapshot,
|
|
1155
|
+
createdAt: record.createdAt,
|
|
1156
|
+
id: record.id,
|
|
1157
|
+
status: record.status,
|
|
1158
|
+
...(record.statusReason === null ? {} : { statusReason: record.statusReason }),
|
|
1159
|
+
updatedAt: record.updatedAt,
|
|
1160
|
+
version: record.version,
|
|
1161
|
+
})
|
|
1162
|
+
}
|
|
1163
|
+
|
|
1164
|
+
function parseSnapshot(snapshot: Snapshot): Snapshot {
|
|
1165
|
+
const parsed = schema.Snapshot.parse(snapshot)
|
|
1166
|
+
return {
|
|
1167
|
+
...parsed,
|
|
1168
|
+
quote: {
|
|
1169
|
+
...parsed.quote,
|
|
1170
|
+
expiresAt: new Date(parsed.quote.expiresAt).toISOString(),
|
|
1171
|
+
},
|
|
1172
|
+
}
|
|
1173
|
+
}
|
|
1174
|
+
|
|
1175
|
+
/** Actual settlement exceeded the creation-time subsidy commitment. */
|
|
1176
|
+
export class SubsidyCommitmentExceededError extends Error {
|
|
1177
|
+
override name = 'Routes.Transfer.SubsidyCommitmentExceededError'
|
|
1178
|
+
}
|
|
1179
|
+
|
|
1180
|
+
/** Source evidence is absent or conflicts with an existing subsidy settlement. */
|
|
1181
|
+
export class SubsidyEvidenceError extends Error {
|
|
1182
|
+
override name = 'Routes.Transfer.SubsidyEvidenceError'
|
|
1183
|
+
}
|
|
1184
|
+
|
|
1185
|
+
/** The configured subsidy signer cannot accept another commitment. */
|
|
1186
|
+
export class SubsidySignerBlockedError extends Error {
|
|
1187
|
+
override name = 'Routes.Transfer.SubsidySignerBlockedError'
|
|
1188
|
+
}
|
|
1189
|
+
|
|
1190
|
+
/** The commitment owner disappeared before its locked persistence boundary. */
|
|
1191
|
+
export class OrganizationNotFoundError extends Error {
|
|
1192
|
+
override name = 'Routes.Transfer.OrganizationNotFoundError'
|
|
1193
|
+
}
|
|
1194
|
+
|
|
1195
|
+
/** The provider quote expired while waiting to reserve subsidy inventory. */
|
|
1196
|
+
export class QuoteExpiredError extends Error {
|
|
1197
|
+
override name = 'Routes.Transfer.QuoteExpiredError'
|
|
1198
|
+
}
|
|
1199
|
+
|
|
1200
|
+
class AtomicTransitionError extends Error {
|
|
1201
|
+
override name = 'Routes.Transfer.AtomicTransitionError'
|
|
1202
|
+
}
|
|
1203
|
+
|
|
1204
|
+
class SourceTransactionConflictError extends Error {
|
|
1205
|
+
override name = 'Routes.Transfer.SourceTransactionConflictError'
|
|
1206
|
+
}
|