tapimo 0.13.0 → 0.15.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +7 -4
- package/dist/ApiKey.js +1 -1
- package/dist/ApiKey.js.map +1 -1
- package/dist/ApiKeys.d.ts +95 -14
- package/dist/ApiKeys.d.ts.map +1 -1
- package/dist/ApiKeys.js +360 -49
- package/dist/ApiKeys.js.map +1 -1
- package/dist/App.d.ts +21383 -18056
- package/dist/App.d.ts.map +1 -1
- package/dist/App.js +301 -22
- package/dist/App.js.map +1 -1
- package/dist/Assets.d.ts.map +1 -1
- package/dist/Assets.js +2 -1
- package/dist/Assets.js.map +1 -1
- package/dist/Handler.d.ts +0 -1
- package/dist/Handler.d.ts.map +1 -1
- package/dist/Handler.js +0 -1
- package/dist/Handler.js.map +1 -1
- package/dist/Scope.d.ts +13 -5
- package/dist/Scope.d.ts.map +1 -1
- package/dist/Scope.js +16 -5
- package/dist/Scope.js.map +1 -1
- package/dist/Webhooks.js +2 -2
- package/dist/Webhooks.js.map +1 -1
- package/dist/admin/App.d.ts +3936 -1337
- package/dist/admin/App.d.ts.map +1 -1
- package/dist/admin/App.js +26 -5
- package/dist/admin/App.js.map +1 -1
- package/dist/admin/apps/api-keys.d.ts +159 -7
- package/dist/admin/apps/api-keys.d.ts.map +1 -1
- package/dist/admin/apps/api-keys.js +95 -43
- package/dist/admin/apps/api-keys.js.map +1 -1
- package/dist/admin/apps/earn-vaults.d.ts +1446 -0
- package/dist/admin/apps/earn-vaults.d.ts.map +1 -1
- package/dist/admin/apps/earn-vaults.js +465 -8
- package/dist/admin/apps/earn-vaults.js.map +1 -1
- package/dist/admin/apps/organizations.d.ts +344 -3
- package/dist/admin/apps/organizations.d.ts.map +1 -1
- package/dist/admin/apps/organizations.js +288 -10
- package/dist/admin/apps/organizations.js.map +1 -1
- package/dist/admin/apps/routes-support.d.ts +95 -0
- package/dist/admin/apps/routes-support.d.ts.map +1 -0
- package/dist/admin/apps/routes-support.js +151 -0
- package/dist/admin/apps/routes-support.js.map +1 -0
- package/dist/admin/apps/routes.d.ts +2764 -0
- package/dist/admin/apps/routes.d.ts.map +1 -0
- package/dist/admin/apps/routes.js +728 -0
- package/dist/admin/apps/routes.js.map +1 -0
- package/dist/admin/apps/subsidies.d.ts +501 -0
- package/dist/admin/apps/subsidies.d.ts.map +1 -0
- package/dist/admin/apps/subsidies.js +384 -0
- package/dist/admin/apps/subsidies.js.map +1 -0
- package/dist/admin/apps/verified-tokens.d.ts +16 -16
- package/dist/admin/apps/verified-tokens.d.ts.map +1 -1
- package/dist/admin/apps/verified-tokens.js +3 -3
- package/dist/admin/apps/verified-tokens.js.map +1 -1
- package/dist/admin/ui.generated.d.ts +1 -1
- package/dist/admin/ui.generated.d.ts.map +1 -1
- package/dist/admin/ui.generated.js +129 -69
- package/dist/admin/ui.generated.js.map +1 -1
- package/dist/analytics/Analytics.d.ts +5 -2
- package/dist/analytics/Analytics.d.ts.map +1 -1
- package/dist/analytics/Analytics.js +31 -1
- package/dist/analytics/Analytics.js.map +1 -1
- package/dist/analytics/tables/requestEvents.d.ts +2 -1
- package/dist/analytics/tables/requestEvents.d.ts.map +1 -1
- package/dist/analytics/tables/requestEvents.js +10 -1
- package/dist/analytics/tables/requestEvents.js.map +1 -1
- package/dist/analytics/tables/routesLifecycleIntervals.d.ts +72 -0
- package/dist/analytics/tables/routesLifecycleIntervals.d.ts.map +1 -0
- package/dist/analytics/tables/routesLifecycleIntervals.js +56 -0
- package/dist/analytics/tables/routesLifecycleIntervals.js.map +1 -0
- package/dist/apps/Zones.d.ts +21 -12526
- package/dist/apps/Zones.d.ts.map +1 -1
- package/dist/apps/Zones.js +40 -8
- package/dist/apps/Zones.js.map +1 -1
- package/dist/apps/data/App.d.ts +4310 -2548
- package/dist/apps/data/App.d.ts.map +1 -1
- package/dist/apps/data/App.js +86 -26
- package/dist/apps/data/App.js.map +1 -1
- package/dist/apps/data/routes/activities.d.ts +364 -34
- package/dist/apps/data/routes/activities.d.ts.map +1 -1
- package/dist/apps/data/routes/activities.js +495 -190
- package/dist/apps/data/routes/activities.js.map +1 -1
- package/dist/apps/data/routes/addresses.d.ts +94 -22
- package/dist/apps/data/routes/addresses.d.ts.map +1 -1
- package/dist/apps/data/routes/blocks.d.ts +37 -37
- package/dist/apps/data/routes/coingecko.d.ts.map +1 -1
- package/dist/apps/data/routes/coingecko.js +47 -21
- package/dist/apps/data/routes/coingecko.js.map +1 -1
- package/dist/apps/data/routes/earn.d.ts +1641 -352
- package/dist/apps/data/routes/earn.d.ts.map +1 -1
- package/dist/apps/data/routes/earn.js +1561 -120
- package/dist/apps/data/routes/earn.js.map +1 -1
- package/dist/apps/data/routes/exchanges.d.ts +15 -0
- package/dist/apps/data/routes/exchanges.d.ts.map +1 -1
- package/dist/apps/data/routes/exchanges.js +180 -114
- package/dist/apps/data/routes/exchanges.js.map +1 -1
- package/dist/apps/data/routes/fee-amm.d.ts +5 -0
- package/dist/apps/data/routes/fee-amm.d.ts.map +1 -1
- package/dist/apps/data/routes/fee-amm.js +49 -38
- package/dist/apps/data/routes/fee-amm.js.map +1 -1
- package/dist/apps/data/routes/indexer.d.ts +125 -0
- package/dist/apps/data/routes/indexer.d.ts.map +1 -1
- package/dist/apps/data/routes/indexer.js +83 -27
- package/dist/apps/data/routes/indexer.js.map +1 -1
- package/dist/apps/data/routes/rpc.d.ts +507 -33
- package/dist/apps/data/routes/rpc.d.ts.map +1 -1
- package/dist/apps/data/routes/rpc.js +266 -156
- package/dist/apps/data/routes/rpc.js.map +1 -1
- package/dist/apps/data/routes/tokenlist.d.ts +47 -15
- package/dist/apps/data/routes/tokenlist.d.ts.map +1 -1
- package/dist/apps/data/routes/tokenlist.js +68 -11
- package/dist/apps/data/routes/tokenlist.js.map +1 -1
- package/dist/apps/data/routes/tokens.d.ts +95 -93
- package/dist/apps/data/routes/tokens.d.ts.map +1 -1
- package/dist/apps/data/routes/tokens.js +26 -14
- package/dist/apps/data/routes/tokens.js.map +1 -1
- package/dist/apps/data/routes/transfers.d.ts +16 -0
- package/dist/apps/data/routes/transfers.d.ts.map +1 -1
- package/dist/apps/data/routes/transfers.js +9 -7
- package/dist/apps/data/routes/transfers.js.map +1 -1
- package/dist/apps/data/routes/verified-tokens.d.ts +4 -4
- package/dist/apps/data/routes/verified-tokens.d.ts.map +1 -1
- package/dist/apps/data/routes/verified-tokens.js +64 -20
- package/dist/apps/data/routes/verified-tokens.js.map +1 -1
- package/dist/apps/data/routes/webhooks.d.ts +1210 -70
- package/dist/apps/data/routes/webhooks.d.ts.map +1 -1
- package/dist/apps/data/routes/webhooks.js +301 -163
- package/dist/apps/data/routes/webhooks.js.map +1 -1
- package/dist/apps/data/routes/zones.d.ts.map +1 -1
- package/dist/apps/data/routes/zones.js +20 -12
- package/dist/apps/data/routes/zones.js.map +1 -1
- package/dist/apps/docs/reference.js +2 -2
- package/dist/apps/docs/reference.js.map +1 -1
- package/dist/apps/index.d.ts +1 -1
- package/dist/apps/index.d.ts.map +1 -1
- package/dist/apps/index.js +1 -1
- package/dist/apps/index.js.map +1 -1
- package/dist/apps/management/App.d.ts +4119 -3297
- package/dist/apps/management/App.d.ts.map +1 -1
- package/dist/apps/management/App.js +5 -14
- package/dist/apps/management/App.js.map +1 -1
- package/dist/apps/management/Billing.d.ts +49 -8
- package/dist/apps/management/Billing.d.ts.map +1 -1
- package/dist/apps/management/Billing.js +221 -26
- package/dist/apps/management/Billing.js.map +1 -1
- package/dist/apps/management/routes/api-keys.d.ts +174 -72
- package/dist/apps/management/routes/api-keys.d.ts.map +1 -1
- package/dist/apps/management/routes/api-keys.js +43 -15
- package/dist/apps/management/routes/api-keys.js.map +1 -1
- package/dist/apps/management/routes/billing.d.ts +364 -78
- package/dist/apps/management/routes/billing.d.ts.map +1 -1
- package/dist/apps/management/routes/billing.js +274 -49
- package/dist/apps/management/routes/billing.js.map +1 -1
- package/dist/apps/management/routes/faucet.d.ts +6 -6
- package/dist/apps/management/routes/faucet.js +1 -1
- package/dist/apps/management/routes/faucet.js.map +1 -1
- package/dist/apps/management/routes/invitations.d.ts +99 -24
- package/dist/apps/management/routes/invitations.d.ts.map +1 -1
- package/dist/apps/management/routes/invitations.js +117 -13
- package/dist/apps/management/routes/invitations.js.map +1 -1
- package/dist/apps/management/routes/invite-links.d.ts +42 -42
- package/dist/apps/management/routes/me.d.ts.map +1 -1
- package/dist/apps/management/routes/me.js +6 -2
- package/dist/apps/management/routes/me.js.map +1 -1
- package/dist/apps/management/routes/members.d.ts +16 -16
- package/dist/apps/management/routes/orgs.d.ts +36 -20
- package/dist/apps/management/routes/orgs.d.ts.map +1 -1
- package/dist/apps/management/routes/orgs.js +52 -12
- package/dist/apps/management/routes/orgs.js.map +1 -1
- package/dist/apps/management/routes/projects.d.ts +40 -40
- package/dist/apps/management/routes/projects.d.ts.map +1 -1
- package/dist/apps/management/routes/projects.js +6 -1
- package/dist/apps/management/routes/projects.js.map +1 -1
- package/dist/apps/management/routes/scopes.d.ts.map +1 -1
- package/dist/apps/management/routes/scopes.js +4 -1
- package/dist/apps/management/routes/scopes.js.map +1 -1
- package/dist/apps/management/routes/usage.d.ts +8 -8
- package/dist/apps/management/routes/usage.js +21 -4
- package/dist/apps/management/routes/usage.js.map +1 -1
- package/dist/apps/management/routes/verified-token-requests.d.ts +16 -16
- package/dist/apps/management/routes/webhooks.d.ts +931 -215
- package/dist/apps/management/routes/webhooks.d.ts.map +1 -1
- package/dist/apps/management/routes/webhooks.js +71 -25
- package/dist/apps/management/routes/webhooks.js.map +1 -1
- package/dist/apps/mcp.d.ts +1 -1
- package/dist/apps/mcp.js +7 -7
- package/dist/apps/mcp.js.map +1 -1
- package/dist/apps/mpp/App.d.ts.map +1 -1
- package/dist/apps/mpp/App.js +35 -7
- package/dist/apps/mpp/App.js.map +1 -1
- package/dist/apps/mpp/internal/Adapter.d.ts +2 -0
- package/dist/apps/mpp/internal/Adapter.d.ts.map +1 -1
- package/dist/apps/mpp/internal/Adapter.js +30 -1
- package/dist/apps/mpp/internal/Adapter.js.map +1 -1
- package/dist/apps/mpp/internal/Policy.d.ts +22 -4
- package/dist/apps/mpp/internal/Policy.d.ts.map +1 -1
- package/dist/apps/mpp/internal/Policy.js +24 -6
- package/dist/apps/mpp/internal/Policy.js.map +1 -1
- package/dist/apps/mpp/internal/Sponsorship.d.ts +3 -0
- package/dist/apps/mpp/internal/Sponsorship.d.ts.map +1 -1
- package/dist/apps/mpp/internal/Sponsorship.js +6 -3
- package/dist/apps/mpp/internal/Sponsorship.js.map +1 -1
- package/dist/apps/relay/App.d.ts +2 -0
- package/dist/apps/relay/App.d.ts.map +1 -1
- package/dist/apps/relay/App.js +177 -26
- package/dist/apps/relay/App.js.map +1 -1
- package/dist/apps/relay/Sponsorships.d.ts +5 -3
- package/dist/apps/relay/Sponsorships.d.ts.map +1 -1
- package/dist/apps/relay/Sponsorships.js +232 -25
- package/dist/apps/relay/Sponsorships.js.map +1 -1
- package/dist/apps/{funding → routes}/Access.d.ts +4 -4
- package/dist/apps/routes/Access.d.ts.map +1 -0
- package/dist/apps/{funding → routes}/Access.js +4 -4
- package/dist/apps/routes/Access.js.map +1 -0
- package/dist/apps/{funding → routes}/App.d.ts +841 -136
- package/dist/apps/{funding → routes}/App.d.ts.map +1 -1
- package/dist/apps/{funding → routes}/App.js +17 -17
- package/dist/apps/routes/App.js.map +1 -0
- package/dist/apps/routes/Inventory.d.ts.map +1 -0
- package/dist/apps/{funding → routes}/Inventory.js +2 -2
- package/dist/apps/routes/Inventory.js.map +1 -0
- package/dist/apps/routes/index.d.ts +2 -0
- package/dist/apps/routes/index.d.ts.map +1 -0
- package/dist/apps/routes/index.js +2 -0
- package/dist/apps/routes/index.js.map +1 -0
- package/dist/apps/{funding → routes}/routes/chains.d.ts +7 -7
- package/dist/apps/routes/routes/chains.d.ts.map +1 -0
- package/dist/apps/{funding → routes}/routes/chains.js +25 -25
- package/dist/apps/routes/routes/chains.js.map +1 -0
- package/dist/apps/{funding → routes}/routes/deposit-addresses.d.ts +123 -59
- package/dist/apps/routes/routes/deposit-addresses.d.ts.map +1 -0
- package/dist/apps/{funding → routes}/routes/deposit-addresses.js +498 -223
- package/dist/apps/routes/routes/deposit-addresses.js.map +1 -0
- package/dist/apps/{funding → routes}/routes/providers.d.ts +8 -8
- package/dist/apps/routes/routes/providers.d.ts.map +1 -0
- package/dist/apps/routes/routes/providers.js +57 -0
- package/dist/apps/routes/routes/providers.js.map +1 -0
- package/dist/apps/{funding → routes}/routes/quotes.d.ts +19 -16
- package/dist/apps/routes/routes/quotes.d.ts.map +1 -0
- package/dist/apps/{funding → routes}/routes/quotes.js +55 -38
- package/dist/apps/routes/routes/quotes.js.map +1 -0
- package/dist/apps/{funding → routes}/routes/transfers.d.ts +957 -71
- package/dist/apps/routes/routes/transfers.d.ts.map +1 -0
- package/dist/apps/routes/routes/transfers.js +1140 -0
- package/dist/apps/routes/routes/transfers.js.map +1 -0
- package/dist/cli/Cli.d.ts +30 -0
- package/dist/cli/Cli.d.ts.map +1 -1
- package/dist/cli/commands/admin.d.ts +36 -0
- package/dist/cli/commands/admin.d.ts.map +1 -1
- package/dist/cli/commands/admin.js +273 -0
- package/dist/cli/commands/admin.js.map +1 -1
- package/dist/cloudflare.d.ts +16 -14
- package/dist/cloudflare.d.ts.map +1 -1
- package/dist/cloudflare.js +26 -21
- package/dist/cloudflare.js.map +1 -1
- package/dist/db/Db.d.ts +63 -21
- package/dist/db/Db.d.ts.map +1 -1
- package/dist/db/Db.js +1052 -15
- package/dist/db/Db.js.map +1 -1
- package/dist/db/Schema.d.ts +785 -133
- package/dist/db/Schema.d.ts.map +1 -1
- package/dist/db/Schema.js +590 -162
- package/dist/db/Schema.js.map +1 -1
- package/dist/db/tables/apiKeyAdmissionBootstraps.d.ts +4 -0
- package/dist/db/tables/apiKeyAdmissionBootstraps.d.ts.map +1 -0
- package/dist/db/tables/apiKeyAdmissionBootstraps.js +2 -0
- package/dist/db/tables/apiKeyAdmissionBootstraps.js.map +1 -0
- package/dist/db/tables/apiKeyAdmissions.d.ts +73 -0
- package/dist/db/tables/apiKeyAdmissions.d.ts.map +1 -0
- package/dist/db/tables/apiKeyAdmissions.js +142 -0
- package/dist/db/tables/apiKeyAdmissions.js.map +1 -0
- package/dist/db/tables/apiKeyOwnerAdmissions.d.ts +4 -0
- package/dist/db/tables/apiKeyOwnerAdmissions.d.ts.map +1 -0
- package/dist/db/tables/apiKeyOwnerAdmissions.js +2 -0
- package/dist/db/tables/apiKeyOwnerAdmissions.js.map +1 -0
- package/dist/db/tables/apiKeyOwnerTombstones.d.ts +20 -0
- package/dist/db/tables/apiKeyOwnerTombstones.d.ts.map +1 -0
- package/dist/db/tables/apiKeyOwnerTombstones.js +57 -0
- package/dist/db/tables/apiKeyOwnerTombstones.js.map +1 -0
- package/dist/db/tables/apiKeyRevocations.d.ts +21 -0
- package/dist/db/tables/apiKeyRevocations.d.ts.map +1 -0
- package/dist/db/tables/apiKeyRevocations.js +98 -0
- package/dist/db/tables/apiKeyRevocations.js.map +1 -0
- package/dist/db/tables/authAccounts.d.ts +47 -0
- package/dist/db/tables/authAccounts.d.ts.map +1 -0
- package/dist/db/tables/authAccounts.js +72 -0
- package/dist/db/tables/authAccounts.js.map +1 -0
- package/dist/db/tables/authSessions.d.ts +12 -0
- package/dist/db/tables/authSessions.d.ts.map +1 -0
- package/dist/db/tables/authSessions.js +2 -0
- package/dist/db/tables/authSessions.js.map +1 -0
- package/dist/db/tables/authVerifications.d.ts +12 -0
- package/dist/db/tables/authVerifications.d.ts.map +1 -0
- package/dist/db/tables/authVerifications.js +2 -0
- package/dist/db/tables/authVerifications.js.map +1 -0
- package/dist/db/tables/invitations.d.ts +17 -1
- package/dist/db/tables/invitations.d.ts.map +1 -1
- package/dist/db/tables/invitations.js +123 -43
- package/dist/db/tables/invitations.js.map +1 -1
- package/dist/db/tables/memberships.d.ts +8 -0
- package/dist/db/tables/memberships.d.ts.map +1 -1
- package/dist/db/tables/memberships.js +51 -2
- package/dist/db/tables/memberships.js.map +1 -1
- package/dist/db/tables/organizations.d.ts +51 -5
- package/dist/db/tables/organizations.d.ts.map +1 -1
- package/dist/db/tables/organizations.js +135 -47
- package/dist/db/tables/organizations.js.map +1 -1
- package/dist/db/tables/projects.d.ts +27 -1
- package/dist/db/tables/projects.d.ts.map +1 -1
- package/dist/db/tables/projects.js +38 -3
- package/dist/db/tables/projects.js.map +1 -1
- package/dist/db/tables/requestUsage.d.ts.map +1 -1
- package/dist/db/tables/requestUsage.js.map +1 -1
- package/dist/db/tables/rewardAccounts.d.ts +86 -0
- package/dist/db/tables/rewardAccounts.d.ts.map +1 -0
- package/dist/db/tables/rewardAccounts.js +88 -0
- package/dist/db/tables/rewardAccounts.js.map +1 -0
- package/dist/db/tables/rewardCampaignDistributors.d.ts +36 -0
- package/dist/db/tables/rewardCampaignDistributors.d.ts.map +1 -0
- package/dist/db/tables/rewardCampaignDistributors.js +30 -0
- package/dist/db/tables/rewardCampaignDistributors.js.map +1 -0
- package/dist/db/tables/rewardCampaigns.d.ts +171 -0
- package/dist/db/tables/rewardCampaigns.d.ts.map +1 -0
- package/dist/db/tables/rewardCampaigns.js +392 -0
- package/dist/db/tables/rewardCampaigns.js.map +1 -0
- package/dist/db/tables/rewardCredits.d.ts +53 -0
- package/dist/db/tables/rewardCredits.d.ts.map +1 -0
- package/dist/db/tables/rewardCredits.js +63 -0
- package/dist/db/tables/rewardCredits.js.map +1 -0
- package/dist/db/tables/rewardEligibilityAssociations.d.ts +61 -0
- package/dist/db/tables/rewardEligibilityAssociations.d.ts.map +1 -0
- package/dist/db/tables/rewardEligibilityAssociations.js +103 -0
- package/dist/db/tables/rewardEligibilityAssociations.js.map +1 -0
- package/dist/db/tables/rewardRuns.d.ts +188 -0
- package/dist/db/tables/rewardRuns.d.ts.map +1 -0
- package/dist/db/tables/rewardRuns.js +278 -0
- package/dist/db/tables/rewardRuns.js.map +1 -0
- package/dist/db/tables/rewardTransactionAttempts.d.ts +100 -0
- package/dist/db/tables/rewardTransactionAttempts.d.ts.map +1 -0
- package/dist/db/tables/rewardTransactionAttempts.js +163 -0
- package/dist/db/tables/rewardTransactionAttempts.js.map +1 -0
- package/dist/db/tables/routesCatalog.d.ts +58 -0
- package/dist/db/tables/routesCatalog.d.ts.map +1 -0
- package/dist/db/tables/{fundingCatalog.js → routesCatalog.js} +19 -19
- package/dist/db/tables/routesCatalog.js.map +1 -0
- package/dist/db/tables/routesDepositAddresses.d.ts +476 -0
- package/dist/db/tables/routesDepositAddresses.d.ts.map +1 -0
- package/dist/db/tables/routesDepositAddresses.js +587 -0
- package/dist/db/tables/routesDepositAddresses.js.map +1 -0
- package/dist/db/tables/{fundingDepositRequestObservations.d.ts → routesDepositRequestObservations.d.ts} +6 -6
- package/dist/db/tables/routesDepositRequestObservations.d.ts.map +1 -0
- package/dist/db/tables/{fundingDepositRequestObservations.js → routesDepositRequestObservations.js} +6 -6
- package/dist/db/tables/routesDepositRequestObservations.js.map +1 -0
- package/dist/db/tables/{fundingDeposits.d.ts → routesDeposits.d.ts} +210 -22
- package/dist/db/tables/routesDeposits.d.ts.map +1 -0
- package/dist/db/tables/routesDeposits.js +576 -0
- package/dist/db/tables/routesDeposits.js.map +1 -0
- package/dist/db/tables/routesIdempotency.d.ts +166 -0
- package/dist/db/tables/routesIdempotency.d.ts.map +1 -0
- package/dist/db/tables/routesIdempotency.js +330 -0
- package/dist/db/tables/routesIdempotency.js.map +1 -0
- package/dist/db/tables/routesSubsidies.d.ts +27 -0
- package/dist/db/tables/routesSubsidies.d.ts.map +1 -0
- package/dist/db/tables/routesSubsidies.js +45 -0
- package/dist/db/tables/routesSubsidies.js.map +1 -0
- package/dist/db/tables/{fundingTransferEvents.d.ts → routesTransferEvents.d.ts} +3 -3
- package/dist/db/tables/routesTransferEvents.d.ts.map +1 -0
- package/dist/db/tables/{fundingTransferEvents.js → routesTransferEvents.js} +3 -3
- package/dist/db/tables/routesTransferEvents.js.map +1 -0
- package/dist/db/tables/routesTransferSubsidies.d.ts +19 -0
- package/dist/db/tables/routesTransferSubsidies.d.ts.map +1 -0
- package/dist/db/tables/routesTransferSubsidies.js +17 -0
- package/dist/db/tables/routesTransferSubsidies.js.map +1 -0
- package/dist/db/tables/routesTransferSubsidyNonces.d.ts +51 -0
- package/dist/db/tables/routesTransferSubsidyNonces.d.ts.map +1 -0
- package/dist/db/tables/routesTransferSubsidyNonces.js +82 -0
- package/dist/db/tables/routesTransferSubsidyNonces.js.map +1 -0
- package/dist/db/tables/routesTransferTransactions.d.ts +77 -0
- package/dist/db/tables/routesTransferTransactions.d.ts.map +1 -0
- package/dist/db/tables/routesTransferTransactions.js +86 -0
- package/dist/db/tables/routesTransferTransactions.js.map +1 -0
- package/dist/db/tables/routesTransfers.d.ts +319 -0
- package/dist/db/tables/routesTransfers.d.ts.map +1 -0
- package/dist/db/tables/routesTransfers.js +372 -0
- package/dist/db/tables/routesTransfers.js.map +1 -0
- package/dist/db/tables/sponsoredTransactions.d.ts +112 -13
- package/dist/db/tables/sponsoredTransactions.d.ts.map +1 -1
- package/dist/db/tables/sponsoredTransactions.js +241 -38
- package/dist/db/tables/sponsoredTransactions.js.map +1 -1
- package/dist/db/tables/sponsorshipAttributions.d.ts +69 -0
- package/dist/db/tables/sponsorshipAttributions.d.ts.map +1 -0
- package/dist/db/tables/sponsorshipAttributions.js +77 -0
- package/dist/db/tables/sponsorshipAttributions.js.map +1 -0
- package/dist/db/tables/sponsorshipReconciliationCursors.d.ts +22 -0
- package/dist/db/tables/sponsorshipReconciliationCursors.d.ts.map +1 -0
- package/dist/db/tables/sponsorshipReconciliationCursors.js +45 -0
- package/dist/db/tables/sponsorshipReconciliationCursors.js.map +1 -0
- package/dist/db/tables/stripeCustomers.d.ts +11 -0
- package/dist/db/tables/stripeCustomers.d.ts.map +1 -1
- package/dist/db/tables/stripeCustomers.js +13 -0
- package/dist/db/tables/stripeCustomers.js.map +1 -1
- package/dist/db/tables/users.d.ts +17 -1
- package/dist/db/tables/users.d.ts.map +1 -1
- package/dist/db/tables/users.js +47 -2
- package/dist/db/tables/users.js.map +1 -1
- package/dist/db/tables/webhookQueueEvents.d.ts.map +1 -1
- package/dist/db/tables/webhookQueueEvents.js +5 -1
- package/dist/db/tables/webhookQueueEvents.js.map +1 -1
- package/dist/db/tables/webhookSubscriptions.d.ts +22 -10
- package/dist/db/tables/webhookSubscriptions.d.ts.map +1 -1
- package/dist/db/tables/webhookSubscriptions.js +50 -15
- package/dist/db/tables/webhookSubscriptions.js.map +1 -1
- package/dist/handlers/internal/executionError.d.ts +2 -2
- package/dist/handlers/internal/executionError.d.ts.map +1 -1
- package/dist/handlers/internal/executionError.js +1 -2
- package/dist/handlers/internal/executionError.js.map +1 -1
- package/dist/handlers/internal/multisig.d.ts +4 -232
- package/dist/handlers/internal/multisig.d.ts.map +1 -1
- package/dist/handlers/internal/multisig.js +11 -537
- package/dist/handlers/internal/multisig.js.map +1 -1
- package/dist/handlers/internal/sponsorship.d.ts +19 -8
- package/dist/handlers/internal/sponsorship.d.ts.map +1 -1
- package/dist/handlers/internal/sponsorship.js +13 -9
- package/dist/handlers/internal/sponsorship.js.map +1 -1
- package/dist/handlers/relay.d.ts +9 -12
- package/dist/handlers/relay.d.ts.map +1 -1
- package/dist/handlers/relay.js +81 -85
- package/dist/handlers/relay.js.map +1 -1
- package/dist/index.d.ts +0 -17
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +0 -17
- package/dist/index.js.map +1 -1
- package/dist/internal/AssetResponse.d.ts +12 -0
- package/dist/internal/AssetResponse.d.ts.map +1 -0
- package/dist/internal/AssetResponse.js +21 -0
- package/dist/internal/AssetResponse.js.map +1 -0
- package/dist/internal/Auth.d.ts +48 -12
- package/dist/internal/Auth.d.ts.map +1 -1
- package/dist/internal/Auth.js +603 -175
- package/dist/internal/Auth.js.map +1 -1
- package/dist/internal/BetterAuth.d.ts +1488 -0
- package/dist/internal/BetterAuth.d.ts.map +1 -0
- package/dist/internal/BetterAuth.js +253 -0
- package/dist/internal/BetterAuth.js.map +1 -0
- package/dist/internal/Cache.d.ts +2 -0
- package/dist/internal/Cache.d.ts.map +1 -1
- package/dist/internal/Cache.js +2 -0
- package/dist/internal/Cache.js.map +1 -1
- package/dist/internal/EarnRates.d.ts +26 -3
- package/dist/internal/EarnRates.d.ts.map +1 -1
- package/dist/internal/EarnRates.js +84 -19
- package/dist/internal/EarnRates.js.map +1 -1
- package/dist/internal/EarnSharePrices.d.ts +120 -0
- package/dist/internal/EarnSharePrices.d.ts.map +1 -0
- package/dist/internal/EarnSharePrices.js +179 -0
- package/dist/internal/EarnSharePrices.js.map +1 -0
- package/dist/internal/EarnVaults.d.ts +4 -0
- package/dist/internal/EarnVaults.d.ts.map +1 -1
- package/dist/internal/EarnVaults.js +31 -14
- package/dist/internal/EarnVaults.js.map +1 -1
- package/dist/internal/Email.d.ts +37 -0
- package/dist/internal/Email.d.ts.map +1 -0
- package/dist/internal/Email.js +16 -0
- package/dist/internal/Email.js.map +1 -0
- package/dist/internal/Log.d.ts +32 -28
- package/dist/internal/Log.d.ts.map +1 -1
- package/dist/internal/Log.js +18 -11
- package/dist/internal/Log.js.map +1 -1
- package/dist/internal/MetricSink.d.ts +3 -0
- package/dist/internal/MetricSink.d.ts.map +1 -1
- package/dist/internal/MetricSink.js +67 -8
- package/dist/internal/MetricSink.js.map +1 -1
- package/dist/internal/Mpp.d.ts.map +1 -1
- package/dist/internal/Mpp.js +20 -25
- package/dist/internal/Mpp.js.map +1 -1
- package/dist/internal/OpenApi.d.ts +26 -3
- package/dist/internal/OpenApi.d.ts.map +1 -1
- package/dist/internal/OpenApi.js +25 -10
- package/dist/internal/OpenApi.js.map +1 -1
- package/dist/internal/Provider.d.ts +1 -1
- package/dist/internal/Provider.d.ts.map +1 -1
- package/dist/internal/RateLimit.d.ts.map +1 -1
- package/dist/internal/RateLimit.js +13 -1
- package/dist/internal/RateLimit.js.map +1 -1
- package/dist/internal/Store.d.ts +16 -0
- package/dist/internal/Store.d.ts.map +1 -1
- package/dist/internal/Store.js +59 -8
- package/dist/internal/Store.js.map +1 -1
- package/dist/internal/Tidx.d.ts +9 -2
- package/dist/internal/Tidx.d.ts.map +1 -1
- package/dist/internal/Tidx.js +78 -11
- package/dist/internal/Tidx.js.map +1 -1
- package/dist/internal/Timing.d.ts +26 -0
- package/dist/internal/Timing.d.ts.map +1 -1
- package/dist/internal/Timing.js +63 -5
- package/dist/internal/Timing.js.map +1 -1
- package/dist/internal/VercelOidc.d.ts +94 -0
- package/dist/internal/VercelOidc.d.ts.map +1 -0
- package/dist/internal/VercelOidc.js +128 -0
- package/dist/internal/VercelOidc.js.map +1 -0
- package/dist/internal/VerifiedTokens.d.ts +2 -8
- package/dist/internal/VerifiedTokens.d.ts.map +1 -1
- package/dist/internal/VerifiedTokens.js +24 -24
- package/dist/internal/VerifiedTokens.js.map +1 -1
- package/dist/internal/Viem.d.ts +46 -2068
- package/dist/internal/Viem.d.ts.map +1 -1
- package/dist/internal/Viem.js +171 -11
- package/dist/internal/Viem.js.map +1 -1
- package/dist/internal/Webhooks.d.ts +12 -4
- package/dist/internal/Webhooks.d.ts.map +1 -1
- package/dist/internal/Webhooks.js +9 -3
- package/dist/internal/Webhooks.js.map +1 -1
- package/dist/internal/ZoneRpc.d.ts +7 -0
- package/dist/internal/ZoneRpc.d.ts.map +1 -0
- package/dist/internal/ZoneRpc.js +49 -0
- package/dist/internal/ZoneRpc.js.map +1 -0
- package/dist/internal/index.d.ts +3 -1
- package/dist/internal/index.d.ts.map +1 -1
- package/dist/internal/index.js +3 -1
- package/dist/internal/index.js.map +1 -1
- package/dist/internal/rewards/Audit.d.ts +88 -0
- package/dist/internal/rewards/Audit.d.ts.map +1 -0
- package/dist/internal/rewards/Audit.js +134 -0
- package/dist/internal/rewards/Audit.js.map +1 -0
- package/dist/internal/rewards/Campaigns.d.ts +572 -0
- package/dist/internal/rewards/Campaigns.d.ts.map +1 -0
- package/dist/internal/rewards/Campaigns.js +531 -0
- package/dist/internal/rewards/Campaigns.js.map +1 -0
- package/dist/internal/rewards/Credits.d.ts +76 -0
- package/dist/internal/rewards/Credits.d.ts.map +1 -0
- package/dist/internal/rewards/Credits.js +95 -0
- package/dist/internal/rewards/Credits.js.map +1 -0
- package/dist/internal/rewards/Events.d.ts +100 -0
- package/dist/internal/rewards/Events.d.ts.map +1 -0
- package/dist/internal/rewards/Events.js +340 -0
- package/dist/internal/rewards/Events.js.map +1 -0
- package/dist/internal/rewards/Projection.d.ts +237 -0
- package/dist/internal/rewards/Projection.d.ts.map +1 -0
- package/dist/internal/rewards/Projection.js +616 -0
- package/dist/internal/rewards/Projection.js.map +1 -0
- package/dist/internal/rewards/Rates.d.ts +44 -0
- package/dist/internal/rewards/Rates.d.ts.map +1 -0
- package/dist/internal/rewards/Rates.js +60 -0
- package/dist/internal/rewards/Rates.js.map +1 -0
- package/dist/internal/rewards/Read.d.ts +158 -0
- package/dist/internal/rewards/Read.d.ts.map +1 -0
- package/dist/internal/rewards/Read.js +292 -0
- package/dist/internal/rewards/Read.js.map +1 -0
- package/dist/internal/rewards/Runner.d.ts +164 -0
- package/dist/internal/rewards/Runner.d.ts.map +1 -0
- package/dist/internal/rewards/Runner.js +1778 -0
- package/dist/internal/rewards/Runner.js.map +1 -0
- package/dist/internal/rewards/Signer.d.ts +224 -0
- package/dist/internal/rewards/Signer.d.ts.map +1 -0
- package/dist/internal/rewards/Signer.js +135 -0
- package/dist/internal/rewards/Signer.js.map +1 -0
- package/dist/internal/rewards/index.d.ts +15 -0
- package/dist/internal/rewards/index.d.ts.map +1 -0
- package/dist/internal/rewards/index.js +15 -0
- package/dist/internal/rewards/index.js.map +1 -0
- package/dist/internal/{funding → routes}/Action.d.ts +12 -1
- package/dist/internal/routes/Action.d.ts.map +1 -0
- package/dist/internal/{funding → routes}/Action.js +17 -9
- package/dist/internal/routes/Action.js.map +1 -0
- package/dist/internal/{funding → routes}/Catalog.d.ts +20 -20
- package/dist/internal/routes/Catalog.d.ts.map +1 -0
- package/dist/internal/{funding → routes}/Catalog.js +29 -29
- package/dist/internal/routes/Catalog.js.map +1 -0
- package/dist/internal/{funding → routes}/Chain.d.ts +10 -10
- package/dist/internal/routes/Chain.d.ts.map +1 -0
- package/dist/internal/{funding → routes}/Chain.js +3 -3
- package/dist/internal/routes/Chain.js.map +1 -0
- package/dist/internal/{funding → routes}/Deposit.d.ts +45 -23
- package/dist/internal/routes/Deposit.d.ts.map +1 -0
- package/dist/internal/{funding → routes}/Deposit.js +60 -27
- package/dist/internal/routes/Deposit.js.map +1 -0
- package/dist/internal/{funding → routes}/DepositAddress.d.ts +56 -27
- package/dist/internal/routes/DepositAddress.d.ts.map +1 -0
- package/dist/internal/{funding → routes}/DepositAddress.js +95 -33
- package/dist/internal/routes/DepositAddress.js.map +1 -0
- package/dist/internal/{funding → routes}/DepositWebhook.d.ts +4 -4
- package/dist/internal/routes/DepositWebhook.d.ts.map +1 -0
- package/dist/internal/{funding → routes}/DepositWebhook.js +4 -3
- package/dist/internal/routes/DepositWebhook.js.map +1 -0
- package/dist/internal/routes/Economics.d.ts +25 -0
- package/dist/internal/routes/Economics.d.ts.map +1 -0
- package/dist/internal/routes/Economics.js +28 -0
- package/dist/internal/routes/Economics.js.map +1 -0
- package/dist/internal/{funding → routes}/Evidence.d.ts +3 -3
- package/dist/internal/routes/Evidence.d.ts.map +1 -0
- package/dist/internal/{funding → routes}/Evidence.js +9 -17
- package/dist/internal/routes/Evidence.js.map +1 -0
- package/dist/internal/routes/Observability.d.ts +154 -0
- package/dist/internal/routes/Observability.d.ts.map +1 -0
- package/dist/internal/routes/Observability.js +389 -0
- package/dist/internal/routes/Observability.js.map +1 -0
- package/dist/internal/{funding → routes}/Provider.d.ts +350 -104
- package/dist/internal/routes/Provider.d.ts.map +1 -0
- package/dist/internal/{funding → routes}/Provider.js +233 -97
- package/dist/internal/routes/Provider.js.map +1 -0
- package/dist/internal/{funding → routes}/Reconciliation.d.ts +11 -6
- package/dist/internal/routes/Reconciliation.d.ts.map +1 -0
- package/dist/internal/{funding → routes}/Reconciliation.js +408 -158
- package/dist/internal/routes/Reconciliation.js.map +1 -0
- package/dist/internal/routes/Route.d.ts +21 -0
- package/dist/internal/routes/Route.d.ts.map +1 -0
- package/dist/internal/{funding → routes}/Route.js +1 -1
- package/dist/internal/routes/Route.js.map +1 -0
- package/dist/internal/{funding → routes}/SourceObservation.d.ts +6 -6
- package/dist/internal/routes/SourceObservation.d.ts.map +1 -0
- package/dist/internal/{funding → routes}/SourceObservation.js +13 -15
- package/dist/internal/routes/SourceObservation.js.map +1 -0
- package/dist/internal/{funding → routes}/Subsidy.d.ts +48 -3
- package/dist/internal/routes/Subsidy.d.ts.map +1 -0
- package/dist/internal/{funding → routes}/Subsidy.js +43 -3
- package/dist/internal/routes/Subsidy.js.map +1 -0
- package/dist/internal/{funding → routes}/Token.d.ts +4 -4
- package/dist/internal/routes/Token.d.ts.map +1 -0
- package/dist/internal/{funding → routes}/Token.js +3 -3
- package/dist/internal/routes/Token.js.map +1 -0
- package/dist/internal/{funding → routes}/Transfer.d.ts +324 -34
- package/dist/internal/routes/Transfer.d.ts.map +1 -0
- package/dist/internal/routes/Transfer.js +728 -0
- package/dist/internal/routes/Transfer.js.map +1 -0
- package/dist/internal/routes/TransferReconciliation.d.ts +55 -0
- package/dist/internal/routes/TransferReconciliation.d.ts.map +1 -0
- package/dist/internal/routes/TransferReconciliation.js +422 -0
- package/dist/internal/routes/TransferReconciliation.js.map +1 -0
- package/dist/internal/routes/TransferSubsidy.d.ts +201 -0
- package/dist/internal/routes/TransferSubsidy.d.ts.map +1 -0
- package/dist/internal/routes/TransferSubsidy.js +256 -0
- package/dist/internal/routes/TransferSubsidy.js.map +1 -0
- package/dist/internal/routes/TransferWebhook.d.ts +21 -0
- package/dist/internal/routes/TransferWebhook.d.ts.map +1 -0
- package/dist/internal/routes/TransferWebhook.js +43 -0
- package/dist/internal/routes/TransferWebhook.js.map +1 -0
- package/dist/internal/{funding → routes}/index.d.ts +3 -0
- package/dist/internal/routes/index.d.ts.map +1 -0
- package/dist/internal/{funding → routes}/index.js +3 -0
- package/dist/internal/routes/index.js.map +1 -0
- package/dist/internal/{funding → routes}/providers/across.d.ts +4 -4
- package/dist/internal/routes/providers/across.d.ts.map +1 -0
- package/dist/internal/{funding → routes}/providers/across.js +13 -13
- package/dist/internal/routes/providers/across.js.map +1 -0
- package/dist/internal/{funding → routes}/providers/relay.d.ts +21 -12
- package/dist/internal/routes/providers/relay.d.ts.map +1 -0
- package/dist/internal/{funding → routes}/providers/relay.js +197 -122
- package/dist/internal/routes/providers/relay.js.map +1 -0
- package/dist/internal/{funding → routes}/providers/rhino.d.ts +4 -4
- package/dist/internal/routes/providers/rhino.d.ts.map +1 -0
- package/dist/internal/{funding → routes}/providers/rhino.js +10 -10
- package/dist/internal/routes/providers/rhino.js.map +1 -0
- package/dist/internal/{funding → routes}/providers/squid.d.ts +4 -4
- package/dist/internal/routes/providers/squid.d.ts.map +1 -0
- package/dist/internal/{funding → routes}/providers/squid.js +14 -14
- package/dist/internal/routes/providers/squid.js.map +1 -0
- package/dist/internal/routes/providers/stargate.d.ts +165 -0
- package/dist/internal/routes/providers/stargate.d.ts.map +1 -0
- package/dist/internal/routes/providers/stargate.js +898 -0
- package/dist/internal/routes/providers/stargate.js.map +1 -0
- package/dist/internal/{funding → routes}/providers/symbiosis.d.ts +4 -4
- package/dist/internal/routes/providers/symbiosis.d.ts.map +1 -0
- package/dist/internal/{funding → routes}/providers/symbiosis.js +30 -20
- package/dist/internal/routes/providers/symbiosis.js.map +1 -0
- package/dist/internal/webhookDestinations/slack.d.ts.map +1 -1
- package/dist/internal/webhookDestinations/slack.js +22 -6
- package/dist/internal/webhookDestinations/slack.js.map +1 -1
- package/dist/providers/index.d.ts +12 -12
- package/dist/providers/index.d.ts.map +1 -1
- package/dist/providers/index.js +12 -12
- package/dist/providers/index.js.map +1 -1
- package/dist/server.d.ts +19 -0
- package/dist/server.d.ts.map +1 -0
- package/dist/server.js +19 -0
- package/dist/server.js.map +1 -0
- package/package.json +15 -4
- package/src/ApiKey.ts +1 -1
- package/src/ApiKeys.test.ts +1033 -3
- package/src/ApiKeys.ts +489 -48
- package/src/App.test-d.ts +1 -1
- package/src/App.test.ts +216 -25
- package/src/App.ts +335 -31
- package/src/Assets.test.ts +2 -2
- package/src/Assets.ts +3 -1
- package/src/Auth.test-d.ts +1 -1
- package/src/Client.test-d.ts +611 -101
- package/src/Handler.ts +0 -1
- package/src/OpenApi.contract.test.ts +195 -0
- package/src/Scope.ts +17 -5
- package/src/Webhooks.ts +2 -2
- package/src/admin/App.test.ts +30 -2
- package/src/admin/App.ts +42 -6
- package/src/admin/apps/api-keys.test.ts +267 -5
- package/src/admin/apps/api-keys.ts +100 -50
- package/src/admin/apps/earn-vaults.test.ts +158 -0
- package/src/admin/apps/earn-vaults.ts +681 -7
- package/src/admin/apps/organizations.test.ts +342 -1
- package/src/admin/apps/organizations.ts +368 -8
- package/src/admin/apps/routes-support.test.ts +200 -0
- package/src/admin/apps/routes-support.ts +201 -0
- package/src/admin/apps/routes.test.ts +450 -0
- package/src/admin/apps/routes.ts +896 -0
- package/src/admin/apps/scopes.test.ts +15 -5
- package/src/admin/apps/subsidies.test.ts +306 -0
- package/src/admin/apps/subsidies.ts +457 -0
- package/src/admin/apps/verified-tokens.test.ts +8 -3
- package/src/admin/apps/verified-tokens.ts +3 -3
- package/src/admin/ui/plugin.ts +1 -2
- package/src/admin/ui/src/components/RewardCampaignForm.tsx +1009 -0
- package/src/admin/ui/src/lib/config.ts +11 -2
- package/src/admin/ui/src/lib/earn-vaults.ts +2 -2
- package/src/admin/ui/src/lib/organizations.test.ts +147 -3
- package/src/admin/ui/src/lib/organizations.ts +136 -0
- package/src/admin/ui/src/lib/query-client.ts +1 -1
- package/src/admin/ui/src/lib/reward-campaigns.ts +136 -0
- package/src/admin/ui/src/lib/routes.test.ts +88 -0
- package/src/admin/ui/src/lib/routes.ts +304 -0
- package/src/admin/ui/src/lib/subsidies.ts +75 -0
- package/src/admin/ui/src/routeTree.gen.ts +63 -0
- package/src/admin/ui/src/routes/__root.tsx +12 -1
- package/src/admin/ui/src/routes/api-keys.tsx +196 -84
- package/src/admin/ui/src/routes/earn.vaults_.$vaultId.edit.tsx +105 -70
- package/src/admin/ui/src/routes/organizations_.$orgId.tsx +334 -2
- package/src/admin/ui/src/routes/routes.tsx +1615 -0
- package/src/admin/ui/src/routes/routes_.support.tsx +248 -0
- package/src/admin/ui/src/routes/subsidies.tsx +799 -0
- package/src/admin/ui.generated.ts +144 -69
- package/src/analytics/Analytics.test.ts +108 -18
- package/src/analytics/Analytics.ts +38 -6
- package/src/analytics/tables/requestEvents.test.ts +100 -0
- package/src/analytics/tables/requestEvents.ts +10 -1
- package/src/analytics/tables/routesLifecycleIntervals.ts +140 -0
- package/src/apps/Zones.test.ts +18 -3
- package/src/apps/Zones.ts +55 -8
- package/src/apps/composition.test.ts +68 -59
- package/src/apps/data/App.test.ts +154 -2
- package/src/apps/data/App.ts +102 -33
- package/src/apps/data/routes/activities.test.ts +419 -7
- package/src/apps/data/routes/activities.ts +683 -216
- package/src/apps/data/routes/balances.test.ts +2 -2
- package/src/apps/data/routes/blocks.test.ts +46 -1
- package/src/apps/data/routes/coingecko.test.ts +419 -1
- package/src/apps/data/routes/coingecko.ts +309 -253
- package/src/apps/data/routes/earn.discovery.test.ts +274 -0
- package/src/apps/data/routes/earn.test.ts +1661 -29
- package/src/apps/data/routes/earn.ts +2314 -328
- package/src/apps/data/routes/exchanges.test.ts +752 -30
- package/src/apps/data/routes/exchanges.ts +954 -753
- package/src/apps/data/routes/fee-amm.test.ts +224 -0
- package/src/apps/data/routes/fee-amm.ts +208 -178
- package/src/apps/data/routes/indexer.test.ts +389 -0
- package/src/apps/data/routes/indexer.ts +165 -69
- package/src/apps/data/routes/receipts.test.ts +1 -1
- package/src/apps/data/routes/rpc.test.ts +352 -8
- package/src/apps/data/routes/rpc.ts +407 -219
- package/src/apps/data/routes/rpc.zone.test.ts +340 -0
- package/src/apps/data/routes/tokenlist.test.ts +285 -0
- package/src/apps/data/routes/tokenlist.ts +173 -88
- package/src/apps/data/routes/tokens.test.ts +93 -3
- package/src/apps/data/routes/tokens.ts +39 -23
- package/src/apps/data/routes/transactions.test.ts +1 -1
- package/src/apps/data/routes/transfers.test.ts +56 -24
- package/src/apps/data/routes/transfers.ts +19 -8
- package/src/apps/data/routes/valuation.test.ts +1 -1
- package/src/apps/data/routes/verified-tokens.test.ts +345 -0
- package/src/apps/data/routes/verified-tokens.ts +99 -29
- package/src/apps/data/routes/webhooks.test.ts +659 -81
- package/src/apps/data/routes/webhooks.ts +1104 -817
- package/src/apps/data/routes/zones.test.ts +148 -71
- package/src/apps/data/routes/zones.ts +71 -55
- package/src/apps/docs/reference.ts +2 -2
- package/src/apps/index.ts +1 -1
- package/src/apps/management/App.ts +9 -51
- package/src/apps/management/Billing.test.ts +375 -14
- package/src/apps/management/Billing.ts +283 -34
- package/src/apps/management/routes/api-keys.test.ts +269 -7
- package/src/apps/management/routes/api-keys.ts +61 -20
- package/src/apps/management/routes/billing.test.ts +477 -15
- package/src/apps/management/routes/billing.ts +377 -50
- package/src/apps/management/routes/faucet.test.ts +1 -1
- package/src/apps/management/routes/faucet.ts +1 -1
- package/src/apps/management/routes/invitations.test.ts +270 -3
- package/src/apps/management/routes/invitations.ts +185 -15
- package/src/apps/management/routes/invoicePreview.test.ts +549 -0
- package/src/apps/management/routes/me.test.ts +246 -5
- package/src/apps/management/routes/me.ts +7 -2
- package/src/apps/management/routes/members.test.ts +108 -0
- package/src/apps/management/routes/orgs.test.ts +191 -3
- package/src/apps/management/routes/orgs.ts +58 -11
- package/src/apps/management/routes/projects.test.ts +33 -3
- package/src/apps/management/routes/projects.ts +6 -1
- package/src/apps/management/routes/scopes.test.ts +30 -2
- package/src/apps/management/routes/scopes.ts +4 -1
- package/src/apps/management/routes/usage.test.ts +32 -0
- package/src/apps/management/routes/usage.ts +22 -4
- package/src/apps/management/routes/webhooks.test.ts +49 -26
- package/src/apps/management/routes/webhooks.ts +93 -38
- package/src/apps/mcp.test.ts +6 -6
- package/src/apps/mcp.ts +7 -7
- package/src/apps/mpp/App.ts +37 -7
- package/src/apps/mpp/Mpp.test.ts +49 -8
- package/src/apps/mpp/Mpp.zone.test.ts +219 -0
- package/src/apps/mpp/internal/Adapter.ts +34 -0
- package/src/apps/mpp/internal/Policy.test.ts +86 -31
- package/src/apps/mpp/internal/Policy.ts +49 -7
- package/src/apps/mpp/internal/Sponsorship.test.ts +207 -0
- package/src/apps/mpp/internal/Sponsorship.ts +9 -3
- package/src/apps/relay/App.test.ts +1024 -38
- package/src/apps/relay/App.ts +228 -32
- package/src/apps/relay/App.zone-billing.test.ts +257 -0
- package/src/apps/relay/Sponsorships.test.ts +67 -4
- package/src/apps/relay/Sponsorships.ts +253 -29
- package/src/apps/relay/Sponsorships.zone.test.ts +102 -0
- package/src/apps/{funding → routes}/Access.ts +6 -6
- package/src/apps/routes/App.test.ts +165 -0
- package/src/apps/routes/App.ts +96 -0
- package/src/apps/{funding → routes}/Inventory.ts +2 -2
- package/src/apps/routes/index.ts +1 -0
- package/src/apps/{funding → routes}/routes/chains.test.ts +66 -66
- package/src/apps/{funding → routes}/routes/chains.ts +23 -23
- package/src/apps/{funding → routes}/routes/deposit-addresses.test.ts +1362 -462
- package/src/apps/{funding → routes}/routes/deposit-addresses.ts +568 -248
- package/src/apps/{funding → routes}/routes/providers.test.ts +27 -33
- package/src/apps/{funding → routes}/routes/providers.ts +23 -23
- package/src/apps/{funding → routes}/routes/quotes.test.ts +298 -41
- package/src/apps/{funding → routes}/routes/quotes.ts +57 -40
- package/src/apps/routes/routes/transfers.test.ts +2876 -0
- package/src/apps/routes/routes/transfers.ts +1332 -0
- package/src/cli/Cli.test.ts +1 -1
- package/src/cli/commands/admin.test.ts +748 -1
- package/src/cli/commands/admin.ts +278 -0
- package/src/cloudflare.ts +52 -47
- package/src/db/Db.test.ts +245 -2
- package/src/db/Db.ts +1511 -34
- package/src/db/Schema.ts +744 -228
- package/src/db/tables/apiKeyAdmissionBootstraps.ts +4 -0
- package/src/db/tables/apiKeyAdmissions.ts +218 -0
- package/src/db/tables/apiKeyOwnerAdmissions.ts +4 -0
- package/src/db/tables/apiKeyOwnerTombstones.ts +81 -0
- package/src/db/tables/apiKeyRevocations.test.ts +74 -0
- package/src/db/tables/apiKeyRevocations.ts +121 -0
- package/src/db/tables/authAccounts.ts +105 -0
- package/src/db/tables/authSessions.ts +13 -0
- package/src/db/tables/authVerifications.ts +13 -0
- package/src/db/tables/invitations.ts +142 -45
- package/src/db/tables/memberships.ts +79 -3
- package/src/db/tables/organizations.test.ts +725 -7
- package/src/db/tables/organizations.ts +182 -49
- package/src/db/tables/projects.test.ts +71 -0
- package/src/db/tables/projects.ts +59 -4
- package/src/db/tables/requestUsage.ts +4 -1
- package/src/db/tables/rewardAccounts.ts +178 -0
- package/src/db/tables/rewardCampaignDistributors.ts +68 -0
- package/src/db/tables/rewardCampaigns.test.ts +1388 -0
- package/src/db/tables/rewardCampaigns.ts +647 -0
- package/src/db/tables/rewardCredits.ts +110 -0
- package/src/db/tables/rewardEligibilityAssociations.test.ts +271 -0
- package/src/db/tables/rewardEligibilityAssociations.ts +184 -0
- package/src/db/tables/rewardRuns.ts +514 -0
- package/src/db/tables/rewardTransactionAttempts.ts +272 -0
- package/src/db/tables/routesCatalog.test.ts +185 -0
- package/src/db/tables/routesCatalog.ts +163 -0
- package/src/db/tables/routesDepositAddresses.test.ts +1048 -0
- package/src/db/tables/routesDepositAddresses.ts +1008 -0
- package/src/db/tables/{fundingDepositRequestObservations.test.ts → routesDepositRequestObservations.test.ts} +13 -14
- package/src/db/tables/{fundingDepositRequestObservations.ts → routesDepositRequestObservations.ts} +10 -10
- package/src/db/tables/{fundingDeposits.test.ts → routesDeposits.test.ts} +316 -46
- package/src/db/tables/routesDeposits.ts +1062 -0
- package/src/db/tables/routesIdempotency.test.ts +796 -0
- package/src/db/tables/routesIdempotency.ts +496 -0
- package/src/db/tables/routesSubsidies.test.ts +120 -0
- package/src/db/tables/routesSubsidies.ts +71 -0
- package/src/db/tables/{fundingTransferEvents.ts → routesTransferEvents.ts} +4 -4
- package/src/db/tables/routesTransferSubsidies.ts +38 -0
- package/src/db/tables/routesTransferSubsidyNonces.ts +124 -0
- package/src/db/tables/routesTransferTransactions.test.ts +195 -0
- package/src/db/tables/routesTransferTransactions.ts +158 -0
- package/src/db/tables/routesTransfers.test.ts +338 -0
- package/src/db/tables/routesTransfers.ts +662 -0
- package/src/db/tables/sponsoredTransactions.test.ts +563 -1
- package/src/db/tables/sponsoredTransactions.ts +386 -42
- package/src/db/tables/sponsorshipAttributions.test.ts +160 -0
- package/src/db/tables/sponsorshipAttributions.ts +168 -0
- package/src/db/tables/sponsorshipReconciliationCursors.test.ts +115 -0
- package/src/db/tables/sponsorshipReconciliationCursors.ts +67 -0
- package/src/db/tables/stripeCustomers.test.ts +85 -0
- package/src/db/tables/stripeCustomers.ts +24 -0
- package/src/db/tables/users.test.ts +129 -0
- package/src/db/tables/users.ts +49 -3
- package/src/db/tables/webhookQueueEvents.ts +8 -1
- package/src/db/tables/webhookSubscriptions.ts +103 -21
- package/src/handlers/internal/executionError.ts +3 -4
- package/src/handlers/internal/multisig.ts +13 -816
- package/src/handlers/internal/sponsorship.ts +26 -10
- package/src/handlers/relay.test-d.ts +9 -1
- package/src/handlers/relay.test.ts +823 -3
- package/src/handlers/relay.ts +127 -107
- package/src/index.test-d.ts +7 -0
- package/src/index.ts +0 -17
- package/src/internal/AssetResponse.ts +26 -0
- package/src/internal/Auth.test.ts +1564 -9
- package/src/internal/Auth.ts +833 -239
- package/src/internal/BetterAuth.test.ts +242 -0
- package/src/internal/BetterAuth.ts +349 -0
- package/src/internal/Cache.ts +2 -0
- package/src/internal/EarnRates.test.ts +17 -0
- package/src/internal/EarnRates.ts +124 -31
- package/src/internal/EarnSharePrices.test.ts +182 -0
- package/src/internal/EarnSharePrices.ts +313 -0
- package/src/internal/EarnVaults.test.ts +21 -0
- package/src/internal/EarnVaults.ts +37 -15
- package/src/internal/Email.ts +54 -0
- package/src/internal/Idempotency.test.ts +2 -2
- package/src/internal/Log.test-d.ts +10 -7
- package/src/internal/Log.test.ts +114 -16
- package/src/internal/Log.ts +55 -40
- package/src/internal/MetricSink.test.ts +313 -26
- package/src/internal/MetricSink.ts +73 -8
- package/src/internal/Mpp.test.ts +31 -0
- package/src/internal/Mpp.ts +21 -24
- package/src/internal/OpenApi.ts +45 -12
- package/src/internal/Provider.test.ts +1 -1
- package/src/internal/Provider.ts +1 -1
- package/src/internal/RateLimit.test.ts +21 -3
- package/src/internal/RateLimit.ts +12 -1
- package/src/internal/Store.test-d.ts +1 -1
- package/src/internal/Store.test.ts +151 -8
- package/src/internal/Store.ts +76 -9
- package/src/internal/Tidx.test.ts +59 -8
- package/src/internal/Tidx.ts +86 -14
- package/src/internal/Timing.test.ts +77 -0
- package/src/internal/Timing.ts +83 -6
- package/src/internal/VercelOidc.test.ts +188 -0
- package/src/internal/VercelOidc.ts +193 -0
- package/src/internal/VerifiedTokens.test.ts +60 -6
- package/src/internal/VerifiedTokens.ts +21 -24
- package/src/internal/Viem.batch.test.ts +80 -0
- package/src/internal/Viem.test.ts +201 -2
- package/src/internal/Viem.ts +249 -17
- package/src/internal/Webhooks.test.ts +125 -1
- package/src/internal/Webhooks.ts +22 -4
- package/src/internal/ZoneRpc.ts +50 -0
- package/src/internal/exchange/Provider.test.ts +2 -2
- package/src/internal/index.test.ts +3 -1
- package/src/internal/index.ts +3 -1
- package/src/internal/rewards/Audit.ts +231 -0
- package/src/internal/rewards/Campaigns.test.ts +1234 -0
- package/src/internal/rewards/Campaigns.ts +1205 -0
- package/src/internal/rewards/Credits.ts +165 -0
- package/src/internal/rewards/Events.local.test.ts +113 -0
- package/src/internal/rewards/Events.test.ts +152 -0
- package/src/internal/rewards/Events.ts +468 -0
- package/src/internal/rewards/Projection.test.ts +681 -0
- package/src/internal/rewards/Projection.ts +987 -0
- package/src/internal/rewards/Rates.test.ts +171 -0
- package/src/internal/rewards/Rates.ts +110 -0
- package/src/internal/rewards/Read.test.ts +501 -0
- package/src/internal/rewards/Read.ts +476 -0
- package/src/internal/rewards/Runner.checkpoint.test.ts +80 -0
- package/src/internal/rewards/Runner.states.test.ts +188 -0
- package/src/internal/rewards/Runner.test.ts +90 -0
- package/src/internal/rewards/Runner.ts +2229 -0
- package/src/internal/rewards/Signer.test.ts +79 -0
- package/src/internal/rewards/Signer.ts +180 -0
- package/src/internal/rewards/index.ts +14 -0
- package/src/internal/{funding → routes}/Action.test.ts +63 -14
- package/src/internal/{funding → routes}/Action.ts +35 -8
- package/src/internal/{funding → routes}/Catalog.test.ts +3 -3
- package/src/internal/{funding → routes}/Catalog.ts +39 -39
- package/src/internal/{funding → routes}/Chain.test.ts +1 -1
- package/src/internal/{funding → routes}/Chain.ts +11 -11
- package/src/internal/{funding → routes}/Deposit.test.ts +1 -1
- package/src/internal/{funding → routes}/Deposit.ts +93 -45
- package/src/internal/{funding → routes}/DepositAddress.test.ts +11 -3
- package/src/internal/{funding → routes}/DepositAddress.ts +132 -53
- package/src/internal/{funding → routes}/DepositWebhook.test.ts +61 -18
- package/src/internal/{funding → routes}/DepositWebhook.ts +9 -8
- package/src/internal/routes/Economics.test.ts +42 -0
- package/src/internal/routes/Economics.ts +47 -0
- package/src/internal/{funding → routes}/Evidence.test.ts +6 -6
- package/src/internal/{funding → routes}/Evidence.ts +11 -22
- package/src/internal/routes/Observability.test.ts +636 -0
- package/src/internal/routes/Observability.ts +668 -0
- package/src/internal/{funding → routes}/Provider.test.ts +489 -153
- package/src/internal/{funding → routes}/Provider.ts +531 -185
- package/src/internal/{funding → routes}/Reconciliation.local.test.ts +84 -12
- package/src/internal/{funding → routes}/Reconciliation.test.ts +1213 -279
- package/src/internal/{funding → routes}/Reconciliation.ts +501 -203
- package/src/internal/routes/Reconciliation.unattributed.test.ts +250 -0
- package/src/internal/{funding → routes}/Route.ts +7 -7
- package/src/internal/{funding → routes}/SourceObservation.test.ts +13 -14
- package/src/internal/{funding → routes}/SourceObservation.ts +18 -22
- package/src/internal/{funding → routes}/Subsidy.local.test.ts +7 -7
- package/src/internal/routes/Subsidy.test.ts +169 -0
- package/src/internal/{funding → routes}/Subsidy.ts +86 -6
- package/src/internal/{funding → routes}/Token.test.ts +1 -1
- package/src/internal/{funding → routes}/Token.ts +5 -5
- package/src/internal/routes/Transfer.test.ts +1199 -0
- package/src/internal/routes/Transfer.ts +1206 -0
- package/src/internal/routes/TransferReconciliation.test.ts +731 -0
- package/src/internal/routes/TransferReconciliation.ts +527 -0
- package/src/internal/routes/TransferSubsidy.test.ts +172 -0
- package/src/internal/routes/TransferSubsidy.ts +447 -0
- package/src/internal/routes/TransferWebhook.test.ts +128 -0
- package/src/internal/routes/TransferWebhook.ts +67 -0
- package/src/internal/{funding → routes}/index.test.ts +6 -3
- package/src/internal/{funding → routes}/index.ts +3 -0
- package/src/internal/{funding → routes}/providers/across.ts +16 -16
- package/src/internal/{funding → routes}/providers/index.test.ts +157 -44
- package/src/internal/{funding → routes}/providers/relay.test.ts +165 -32
- package/src/internal/{funding → routes}/providers/relay.ts +231 -136
- package/src/internal/{funding → routes}/providers/rhino.ts +16 -16
- package/src/internal/{funding → routes}/providers/squid.ts +17 -17
- package/src/internal/routes/providers/stargate.test.ts +728 -0
- package/src/internal/routes/providers/stargate.ts +1276 -0
- package/src/internal/{funding → routes}/providers/symbiosis.ts +64 -24
- package/src/internal/webhookDestinations/slack.ts +20 -5
- package/src/providers/index.ts +13 -13
- package/src/server.ts +18 -0
- package/dist/apps/funding/Access.d.ts.map +0 -1
- package/dist/apps/funding/Access.js.map +0 -1
- package/dist/apps/funding/App.js.map +0 -1
- package/dist/apps/funding/Inventory.d.ts.map +0 -1
- package/dist/apps/funding/Inventory.js.map +0 -1
- package/dist/apps/funding/ProviderAttempts.d.ts +0 -5
- package/dist/apps/funding/ProviderAttempts.d.ts.map +0 -1
- package/dist/apps/funding/ProviderAttempts.js +0 -24
- package/dist/apps/funding/ProviderAttempts.js.map +0 -1
- package/dist/apps/funding/index.d.ts +0 -2
- package/dist/apps/funding/index.d.ts.map +0 -1
- package/dist/apps/funding/index.js +0 -2
- package/dist/apps/funding/index.js.map +0 -1
- package/dist/apps/funding/routes/chains.d.ts.map +0 -1
- package/dist/apps/funding/routes/chains.js.map +0 -1
- package/dist/apps/funding/routes/deposit-addresses.d.ts.map +0 -1
- package/dist/apps/funding/routes/deposit-addresses.js.map +0 -1
- package/dist/apps/funding/routes/providers.d.ts.map +0 -1
- package/dist/apps/funding/routes/providers.js +0 -57
- package/dist/apps/funding/routes/providers.js.map +0 -1
- package/dist/apps/funding/routes/quotes.d.ts.map +0 -1
- package/dist/apps/funding/routes/quotes.js.map +0 -1
- package/dist/apps/funding/routes/transfers.d.ts.map +0 -1
- package/dist/apps/funding/routes/transfers.js +0 -622
- package/dist/apps/funding/routes/transfers.js.map +0 -1
- package/dist/db/tables/fundingCatalog.d.ts +0 -58
- package/dist/db/tables/fundingCatalog.d.ts.map +0 -1
- package/dist/db/tables/fundingCatalog.js.map +0 -1
- package/dist/db/tables/fundingDepositAddresses.d.ts +0 -192
- package/dist/db/tables/fundingDepositAddresses.d.ts.map +0 -1
- package/dist/db/tables/fundingDepositAddresses.js +0 -235
- package/dist/db/tables/fundingDepositAddresses.js.map +0 -1
- package/dist/db/tables/fundingDepositRequestObservations.d.ts.map +0 -1
- package/dist/db/tables/fundingDepositRequestObservations.js.map +0 -1
- package/dist/db/tables/fundingDeposits.d.ts.map +0 -1
- package/dist/db/tables/fundingDeposits.js +0 -295
- package/dist/db/tables/fundingDeposits.js.map +0 -1
- package/dist/db/tables/fundingIdempotency.d.ts +0 -91
- package/dist/db/tables/fundingIdempotency.d.ts.map +0 -1
- package/dist/db/tables/fundingIdempotency.js +0 -103
- package/dist/db/tables/fundingIdempotency.js.map +0 -1
- package/dist/db/tables/fundingTransferEvents.d.ts.map +0 -1
- package/dist/db/tables/fundingTransferEvents.js.map +0 -1
- package/dist/db/tables/fundingTransferTransactions.d.ts +0 -15
- package/dist/db/tables/fundingTransferTransactions.d.ts.map +0 -1
- package/dist/db/tables/fundingTransferTransactions.js +0 -27
- package/dist/db/tables/fundingTransferTransactions.js.map +0 -1
- package/dist/db/tables/fundingTransfers.d.ts +0 -82
- package/dist/db/tables/fundingTransfers.d.ts.map +0 -1
- package/dist/db/tables/fundingTransfers.js +0 -89
- package/dist/db/tables/fundingTransfers.js.map +0 -1
- package/dist/internal/funding/Action.d.ts.map +0 -1
- package/dist/internal/funding/Action.js.map +0 -1
- package/dist/internal/funding/Catalog.d.ts.map +0 -1
- package/dist/internal/funding/Catalog.js.map +0 -1
- package/dist/internal/funding/Chain.d.ts.map +0 -1
- package/dist/internal/funding/Chain.js.map +0 -1
- package/dist/internal/funding/Deposit.d.ts.map +0 -1
- package/dist/internal/funding/Deposit.js.map +0 -1
- package/dist/internal/funding/DepositAddress.d.ts.map +0 -1
- package/dist/internal/funding/DepositAddress.js.map +0 -1
- package/dist/internal/funding/DepositWebhook.d.ts.map +0 -1
- package/dist/internal/funding/DepositWebhook.js.map +0 -1
- package/dist/internal/funding/Evidence.d.ts.map +0 -1
- package/dist/internal/funding/Evidence.js.map +0 -1
- package/dist/internal/funding/Provider.d.ts.map +0 -1
- package/dist/internal/funding/Provider.js.map +0 -1
- package/dist/internal/funding/Reconciliation.d.ts.map +0 -1
- package/dist/internal/funding/Reconciliation.js.map +0 -1
- package/dist/internal/funding/Route.d.ts +0 -21
- package/dist/internal/funding/Route.d.ts.map +0 -1
- package/dist/internal/funding/Route.js.map +0 -1
- package/dist/internal/funding/SourceObservation.d.ts.map +0 -1
- package/dist/internal/funding/SourceObservation.js.map +0 -1
- package/dist/internal/funding/Subsidy.d.ts.map +0 -1
- package/dist/internal/funding/Subsidy.js.map +0 -1
- package/dist/internal/funding/Token.d.ts.map +0 -1
- package/dist/internal/funding/Token.js.map +0 -1
- package/dist/internal/funding/Transfer.d.ts.map +0 -1
- package/dist/internal/funding/Transfer.js +0 -334
- package/dist/internal/funding/Transfer.js.map +0 -1
- package/dist/internal/funding/index.d.ts.map +0 -1
- package/dist/internal/funding/index.js.map +0 -1
- package/dist/internal/funding/providers/across.d.ts.map +0 -1
- package/dist/internal/funding/providers/across.js.map +0 -1
- package/dist/internal/funding/providers/relay.d.ts.map +0 -1
- package/dist/internal/funding/providers/relay.js.map +0 -1
- package/dist/internal/funding/providers/rhino.d.ts.map +0 -1
- package/dist/internal/funding/providers/rhino.js.map +0 -1
- package/dist/internal/funding/providers/squid.d.ts.map +0 -1
- package/dist/internal/funding/providers/squid.js.map +0 -1
- package/dist/internal/funding/providers/stargate.d.ts +0 -38
- package/dist/internal/funding/providers/stargate.d.ts.map +0 -1
- package/dist/internal/funding/providers/stargate.js +0 -277
- package/dist/internal/funding/providers/stargate.js.map +0 -1
- package/dist/internal/funding/providers/symbiosis.d.ts.map +0 -1
- package/dist/internal/funding/providers/symbiosis.js.map +0 -1
- package/src/apps/funding/App.test.ts +0 -78
- package/src/apps/funding/App.ts +0 -78
- package/src/apps/funding/ProviderAttempts.ts +0 -26
- package/src/apps/funding/index.ts +0 -1
- package/src/apps/funding/routes/transfers.test.ts +0 -1638
- package/src/apps/funding/routes/transfers.ts +0 -721
- package/src/db/tables/fundingCatalog.test.ts +0 -122
- package/src/db/tables/fundingCatalog.ts +0 -163
- package/src/db/tables/fundingDepositAddresses.test.ts +0 -608
- package/src/db/tables/fundingDepositAddresses.ts +0 -443
- package/src/db/tables/fundingDeposits.ts +0 -572
- package/src/db/tables/fundingIdempotency.test.ts +0 -182
- package/src/db/tables/fundingIdempotency.ts +0 -180
- package/src/db/tables/fundingTransferTransactions.test.ts +0 -69
- package/src/db/tables/fundingTransferTransactions.ts +0 -37
- package/src/db/tables/fundingTransfers.test.ts +0 -89
- package/src/db/tables/fundingTransfers.ts +0 -153
- package/src/handlers/internal/multisig.test.ts +0 -818
- package/src/internal/funding/Subsidy.test.ts +0 -75
- package/src/internal/funding/Transfer.test.ts +0 -369
- package/src/internal/funding/Transfer.ts +0 -545
- package/src/internal/funding/providers/stargate.test.ts +0 -163
- package/src/internal/funding/providers/stargate.ts +0 -409
- /package/dist/apps/{funding → routes}/Inventory.d.ts +0 -0
- /package/src/internal/{funding → routes}/Route.test.ts +0 -0
|
@@ -0,0 +1,1008 @@
|
|
|
1
|
+
import { sql, type JSONColumnType, type Selectable } from 'kysely'
|
|
2
|
+
import * as pg from 'pg'
|
|
3
|
+
|
|
4
|
+
import type * as Db from '../Db.js'
|
|
5
|
+
import type * as db_Schema from '../Schema.js'
|
|
6
|
+
import * as RoutesIdempotency from './routesIdempotency.js'
|
|
7
|
+
import * as RoutesSubsidies from './routesSubsidies.js'
|
|
8
|
+
|
|
9
|
+
/** Columns of the `routes_deposit_addresses` table. */
|
|
10
|
+
export type Table = Omit<db_Schema.RoutesDepositAddress, 'providerRequestIds'> & {
|
|
11
|
+
/** Private provider request identifiers stored as JSON. */
|
|
12
|
+
providerRequestIds: JSONColumnType<readonly string[], string, string>
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
/** A stored route deposit address. */
|
|
16
|
+
export type Record = Selectable<Table>
|
|
17
|
+
|
|
18
|
+
/** Ownership filter derived from the authenticated API key. */
|
|
19
|
+
export type Owner = {
|
|
20
|
+
/** Key environment. */
|
|
21
|
+
environment: Record['environment']
|
|
22
|
+
/** Owning organization id (`org_…`). */
|
|
23
|
+
orgId: string
|
|
24
|
+
/** Attributed project id for project-scoped API keys. */
|
|
25
|
+
projectId?: string | undefined
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/** Identity fields that make one reusable address match a caller request. */
|
|
29
|
+
export type Match = Owner & {
|
|
30
|
+
/** Customer destination token key. */
|
|
31
|
+
destinationTokenKey: string
|
|
32
|
+
/** Tempo account that receives completed deposits. */
|
|
33
|
+
recipient: string
|
|
34
|
+
/** Source-chain account that receives refunds. */
|
|
35
|
+
refundAddress: string
|
|
36
|
+
/** Source chain CAIP-2 id. */
|
|
37
|
+
sourceChainId: string
|
|
38
|
+
/** Source token key. */
|
|
39
|
+
sourceTokenKey: string
|
|
40
|
+
/** Whether Tempo guarantees normalized 1:1 delivery. */
|
|
41
|
+
subsidize: boolean
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/** Counts durable route deposit addresses owned by an organization creator. */
|
|
45
|
+
async function countByOwner(db: Db.Db, owner: countByOwner.Owner): Promise<number> {
|
|
46
|
+
let query = db.kysely
|
|
47
|
+
.selectFrom('routes_deposit_addresses')
|
|
48
|
+
.select(({ fn }) => fn.countAll<string>().as('count'))
|
|
49
|
+
const userId = owner.userId
|
|
50
|
+
query = userId
|
|
51
|
+
? query.where('creatorUserId', '=', userId)
|
|
52
|
+
: query.where('orgId', '=', owner.orgId)
|
|
53
|
+
const result = await query.executeTakeFirstOrThrow()
|
|
54
|
+
return Number(result.count)
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
declare namespace countByOwner {
|
|
58
|
+
/** Canonical creator scope, with organization fallback for unowned rows. */
|
|
59
|
+
type Owner = {
|
|
60
|
+
/** Organization id (`org_…`). */
|
|
61
|
+
orgId: string
|
|
62
|
+
/** Canonical creator id (`usr_…`). */
|
|
63
|
+
userId: string | null
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/** Counts durable route deposit addresses for one organization. */
|
|
68
|
+
export async function countByOrganization(db: Db.Db, orgId: string): Promise<number> {
|
|
69
|
+
const result = await db.kysely
|
|
70
|
+
.selectFrom('routes_deposit_addresses')
|
|
71
|
+
.select(({ fn }) => fn.countAll<string>().as('count'))
|
|
72
|
+
.where('orgId', '=', orgId)
|
|
73
|
+
.executeTakeFirstOrThrow()
|
|
74
|
+
return Number(result.count)
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/** Lists active addresses that organization deletion will deactivate. */
|
|
78
|
+
export function listActiveByOrganization(db: Db.Db, orgId: string): Promise<readonly Record[]> {
|
|
79
|
+
return db.kysely
|
|
80
|
+
.selectFrom('routes_deposit_addresses')
|
|
81
|
+
.selectAll()
|
|
82
|
+
.where('orgId', '=', orgId)
|
|
83
|
+
.where('status', '!=', 'deactivated')
|
|
84
|
+
.execute()
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/** Claims address creation under the organization deletion fence. */
|
|
88
|
+
export function claimCreation(
|
|
89
|
+
db: Db.Db,
|
|
90
|
+
options: claimCreation.Options,
|
|
91
|
+
): Promise<RoutesIdempotency.claim.Result> {
|
|
92
|
+
return db.transaction(async (tx) => {
|
|
93
|
+
await RoutesSubsidies.lockOrganization(tx, options.orgId)
|
|
94
|
+
const organization = await getOrCreateCapacityOwner(tx, {
|
|
95
|
+
apiKeyId: options.claim.apiKeyId,
|
|
96
|
+
orgId: options.orgId,
|
|
97
|
+
})
|
|
98
|
+
if (!organization) throw new OwnerNotFoundError()
|
|
99
|
+
const claim = await RoutesIdempotency.claim(tx, {
|
|
100
|
+
...options.claim,
|
|
101
|
+
operation: RoutesIdempotency.operations.depositAddress,
|
|
102
|
+
orgId: options.orgId,
|
|
103
|
+
})
|
|
104
|
+
return claim
|
|
105
|
+
})
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
export declare namespace claimCreation {
|
|
109
|
+
/** Claim identity and organization deletion fence. */
|
|
110
|
+
type Options = {
|
|
111
|
+
/** Idempotency identity and lease. */
|
|
112
|
+
claim: Omit<RoutesIdempotency.claim.Input, 'operation' | 'orgId'>
|
|
113
|
+
/** Organization reserving address capacity. */
|
|
114
|
+
orgId: string
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
/** Validates reserved address capacity, excluding an already reusable match. */
|
|
119
|
+
export function validateCreationCapacity(
|
|
120
|
+
db: Db.Db,
|
|
121
|
+
options: validateCreationCapacity.Options,
|
|
122
|
+
): Promise<validateCreationCapacity.Result> {
|
|
123
|
+
return db
|
|
124
|
+
.transaction(async (tx) => {
|
|
125
|
+
await RoutesSubsidies.lockOrganization(tx, options.orgId)
|
|
126
|
+
const organization = await getCapacityOwner(tx, options.orgId)
|
|
127
|
+
if (!organization) throw new OwnerNotFoundError()
|
|
128
|
+
await lockCapacityOwner(tx, organization)
|
|
129
|
+
const matching = await getMatching(tx, options.match)
|
|
130
|
+
if (matching) {
|
|
131
|
+
const response = options.serializeMatchingResponse(matching)
|
|
132
|
+
const completed = await RoutesIdempotency.complete(tx, {
|
|
133
|
+
...options.claim,
|
|
134
|
+
replayTtlMs: options.replayTtlMs,
|
|
135
|
+
response,
|
|
136
|
+
})
|
|
137
|
+
if (!completed) throw new CapacityClaimNotFoundError()
|
|
138
|
+
if (options.recoveredClaim)
|
|
139
|
+
await RoutesIdempotency.complete(tx, {
|
|
140
|
+
...options.recoveredClaim,
|
|
141
|
+
replayTtlMs: options.replayTtlMs,
|
|
142
|
+
response,
|
|
143
|
+
})
|
|
144
|
+
return { allowed: true, result: { record: matching, type: 'existing' } } as const
|
|
145
|
+
}
|
|
146
|
+
// Old workers cannot prove a checkpoint's owner or match; exact same-key retries attribute it before this fence.
|
|
147
|
+
if (await RoutesIdempotency.hasUnattributedInFlightClaim(tx)) throw new MatchInProgressError()
|
|
148
|
+
const reservation = await RoutesIdempotency.reserveDepositAddressMatch(tx, {
|
|
149
|
+
...options.claim,
|
|
150
|
+
matchHash: options.matchHash,
|
|
151
|
+
orgId: options.orgId,
|
|
152
|
+
ttlMs: options.pendingTtlMs,
|
|
153
|
+
})
|
|
154
|
+
if (reservation.type === 'lost') throw new CapacityClaimNotFoundError()
|
|
155
|
+
if (reservation.type === 'pending') throw new MatchInProgressError()
|
|
156
|
+
if (reservation.type === 'resume') return { allowed: true, result: reservation } as const
|
|
157
|
+
if (reservation.type === 'provisioned' || options.recoveredClaim !== undefined)
|
|
158
|
+
return { allowed: true, result: { type: 'reserved' } } as const
|
|
159
|
+
const addresses = await countByOwner(tx, organization)
|
|
160
|
+
const inFlight = await RoutesIdempotency.countInFlightDepositAddresses(tx, organization)
|
|
161
|
+
if (addresses + inFlight <= options.maxPerCreator)
|
|
162
|
+
return { allowed: true, result: { type: 'reserved' } } as const
|
|
163
|
+
await RoutesIdempotency.release(tx, options.claim)
|
|
164
|
+
return { allowed: false, result: undefined } as const
|
|
165
|
+
})
|
|
166
|
+
.then((result) => {
|
|
167
|
+
if (!result.allowed) throw new LimitExceededError(options.maxPerCreator)
|
|
168
|
+
return result.result
|
|
169
|
+
})
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
export declare namespace validateCreationCapacity {
|
|
173
|
+
/** Reusable identity and organization capacity bound. */
|
|
174
|
+
type Options = {
|
|
175
|
+
/** Pending claim released atomically when the creator-wide cap is full. */
|
|
176
|
+
claim: RoutesIdempotency.release.Input
|
|
177
|
+
/** Maximum durable and in-flight addresses for one canonical creator. */
|
|
178
|
+
maxPerCreator: number
|
|
179
|
+
/** Stable reusable-address identity that does not consume new capacity when present. */
|
|
180
|
+
match: Match
|
|
181
|
+
/** SHA-256 fingerprint of the canonical reusable match. */
|
|
182
|
+
matchHash: string
|
|
183
|
+
/** Organization reserving address capacity. */
|
|
184
|
+
orgId: string
|
|
185
|
+
/** Renewed pending lease duration, in milliseconds. */
|
|
186
|
+
pendingTtlMs: number
|
|
187
|
+
/** Successful-response replay retention from completion, in milliseconds. */
|
|
188
|
+
replayTtlMs: number
|
|
189
|
+
/** Older provider checkpoint completed when its durable match already exists. */
|
|
190
|
+
recoveredClaim?: RoutesIdempotency.release.Input | undefined
|
|
191
|
+
/** Serializes a reusable address into the idempotent response. */
|
|
192
|
+
serializeMatchingResponse: (record: Record) => string
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
/** Capacity reservation or reusable recovery result. */
|
|
196
|
+
type Result =
|
|
197
|
+
| { record: Record; type: 'existing' }
|
|
198
|
+
| { type: 'reserved' }
|
|
199
|
+
| {
|
|
200
|
+
checkpointFresh: boolean
|
|
201
|
+
claim: RoutesIdempotency.release.Input
|
|
202
|
+
response: string
|
|
203
|
+
type: 'resume'
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
/** Deactivates an organization's addresses so deletion leaves no recurring work. */
|
|
208
|
+
export function deactivateByOrganization(
|
|
209
|
+
db: Db.Db,
|
|
210
|
+
options: deactivateByOrganization.Options,
|
|
211
|
+
): Promise<readonly Record[]> {
|
|
212
|
+
return db.kysely
|
|
213
|
+
.updateTable('routes_deposit_addresses')
|
|
214
|
+
.set({
|
|
215
|
+
pollLeaseUntil: null,
|
|
216
|
+
pollLeaseVersion: sql<number>`poll_lease_version + 1`,
|
|
217
|
+
status: 'deactivated',
|
|
218
|
+
statusUpdatedAt: options.now,
|
|
219
|
+
updatedAt: options.now,
|
|
220
|
+
version: sql<number>`version + 1`,
|
|
221
|
+
})
|
|
222
|
+
.where('orgId', '=', options.orgId)
|
|
223
|
+
.where('status', '!=', 'deactivated')
|
|
224
|
+
.returningAll()
|
|
225
|
+
.execute()
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
export declare namespace deactivateByOrganization {
|
|
229
|
+
/** Organization and timestamp for one bulk deactivation. */
|
|
230
|
+
type Options = {
|
|
231
|
+
/** Timestamp committed to each changed address. */
|
|
232
|
+
now: string
|
|
233
|
+
/** Owning organization id (`org_…`). */
|
|
234
|
+
orgId: string
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
/** Returns whether an organization owns an irrevocable provider subsidy request. */
|
|
239
|
+
export async function hasSubsidizedRelayAddress(db: Db.Db, orgId: string): Promise<boolean> {
|
|
240
|
+
return Boolean(
|
|
241
|
+
await db.kysely
|
|
242
|
+
.selectFrom('routes_deposit_addresses')
|
|
243
|
+
.select('id')
|
|
244
|
+
.where('orgId', '=', orgId)
|
|
245
|
+
.where('providerId', '=', 'relay')
|
|
246
|
+
.where('subsidize', '=', true)
|
|
247
|
+
.limit(1)
|
|
248
|
+
.executeTakeFirst(),
|
|
249
|
+
)
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
/** Aggregates current deposit-address states for bounded operational metrics. */
|
|
253
|
+
export function summarizeStates(db: Db.Db) {
|
|
254
|
+
return db.kysely
|
|
255
|
+
.selectFrom('routes_deposit_addresses')
|
|
256
|
+
.select(({ fn }) => [
|
|
257
|
+
'environment',
|
|
258
|
+
'providerId',
|
|
259
|
+
'status',
|
|
260
|
+
fn.countAll<string>().as('count'),
|
|
261
|
+
sql<string>`min(coalesce(status_updated_at, updated_at))`.as('oldestStatusUpdatedAt'),
|
|
262
|
+
])
|
|
263
|
+
.where('status', '!=', 'deactivated')
|
|
264
|
+
.groupBy(['environment', 'providerId', 'status'])
|
|
265
|
+
.execute()
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
/** Aggregates active deposit-address checks that are due without a live lease. */
|
|
269
|
+
export function summarizeOverdue(db: Db.Db, options: summarizeOverdue.Options) {
|
|
270
|
+
return db.kysely
|
|
271
|
+
.selectFrom('routes_deposit_addresses')
|
|
272
|
+
.select(({ fn }) => [
|
|
273
|
+
'environment',
|
|
274
|
+
'providerId',
|
|
275
|
+
fn.countAll<string>().as('count'),
|
|
276
|
+
fn.min<string>('nextPollAt').as('oldestNextPollAt'),
|
|
277
|
+
])
|
|
278
|
+
.where('nextPollAt', '<', options.now)
|
|
279
|
+
.where('status', '=', 'active')
|
|
280
|
+
.where((eb) =>
|
|
281
|
+
eb.or([eb('pollLeaseUntil', 'is', null), eb('pollLeaseUntil', '<=', options.now)]),
|
|
282
|
+
)
|
|
283
|
+
.groupBy(['environment', 'providerId'])
|
|
284
|
+
.execute()
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
export declare namespace summarizeOverdue {
|
|
288
|
+
/** Overdue-address snapshot options. */
|
|
289
|
+
type Options = {
|
|
290
|
+
/** Current timestamp used to classify due and leased addresses. */
|
|
291
|
+
now: string
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
/** Inserts a provisioned route deposit address. */
|
|
296
|
+
export function insert(db: Db.Db, record: Record): Promise<Record> {
|
|
297
|
+
return db.kysely
|
|
298
|
+
.insertInto('routes_deposit_addresses')
|
|
299
|
+
.values({
|
|
300
|
+
...record,
|
|
301
|
+
providerRequestIds: JSON.stringify(record.providerRequestIds),
|
|
302
|
+
})
|
|
303
|
+
.returningAll()
|
|
304
|
+
.executeTakeFirstOrThrow()
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
/** Inserts an address or returns the concurrently-created matching resource. */
|
|
308
|
+
export async function insertOrGet(db: Db.Db, options: insertOrGet.Options): Promise<Record> {
|
|
309
|
+
const record = await db.kysely
|
|
310
|
+
.insertInto('routes_deposit_addresses')
|
|
311
|
+
.values({
|
|
312
|
+
...options.record,
|
|
313
|
+
providerRequestIds: JSON.stringify(options.record.providerRequestIds),
|
|
314
|
+
})
|
|
315
|
+
.onConflict((oc) =>
|
|
316
|
+
oc
|
|
317
|
+
.columns([
|
|
318
|
+
'orgId',
|
|
319
|
+
'environment',
|
|
320
|
+
'projectId',
|
|
321
|
+
'sourceChainId',
|
|
322
|
+
'sourceTokenKey',
|
|
323
|
+
'destinationTokenKey',
|
|
324
|
+
'recipient',
|
|
325
|
+
'refundAddress',
|
|
326
|
+
'subsidize',
|
|
327
|
+
])
|
|
328
|
+
.doNothing(),
|
|
329
|
+
)
|
|
330
|
+
.returningAll()
|
|
331
|
+
.executeTakeFirst()
|
|
332
|
+
.catch((cause) => {
|
|
333
|
+
if (
|
|
334
|
+
cause instanceof pg.DatabaseError &&
|
|
335
|
+
cause.code === '23505' &&
|
|
336
|
+
cause.constraint === 'routes_deposit_addresses_provider_address_key'
|
|
337
|
+
)
|
|
338
|
+
throw new ConflictError()
|
|
339
|
+
throw cause
|
|
340
|
+
})
|
|
341
|
+
if (record) return record
|
|
342
|
+
const existing = await getMatching(db, options.match)
|
|
343
|
+
if (existing) return existing
|
|
344
|
+
throw new ConflictError()
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
/**
|
|
348
|
+
* Inserts or returns a matching address while enforcing its creator's cap.
|
|
349
|
+
* The caller must provide a transaction so the advisory lock covers the insert.
|
|
350
|
+
*/
|
|
351
|
+
export async function insertOrGetWithinLimit(
|
|
352
|
+
db: Db.Db,
|
|
353
|
+
options: insertOrGetWithinLimit.Options,
|
|
354
|
+
): Promise<Record> {
|
|
355
|
+
await RoutesSubsidies.lockOrganization(db, options.record.orgId)
|
|
356
|
+
const organization = await getCapacityOwner(db, options.record.orgId)
|
|
357
|
+
if (!organization) throw new OwnerNotFoundError()
|
|
358
|
+
await lockCapacityOwner(db, organization)
|
|
359
|
+
const existing = await getMatching(db, options.match)
|
|
360
|
+
if (existing) return existing
|
|
361
|
+
if ((await countByOwner(db, organization)) >= options.maxPerCreator)
|
|
362
|
+
throw new LimitExceededError(options.maxPerCreator)
|
|
363
|
+
return insertOrGet(db, options)
|
|
364
|
+
}
|
|
365
|
+
|
|
366
|
+
export declare namespace insertOrGetWithinLimit {
|
|
367
|
+
/** Record, stable identity, and creator-wide cap for an atomic insert. */
|
|
368
|
+
type Options = insertOrGet.Options & {
|
|
369
|
+
/** Maximum durable deposit addresses one canonical creator may own. */
|
|
370
|
+
maxPerCreator: number
|
|
371
|
+
}
|
|
372
|
+
}
|
|
373
|
+
|
|
374
|
+
/** Inserts an already-provisioned address under the creator locks without applying a new-work cap. */
|
|
375
|
+
export async function insertProvisionedOrGet(
|
|
376
|
+
db: Db.Db,
|
|
377
|
+
options: insertProvisionedOrGet.Options,
|
|
378
|
+
): Promise<Record> {
|
|
379
|
+
await RoutesSubsidies.lockOrganization(db, options.record.orgId)
|
|
380
|
+
const organization = await getCapacityOwner(db, options.record.orgId)
|
|
381
|
+
if (!organization) throw new OwnerNotFoundError()
|
|
382
|
+
await lockCapacityOwner(db, organization)
|
|
383
|
+
return insertOrGet(db, options)
|
|
384
|
+
}
|
|
385
|
+
|
|
386
|
+
export declare namespace insertProvisionedOrGet {
|
|
387
|
+
/** Already-provisioned record and stable reusable identity. */
|
|
388
|
+
type Options = insertOrGet.Options
|
|
389
|
+
}
|
|
390
|
+
|
|
391
|
+
export declare namespace insertOrGet {
|
|
392
|
+
/** Record and stable identity used by create-or-get. */
|
|
393
|
+
type Options = {
|
|
394
|
+
/** Stable customer-visible address identity. */
|
|
395
|
+
match: Match
|
|
396
|
+
/** Provisioned address record to insert. */
|
|
397
|
+
record: Record
|
|
398
|
+
}
|
|
399
|
+
}
|
|
400
|
+
|
|
401
|
+
function getCapacityOwner(db: Db.Db, orgId: string): Promise<countByOwner.Owner | undefined> {
|
|
402
|
+
return db.kysely
|
|
403
|
+
.selectFrom('organizations')
|
|
404
|
+
.select(['id as orgId', 'userId'])
|
|
405
|
+
.where('id', '=', orgId)
|
|
406
|
+
.executeTakeFirst()
|
|
407
|
+
}
|
|
408
|
+
|
|
409
|
+
async function getOrCreateCapacityOwner(
|
|
410
|
+
db: Db.Db,
|
|
411
|
+
options: getOrCreateCapacityOwner.Options,
|
|
412
|
+
): Promise<countByOwner.Owner | undefined> {
|
|
413
|
+
const existing = await getCapacityOwner(db, options.orgId)
|
|
414
|
+
if (existing || options.apiKeyId !== options.orgId) return existing
|
|
415
|
+
// Legacy organization-less keys use their key id as orgId; materialize it so lifecycle fences remain enforceable.
|
|
416
|
+
const now = new Date().toISOString()
|
|
417
|
+
await db.kysely
|
|
418
|
+
.insertInto('organizations')
|
|
419
|
+
.values({
|
|
420
|
+
createdAt: now,
|
|
421
|
+
createdBy: null,
|
|
422
|
+
id: options.orgId,
|
|
423
|
+
name: options.orgId,
|
|
424
|
+
sponsorshipSubsidyDurationDays: null,
|
|
425
|
+
sponsorshipSubsidyProjectSpendLimit: null,
|
|
426
|
+
updatedAt: now,
|
|
427
|
+
userId: null,
|
|
428
|
+
})
|
|
429
|
+
.onConflict((oc) => oc.column('id').doNothing())
|
|
430
|
+
.execute()
|
|
431
|
+
return getCapacityOwner(db, options.orgId)
|
|
432
|
+
}
|
|
433
|
+
|
|
434
|
+
declare namespace getOrCreateCapacityOwner {
|
|
435
|
+
/** Legacy API-key fallback identity. */
|
|
436
|
+
type Options = {
|
|
437
|
+
/** API key id (`key_…`). */
|
|
438
|
+
apiKeyId: string
|
|
439
|
+
/** API key organization fallback. */
|
|
440
|
+
orgId: string
|
|
441
|
+
}
|
|
442
|
+
}
|
|
443
|
+
|
|
444
|
+
async function lockCapacityOwner(db: Db.Db, owner: countByOwner.Owner): Promise<void> {
|
|
445
|
+
const key = owner.userId
|
|
446
|
+
? `routes-deposit-address-capacity:user:${owner.userId}`
|
|
447
|
+
: `routes-deposit-address-capacity:organization:${owner.orgId}`
|
|
448
|
+
await sql`SELECT pg_advisory_xact_lock(hashtextextended(${key}, 0))`.execute(db.kysely)
|
|
449
|
+
}
|
|
450
|
+
|
|
451
|
+
/** Gets a route deposit address without ownership scoping. */
|
|
452
|
+
export function get(db: Db.Db, id: string): Promise<Record | undefined> {
|
|
453
|
+
return db.kysely
|
|
454
|
+
.selectFrom('routes_deposit_addresses')
|
|
455
|
+
.selectAll()
|
|
456
|
+
.where('id', '=', id)
|
|
457
|
+
.executeTakeFirst()
|
|
458
|
+
}
|
|
459
|
+
|
|
460
|
+
/** Gets a route deposit address by its provider-owned address. */
|
|
461
|
+
export function getByProviderAddress(
|
|
462
|
+
db: Db.Db,
|
|
463
|
+
options: getByProviderAddress.Options,
|
|
464
|
+
): Promise<Record | undefined> {
|
|
465
|
+
const address = /^0x[0-9a-fA-F]{40}$/.test(options.address)
|
|
466
|
+
? options.address.toLowerCase()
|
|
467
|
+
: options.address
|
|
468
|
+
return db.kysely
|
|
469
|
+
.selectFrom('routes_deposit_addresses')
|
|
470
|
+
.selectAll()
|
|
471
|
+
.where('address', '=', address)
|
|
472
|
+
.where('providerId', '=', options.providerId)
|
|
473
|
+
.where('status', '!=', 'deactivated')
|
|
474
|
+
.executeTakeFirst()
|
|
475
|
+
}
|
|
476
|
+
|
|
477
|
+
export declare namespace getByProviderAddress {
|
|
478
|
+
/** Provider address identity received from a reconciliation trigger. */
|
|
479
|
+
type Options = {
|
|
480
|
+
/** Provider-owned reusable deposit address. */
|
|
481
|
+
address: string
|
|
482
|
+
/** Route provider id. */
|
|
483
|
+
providerId: string
|
|
484
|
+
}
|
|
485
|
+
}
|
|
486
|
+
|
|
487
|
+
/** Gets an owner-visible route deposit address. */
|
|
488
|
+
export function getOwned(db: Db.Db, owner: Owner, id: string): Promise<Record | undefined> {
|
|
489
|
+
let query = db.kysely
|
|
490
|
+
.selectFrom('routes_deposit_addresses')
|
|
491
|
+
.selectAll()
|
|
492
|
+
.where('environment', '=', owner.environment)
|
|
493
|
+
.where('id', '=', id)
|
|
494
|
+
.where('orgId', '=', owner.orgId)
|
|
495
|
+
.where('status', '!=', 'deactivated')
|
|
496
|
+
if (owner.projectId !== undefined) query = query.where('projectId', '=', owner.projectId)
|
|
497
|
+
return query.executeTakeFirst()
|
|
498
|
+
}
|
|
499
|
+
|
|
500
|
+
/** Lists owner-visible route deposit addresses newest-first. */
|
|
501
|
+
export function listByOwner(db: Db.Db, options: listByOwner.Options): Promise<Record[]> {
|
|
502
|
+
const { cursor, limit, owner } = options
|
|
503
|
+
let query = db.kysely
|
|
504
|
+
.selectFrom('routes_deposit_addresses')
|
|
505
|
+
.selectAll()
|
|
506
|
+
.where('environment', '=', owner.environment)
|
|
507
|
+
.where('orgId', '=', owner.orgId)
|
|
508
|
+
.where('status', '!=', 'deactivated')
|
|
509
|
+
if (owner.projectId !== undefined) query = query.where('projectId', '=', owner.projectId)
|
|
510
|
+
if (cursor)
|
|
511
|
+
query = query.where((eb) =>
|
|
512
|
+
eb.or([
|
|
513
|
+
eb('createdAt', '<', cursor.createdAt),
|
|
514
|
+
eb.and([eb('createdAt', '=', cursor.createdAt), eb('id', '<', cursor.id)]),
|
|
515
|
+
]),
|
|
516
|
+
)
|
|
517
|
+
return query.orderBy('createdAt', 'desc').orderBy('id', 'desc').limit(limit).execute()
|
|
518
|
+
}
|
|
519
|
+
|
|
520
|
+
export declare namespace listByOwner {
|
|
521
|
+
/** Ownership and paging options for route deposit addresses. */
|
|
522
|
+
type Options = {
|
|
523
|
+
/** Exclusive lower bound from the previous page. */
|
|
524
|
+
cursor?: Cursor | undefined
|
|
525
|
+
/** Maximum rows to return. */
|
|
526
|
+
limit: number
|
|
527
|
+
/** Ownership filter derived from the authenticated API key. */
|
|
528
|
+
owner: Owner
|
|
529
|
+
}
|
|
530
|
+
|
|
531
|
+
/** Cursor fields for the last address returned by the previous page. */
|
|
532
|
+
type Cursor = {
|
|
533
|
+
/** Deposit address creation time. */
|
|
534
|
+
createdAt: string
|
|
535
|
+
/** Deposit address id, used as a deterministic tie-breaker. */
|
|
536
|
+
id: string
|
|
537
|
+
}
|
|
538
|
+
}
|
|
539
|
+
|
|
540
|
+
/** Lists filtered route deposit addresses, newest update first. */
|
|
541
|
+
export function list(db: Db.Db, options: list.Options): Promise<Record[]> {
|
|
542
|
+
let query = db.kysely.selectFrom('routes_deposit_addresses').selectAll()
|
|
543
|
+
if (options.environments !== undefined)
|
|
544
|
+
query = query.where('environment', 'in', options.environments)
|
|
545
|
+
else if (options.environment !== undefined)
|
|
546
|
+
query = query.where('environment', '=', options.environment)
|
|
547
|
+
if (options.orgId !== undefined) query = query.where('orgId', '=', options.orgId)
|
|
548
|
+
if (options.projectId !== undefined) query = query.where('projectId', '=', options.projectId)
|
|
549
|
+
if (options.providerIds !== undefined)
|
|
550
|
+
query = query.where('providerId', 'in', options.providerIds)
|
|
551
|
+
else if (options.providerId !== undefined)
|
|
552
|
+
query = query.where('providerId', '=', options.providerId)
|
|
553
|
+
if (options.sourceChainIds !== undefined)
|
|
554
|
+
query = query.where('sourceChainId', 'in', options.sourceChainIds)
|
|
555
|
+
else if (options.sourceChainId !== undefined)
|
|
556
|
+
query = query.where('sourceChainId', '=', options.sourceChainId)
|
|
557
|
+
if (options.statuses !== undefined) query = query.where('status', 'in', options.statuses)
|
|
558
|
+
else if (options.status !== undefined) query = query.where('status', '=', options.status)
|
|
559
|
+
if (options.query !== undefined) {
|
|
560
|
+
const exact = options.query
|
|
561
|
+
const address = /^0x[0-9a-fA-F]{40}$/.test(options.query)
|
|
562
|
+
? options.query.toLowerCase()
|
|
563
|
+
: options.query
|
|
564
|
+
const transactionRef = /^(?:0x)?[0-9a-fA-F]{64}$/.test(options.query)
|
|
565
|
+
? options.query.toLowerCase()
|
|
566
|
+
: options.query
|
|
567
|
+
query = query.where((eb) =>
|
|
568
|
+
eb.or([
|
|
569
|
+
eb('address', '=', address),
|
|
570
|
+
eb('id', '=', exact),
|
|
571
|
+
eb.exists(
|
|
572
|
+
eb
|
|
573
|
+
.selectFrom('routes_deposits')
|
|
574
|
+
.select('routes_deposits.id')
|
|
575
|
+
.whereRef('routes_deposits.depositAddressId', '=', 'routes_deposit_addresses.id')
|
|
576
|
+
.where((fb) =>
|
|
577
|
+
fb.or([
|
|
578
|
+
fb('routes_deposits.settlementTransactionHash', '=', transactionRef),
|
|
579
|
+
fb('routes_deposits.sourceTransactionHash', '=', transactionRef),
|
|
580
|
+
sql<boolean>`routes_deposits.provider_transaction_hashes @> ${JSON.stringify([transactionRef])}::jsonb`,
|
|
581
|
+
sql<boolean>`routes_deposits.snapshot->'destinationTransactionHashes' @> ${JSON.stringify([transactionRef])}::jsonb`,
|
|
582
|
+
sql<boolean>`routes_deposits.snapshot->'refundTransactionHashes' @> ${JSON.stringify([transactionRef])}::jsonb`,
|
|
583
|
+
]),
|
|
584
|
+
),
|
|
585
|
+
),
|
|
586
|
+
]),
|
|
587
|
+
)
|
|
588
|
+
}
|
|
589
|
+
const cursor = options.cursor
|
|
590
|
+
if (cursor !== undefined)
|
|
591
|
+
query = query.where((eb) =>
|
|
592
|
+
eb.or([
|
|
593
|
+
eb('updatedAt', '<', cursor.updatedAt),
|
|
594
|
+
eb.and([eb('updatedAt', '=', cursor.updatedAt), eb('id', '<', cursor.id)]),
|
|
595
|
+
]),
|
|
596
|
+
)
|
|
597
|
+
return query.orderBy('updatedAt', 'desc').orderBy('id', 'desc').limit(options.limit).execute()
|
|
598
|
+
}
|
|
599
|
+
|
|
600
|
+
export declare namespace list {
|
|
601
|
+
/** Deposit-address filters and page bound. */
|
|
602
|
+
type Options = {
|
|
603
|
+
/** Exclusive lower bound from the previous page. */
|
|
604
|
+
cursor?: Cursor | undefined
|
|
605
|
+
/** Restricts addresses to one route environment. */
|
|
606
|
+
environment?: Record['environment'] | undefined
|
|
607
|
+
/** Restricts addresses to any listed route environment. */
|
|
608
|
+
environments?: readonly Record['environment'][] | undefined
|
|
609
|
+
/** Maximum rows returned. */
|
|
610
|
+
limit: number
|
|
611
|
+
/** Restricts addresses to one organization. */
|
|
612
|
+
orgId?: string | undefined
|
|
613
|
+
/** Restricts addresses to one project. */
|
|
614
|
+
projectId?: string | undefined
|
|
615
|
+
/** Restricts addresses to one provider. */
|
|
616
|
+
providerId?: string | undefined
|
|
617
|
+
/** Restricts addresses to any listed provider. */
|
|
618
|
+
providerIds?: readonly string[] | undefined
|
|
619
|
+
/** Exact address resource id, deposit address, or related transaction reference. */
|
|
620
|
+
query?: string | undefined
|
|
621
|
+
/** Restricts addresses to one source chain. */
|
|
622
|
+
sourceChainId?: string | undefined
|
|
623
|
+
/** Restricts addresses to any listed source chain. */
|
|
624
|
+
sourceChainIds?: readonly string[] | undefined
|
|
625
|
+
/** Restricts addresses to one lifecycle status. */
|
|
626
|
+
status?: Record['status'] | undefined
|
|
627
|
+
/** Restricts addresses to any listed lifecycle status. */
|
|
628
|
+
statuses?: readonly Record['status'][] | undefined
|
|
629
|
+
}
|
|
630
|
+
|
|
631
|
+
/** Cursor fields for the last address on the previous page. */
|
|
632
|
+
type Cursor = {
|
|
633
|
+
/** Deposit address id, used as a deterministic tie-breaker. */
|
|
634
|
+
id: string
|
|
635
|
+
/** Latest material update time. */
|
|
636
|
+
updatedAt: string
|
|
637
|
+
}
|
|
638
|
+
}
|
|
639
|
+
|
|
640
|
+
/** Summarizes deposit addresses that require operator action. */
|
|
641
|
+
export async function summarize(
|
|
642
|
+
db: Db.Db,
|
|
643
|
+
options: summarize.Options = {},
|
|
644
|
+
): Promise<summarize.Result> {
|
|
645
|
+
let query = db.kysely.selectFrom('routes_deposit_addresses')
|
|
646
|
+
if (options.environments !== undefined)
|
|
647
|
+
query = query.where('environment', 'in', options.environments)
|
|
648
|
+
else if (options.environment !== undefined)
|
|
649
|
+
query = query.where('environment', '=', options.environment)
|
|
650
|
+
if (options.orgId !== undefined) query = query.where('orgId', '=', options.orgId)
|
|
651
|
+
if (options.projectId !== undefined) query = query.where('projectId', '=', options.projectId)
|
|
652
|
+
if (options.providerIds !== undefined)
|
|
653
|
+
query = query.where('providerId', 'in', options.providerIds)
|
|
654
|
+
else if (options.providerId !== undefined)
|
|
655
|
+
query = query.where('providerId', '=', options.providerId)
|
|
656
|
+
if (options.sourceChainIds !== undefined)
|
|
657
|
+
query = query.where('sourceChainId', 'in', options.sourceChainIds)
|
|
658
|
+
else if (options.sourceChainId !== undefined)
|
|
659
|
+
query = query.where('sourceChainId', '=', options.sourceChainId)
|
|
660
|
+
const row = await query
|
|
661
|
+
.select((eb) => [
|
|
662
|
+
eb.fn.countAll<number>().filterWhere('status', '=', 'action-required').as('actionRequired'),
|
|
663
|
+
eb.fn
|
|
664
|
+
.min(eb.fn.coalesce('statusUpdatedAt', 'updatedAt'))
|
|
665
|
+
.filterWhere('status', '=', 'action-required')
|
|
666
|
+
.as('oldestActiveAt'),
|
|
667
|
+
])
|
|
668
|
+
.executeTakeFirstOrThrow()
|
|
669
|
+
return {
|
|
670
|
+
actionRequired: Number(row.actionRequired),
|
|
671
|
+
inProgress: 0,
|
|
672
|
+
oldestActiveAt: row.oldestActiveAt,
|
|
673
|
+
}
|
|
674
|
+
}
|
|
675
|
+
|
|
676
|
+
export declare namespace summarize {
|
|
677
|
+
/** Attribution and route filters. */
|
|
678
|
+
type Options = {
|
|
679
|
+
/** Restricts addresses to one route environment. */
|
|
680
|
+
environment?: Record['environment'] | undefined
|
|
681
|
+
/** Restricts addresses to any listed route environment. */
|
|
682
|
+
environments?: readonly Record['environment'][] | undefined
|
|
683
|
+
/** Restricts addresses to one organization. */
|
|
684
|
+
orgId?: string | undefined
|
|
685
|
+
/** Restricts addresses to one project. */
|
|
686
|
+
projectId?: string | undefined
|
|
687
|
+
/** Restricts addresses to one provider. */
|
|
688
|
+
providerId?: string | undefined
|
|
689
|
+
/** Restricts addresses to any listed provider. */
|
|
690
|
+
providerIds?: readonly string[] | undefined
|
|
691
|
+
/** Restricts addresses to one source chain. */
|
|
692
|
+
sourceChainId?: string | undefined
|
|
693
|
+
/** Restricts addresses to any listed source chain. */
|
|
694
|
+
sourceChainIds?: readonly string[] | undefined
|
|
695
|
+
}
|
|
696
|
+
|
|
697
|
+
/** Current deposit-address work totals. */
|
|
698
|
+
type Result = {
|
|
699
|
+
/** Addresses that require operator action. */
|
|
700
|
+
actionRequired: number
|
|
701
|
+
/** Deposit addresses never count as processing work. */
|
|
702
|
+
inProgress: 0
|
|
703
|
+
/** When the oldest address entered action-required status. */
|
|
704
|
+
oldestActiveAt: string | null
|
|
705
|
+
}
|
|
706
|
+
}
|
|
707
|
+
|
|
708
|
+
/** Gets the reusable address that matches one owner and route identity. */
|
|
709
|
+
export function getMatching(db: Db.Db, match: Match): Promise<Record | undefined> {
|
|
710
|
+
let query = db.kysely
|
|
711
|
+
.selectFrom('routes_deposit_addresses')
|
|
712
|
+
.selectAll()
|
|
713
|
+
.where('destinationTokenKey', '=', match.destinationTokenKey)
|
|
714
|
+
.where('environment', '=', match.environment)
|
|
715
|
+
.where('orgId', '=', match.orgId)
|
|
716
|
+
.where('recipient', '=', match.recipient)
|
|
717
|
+
.where('refundAddress', '=', match.refundAddress)
|
|
718
|
+
.where('sourceChainId', '=', match.sourceChainId)
|
|
719
|
+
.where('sourceTokenKey', '=', match.sourceTokenKey)
|
|
720
|
+
.where('subsidize', '=', match.subsidize)
|
|
721
|
+
query =
|
|
722
|
+
match.projectId === undefined
|
|
723
|
+
? query.where('projectId', 'is', null)
|
|
724
|
+
: query.where('projectId', '=', match.projectId)
|
|
725
|
+
return query.executeTakeFirst()
|
|
726
|
+
}
|
|
727
|
+
|
|
728
|
+
/** Lists active provider addresses for one source-chain token. */
|
|
729
|
+
export function listActiveSources(
|
|
730
|
+
db: Db.Db,
|
|
731
|
+
options: listActiveSources.Options,
|
|
732
|
+
): Promise<readonly Record[]> {
|
|
733
|
+
return db.kysely
|
|
734
|
+
.selectFrom('routes_deposit_addresses')
|
|
735
|
+
.selectAll()
|
|
736
|
+
.where('providerId', '=', options.providerId)
|
|
737
|
+
.where('sourceChainId', '=', options.sourceChainId)
|
|
738
|
+
.where('sourceTokenKey', '=', options.sourceTokenKey)
|
|
739
|
+
.where('status', '=', 'active')
|
|
740
|
+
.orderBy('id', 'asc')
|
|
741
|
+
.execute()
|
|
742
|
+
}
|
|
743
|
+
|
|
744
|
+
export declare namespace listActiveSources {
|
|
745
|
+
/** Provider and source asset identifying one observer shard. */
|
|
746
|
+
type Options = {
|
|
747
|
+
/** Route provider that owns the deposit addresses. */
|
|
748
|
+
providerId: string
|
|
749
|
+
/** Source chain CAIP-2 id. */
|
|
750
|
+
sourceChainId: string
|
|
751
|
+
/** Source token key. */
|
|
752
|
+
sourceTokenKey: string
|
|
753
|
+
}
|
|
754
|
+
}
|
|
755
|
+
|
|
756
|
+
/** Claims a bounded batch of active addresses due for provider reconciliation. */
|
|
757
|
+
export function claimDue(db: Db.Db, options: claimDue.Options): Promise<readonly Record[]> {
|
|
758
|
+
return db.transaction(async (tx) => {
|
|
759
|
+
const due = await tx.kysely
|
|
760
|
+
.selectFrom('routes_deposit_addresses')
|
|
761
|
+
.select('id')
|
|
762
|
+
.where('nextPollAt', '<=', options.now)
|
|
763
|
+
.where('providerId', '=', options.providerId)
|
|
764
|
+
.where('status', '=', 'active')
|
|
765
|
+
.where((eb) =>
|
|
766
|
+
eb.or([eb('pollLeaseUntil', 'is', null), eb('pollLeaseUntil', '<=', options.now)]),
|
|
767
|
+
)
|
|
768
|
+
.orderBy('nextPollAt', 'asc')
|
|
769
|
+
.orderBy('id', 'asc')
|
|
770
|
+
.limit(options.limit)
|
|
771
|
+
.forUpdate()
|
|
772
|
+
.skipLocked()
|
|
773
|
+
.execute()
|
|
774
|
+
if (due.length === 0) return []
|
|
775
|
+
return tx.kysely
|
|
776
|
+
.updateTable('routes_deposit_addresses')
|
|
777
|
+
.set({
|
|
778
|
+
pollLeaseUntil: options.leaseUntil,
|
|
779
|
+
pollLeaseVersion: sql<number>`poll_lease_version + 1`,
|
|
780
|
+
})
|
|
781
|
+
.where(
|
|
782
|
+
'id',
|
|
783
|
+
'in',
|
|
784
|
+
due.map((record) => record.id),
|
|
785
|
+
)
|
|
786
|
+
.returningAll()
|
|
787
|
+
.execute()
|
|
788
|
+
})
|
|
789
|
+
}
|
|
790
|
+
|
|
791
|
+
export declare namespace claimDue {
|
|
792
|
+
/** Provider and lease bounds for one reconciliation claim. */
|
|
793
|
+
type Options = {
|
|
794
|
+
/** Exclusive upper bound on rows claimed in one tick. */
|
|
795
|
+
limit: number
|
|
796
|
+
/** Expiry time assigned to each claimed lease. */
|
|
797
|
+
leaseUntil: string
|
|
798
|
+
/** Current time used for due and expired-lease comparisons. */
|
|
799
|
+
now: string
|
|
800
|
+
/** Route provider whose addresses should be claimed. */
|
|
801
|
+
providerId: string
|
|
802
|
+
}
|
|
803
|
+
}
|
|
804
|
+
|
|
805
|
+
/** Claims one active address unless another reconciliation owns its lease. */
|
|
806
|
+
export function claim(db: Db.Db, options: claim.Options): Promise<Record | undefined> {
|
|
807
|
+
return db.kysely
|
|
808
|
+
.updateTable('routes_deposit_addresses')
|
|
809
|
+
.set({
|
|
810
|
+
pollLeaseUntil: options.leaseUntil,
|
|
811
|
+
pollLeaseVersion: sql<number>`poll_lease_version + 1`,
|
|
812
|
+
})
|
|
813
|
+
.where('id', '=', options.id)
|
|
814
|
+
.where('status', '=', 'active')
|
|
815
|
+
.where((eb) =>
|
|
816
|
+
eb.or([eb('pollLeaseUntil', 'is', null), eb('pollLeaseUntil', '<=', options.now)]),
|
|
817
|
+
)
|
|
818
|
+
.returningAll()
|
|
819
|
+
.executeTakeFirst()
|
|
820
|
+
}
|
|
821
|
+
|
|
822
|
+
export declare namespace claim {
|
|
823
|
+
/** Identity and lease bounds for one reconciliation claim. */
|
|
824
|
+
type Options = {
|
|
825
|
+
/** Route deposit address id (`rda_…`). */
|
|
826
|
+
id: string
|
|
827
|
+
/** Expiry time assigned to the claimed lease. */
|
|
828
|
+
leaseUntil: string
|
|
829
|
+
/** Current time used for expired-lease comparison. */
|
|
830
|
+
now: string
|
|
831
|
+
}
|
|
832
|
+
}
|
|
833
|
+
|
|
834
|
+
/** Extends an active reconciliation lease without changing its fence. */
|
|
835
|
+
export async function renewPoll(db: Db.Db, options: renewPoll.Options): Promise<boolean> {
|
|
836
|
+
return Boolean(
|
|
837
|
+
await db.kysely
|
|
838
|
+
.updateTable('routes_deposit_addresses')
|
|
839
|
+
.set({ pollLeaseUntil: options.leaseUntil })
|
|
840
|
+
.where('id', '=', options.id)
|
|
841
|
+
.where('pollLeaseUntil', 'is not', null)
|
|
842
|
+
.where('pollLeaseVersion', '=', options.pollLeaseVersion)
|
|
843
|
+
.where('status', '=', 'active')
|
|
844
|
+
.returning('id')
|
|
845
|
+
.executeTakeFirst(),
|
|
846
|
+
)
|
|
847
|
+
}
|
|
848
|
+
|
|
849
|
+
export declare namespace renewPoll {
|
|
850
|
+
/** Lease identity and renewed expiry guarded by the current fence. */
|
|
851
|
+
type Options = {
|
|
852
|
+
/** Route deposit address id (`rda_…`). */
|
|
853
|
+
id: string
|
|
854
|
+
/** Replacement reconciliation lease expiry. */
|
|
855
|
+
leaseUntil: string
|
|
856
|
+
/** Fencing token returned by the claim operation. */
|
|
857
|
+
pollLeaseVersion: number
|
|
858
|
+
}
|
|
859
|
+
}
|
|
860
|
+
|
|
861
|
+
/** Saves reconciliation progress before processing a page under an owned lease. */
|
|
862
|
+
export function checkpointPoll(db: Db.Db, options: checkpointPoll.Options) {
|
|
863
|
+
return db.kysely
|
|
864
|
+
.updateTable('routes_deposit_addresses')
|
|
865
|
+
.set({ providerState: options.providerState })
|
|
866
|
+
.where('id', '=', options.id)
|
|
867
|
+
.where('pollLeaseVersion', '=', options.pollLeaseVersion)
|
|
868
|
+
.returningAll()
|
|
869
|
+
.executeTakeFirst()
|
|
870
|
+
}
|
|
871
|
+
|
|
872
|
+
export declare namespace checkpointPoll {
|
|
873
|
+
/** Progress update fenced by the address reconciliation lease. */
|
|
874
|
+
type Options = Pick<completePoll.Options, 'id' | 'pollLeaseVersion' | 'providerState'>
|
|
875
|
+
}
|
|
876
|
+
|
|
877
|
+
/** Completes an owned reconciliation lease and schedules the address again. */
|
|
878
|
+
export function completePoll(
|
|
879
|
+
db: Db.Db,
|
|
880
|
+
options: completePoll.Options,
|
|
881
|
+
): Promise<Record | undefined> {
|
|
882
|
+
return db.kysely
|
|
883
|
+
.updateTable('routes_deposit_addresses')
|
|
884
|
+
.set({
|
|
885
|
+
lastPolledAt: options.lastPolledAt,
|
|
886
|
+
nextPollAt: options.nextPollAt,
|
|
887
|
+
pollFailureCount: 0,
|
|
888
|
+
pollLeaseUntil: null,
|
|
889
|
+
providerRequestIds: JSON.stringify(options.providerRequestIds),
|
|
890
|
+
providerState: options.providerState,
|
|
891
|
+
})
|
|
892
|
+
.where('id', '=', options.id)
|
|
893
|
+
.where('pollLeaseVersion', '=', options.pollLeaseVersion)
|
|
894
|
+
.returningAll()
|
|
895
|
+
.executeTakeFirst()
|
|
896
|
+
}
|
|
897
|
+
|
|
898
|
+
export declare namespace completePoll {
|
|
899
|
+
/** Successful reconciliation result guarded by the claimed lease version. */
|
|
900
|
+
type Options = {
|
|
901
|
+
/** Route deposit address id (`rda_…`). */
|
|
902
|
+
id: string
|
|
903
|
+
/** Time when provider reconciliation completed. */
|
|
904
|
+
lastPolledAt: string
|
|
905
|
+
/** Time when this address becomes due again. */
|
|
906
|
+
nextPollAt: string
|
|
907
|
+
/** Fencing token returned by {@link claimDue}. */
|
|
908
|
+
pollLeaseVersion: number
|
|
909
|
+
/** Provider request identifiers retained from address provisioning. */
|
|
910
|
+
providerRequestIds: readonly string[]
|
|
911
|
+
/** Bounded provider reconciliation state. */
|
|
912
|
+
providerState: Record['providerState']
|
|
913
|
+
}
|
|
914
|
+
}
|
|
915
|
+
|
|
916
|
+
/** Releases an owned reconciliation lease after failure and schedules a retry. */
|
|
917
|
+
export function failPoll(db: Db.Db, options: failPoll.Options): Promise<Record | undefined> {
|
|
918
|
+
return db.kysely
|
|
919
|
+
.updateTable('routes_deposit_addresses')
|
|
920
|
+
.set({
|
|
921
|
+
nextPollAt: options.nextPollAt,
|
|
922
|
+
pollFailureCount: sql<number>`poll_failure_count + 1`,
|
|
923
|
+
pollLeaseUntil: null,
|
|
924
|
+
})
|
|
925
|
+
.where('id', '=', options.id)
|
|
926
|
+
.where('pollLeaseVersion', '=', options.pollLeaseVersion)
|
|
927
|
+
.returningAll()
|
|
928
|
+
.executeTakeFirst()
|
|
929
|
+
}
|
|
930
|
+
|
|
931
|
+
export declare namespace failPoll {
|
|
932
|
+
/** Failed reconciliation result guarded by the claimed lease version. */
|
|
933
|
+
type Options = {
|
|
934
|
+
/** Route deposit address id (`rda_…`). */
|
|
935
|
+
id: string
|
|
936
|
+
/** Time when this address becomes eligible for retry. */
|
|
937
|
+
nextPollAt: string
|
|
938
|
+
/** Fencing token returned by {@link claimDue}. */
|
|
939
|
+
pollLeaseVersion: number
|
|
940
|
+
}
|
|
941
|
+
}
|
|
942
|
+
|
|
943
|
+
/** Applies a version-guarded deposit address status update. */
|
|
944
|
+
export function update(db: Db.Db, options: update.Options): Promise<Record | undefined> {
|
|
945
|
+
return db.kysely
|
|
946
|
+
.updateTable('routes_deposit_addresses')
|
|
947
|
+
.set({
|
|
948
|
+
status: options.status,
|
|
949
|
+
statusUpdatedAt: options.statusUpdatedAt,
|
|
950
|
+
updatedAt: options.updatedAt,
|
|
951
|
+
version: options.version,
|
|
952
|
+
})
|
|
953
|
+
.where('id', '=', options.id)
|
|
954
|
+
.where('version', '=', options.expectedVersion)
|
|
955
|
+
.returningAll()
|
|
956
|
+
.executeTakeFirst()
|
|
957
|
+
}
|
|
958
|
+
|
|
959
|
+
export declare namespace update {
|
|
960
|
+
/** Guarded address update fields. */
|
|
961
|
+
type Options = {
|
|
962
|
+
/** Stored version required for the update. */
|
|
963
|
+
expectedVersion: number
|
|
964
|
+
/** Route deposit address id (`rda_…`). */
|
|
965
|
+
id: string
|
|
966
|
+
/** Replacement lifecycle status. */
|
|
967
|
+
status: Record['status']
|
|
968
|
+
/** When the address entered its current status. */
|
|
969
|
+
statusUpdatedAt: Record['statusUpdatedAt']
|
|
970
|
+
/** New material update time. */
|
|
971
|
+
updatedAt: string
|
|
972
|
+
/** New material version. */
|
|
973
|
+
version: number
|
|
974
|
+
}
|
|
975
|
+
}
|
|
976
|
+
|
|
977
|
+
/** The capacity claim was replaced before it could be reserved. */
|
|
978
|
+
export class CapacityClaimNotFoundError extends Error {
|
|
979
|
+
override readonly name = 'RoutesDepositAddresses.CapacityClaimNotFoundError'
|
|
980
|
+
}
|
|
981
|
+
|
|
982
|
+
/** Provider address conflicted with a different customer-visible identity. */
|
|
983
|
+
export class ConflictError extends Error {
|
|
984
|
+
override name = 'RoutesDepositAddresses.ConflictError'
|
|
985
|
+
}
|
|
986
|
+
|
|
987
|
+
/** Organization deposit-address cap reached. */
|
|
988
|
+
export class LimitExceededError extends Error {
|
|
989
|
+
override name = 'RoutesDepositAddresses.LimitExceededError'
|
|
990
|
+
|
|
991
|
+
/** Maximum durable deposit addresses the organization may own. */
|
|
992
|
+
limit: number
|
|
993
|
+
|
|
994
|
+
constructor(limit: number) {
|
|
995
|
+
super(`Route deposit address limit reached (${limit}).`)
|
|
996
|
+
this.limit = limit
|
|
997
|
+
}
|
|
998
|
+
}
|
|
999
|
+
|
|
1000
|
+
/** Another request owns provider provisioning for the same reusable match. */
|
|
1001
|
+
export class MatchInProgressError extends Error {
|
|
1002
|
+
override readonly name = 'RoutesDepositAddresses.MatchInProgressError'
|
|
1003
|
+
}
|
|
1004
|
+
|
|
1005
|
+
/** Owning organization disappeared before address persistence. */
|
|
1006
|
+
export class OwnerNotFoundError extends Error {
|
|
1007
|
+
override name = 'RoutesDepositAddresses.OwnerNotFoundError'
|
|
1008
|
+
}
|