tapimo 0.7.1 → 0.8.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 +10 -7
- package/dist/ApiKey.d.ts +3 -0
- package/dist/ApiKey.d.ts.map +1 -1
- package/dist/ApiKey.js +10 -0
- package/dist/ApiKey.js.map +1 -1
- package/dist/ApiKeys.d.ts +29 -8
- package/dist/ApiKeys.d.ts.map +1 -1
- package/dist/ApiKeys.js +24 -5
- package/dist/ApiKeys.js.map +1 -1
- package/dist/App.d.ts +20680 -15487
- package/dist/App.d.ts.map +1 -1
- package/dist/App.js +250 -129
- package/dist/App.js.map +1 -1
- package/dist/Assets.d.ts +10 -0
- package/dist/Assets.d.ts.map +1 -1
- package/dist/Assets.js +17 -4
- package/dist/Assets.js.map +1 -1
- package/dist/Scope.d.ts +19 -8
- package/dist/Scope.d.ts.map +1 -1
- package/dist/Scope.js +25 -9
- package/dist/Scope.js.map +1 -1
- package/dist/Webhooks.d.ts +1 -1
- package/dist/admin/App.d.ts +667 -76
- package/dist/admin/App.d.ts.map +1 -1
- package/dist/admin/App.js +12 -2
- package/dist/admin/App.js.map +1 -1
- package/dist/admin/apps/api-keys.d.ts +107 -11
- package/dist/admin/apps/api-keys.d.ts.map +1 -1
- package/dist/admin/apps/api-keys.js +145 -32
- package/dist/admin/apps/api-keys.js.map +1 -1
- package/dist/admin/apps/earn-vaults.d.ts +1069 -0
- package/dist/admin/apps/earn-vaults.d.ts.map +1 -0
- package/dist/admin/apps/earn-vaults.js +409 -0
- package/dist/admin/apps/earn-vaults.js.map +1 -0
- package/dist/admin/apps/organizations.d.ts +2 -0
- package/dist/admin/apps/organizations.d.ts.map +1 -1
- package/dist/admin/apps/verified-tokens.d.ts +74 -74
- 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 +99 -43
- package/dist/admin/ui.generated.js.map +1 -1
- package/dist/analytics/Analytics.d.ts +4 -0
- package/dist/analytics/Analytics.d.ts.map +1 -1
- package/dist/analytics/Analytics.js +21 -2
- package/dist/analytics/Analytics.js.map +1 -1
- package/dist/analytics/tables/requestEvents.d.ts +22 -1
- package/dist/analytics/tables/requestEvents.d.ts.map +1 -1
- package/dist/analytics/tables/requestEvents.js +59 -39
- package/dist/analytics/tables/requestEvents.js.map +1 -1
- package/dist/apps/Zones.d.ts +8335 -0
- package/dist/apps/Zones.d.ts.map +1 -0
- package/dist/apps/Zones.js +38 -0
- package/dist/apps/Zones.js.map +1 -0
- package/dist/apps/data/App.d.ts +5666 -3934
- package/dist/apps/data/App.d.ts.map +1 -1
- package/dist/apps/data/App.js +90 -22
- package/dist/apps/data/App.js.map +1 -1
- package/dist/apps/data/FxOracle.d.ts +1 -1
- package/dist/apps/data/FxOracle.d.ts.map +1 -1
- package/dist/apps/data/index.d.ts +0 -1
- package/dist/apps/data/index.d.ts.map +1 -1
- package/dist/apps/data/index.js +0 -1
- package/dist/apps/data/index.js.map +1 -1
- package/dist/apps/data/routes/activities.d.ts +56 -56
- package/dist/apps/data/routes/activities.d.ts.map +1 -1
- package/dist/apps/data/routes/activities.js +130 -65
- package/dist/apps/data/routes/activities.js.map +1 -1
- package/dist/apps/data/routes/addresses.d.ts +65 -65
- package/dist/apps/data/routes/balances.d.ts +14 -14
- package/dist/apps/data/routes/balances.js +5 -5
- package/dist/apps/data/routes/balances.js.map +1 -1
- package/dist/apps/data/routes/blocks.d.ts +39 -39
- package/dist/apps/data/routes/coingecko.d.ts +54 -54
- package/dist/apps/data/routes/coingecko.d.ts.map +1 -1
- package/dist/apps/data/routes/coingecko.js +62 -35
- package/dist/apps/data/routes/coingecko.js.map +1 -1
- package/dist/apps/data/routes/earn.d.ts +2574 -0
- package/dist/apps/data/routes/earn.d.ts.map +1 -0
- package/dist/apps/data/routes/earn.js +1574 -0
- package/dist/apps/data/routes/earn.js.map +1 -0
- package/dist/apps/data/routes/exchanges.d.ts +1626 -719
- package/dist/apps/data/routes/exchanges.d.ts.map +1 -1
- package/dist/apps/data/routes/exchanges.js +656 -193
- package/dist/apps/data/routes/exchanges.js.map +1 -1
- package/dist/apps/data/routes/fee-amm.d.ts +108 -108
- package/dist/apps/data/routes/fee-amm.d.ts.map +1 -1
- package/dist/apps/data/routes/fee-amm.js +59 -8
- package/dist/apps/data/routes/fee-amm.js.map +1 -1
- package/dist/apps/data/routes/indexer.d.ts +35 -35
- package/dist/apps/data/routes/indexer.d.ts.map +1 -1
- package/dist/apps/data/routes/indexer.js +23 -3
- package/dist/apps/data/routes/indexer.js.map +1 -1
- package/dist/apps/data/routes/receipts.d.ts +33 -33
- package/dist/apps/data/routes/receipts.d.ts.map +1 -1
- package/dist/apps/data/routes/receipts.js +11 -11
- package/dist/apps/data/routes/receipts.js.map +1 -1
- package/dist/apps/data/routes/rpc.d.ts +6 -6
- package/dist/apps/data/routes/rpc.d.ts.map +1 -1
- package/dist/apps/data/routes/rpc.js +214 -22
- package/dist/apps/data/routes/rpc.js.map +1 -1
- package/dist/apps/data/routes/tokenlist.d.ts +1 -1
- package/dist/apps/data/routes/tokenlist.d.ts.map +1 -1
- package/dist/apps/data/routes/tokenlist.js +39 -8
- package/dist/apps/data/routes/tokenlist.js.map +1 -1
- package/dist/apps/data/routes/tokens.d.ts +115 -87
- package/dist/apps/data/routes/tokens.d.ts.map +1 -1
- package/dist/apps/data/routes/tokens.js +194 -91
- package/dist/apps/data/routes/tokens.js.map +1 -1
- package/dist/apps/data/routes/transactions.d.ts +54 -54
- package/dist/apps/data/routes/transactions.d.ts.map +1 -1
- package/dist/apps/data/routes/transactions.js +78 -39
- package/dist/apps/data/routes/transactions.js.map +1 -1
- package/dist/apps/data/routes/transfers.d.ts +76 -27
- package/dist/apps/data/routes/transfers.d.ts.map +1 -1
- package/dist/apps/data/routes/transfers.js +165 -67
- package/dist/apps/data/routes/transfers.js.map +1 -1
- package/dist/apps/data/routes/valuation.d.ts +42 -42
- package/dist/apps/data/routes/valuation.js +2 -2
- package/dist/apps/data/routes/valuation.js.map +1 -1
- package/dist/apps/data/routes/verified-tokens.d.ts +36 -36
- package/dist/apps/data/routes/webhooks.d.ts +370 -368
- package/dist/apps/data/routes/webhooks.d.ts.map +1 -1
- package/dist/apps/data/routes/webhooks.js +161 -59
- package/dist/apps/data/routes/webhooks.js.map +1 -1
- package/dist/apps/data/routes/zones.d.ts +281 -0
- package/dist/apps/data/routes/zones.d.ts.map +1 -0
- package/dist/apps/data/routes/zones.js +252 -0
- package/dist/apps/data/routes/zones.js.map +1 -0
- package/dist/apps/docs/reference.js +6 -5
- package/dist/apps/docs/reference.js.map +1 -1
- package/dist/apps/funding/Access.d.ts +16 -0
- package/dist/apps/funding/Access.d.ts.map +1 -0
- package/dist/apps/funding/Access.js +22 -0
- package/dist/apps/funding/Access.js.map +1 -0
- package/dist/apps/funding/App.d.ts +3183 -0
- package/dist/apps/funding/App.d.ts.map +1 -0
- package/dist/apps/funding/App.js +46 -0
- package/dist/apps/funding/App.js.map +1 -0
- package/dist/apps/funding/Inventory.d.ts +5 -0
- package/dist/apps/funding/Inventory.d.ts.map +1 -0
- package/dist/apps/funding/Inventory.js +25 -0
- package/dist/apps/funding/Inventory.js.map +1 -0
- package/dist/apps/funding/ProviderAttempts.d.ts +5 -0
- package/dist/apps/funding/ProviderAttempts.d.ts.map +1 -0
- package/dist/apps/funding/ProviderAttempts.js +24 -0
- package/dist/apps/funding/ProviderAttempts.js.map +1 -0
- package/dist/apps/funding/index.d.ts +2 -0
- package/dist/apps/funding/index.d.ts.map +1 -0
- package/dist/apps/funding/index.js +2 -0
- package/dist/apps/funding/index.js.map +1 -0
- package/dist/apps/funding/routes/chains.d.ts +169 -0
- package/dist/apps/funding/routes/chains.d.ts.map +1 -0
- package/dist/apps/funding/routes/chains.js +80 -0
- package/dist/apps/funding/routes/chains.js.map +1 -0
- package/dist/apps/funding/routes/deposit-addresses.d.ts +2388 -0
- package/dist/apps/funding/routes/deposit-addresses.d.ts.map +1 -0
- package/dist/apps/funding/routes/deposit-addresses.js +860 -0
- package/dist/apps/funding/routes/deposit-addresses.js.map +1 -0
- package/dist/apps/funding/routes/providers.d.ts +91 -0
- package/dist/apps/funding/routes/providers.d.ts.map +1 -0
- package/dist/apps/funding/routes/providers.js +56 -0
- package/dist/apps/funding/routes/providers.js.map +1 -0
- package/dist/apps/{data/routes/funding.d.ts → funding/routes/quotes.d.ts} +26 -396
- package/dist/apps/funding/routes/quotes.d.ts.map +1 -0
- package/dist/apps/funding/routes/quotes.js +188 -0
- package/dist/apps/funding/routes/quotes.js.map +1 -0
- package/dist/apps/funding/routes/transfers.d.ts +1999 -0
- package/dist/apps/funding/routes/transfers.d.ts.map +1 -0
- package/dist/apps/funding/routes/transfers.js +614 -0
- package/dist/apps/funding/routes/transfers.js.map +1 -0
- package/dist/apps/index.d.ts +3 -1
- package/dist/apps/index.d.ts.map +1 -1
- package/dist/apps/index.js +3 -1
- package/dist/apps/index.js.map +1 -1
- package/dist/apps/management/App.d.ts +839 -574
- package/dist/apps/management/App.d.ts.map +1 -1
- package/dist/apps/management/Billing.d.ts +8 -0
- package/dist/apps/management/Billing.d.ts.map +1 -1
- package/dist/apps/management/Billing.js +12 -0
- package/dist/apps/management/Billing.js.map +1 -1
- package/dist/apps/management/Error.d.ts +12 -0
- package/dist/apps/management/Error.d.ts.map +1 -0
- package/dist/apps/management/Error.js +10 -0
- package/dist/apps/management/Error.js.map +1 -0
- package/dist/apps/management/routes/api-keys.d.ts +296 -19
- package/dist/apps/management/routes/api-keys.d.ts.map +1 -1
- package/dist/apps/management/routes/api-keys.js +77 -9
- package/dist/apps/management/routes/api-keys.js.map +1 -1
- package/dist/apps/management/routes/billing.d.ts +119 -119
- package/dist/apps/management/routes/faucet.d.ts +35 -35
- package/dist/apps/management/routes/invitations.d.ts +17 -17
- package/dist/apps/management/routes/invitations.d.ts.map +1 -1
- package/dist/apps/management/routes/invitations.js +4 -10
- package/dist/apps/management/routes/invitations.js.map +1 -1
- package/dist/apps/management/routes/invite-links.d.ts +38 -38
- package/dist/apps/management/routes/me.d.ts +6 -6
- package/dist/apps/management/routes/members.d.ts +69 -69
- package/dist/apps/management/routes/orgs.d.ts +16 -16
- package/dist/apps/management/routes/orgs.d.ts.map +1 -1
- package/dist/apps/management/routes/orgs.js +2 -8
- package/dist/apps/management/routes/orgs.js.map +1 -1
- package/dist/apps/management/routes/projects.d.ts +19 -19
- package/dist/apps/management/routes/scopes.d.ts +1 -1
- package/dist/apps/management/routes/scopes.js +2 -2
- package/dist/apps/management/routes/scopes.js.map +1 -1
- package/dist/apps/management/routes/usage.d.ts +72 -72
- package/dist/apps/management/routes/verified-token-requests.d.ts +18 -18
- package/dist/apps/management/routes/webhooks.d.ts +122 -122
- package/dist/apps/management/routes/webhooks.d.ts.map +1 -1
- package/dist/apps/management/routes/webhooks.js +15 -3
- package/dist/apps/management/routes/webhooks.js.map +1 -1
- package/dist/apps/mcp.d.ts +2 -3
- package/dist/apps/mcp.d.ts.map +1 -1
- package/dist/apps/mcp.js +16 -14
- package/dist/apps/mcp.js.map +1 -1
- package/dist/apps/metadata.d.ts +4 -0
- package/dist/apps/metadata.d.ts.map +1 -1
- package/dist/apps/metadata.js +10 -0
- package/dist/apps/metadata.js.map +1 -1
- package/dist/apps/mpp/App.d.ts +57 -58
- package/dist/apps/mpp/App.d.ts.map +1 -1
- package/dist/apps/mpp/App.js +192 -27
- package/dist/apps/mpp/App.js.map +1 -1
- package/dist/apps/mpp/Mpp.d.ts +0 -20
- package/dist/apps/mpp/Mpp.d.ts.map +1 -1
- package/dist/apps/mpp/Mpp.js +0 -24
- package/dist/apps/mpp/Mpp.js.map +1 -1
- package/dist/apps/mpp/internal/Adapter.d.ts +40 -0
- package/dist/apps/mpp/internal/Adapter.d.ts.map +1 -0
- package/dist/apps/mpp/internal/Adapter.js +66 -0
- package/dist/apps/mpp/internal/Adapter.js.map +1 -0
- package/dist/apps/mpp/internal/Error.d.ts +4 -0
- package/dist/apps/mpp/internal/Error.d.ts.map +1 -0
- package/dist/apps/mpp/internal/Error.js +41 -0
- package/dist/apps/mpp/internal/Error.js.map +1 -0
- package/dist/apps/mpp/internal/Idempotency.d.ts +33 -0
- package/dist/apps/mpp/internal/Idempotency.d.ts.map +1 -0
- package/dist/apps/mpp/internal/Idempotency.js +28 -0
- package/dist/apps/mpp/internal/Idempotency.js.map +1 -0
- package/dist/apps/mpp/internal/Policy.d.ts +46 -0
- package/dist/apps/mpp/internal/Policy.d.ts.map +1 -0
- package/dist/apps/mpp/internal/Policy.js +57 -0
- package/dist/apps/mpp/internal/Policy.js.map +1 -0
- package/dist/apps/mpp/internal/ScreenManager.d.ts +27 -0
- package/dist/apps/mpp/internal/ScreenManager.d.ts.map +1 -0
- package/dist/apps/mpp/internal/ScreenManager.js +18 -0
- package/dist/apps/mpp/internal/ScreenManager.js.map +1 -0
- package/dist/apps/mpp/internal/Screening.d.ts +35 -0
- package/dist/apps/mpp/internal/Screening.d.ts.map +1 -0
- package/dist/apps/mpp/internal/Screening.js +20 -0
- package/dist/apps/mpp/internal/Screening.js.map +1 -0
- package/dist/apps/mpp/internal/Sponsorship.d.ts +36 -0
- package/dist/apps/mpp/internal/Sponsorship.d.ts.map +1 -0
- package/dist/apps/mpp/internal/Sponsorship.js +103 -0
- package/dist/apps/mpp/internal/Sponsorship.js.map +1 -0
- package/dist/apps/mpp/internal/Utils.d.ts +7 -0
- package/dist/apps/mpp/internal/Utils.d.ts.map +1 -0
- package/dist/apps/mpp/internal/Utils.js +24 -0
- package/dist/apps/mpp/internal/Utils.js.map +1 -0
- package/dist/apps/relay/App.js +183 -23
- package/dist/apps/relay/App.js.map +1 -1
- package/dist/apps/relay/Sponsorships.d.ts +4 -0
- package/dist/apps/relay/Sponsorships.d.ts.map +1 -1
- package/dist/apps/relay/Sponsorships.js +15 -6
- package/dist/apps/relay/Sponsorships.js.map +1 -1
- package/dist/cloudflare.d.ts +50 -0
- package/dist/cloudflare.d.ts.map +1 -1
- package/dist/cloudflare.js +178 -0
- package/dist/cloudflare.js.map +1 -1
- package/dist/db/Db.d.ts +22 -0
- package/dist/db/Db.d.ts.map +1 -1
- package/dist/db/Db.js +379 -0
- package/dist/db/Db.js.map +1 -1
- package/dist/db/Schema.d.ts +933 -1
- package/dist/db/Schema.d.ts.map +1 -1
- package/dist/db/Schema.js +289 -1
- package/dist/db/Schema.js.map +1 -1
- package/dist/db/tables/earnVaults.d.ts +68 -0
- package/dist/db/tables/earnVaults.d.ts.map +1 -0
- package/dist/db/tables/earnVaults.js +72 -0
- package/dist/db/tables/earnVaults.js.map +1 -0
- package/dist/db/tables/fundingCatalog.d.ts +56 -0
- package/dist/db/tables/fundingCatalog.d.ts.map +1 -0
- package/dist/db/tables/fundingCatalog.js +85 -0
- package/dist/db/tables/fundingCatalog.js.map +1 -0
- package/dist/db/tables/fundingDepositAddresses.d.ts +172 -0
- package/dist/db/tables/fundingDepositAddresses.d.ts.map +1 -0
- package/dist/db/tables/fundingDepositAddresses.js +218 -0
- package/dist/db/tables/fundingDepositAddresses.js.map +1 -0
- package/dist/db/tables/fundingDepositRequestObservations.d.ts +45 -0
- package/dist/db/tables/fundingDepositRequestObservations.d.ts.map +1 -0
- package/dist/db/tables/fundingDepositRequestObservations.js +46 -0
- package/dist/db/tables/fundingDepositRequestObservations.js.map +1 -0
- package/dist/db/tables/fundingDeposits.d.ts +171 -0
- package/dist/db/tables/fundingDeposits.d.ts.map +1 -0
- package/dist/db/tables/fundingDeposits.js +182 -0
- package/dist/db/tables/fundingDeposits.js.map +1 -0
- package/dist/db/tables/fundingIdempotency.d.ts +91 -0
- package/dist/db/tables/fundingIdempotency.d.ts.map +1 -0
- package/dist/db/tables/fundingIdempotency.js +103 -0
- package/dist/db/tables/fundingIdempotency.js.map +1 -0
- package/dist/db/tables/fundingTransferEvents.d.ts +12 -0
- package/dist/db/tables/fundingTransferEvents.d.ts.map +1 -0
- package/dist/db/tables/fundingTransferEvents.js +18 -0
- package/dist/db/tables/fundingTransferEvents.js.map +1 -0
- package/dist/db/tables/fundingTransferTransactions.d.ts +15 -0
- package/dist/db/tables/fundingTransferTransactions.d.ts.map +1 -0
- package/dist/db/tables/fundingTransferTransactions.js +27 -0
- package/dist/db/tables/fundingTransferTransactions.js.map +1 -0
- package/dist/db/tables/fundingTransfers.d.ts +82 -0
- package/dist/db/tables/fundingTransfers.d.ts.map +1 -0
- package/dist/db/tables/fundingTransfers.js +89 -0
- package/dist/db/tables/fundingTransfers.js.map +1 -0
- package/dist/db/tables/organizations.d.ts +8 -0
- package/dist/db/tables/organizations.d.ts.map +1 -1
- package/dist/db/tables/organizations.js +16 -0
- package/dist/db/tables/organizations.js.map +1 -1
- package/dist/db/tables/projects.d.ts +8 -0
- package/dist/db/tables/projects.d.ts.map +1 -1
- package/dist/db/tables/projects.js +16 -0
- package/dist/db/tables/projects.js.map +1 -1
- package/dist/db/tables/requestUsage.d.ts +13 -0
- package/dist/db/tables/requestUsage.d.ts.map +1 -1
- package/dist/db/tables/requestUsage.js +16 -0
- package/dist/db/tables/requestUsage.js.map +1 -1
- package/dist/db/tables/sponsoredTransactions.d.ts +2 -2
- package/dist/db/tables/sponsoredTransactions.d.ts.map +1 -1
- package/dist/db/tables/sponsoredTransactions.js +1 -1
- package/dist/db/tables/sponsoredTransactions.js.map +1 -1
- package/dist/db/tables/users.d.ts +8 -0
- package/dist/db/tables/users.d.ts.map +1 -1
- package/dist/db/tables/users.js +16 -0
- package/dist/db/tables/users.js.map +1 -1
- package/dist/db/tables/verifiedTokens.d.ts +14 -7
- package/dist/db/tables/verifiedTokens.d.ts.map +1 -1
- package/dist/db/tables/verifiedTokens.js +9 -7
- package/dist/db/tables/verifiedTokens.js.map +1 -1
- package/dist/db/tables/webhookSubscriptions.d.ts +31 -1
- package/dist/db/tables/webhookSubscriptions.d.ts.map +1 -1
- package/dist/db/tables/webhookSubscriptions.js +24 -3
- package/dist/db/tables/webhookSubscriptions.js.map +1 -1
- package/dist/handlers/relay.js +108 -108
- package/dist/handlers/relay.js.map +1 -1
- package/dist/internal/Auth.d.ts +37 -11
- package/dist/internal/Auth.d.ts.map +1 -1
- package/dist/internal/Auth.js +75 -16
- package/dist/internal/Auth.js.map +1 -1
- package/dist/internal/Cache.d.ts.map +1 -1
- package/dist/internal/Cache.js +17 -11
- package/dist/internal/Cache.js.map +1 -1
- package/dist/internal/Cursor.js +1 -1
- package/dist/internal/Cursor.js.map +1 -1
- package/dist/internal/EarnRates.d.ts +89 -0
- package/dist/internal/EarnRates.d.ts.map +1 -0
- package/dist/internal/EarnRates.js +266 -0
- package/dist/internal/EarnRates.js.map +1 -0
- package/dist/internal/EarnVaults.d.ts +171 -0
- package/dist/internal/EarnVaults.d.ts.map +1 -0
- package/dist/internal/EarnVaults.js +547 -0
- package/dist/internal/EarnVaults.js.map +1 -0
- package/dist/internal/EdgeCache.d.ts +10 -3
- package/dist/internal/EdgeCache.d.ts.map +1 -1
- package/dist/internal/EdgeCache.js +43 -11
- package/dist/internal/EdgeCache.js.map +1 -1
- package/dist/internal/Id.d.ts +11 -0
- package/dist/internal/Id.d.ts.map +1 -1
- package/dist/internal/Id.js +13 -0
- package/dist/internal/Id.js.map +1 -1
- package/dist/internal/Idempotency.d.ts +83 -0
- package/dist/internal/Idempotency.d.ts.map +1 -0
- package/dist/internal/Idempotency.js +113 -0
- package/dist/internal/Idempotency.js.map +1 -0
- package/dist/internal/IpAllowlist.d.ts +15 -0
- package/dist/internal/IpAllowlist.d.ts.map +1 -0
- package/dist/internal/IpAllowlist.js +27 -0
- package/dist/internal/IpAllowlist.js.map +1 -0
- package/dist/internal/Log.d.ts +64 -9
- package/dist/internal/Log.d.ts.map +1 -1
- package/dist/internal/Log.js +29 -7
- package/dist/internal/Log.js.map +1 -1
- package/dist/internal/MetricSink.d.ts.map +1 -1
- package/dist/internal/MetricSink.js +47 -1
- package/dist/internal/MetricSink.js.map +1 -1
- package/dist/internal/OpenApi.d.ts +2 -2
- package/dist/internal/OpenApi.d.ts.map +1 -1
- package/dist/internal/OpenApi.js +4 -1
- package/dist/internal/OpenApi.js.map +1 -1
- package/dist/internal/Provider.d.ts +14 -0
- package/dist/internal/Provider.d.ts.map +1 -0
- package/dist/internal/Provider.js +5 -0
- package/dist/internal/Provider.js.map +1 -0
- package/dist/internal/Schema.d.ts +6 -1
- package/dist/internal/Schema.d.ts.map +1 -1
- package/dist/internal/Schema.js +20 -11
- package/dist/internal/Schema.js.map +1 -1
- package/dist/internal/Store.d.ts +6 -0
- package/dist/internal/Store.d.ts.map +1 -1
- package/dist/internal/Store.js +35 -0
- package/dist/internal/Store.js.map +1 -1
- package/dist/internal/Tidx.d.ts +49 -24
- package/dist/internal/Tidx.d.ts.map +1 -1
- package/dist/internal/Tidx.js +90 -12
- package/dist/internal/Tidx.js.map +1 -1
- package/dist/internal/Viem.d.ts +90 -65
- package/dist/internal/Viem.d.ts.map +1 -1
- package/dist/internal/Viem.js +90 -12
- package/dist/internal/Viem.js.map +1 -1
- package/dist/internal/WebhookDestination.d.ts.map +1 -1
- package/dist/internal/WebhookDestination.js +34 -28
- package/dist/internal/WebhookDestination.js.map +1 -1
- package/dist/internal/Webhooks.d.ts +9 -0
- package/dist/internal/Webhooks.d.ts.map +1 -1
- package/dist/internal/Webhooks.js +15 -10
- package/dist/internal/Webhooks.js.map +1 -1
- package/dist/internal/exchange/Provider.d.ts +219 -0
- package/dist/internal/exchange/Provider.d.ts.map +1 -0
- package/dist/internal/exchange/Provider.js +117 -0
- package/dist/internal/exchange/Provider.js.map +1 -0
- package/dist/internal/exchange/index.d.ts +2 -0
- package/dist/internal/exchange/index.d.ts.map +1 -0
- package/dist/internal/exchange/index.js +2 -0
- package/dist/internal/exchange/index.js.map +1 -0
- package/dist/internal/exchange/providers/uniswap.d.ts +57 -0
- package/dist/internal/exchange/providers/uniswap.d.ts.map +1 -0
- package/dist/internal/exchange/providers/uniswap.js +553 -0
- package/dist/internal/exchange/providers/uniswap.js.map +1 -0
- package/dist/internal/funding/Action.d.ts +55 -0
- package/dist/internal/funding/Action.d.ts.map +1 -0
- package/dist/internal/funding/Action.js +74 -0
- package/dist/internal/funding/Action.js.map +1 -0
- package/dist/internal/funding/Catalog.d.ts +107 -0
- package/dist/internal/funding/Catalog.d.ts.map +1 -0
- package/dist/internal/funding/Catalog.js +270 -0
- package/dist/internal/funding/Catalog.js.map +1 -0
- package/dist/internal/funding/Chain.d.ts +76 -0
- package/dist/internal/funding/Chain.d.ts.map +1 -0
- package/dist/internal/funding/Chain.js +38 -0
- package/dist/internal/funding/Chain.js.map +1 -0
- package/dist/internal/funding/Deposit.d.ts +408 -0
- package/dist/internal/funding/Deposit.d.ts.map +1 -0
- package/dist/internal/funding/Deposit.js +318 -0
- package/dist/internal/funding/Deposit.js.map +1 -0
- package/dist/internal/funding/DepositAddress.d.ts +345 -0
- package/dist/internal/funding/DepositAddress.d.ts.map +1 -0
- package/dist/internal/funding/DepositAddress.js +189 -0
- package/dist/internal/funding/DepositAddress.js.map +1 -0
- package/dist/internal/funding/Evidence.d.ts +48 -0
- package/dist/internal/funding/Evidence.d.ts.map +1 -0
- package/dist/internal/funding/Evidence.js +315 -0
- package/dist/internal/funding/Evidence.js.map +1 -0
- package/dist/internal/funding/Provider.d.ts +1288 -0
- package/dist/internal/funding/Provider.d.ts.map +1 -0
- package/dist/internal/funding/Provider.js +1086 -0
- package/dist/internal/funding/Provider.js.map +1 -0
- package/dist/internal/funding/Reconciliation.d.ts +127 -0
- package/dist/internal/funding/Reconciliation.d.ts.map +1 -0
- package/dist/internal/funding/Reconciliation.js +885 -0
- package/dist/internal/funding/Reconciliation.js.map +1 -0
- package/dist/internal/funding/Route.d.ts +21 -0
- package/dist/internal/funding/Route.d.ts.map +1 -0
- package/dist/internal/funding/Route.js +5 -0
- package/dist/internal/funding/Route.js.map +1 -0
- package/dist/internal/funding/SourceObservation.d.ts +108 -0
- package/dist/internal/funding/SourceObservation.d.ts.map +1 -0
- package/dist/internal/funding/SourceObservation.js +143 -0
- package/dist/internal/funding/SourceObservation.js.map +1 -0
- package/dist/internal/funding/Subsidy.d.ts +113 -0
- package/dist/internal/funding/Subsidy.d.ts.map +1 -0
- package/dist/internal/funding/Subsidy.js +138 -0
- package/dist/internal/funding/Subsidy.js.map +1 -0
- package/dist/internal/funding/Token.d.ts +41 -0
- package/dist/internal/funding/Token.d.ts.map +1 -0
- package/dist/internal/funding/Token.js +22 -0
- package/dist/internal/funding/Token.js.map +1 -0
- package/dist/internal/funding/Transfer.d.ts +643 -0
- package/dist/internal/funding/Transfer.d.ts.map +1 -0
- package/dist/internal/funding/Transfer.js +332 -0
- package/dist/internal/funding/Transfer.js.map +1 -0
- package/dist/internal/funding/index.d.ts +14 -0
- package/dist/internal/funding/index.d.ts.map +1 -0
- package/dist/internal/funding/index.js +14 -0
- package/dist/internal/funding/index.js.map +1 -0
- package/dist/internal/funding/providers/across.d.ts +21 -0
- package/dist/internal/funding/providers/across.d.ts.map +1 -0
- package/dist/internal/funding/providers/across.js +117 -0
- package/dist/internal/funding/providers/across.js.map +1 -0
- package/dist/internal/funding/providers/relay.d.ts +88 -0
- package/dist/internal/funding/providers/relay.d.ts.map +1 -0
- package/dist/internal/funding/providers/relay.js +871 -0
- package/dist/internal/funding/providers/relay.js.map +1 -0
- package/dist/internal/funding/providers/rhino.d.ts +15 -0
- package/dist/internal/funding/providers/rhino.d.ts.map +1 -0
- package/dist/internal/funding/providers/rhino.js +116 -0
- package/dist/internal/funding/providers/rhino.js.map +1 -0
- package/dist/internal/funding/providers/squid.d.ts +19 -0
- package/dist/internal/funding/providers/squid.d.ts.map +1 -0
- package/dist/internal/funding/providers/squid.js +120 -0
- package/dist/internal/funding/providers/squid.js.map +1 -0
- package/dist/internal/funding/providers/symbiosis.d.ts +20 -0
- package/dist/internal/funding/providers/symbiosis.d.ts.map +1 -0
- package/dist/internal/funding/providers/symbiosis.js +176 -0
- package/dist/internal/funding/providers/symbiosis.js.map +1 -0
- package/dist/internal/index.d.ts +5 -1
- package/dist/internal/index.d.ts.map +1 -1
- package/dist/internal/index.js +5 -1
- package/dist/internal/index.js.map +1 -1
- package/dist/internal/webhookDestinations/url.js +61 -57
- package/dist/internal/webhookDestinations/url.js.map +1 -1
- package/dist/providers/index.d.ts +43 -0
- package/dist/providers/index.d.ts.map +1 -0
- package/dist/providers/index.js +19 -0
- package/dist/providers/index.js.map +1 -0
- package/package.json +10 -5
- package/src/ApiKey.test.ts +35 -0
- package/src/ApiKey.ts +27 -0
- package/src/ApiKeys.test.ts +40 -7
- package/src/ApiKeys.ts +46 -10
- package/src/App.test.ts +108 -15
- package/src/App.ts +296 -138
- package/src/Assets.ts +29 -4
- package/src/Client.test-d.ts +809 -37
- package/src/Scope.test.ts +19 -0
- package/src/Scope.ts +28 -11
- package/src/Webhooks.test.ts +25 -0
- package/src/Webhooks.ts +1 -1
- package/src/admin/App.test.ts +9 -2
- package/src/admin/App.ts +32 -9
- package/src/admin/apps/api-keys.test.ts +190 -22
- package/src/admin/apps/api-keys.ts +170 -28
- package/src/admin/apps/earn-vaults.test.ts +338 -0
- package/src/admin/apps/earn-vaults.ts +572 -0
- package/src/admin/apps/scopes.test.ts +16 -1
- package/src/admin/ui/plugin.ts +2 -2
- package/src/admin/ui/src/components/EarnVaultForm.tsx +137 -0
- package/src/admin/ui/src/components/MobileProfile.tsx +2 -2
- package/src/admin/ui/src/components/Page.tsx +1 -1
- package/src/admin/ui/src/components/ThemeToggle.tsx +1 -1
- package/src/admin/ui/src/lib/api-keys.ts +37 -7
- package/src/admin/ui/src/lib/client.ts +1 -1
- package/src/admin/ui/src/lib/config.ts +1 -1
- package/src/admin/ui/src/lib/early-access.ts +8 -9
- package/src/admin/ui/src/lib/earn-vaults.ts +207 -0
- package/src/admin/ui/src/lib/format.ts +13 -0
- package/src/admin/ui/src/lib/organizations.test.ts +14 -4
- package/src/admin/ui/src/lib/organizations.ts +7 -1
- package/src/admin/ui/src/lib/response.ts +22 -0
- package/src/admin/ui/src/lib/scopes.test.ts +19 -11
- package/src/admin/ui/src/lib/scopes.ts +28 -7
- package/src/admin/ui/src/lib/verified-tokens.ts +10 -9
- package/src/admin/ui/src/routeTree.gen.ts +70 -7
- package/src/admin/ui/src/router.tsx +2 -2
- package/src/admin/ui/src/routes/__root.tsx +9 -8
- package/src/admin/ui/src/routes/api-keys.tsx +475 -64
- package/src/admin/ui/src/routes/early-access.tsx +5 -12
- package/src/admin/ui/src/routes/earn.vaults.tsx +348 -0
- package/src/admin/ui/src/routes/earn.vaults_.$vaultId.edit.tsx +154 -0
- package/src/admin/ui/src/routes/earn.vaults_.new.tsx +190 -0
- package/src/admin/ui/src/routes/organizations.tsx +4 -7
- package/src/admin/ui/src/routes/organizations_.$orgId.tsx +56 -54
- package/src/admin/ui/src/routes/verified-tokens.tsx +4 -4
- package/src/admin/ui/vite.config.ts +4 -1
- package/src/admin/ui.generated.ts +113 -43
- package/src/analytics/Analytics.test.ts +69 -10
- package/src/analytics/Analytics.ts +24 -1
- package/src/analytics/tables/requestEvents.ts +79 -37
- package/src/apps/Zones.test.ts +33 -0
- package/src/apps/Zones.ts +40 -0
- package/src/apps/composition.test.ts +184 -3
- package/src/apps/data/App.test.ts +28 -23
- package/src/apps/data/App.ts +95 -36
- package/src/apps/data/FxOracle.ts +1 -1
- package/src/apps/data/index.ts +0 -1
- package/src/apps/data/routes/activities.test.ts +82 -6
- package/src/apps/data/routes/activities.ts +131 -71
- package/src/apps/data/routes/balances.test.ts +50 -37
- package/src/apps/data/routes/balances.ts +5 -5
- package/src/apps/data/routes/blocks.test.ts +2 -0
- package/src/apps/data/routes/coingecko.test.ts +22 -0
- package/src/apps/data/routes/coingecko.ts +84 -48
- package/src/apps/data/routes/earn.test.ts +1391 -0
- package/src/apps/data/routes/earn.ts +2188 -0
- package/src/apps/data/routes/exchanges.test.ts +82 -33
- package/src/apps/data/routes/exchanges.ts +842 -227
- package/src/apps/data/routes/fee-amm.test.ts +4 -6
- package/src/apps/data/routes/fee-amm.ts +69 -12
- package/src/apps/data/routes/indexer.test.ts +43 -34
- package/src/apps/data/routes/indexer.ts +21 -3
- package/src/apps/data/routes/receipts.test.ts +5 -3
- package/src/apps/data/routes/receipts.ts +13 -11
- package/src/apps/data/routes/rpc.test.ts +446 -28
- package/src/apps/data/routes/rpc.ts +245 -25
- package/src/apps/data/routes/tokenlist.ts +72 -19
- package/src/apps/data/routes/tokens.test.ts +6 -8
- package/src/apps/data/routes/tokens.ts +258 -86
- package/src/apps/data/routes/transactions.test.ts +2 -0
- package/src/apps/data/routes/transactions.ts +77 -42
- package/src/apps/data/routes/transfers.test.ts +166 -4
- package/src/apps/data/routes/transfers.ts +216 -78
- package/src/apps/data/routes/valuation.test.ts +62 -9
- package/src/apps/data/routes/valuation.ts +2 -2
- package/src/apps/data/routes/webhooks.test.ts +386 -43
- package/src/apps/data/routes/webhooks.ts +172 -71
- package/src/apps/data/routes/zones.test.ts +473 -0
- package/src/apps/data/routes/zones.ts +338 -0
- package/src/apps/docs/reference.ts +8 -6
- package/src/apps/funding/Access.ts +26 -0
- package/src/apps/funding/App.test.ts +78 -0
- package/src/apps/funding/App.ts +63 -0
- package/src/apps/funding/Inventory.ts +30 -0
- package/src/apps/funding/ProviderAttempts.ts +26 -0
- package/src/apps/funding/index.ts +1 -0
- package/src/apps/funding/routes/chains.test.ts +78 -0
- package/src/apps/funding/routes/chains.ts +101 -0
- package/src/apps/funding/routes/deposit-addresses.test.ts +1628 -0
- package/src/apps/funding/routes/deposit-addresses.ts +1015 -0
- package/src/apps/funding/routes/providers.test.ts +165 -0
- package/src/apps/funding/routes/providers.ts +73 -0
- package/src/apps/funding/routes/quotes.test.ts +511 -0
- package/src/apps/funding/routes/quotes.ts +205 -0
- package/src/apps/funding/routes/transfers.test.ts +1255 -0
- package/src/apps/funding/routes/transfers.ts +704 -0
- package/src/apps/index.ts +3 -1
- package/src/apps/management/Billing.test.ts +29 -0
- package/src/apps/management/Billing.ts +23 -0
- package/src/apps/management/Error.ts +12 -0
- package/src/apps/management/routes/api-keys.test.ts +103 -3
- package/src/apps/management/routes/api-keys.ts +98 -10
- package/src/apps/management/routes/invitations.ts +4 -11
- package/src/apps/management/routes/orgs.ts +2 -9
- package/src/apps/management/routes/scopes.test.ts +7 -2
- package/src/apps/management/routes/scopes.ts +2 -2
- package/src/apps/management/routes/webhooks.test.ts +6 -1
- package/src/apps/management/routes/webhooks.ts +15 -3
- package/src/apps/mcp.test.ts +17 -2
- package/src/apps/mcp.ts +18 -13
- package/src/apps/metadata.ts +12 -0
- package/src/apps/mpp/App.ts +276 -29
- package/src/apps/mpp/Mpp.test.ts +631 -26
- package/src/apps/mpp/Mpp.ts +0 -42
- package/src/apps/mpp/internal/Adapter.ts +108 -3
- package/src/apps/mpp/internal/Error.test.ts +33 -0
- package/src/apps/mpp/internal/Error.ts +44 -6
- package/src/apps/mpp/internal/Idempotency.test.ts +213 -0
- package/src/apps/mpp/internal/Idempotency.ts +59 -5
- package/src/apps/mpp/internal/Policy.test.ts +128 -0
- package/src/apps/mpp/internal/Policy.ts +98 -0
- package/src/apps/mpp/internal/ScreenManager.test.ts +68 -0
- package/src/apps/mpp/internal/ScreenManager.ts +41 -0
- package/src/apps/mpp/internal/Screening.ts +40 -3
- package/src/apps/mpp/internal/Sponsorship.ts +144 -0
- package/src/apps/mpp/internal/Utils.ts +30 -0
- package/src/apps/relay/App.test.ts +493 -62
- package/src/apps/relay/App.ts +233 -23
- package/src/apps/relay/Sponsorships.test.ts +49 -0
- package/src/apps/relay/Sponsorships.ts +18 -6
- package/src/cloudflare.ts +279 -0
- package/src/db/Db.ts +501 -0
- package/src/db/Schema.ts +349 -2
- package/src/db/tables/earnVaults.test.ts +185 -0
- package/src/db/tables/earnVaults.ts +151 -0
- package/src/db/tables/fundingCatalog.test.ts +108 -0
- package/src/db/tables/fundingCatalog.ts +157 -0
- package/src/db/tables/fundingDepositAddresses.test.ts +580 -0
- package/src/db/tables/fundingDepositAddresses.ts +404 -0
- package/src/db/tables/fundingDepositRequestObservations.test.ts +106 -0
- package/src/db/tables/fundingDepositRequestObservations.ts +99 -0
- package/src/db/tables/fundingDeposits.test.ts +399 -0
- package/src/db/tables/fundingDeposits.ts +373 -0
- package/src/db/tables/fundingIdempotency.test.ts +182 -0
- package/src/db/tables/fundingIdempotency.ts +180 -0
- package/src/db/tables/fundingTransferEvents.ts +28 -0
- package/src/db/tables/fundingTransferTransactions.test.ts +69 -0
- package/src/db/tables/fundingTransferTransactions.ts +37 -0
- package/src/db/tables/fundingTransfers.test.ts +89 -0
- package/src/db/tables/fundingTransfers.ts +153 -0
- package/src/db/tables/organizations.ts +16 -0
- package/src/db/tables/projects.ts +16 -0
- package/src/db/tables/requestUsage.ts +23 -0
- package/src/db/tables/sponsoredTransactions.test.ts +11 -0
- package/src/db/tables/sponsoredTransactions.ts +3 -3
- package/src/db/tables/users.ts +16 -0
- package/src/db/tables/verifiedTokens.ts +19 -14
- package/src/db/tables/webhookSubscriptions.ts +58 -3
- package/src/handlers/relay.test.ts +2 -0
- package/src/handlers/relay.ts +95 -99
- package/src/internal/Auth.test.ts +225 -5
- package/src/internal/Auth.ts +109 -20
- package/src/internal/Cache.test.ts +37 -3
- package/src/internal/Cache.ts +14 -10
- package/src/internal/Cursor.test.ts +2 -2
- package/src/internal/Cursor.ts +1 -1
- package/src/internal/EarnRates.test.ts +125 -0
- package/src/internal/EarnRates.ts +409 -0
- package/src/internal/EarnVaults.test.ts +195 -0
- package/src/internal/EarnVaults.ts +876 -0
- package/src/internal/EdgeCache.test.ts +26 -7
- package/src/internal/EdgeCache.ts +48 -9
- package/src/internal/Id.ts +14 -0
- package/src/internal/Idempotency.test.ts +109 -0
- package/src/internal/Idempotency.ts +237 -0
- package/src/internal/IpAllowlist.test.ts +52 -0
- package/src/internal/IpAllowlist.ts +39 -0
- package/src/internal/Log.test-d.ts +41 -8
- package/src/internal/Log.test.ts +196 -9
- package/src/internal/Log.ts +124 -17
- package/src/internal/MetricSink.test.ts +244 -4
- package/src/internal/MetricSink.ts +51 -1
- package/src/internal/OpenApi.ts +4 -1
- package/src/internal/Provider.test.ts +17 -0
- package/src/internal/Provider.ts +17 -0
- package/src/internal/Schema.ts +27 -17
- package/src/internal/Store.test.ts +25 -0
- package/src/internal/Store.ts +46 -0
- package/src/internal/Tidx.local.test.ts +78 -3
- package/src/internal/Tidx.test.ts +240 -18
- package/src/internal/Tidx.ts +129 -33
- package/src/internal/VerifiedTokens.test.ts +15 -0
- package/src/internal/Viem.test.ts +198 -17
- package/src/internal/Viem.ts +127 -28
- package/src/internal/WebhookDestination.ts +25 -23
- package/src/internal/Webhooks.test.ts +59 -0
- package/src/internal/Webhooks.ts +34 -10
- package/src/internal/exchange/Provider.test.ts +216 -0
- package/src/internal/exchange/Provider.ts +326 -0
- package/src/internal/exchange/index.test.ts +6 -0
- package/src/internal/exchange/index.ts +1 -0
- package/src/internal/exchange/providers/uniswap.test.ts +122 -0
- package/src/internal/exchange/providers/uniswap.ts +682 -0
- package/src/internal/funding/Action.test.ts +138 -0
- package/src/internal/funding/Action.ts +117 -0
- package/src/internal/funding/Catalog.test.ts +311 -0
- package/src/internal/funding/Catalog.ts +347 -0
- package/src/internal/funding/Chain.test.ts +79 -0
- package/src/internal/funding/Chain.ts +120 -0
- package/src/internal/funding/Deposit.test.ts +26 -0
- package/src/internal/funding/Deposit.ts +522 -0
- package/src/internal/funding/DepositAddress.test.ts +18 -0
- package/src/internal/funding/DepositAddress.ts +312 -0
- package/src/internal/funding/Evidence.test.ts +297 -0
- package/src/internal/funding/Evidence.ts +425 -0
- package/src/internal/funding/Provider.test.ts +1328 -0
- package/src/internal/funding/Provider.ts +1911 -0
- package/src/internal/funding/Reconciliation.local.test.ts +511 -0
- package/src/internal/funding/Reconciliation.test.ts +3037 -0
- package/src/internal/funding/Reconciliation.ts +1202 -0
- package/src/internal/funding/Route.test.ts +66 -0
- package/src/internal/funding/Route.ts +29 -0
- package/src/internal/funding/SourceObservation.test.ts +301 -0
- package/src/internal/funding/SourceObservation.ts +267 -0
- package/src/internal/funding/Subsidy.local.test.ts +152 -0
- package/src/internal/funding/Subsidy.test.ts +75 -0
- package/src/internal/funding/Subsidy.ts +260 -0
- package/src/internal/funding/Token.test.ts +47 -0
- package/src/internal/funding/Token.ts +59 -0
- package/src/internal/funding/Transfer.test.ts +369 -0
- package/src/internal/funding/Transfer.ts +522 -0
- package/src/internal/funding/index.test.ts +21 -0
- package/src/internal/funding/index.ts +13 -0
- package/src/internal/funding/providers/across.ts +149 -0
- package/src/{apps/data/FundingQuoteProviders.test.ts → internal/funding/providers/index.test.ts} +178 -157
- package/src/internal/funding/providers/relay.test.ts +564 -0
- package/src/internal/funding/providers/relay.ts +1060 -0
- package/src/internal/funding/providers/rhino.ts +139 -0
- package/src/internal/funding/providers/squid.ts +151 -0
- package/src/internal/funding/providers/symbiosis.ts +221 -0
- package/src/internal/index.test.ts +5 -1
- package/src/internal/index.ts +5 -1
- package/src/internal/webhookDestinations/url.ts +49 -45
- package/src/providers/index.test.ts +14 -0
- package/src/providers/index.ts +54 -0
- package/dist/apps/data/FundingQuoteProviders.d.ts +0 -174
- package/dist/apps/data/FundingQuoteProviders.d.ts.map +0 -1
- package/dist/apps/data/FundingQuoteProviders.js +0 -775
- package/dist/apps/data/FundingQuoteProviders.js.map +0 -1
- package/dist/apps/data/routes/funding.d.ts.map +0 -1
- package/dist/apps/data/routes/funding.js +0 -410
- package/dist/apps/data/routes/funding.js.map +0 -1
- package/dist/internal/FundingQuotes.d.ts +0 -864
- package/dist/internal/FundingQuotes.d.ts.map +0 -1
- package/dist/internal/FundingQuotes.js +0 -672
- package/dist/internal/FundingQuotes.js.map +0 -1
- package/src/apps/data/FundingQuoteProviders.ts +0 -1043
- package/src/apps/data/routes/funding.test.ts +0 -503
- package/src/apps/data/routes/funding.ts +0 -604
- package/src/internal/FundingQuotes.test.ts +0 -456
- package/src/internal/FundingQuotes.ts +0 -944
|
@@ -0,0 +1,871 @@
|
|
|
1
|
+
import { AbiEvent, AbiFunction, Address, Hash, Hex, RpcTransport } from 'ox';
|
|
2
|
+
import { createClient, custom, fallback } from 'viem';
|
|
3
|
+
import { getBlockNumber, getLogs, getTransaction, getTransactionReceipt } from 'viem/actions';
|
|
4
|
+
import * as z from 'zod/mini';
|
|
5
|
+
import * as Db from '../../../db/Db.js';
|
|
6
|
+
import * as FundingDepositAddresses from '../../../db/tables/fundingDepositAddresses.js';
|
|
7
|
+
import * as FundingDepositRequestObservations from '../../../db/tables/fundingDepositRequestObservations.js';
|
|
8
|
+
import * as Viem from '../../Viem.js';
|
|
9
|
+
import * as FundingCatalog from '../Catalog.js';
|
|
10
|
+
import * as FundingChain from '../Chain.js';
|
|
11
|
+
import * as Evidence from '../Evidence.js';
|
|
12
|
+
import * as FundingProvider from '../Provider.js';
|
|
13
|
+
import * as Subsidy from '../Subsidy.js';
|
|
14
|
+
const defaultBaseUrl = 'https://api.relay.link';
|
|
15
|
+
const defaultFetch = (input, init) => globalThis.fetch(input, init);
|
|
16
|
+
const deliveryBackfillBlocks = 256n;
|
|
17
|
+
const relayChainsCacheTtlMs = 60_000;
|
|
18
|
+
const sourceSweepForwardBlocks = 256n;
|
|
19
|
+
const depositErc20FullAllowance = AbiFunction.from('function depositErc20(address depositor,address token,bytes32 id)');
|
|
20
|
+
const depositErc20WithAmount = AbiFunction.from('function depositErc20(address depositor,address token,uint256 amount,bytes32 id)');
|
|
21
|
+
const relayErc20DepositEvent = AbiEvent.from('event RelayErc20Deposit(address from, address token, uint256 amount, bytes32 id)');
|
|
22
|
+
const relayTransfer = AbiFunction.from('function transfer(address recipient,uint256 amount)');
|
|
23
|
+
const transferEvent = AbiEvent.from('event Transfer(address indexed from, address indexed to, uint256 value)');
|
|
24
|
+
const webhookSignatureToleranceMs = 300_000;
|
|
25
|
+
const deliveryObservationStatuses = [
|
|
26
|
+
'depositing',
|
|
27
|
+
'pending',
|
|
28
|
+
'submitted',
|
|
29
|
+
'success',
|
|
30
|
+
'waiting',
|
|
31
|
+
];
|
|
32
|
+
// Bound provider statuses before using them as metric tags.
|
|
33
|
+
const webhookStatuses = [
|
|
34
|
+
'depositing',
|
|
35
|
+
'failure',
|
|
36
|
+
'fallback',
|
|
37
|
+
'pending',
|
|
38
|
+
'refund',
|
|
39
|
+
'submitted',
|
|
40
|
+
'success',
|
|
41
|
+
'waiting',
|
|
42
|
+
];
|
|
43
|
+
var schema;
|
|
44
|
+
(function (schema) {
|
|
45
|
+
const Decimal = z.union([
|
|
46
|
+
z.string().check(z.regex(/^\d+(\.\d+)?$/)),
|
|
47
|
+
z.pipe(z.number().check(z.nonnegative()), z.transform((value) => String(value))),
|
|
48
|
+
]);
|
|
49
|
+
const Integer = z.union([
|
|
50
|
+
z.number().check(z.int(), z.nonnegative()),
|
|
51
|
+
z.pipe(z.pipe(z.string().check(z.regex(/^\d+$/)), z.transform((value) => Number(value))), z.number().check(z.int(), z.nonnegative())),
|
|
52
|
+
]);
|
|
53
|
+
schema.Quote = z.object({
|
|
54
|
+
details: z.optional(z.object({
|
|
55
|
+
currencyOut: z.optional(z.object({
|
|
56
|
+
amount: z.optional(Decimal),
|
|
57
|
+
minimumAmount: z.optional(Decimal),
|
|
58
|
+
})),
|
|
59
|
+
timeEstimate: z.optional(Integer),
|
|
60
|
+
})),
|
|
61
|
+
});
|
|
62
|
+
const StepCall = z.object({
|
|
63
|
+
chainId: Integer,
|
|
64
|
+
data: z.string().check(z.regex(/^0x[0-9a-fA-F]*$/)),
|
|
65
|
+
from: z.string(),
|
|
66
|
+
to: z.string().check(z.regex(/^0x[0-9a-fA-F]{40}$/)),
|
|
67
|
+
value: z.optional(z.string().check(z.regex(/^\d+$/))),
|
|
68
|
+
});
|
|
69
|
+
const StepItem = z.object({
|
|
70
|
+
check: z.optional(z.object({ endpoint: z.string() })),
|
|
71
|
+
data: StepCall,
|
|
72
|
+
});
|
|
73
|
+
const Step = z.object({
|
|
74
|
+
depositAddress: z.optional(z.string()),
|
|
75
|
+
id: z.string(),
|
|
76
|
+
items: z.optional(z.array(StepItem)),
|
|
77
|
+
kind: z.string(),
|
|
78
|
+
requestId: z.optional(z.string()),
|
|
79
|
+
});
|
|
80
|
+
schema.PreparedQuote = z.object({
|
|
81
|
+
details: z.object({
|
|
82
|
+
currencyIn: z.object({ amount: Decimal }),
|
|
83
|
+
currencyOut: z.object({ amount: Decimal, minimumAmount: Decimal }),
|
|
84
|
+
timeEstimate: z.optional(Integer),
|
|
85
|
+
}),
|
|
86
|
+
fees: z.optional(z.object({
|
|
87
|
+
relayer: z.optional(z.object({ amount: Decimal })),
|
|
88
|
+
})),
|
|
89
|
+
steps: z.array(Step),
|
|
90
|
+
});
|
|
91
|
+
schema.DepositAddress = z.object({
|
|
92
|
+
details: schema.PreparedQuote.shape.details,
|
|
93
|
+
fees: schema.PreparedQuote.shape.fees,
|
|
94
|
+
steps: z.array(z.object({
|
|
95
|
+
depositAddress: z.optional(z.string()),
|
|
96
|
+
items: z.optional(z.array(z.object({
|
|
97
|
+
check: z.optional(z.object({ endpoint: z.string() })),
|
|
98
|
+
}))),
|
|
99
|
+
requestId: z.optional(z.string()),
|
|
100
|
+
})),
|
|
101
|
+
});
|
|
102
|
+
schema.Chains = z.object({
|
|
103
|
+
chains: z.array(z.object({
|
|
104
|
+
id: Integer,
|
|
105
|
+
protocol: z.optional(z.object({
|
|
106
|
+
v2: z.optional(z.object({
|
|
107
|
+
depository: z.string().check(z.regex(/^0x[0-9a-fA-F]{40}$/)),
|
|
108
|
+
})),
|
|
109
|
+
})),
|
|
110
|
+
solverAddresses: z.optional(z.array(z.string().check(z.regex(/^0x[0-9a-fA-F]{40}$/)))),
|
|
111
|
+
})),
|
|
112
|
+
});
|
|
113
|
+
schema.DeliveryObservation = z.object({
|
|
114
|
+
relay: z.object({
|
|
115
|
+
orderId: z.string().check(z.regex(/^0x[0-9a-fA-F]{64}$/)),
|
|
116
|
+
sourceDepository: z.string().check(z.regex(/^0x[0-9a-fA-F]{40}$/)),
|
|
117
|
+
sourceObservedAt: z.iso.datetime(),
|
|
118
|
+
sourceSweepTransactionHash: z.string().check(z.regex(/^0x[0-9a-fA-F]{64}$/)),
|
|
119
|
+
}),
|
|
120
|
+
});
|
|
121
|
+
schema.RequestCorrelation = z.object({
|
|
122
|
+
relay: z.object({
|
|
123
|
+
depositor: z.optional(z.string().check(z.regex(/^0x[0-9a-fA-F]{40}$/))),
|
|
124
|
+
depository: z.optional(z.string().check(z.regex(/^0x[0-9a-fA-F]{40}$/))),
|
|
125
|
+
orderId: z.optional(z.string().check(z.regex(/^0x[0-9a-fA-F]{64}$/))),
|
|
126
|
+
solver: z.optional(z.string().check(z.regex(/^0x[0-9a-fA-F]{40}$/))),
|
|
127
|
+
}),
|
|
128
|
+
});
|
|
129
|
+
const RequestTransaction = z.object({
|
|
130
|
+
txHash: z.string().check(z.minLength(1)),
|
|
131
|
+
});
|
|
132
|
+
schema.Requests = z.object({
|
|
133
|
+
continuation: z.optional(z.string().check(z.minLength(1))),
|
|
134
|
+
requests: z.array(z.object({
|
|
135
|
+
createdAt: z.iso.datetime(),
|
|
136
|
+
data: z.optional(z.object({
|
|
137
|
+
outTxs: z.optional(z.array(RequestTransaction)),
|
|
138
|
+
})),
|
|
139
|
+
depositAddress: z.optional(z.nullable(z.object({
|
|
140
|
+
depositTxHash: z.optional(z.nullable(z.string().check(z.minLength(1)))),
|
|
141
|
+
}))),
|
|
142
|
+
id: z.string().check(z.minLength(1)),
|
|
143
|
+
protocol: z.optional(z.nullable(z.object({
|
|
144
|
+
deposit: z.optional(z.object({
|
|
145
|
+
origin: z.optional(z.object({
|
|
146
|
+
depositor: z.optional(z.string().check(z.regex(/^0x[0-9a-fA-F]{40}$/))),
|
|
147
|
+
depository: z.optional(z.string().check(z.regex(/^0x[0-9a-fA-F]{40}$/))),
|
|
148
|
+
})),
|
|
149
|
+
})),
|
|
150
|
+
orderId: z.optional(z.string().check(z.regex(/^0x[0-9a-fA-F]{64}$/))),
|
|
151
|
+
solver: z.optional(z.object({
|
|
152
|
+
address: z.optional(z.string().check(z.regex(/^0x[0-9a-fA-F]{40}$/))),
|
|
153
|
+
})),
|
|
154
|
+
}))),
|
|
155
|
+
status: z.string().check(z.minLength(1)),
|
|
156
|
+
updatedAt: z.iso.datetime(),
|
|
157
|
+
})),
|
|
158
|
+
});
|
|
159
|
+
schema.WebhookPayload = z.object({
|
|
160
|
+
data: z.object({
|
|
161
|
+
depositAddress: z.nullable(z.object({ address: z.string().check(z.minLength(1)) })),
|
|
162
|
+
requestId: z.optional(z.string().check(z.minLength(1))),
|
|
163
|
+
status: z.string().check(z.minLength(1)),
|
|
164
|
+
updatedAt: z.number().check(z.int(), z.nonnegative()),
|
|
165
|
+
}),
|
|
166
|
+
event: z.literal('request.status.updated'),
|
|
167
|
+
});
|
|
168
|
+
})(schema || (schema = {}));
|
|
169
|
+
/** Validates a Relay request-list response and reports payload drift with field-level details. */
|
|
170
|
+
export function parseDepositAddressRequests(value) {
|
|
171
|
+
const parsed = schema.Requests.safeParse(value);
|
|
172
|
+
if (!parsed.success)
|
|
173
|
+
throw new FundingProvider.ProviderPayloadError(z.prettifyError(parsed.error));
|
|
174
|
+
return parsed.data;
|
|
175
|
+
}
|
|
176
|
+
/** Creates a Relay funding provider backed by `/quote/v2`. */
|
|
177
|
+
export function relay(options = {}) {
|
|
178
|
+
if ((options.userAddress !== undefined &&
|
|
179
|
+
!Address.validate(options.userAddress, { strict: false })) ||
|
|
180
|
+
(options.recipientAddress !== undefined &&
|
|
181
|
+
!Address.validate(options.recipientAddress, { strict: false })))
|
|
182
|
+
throw new FundingProvider.ProviderConfigurationError();
|
|
183
|
+
const endpoint = quoteEndpoint(options);
|
|
184
|
+
const fetch = options.fetch ?? defaultFetch;
|
|
185
|
+
const now = options.now ?? (() => new Date());
|
|
186
|
+
const observeDepositAddressRequest = options.observation
|
|
187
|
+
? createDepositAddressObserver({
|
|
188
|
+
...options.observation,
|
|
189
|
+
...(options.apiKey ? { apiKey: options.apiKey } : {}),
|
|
190
|
+
...(options.baseUrl ? { baseUrl: options.baseUrl } : {}),
|
|
191
|
+
fetch,
|
|
192
|
+
now,
|
|
193
|
+
})
|
|
194
|
+
: undefined;
|
|
195
|
+
const webhook = (() => {
|
|
196
|
+
if (!options.apiKey || !options.webhook)
|
|
197
|
+
return undefined;
|
|
198
|
+
const { apiKey, webhook } = options;
|
|
199
|
+
const verify = (input) => verifyWebhook(webhookOptions(input, apiKey));
|
|
200
|
+
return {
|
|
201
|
+
async receive(input) {
|
|
202
|
+
const receivedAt = now().toISOString();
|
|
203
|
+
const hint = (() => {
|
|
204
|
+
try {
|
|
205
|
+
return verify(input);
|
|
206
|
+
}
|
|
207
|
+
catch (cause) {
|
|
208
|
+
webhook.onResult?.(cause instanceof FundingProvider.WebhookAuthenticationError
|
|
209
|
+
? 'authentication_failed'
|
|
210
|
+
: 'payload_invalid');
|
|
211
|
+
throw cause;
|
|
212
|
+
}
|
|
213
|
+
})();
|
|
214
|
+
if (!hint.address) {
|
|
215
|
+
webhook.onResult?.('ignored');
|
|
216
|
+
return { type: 'ignored' };
|
|
217
|
+
}
|
|
218
|
+
const database = Db.get(webhook.db);
|
|
219
|
+
const address = await FundingDepositAddresses.getByProviderAddress(database, {
|
|
220
|
+
address: hint.address,
|
|
221
|
+
providerId: 'relay',
|
|
222
|
+
});
|
|
223
|
+
if (!address) {
|
|
224
|
+
webhook.onResult?.('unknown_address');
|
|
225
|
+
return { type: 'unknown_address' };
|
|
226
|
+
}
|
|
227
|
+
if (hint.requestId)
|
|
228
|
+
await FundingDepositRequestObservations.observeWebhook(database, {
|
|
229
|
+
depositAddressId: address.id,
|
|
230
|
+
providerRequestId: hint.requestId,
|
|
231
|
+
receivedAt,
|
|
232
|
+
}).catch((cause) => {
|
|
233
|
+
webhook.onResult?.('observation_failed');
|
|
234
|
+
throw cause;
|
|
235
|
+
});
|
|
236
|
+
try {
|
|
237
|
+
const webhookTiming = (() => {
|
|
238
|
+
if (!hint.providerStatus || !hint.providerUpdatedAt || !hint.requestId || !hint.sentAt)
|
|
239
|
+
return undefined;
|
|
240
|
+
return {
|
|
241
|
+
enqueuedAt: now().toISOString(),
|
|
242
|
+
providerStatus: hint.providerStatus,
|
|
243
|
+
providerUpdatedAt: hint.providerUpdatedAt,
|
|
244
|
+
receivedAt,
|
|
245
|
+
sentAt: hint.sentAt,
|
|
246
|
+
};
|
|
247
|
+
})();
|
|
248
|
+
await webhook.dispatch({
|
|
249
|
+
addressId: address.id,
|
|
250
|
+
...(hint.requestId ? { requestId: hint.requestId } : {}),
|
|
251
|
+
trigger: 'webhook',
|
|
252
|
+
type: 'funding:deposit-address:reconcile',
|
|
253
|
+
...(webhookTiming ? { webhookTiming } : {}),
|
|
254
|
+
});
|
|
255
|
+
}
|
|
256
|
+
catch (cause) {
|
|
257
|
+
webhook.onResult?.('enqueue_failed');
|
|
258
|
+
throw cause;
|
|
259
|
+
}
|
|
260
|
+
webhook.onResult?.('queued');
|
|
261
|
+
return { addressId: address.id, type: 'queued' };
|
|
262
|
+
},
|
|
263
|
+
verify,
|
|
264
|
+
};
|
|
265
|
+
})();
|
|
266
|
+
return FundingProvider.from({
|
|
267
|
+
id: 'relay',
|
|
268
|
+
name: 'Relay',
|
|
269
|
+
...(webhook ? { webhook } : {}),
|
|
270
|
+
async createDepositAddress({ amount, candidate, recipient, refundAddress, subsidize }, signal) {
|
|
271
|
+
if (subsidize &&
|
|
272
|
+
(!options.subsidies ||
|
|
273
|
+
!Subsidy.supports(options.subsidies, {
|
|
274
|
+
amount,
|
|
275
|
+
destinationToken: candidate.destinationToken,
|
|
276
|
+
sourceToken: candidate.sourceToken,
|
|
277
|
+
})))
|
|
278
|
+
throw new FundingProvider.ProviderUnavailableError();
|
|
279
|
+
const quote = await (async () => {
|
|
280
|
+
try {
|
|
281
|
+
return await FundingProvider.requestJson(endpoint, {
|
|
282
|
+
body: {
|
|
283
|
+
amount,
|
|
284
|
+
destinationChainId: relayChainId(candidate.route.destination.chain),
|
|
285
|
+
destinationCurrency: candidate.destinationToken.address,
|
|
286
|
+
originChainId: relayChainId(candidate.route.source.chain),
|
|
287
|
+
originCurrency: candidate.sourceToken.address,
|
|
288
|
+
recipient,
|
|
289
|
+
refundTo: refundAddress,
|
|
290
|
+
subsidizeFees: subsidize,
|
|
291
|
+
tradeType: 'EXACT_INPUT',
|
|
292
|
+
useDepositAddress: true,
|
|
293
|
+
user: refundAddress,
|
|
294
|
+
},
|
|
295
|
+
fetch,
|
|
296
|
+
headers: options.apiKey ? { 'x-api-key': options.apiKey } : undefined,
|
|
297
|
+
method: 'POST',
|
|
298
|
+
signal,
|
|
299
|
+
});
|
|
300
|
+
}
|
|
301
|
+
catch (cause) {
|
|
302
|
+
if (FundingProvider.unavailable(cause, ['NO_QUOTES', 'NO_ROUTE', 'UNSUPPORTED_ROUTE']))
|
|
303
|
+
throw new FundingProvider.ProviderUnavailableError();
|
|
304
|
+
throw cause;
|
|
305
|
+
}
|
|
306
|
+
})();
|
|
307
|
+
const parsed = schema.DepositAddress.safeParse(quote);
|
|
308
|
+
if (!parsed.success)
|
|
309
|
+
throw new FundingProvider.ProviderPayloadError();
|
|
310
|
+
if (parsed.data.details.currencyIn.amount !== amount)
|
|
311
|
+
throw new FundingProvider.ProviderPayloadError();
|
|
312
|
+
const step = parsed.data.steps.find((candidate) => candidate.depositAddress && candidate.requestId);
|
|
313
|
+
if (!step?.depositAddress || !step.requestId)
|
|
314
|
+
throw new FundingProvider.ProviderPayloadError();
|
|
315
|
+
const checkEndpoint = step.items?.find((item) => item.check)?.check?.endpoint;
|
|
316
|
+
const providerFee = parsed.data.fees?.relayer?.amount;
|
|
317
|
+
return {
|
|
318
|
+
address: step.depositAddress,
|
|
319
|
+
correlation: {
|
|
320
|
+
...(checkEndpoint ? { checkEndpoint } : {}),
|
|
321
|
+
requestId: step.requestId,
|
|
322
|
+
},
|
|
323
|
+
destinationAmount: parsed.data.details.currencyOut.amount,
|
|
324
|
+
destinationAmountMin: parsed.data.details.currencyOut.minimumAmount,
|
|
325
|
+
fees: providerFee && BigInt(providerFee) > 0n ? [{ amount: providerFee, side: 'source' }] : [],
|
|
326
|
+
sampledAt: now().toISOString(),
|
|
327
|
+
};
|
|
328
|
+
},
|
|
329
|
+
async getQuote({ candidate, route }, signal) {
|
|
330
|
+
if (options.userAddress === undefined)
|
|
331
|
+
return FundingProvider.unavailableResult({
|
|
332
|
+
detail: 'relay:quote-v2',
|
|
333
|
+
message: 'QUOTE_USER_NOT_CONFIGURED',
|
|
334
|
+
now: now(),
|
|
335
|
+
source: 'providerQuote',
|
|
336
|
+
});
|
|
337
|
+
const destinationChainId = relayChainId(route.destination.chain);
|
|
338
|
+
const sourceChainId = relayChainId(route.source.chain);
|
|
339
|
+
try {
|
|
340
|
+
const quote = await FundingProvider.requestJson(endpoint, {
|
|
341
|
+
body: {
|
|
342
|
+
amount: candidate.sourceAmount.amount,
|
|
343
|
+
destinationChainId,
|
|
344
|
+
destinationCurrency: candidate.destinationToken.address,
|
|
345
|
+
originChainId: sourceChainId,
|
|
346
|
+
originCurrency: candidate.sourceToken.address,
|
|
347
|
+
recipient: options.recipientAddress ?? options.userAddress,
|
|
348
|
+
tradeType: 'EXACT_INPUT',
|
|
349
|
+
user: options.userAddress,
|
|
350
|
+
},
|
|
351
|
+
fetch,
|
|
352
|
+
headers: options.apiKey ? { 'x-api-key': options.apiKey } : undefined,
|
|
353
|
+
method: 'POST',
|
|
354
|
+
signal,
|
|
355
|
+
});
|
|
356
|
+
const parsed = schema.Quote.safeParse(quote);
|
|
357
|
+
if (!parsed.success)
|
|
358
|
+
throw new FundingProvider.ProviderPayloadError();
|
|
359
|
+
const destinationAmount = parsed.data.details?.currencyOut?.amount;
|
|
360
|
+
const status = destinationAmount
|
|
361
|
+
? { status: 'available', tier: 'liquid' }
|
|
362
|
+
: { status: 'unknown', tier: 'unknown' };
|
|
363
|
+
return {
|
|
364
|
+
destinationAmountMin: parsed.data.details?.currencyOut?.minimumAmount,
|
|
365
|
+
destinationAmount,
|
|
366
|
+
quality: {
|
|
367
|
+
estimatedSeconds: parsed.data.details?.timeEstimate,
|
|
368
|
+
liquiditySource: 'providerQuote',
|
|
369
|
+
sourceDetail: 'relay:quote-v2',
|
|
370
|
+
tier: status.tier,
|
|
371
|
+
},
|
|
372
|
+
sampledAt: now().toISOString(),
|
|
373
|
+
status: status.status,
|
|
374
|
+
};
|
|
375
|
+
}
|
|
376
|
+
catch (cause) {
|
|
377
|
+
const unavailable = FundingProvider.unavailable(cause, [
|
|
378
|
+
'NO_QUOTES',
|
|
379
|
+
'NO_ROUTE',
|
|
380
|
+
'UNSUPPORTED_ROUTE',
|
|
381
|
+
]);
|
|
382
|
+
if (!unavailable)
|
|
383
|
+
throw cause;
|
|
384
|
+
return FundingProvider.unavailableResult({
|
|
385
|
+
detail: 'relay:quote-v2',
|
|
386
|
+
message: unavailable,
|
|
387
|
+
now: now(),
|
|
388
|
+
source: 'providerQuote',
|
|
389
|
+
});
|
|
390
|
+
}
|
|
391
|
+
},
|
|
392
|
+
async listDepositAddressRequests({ address, continuation, requestId }, signal) {
|
|
393
|
+
const requestUrl = requestsEndpoint(options);
|
|
394
|
+
if (requestId)
|
|
395
|
+
requestUrl.searchParams.set('id', requestId);
|
|
396
|
+
else
|
|
397
|
+
requestUrl.searchParams.set('depositAddress', address);
|
|
398
|
+
requestUrl.searchParams.set('includeChildRequests', 'true');
|
|
399
|
+
requestUrl.searchParams.set('limit', '50');
|
|
400
|
+
requestUrl.searchParams.set('sortBy', 'updatedAt');
|
|
401
|
+
requestUrl.searchParams.set('sortDirection', 'desc');
|
|
402
|
+
if (continuation)
|
|
403
|
+
requestUrl.searchParams.set('continuation', continuation);
|
|
404
|
+
const response = await FundingProvider.requestJson(requestUrl, {
|
|
405
|
+
fetch,
|
|
406
|
+
headers: options.apiKey ? { 'x-api-key': options.apiKey } : undefined,
|
|
407
|
+
method: 'GET',
|
|
408
|
+
signal,
|
|
409
|
+
});
|
|
410
|
+
const parsed = parseDepositAddressRequests(response);
|
|
411
|
+
return {
|
|
412
|
+
...(parsed.continuation ? { continuation: parsed.continuation } : {}),
|
|
413
|
+
requests: parsed.requests.map((request) => {
|
|
414
|
+
const correlation = (() => {
|
|
415
|
+
const { protocol } = request;
|
|
416
|
+
if (!protocol)
|
|
417
|
+
return undefined;
|
|
418
|
+
const relay = {
|
|
419
|
+
...(protocol.deposit?.origin?.depositor
|
|
420
|
+
? { depositor: protocol.deposit.origin.depositor }
|
|
421
|
+
: {}),
|
|
422
|
+
...(protocol.deposit?.origin?.depository
|
|
423
|
+
? { depository: protocol.deposit.origin.depository }
|
|
424
|
+
: {}),
|
|
425
|
+
...(protocol.orderId ? { orderId: protocol.orderId } : {}),
|
|
426
|
+
...(protocol.solver?.address ? { solver: protocol.solver.address } : {}),
|
|
427
|
+
};
|
|
428
|
+
if (Object.keys(relay).length === 0)
|
|
429
|
+
return undefined;
|
|
430
|
+
return schema.RequestCorrelation.parse({ relay });
|
|
431
|
+
})();
|
|
432
|
+
return {
|
|
433
|
+
createdAt: new Date(request.createdAt).toISOString(),
|
|
434
|
+
destinationTransactionHashes: request.data?.outTxs?.map((tx) => tx.txHash) ?? [],
|
|
435
|
+
id: request.id,
|
|
436
|
+
...(correlation ? { providerState: correlation } : {}),
|
|
437
|
+
sourceTransactionHashes: request.depositAddress?.depositTxHash
|
|
438
|
+
? [request.depositAddress.depositTxHash]
|
|
439
|
+
: [],
|
|
440
|
+
status: request.status,
|
|
441
|
+
updatedAt: new Date(request.updatedAt).toISOString(),
|
|
442
|
+
};
|
|
443
|
+
}),
|
|
444
|
+
};
|
|
445
|
+
},
|
|
446
|
+
...(observeDepositAddressRequest ? { observeDepositAddressRequest } : {}),
|
|
447
|
+
async prepareTransfer({ candidate, method, mode, recipient, sender, slippageBps }, signal) {
|
|
448
|
+
// Catalog capabilities gate deposit addresses and exact destination
|
|
449
|
+
// off this adapter; refuse them defensively if one slips through.
|
|
450
|
+
if (method !== 'transaction' || mode !== 'exactSource')
|
|
451
|
+
throw new FundingProvider.ProviderConfigurationError();
|
|
452
|
+
const quote = await (async () => {
|
|
453
|
+
try {
|
|
454
|
+
return await FundingProvider.requestJson(endpoint, {
|
|
455
|
+
body: {
|
|
456
|
+
amount: candidate.sourceAmount.amount,
|
|
457
|
+
destinationChainId: Number(FundingChain.eip155Id(candidate.route.destination.chain)),
|
|
458
|
+
destinationCurrency: candidate.destinationToken.address,
|
|
459
|
+
originChainId: Number(FundingChain.eip155Id(candidate.route.source.chain)),
|
|
460
|
+
originCurrency: candidate.sourceToken.address,
|
|
461
|
+
recipient,
|
|
462
|
+
...(slippageBps !== undefined ? { slippageTolerance: String(slippageBps) } : {}),
|
|
463
|
+
tradeType: 'EXACT_INPUT',
|
|
464
|
+
user: sender,
|
|
465
|
+
},
|
|
466
|
+
fetch,
|
|
467
|
+
headers: options.apiKey ? { 'x-api-key': options.apiKey } : undefined,
|
|
468
|
+
method: 'POST',
|
|
469
|
+
signal,
|
|
470
|
+
});
|
|
471
|
+
}
|
|
472
|
+
catch (cause) {
|
|
473
|
+
if (FundingProvider.unavailable(cause, ['NO_QUOTES', 'NO_ROUTE', 'UNSUPPORTED_ROUTE']))
|
|
474
|
+
throw new FundingProvider.ProviderUnavailableError();
|
|
475
|
+
throw cause;
|
|
476
|
+
}
|
|
477
|
+
})();
|
|
478
|
+
const parsed = schema.PreparedQuote.safeParse(quote);
|
|
479
|
+
if (!parsed.success)
|
|
480
|
+
throw new FundingProvider.ProviderPayloadError();
|
|
481
|
+
const { details, fees, steps } = parsed.data;
|
|
482
|
+
// The quoted input must match the request exactly; a drifted amount
|
|
483
|
+
// would desynchronize the stored terms from the prepared calls.
|
|
484
|
+
if (details.currencyIn.amount !== candidate.sourceAmount.amount)
|
|
485
|
+
throw new FundingProvider.ProviderPayloadError();
|
|
486
|
+
const items = steps
|
|
487
|
+
.filter((step) => step.kind === 'transaction')
|
|
488
|
+
.flatMap((step) => step.items ?? []);
|
|
489
|
+
const requestId = steps.find((step) => step.requestId)?.requestId;
|
|
490
|
+
if (items.length === 0 || !requestId)
|
|
491
|
+
throw new FundingProvider.ProviderPayloadError();
|
|
492
|
+
const sourceChainId = Number(FundingChain.eip155Id(candidate.route.source.chain));
|
|
493
|
+
for (const item of items)
|
|
494
|
+
if (item.data.chainId !== sourceChainId ||
|
|
495
|
+
item.data.from.toLowerCase() !== sender.toLowerCase())
|
|
496
|
+
throw new FundingProvider.ProviderPayloadError();
|
|
497
|
+
const checkEndpoint = items.find((item) => item.check)?.check?.endpoint;
|
|
498
|
+
// Relay's `relayer` fee is the solver's total source-side charge (gas
|
|
499
|
+
// plus service); it surfaces as the transfer's provider fee.
|
|
500
|
+
const providerFee = fees?.relayer?.amount;
|
|
501
|
+
return {
|
|
502
|
+
action: {
|
|
503
|
+
calls: items.map((item) => ({
|
|
504
|
+
data: item.data.data,
|
|
505
|
+
to: item.data.to,
|
|
506
|
+
value: Hex.fromNumber(BigInt(item.data.value ?? '0')),
|
|
507
|
+
})),
|
|
508
|
+
type: 'evm:calls',
|
|
509
|
+
},
|
|
510
|
+
correlation: { ...(checkEndpoint ? { checkEndpoint } : {}), requestId },
|
|
511
|
+
fees: providerFee && BigInt(providerFee) > 0n ? [{ amount: providerFee, side: 'source' }] : [],
|
|
512
|
+
destinationAmountMin: details.currencyOut.minimumAmount,
|
|
513
|
+
destinationAmount: details.currencyOut.amount,
|
|
514
|
+
quality: {
|
|
515
|
+
...(details.timeEstimate !== undefined ? { estimatedSeconds: details.timeEstimate } : {}),
|
|
516
|
+
liquiditySource: 'providerQuote',
|
|
517
|
+
sourceDetail: 'relay:quote-v2',
|
|
518
|
+
tier: 'liquid',
|
|
519
|
+
},
|
|
520
|
+
sampledAt: now().toISOString(),
|
|
521
|
+
};
|
|
522
|
+
},
|
|
523
|
+
});
|
|
524
|
+
}
|
|
525
|
+
function createDepositAddressObserver(options) {
|
|
526
|
+
let chainsExpiresAt = 0;
|
|
527
|
+
let chainsPromise;
|
|
528
|
+
let urlsExpiresAt = 0;
|
|
529
|
+
let urlsPromise;
|
|
530
|
+
const getChains = (signal) => {
|
|
531
|
+
if (chainsPromise && options.now().getTime() < chainsExpiresAt)
|
|
532
|
+
return chainsPromise;
|
|
533
|
+
chainsExpiresAt = options.now().getTime() + relayChainsCacheTtlMs;
|
|
534
|
+
chainsPromise = FundingProvider.requestJson(chainsEndpoint(options), {
|
|
535
|
+
fetch: options.fetch,
|
|
536
|
+
headers: options.apiKey ? { 'x-api-key': options.apiKey } : undefined,
|
|
537
|
+
signal,
|
|
538
|
+
})
|
|
539
|
+
.then((value) => schema.Chains.parse(value).chains)
|
|
540
|
+
.catch((cause) => {
|
|
541
|
+
chainsExpiresAt = 0;
|
|
542
|
+
chainsPromise = undefined;
|
|
543
|
+
throw cause;
|
|
544
|
+
});
|
|
545
|
+
return chainsPromise;
|
|
546
|
+
};
|
|
547
|
+
const getUrls = () => {
|
|
548
|
+
if (urlsPromise && options.now().getTime() < urlsExpiresAt)
|
|
549
|
+
return urlsPromise;
|
|
550
|
+
urlsExpiresAt = options.now().getTime() + relayChainsCacheTtlMs;
|
|
551
|
+
urlsPromise = FundingCatalog.read(Db.get(options.db))
|
|
552
|
+
.then((catalog) => new Map([...catalog.chainsByKey.values()].map((chain) => [
|
|
553
|
+
chain.id,
|
|
554
|
+
Evidence.resolveRpcUrls({
|
|
555
|
+
chain,
|
|
556
|
+
defaultChainId: options.defaultChainId ?? Viem.defaultChainId,
|
|
557
|
+
rpcUrlEnv: options.rpcUrlEnv,
|
|
558
|
+
}),
|
|
559
|
+
])))
|
|
560
|
+
.catch((cause) => {
|
|
561
|
+
urlsExpiresAt = 0;
|
|
562
|
+
urlsPromise = undefined;
|
|
563
|
+
throw cause;
|
|
564
|
+
});
|
|
565
|
+
return urlsPromise;
|
|
566
|
+
};
|
|
567
|
+
return async (parameters, signal) => {
|
|
568
|
+
if (!deliveryObservationStatuses.includes(parameters.request.status))
|
|
569
|
+
return { type: 'unsupported' };
|
|
570
|
+
if (parameters.sourceChain.kind !== 'evm' || parameters.destinationChain.kind !== 'evm')
|
|
571
|
+
return { type: 'unsupported' };
|
|
572
|
+
if (!Address.validate(parameters.address, { strict: false }) ||
|
|
573
|
+
!Address.validate(parameters.destinationToken.address, { strict: false }) ||
|
|
574
|
+
!Address.validate(parameters.recipient, { strict: false }) ||
|
|
575
|
+
!Address.validate(parameters.refundAddress, { strict: false }) ||
|
|
576
|
+
!Address.validate(parameters.sourceToken.address, { strict: false }) ||
|
|
577
|
+
!Hash.validate(parameters.source.transactionHash))
|
|
578
|
+
return { type: 'unsupported' };
|
|
579
|
+
const [chains, urls] = await Promise.all([getChains(signal), getUrls()]);
|
|
580
|
+
const sourceChain = relayEvmChain(chains, parameters.sourceChain);
|
|
581
|
+
const destinationChain = relayEvmChain(chains, parameters.destinationChain);
|
|
582
|
+
const sourceUrls = urls.get(parameters.sourceChain.id);
|
|
583
|
+
const destinationUrls = urls.get(parameters.destinationChain.id);
|
|
584
|
+
const depository = sourceChain?.protocol?.v2?.depository;
|
|
585
|
+
const solvers = destinationChain?.solverAddresses;
|
|
586
|
+
if (!depository ||
|
|
587
|
+
!solvers ||
|
|
588
|
+
solvers.length === 0 ||
|
|
589
|
+
!sourceUrls?.length ||
|
|
590
|
+
!destinationUrls?.length)
|
|
591
|
+
return { type: 'unsupported' };
|
|
592
|
+
const parsedCorrelation = schema.RequestCorrelation.safeParse(parameters.request.providerState);
|
|
593
|
+
const correlation = parsedCorrelation.success ? parsedCorrelation.data.relay : undefined;
|
|
594
|
+
if ((correlation?.depository &&
|
|
595
|
+
!Address.isEqual(correlation.depository, depository)) ||
|
|
596
|
+
(correlation?.solver &&
|
|
597
|
+
!solvers.some((solver) => Address.isEqual(solver, correlation.solver))))
|
|
598
|
+
return { type: 'unsupported' };
|
|
599
|
+
const depositor = (correlation?.depositor ?? parameters.refundAddress);
|
|
600
|
+
const stored = schema.DeliveryObservation.safeParse(parameters.providerState);
|
|
601
|
+
const sourceObservation = await (async () => {
|
|
602
|
+
if (stored.success)
|
|
603
|
+
return stored.data.relay;
|
|
604
|
+
const sourceClient = jsonRpcClient({ fetch: options.fetch, urls: sourceUrls });
|
|
605
|
+
const sourceReceipt = await getTransactionReceipt(sourceClient, {
|
|
606
|
+
hash: parameters.source.transactionHash,
|
|
607
|
+
});
|
|
608
|
+
if (sourceReceipt.status !== 'success' || sourceReceipt.blockNumber === null)
|
|
609
|
+
return undefined;
|
|
610
|
+
const sourceHead = await getBlockNumber(sourceClient, { cacheTime: 0 });
|
|
611
|
+
const sweepLogs = await getLogs(sourceClient, {
|
|
612
|
+
address: depository,
|
|
613
|
+
event: relayErc20DepositEvent,
|
|
614
|
+
fromBlock: sourceReceipt.blockNumber,
|
|
615
|
+
toBlock: minimum(sourceHead, sourceReceipt.blockNumber + sourceSweepForwardBlocks),
|
|
616
|
+
});
|
|
617
|
+
const observations = [];
|
|
618
|
+
for (const log of sweepLogs) {
|
|
619
|
+
if (!log.transactionHash)
|
|
620
|
+
continue;
|
|
621
|
+
const event = decodeEvent(relayErc20DepositEvent, log);
|
|
622
|
+
if (!event ||
|
|
623
|
+
!Address.isEqual(event.from, depositor) ||
|
|
624
|
+
!Address.isEqual(event.token, parameters.sourceToken.address) ||
|
|
625
|
+
event.amount !== BigInt(parameters.source.amount) ||
|
|
626
|
+
(correlation?.orderId && !Hex.isEqual(event.id, correlation.orderId)))
|
|
627
|
+
continue;
|
|
628
|
+
const transaction = await getTransaction(sourceClient, { hash: log.transactionHash });
|
|
629
|
+
const call = decodeRelayErc20Deposit(transaction.input);
|
|
630
|
+
if (!call ||
|
|
631
|
+
!Address.isEqual(transaction.from, parameters.address) ||
|
|
632
|
+
!transaction.to ||
|
|
633
|
+
!Address.isEqual(transaction.to, depository) ||
|
|
634
|
+
!Address.isEqual(call.depositor, event.from) ||
|
|
635
|
+
!Address.isEqual(call.token, event.token) ||
|
|
636
|
+
(call.amount !== undefined && call.amount !== event.amount) ||
|
|
637
|
+
!Hex.isEqual(call.id, event.id))
|
|
638
|
+
continue;
|
|
639
|
+
observations.push({
|
|
640
|
+
orderId: event.id,
|
|
641
|
+
sourceDepository: depository,
|
|
642
|
+
sourceObservedAt: options.now().toISOString(),
|
|
643
|
+
sourceSweepTransactionHash: log.transactionHash,
|
|
644
|
+
});
|
|
645
|
+
}
|
|
646
|
+
return observations.length === 1 ? observations[0] : undefined;
|
|
647
|
+
})();
|
|
648
|
+
if (!sourceObservation)
|
|
649
|
+
return { type: 'pending' };
|
|
650
|
+
const destinationClient = jsonRpcClient({ fetch: options.fetch, urls: destinationUrls });
|
|
651
|
+
const destinationHead = await getBlockNumber(destinationClient, { cacheTime: 0 });
|
|
652
|
+
const destinationLogs = await getLogs(destinationClient, {
|
|
653
|
+
address: parameters.destinationToken.address,
|
|
654
|
+
args: { to: parameters.recipient },
|
|
655
|
+
event: transferEvent,
|
|
656
|
+
fromBlock: destinationHead > deliveryBackfillBlocks ? destinationHead - deliveryBackfillBlocks : 0n,
|
|
657
|
+
toBlock: destinationHead,
|
|
658
|
+
});
|
|
659
|
+
const solverAddresses = (correlation?.solver ? [correlation.solver] : solvers).map((address) => address);
|
|
660
|
+
const correlatedTransactionHashes = [];
|
|
661
|
+
const uncorrelatedTransactionHashes = [];
|
|
662
|
+
for (const log of destinationLogs) {
|
|
663
|
+
if (!log.transactionHash ||
|
|
664
|
+
correlatedTransactionHashes.includes(log.transactionHash) ||
|
|
665
|
+
uncorrelatedTransactionHashes.includes(log.transactionHash))
|
|
666
|
+
continue;
|
|
667
|
+
const event = decodeEvent(transferEvent, log);
|
|
668
|
+
if (!event ||
|
|
669
|
+
event.value === 0n ||
|
|
670
|
+
!Address.isEqual(event.to, parameters.recipient) ||
|
|
671
|
+
!solverAddresses.some((address) => Address.isEqual(address, event.from)))
|
|
672
|
+
continue;
|
|
673
|
+
const transaction = await getTransaction(destinationClient, { hash: log.transactionHash });
|
|
674
|
+
const call = decodeRelayTransfer(transaction.input);
|
|
675
|
+
if (!call ||
|
|
676
|
+
!solverAddresses.some((address) => Address.isEqual(address, transaction.from)) ||
|
|
677
|
+
!Address.isEqual(event.from, transaction.from) ||
|
|
678
|
+
!transaction.to ||
|
|
679
|
+
!Address.isEqual(transaction.to, parameters.destinationToken.address) ||
|
|
680
|
+
!Address.isEqual(call.recipient, event.to) ||
|
|
681
|
+
call.amount !== event.value ||
|
|
682
|
+
(call.orderId && !Hex.isEqual(call.orderId, sourceObservation.orderId)))
|
|
683
|
+
continue;
|
|
684
|
+
if (call.orderId)
|
|
685
|
+
correlatedTransactionHashes.push(log.transactionHash);
|
|
686
|
+
else
|
|
687
|
+
uncorrelatedTransactionHashes.push(log.transactionHash);
|
|
688
|
+
}
|
|
689
|
+
const destinationTransactionHashes = (() => {
|
|
690
|
+
if (correlatedTransactionHashes.length > 0)
|
|
691
|
+
return correlatedTransactionHashes;
|
|
692
|
+
if (uncorrelatedTransactionHashes.length === 1)
|
|
693
|
+
return uncorrelatedTransactionHashes;
|
|
694
|
+
return [];
|
|
695
|
+
})();
|
|
696
|
+
const providerState = { relay: sourceObservation };
|
|
697
|
+
if (destinationTransactionHashes.length === 0)
|
|
698
|
+
return {
|
|
699
|
+
providerState,
|
|
700
|
+
providerTransactionHashes: [sourceObservation.sourceSweepTransactionHash],
|
|
701
|
+
type: 'pending',
|
|
702
|
+
};
|
|
703
|
+
return {
|
|
704
|
+
destinationTransactionHashes,
|
|
705
|
+
providerState: {
|
|
706
|
+
relay: {
|
|
707
|
+
...sourceObservation,
|
|
708
|
+
destinationObservedAt: options.now().toISOString(),
|
|
709
|
+
},
|
|
710
|
+
},
|
|
711
|
+
providerTransactionHashes: [
|
|
712
|
+
sourceObservation.sourceSweepTransactionHash,
|
|
713
|
+
...destinationTransactionHashes,
|
|
714
|
+
],
|
|
715
|
+
type: 'verified',
|
|
716
|
+
};
|
|
717
|
+
};
|
|
718
|
+
}
|
|
719
|
+
function chainsEndpoint(options) {
|
|
720
|
+
const endpoint = new URL(options.baseUrl ?? defaultBaseUrl);
|
|
721
|
+
endpoint.pathname = `${endpoint.pathname.replace(/\/+$/, '')}/chains`;
|
|
722
|
+
return endpoint;
|
|
723
|
+
}
|
|
724
|
+
function decodeRelayErc20Deposit(data) {
|
|
725
|
+
const fullAllowanceLength = 2 + 2 * (4 + 32 * 3);
|
|
726
|
+
const withAmountLength = 2 + 2 * (4 + 32 * 4);
|
|
727
|
+
try {
|
|
728
|
+
if (data.length === withAmountLength) {
|
|
729
|
+
const [depositor, token, amount, id] = AbiFunction.decodeData(depositErc20WithAmount, data);
|
|
730
|
+
return { amount, depositor, id, token };
|
|
731
|
+
}
|
|
732
|
+
if (data.length === fullAllowanceLength) {
|
|
733
|
+
const [depositor, token, id] = AbiFunction.decodeData(depositErc20FullAllowance, data);
|
|
734
|
+
return { depositor, id, token };
|
|
735
|
+
}
|
|
736
|
+
return undefined;
|
|
737
|
+
}
|
|
738
|
+
catch {
|
|
739
|
+
return undefined;
|
|
740
|
+
}
|
|
741
|
+
}
|
|
742
|
+
function decodeRelayTransfer(data) {
|
|
743
|
+
const encodedLength = 2 + 2 * (4 + 32 * 2);
|
|
744
|
+
if (data.length !== encodedLength && data.length !== encodedLength + 64)
|
|
745
|
+
return undefined;
|
|
746
|
+
try {
|
|
747
|
+
const [recipient, amount] = AbiFunction.decodeData(relayTransfer, data.slice(0, encodedLength));
|
|
748
|
+
return {
|
|
749
|
+
amount,
|
|
750
|
+
...(data.length > encodedLength
|
|
751
|
+
? { orderId: `0x${data.slice(encodedLength)}` }
|
|
752
|
+
: {}),
|
|
753
|
+
recipient,
|
|
754
|
+
};
|
|
755
|
+
}
|
|
756
|
+
catch {
|
|
757
|
+
return undefined;
|
|
758
|
+
}
|
|
759
|
+
}
|
|
760
|
+
function decodeEvent(abiEvent, log) {
|
|
761
|
+
try {
|
|
762
|
+
return AbiEvent.decode(abiEvent, log);
|
|
763
|
+
}
|
|
764
|
+
catch {
|
|
765
|
+
return undefined;
|
|
766
|
+
}
|
|
767
|
+
}
|
|
768
|
+
function jsonRpcClient(options) {
|
|
769
|
+
return createClient({
|
|
770
|
+
transport: fallback(options.urls.map((url) => {
|
|
771
|
+
const transport = RpcTransport.fromHttp(url, { fetchFn: options.fetch });
|
|
772
|
+
return custom(transport, { retryCount: 0 });
|
|
773
|
+
})),
|
|
774
|
+
});
|
|
775
|
+
}
|
|
776
|
+
function minimum(left, right) {
|
|
777
|
+
return left < right ? left : right;
|
|
778
|
+
}
|
|
779
|
+
function relayEvmChain(chains, chain) {
|
|
780
|
+
if (chain.kind !== 'evm')
|
|
781
|
+
return undefined;
|
|
782
|
+
const match = /^eip155:(\d+)$/.exec(chain.id);
|
|
783
|
+
if (!match?.[1])
|
|
784
|
+
return undefined;
|
|
785
|
+
return chains.find((candidate) => candidate.id === Number(match[1]));
|
|
786
|
+
}
|
|
787
|
+
function verifyWebhook(options) {
|
|
788
|
+
const timestamp = Number(options.timestamp);
|
|
789
|
+
if (!Number.isSafeInteger(timestamp))
|
|
790
|
+
throw new WebhookSignatureError();
|
|
791
|
+
if (Math.abs(Date.now() - timestamp) > webhookSignatureToleranceMs)
|
|
792
|
+
throw new WebhookSignatureError();
|
|
793
|
+
if (!/^[0-9a-fA-F]{64}$/.test(options.signature))
|
|
794
|
+
throw new WebhookSignatureError();
|
|
795
|
+
const expected = Hash.hmac256(Hex.fromString(options.secret), Hex.fromString(`${options.timestamp}.${options.body}`)).slice(2);
|
|
796
|
+
if (!timingSafeEqual(expected, options.signature))
|
|
797
|
+
throw new WebhookSignatureError();
|
|
798
|
+
const payload = (() => {
|
|
799
|
+
try {
|
|
800
|
+
return JSON.parse(options.body);
|
|
801
|
+
}
|
|
802
|
+
catch {
|
|
803
|
+
throw new WebhookPayloadError();
|
|
804
|
+
}
|
|
805
|
+
})();
|
|
806
|
+
const parsed = schema.WebhookPayload.safeParse(payload);
|
|
807
|
+
if (!parsed.success)
|
|
808
|
+
throw new WebhookPayloadError();
|
|
809
|
+
return {
|
|
810
|
+
address: parsed.data.data.depositAddress?.address,
|
|
811
|
+
providerStatus: webhookStatus(parsed.data.data.status),
|
|
812
|
+
providerUpdatedAt: webhookTimestamp(parsed.data.data.updatedAt),
|
|
813
|
+
requestId: parsed.data.data.requestId,
|
|
814
|
+
sentAt: webhookTimestamp(timestamp),
|
|
815
|
+
};
|
|
816
|
+
}
|
|
817
|
+
function webhookOptions(input, secret) {
|
|
818
|
+
const signature = input.headers.get('x-signature-sha256');
|
|
819
|
+
const timestamp = input.headers.get('x-signature-timestamp');
|
|
820
|
+
if (!signature || !timestamp)
|
|
821
|
+
throw new WebhookSignatureError();
|
|
822
|
+
return { body: input.body, secret, signature, timestamp };
|
|
823
|
+
}
|
|
824
|
+
function quoteEndpoint(options) {
|
|
825
|
+
const endpoint = new URL(options.baseUrl ?? defaultBaseUrl);
|
|
826
|
+
endpoint.pathname = `${endpoint.pathname.replace(/\/+$/, '')}/quote/v2`;
|
|
827
|
+
return endpoint;
|
|
828
|
+
}
|
|
829
|
+
function requestsEndpoint(options) {
|
|
830
|
+
const endpoint = new URL(options.baseUrl ?? defaultBaseUrl);
|
|
831
|
+
endpoint.pathname = `${endpoint.pathname.replace(/\/+$/, '')}/requests/v3`;
|
|
832
|
+
return endpoint;
|
|
833
|
+
}
|
|
834
|
+
function timingSafeEqual(left, right) {
|
|
835
|
+
if (left.length !== right.length)
|
|
836
|
+
return false;
|
|
837
|
+
let mismatch = 0;
|
|
838
|
+
for (let index = 0; index < left.length; index++)
|
|
839
|
+
mismatch |= left.charCodeAt(index) ^ right.charCodeAt(index);
|
|
840
|
+
return mismatch === 0;
|
|
841
|
+
}
|
|
842
|
+
function webhookStatus(status) {
|
|
843
|
+
return webhookStatuses.includes(status) ? status : 'unknown';
|
|
844
|
+
}
|
|
845
|
+
function webhookTimestamp(value) {
|
|
846
|
+
try {
|
|
847
|
+
return new Date(value).toISOString();
|
|
848
|
+
}
|
|
849
|
+
catch {
|
|
850
|
+
throw new WebhookPayloadError();
|
|
851
|
+
}
|
|
852
|
+
}
|
|
853
|
+
function relayChainId(chain) {
|
|
854
|
+
if (chain.id.startsWith('eip155:'))
|
|
855
|
+
return Number(FundingChain.eip155Id(chain));
|
|
856
|
+
// Relay uses a numeric chain ID for Solana instead of its CAIP-2 reference.
|
|
857
|
+
if (chain.id === 'solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp')
|
|
858
|
+
return 792_703_809;
|
|
859
|
+
if (chain.id.startsWith('tron:'))
|
|
860
|
+
return Number(chain.id.slice('tron:'.length));
|
|
861
|
+
throw new FundingProvider.ProviderConfigurationError();
|
|
862
|
+
}
|
|
863
|
+
/** Relay webhook signature is missing, stale, or invalid. */
|
|
864
|
+
export class WebhookSignatureError extends FundingProvider.WebhookAuthenticationError {
|
|
865
|
+
name = 'Funding.Provider.Relay.WebhookSignatureError';
|
|
866
|
+
}
|
|
867
|
+
/** Relay webhook body does not match the expected status event shape. */
|
|
868
|
+
export class WebhookPayloadError extends FundingProvider.WebhookPayloadError {
|
|
869
|
+
name = 'Funding.Provider.Relay.WebhookPayloadError';
|
|
870
|
+
}
|
|
871
|
+
//# sourceMappingURL=relay.js.map
|