tapimo 0.12.0 → 0.14.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/dist/App.d.ts +11333 -9563
- package/dist/App.d.ts.map +1 -1
- package/dist/App.js +39 -3
- package/dist/App.js.map +1 -1
- package/dist/Scope.d.ts +2 -0
- package/dist/Scope.d.ts.map +1 -1
- package/dist/Scope.js +17 -0
- 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 +1064 -924
- package/dist/admin/App.d.ts.map +1 -1
- package/dist/admin/apps/api-keys.d.ts +80 -0
- package/dist/admin/apps/api-keys.d.ts.map +1 -1
- package/dist/admin/apps/api-keys.js +54 -0
- package/dist/admin/apps/api-keys.js.map +1 -1
- package/dist/admin/apps/earn-vaults.d.ts +63 -15
- package/dist/admin/apps/earn-vaults.d.ts.map +1 -1
- package/dist/admin/apps/earn-vaults.js +2 -1
- package/dist/admin/apps/earn-vaults.js.map +1 -1
- package/dist/admin/apps/organizations.d.ts +92 -3
- package/dist/admin/apps/organizations.d.ts.map +1 -1
- package/dist/admin/apps/organizations.js +69 -7
- package/dist/admin/apps/organizations.js.map +1 -1
- package/dist/admin/apps/verified-tokens.d.ts +7 -7
- 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 +151 -151
- package/dist/admin/ui.generated.js.map +1 -1
- package/dist/apps/Zones.d.ts +28 -28
- package/dist/apps/Zones.js +7 -7
- package/dist/apps/data/App.d.ts +2909 -2523
- package/dist/apps/data/App.d.ts.map +1 -1
- package/dist/apps/data/App.js +26 -21
- package/dist/apps/data/App.js.map +1 -1
- package/dist/apps/data/ZoneSelection.d.ts +8 -8
- package/dist/apps/data/ZoneSelection.d.ts.map +1 -1
- package/dist/apps/data/ZoneSelection.js +1 -1
- package/dist/apps/data/ZoneSelection.js.map +1 -1
- package/dist/apps/data/routes/activities.d.ts +588 -584
- package/dist/apps/data/routes/activities.d.ts.map +1 -1
- package/dist/apps/data/routes/activities.js +1561 -1239
- package/dist/apps/data/routes/activities.js.map +1 -1
- package/dist/apps/data/routes/addresses.d.ts +22 -22
- package/dist/apps/data/routes/balances.d.ts +26 -26
- package/dist/apps/data/routes/balances.d.ts.map +1 -1
- package/dist/apps/data/routes/balances.js +43 -16
- package/dist/apps/data/routes/balances.js.map +1 -1
- package/dist/apps/data/routes/blocks.d.ts +44 -44
- package/dist/apps/data/routes/blocks.d.ts.map +1 -1
- package/dist/apps/data/routes/blocks.js +21 -11
- package/dist/apps/data/routes/blocks.js.map +1 -1
- package/dist/apps/data/routes/coingecko.d.ts +3 -3
- package/dist/apps/data/routes/earn.d.ts +201 -25
- package/dist/apps/data/routes/earn.d.ts.map +1 -1
- package/dist/apps/data/routes/earn.js +434 -75
- package/dist/apps/data/routes/earn.js.map +1 -1
- package/dist/apps/data/routes/exchanges.d.ts +160 -145
- 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 +2 -2
- package/dist/apps/data/routes/fee-amm.d.ts.map +1 -1
- package/dist/apps/data/routes/fee-amm.js +18 -19
- package/dist/apps/data/routes/fee-amm.js.map +1 -1
- package/dist/apps/data/routes/receipts.d.ts +155 -55
- package/dist/apps/data/routes/receipts.d.ts.map +1 -1
- package/dist/apps/data/routes/receipts.js +28 -10
- package/dist/apps/data/routes/receipts.js.map +1 -1
- package/dist/apps/data/routes/tokenlist.d.ts +13 -13
- package/dist/apps/data/routes/tokens.d.ts +5 -5
- package/dist/apps/data/routes/tokens.d.ts.map +1 -1
- package/dist/apps/data/routes/tokens.js +51 -20
- package/dist/apps/data/routes/tokens.js.map +1 -1
- package/dist/apps/data/routes/transactions.d.ts +7 -2
- package/dist/apps/data/routes/transactions.d.ts.map +1 -1
- package/dist/apps/data/routes/transactions.js +37 -17
- package/dist/apps/data/routes/transactions.js.map +1 -1
- package/dist/apps/data/routes/transfers.d.ts +13 -13
- package/dist/apps/data/routes/transfers.d.ts.map +1 -1
- package/dist/apps/data/routes/transfers.js +18 -12
- package/dist/apps/data/routes/transfers.js.map +1 -1
- package/dist/apps/data/routes/valuation.d.ts +31 -31
- package/dist/apps/data/routes/valuation.d.ts.map +1 -1
- package/dist/apps/data/routes/valuation.js +12 -7
- package/dist/apps/data/routes/valuation.js.map +1 -1
- package/dist/apps/data/routes/verified-tokens.d.ts +8 -8
- package/dist/apps/data/routes/webhooks.d.ts +816 -113
- package/dist/apps/data/routes/webhooks.d.ts.map +1 -1
- package/dist/apps/data/routes/webhooks.js +47 -5
- package/dist/apps/data/routes/webhooks.js.map +1 -1
- package/dist/apps/data/routes/zones.d.ts +14 -14
- package/dist/apps/data/routes/zones.js +1 -1
- package/dist/apps/funding/App.d.ts +466 -44
- package/dist/apps/funding/App.d.ts.map +1 -1
- package/dist/apps/funding/App.js +1 -1
- package/dist/apps/funding/App.js.map +1 -1
- package/dist/apps/funding/routes/deposit-addresses.d.ts +17 -17
- package/dist/apps/funding/routes/deposit-addresses.d.ts.map +1 -1
- package/dist/apps/funding/routes/deposit-addresses.js +17 -12
- package/dist/apps/funding/routes/deposit-addresses.js.map +1 -1
- package/dist/apps/funding/routes/transfers.d.ts +650 -57
- package/dist/apps/funding/routes/transfers.d.ts.map +1 -1
- package/dist/apps/funding/routes/transfers.js +238 -24
- package/dist/apps/funding/routes/transfers.js.map +1 -1
- package/dist/apps/management/App.d.ts +5120 -4152
- package/dist/apps/management/App.d.ts.map +1 -1
- package/dist/apps/management/Billing.d.ts +1 -1
- package/dist/apps/management/Billing.d.ts.map +1 -1
- package/dist/apps/management/Billing.js +17 -1
- package/dist/apps/management/Billing.js.map +1 -1
- package/dist/apps/management/routes/api-keys.d.ts +632 -81
- package/dist/apps/management/routes/api-keys.d.ts.map +1 -1
- package/dist/apps/management/routes/api-keys.js +236 -4
- package/dist/apps/management/routes/api-keys.js.map +1 -1
- package/dist/apps/management/routes/billing.d.ts +76 -76
- package/dist/apps/management/routes/faucet.d.ts +6 -6
- package/dist/apps/management/routes/invitations.d.ts +24 -24
- package/dist/apps/management/routes/invite-links.d.ts +4 -4
- package/dist/apps/management/routes/members.d.ts +16 -16
- package/dist/apps/management/routes/orgs.d.ts +20 -20
- package/dist/apps/management/routes/projects.d.ts +4 -4
- package/dist/apps/management/routes/usage.d.ts +8 -8
- package/dist/apps/management/routes/verified-token-requests.d.ts +17 -17
- package/dist/apps/management/routes/webhooks.d.ts +675 -25
- package/dist/apps/management/routes/webhooks.d.ts.map +1 -1
- package/dist/apps/management/routes/webhooks.js +21 -21
- package/dist/apps/management/routes/webhooks.js.map +1 -1
- package/dist/apps/relay/App.d.ts.map +1 -1
- package/dist/apps/relay/App.js +115 -23
- package/dist/apps/relay/App.js.map +1 -1
- package/dist/apps/relay/Sponsorships.d.ts.map +1 -1
- package/dist/apps/relay/Sponsorships.js +27 -1
- package/dist/apps/relay/Sponsorships.js.map +1 -1
- package/dist/db/Db.d.ts.map +1 -1
- package/dist/db/Db.js +34 -1
- package/dist/db/Db.js.map +1 -1
- package/dist/db/Schema.d.ts +11 -5
- package/dist/db/Schema.d.ts.map +1 -1
- package/dist/db/Schema.js +21 -3
- package/dist/db/Schema.js.map +1 -1
- package/dist/db/tables/fundingCatalog.d.ts +4 -2
- package/dist/db/tables/fundingCatalog.d.ts.map +1 -1
- package/dist/db/tables/fundingCatalog.js +5 -1
- package/dist/db/tables/fundingCatalog.js.map +1 -1
- package/dist/db/tables/fundingTransferTransactions.d.ts +38 -0
- package/dist/db/tables/fundingTransferTransactions.d.ts.map +1 -1
- package/dist/db/tables/fundingTransferTransactions.js +44 -3
- package/dist/db/tables/fundingTransferTransactions.js.map +1 -1
- package/dist/db/tables/fundingTransfers.d.ts +17 -0
- package/dist/db/tables/fundingTransfers.d.ts.map +1 -1
- package/dist/db/tables/fundingTransfers.js +21 -0
- package/dist/db/tables/fundingTransfers.js.map +1 -1
- package/dist/db/tables/organizations.d.ts +24 -0
- package/dist/db/tables/organizations.d.ts.map +1 -1
- package/dist/db/tables/organizations.js +27 -0
- package/dist/db/tables/organizations.js.map +1 -1
- package/dist/db/tables/projects.d.ts +25 -1
- package/dist/db/tables/projects.d.ts.map +1 -1
- package/dist/db/tables/projects.js +26 -0
- package/dist/db/tables/projects.js.map +1 -1
- package/dist/db/tables/sponsoredTransactions.d.ts +44 -0
- package/dist/db/tables/sponsoredTransactions.d.ts.map +1 -1
- package/dist/db/tables/sponsoredTransactions.js +146 -13
- package/dist/db/tables/sponsoredTransactions.js.map +1 -1
- package/dist/db/tables/webhookSubscriptions.d.ts +10 -6
- package/dist/db/tables/webhookSubscriptions.d.ts.map +1 -1
- package/dist/db/tables/webhookSubscriptions.js +9 -6
- package/dist/db/tables/webhookSubscriptions.js.map +1 -1
- package/dist/handlers/internal/utils.d.ts.map +1 -1
- package/dist/handlers/internal/utils.js +9 -0
- package/dist/handlers/internal/utils.js.map +1 -1
- package/dist/internal/Auth.d.ts +3 -1
- package/dist/internal/Auth.d.ts.map +1 -1
- package/dist/internal/Auth.js +6 -3
- package/dist/internal/Auth.js.map +1 -1
- package/dist/internal/EarnVaults.d.ts +3 -3
- package/dist/internal/EarnVaults.js +5 -5
- package/dist/internal/EarnVaults.js.map +1 -1
- package/dist/internal/Fetch.d.ts +23 -0
- package/dist/internal/Fetch.d.ts.map +1 -0
- package/dist/internal/Fetch.js +26 -0
- package/dist/internal/Fetch.js.map +1 -0
- package/dist/internal/Log.d.ts +4 -2
- package/dist/internal/Log.d.ts.map +1 -1
- package/dist/internal/Log.js +16 -3
- package/dist/internal/Log.js.map +1 -1
- package/dist/internal/OpenApi.d.ts +5 -3
- package/dist/internal/OpenApi.d.ts.map +1 -1
- package/dist/internal/OpenApi.js +13 -3
- package/dist/internal/OpenApi.js.map +1 -1
- package/dist/internal/Response.d.ts +1 -1
- package/dist/internal/Response.d.ts.map +1 -1
- package/dist/internal/Schema.d.ts +6 -3
- package/dist/internal/Schema.d.ts.map +1 -1
- package/dist/internal/Schema.js +8 -2
- package/dist/internal/Schema.js.map +1 -1
- package/dist/internal/Store.d.ts +16 -3
- package/dist/internal/Store.d.ts.map +1 -1
- package/dist/internal/Store.js +82 -16
- package/dist/internal/Store.js.map +1 -1
- package/dist/internal/Tidx.d.ts.map +1 -1
- package/dist/internal/Tidx.js +7 -2
- package/dist/internal/Tidx.js.map +1 -1
- package/dist/internal/Timeout.d.ts +36 -0
- package/dist/internal/Timeout.d.ts.map +1 -0
- package/dist/internal/Timeout.js +37 -0
- package/dist/internal/Timeout.js.map +1 -0
- package/dist/internal/Timing.d.ts +9 -0
- package/dist/internal/Timing.d.ts.map +1 -1
- package/dist/internal/Timing.js +7 -0
- package/dist/internal/Timing.js.map +1 -1
- package/dist/internal/Viem.d.ts +16 -1
- package/dist/internal/Viem.d.ts.map +1 -1
- package/dist/internal/Viem.js +12 -2
- package/dist/internal/Viem.js.map +1 -1
- package/dist/internal/WebhookDestination.d.ts.map +1 -1
- package/dist/internal/WebhookDestination.js +3 -0
- package/dist/internal/WebhookDestination.js.map +1 -1
- package/dist/internal/funding/Action.d.ts +9 -0
- package/dist/internal/funding/Action.d.ts.map +1 -1
- package/dist/internal/funding/Action.js +16 -8
- package/dist/internal/funding/Action.js.map +1 -1
- package/dist/internal/funding/Catalog.d.ts +9 -2
- package/dist/internal/funding/Catalog.d.ts.map +1 -1
- package/dist/internal/funding/Catalog.js +19 -8
- package/dist/internal/funding/Catalog.js.map +1 -1
- package/dist/internal/funding/DepositWebhook.d.ts.map +1 -1
- package/dist/internal/funding/DepositWebhook.js +2 -1
- package/dist/internal/funding/DepositWebhook.js.map +1 -1
- package/dist/internal/funding/Evidence.d.ts.map +1 -1
- package/dist/internal/funding/Evidence.js +2 -10
- package/dist/internal/funding/Evidence.js.map +1 -1
- package/dist/internal/funding/Provider.d.ts +108 -13
- package/dist/internal/funding/Provider.d.ts.map +1 -1
- package/dist/internal/funding/Provider.js +34 -8
- package/dist/internal/funding/Provider.js.map +1 -1
- package/dist/internal/funding/SourceObservation.d.ts.map +1 -1
- package/dist/internal/funding/SourceObservation.js +5 -7
- package/dist/internal/funding/SourceObservation.js.map +1 -1
- package/dist/internal/funding/Transfer.d.ts +114 -18
- package/dist/internal/funding/Transfer.d.ts.map +1 -1
- package/dist/internal/funding/Transfer.js +185 -55
- package/dist/internal/funding/Transfer.js.map +1 -1
- package/dist/internal/funding/TransferReconciliation.d.ts +52 -0
- package/dist/internal/funding/TransferReconciliation.d.ts.map +1 -0
- package/dist/internal/funding/TransferReconciliation.js +192 -0
- package/dist/internal/funding/TransferReconciliation.js.map +1 -0
- package/dist/internal/funding/TransferWebhook.d.ts +21 -0
- package/dist/internal/funding/TransferWebhook.d.ts.map +1 -0
- package/dist/internal/funding/TransferWebhook.js +43 -0
- package/dist/internal/funding/TransferWebhook.js.map +1 -0
- package/dist/internal/funding/index.d.ts +1 -0
- package/dist/internal/funding/index.d.ts.map +1 -1
- package/dist/internal/funding/index.js +1 -0
- package/dist/internal/funding/index.js.map +1 -1
- package/dist/internal/funding/providers/relay.d.ts.map +1 -1
- package/dist/internal/funding/providers/relay.js +3 -12
- package/dist/internal/funding/providers/relay.js.map +1 -1
- package/dist/internal/funding/providers/stargate.d.ts +127 -9
- package/dist/internal/funding/providers/stargate.d.ts.map +1 -1
- package/dist/internal/funding/providers/stargate.js +548 -112
- package/dist/internal/funding/providers/stargate.js.map +1 -1
- package/dist/internal/index.d.ts +1 -0
- package/dist/internal/index.d.ts.map +1 -1
- package/dist/internal/index.js +1 -0
- package/dist/internal/index.js.map +1 -1
- package/dist/internal/webhookDestinations/slack.d.ts.map +1 -1
- package/dist/internal/webhookDestinations/slack.js +16 -0
- package/dist/internal/webhookDestinations/slack.js.map +1 -1
- package/package.json +2 -2
- package/src/App.test.ts +100 -0
- package/src/App.ts +43 -3
- package/src/Client.test-d.ts +129 -2
- package/src/Scope.test.ts +20 -0
- package/src/Scope.ts +16 -0
- package/src/Webhooks.ts +2 -2
- package/src/admin/apps/api-keys.test.ts +75 -0
- package/src/admin/apps/api-keys.ts +64 -0
- package/src/admin/apps/earn-vaults.test.ts +1 -1
- package/src/admin/apps/earn-vaults.ts +2 -1
- package/src/admin/apps/organizations.test.ts +53 -1
- package/src/admin/apps/organizations.ts +90 -5
- package/src/admin/ui/src/lib/api-keys.ts +19 -0
- package/src/admin/ui/src/lib/organizations.test.ts +112 -1
- package/src/admin/ui/src/lib/organizations.ts +55 -0
- package/src/admin/ui/src/routes/api-keys.tsx +89 -2
- package/src/admin/ui/src/routes/organizations_.$orgId.tsx +116 -0
- package/src/admin/ui.generated.ts +189 -151
- package/src/apps/Zones.test.ts +7 -7
- package/src/apps/Zones.ts +7 -7
- package/src/apps/composition.test.ts +2 -1
- package/src/apps/data/App.test.ts +41 -0
- package/src/apps/data/App.ts +30 -21
- package/src/apps/data/ZoneSelection.test.ts +2 -2
- package/src/apps/data/ZoneSelection.ts +8 -8
- package/src/apps/data/routes/activities.test.ts +1526 -12
- package/src/apps/data/routes/activities.ts +1774 -1356
- package/src/apps/data/routes/balances.ts +133 -97
- package/src/apps/data/routes/blocks.test.ts +533 -0
- package/src/apps/data/routes/blocks.ts +35 -16
- package/src/apps/data/routes/earn.test.ts +373 -16
- package/src/apps/data/routes/earn.ts +548 -79
- package/src/apps/data/routes/earn.zone-access.test.ts +6 -6
- package/src/apps/data/routes/exchanges.test.ts +740 -15
- package/src/apps/data/routes/exchanges.ts +954 -753
- package/src/apps/data/routes/fee-amm.ts +17 -18
- package/src/apps/data/routes/receipts.ts +47 -16
- package/src/apps/data/routes/tokens.test.ts +578 -0
- package/src/apps/data/routes/tokens.ts +283 -225
- package/src/apps/data/routes/transactions.ts +68 -29
- package/src/apps/data/routes/transfers.test.ts +421 -0
- package/src/apps/data/routes/transfers.ts +45 -27
- package/src/apps/data/routes/valuation.ts +94 -78
- package/src/apps/data/routes/webhooks.test.ts +21 -5
- package/src/apps/data/routes/webhooks.ts +63 -8
- package/src/apps/data/routes/zones.test.ts +2 -2
- package/src/apps/data/routes/zones.ts +1 -1
- package/src/apps/funding/App.ts +12 -2
- package/src/apps/funding/routes/deposit-addresses.test.ts +29 -7
- package/src/apps/funding/routes/deposit-addresses.ts +19 -14
- package/src/apps/funding/routes/quotes.test.ts +5 -9
- package/src/apps/funding/routes/transfers.test.ts +901 -23
- package/src/apps/funding/routes/transfers.ts +347 -64
- package/src/apps/management/Billing.ts +18 -5
- package/src/apps/management/routes/api-keys.test.ts +220 -0
- package/src/apps/management/routes/api-keys.ts +280 -3
- package/src/apps/management/routes/webhooks.test.ts +3 -3
- package/src/apps/management/routes/webhooks.ts +24 -25
- package/src/apps/relay/App.test.ts +212 -1
- package/src/apps/relay/App.ts +158 -29
- package/src/apps/relay/Sponsorships.ts +24 -1
- package/src/db/Db.ts +48 -1
- package/src/db/Schema.ts +22 -4
- package/src/db/tables/earnVaults.test.ts +9 -9
- package/src/db/tables/fundingCatalog.test.ts +16 -2
- package/src/db/tables/fundingCatalog.ts +9 -3
- package/src/db/tables/fundingTransferTransactions.test.ts +43 -0
- package/src/db/tables/fundingTransferTransactions.ts +79 -3
- package/src/db/tables/fundingTransfers.test.ts +26 -0
- package/src/db/tables/fundingTransfers.ts +36 -0
- package/src/db/tables/organizations.test.ts +41 -0
- package/src/db/tables/organizations.ts +49 -0
- package/src/db/tables/projects.test.ts +55 -0
- package/src/db/tables/projects.ts +46 -1
- package/src/db/tables/sponsoredTransactions.test.ts +338 -0
- package/src/db/tables/sponsoredTransactions.ts +197 -13
- package/src/db/tables/webhookSubscriptions.ts +18 -11
- package/src/handlers/internal/utils.test.ts +53 -0
- package/src/handlers/internal/utils.ts +15 -0
- package/src/internal/Auth.ts +12 -4
- package/src/internal/EarnVaults.capabilities.test.ts +2 -2
- package/src/internal/EarnVaults.test.ts +1 -1
- package/src/internal/EarnVaults.ts +5 -5
- package/src/internal/Fetch.test.ts +46 -0
- package/src/internal/Fetch.ts +56 -0
- package/src/internal/Log.test-d.ts +2 -0
- package/src/internal/Log.test.ts +21 -0
- package/src/internal/Log.ts +22 -5
- package/src/internal/OpenApi.ts +14 -4
- package/src/internal/Response.ts +1 -1
- package/src/internal/Schema.test.ts +2 -0
- package/src/internal/Schema.ts +12 -2
- package/src/internal/Store.test.ts +178 -0
- package/src/internal/Store.ts +104 -18
- package/src/internal/Tidx.test.ts +2 -1
- package/src/internal/Tidx.ts +7 -2
- package/src/internal/Timeout.test.ts +35 -0
- package/src/internal/Timeout.ts +73 -0
- package/src/internal/Timing.ts +16 -0
- package/src/internal/Viem.ts +39 -3
- package/src/internal/WebhookDestination.ts +3 -0
- package/src/internal/Webhooks.test.ts +45 -0
- package/src/internal/funding/Action.test.ts +41 -1
- package/src/internal/funding/Action.ts +69 -41
- package/src/internal/funding/Catalog.test.ts +34 -0
- package/src/internal/funding/Catalog.ts +28 -11
- package/src/internal/funding/DepositWebhook.ts +2 -1
- package/src/internal/funding/Evidence.ts +2 -13
- package/src/internal/funding/Provider.test.ts +73 -0
- package/src/internal/funding/Provider.ts +125 -28
- package/src/internal/funding/SourceObservation.ts +5 -9
- package/src/internal/funding/Transfer.test.ts +155 -0
- package/src/internal/funding/Transfer.ts +387 -147
- package/src/internal/funding/TransferReconciliation.test.ts +147 -0
- package/src/internal/funding/TransferReconciliation.ts +264 -0
- package/src/internal/funding/TransferWebhook.test.ts +128 -0
- package/src/internal/funding/TransferWebhook.ts +67 -0
- package/src/internal/funding/index.test.ts +1 -0
- package/src/internal/funding/index.ts +1 -0
- package/src/internal/funding/providers/index.test.ts +4 -167
- package/src/internal/funding/providers/relay.test.ts +2 -2
- package/src/internal/funding/providers/relay.ts +3 -15
- package/src/internal/funding/providers/stargate.test.ts +328 -0
- package/src/internal/funding/providers/stargate.ts +807 -135
- package/src/internal/index.test.ts +1 -0
- package/src/internal/index.ts +1 -0
- package/src/internal/webhookDestinations/slack.ts +15 -0
|
@@ -1,143 +1,579 @@
|
|
|
1
|
-
import { Address } from 'ox';
|
|
1
|
+
import { AbiEvent, AbiFunction, Address, Hash, Hex } from 'ox';
|
|
2
|
+
import { BlockNotFoundError, parseEventLogs, publicActions, TransactionReceiptNotFoundError, } from 'viem';
|
|
2
3
|
import * as z from 'zod/mini';
|
|
4
|
+
import * as Viem from '../../Viem.js';
|
|
5
|
+
import * as Action from '../Action.js';
|
|
6
|
+
import * as Chain from '../Chain.js';
|
|
3
7
|
import * as FundingProvider from '../Provider.js';
|
|
4
|
-
const
|
|
8
|
+
const approve = AbiFunction.from('function approve(address spender, uint256 amount)');
|
|
5
9
|
const defaultFetch = (input, init) => globalThis.fetch(input, init);
|
|
6
|
-
const
|
|
7
|
-
|
|
8
|
-
|
|
10
|
+
const destinationChainId = 'eip155:4217';
|
|
11
|
+
const destinationEid = 30_410;
|
|
12
|
+
const destinationPool = '0x8c76e2f6c5ceda9aa7772e7eff30280226c44392';
|
|
13
|
+
const destinationToken = '0x20C000000000000000000000b9537d11c60E8b50';
|
|
14
|
+
const layerZeroEndpoint = '0x1a44076050125825900e736c501f859c50fE728c';
|
|
15
|
+
const oftReceived = AbiEvent.from('event OFTReceived(bytes32 indexed guid, uint32 srcEid, address indexed toAddress, uint256 amountReceivedLD)');
|
|
16
|
+
const oftSent = AbiEvent.from('event OFTSent(bytes32 indexed guid, uint32 dstEid, address indexed fromAddress, uint256 amountSentLD, uint256 amountReceivedLD)');
|
|
17
|
+
const packetSent = AbiEvent.from('event PacketSent(bytes encodedPayload, bytes options, address sendLibrary)');
|
|
18
|
+
const quoteOft = AbiFunction.from('function quoteOFT((uint32 dstEid, bytes32 to, uint256 amountLD, uint256 minAmountLD, bytes extraOptions, bytes composeMsg, bytes oftCmd) sendParam) view returns ((uint256 minAmountLD, uint256 maxAmountLD) limit, (int256 feeAmountLD, string description)[] oftFeeDetails, (uint256 amountSentLD, uint256 amountReceivedLD) receipt)');
|
|
19
|
+
const quoteSend = AbiFunction.from('function quoteSend((uint32 dstEid, bytes32 to, uint256 amountLD, uint256 minAmountLD, bytes extraOptions, bytes composeMsg, bytes oftCmd) sendParam, bool payInLzToken) view returns ((uint256 nativeFee, uint256 lzTokenFee) fee)');
|
|
20
|
+
const sendToken = AbiFunction.from('function sendToken((uint32 dstEid, bytes32 to, uint256 amountLD, uint256 minAmountLD, bytes extraOptions, bytes composeMsg, bytes oftCmd) sendParam, (uint256 nativeFee, uint256 lzTokenFee) fee, address refundAddress) payable returns ((bytes32 guid, uint64 nonce, (uint256 nativeFee, uint256 lzTokenFee) fee) msgReceipt, (uint256 amountSentLD, uint256 amountReceivedLD) oftReceipt, (uint72 ticketId, bytes passengerBytes) ticket)');
|
|
21
|
+
const quoteTtlMs = 60_000;
|
|
22
|
+
const maximumLogBlockRange = 100000n;
|
|
23
|
+
const sourceEids = {
|
|
24
|
+
'eip155:1': 30_101,
|
|
25
|
+
'eip155:8453': 30_184,
|
|
9
26
|
};
|
|
10
|
-
|
|
27
|
+
const transferEvent = AbiEvent.from('event Transfer(address indexed from, address indexed to, uint256 value)');
|
|
28
|
+
const zeroAddress = '0x0000000000000000000000000000000000000000';
|
|
29
|
+
/** Stargate provider schemas. */
|
|
30
|
+
export var schema;
|
|
11
31
|
(function (schema) {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
.
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
}))
|
|
27
|
-
.check(z.minLength(1)),
|
|
28
|
-
srcAmount: IntegerString,
|
|
29
|
-
});
|
|
30
|
-
const Error = z.object({
|
|
31
|
-
message: z.string(),
|
|
32
|
-
status: z.union([z.string(), z.number()]),
|
|
33
|
-
});
|
|
34
|
-
schema.Quotes = z.object({
|
|
35
|
-
error: z.optional(z.nullable(Error)),
|
|
36
|
-
quotes: z.array(Quote),
|
|
37
|
-
});
|
|
32
|
+
/** Configuration captured from one selected Stargate route. */
|
|
33
|
+
schema.Configuration = z
|
|
34
|
+
.strictObject({
|
|
35
|
+
destinationPoolAddress: z.optional(z
|
|
36
|
+
.string()
|
|
37
|
+
.check(z.regex(/^0x[0-9a-fA-F]{40}$/), z.describe('Stargate pool contract on the Tempo destination chain.'))),
|
|
38
|
+
poolAddress: z
|
|
39
|
+
.string()
|
|
40
|
+
.check(z.regex(/^0x[0-9a-fA-F]{40}$/), z.describe('Stargate pool contract on the source chain.')),
|
|
41
|
+
sourceEid: z.optional(z
|
|
42
|
+
.number()
|
|
43
|
+
.check(z.int(), z.positive(), z.describe('LayerZero endpoint ID for the source chain.'))),
|
|
44
|
+
})
|
|
45
|
+
.check(z.describe('Stargate configuration for one funding route.'));
|
|
38
46
|
})(schema || (schema = {}));
|
|
39
|
-
/** Creates a Stargate funding provider
|
|
40
|
-
export function stargate(options) {
|
|
41
|
-
if (options.apiKey.trim().length === 0)
|
|
42
|
-
throw new FundingProvider.ProviderConfigurationError();
|
|
43
|
-
if (!Address.validate(options.userAddress, { strict: false }))
|
|
44
|
-
throw new FundingProvider.ProviderConfigurationError();
|
|
45
|
-
const endpoint = new URL(options.baseUrl ?? defaultBaseUrl);
|
|
46
|
-
endpoint.pathname = `${endpoint.pathname.replace(/\/+$/, '')}/quotes`;
|
|
47
|
+
/** Creates a direct Stargate V2 OFT funding provider. */
|
|
48
|
+
export function stargate(options = {}) {
|
|
47
49
|
const fetch = options.fetch ?? defaultFetch;
|
|
48
50
|
const now = options.now ?? (() => new Date());
|
|
49
51
|
return FundingProvider.from({
|
|
50
52
|
id: 'stargate',
|
|
51
53
|
name: 'Stargate',
|
|
52
54
|
async getQuote({ candidate, route }, signal) {
|
|
53
|
-
const
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
55
|
+
const deployment = resolveDeployment({
|
|
56
|
+
configuration: candidate.configuration,
|
|
57
|
+
destinationChainId: route.destination.chain.id,
|
|
58
|
+
destinationTokenAddress: route.destination.address,
|
|
59
|
+
sourceChainId: route.source.chain.id,
|
|
60
|
+
sourceTokenAddress: route.source.address,
|
|
61
|
+
});
|
|
62
|
+
const sampledAt = now();
|
|
63
|
+
if (!deployment)
|
|
64
|
+
return unavailable({ message: 'ROUTE_NOT_CONFIGURED', now: sampledAt });
|
|
65
|
+
const sendParam = createSendParam({
|
|
66
|
+
amount: candidate.sourceAmount.amount,
|
|
67
|
+
recipient: zeroAddress,
|
|
68
|
+
});
|
|
69
|
+
const [limit, feeDetails, receipt] = await rpcClient({
|
|
64
70
|
fetch,
|
|
65
|
-
headers: { 'user-agent': 'tempo-api', 'x-api-key': options.apiKey },
|
|
66
|
-
method: 'POST',
|
|
67
71
|
signal,
|
|
72
|
+
urls: route.source.chain.rpcUrls,
|
|
73
|
+
}).readContract({
|
|
74
|
+
abi: [quoteOft],
|
|
75
|
+
address: deployment.pool,
|
|
76
|
+
args: [sendParam],
|
|
77
|
+
functionName: 'quoteOFT',
|
|
68
78
|
});
|
|
69
|
-
|
|
70
|
-
|
|
79
|
+
if (!isExactQuote({ amount: candidate.sourceAmount.amount, feeDetails, limit, receipt }))
|
|
80
|
+
return unavailable({ message: 'NO_EXACT_ROUTE', now: sampledAt });
|
|
81
|
+
return {
|
|
82
|
+
destinationAmountMin: receipt.amountReceivedLD.toString(),
|
|
83
|
+
destinationAmount: receipt.amountReceivedLD.toString(),
|
|
84
|
+
quality: quality(),
|
|
85
|
+
sampledAt: sampledAt.toISOString(),
|
|
86
|
+
status: 'available',
|
|
87
|
+
};
|
|
88
|
+
},
|
|
89
|
+
async prepareTransfer({ candidate, method, mode, recipient, sender }, signal) {
|
|
90
|
+
if (method !== 'transaction' ||
|
|
91
|
+
mode !== 'exactSource' ||
|
|
92
|
+
!Address.validate(recipient, { strict: false }) ||
|
|
93
|
+
!Address.validate(sender, { strict: false }))
|
|
94
|
+
throw new FundingProvider.ProviderConfigurationError();
|
|
95
|
+
const deployment = resolveDeployment({
|
|
96
|
+
configuration: candidate.configuration,
|
|
97
|
+
destinationChainId: candidate.destinationChain.id,
|
|
98
|
+
destinationTokenAddress: candidate.destinationToken.address,
|
|
99
|
+
sourceChainId: candidate.sourceChain.id,
|
|
100
|
+
sourceTokenAddress: candidate.sourceToken.address,
|
|
101
|
+
});
|
|
102
|
+
if (!deployment)
|
|
103
|
+
throw new FundingProvider.ProviderUnavailableError();
|
|
104
|
+
const sendParam = createSendParam({ amount: candidate.sourceAmount.amount, recipient });
|
|
105
|
+
const rpc = rpcClient({ fetch, signal, urls: candidate.route.source.chain.rpcUrls });
|
|
106
|
+
const [[limit, feeDetails, receipt], messagingFee, destinationBlock] = await Promise.all([
|
|
107
|
+
rpc.readContract({
|
|
108
|
+
abi: [quoteOft],
|
|
109
|
+
address: deployment.pool,
|
|
110
|
+
args: [sendParam],
|
|
111
|
+
functionName: 'quoteOFT',
|
|
112
|
+
}),
|
|
113
|
+
rpc.readContract({
|
|
114
|
+
abi: [quoteSend],
|
|
115
|
+
account: sender,
|
|
116
|
+
address: deployment.pool,
|
|
117
|
+
args: [sendParam, false],
|
|
118
|
+
functionName: 'quoteSend',
|
|
119
|
+
}),
|
|
120
|
+
rpcClient({
|
|
121
|
+
fetch,
|
|
122
|
+
signal,
|
|
123
|
+
urls: candidate.route.destination.chain.rpcUrls,
|
|
124
|
+
}).getBlock({ blockTag: 'finalized', includeTransactions: false }),
|
|
125
|
+
]);
|
|
126
|
+
if (!isExactQuote({ amount: candidate.sourceAmount.amount, feeDetails, limit, receipt }))
|
|
127
|
+
throw new FundingProvider.ProviderUnavailableError();
|
|
128
|
+
if (messagingFee.lzTokenFee !== 0n)
|
|
71
129
|
throw new FundingProvider.ProviderPayloadError();
|
|
130
|
+
const action = {
|
|
131
|
+
calls: [
|
|
132
|
+
{
|
|
133
|
+
data: AbiFunction.encodeData(approve, [
|
|
134
|
+
deployment.pool,
|
|
135
|
+
BigInt(candidate.sourceAmount.amount),
|
|
136
|
+
]),
|
|
137
|
+
to: deployment.sourceToken,
|
|
138
|
+
value: '0x0',
|
|
139
|
+
},
|
|
140
|
+
{
|
|
141
|
+
data: AbiFunction.encodeData(sendToken, [sendParam, messagingFee, sender]),
|
|
142
|
+
to: deployment.pool,
|
|
143
|
+
value: Hex.fromNumber(messagingFee.nativeFee),
|
|
144
|
+
},
|
|
145
|
+
],
|
|
146
|
+
type: 'evm:calls',
|
|
147
|
+
};
|
|
148
|
+
validateAction({
|
|
149
|
+
action,
|
|
150
|
+
configuration: candidate.configuration,
|
|
151
|
+
destinationTokenAddress: candidate.destinationToken.address,
|
|
152
|
+
recipient,
|
|
153
|
+
sender,
|
|
154
|
+
sourceAmount: candidate.sourceAmount.amount,
|
|
155
|
+
sourceChainId: candidate.sourceChain.id,
|
|
156
|
+
sourceTokenAddress: candidate.sourceToken.address,
|
|
157
|
+
});
|
|
72
158
|
const sampledAt = now();
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
159
|
+
return {
|
|
160
|
+
action,
|
|
161
|
+
destinationAmountMin: receipt.amountReceivedLD.toString(),
|
|
162
|
+
destinationAmount: receipt.amountReceivedLD.toString(),
|
|
163
|
+
expiresAt: new Date(sampledAt.getTime() + quoteTtlMs).toISOString(),
|
|
164
|
+
fees: messagingFee.nativeFee === 0n
|
|
165
|
+
? []
|
|
166
|
+
: [
|
|
167
|
+
{
|
|
168
|
+
amount: messagingFee.nativeFee.toString(),
|
|
169
|
+
side: 'source',
|
|
170
|
+
token: nativeToken(candidate.sourceChain.id),
|
|
171
|
+
},
|
|
172
|
+
],
|
|
173
|
+
providerState: {
|
|
174
|
+
destinationBlockNumber: destinationBlock.number.toString(),
|
|
175
|
+
routeConfiguration: candidate.configuration,
|
|
176
|
+
},
|
|
177
|
+
quality: quality(),
|
|
178
|
+
sampledAt: sampledAt.toISOString(),
|
|
179
|
+
};
|
|
180
|
+
},
|
|
181
|
+
validateTransferAction({ action, candidate, recipient, sender }) {
|
|
182
|
+
return {
|
|
183
|
+
nativeValues: validateAction({
|
|
184
|
+
action,
|
|
185
|
+
configuration: candidate.configuration,
|
|
186
|
+
destinationTokenAddress: candidate.destinationToken.address,
|
|
187
|
+
recipient,
|
|
188
|
+
sender,
|
|
189
|
+
sourceAmount: candidate.sourceAmount.amount,
|
|
190
|
+
sourceChainId: candidate.sourceChain.id,
|
|
191
|
+
sourceTokenAddress: candidate.sourceToken.address,
|
|
192
|
+
}),
|
|
193
|
+
};
|
|
194
|
+
},
|
|
195
|
+
async verifySourceTransaction({ destinationChain, providerState, routeConfiguration, sourceChain, transactionHash, transfer, }, signal) {
|
|
196
|
+
if (transfer.method !== 'transaction' || transfer.mode !== 'exactSource' || !transfer.sender)
|
|
197
|
+
return { type: 'invalid' };
|
|
198
|
+
const configuration = providerState?.['routeConfiguration'] ?? routeConfiguration;
|
|
199
|
+
const evidence = await verifySourceTransaction({
|
|
200
|
+
configuration,
|
|
201
|
+
destinationTokenAddress: transfer.destinationToken.address,
|
|
202
|
+
fetch,
|
|
203
|
+
recipient: transfer.recipient,
|
|
204
|
+
sender: transfer.sender,
|
|
205
|
+
signal,
|
|
206
|
+
sourceAmount: transfer.sourceAmount.baseUnits,
|
|
207
|
+
sourceChain,
|
|
208
|
+
sourceTokenAddress: transfer.sourceToken.address,
|
|
209
|
+
transactionHash,
|
|
210
|
+
validAfter: transfer.quote.sampledAt,
|
|
77
211
|
});
|
|
78
|
-
if (
|
|
79
|
-
return
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
212
|
+
if (evidence.type === 'invalid')
|
|
213
|
+
return evidence;
|
|
214
|
+
if (evidence.type !== 'verified')
|
|
215
|
+
return { type: 'pending' };
|
|
216
|
+
const destinationBlockNumber = typeof providerState?.['destinationBlockNumber'] === 'string' &&
|
|
217
|
+
/^\d+$/.test(providerState['destinationBlockNumber'])
|
|
218
|
+
? providerState['destinationBlockNumber']
|
|
219
|
+
: await blockNumberBefore({
|
|
220
|
+
chain: destinationChain,
|
|
221
|
+
fetch,
|
|
222
|
+
signal,
|
|
223
|
+
timestamp: transfer.quote.sampledAt,
|
|
84
224
|
});
|
|
85
|
-
const estimated = estimatedSeconds(selected.quote.duration?.estimated);
|
|
86
225
|
return {
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
226
|
+
providerState: {
|
|
227
|
+
...providerState,
|
|
228
|
+
destinationBlockNumber,
|
|
229
|
+
routeConfiguration: configuration,
|
|
230
|
+
stargate: {
|
|
231
|
+
guid: evidence.guid,
|
|
232
|
+
sourceBlock: {
|
|
233
|
+
hash: evidence.sourceBlock.hash,
|
|
234
|
+
number: evidence.sourceBlock.number.toString(),
|
|
235
|
+
},
|
|
236
|
+
sourceEid: evidence.sourceEid,
|
|
237
|
+
},
|
|
95
238
|
},
|
|
96
|
-
|
|
97
|
-
status: 'available',
|
|
239
|
+
type: 'verified',
|
|
98
240
|
};
|
|
99
241
|
},
|
|
100
242
|
});
|
|
101
243
|
}
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
const
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
if (quote.srcAmount !== options.amount ||
|
|
115
|
-
BigInt(quote.dstAmount) <= 0n ||
|
|
116
|
-
BigInt(quote.dstAmountMin) <= 0n ||
|
|
117
|
-
BigInt(quote.dstAmountMin) > BigInt(quote.dstAmount))
|
|
244
|
+
/** Validates one direct Stargate action and returns its exact native-value allowance. */
|
|
245
|
+
export function validateAction(options) {
|
|
246
|
+
try {
|
|
247
|
+
const action = Action.schema.EvmCalls.parse(options.action);
|
|
248
|
+
const deployment = resolveDeployment({
|
|
249
|
+
configuration: options.configuration,
|
|
250
|
+
destinationChainId,
|
|
251
|
+
destinationTokenAddress: options.destinationTokenAddress,
|
|
252
|
+
sourceChainId: options.sourceChainId,
|
|
253
|
+
sourceTokenAddress: options.sourceTokenAddress,
|
|
254
|
+
});
|
|
255
|
+
if (!deployment || action.calls.length !== 2)
|
|
118
256
|
throw new FundingProvider.ProviderPayloadError();
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
257
|
+
const [approval, execution] = action.calls;
|
|
258
|
+
if (!Address.isEqual(approval.to, deployment.sourceToken) ||
|
|
259
|
+
BigInt(approval.value) !== 0n)
|
|
260
|
+
throw new FundingProvider.ProviderPayloadError();
|
|
261
|
+
const [spender, approvalAmount] = AbiFunction.decodeData(approve, approval.data);
|
|
262
|
+
if (!Address.isEqual(spender, deployment.pool) ||
|
|
263
|
+
approvalAmount !== BigInt(options.sourceAmount))
|
|
264
|
+
throw new FundingProvider.ProviderPayloadError();
|
|
265
|
+
validateSend({
|
|
266
|
+
data: execution.data,
|
|
267
|
+
nativeValue: BigInt(execution.value),
|
|
268
|
+
pool: deployment.pool,
|
|
269
|
+
recipient: options.recipient,
|
|
270
|
+
sender: options.sender,
|
|
271
|
+
sourceAmount: options.sourceAmount,
|
|
272
|
+
to: execution.to,
|
|
273
|
+
});
|
|
274
|
+
return [{ to: execution.to, value: execution.value }];
|
|
275
|
+
}
|
|
276
|
+
catch (cause) {
|
|
277
|
+
if (cause instanceof FundingProvider.ProviderPayloadError)
|
|
278
|
+
throw cause;
|
|
279
|
+
throw new FundingProvider.ProviderPayloadError();
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
/** Verifies a submitted Stargate source transaction against stored transfer terms. */
|
|
283
|
+
export async function verifySourceTransaction(options) {
|
|
284
|
+
const deployment = resolveDeployment({
|
|
285
|
+
configuration: options.configuration,
|
|
286
|
+
destinationChainId,
|
|
287
|
+
destinationTokenAddress: options.destinationTokenAddress,
|
|
288
|
+
sourceChainId: options.sourceChain.id,
|
|
289
|
+
sourceTokenAddress: options.sourceTokenAddress,
|
|
290
|
+
});
|
|
291
|
+
if (!deployment ||
|
|
292
|
+
options.sourceChain.kind !== 'evm' ||
|
|
293
|
+
!Hash.validate(options.transactionHash) ||
|
|
294
|
+
!Address.validate(options.recipient, { strict: false }) ||
|
|
295
|
+
!Address.validate(options.sender, { strict: false }))
|
|
296
|
+
return { type: 'invalid' };
|
|
297
|
+
const rpc = rpcClient({
|
|
298
|
+
fetch: options.fetch ?? defaultFetch,
|
|
299
|
+
signal: options.signal,
|
|
300
|
+
urls: options.sourceChain.rpcUrls,
|
|
301
|
+
});
|
|
302
|
+
const hash = options.transactionHash;
|
|
303
|
+
const [chainId, receipt] = await Promise.all([
|
|
304
|
+
rpc.getChainId(),
|
|
305
|
+
rpc.getTransactionReceipt({ hash }).catch((cause) => {
|
|
306
|
+
if (cause instanceof TransactionReceiptNotFoundError)
|
|
307
|
+
return undefined;
|
|
308
|
+
throw cause;
|
|
309
|
+
}),
|
|
310
|
+
]);
|
|
311
|
+
if (chainId !== Number(Chain.eip155Id(options.sourceChain)))
|
|
312
|
+
return { type: 'invalid' };
|
|
313
|
+
const block = !receipt || receipt.blockNumber === null
|
|
314
|
+
? undefined
|
|
315
|
+
: await rpc
|
|
316
|
+
.getBlock({ blockNumber: receipt.blockNumber, includeTransactions: false })
|
|
317
|
+
.catch((cause) => {
|
|
318
|
+
if (cause instanceof BlockNotFoundError)
|
|
319
|
+
return undefined;
|
|
320
|
+
throw cause;
|
|
321
|
+
});
|
|
322
|
+
if (!receipt ||
|
|
323
|
+
receipt.blockNumber === null ||
|
|
324
|
+
!block ||
|
|
325
|
+
!Hex.isEqual(block.hash, receipt.blockHash)) {
|
|
326
|
+
if (!options.sourceBlock)
|
|
327
|
+
return { type: 'pending' };
|
|
328
|
+
const finalized = await rpc.getBlock({ blockTag: 'finalized', includeTransactions: false });
|
|
329
|
+
if (finalized.number < options.sourceBlock.number)
|
|
330
|
+
return { type: 'pending' };
|
|
331
|
+
const canonical = await rpc
|
|
332
|
+
.getBlock({ blockNumber: options.sourceBlock.number, includeTransactions: false })
|
|
333
|
+
.catch((cause) => {
|
|
334
|
+
if (cause instanceof BlockNotFoundError)
|
|
335
|
+
return undefined;
|
|
336
|
+
throw cause;
|
|
337
|
+
});
|
|
338
|
+
if (!canonical || Hex.isEqual(canonical.hash, options.sourceBlock.hash))
|
|
339
|
+
return { type: 'pending' };
|
|
340
|
+
return { type: 'reorged' };
|
|
341
|
+
}
|
|
342
|
+
if (receipt.status !== 'success')
|
|
343
|
+
return { type: 'invalid' };
|
|
344
|
+
const validAfter = Math.floor(Date.parse(options.validAfter) / 1_000);
|
|
345
|
+
if (!Number.isSafeInteger(validAfter) || block.timestamp < BigInt(validAfter))
|
|
346
|
+
return { type: 'invalid' };
|
|
347
|
+
const amount = BigInt(options.sourceAmount);
|
|
348
|
+
const sourceEvents = parseEventLogs({ abi: [oftSent], logs: receipt.logs, strict: true }).filter(({ address, args }) => Address.isEqual(address, deployment.pool) &&
|
|
349
|
+
args.dstEid === destinationEid &&
|
|
350
|
+
Address.isEqual(args.fromAddress, options.sender) &&
|
|
351
|
+
args.amountSentLD === amount &&
|
|
352
|
+
args.amountReceivedLD === amount);
|
|
353
|
+
const transfers = parseEventLogs({
|
|
354
|
+
abi: [transferEvent],
|
|
355
|
+
logs: receipt.logs,
|
|
356
|
+
strict: true,
|
|
357
|
+
}).filter(({ address, args }) => Address.isEqual(address, deployment.sourceToken) &&
|
|
358
|
+
Address.isEqual(args.from, options.sender) &&
|
|
359
|
+
Address.isEqual(args.to, deployment.pool) &&
|
|
360
|
+
args.value === amount);
|
|
361
|
+
if (sourceEvents.length !== 1 || transfers.length !== 1)
|
|
362
|
+
return { type: 'invalid' };
|
|
363
|
+
const guid = sourceEvents[0].args.guid;
|
|
364
|
+
// PacketV1's 113-byte header is followed by Stargate's type, asset id, recipient, and amount.
|
|
365
|
+
const packets = parseEventLogs({ abi: [packetSent], logs: receipt.logs, strict: true }).filter(({ address, args }) => {
|
|
366
|
+
const packet = args.encodedPayload;
|
|
367
|
+
return (Address.isEqual(address, layerZeroEndpoint) &&
|
|
368
|
+
Hex.size(packet) === 156 &&
|
|
369
|
+
Hex.toNumber(Hex.slice(packet, 0, 1)) === 1 &&
|
|
370
|
+
Hex.toNumber(Hex.slice(packet, 9, 13)) === deployment.sourceEid &&
|
|
371
|
+
Hex.toNumber(Hex.slice(packet, 45, 49)) === destinationEid &&
|
|
372
|
+
Hex.isEqual(Hex.slice(packet, 81, 113), guid) &&
|
|
373
|
+
Hex.toNumber(Hex.slice(packet, 113, 114)) === 1 &&
|
|
374
|
+
Hex.isEqual(Hex.slice(packet, 116, 148), recipientBytes32(options.recipient)) &&
|
|
375
|
+
Hex.toBigInt(Hex.slice(packet, 148, 156)) === amount);
|
|
376
|
+
});
|
|
377
|
+
if (packets.length !== 1)
|
|
378
|
+
return { type: 'invalid' };
|
|
379
|
+
return {
|
|
380
|
+
guid,
|
|
381
|
+
sourceBlock: { hash: block.hash, number: block.number },
|
|
382
|
+
sourceEid: deployment.sourceEid,
|
|
383
|
+
type: 'verified',
|
|
384
|
+
};
|
|
385
|
+
}
|
|
386
|
+
/** Finds and verifies the finalized Stargate delivery directly on Tempo. */
|
|
387
|
+
export async function verifyDestinationDelivery(options) {
|
|
388
|
+
const deployment = resolveDeployment({
|
|
389
|
+
configuration: options.configuration,
|
|
390
|
+
destinationChainId: options.destinationChain.id,
|
|
391
|
+
destinationTokenAddress: options.destinationTokenAddress,
|
|
392
|
+
sourceChainId: options.sourceChainId,
|
|
393
|
+
sourceTokenAddress: options.sourceTokenAddress,
|
|
394
|
+
});
|
|
395
|
+
if (!deployment ||
|
|
396
|
+
options.destinationChain.kind !== 'evm' ||
|
|
397
|
+
!/^\d+$/.test(options.destinationBlockNumber) ||
|
|
398
|
+
!Hash.validate(options.guid) ||
|
|
399
|
+
!Address.validate(options.recipient, { strict: false }))
|
|
400
|
+
return { type: 'invalid' };
|
|
401
|
+
const rpc = rpcClient({
|
|
402
|
+
fetch: options.fetch ?? defaultFetch,
|
|
403
|
+
urls: options.destinationChain.rpcUrls,
|
|
404
|
+
});
|
|
405
|
+
const [chainId, finalized] = await Promise.all([
|
|
406
|
+
rpc.getChainId(),
|
|
407
|
+
rpc.getBlock({ blockTag: 'finalized', includeTransactions: false }),
|
|
408
|
+
]);
|
|
409
|
+
if (chainId !== Number(Chain.eip155Id(options.destinationChain)))
|
|
410
|
+
return { type: 'invalid' };
|
|
411
|
+
const amount = BigInt(options.destinationAmount);
|
|
412
|
+
const discovered = await (async () => {
|
|
413
|
+
for (let fromBlock = BigInt(options.destinationBlockNumber); fromBlock <= finalized.number; fromBlock += maximumLogBlockRange) {
|
|
414
|
+
const toBlock = fromBlock + maximumLogBlockRange - 1n;
|
|
415
|
+
const logs = await rpc.getLogs({
|
|
416
|
+
address: deployment.destinationPool,
|
|
417
|
+
args: { guid: options.guid, toAddress: options.recipient },
|
|
418
|
+
event: oftReceived,
|
|
419
|
+
fromBlock,
|
|
420
|
+
strict: true,
|
|
421
|
+
toBlock: toBlock > finalized.number ? finalized.number : toBlock,
|
|
422
|
+
});
|
|
423
|
+
const matches = logs.filter(({ args, transactionHash }) => transactionHash &&
|
|
424
|
+
args.srcEid === deployment.sourceEid &&
|
|
425
|
+
args.amountReceivedLD === amount);
|
|
426
|
+
if (logs.length !== matches.length || matches.length > 1)
|
|
427
|
+
return { type: 'invalid' };
|
|
428
|
+
if (matches[0]?.transactionHash)
|
|
429
|
+
return { transactionHash: matches[0].transactionHash, type: 'found' };
|
|
430
|
+
}
|
|
431
|
+
return { type: 'pending' };
|
|
432
|
+
})();
|
|
433
|
+
if (discovered.type !== 'found')
|
|
434
|
+
return discovered;
|
|
435
|
+
const { transactionHash } = discovered;
|
|
436
|
+
const receipt = await rpc.getTransactionReceipt({ hash: transactionHash }).catch((cause) => {
|
|
437
|
+
if (cause instanceof TransactionReceiptNotFoundError)
|
|
438
|
+
return undefined;
|
|
439
|
+
throw cause;
|
|
440
|
+
});
|
|
441
|
+
if (!receipt || receipt.blockNumber === null)
|
|
442
|
+
return { type: 'pending' };
|
|
443
|
+
if (receipt.status !== 'success' || receipt.blockNumber > finalized.number)
|
|
444
|
+
return { type: 'invalid' };
|
|
445
|
+
const transfers = parseEventLogs({
|
|
446
|
+
abi: [transferEvent],
|
|
447
|
+
logs: receipt.logs,
|
|
448
|
+
strict: true,
|
|
449
|
+
}).filter(({ address, args }) => Address.isEqual(address, destinationToken) &&
|
|
450
|
+
Address.isEqual(args.from, zeroAddress) &&
|
|
451
|
+
Address.isEqual(args.to, options.recipient) &&
|
|
452
|
+
args.value === amount);
|
|
453
|
+
if (transfers.length !== 1)
|
|
454
|
+
return { type: 'invalid' };
|
|
455
|
+
return { transactionHash, type: 'verified' };
|
|
129
456
|
}
|
|
130
|
-
function
|
|
131
|
-
|
|
457
|
+
function rpcClient(options) {
|
|
458
|
+
if (options.urls.length === 0)
|
|
459
|
+
throw new FundingProvider.ProviderConfigurationError();
|
|
460
|
+
return Viem.createEvmClient(options).extend(publicActions);
|
|
132
461
|
}
|
|
133
|
-
function
|
|
134
|
-
if (
|
|
135
|
-
|
|
136
|
-
const
|
|
137
|
-
|
|
138
|
-
const seconds = (roundedMilliseconds + 999n) / 1000n;
|
|
139
|
-
if (seconds > BigInt(Number.MAX_SAFE_INTEGER))
|
|
462
|
+
async function blockNumberBefore(options) {
|
|
463
|
+
if (options.chain.kind !== 'evm')
|
|
464
|
+
throw new FundingProvider.ProviderConfigurationError();
|
|
465
|
+
const timestamp = Date.parse(options.timestamp);
|
|
466
|
+
if (!Number.isFinite(timestamp))
|
|
140
467
|
throw new FundingProvider.ProviderPayloadError();
|
|
141
|
-
|
|
468
|
+
const rpc = rpcClient({
|
|
469
|
+
fetch: options.fetch,
|
|
470
|
+
signal: options.signal,
|
|
471
|
+
urls: options.chain.rpcUrls,
|
|
472
|
+
});
|
|
473
|
+
const [chainId, finalized] = await Promise.all([
|
|
474
|
+
rpc.getChainId(),
|
|
475
|
+
rpc.getBlock({ blockTag: 'finalized', includeTransactions: false }),
|
|
476
|
+
]);
|
|
477
|
+
if (chainId !== Number(Chain.eip155Id(options.chain)))
|
|
478
|
+
throw new FundingProvider.ProviderConfigurationError();
|
|
479
|
+
const target = BigInt(Math.floor(timestamp / 1_000) - 1);
|
|
480
|
+
let lower = 0n;
|
|
481
|
+
let upper = finalized.number;
|
|
482
|
+
while (lower < upper) {
|
|
483
|
+
const middle = (lower + upper + 1n) / 2n;
|
|
484
|
+
const block = await rpc.getBlock({ blockNumber: middle, includeTransactions: false });
|
|
485
|
+
if (block.timestamp <= target)
|
|
486
|
+
lower = middle;
|
|
487
|
+
else
|
|
488
|
+
upper = middle - 1n;
|
|
489
|
+
}
|
|
490
|
+
return lower.toString();
|
|
491
|
+
}
|
|
492
|
+
function createSendParam(options) {
|
|
493
|
+
const amount = BigInt(options.amount);
|
|
494
|
+
return {
|
|
495
|
+
amountLD: amount,
|
|
496
|
+
composeMsg: '0x',
|
|
497
|
+
dstEid: destinationEid,
|
|
498
|
+
extraOptions: '0x',
|
|
499
|
+
minAmountLD: amount,
|
|
500
|
+
oftCmd: '0x',
|
|
501
|
+
to: recipientBytes32(options.recipient),
|
|
502
|
+
};
|
|
503
|
+
}
|
|
504
|
+
function isExactQuote(options) {
|
|
505
|
+
const amount = BigInt(options.amount);
|
|
506
|
+
return (amount >= options.limit.minAmountLD &&
|
|
507
|
+
amount <= options.limit.maxAmountLD &&
|
|
508
|
+
options.feeDetails.every((fee) => fee.feeAmountLD >= 0n) &&
|
|
509
|
+
options.receipt.amountSentLD === amount &&
|
|
510
|
+
options.receipt.amountReceivedLD === amount);
|
|
511
|
+
}
|
|
512
|
+
function nativeToken(sourceChainId) {
|
|
513
|
+
return {
|
|
514
|
+
address: '0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee',
|
|
515
|
+
currency: 'ETH',
|
|
516
|
+
decimals: 18,
|
|
517
|
+
name: 'Ether',
|
|
518
|
+
standard: 'native',
|
|
519
|
+
symbol: 'ETH',
|
|
520
|
+
tokenKey: `${sourceChainId}/slip44:60`,
|
|
521
|
+
verified: true,
|
|
522
|
+
};
|
|
523
|
+
}
|
|
524
|
+
function quality() {
|
|
525
|
+
return {
|
|
526
|
+
liquiditySource: 'onchain',
|
|
527
|
+
sourceDetail: 'stargate:oft-v2:taxi',
|
|
528
|
+
tier: 'liquid',
|
|
529
|
+
};
|
|
530
|
+
}
|
|
531
|
+
function recipientBytes32(recipient) {
|
|
532
|
+
if (!Address.validate(recipient, { strict: false }))
|
|
533
|
+
throw new FundingProvider.ProviderConfigurationError();
|
|
534
|
+
return Hex.padLeft(recipient, 32);
|
|
535
|
+
}
|
|
536
|
+
function validateSend(options) {
|
|
537
|
+
const [sendParam, messagingFee, refundAddress] = AbiFunction.decodeData(sendToken, options.data);
|
|
538
|
+
const amount = BigInt(options.sourceAmount);
|
|
539
|
+
if (!Address.isEqual(options.to, options.pool) ||
|
|
540
|
+
sendParam.amountLD !== amount ||
|
|
541
|
+
sendParam.composeMsg !== '0x' ||
|
|
542
|
+
sendParam.dstEid !== destinationEid ||
|
|
543
|
+
sendParam.extraOptions !== '0x' ||
|
|
544
|
+
sendParam.minAmountLD !== amount ||
|
|
545
|
+
sendParam.oftCmd !== '0x' ||
|
|
546
|
+
!Hex.isEqual(sendParam.to, recipientBytes32(options.recipient)) ||
|
|
547
|
+
messagingFee.lzTokenFee !== 0n ||
|
|
548
|
+
messagingFee.nativeFee !== options.nativeValue ||
|
|
549
|
+
!Address.isEqual(refundAddress, options.sender))
|
|
550
|
+
throw new FundingProvider.ProviderPayloadError();
|
|
551
|
+
}
|
|
552
|
+
function resolveDeployment(options) {
|
|
553
|
+
const parsed = schema.Configuration.safeParse(options.configuration);
|
|
554
|
+
const sourceEid = parsed.success &&
|
|
555
|
+
(parsed.data.sourceEid ?? sourceEids[options.sourceChainId]);
|
|
556
|
+
if (!parsed.success ||
|
|
557
|
+
!sourceEid ||
|
|
558
|
+
options.destinationChainId !== destinationChainId ||
|
|
559
|
+
!options.sourceChainId.startsWith('eip155:') ||
|
|
560
|
+
!Address.validate(options.destinationTokenAddress, { strict: false }) ||
|
|
561
|
+
!Address.validate(options.sourceTokenAddress, { strict: false }) ||
|
|
562
|
+
!Address.isEqual(options.destinationTokenAddress, destinationToken))
|
|
563
|
+
return undefined;
|
|
564
|
+
return {
|
|
565
|
+
destinationPool: Address.checksum(parsed.data.destinationPoolAddress ?? destinationPool),
|
|
566
|
+
pool: Address.checksum(parsed.data.poolAddress),
|
|
567
|
+
sourceEid,
|
|
568
|
+
sourceToken: Address.checksum(options.sourceTokenAddress),
|
|
569
|
+
};
|
|
570
|
+
}
|
|
571
|
+
function unavailable(options) {
|
|
572
|
+
return FundingProvider.unavailableResult({
|
|
573
|
+
detail: 'stargate:oft-v2',
|
|
574
|
+
message: options.message,
|
|
575
|
+
now: options.now,
|
|
576
|
+
source: 'onchain',
|
|
577
|
+
});
|
|
142
578
|
}
|
|
143
579
|
//# sourceMappingURL=stargate.js.map
|