tapimo 0.14.0 → 0.15.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +7 -4
- package/dist/ApiKey.js +1 -1
- package/dist/ApiKey.js.map +1 -1
- package/dist/ApiKeys.d.ts +95 -14
- package/dist/ApiKeys.d.ts.map +1 -1
- package/dist/ApiKeys.js +360 -49
- package/dist/ApiKeys.js.map +1 -1
- package/dist/App.d.ts +12457 -10365
- 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 -549
- package/dist/admin/App.d.ts.map +1 -1
- package/dist/admin/App.js +26 -5
- package/dist/admin/App.js.map +1 -1
- package/dist/admin/apps/api-keys.d.ts +159 -7
- package/dist/admin/apps/api-keys.d.ts.map +1 -1
- package/dist/admin/apps/api-keys.js +95 -43
- package/dist/admin/apps/api-keys.js.map +1 -1
- package/dist/admin/apps/earn-vaults.d.ts +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 +88 -88
- package/dist/admin/apps/verified-tokens.d.ts.map +1 -1
- package/dist/admin/apps/verified-tokens.js +3 -3
- package/dist/admin/apps/verified-tokens.js.map +1 -1
- package/dist/admin/ui.generated.d.ts +1 -1
- package/dist/admin/ui.generated.d.ts.map +1 -1
- package/dist/admin/ui.generated.js +129 -69
- package/dist/admin/ui.generated.js.map +1 -1
- package/dist/analytics/Analytics.d.ts +5 -2
- package/dist/analytics/Analytics.d.ts.map +1 -1
- package/dist/analytics/Analytics.js +31 -1
- package/dist/analytics/Analytics.js.map +1 -1
- package/dist/analytics/tables/requestEvents.d.ts +2 -1
- package/dist/analytics/tables/requestEvents.d.ts.map +1 -1
- package/dist/analytics/tables/requestEvents.js +10 -1
- package/dist/analytics/tables/requestEvents.js.map +1 -1
- package/dist/analytics/tables/routesLifecycleIntervals.d.ts +72 -0
- package/dist/analytics/tables/routesLifecycleIntervals.d.ts.map +1 -0
- package/dist/analytics/tables/routesLifecycleIntervals.js +56 -0
- package/dist/analytics/tables/routesLifecycleIntervals.js.map +1 -0
- package/dist/apps/Zones.d.ts +21 -12526
- package/dist/apps/Zones.d.ts.map +1 -1
- package/dist/apps/Zones.js +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 +364 -34
- package/dist/apps/data/routes/activities.d.ts.map +1 -1
- package/dist/apps/data/routes/activities.js +495 -190
- package/dist/apps/data/routes/activities.js.map +1 -1
- package/dist/apps/data/routes/addresses.d.ts +72 -0
- package/dist/apps/data/routes/addresses.d.ts.map +1 -1
- package/dist/apps/data/routes/blocks.d.ts +37 -37
- package/dist/apps/data/routes/coingecko.d.ts.map +1 -1
- package/dist/apps/data/routes/coingecko.js +47 -21
- package/dist/apps/data/routes/coingecko.js.map +1 -1
- package/dist/apps/data/routes/earn.d.ts +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 +5 -0
- package/dist/apps/data/routes/fee-amm.d.ts.map +1 -1
- package/dist/apps/data/routes/fee-amm.js +31 -19
- package/dist/apps/data/routes/fee-amm.js.map +1 -1
- package/dist/apps/data/routes/indexer.d.ts +125 -0
- package/dist/apps/data/routes/indexer.d.ts.map +1 -1
- package/dist/apps/data/routes/indexer.js +83 -27
- package/dist/apps/data/routes/indexer.js.map +1 -1
- package/dist/apps/data/routes/rpc.d.ts +507 -33
- package/dist/apps/data/routes/rpc.d.ts.map +1 -1
- package/dist/apps/data/routes/rpc.js +266 -156
- package/dist/apps/data/routes/rpc.js.map +1 -1
- package/dist/apps/data/routes/tokenlist.d.ts +47 -15
- package/dist/apps/data/routes/tokenlist.d.ts.map +1 -1
- package/dist/apps/data/routes/tokenlist.js +68 -11
- package/dist/apps/data/routes/tokenlist.js.map +1 -1
- package/dist/apps/data/routes/tokens.d.ts +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 +28 -12
- 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 +30 -30
- package/dist/apps/data/routes/verified-tokens.d.ts +9 -9
- 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 +613 -176
- package/dist/apps/data/routes/webhooks.d.ts.map +1 -1
- package/dist/apps/data/routes/webhooks.js +291 -195
- package/dist/apps/data/routes/webhooks.js.map +1 -1
- package/dist/apps/data/routes/zones.d.ts.map +1 -1
- package/dist/apps/data/routes/zones.js +20 -12
- package/dist/apps/data/routes/zones.js.map +1 -1
- package/dist/apps/docs/reference.js +2 -2
- package/dist/apps/docs/reference.js.map +1 -1
- package/dist/apps/index.d.ts +1 -1
- package/dist/apps/index.d.ts.map +1 -1
- package/dist/apps/index.js +1 -1
- package/dist/apps/index.js.map +1 -1
- package/dist/apps/management/App.d.ts +3763 -3385
- 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 +106 -4
- 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 +77 -2
- 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 +4 -4
- 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 +18 -2
- 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 +4 -4
- 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 +2 -2
- package/dist/apps/management/routes/webhooks.d.ts +280 -214
- 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.js +7 -7
- package/dist/apps/mcp.js.map +1 -1
- package/dist/apps/mpp/App.d.ts.map +1 -1
- package/dist/apps/mpp/App.js +35 -7
- package/dist/apps/mpp/App.js.map +1 -1
- package/dist/apps/mpp/internal/Adapter.d.ts +2 -0
- package/dist/apps/mpp/internal/Adapter.d.ts.map +1 -1
- package/dist/apps/mpp/internal/Adapter.js +30 -1
- package/dist/apps/mpp/internal/Adapter.js.map +1 -1
- package/dist/apps/mpp/internal/Policy.d.ts +22 -4
- package/dist/apps/mpp/internal/Policy.d.ts.map +1 -1
- package/dist/apps/mpp/internal/Policy.js +24 -6
- package/dist/apps/mpp/internal/Policy.js.map +1 -1
- package/dist/apps/mpp/internal/Sponsorship.d.ts +3 -0
- package/dist/apps/mpp/internal/Sponsorship.d.ts.map +1 -1
- package/dist/apps/mpp/internal/Sponsorship.js +6 -3
- package/dist/apps/mpp/internal/Sponsorship.js.map +1 -1
- package/dist/apps/relay/App.d.ts +2 -0
- package/dist/apps/relay/App.d.ts.map +1 -1
- package/dist/apps/relay/App.js +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 +7 -7
- package/dist/apps/routes/routes/chains.d.ts.map +1 -0
- package/dist/apps/{funding → routes}/routes/chains.js +25 -25
- package/dist/apps/routes/routes/chains.js.map +1 -0
- package/dist/apps/{funding → routes}/routes/deposit-addresses.d.ts +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 +19 -16
- package/dist/apps/routes/routes/quotes.d.ts.map +1 -0
- package/dist/apps/{funding → routes}/routes/quotes.js +55 -38
- package/dist/apps/routes/routes/quotes.js.map +1 -0
- package/dist/apps/{funding → routes}/routes/transfers.d.ts +379 -74
- 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 +1030 -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/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 +48 -12
- package/dist/internal/Auth.d.ts.map +1 -1
- package/dist/internal/Auth.js +603 -175
- package/dist/internal/Auth.js.map +1 -1
- package/dist/internal/BetterAuth.d.ts +1488 -0
- package/dist/internal/BetterAuth.d.ts.map +1 -0
- package/dist/internal/BetterAuth.js +253 -0
- package/dist/internal/BetterAuth.js.map +1 -0
- package/dist/internal/Cache.d.ts +2 -0
- package/dist/internal/Cache.d.ts.map +1 -1
- package/dist/internal/Cache.js +2 -0
- package/dist/internal/Cache.js.map +1 -1
- package/dist/internal/EarnRates.d.ts +26 -3
- package/dist/internal/EarnRates.d.ts.map +1 -1
- package/dist/internal/EarnRates.js +84 -19
- package/dist/internal/EarnRates.js.map +1 -1
- package/dist/internal/EarnSharePrices.d.ts +120 -0
- package/dist/internal/EarnSharePrices.d.ts.map +1 -0
- package/dist/internal/EarnSharePrices.js +179 -0
- package/dist/internal/EarnSharePrices.js.map +1 -0
- package/dist/internal/EarnVaults.d.ts +4 -0
- package/dist/internal/EarnVaults.d.ts.map +1 -1
- package/dist/internal/EarnVaults.js +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 +8 -3
- package/src/admin/apps/verified-tokens.ts +3 -3
- package/src/admin/ui/plugin.ts +1 -2
- package/src/admin/ui/src/components/RewardCampaignForm.tsx +1009 -0
- package/src/admin/ui/src/lib/config.ts +11 -2
- package/src/admin/ui/src/lib/earn-vaults.ts +2 -2
- package/src/admin/ui/src/lib/organizations.test.ts +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/routeTree.gen.ts +63 -0
- package/src/admin/ui/src/routes/__root.tsx +12 -1
- package/src/admin/ui/src/routes/api-keys.tsx +196 -84
- package/src/admin/ui/src/routes/earn.vaults_.$vaultId.edit.tsx +105 -70
- package/src/admin/ui/src/routes/organizations_.$orgId.tsx +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.generated.ts +144 -69
- package/src/analytics/Analytics.test.ts +108 -18
- package/src/analytics/Analytics.ts +38 -6
- package/src/analytics/tables/requestEvents.test.ts +100 -0
- package/src/analytics/tables/requestEvents.ts +10 -1
- package/src/analytics/tables/routesLifecycleIntervals.ts +140 -0
- package/src/apps/Zones.test.ts +15 -0
- package/src/apps/Zones.ts +52 -5
- package/src/apps/composition.test.ts +68 -60
- package/src/apps/data/App.test.ts +154 -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 +224 -0
- package/src/apps/data/routes/fee-amm.ts +191 -160
- package/src/apps/data/routes/indexer.test.ts +389 -0
- package/src/apps/data/routes/indexer.ts +165 -69
- package/src/apps/data/routes/receipts.test.ts +1 -1
- package/src/apps/data/routes/rpc.test.ts +352 -8
- package/src/apps/data/routes/rpc.ts +407 -219
- package/src/apps/data/routes/rpc.zone.test.ts +340 -0
- package/src/apps/data/routes/tokenlist.test.ts +285 -0
- package/src/apps/data/routes/tokenlist.ts +173 -88
- package/src/apps/data/routes/tokens.test.ts +93 -3
- package/src/apps/data/routes/tokens.ts +39 -23
- package/src/apps/data/routes/transactions.test.ts +1 -1
- package/src/apps/data/routes/transfers.test.ts +56 -24
- package/src/apps/data/routes/transfers.ts +19 -8
- package/src/apps/data/routes/valuation.test.ts +1 -1
- package/src/apps/data/routes/verified-tokens.test.ts +345 -0
- package/src/apps/data/routes/verified-tokens.ts +99 -29
- package/src/apps/data/routes/webhooks.test.ts +645 -83
- package/src/apps/data/routes/webhooks.ts +1089 -857
- 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/webhooks.test.ts +49 -26
- package/src/apps/management/routes/webhooks.ts +78 -22
- package/src/apps/mcp.test.ts +6 -6
- package/src/apps/mcp.ts +7 -7
- package/src/apps/mpp/App.ts +37 -7
- package/src/apps/mpp/Mpp.test.ts +49 -8
- package/src/apps/mpp/Mpp.zone.test.ts +219 -0
- package/src/apps/mpp/internal/Adapter.ts +34 -0
- package/src/apps/mpp/internal/Policy.test.ts +86 -31
- package/src/apps/mpp/internal/Policy.ts +49 -7
- package/src/apps/mpp/internal/Sponsorship.test.ts +207 -0
- package/src/apps/mpp/internal/Sponsorship.ts +9 -3
- package/src/apps/relay/App.test.ts +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 +1476 -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} +316 -46
- package/src/db/tables/routesDeposits.ts +1062 -0
- package/src/db/tables/routesIdempotency.test.ts +796 -0
- package/src/db/tables/routesIdempotency.ts +496 -0
- package/src/db/tables/routesSubsidies.test.ts +120 -0
- package/src/db/tables/routesSubsidies.ts +71 -0
- package/src/db/tables/{fundingTransferEvents.ts → routesTransferEvents.ts} +4 -4
- package/src/db/tables/routesTransferSubsidies.ts +38 -0
- package/src/db/tables/routesTransferSubsidyNonces.ts +124 -0
- package/src/db/tables/routesTransferTransactions.test.ts +195 -0
- package/src/db/tables/{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/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 +1564 -9
- package/src/internal/Auth.ts +833 -239
- package/src/internal/BetterAuth.test.ts +242 -0
- package/src/internal/BetterAuth.ts +349 -0
- package/src/internal/Cache.ts +2 -0
- package/src/internal/EarnRates.test.ts +17 -0
- package/src/internal/EarnRates.ts +124 -31
- package/src/internal/EarnSharePrices.test.ts +182 -0
- package/src/internal/EarnSharePrices.ts +313 -0
- package/src/internal/EarnVaults.test.ts +21 -0
- package/src/internal/EarnVaults.ts +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 +165 -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,1062 @@
|
|
|
1
|
+
import { sql, type JSONColumnType, type Selectable } from 'kysely'
|
|
2
|
+
|
|
3
|
+
import * as Fees from '../../internal/Fees.js'
|
|
4
|
+
import type * as Db from '../Db.js'
|
|
5
|
+
import type * as db_Schema from '../Schema.js'
|
|
6
|
+
import * as RoutesSubsidies from './routesSubsidies.js'
|
|
7
|
+
|
|
8
|
+
/** Columns of the `routes_deposits` table. */
|
|
9
|
+
export type Table = Omit<
|
|
10
|
+
db_Schema.RoutesDeposit,
|
|
11
|
+
'providerRequestIds' | 'providerTransactionHashes'
|
|
12
|
+
> & {
|
|
13
|
+
/** Private provider request identifiers stored as JSON. */
|
|
14
|
+
providerRequestIds: JSONColumnType<readonly string[], string, string>
|
|
15
|
+
/** Private provider transaction references stored as JSON. */
|
|
16
|
+
providerTransactionHashes: JSONColumnType<readonly string[], string, string>
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/** A stored route deposit. */
|
|
20
|
+
export type Record = Selectable<Table>
|
|
21
|
+
|
|
22
|
+
/** Ownership filter inherited from the deposit address. */
|
|
23
|
+
export type Owner = {
|
|
24
|
+
/** Key environment. */
|
|
25
|
+
environment: Record['environment']
|
|
26
|
+
/** Owning organization id (`org_…`). */
|
|
27
|
+
orgId: string
|
|
28
|
+
/** Attributed project id for project-scoped API keys. */
|
|
29
|
+
projectId?: string | undefined
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/** Optional filters shared by route deposit list and count queries. */
|
|
33
|
+
export type Filters = {
|
|
34
|
+
/** Reusable source-chain address that received the funds. */
|
|
35
|
+
depositAddress?: string | undefined
|
|
36
|
+
/** Canonical destination token keys accepted by the filter. */
|
|
37
|
+
destinationTokenKeys?: readonly string[] | undefined
|
|
38
|
+
/** Route provider id. */
|
|
39
|
+
providerId?: string | undefined
|
|
40
|
+
/** Tempo account that receives completed deposits. */
|
|
41
|
+
recipient?: string | undefined
|
|
42
|
+
/** Canonical source chain ids accepted by the filter. */
|
|
43
|
+
sourceChainIds?: readonly string[] | undefined
|
|
44
|
+
/** Canonical source token keys accepted by the filter. */
|
|
45
|
+
sourceTokenKeys?: readonly string[] | undefined
|
|
46
|
+
/** Deposit lifecycle status. */
|
|
47
|
+
status?: Record['status'] | undefined
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/** Aggregates active deposit states for bounded operational metrics. */
|
|
51
|
+
export function summarizeStates(db: Db.Db, options: summarizeStates.Options) {
|
|
52
|
+
const reason = sql<string | null>`routes_deposits.status_reason->>'code'`
|
|
53
|
+
return db.kysely
|
|
54
|
+
.selectFrom('routes_deposits')
|
|
55
|
+
.innerJoin(
|
|
56
|
+
'routes_deposit_addresses',
|
|
57
|
+
'routes_deposit_addresses.id',
|
|
58
|
+
'routes_deposits.depositAddressId',
|
|
59
|
+
)
|
|
60
|
+
.select(({ fn }) => [
|
|
61
|
+
'routes_deposits.environment',
|
|
62
|
+
'routes_deposit_addresses.providerId',
|
|
63
|
+
'routes_deposits.status',
|
|
64
|
+
fn.countAll<string>().as('count'),
|
|
65
|
+
sql<string>`min(coalesce(routes_deposits.status_updated_at, routes_deposits.updated_at))`.as(
|
|
66
|
+
'oldestStatusUpdatedAt',
|
|
67
|
+
),
|
|
68
|
+
reason.as('reason'),
|
|
69
|
+
])
|
|
70
|
+
.where('routes_deposits.status', 'in', options.statuses)
|
|
71
|
+
.groupBy([
|
|
72
|
+
'routes_deposits.environment',
|
|
73
|
+
'routes_deposit_addresses.providerId',
|
|
74
|
+
'routes_deposits.status',
|
|
75
|
+
])
|
|
76
|
+
.groupBy(reason)
|
|
77
|
+
.execute()
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
export declare namespace summarizeStates {
|
|
81
|
+
/** Active-state aggregation options. */
|
|
82
|
+
type Options = {
|
|
83
|
+
/** Lifecycle statuses still owned by platform processing or recovery. */
|
|
84
|
+
statuses: readonly Record['status'][]
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/** Inserts one provider-observed source transfer as a route deposit. */
|
|
89
|
+
export function insert(db: Db.Db, record: Record): Promise<Record> {
|
|
90
|
+
return db.kysely
|
|
91
|
+
.insertInto('routes_deposits')
|
|
92
|
+
.values({
|
|
93
|
+
...record,
|
|
94
|
+
providerRequestIds: JSON.stringify(record.providerRequestIds),
|
|
95
|
+
providerTransactionHashes: JSON.stringify(record.providerTransactionHashes),
|
|
96
|
+
})
|
|
97
|
+
.returningAll()
|
|
98
|
+
.executeTakeFirstOrThrow()
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
/** Inserts a chain-observed source transfer or returns its existing deposit. */
|
|
102
|
+
export async function insertOrGetSource(
|
|
103
|
+
db: Db.Db,
|
|
104
|
+
record: Record & { sourceTransferIndex: number },
|
|
105
|
+
): Promise<insertOrGetSource.Result> {
|
|
106
|
+
const inserted = await db.kysely
|
|
107
|
+
.insertInto('routes_deposits')
|
|
108
|
+
.values({
|
|
109
|
+
...record,
|
|
110
|
+
providerRequestIds: JSON.stringify(record.providerRequestIds),
|
|
111
|
+
providerTransactionHashes: JSON.stringify(record.providerTransactionHashes),
|
|
112
|
+
})
|
|
113
|
+
.onConflict((oc) =>
|
|
114
|
+
oc.columns(['depositAddressId', 'sourceTransactionHash', 'sourceTransferIndex']).doNothing(),
|
|
115
|
+
)
|
|
116
|
+
.returningAll()
|
|
117
|
+
.executeTakeFirst()
|
|
118
|
+
if (inserted) return { record: inserted, type: 'created' }
|
|
119
|
+
const existing = await db.kysely
|
|
120
|
+
.selectFrom('routes_deposits')
|
|
121
|
+
.selectAll()
|
|
122
|
+
.where('depositAddressId', '=', record.depositAddressId)
|
|
123
|
+
.where('sourceTransactionHash', '=', record.sourceTransactionHash)
|
|
124
|
+
.where('sourceTransferIndex', '=', record.sourceTransferIndex)
|
|
125
|
+
.executeTakeFirstOrThrow()
|
|
126
|
+
return { record: existing, type: 'existing' }
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
export declare namespace insertOrGetSource {
|
|
130
|
+
/** Result of idempotently persisting one verified source transfer. */
|
|
131
|
+
type Result = { record: Record; type: 'created' | 'existing' }
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
/** Serializes source attribution for one address and transaction. */
|
|
135
|
+
export function withSourceTransaction<const result>(
|
|
136
|
+
db: Db.Db,
|
|
137
|
+
options: withSourceTransaction.Options<result>,
|
|
138
|
+
): Promise<result> {
|
|
139
|
+
return db.transaction(async (tx) => {
|
|
140
|
+
const key = `${options.depositAddressId}:${options.sourceTransactionHash.toLowerCase()}`
|
|
141
|
+
await sql`SELECT pg_advisory_xact_lock(hashtextextended(${key}, 0))`.execute(tx.kysely)
|
|
142
|
+
return options.fn(tx)
|
|
143
|
+
})
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
export declare namespace withSourceTransaction {
|
|
147
|
+
/** Source identity and transaction-scoped work protected by its advisory lock. */
|
|
148
|
+
type Options<result> = {
|
|
149
|
+
/** Route deposit address that received the transfer. */
|
|
150
|
+
depositAddressId: string
|
|
151
|
+
/** Database work serialized for the source transaction. */
|
|
152
|
+
fn: (db: Db.Db) => Promise<result>
|
|
153
|
+
/** Source transaction whose deposit attribution must not race. */
|
|
154
|
+
sourceTransactionHash: string
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
/** Serializes subsidy preparation and persistence with organization deletion. */
|
|
159
|
+
export function withSubsidySettlement<const result>(
|
|
160
|
+
db: Db.Db,
|
|
161
|
+
options: withSubsidySettlement.Options<result>,
|
|
162
|
+
): Promise<result> {
|
|
163
|
+
return db.transaction(async (tx) => {
|
|
164
|
+
await RoutesSubsidies.lockOrganization(tx, options.orgId)
|
|
165
|
+
return options.fn(tx)
|
|
166
|
+
})
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
export declare namespace withSubsidySettlement {
|
|
170
|
+
/** Organization and transaction-scoped work protected by its subsidy lock. */
|
|
171
|
+
type Options<result> = {
|
|
172
|
+
/** Database work serialized with organization deletion. */
|
|
173
|
+
fn: (db: Db.Db) => Promise<result>
|
|
174
|
+
/** Organization whose subsidy liability may change. */
|
|
175
|
+
orgId: string
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
/** Gets deposits created from one provider-observed source transaction. */
|
|
180
|
+
export function listByProviderObservation(
|
|
181
|
+
db: Db.Db,
|
|
182
|
+
options: listByProviderObservation.Options,
|
|
183
|
+
): Promise<Record[]> {
|
|
184
|
+
return db.kysely
|
|
185
|
+
.selectFrom('routes_deposits')
|
|
186
|
+
.selectAll()
|
|
187
|
+
.where('depositAddressId', '=', options.depositAddressId)
|
|
188
|
+
.where('providerRequestId', '=', options.providerRequestId)
|
|
189
|
+
.where('sourceTransactionHash', '=', options.sourceTransactionHash)
|
|
190
|
+
.orderBy('providerTransferIndex', 'asc')
|
|
191
|
+
.execute()
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
export declare namespace listByProviderObservation {
|
|
195
|
+
/** Provider observation fields that identify one source transaction. */
|
|
196
|
+
type Options = {
|
|
197
|
+
/** Route deposit address that received the transfer. */
|
|
198
|
+
depositAddressId: string
|
|
199
|
+
/** Provider request that reported the transfer. */
|
|
200
|
+
providerRequestId: string
|
|
201
|
+
/** Provider-observed source transaction reference. */
|
|
202
|
+
sourceTransactionHash: string
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
/** Attaches first-observation timestamps to every deposit from one provider request. */
|
|
207
|
+
export function recordRequestObservation(
|
|
208
|
+
db: Db.Db,
|
|
209
|
+
options: recordRequestObservation.Options,
|
|
210
|
+
): Promise<Record[]> {
|
|
211
|
+
return db.kysely
|
|
212
|
+
.updateTable('routes_deposits')
|
|
213
|
+
.set({
|
|
214
|
+
...(options.pollObservedAt
|
|
215
|
+
? {
|
|
216
|
+
pollObservedAt: sql<string>`LEAST(COALESCE(poll_observed_at, ${options.pollObservedAt}), ${options.pollObservedAt})`,
|
|
217
|
+
}
|
|
218
|
+
: {}),
|
|
219
|
+
...(options.webhookReceivedAt
|
|
220
|
+
? {
|
|
221
|
+
webhookReceivedAt: sql<string>`LEAST(COALESCE(webhook_received_at, ${options.webhookReceivedAt}), ${options.webhookReceivedAt})`,
|
|
222
|
+
}
|
|
223
|
+
: {}),
|
|
224
|
+
})
|
|
225
|
+
.where('depositAddressId', '=', options.depositAddressId)
|
|
226
|
+
.where('providerRequestId', '=', options.providerRequestId)
|
|
227
|
+
.returningAll()
|
|
228
|
+
.execute()
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
export declare namespace recordRequestObservation {
|
|
232
|
+
/** First observations associated with one provider request. */
|
|
233
|
+
type Options = {
|
|
234
|
+
/** Route deposit address id (`rda_…`). */
|
|
235
|
+
depositAddressId: string
|
|
236
|
+
/** When polling first observed the provider request. */
|
|
237
|
+
pollObservedAt?: string | undefined
|
|
238
|
+
/** Provider request identifier. */
|
|
239
|
+
providerRequestId: string
|
|
240
|
+
/** When Tempo first received an authenticated provider webhook. */
|
|
241
|
+
webhookReceivedAt?: string | undefined
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
/** Gets deposits associated with one address and source transaction. */
|
|
246
|
+
export function listBySourceTransaction(
|
|
247
|
+
db: Db.Db,
|
|
248
|
+
options: listBySourceTransaction.Options,
|
|
249
|
+
): Promise<Record[]> {
|
|
250
|
+
return db.kysely
|
|
251
|
+
.selectFrom('routes_deposits')
|
|
252
|
+
.selectAll()
|
|
253
|
+
.where('depositAddressId', '=', options.depositAddressId)
|
|
254
|
+
.where('sourceTransactionHash', '=', options.sourceTransactionHash)
|
|
255
|
+
.orderBy('sourceTransferIndex', 'asc')
|
|
256
|
+
.execute()
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
export declare namespace listBySourceTransaction {
|
|
260
|
+
/** Source transaction fields scoped to one deposit address. */
|
|
261
|
+
type Options = {
|
|
262
|
+
/** Route deposit address that received the transfer. */
|
|
263
|
+
depositAddressId: string
|
|
264
|
+
/** Provider-observed source transaction reference. */
|
|
265
|
+
sourceTransactionHash: string
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
/** Lists a bounded page of source transfers awaiting provider attribution. */
|
|
270
|
+
export function listUnattributed(db: Db.Db, options: listUnattributed.Options): Promise<Record[]> {
|
|
271
|
+
let query = db.kysely
|
|
272
|
+
.selectFrom('routes_deposits')
|
|
273
|
+
.selectAll()
|
|
274
|
+
.where('depositAddressId', '=', options.depositAddressId)
|
|
275
|
+
.where('providerRequestId', 'is', null)
|
|
276
|
+
.where('createdAt', '<=', options.before)
|
|
277
|
+
if (options.cursor)
|
|
278
|
+
query = query.where(
|
|
279
|
+
sql<boolean>`(created_at, id) > (${options.cursor.createdAt}, ${options.cursor.id})`,
|
|
280
|
+
)
|
|
281
|
+
return query.orderBy('createdAt', 'asc').orderBy('id', 'asc').limit(options.limit).execute()
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
export declare namespace listUnattributed {
|
|
285
|
+
/** Fixed sweep boundary and page position for one address. */
|
|
286
|
+
type Options = {
|
|
287
|
+
/** Inclusive creation-time boundary retained until the sweep finishes. */
|
|
288
|
+
before: string
|
|
289
|
+
/** Last deposit attempted in this sweep. */
|
|
290
|
+
cursor?: listByAddress.Cursor | undefined
|
|
291
|
+
/** Route deposit address whose transfers are reconciled. */
|
|
292
|
+
depositAddressId: string
|
|
293
|
+
/** Maximum deposits returned. */
|
|
294
|
+
limit: number
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
/** Returns whether an address has a source transfer awaiting provider attribution. */
|
|
299
|
+
export async function hasUnattributed(db: Db.Db, depositAddressId: string): Promise<boolean> {
|
|
300
|
+
return Boolean(
|
|
301
|
+
await db.kysely
|
|
302
|
+
.selectFrom('routes_deposits')
|
|
303
|
+
.select('id')
|
|
304
|
+
.where('depositAddressId', '=', depositAddressId)
|
|
305
|
+
.where('providerRequestId', 'is', null)
|
|
306
|
+
.limit(1)
|
|
307
|
+
.executeTakeFirst(),
|
|
308
|
+
)
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
/** Gets a route deposit without ownership scoping. */
|
|
312
|
+
export function get(db: Db.Db, id: string): Promise<Record | undefined> {
|
|
313
|
+
return db.kysely.selectFrom('routes_deposits').selectAll().where('id', '=', id).executeTakeFirst()
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
/** Gets the earliest source transfer detected for one reusable address. */
|
|
317
|
+
export function getFirstByAddress(db: Db.Db, addressId: string): Promise<Record | undefined> {
|
|
318
|
+
return db.kysely
|
|
319
|
+
.selectFrom('routes_deposits')
|
|
320
|
+
.selectAll()
|
|
321
|
+
.where('depositAddressId', '=', addressId)
|
|
322
|
+
.orderBy('createdAt', 'asc')
|
|
323
|
+
.orderBy('id', 'asc')
|
|
324
|
+
.limit(1)
|
|
325
|
+
.executeTakeFirst()
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
/** Gets an owner-visible route deposit. */
|
|
329
|
+
export function getOwned(db: Db.Db, owner: Owner, id: string): Promise<Record | undefined> {
|
|
330
|
+
let query = db.kysely
|
|
331
|
+
.selectFrom('routes_deposits')
|
|
332
|
+
.selectAll()
|
|
333
|
+
.where('environment', '=', owner.environment)
|
|
334
|
+
.where('id', '=', id)
|
|
335
|
+
.where('orgId', '=', owner.orgId)
|
|
336
|
+
if (owner.projectId !== undefined) query = query.where('projectId', '=', owner.projectId)
|
|
337
|
+
return query.executeTakeFirst()
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
/** Lists owner-visible route deposits newest-first. */
|
|
341
|
+
export function listByOwner(db: Db.Db, options: listByOwner.Options): Promise<Record[]> {
|
|
342
|
+
const { cursor, limit } = options
|
|
343
|
+
let builder = query(db, options).selectAll('routes_deposits')
|
|
344
|
+
if (cursor)
|
|
345
|
+
builder = builder.where((eb) =>
|
|
346
|
+
eb.or([
|
|
347
|
+
eb('routes_deposits.createdAt', '<', cursor.createdAt),
|
|
348
|
+
eb.and([
|
|
349
|
+
eb('routes_deposits.createdAt', '=', cursor.createdAt),
|
|
350
|
+
eb('routes_deposits.id', '<', cursor.id),
|
|
351
|
+
]),
|
|
352
|
+
]),
|
|
353
|
+
)
|
|
354
|
+
return builder
|
|
355
|
+
.orderBy('routes_deposits.createdAt', 'desc')
|
|
356
|
+
.orderBy('routes_deposits.id', 'desc')
|
|
357
|
+
.limit(limit)
|
|
358
|
+
.execute()
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
export declare namespace listByOwner {
|
|
362
|
+
/** Ownership and paging options for route deposits. */
|
|
363
|
+
type Options = Filters & {
|
|
364
|
+
/** Exclusive lower bound from the previous page. */
|
|
365
|
+
cursor?: listByAddress.Cursor | undefined
|
|
366
|
+
/** Maximum rows to return. */
|
|
367
|
+
limit: number
|
|
368
|
+
/** Ownership filter derived from the authenticated API key. */
|
|
369
|
+
owner: Owner
|
|
370
|
+
}
|
|
371
|
+
}
|
|
372
|
+
|
|
373
|
+
/** Lists filtered route deposits, newest update first. */
|
|
374
|
+
export function list(db: Db.Db, options: list.Options): Promise<Record[]> {
|
|
375
|
+
let query = db.kysely
|
|
376
|
+
.selectFrom('routes_deposits')
|
|
377
|
+
.innerJoin(
|
|
378
|
+
'routes_deposit_addresses',
|
|
379
|
+
'routes_deposit_addresses.id',
|
|
380
|
+
'routes_deposits.depositAddressId',
|
|
381
|
+
)
|
|
382
|
+
.selectAll('routes_deposits')
|
|
383
|
+
if (options.depositAddressId !== undefined)
|
|
384
|
+
query = query.where('routes_deposits.depositAddressId', '=', options.depositAddressId)
|
|
385
|
+
if (options.environments !== undefined)
|
|
386
|
+
query = query.where('routes_deposits.environment', 'in', options.environments)
|
|
387
|
+
else if (options.environment !== undefined)
|
|
388
|
+
query = query.where('routes_deposits.environment', '=', options.environment)
|
|
389
|
+
if (options.hasSubsidy === true)
|
|
390
|
+
query = query.where((eb) =>
|
|
391
|
+
eb.or([
|
|
392
|
+
sql<boolean>`(routes_deposits.provider_subsidy->'amount'->>'baseUnits')::numeric > 0`,
|
|
393
|
+
eb.and([
|
|
394
|
+
eb('routes_deposits.settlementTransactionHash', 'is not', null),
|
|
395
|
+
sql<boolean>`(routes_deposits.subsidy_amount->>'baseUnits')::numeric > 0`,
|
|
396
|
+
]),
|
|
397
|
+
]),
|
|
398
|
+
)
|
|
399
|
+
if (options.orgId !== undefined) query = query.where('routes_deposits.orgId', '=', options.orgId)
|
|
400
|
+
if (options.projectId !== undefined)
|
|
401
|
+
query = query.where('routes_deposits.projectId', '=', options.projectId)
|
|
402
|
+
if (options.providerIds !== undefined)
|
|
403
|
+
query = query.where('routes_deposit_addresses.providerId', 'in', options.providerIds)
|
|
404
|
+
else if (options.providerId !== undefined)
|
|
405
|
+
query = query.where('routes_deposit_addresses.providerId', '=', options.providerId)
|
|
406
|
+
if (options.sourceChainIds !== undefined)
|
|
407
|
+
query = query.where('routes_deposits.sourceChainId', 'in', options.sourceChainIds)
|
|
408
|
+
else if (options.sourceChainId !== undefined)
|
|
409
|
+
query = query.where('routes_deposits.sourceChainId', '=', options.sourceChainId)
|
|
410
|
+
if (options.statuses !== undefined)
|
|
411
|
+
query = query.where('routes_deposits.status', 'in', options.statuses)
|
|
412
|
+
else if (options.status !== undefined)
|
|
413
|
+
query = query.where('routes_deposits.status', '=', options.status)
|
|
414
|
+
if (options.query !== undefined) {
|
|
415
|
+
const exact = options.query
|
|
416
|
+
const address = /^0x[0-9a-fA-F]{40}$/.test(options.query)
|
|
417
|
+
? options.query.toLowerCase()
|
|
418
|
+
: options.query
|
|
419
|
+
const transactionRef = /^(?:0x)?[0-9a-fA-F]{64}$/.test(options.query)
|
|
420
|
+
? options.query.toLowerCase()
|
|
421
|
+
: options.query
|
|
422
|
+
query = query.where((eb) =>
|
|
423
|
+
eb.or([
|
|
424
|
+
eb('routes_deposit_addresses.address', '=', address),
|
|
425
|
+
eb('routes_deposits.id', '=', exact),
|
|
426
|
+
eb('routes_deposits.settlementTransactionHash', '=', transactionRef),
|
|
427
|
+
eb('routes_deposits.sourceTransactionHash', '=', transactionRef),
|
|
428
|
+
sql<boolean>`routes_deposits.provider_transaction_hashes @> ${JSON.stringify([transactionRef])}::jsonb`,
|
|
429
|
+
sql<boolean>`routes_deposits.snapshot->'destinationTransactionHashes' @> ${JSON.stringify([transactionRef])}::jsonb`,
|
|
430
|
+
sql<boolean>`routes_deposits.snapshot->'refundTransactionHashes' @> ${JSON.stringify([transactionRef])}::jsonb`,
|
|
431
|
+
]),
|
|
432
|
+
)
|
|
433
|
+
}
|
|
434
|
+
const cursor = options.cursor
|
|
435
|
+
if (cursor !== undefined)
|
|
436
|
+
query = query.where((eb) =>
|
|
437
|
+
eb.or([
|
|
438
|
+
eb('routes_deposits.updatedAt', '<', cursor.updatedAt),
|
|
439
|
+
eb.and([
|
|
440
|
+
eb('routes_deposits.updatedAt', '=', cursor.updatedAt),
|
|
441
|
+
eb('routes_deposits.id', '<', cursor.id),
|
|
442
|
+
]),
|
|
443
|
+
]),
|
|
444
|
+
)
|
|
445
|
+
return query
|
|
446
|
+
.orderBy('routes_deposits.updatedAt', 'desc')
|
|
447
|
+
.orderBy('routes_deposits.id', 'desc')
|
|
448
|
+
.limit(options.limit)
|
|
449
|
+
.execute()
|
|
450
|
+
}
|
|
451
|
+
|
|
452
|
+
export declare namespace list {
|
|
453
|
+
/** Deposit filters and page bound. */
|
|
454
|
+
type Options = {
|
|
455
|
+
/** Exclusive lower bound from the previous page. */
|
|
456
|
+
cursor?: Cursor | undefined
|
|
457
|
+
/** Restricts deposits to one deposit address. */
|
|
458
|
+
depositAddressId?: string | undefined
|
|
459
|
+
/** Restricts deposits to one route environment. */
|
|
460
|
+
environment?: Record['environment'] | undefined
|
|
461
|
+
/** Restricts deposits to any listed route environment. */
|
|
462
|
+
environments?: readonly Record['environment'][] | undefined
|
|
463
|
+
/** Restricts deposits to records with a positive provider or Tempo subsidy. */
|
|
464
|
+
hasSubsidy?: true | undefined
|
|
465
|
+
/** Maximum rows returned. */
|
|
466
|
+
limit: number
|
|
467
|
+
/** Restricts deposits to one organization. */
|
|
468
|
+
orgId?: string | undefined
|
|
469
|
+
/** Restricts deposits to one project. */
|
|
470
|
+
projectId?: string | undefined
|
|
471
|
+
/** Restricts deposits to one provider. */
|
|
472
|
+
providerId?: string | undefined
|
|
473
|
+
/** Restricts deposits to any listed provider. */
|
|
474
|
+
providerIds?: readonly string[] | undefined
|
|
475
|
+
/** Exact deposit id, deposit address, or transaction reference. */
|
|
476
|
+
query?: string | undefined
|
|
477
|
+
/** Restricts deposits to one source chain. */
|
|
478
|
+
sourceChainId?: string | undefined
|
|
479
|
+
/** Restricts deposits to any listed source chain. */
|
|
480
|
+
sourceChainIds?: readonly string[] | undefined
|
|
481
|
+
/** Restricts deposits to one lifecycle status. */
|
|
482
|
+
status?: Record['status'] | undefined
|
|
483
|
+
/** Restricts deposits to any listed lifecycle status. */
|
|
484
|
+
statuses?: readonly Record['status'][] | undefined
|
|
485
|
+
}
|
|
486
|
+
|
|
487
|
+
/** Cursor fields for the last deposit on the previous page. */
|
|
488
|
+
type Cursor = {
|
|
489
|
+
/** Deposit id, used as a deterministic tie-breaker. */
|
|
490
|
+
id: string
|
|
491
|
+
/** Latest material update time. */
|
|
492
|
+
updatedAt: string
|
|
493
|
+
}
|
|
494
|
+
}
|
|
495
|
+
|
|
496
|
+
/** Summarizes deposit work across the selected filters. */
|
|
497
|
+
export async function summarize(
|
|
498
|
+
db: Db.Db,
|
|
499
|
+
options: summarize.Options = {},
|
|
500
|
+
): Promise<summarize.Result> {
|
|
501
|
+
let query = db.kysely
|
|
502
|
+
.selectFrom('routes_deposits')
|
|
503
|
+
.innerJoin(
|
|
504
|
+
'routes_deposit_addresses',
|
|
505
|
+
'routes_deposit_addresses.id',
|
|
506
|
+
'routes_deposits.depositAddressId',
|
|
507
|
+
)
|
|
508
|
+
if (options.environments !== undefined)
|
|
509
|
+
query = query.where('routes_deposits.environment', 'in', options.environments)
|
|
510
|
+
else if (options.environment !== undefined)
|
|
511
|
+
query = query.where('routes_deposits.environment', '=', options.environment)
|
|
512
|
+
if (options.orgId !== undefined) query = query.where('routes_deposits.orgId', '=', options.orgId)
|
|
513
|
+
if (options.projectId !== undefined)
|
|
514
|
+
query = query.where('routes_deposits.projectId', '=', options.projectId)
|
|
515
|
+
if (options.providerIds !== undefined)
|
|
516
|
+
query = query.where('routes_deposit_addresses.providerId', 'in', options.providerIds)
|
|
517
|
+
else if (options.providerId !== undefined)
|
|
518
|
+
query = query.where('routes_deposit_addresses.providerId', '=', options.providerId)
|
|
519
|
+
if (options.sourceChainIds !== undefined)
|
|
520
|
+
query = query.where('routes_deposits.sourceChainId', 'in', options.sourceChainIds)
|
|
521
|
+
else if (options.sourceChainId !== undefined)
|
|
522
|
+
query = query.where('routes_deposits.sourceChainId', '=', options.sourceChainId)
|
|
523
|
+
const active = ['action-required', 'bridging', 'detected', 'refunding', 'settling'] as const
|
|
524
|
+
const row = await query
|
|
525
|
+
.select((eb) => [
|
|
526
|
+
eb.fn
|
|
527
|
+
.countAll<number>()
|
|
528
|
+
.filterWhere('routes_deposits.status', '=', 'action-required')
|
|
529
|
+
.as('actionRequired'),
|
|
530
|
+
eb.fn
|
|
531
|
+
.countAll<number>()
|
|
532
|
+
.filterWhere('routes_deposits.status', 'in', [
|
|
533
|
+
'bridging',
|
|
534
|
+
'detected',
|
|
535
|
+
'refunding',
|
|
536
|
+
'settling',
|
|
537
|
+
])
|
|
538
|
+
.as('inProgress'),
|
|
539
|
+
eb.fn
|
|
540
|
+
.min(eb.fn.coalesce('routes_deposits.statusUpdatedAt', 'routes_deposits.updatedAt'))
|
|
541
|
+
.filterWhere('routes_deposits.status', 'in', active)
|
|
542
|
+
.as('oldestActiveAt'),
|
|
543
|
+
])
|
|
544
|
+
.executeTakeFirstOrThrow()
|
|
545
|
+
return {
|
|
546
|
+
actionRequired: Number(row.actionRequired),
|
|
547
|
+
inProgress: Number(row.inProgress),
|
|
548
|
+
oldestActiveAt: row.oldestActiveAt,
|
|
549
|
+
}
|
|
550
|
+
}
|
|
551
|
+
|
|
552
|
+
export declare namespace summarize {
|
|
553
|
+
/** Attribution and route filters. */
|
|
554
|
+
type Options = {
|
|
555
|
+
/** Restricts deposits to one route environment. */
|
|
556
|
+
environment?: Record['environment'] | undefined
|
|
557
|
+
/** Restricts deposits to any listed route environment. */
|
|
558
|
+
environments?: readonly Record['environment'][] | undefined
|
|
559
|
+
/** Restricts deposits to one organization. */
|
|
560
|
+
orgId?: string | undefined
|
|
561
|
+
/** Restricts deposits to one project. */
|
|
562
|
+
projectId?: string | undefined
|
|
563
|
+
/** Restricts deposits to one provider. */
|
|
564
|
+
providerId?: string | undefined
|
|
565
|
+
/** Restricts deposits to any listed provider. */
|
|
566
|
+
providerIds?: readonly string[] | undefined
|
|
567
|
+
/** Restricts deposits to one source chain. */
|
|
568
|
+
sourceChainId?: string | undefined
|
|
569
|
+
/** Restricts deposits to any listed source chain. */
|
|
570
|
+
sourceChainIds?: readonly string[] | undefined
|
|
571
|
+
}
|
|
572
|
+
|
|
573
|
+
/** Current deposit work totals. */
|
|
574
|
+
type Result = {
|
|
575
|
+
/** Deposits that require operator action. */
|
|
576
|
+
actionRequired: number
|
|
577
|
+
/** Deposits currently owned by platform processing or recovery. */
|
|
578
|
+
inProgress: number
|
|
579
|
+
/** When the oldest active deposit entered its current status. */
|
|
580
|
+
oldestActiveAt: string | null
|
|
581
|
+
}
|
|
582
|
+
}
|
|
583
|
+
|
|
584
|
+
/** Counts owner-visible route deposits through the list's shared filters. */
|
|
585
|
+
export async function count(db: Db.Db, options: count.Options): Promise<number> {
|
|
586
|
+
const rows = query(db, options)
|
|
587
|
+
.select('routes_deposits.id')
|
|
588
|
+
.limit(options.cap + 1)
|
|
589
|
+
.as('rows')
|
|
590
|
+
const result = await db.kysely
|
|
591
|
+
.selectFrom(rows)
|
|
592
|
+
.select(sql<number>`count(*)::int`.as('count'))
|
|
593
|
+
.executeTakeFirstOrThrow()
|
|
594
|
+
return result.count
|
|
595
|
+
}
|
|
596
|
+
|
|
597
|
+
export declare namespace count {
|
|
598
|
+
/** Ownership, filter, and cap options for counting route deposits. */
|
|
599
|
+
type Options = Filters & {
|
|
600
|
+
/** Maximum exact count before returning the cap plus one. */
|
|
601
|
+
cap: number
|
|
602
|
+
/** Ownership filter derived from the authenticated API key. */
|
|
603
|
+
owner: Owner
|
|
604
|
+
}
|
|
605
|
+
}
|
|
606
|
+
|
|
607
|
+
function query(db: Db.Db, options: query.Options) {
|
|
608
|
+
const owner = options.owner
|
|
609
|
+
let builder = db.kysely
|
|
610
|
+
.selectFrom('routes_deposits')
|
|
611
|
+
.innerJoin(
|
|
612
|
+
'routes_deposit_addresses',
|
|
613
|
+
'routes_deposit_addresses.id',
|
|
614
|
+
'routes_deposits.depositAddressId',
|
|
615
|
+
)
|
|
616
|
+
.where('routes_deposit_addresses.environment', '=', owner.environment)
|
|
617
|
+
.where('routes_deposit_addresses.orgId', '=', owner.orgId)
|
|
618
|
+
.where('routes_deposits.environment', '=', owner.environment)
|
|
619
|
+
.where('routes_deposits.orgId', '=', owner.orgId)
|
|
620
|
+
if (owner.projectId !== undefined)
|
|
621
|
+
builder = builder
|
|
622
|
+
.where('routes_deposit_addresses.projectId', '=', owner.projectId)
|
|
623
|
+
.where('routes_deposits.projectId', '=', owner.projectId)
|
|
624
|
+
if (options.depositAddress !== undefined) {
|
|
625
|
+
const address = /^0x[0-9a-fA-F]{40}$/.test(options.depositAddress)
|
|
626
|
+
? options.depositAddress.toLowerCase()
|
|
627
|
+
: options.depositAddress
|
|
628
|
+
builder = builder.where('routes_deposit_addresses.address', '=', address)
|
|
629
|
+
}
|
|
630
|
+
if (options.destinationTokenKeys !== undefined)
|
|
631
|
+
builder = options.destinationTokenKeys.length
|
|
632
|
+
? builder.where(
|
|
633
|
+
'routes_deposit_addresses.destinationTokenKey',
|
|
634
|
+
'in',
|
|
635
|
+
options.destinationTokenKeys,
|
|
636
|
+
)
|
|
637
|
+
: builder.where(sql<boolean>`false`)
|
|
638
|
+
if (options.providerId !== undefined)
|
|
639
|
+
builder = builder.where('routes_deposit_addresses.providerId', '=', options.providerId)
|
|
640
|
+
if (options.recipient !== undefined)
|
|
641
|
+
builder = builder.where(
|
|
642
|
+
sql<boolean>`lower(routes_deposit_addresses.recipient) = ${options.recipient.toLowerCase()}`,
|
|
643
|
+
)
|
|
644
|
+
if (options.sourceChainIds !== undefined)
|
|
645
|
+
builder = options.sourceChainIds.length
|
|
646
|
+
? builder.where('routes_deposit_addresses.sourceChainId', 'in', options.sourceChainIds)
|
|
647
|
+
: builder.where(sql<boolean>`false`)
|
|
648
|
+
if (options.sourceTokenKeys !== undefined)
|
|
649
|
+
builder = options.sourceTokenKeys.length
|
|
650
|
+
? builder.where('routes_deposit_addresses.sourceTokenKey', 'in', options.sourceTokenKeys)
|
|
651
|
+
: builder.where(sql<boolean>`false`)
|
|
652
|
+
if (options.status !== undefined)
|
|
653
|
+
builder = builder.where('routes_deposits.status', '=', options.status)
|
|
654
|
+
return builder
|
|
655
|
+
}
|
|
656
|
+
|
|
657
|
+
declare namespace query {
|
|
658
|
+
type Options = Filters & {
|
|
659
|
+
owner: Owner
|
|
660
|
+
}
|
|
661
|
+
}
|
|
662
|
+
|
|
663
|
+
/** Lists one owner-visible address's deposits newest-first. */
|
|
664
|
+
export function listByAddress(
|
|
665
|
+
db: Db.Db,
|
|
666
|
+
owner: Owner,
|
|
667
|
+
addressId: string,
|
|
668
|
+
options: listByAddress.Options,
|
|
669
|
+
): Promise<Record[]> {
|
|
670
|
+
const { cursor, limit } = options
|
|
671
|
+
let query = db.kysely
|
|
672
|
+
.selectFrom('routes_deposits')
|
|
673
|
+
.selectAll()
|
|
674
|
+
.where('depositAddressId', '=', addressId)
|
|
675
|
+
.where('environment', '=', owner.environment)
|
|
676
|
+
.where('orgId', '=', owner.orgId)
|
|
677
|
+
if (owner.projectId !== undefined) query = query.where('projectId', '=', owner.projectId)
|
|
678
|
+
if (cursor)
|
|
679
|
+
query = query.where((eb) =>
|
|
680
|
+
eb.or([
|
|
681
|
+
eb('createdAt', '<', cursor.createdAt),
|
|
682
|
+
eb.and([eb('createdAt', '=', cursor.createdAt), eb('id', '<', cursor.id)]),
|
|
683
|
+
]),
|
|
684
|
+
)
|
|
685
|
+
return query.orderBy('createdAt', 'desc').orderBy('id', 'desc').limit(limit).execute()
|
|
686
|
+
}
|
|
687
|
+
|
|
688
|
+
export declare namespace listByAddress {
|
|
689
|
+
/** Cursor fields for the last deposit returned by the previous page. */
|
|
690
|
+
type Cursor = {
|
|
691
|
+
/** Deposit creation time. */
|
|
692
|
+
createdAt: string
|
|
693
|
+
/** Deposit id, used as a deterministic tie-breaker. */
|
|
694
|
+
id: string
|
|
695
|
+
}
|
|
696
|
+
|
|
697
|
+
/** Paging options for one address's deposits. */
|
|
698
|
+
type Options = {
|
|
699
|
+
/** Exclusive lower bound from the previous page. */
|
|
700
|
+
cursor?: Cursor | undefined
|
|
701
|
+
/** Maximum rows to return. */
|
|
702
|
+
limit: number
|
|
703
|
+
}
|
|
704
|
+
}
|
|
705
|
+
|
|
706
|
+
/** Lists deposits for one reusable source-chain address newest-first. */
|
|
707
|
+
export function listByDepositAddress(
|
|
708
|
+
db: Db.Db,
|
|
709
|
+
options: listByDepositAddress.Options,
|
|
710
|
+
): Promise<Record[]> {
|
|
711
|
+
const { cursor, depositAddress, limit, owner } = options
|
|
712
|
+
const address = /^0x[0-9a-fA-F]{40}$/.test(depositAddress)
|
|
713
|
+
? depositAddress.toLowerCase()
|
|
714
|
+
: depositAddress
|
|
715
|
+
let query = db.kysely
|
|
716
|
+
.selectFrom('routes_deposits')
|
|
717
|
+
.innerJoin(
|
|
718
|
+
'routes_deposit_addresses',
|
|
719
|
+
'routes_deposit_addresses.id',
|
|
720
|
+
'routes_deposits.depositAddressId',
|
|
721
|
+
)
|
|
722
|
+
.selectAll('routes_deposits')
|
|
723
|
+
.where('routes_deposit_addresses.address', '=', address)
|
|
724
|
+
.where('routes_deposit_addresses.environment', '=', owner.environment)
|
|
725
|
+
.where('routes_deposit_addresses.orgId', '=', owner.orgId)
|
|
726
|
+
.where('routes_deposits.environment', '=', owner.environment)
|
|
727
|
+
.where('routes_deposits.orgId', '=', owner.orgId)
|
|
728
|
+
if (owner.projectId !== undefined)
|
|
729
|
+
query = query
|
|
730
|
+
.where('routes_deposit_addresses.projectId', '=', owner.projectId)
|
|
731
|
+
.where('routes_deposits.projectId', '=', owner.projectId)
|
|
732
|
+
if (cursor)
|
|
733
|
+
query = query.where((eb) =>
|
|
734
|
+
eb.or([
|
|
735
|
+
eb('routes_deposits.createdAt', '<', cursor.createdAt),
|
|
736
|
+
eb.and([
|
|
737
|
+
eb('routes_deposits.createdAt', '=', cursor.createdAt),
|
|
738
|
+
eb('routes_deposits.id', '<', cursor.id),
|
|
739
|
+
]),
|
|
740
|
+
]),
|
|
741
|
+
)
|
|
742
|
+
return query
|
|
743
|
+
.orderBy('routes_deposits.createdAt', 'desc')
|
|
744
|
+
.orderBy('routes_deposits.id', 'desc')
|
|
745
|
+
.limit(limit)
|
|
746
|
+
.execute()
|
|
747
|
+
}
|
|
748
|
+
|
|
749
|
+
export declare namespace listByDepositAddress {
|
|
750
|
+
/** Deposit address filter, ownership, and paging options. */
|
|
751
|
+
type Options = {
|
|
752
|
+
/** Exclusive lower bound from the previous page. */
|
|
753
|
+
cursor?: listByAddress.Cursor | undefined
|
|
754
|
+
/** Reusable source-chain address that received the funds. */
|
|
755
|
+
depositAddress: string
|
|
756
|
+
/** Maximum rows to return. */
|
|
757
|
+
limit: number
|
|
758
|
+
/** Ownership filter derived from the authenticated API key. */
|
|
759
|
+
owner: Owner
|
|
760
|
+
}
|
|
761
|
+
}
|
|
762
|
+
|
|
763
|
+
/** Lists one recipient's owner-visible deposits newest-first. */
|
|
764
|
+
export function listByRecipient(db: Db.Db, options: listByRecipient.Options): Promise<Record[]> {
|
|
765
|
+
const { cursor, limit, owner, recipient } = options
|
|
766
|
+
let query = db.kysely
|
|
767
|
+
.selectFrom('routes_deposits')
|
|
768
|
+
.selectAll()
|
|
769
|
+
.where('environment', '=', owner.environment)
|
|
770
|
+
.where('orgId', '=', owner.orgId)
|
|
771
|
+
.where(sql<boolean>`lower(snapshot->>'recipient') = ${recipient.toLowerCase()}`)
|
|
772
|
+
if (owner.projectId !== undefined) query = query.where('projectId', '=', owner.projectId)
|
|
773
|
+
if (cursor)
|
|
774
|
+
query = query.where((eb) =>
|
|
775
|
+
eb.or([
|
|
776
|
+
eb('createdAt', '<', cursor.createdAt),
|
|
777
|
+
eb.and([eb('createdAt', '=', cursor.createdAt), eb('id', '<', cursor.id)]),
|
|
778
|
+
]),
|
|
779
|
+
)
|
|
780
|
+
return query.orderBy('createdAt', 'desc').orderBy('id', 'desc').limit(limit).execute()
|
|
781
|
+
}
|
|
782
|
+
|
|
783
|
+
export declare namespace listByRecipient {
|
|
784
|
+
/** Recipient filter, ownership, and paging options. */
|
|
785
|
+
type Options = {
|
|
786
|
+
/** Exclusive lower bound from the previous page. */
|
|
787
|
+
cursor?: listByAddress.Cursor | undefined
|
|
788
|
+
/** Maximum rows to return. */
|
|
789
|
+
limit: number
|
|
790
|
+
/** Ownership filter derived from the authenticated API key. */
|
|
791
|
+
owner: Owner
|
|
792
|
+
/** Tempo account that receives completed deposits. */
|
|
793
|
+
recipient: string
|
|
794
|
+
}
|
|
795
|
+
}
|
|
796
|
+
|
|
797
|
+
/** Returns provider-paid and settled Tempo subsidies for one deposit. */
|
|
798
|
+
export function subsidies(record: Record) {
|
|
799
|
+
return [
|
|
800
|
+
...(record.providerSubsidy ? [record.providerSubsidy] : []),
|
|
801
|
+
...(record.settlementTransactionHash && record.subsidyAmount
|
|
802
|
+
? [
|
|
803
|
+
{
|
|
804
|
+
amount: record.subsidyAmount,
|
|
805
|
+
provider: 'tempo' as const,
|
|
806
|
+
token: record.snapshot.destinationToken,
|
|
807
|
+
},
|
|
808
|
+
]
|
|
809
|
+
: []),
|
|
810
|
+
]
|
|
811
|
+
}
|
|
812
|
+
|
|
813
|
+
/** Lists verified production subsidies awaiting a Stripe acknowledgement. */
|
|
814
|
+
export function listUnreportedSubsidies(
|
|
815
|
+
db: Db.Db,
|
|
816
|
+
options: listUnreportedSubsidies.Options = {},
|
|
817
|
+
): Promise<Record[]> {
|
|
818
|
+
let query = db.kysely
|
|
819
|
+
.selectFrom('routes_deposits')
|
|
820
|
+
.selectAll()
|
|
821
|
+
.where('environment', '=', 'production')
|
|
822
|
+
.where((eb) =>
|
|
823
|
+
eb.or([
|
|
824
|
+
eb('status', '=', 'completed'),
|
|
825
|
+
eb.and([
|
|
826
|
+
eb('status', 'in', ['action-required', 'settling']),
|
|
827
|
+
eb('tempoGasPaid', 'is not', null),
|
|
828
|
+
]),
|
|
829
|
+
]),
|
|
830
|
+
)
|
|
831
|
+
.where((eb) =>
|
|
832
|
+
eb.or([
|
|
833
|
+
sql<boolean>`(provider_subsidy->'amount'->>'baseUnits')::numeric > 0`,
|
|
834
|
+
eb.and([
|
|
835
|
+
eb('settlementTransactionHash', 'is not', null),
|
|
836
|
+
eb('subsidyAmount', 'is not', null),
|
|
837
|
+
sql<boolean>`(subsidy_amount->>'baseUnits')::numeric > 0`,
|
|
838
|
+
]),
|
|
839
|
+
]),
|
|
840
|
+
)
|
|
841
|
+
.where('subsidyMeterReportedAt', 'is', null)
|
|
842
|
+
.orderBy('statusUpdatedAt', 'asc')
|
|
843
|
+
.orderBy('id', 'asc')
|
|
844
|
+
if (options.limit !== undefined) query = query.limit(options.limit)
|
|
845
|
+
if (options.orgId !== undefined) query = query.where('orgId', '=', options.orgId)
|
|
846
|
+
return query.execute()
|
|
847
|
+
}
|
|
848
|
+
|
|
849
|
+
export declare namespace listUnreportedSubsidies {
|
|
850
|
+
/** Options for the Routes subsidy reporting scan. */
|
|
851
|
+
type Options = {
|
|
852
|
+
/** Maximum rows to return. */
|
|
853
|
+
limit?: number | undefined
|
|
854
|
+
/** Organization whose pending usage is listed. */
|
|
855
|
+
orgId?: string | undefined
|
|
856
|
+
}
|
|
857
|
+
}
|
|
858
|
+
|
|
859
|
+
/** Stores the effective timestamp after Stripe acknowledges a Routes subsidy meter event. */
|
|
860
|
+
export async function markSubsidyReported(db: Db.Db, id: string, meteredAt: string): Promise<void> {
|
|
861
|
+
await db.kysely
|
|
862
|
+
.updateTable('routes_deposits')
|
|
863
|
+
.set({ subsidyMeterReportedAt: meteredAt })
|
|
864
|
+
.where('id', '=', id)
|
|
865
|
+
.where('subsidyMeterReportedAt', 'is', null)
|
|
866
|
+
.execute()
|
|
867
|
+
}
|
|
868
|
+
|
|
869
|
+
/** Returns whether one organization has a Routes subsidy awaiting Stripe settlement. */
|
|
870
|
+
export async function hasUnreportedSubsidies(
|
|
871
|
+
db: Db.Db,
|
|
872
|
+
options: hasUnreportedSubsidies.Options,
|
|
873
|
+
): Promise<boolean> {
|
|
874
|
+
return Boolean(
|
|
875
|
+
await db.kysely
|
|
876
|
+
.selectFrom('routes_deposits')
|
|
877
|
+
.select('id')
|
|
878
|
+
.where('environment', '=', 'production')
|
|
879
|
+
.where('orgId', '=', options.orgId)
|
|
880
|
+
.where('status', 'in', ['action-required', 'settling', 'completed'])
|
|
881
|
+
.where((eb) =>
|
|
882
|
+
eb.or([
|
|
883
|
+
eb.and([
|
|
884
|
+
sql<boolean>`(provider_subsidy->'amount'->>'baseUnits')::numeric > 0`,
|
|
885
|
+
eb.or([
|
|
886
|
+
eb('status', '=', 'completed'),
|
|
887
|
+
eb.and([
|
|
888
|
+
eb('status', 'in', ['action-required', 'settling']),
|
|
889
|
+
eb('tempoGasPaid', 'is not', null),
|
|
890
|
+
]),
|
|
891
|
+
]),
|
|
892
|
+
]),
|
|
893
|
+
eb.and([
|
|
894
|
+
eb('settlementTransactionHash', 'is not', null),
|
|
895
|
+
eb('subsidyAmount', 'is not', null),
|
|
896
|
+
sql<boolean>`(subsidy_amount->>'baseUnits')::numeric > 0`,
|
|
897
|
+
]),
|
|
898
|
+
]),
|
|
899
|
+
)
|
|
900
|
+
.where('subsidyMeterReportedAt', 'is', null)
|
|
901
|
+
.limit(1)
|
|
902
|
+
.executeTakeFirst(),
|
|
903
|
+
)
|
|
904
|
+
}
|
|
905
|
+
|
|
906
|
+
export declare namespace hasUnreportedSubsidies {
|
|
907
|
+
/** Organization filter for pending Routes subsidy usage. */
|
|
908
|
+
type Options = {
|
|
909
|
+
/** Organization whose pending usage is checked. */
|
|
910
|
+
orgId: string
|
|
911
|
+
}
|
|
912
|
+
}
|
|
913
|
+
|
|
914
|
+
/** Reads billable Routes subsidy usage for one organization and time window. */
|
|
915
|
+
export async function subsidyUsage(
|
|
916
|
+
db: Db.Db,
|
|
917
|
+
options: subsidyUsage.Options,
|
|
918
|
+
): Promise<subsidyUsage.Result> {
|
|
919
|
+
// Sum the same per-row ceilings used by Stripe reporting so admin usage matches the invoice.
|
|
920
|
+
const providerAmount = sql<string>`coalesce(ceil((provider_subsidy->'amount'->>'baseUnits')::numeric * power(10::numeric, ${Fees.tokenDecimals} - (provider_subsidy->'amount'->>'decimals')::integer)), 0)`
|
|
921
|
+
const tempoAmount = sql<string>`case when settlement_transaction_hash is not null then coalesce(ceil((subsidy_amount->>'baseUnits')::numeric * power(10::numeric, ${Fees.tokenDecimals} - (subsidy_amount->>'decimals')::integer)), 0) else 0 end`
|
|
922
|
+
const amount = sql<string>`${providerAmount} + ${tempoAmount}`
|
|
923
|
+
const meteredAt = sql<string>`coalesce(subsidy_meter_reported_at, status_updated_at, updated_at)`
|
|
924
|
+
const row = await db.kysely
|
|
925
|
+
.selectFrom('routes_deposits')
|
|
926
|
+
.select([
|
|
927
|
+
sql<string>`coalesce(sum(${amount}), 0)`.as('amount'),
|
|
928
|
+
sql<string>`count(*)`.as('count'),
|
|
929
|
+
])
|
|
930
|
+
.where('orgId', '=', options.orgId)
|
|
931
|
+
.where('environment', '=', options.environment)
|
|
932
|
+
.where((eb) =>
|
|
933
|
+
eb.or([
|
|
934
|
+
eb('status', '=', 'completed'),
|
|
935
|
+
eb.and([
|
|
936
|
+
eb('status', 'in', ['action-required', 'settling']),
|
|
937
|
+
eb('tempoGasPaid', 'is not', null),
|
|
938
|
+
]),
|
|
939
|
+
]),
|
|
940
|
+
)
|
|
941
|
+
.where((eb) =>
|
|
942
|
+
eb.or([
|
|
943
|
+
sql<boolean>`(provider_subsidy->'amount'->>'baseUnits')::numeric > 0`,
|
|
944
|
+
eb.and([
|
|
945
|
+
eb('settlementTransactionHash', 'is not', null),
|
|
946
|
+
eb('subsidyAmount', 'is not', null),
|
|
947
|
+
sql<boolean>`(subsidy_amount->>'baseUnits')::numeric > 0`,
|
|
948
|
+
]),
|
|
949
|
+
]),
|
|
950
|
+
)
|
|
951
|
+
.where(meteredAt, '>=', options.from)
|
|
952
|
+
.where(meteredAt, '<=', options.to)
|
|
953
|
+
.executeTakeFirstOrThrow()
|
|
954
|
+
return {
|
|
955
|
+
amount: BigInt(row.amount),
|
|
956
|
+
count: Number(row.count),
|
|
957
|
+
}
|
|
958
|
+
}
|
|
959
|
+
|
|
960
|
+
export declare namespace subsidyUsage {
|
|
961
|
+
/** Organization and meter-event window for Routes subsidy usage. */
|
|
962
|
+
type Options = {
|
|
963
|
+
/** Key environment to include. */
|
|
964
|
+
environment: Record['environment']
|
|
965
|
+
/** Inclusive meter-event lower bound. */
|
|
966
|
+
from: string
|
|
967
|
+
/** Organization whose subsidy usage is read. */
|
|
968
|
+
orgId: string
|
|
969
|
+
/** Inclusive meter-event upper bound. */
|
|
970
|
+
to: string
|
|
971
|
+
}
|
|
972
|
+
|
|
973
|
+
/** Billable Routes subsidy usage in fee-payer meter units. */
|
|
974
|
+
type Result = {
|
|
975
|
+
/** USD subsidy total in six-decimal meter units. */
|
|
976
|
+
amount: bigint
|
|
977
|
+
/** Metered provider fees and Tempo top-ups. */
|
|
978
|
+
count: number
|
|
979
|
+
}
|
|
980
|
+
}
|
|
981
|
+
|
|
982
|
+
/** Applies a version-guarded deposit update. */
|
|
983
|
+
export function update(db: Db.Db, options: update.Options): Promise<Record | undefined> {
|
|
984
|
+
return db.kysely
|
|
985
|
+
.updateTable('routes_deposits')
|
|
986
|
+
.set({
|
|
987
|
+
providerDeliveredAt: options.providerDeliveredAt,
|
|
988
|
+
providerOutputAmount: options.providerOutputAmount,
|
|
989
|
+
providerRequestId: options.providerRequestId,
|
|
990
|
+
providerRequestIds: JSON.stringify(options.providerRequestIds),
|
|
991
|
+
providerState: options.providerState,
|
|
992
|
+
providerSubsidy: options.providerSubsidy,
|
|
993
|
+
providerTransactionHashes: JSON.stringify(options.providerTransactionHashes),
|
|
994
|
+
providerTransferIndex: options.providerTransferIndex,
|
|
995
|
+
retryState: options.retryState,
|
|
996
|
+
settlementTransaction: options.settlementTransaction,
|
|
997
|
+
settlementTransactionHash: options.settlementTransactionHash,
|
|
998
|
+
snapshot: options.snapshot,
|
|
999
|
+
sourceTransferIndex: options.sourceTransferIndex,
|
|
1000
|
+
status: options.status,
|
|
1001
|
+
statusReason: options.statusReason,
|
|
1002
|
+
statusUpdatedAt: options.statusUpdatedAt,
|
|
1003
|
+
subsidyAmount: options.subsidyAmount,
|
|
1004
|
+
tempoGasPaid: options.tempoGasPaid,
|
|
1005
|
+
updatedAt: options.updatedAt,
|
|
1006
|
+
version: options.version,
|
|
1007
|
+
})
|
|
1008
|
+
.where('id', '=', options.id)
|
|
1009
|
+
.where('version', '=', options.expectedVersion)
|
|
1010
|
+
.returningAll()
|
|
1011
|
+
.executeTakeFirst()
|
|
1012
|
+
}
|
|
1013
|
+
|
|
1014
|
+
export declare namespace update {
|
|
1015
|
+
/** Guarded deposit update fields. */
|
|
1016
|
+
type Options = {
|
|
1017
|
+
/** Stored version required for the update. */
|
|
1018
|
+
expectedVersion: number
|
|
1019
|
+
/** Route deposit id (`rdp_…`). */
|
|
1020
|
+
id: string
|
|
1021
|
+
/** When provider delivery was first verified. */
|
|
1022
|
+
providerDeliveredAt: Record['providerDeliveredAt']
|
|
1023
|
+
/** Provider output amount confirmed on Tempo. */
|
|
1024
|
+
providerOutputAmount: Record['providerOutputAmount']
|
|
1025
|
+
/** Provider request that first reported the deposit. */
|
|
1026
|
+
providerRequestId: Record['providerRequestId']
|
|
1027
|
+
/** Private provider request identifiers. */
|
|
1028
|
+
providerRequestIds: Record['providerRequestIds']
|
|
1029
|
+
/** Bounded private provider state. */
|
|
1030
|
+
providerState: Record['providerState']
|
|
1031
|
+
/** Provider-paid subsidy amount and token. */
|
|
1032
|
+
providerSubsidy: Record['providerSubsidy']
|
|
1033
|
+
/** Provider-leg transaction references. */
|
|
1034
|
+
providerTransactionHashes: Record['providerTransactionHashes']
|
|
1035
|
+
/** Deposit position within the provider request. */
|
|
1036
|
+
providerTransferIndex: Record['providerTransferIndex']
|
|
1037
|
+
/** Bounded private retry state. */
|
|
1038
|
+
retryState: Record['retryState']
|
|
1039
|
+
/** Persisted settlement transaction bytes for exactly-once rebroadcast. */
|
|
1040
|
+
settlementTransaction: Record['settlementTransaction']
|
|
1041
|
+
/** Persisted settlement transaction hash. */
|
|
1042
|
+
settlementTransactionHash: Record['settlementTransactionHash']
|
|
1043
|
+
/** Replacement public snapshot. */
|
|
1044
|
+
snapshot: Record['snapshot']
|
|
1045
|
+
/** Verified transfer position in the source transaction, or null. */
|
|
1046
|
+
sourceTransferIndex: Record['sourceTransferIndex']
|
|
1047
|
+
/** Replacement lifecycle status. */
|
|
1048
|
+
status: Record['status']
|
|
1049
|
+
/** Replacement customer-safe reason. */
|
|
1050
|
+
statusReason: Record['statusReason']
|
|
1051
|
+
/** When the deposit entered its current status. */
|
|
1052
|
+
statusUpdatedAt: Record['statusUpdatedAt']
|
|
1053
|
+
/** Destination token amount supplied by Tempo. */
|
|
1054
|
+
subsidyAmount: Record['subsidyAmount']
|
|
1055
|
+
/** Tempo gas paid for settlement, in base units. */
|
|
1056
|
+
tempoGasPaid: Record['tempoGasPaid']
|
|
1057
|
+
/** New material update time. */
|
|
1058
|
+
updatedAt: string
|
|
1059
|
+
/** New material version. */
|
|
1060
|
+
version: number
|
|
1061
|
+
}
|
|
1062
|
+
}
|