tapimo 0.7.2 → 0.9.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 +7 -3
- package/dist/ApiKeys.d.ts.map +1 -1
- package/dist/ApiKeys.js +9 -2
- package/dist/ApiKeys.js.map +1 -1
- package/dist/App.d.ts +20117 -19183
- package/dist/App.d.ts.map +1 -1
- package/dist/App.js +61 -4
- package/dist/App.js.map +1 -1
- package/dist/admin/App.d.ts +84 -74
- package/dist/admin/App.d.ts.map +1 -1
- package/dist/admin/apps/api-keys.d.ts +14 -1
- package/dist/admin/apps/api-keys.d.ts.map +1 -1
- package/dist/admin/apps/api-keys.js +6 -2
- package/dist/admin/apps/api-keys.js.map +1 -1
- 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 +11 -11
- package/dist/admin/ui.generated.d.ts +1 -1
- package/dist/admin/ui.generated.js +67 -67
- package/dist/admin/ui.generated.js.map +1 -1
- package/dist/analytics/Analytics.d.ts +2 -0
- package/dist/analytics/Analytics.d.ts.map +1 -1
- package/dist/analytics/Analytics.js +3 -0
- package/dist/analytics/Analytics.js.map +1 -1
- package/dist/apps/data/App.d.ts +11696 -13937
- package/dist/apps/data/App.d.ts.map +1 -1
- package/dist/apps/data/App.js +4 -8
- package/dist/apps/data/App.js.map +1 -1
- package/dist/apps/data/routes/activities.d.ts +271 -271
- package/dist/apps/data/routes/addresses.d.ts +398 -167
- package/dist/apps/data/routes/addresses.d.ts.map +1 -1
- package/dist/apps/data/routes/balances.d.ts +278 -8
- package/dist/apps/data/routes/balances.d.ts.map +1 -1
- package/dist/apps/data/routes/balances.js +114 -2
- package/dist/apps/data/routes/balances.js.map +1 -1
- package/dist/apps/data/routes/blocks.d.ts +123 -123
- package/dist/apps/data/routes/coingecko.d.ts +170 -170
- package/dist/apps/data/routes/earn.d.ts +498 -6
- package/dist/apps/data/routes/earn.d.ts.map +1 -1
- package/dist/apps/data/routes/earn.js +876 -4
- package/dist/apps/data/routes/earn.js.map +1 -1
- package/dist/apps/data/routes/exchanges.d.ts +10 -10
- package/dist/apps/data/routes/fee-amm.d.ts +2 -2
- package/dist/apps/data/routes/indexer.d.ts +6 -6
- package/dist/apps/data/routes/indexer.js +4 -1
- package/dist/apps/data/routes/indexer.js.map +1 -1
- package/dist/apps/data/routes/receipts.d.ts +235 -235
- package/dist/apps/data/routes/rpc.d.ts +31 -31
- package/dist/apps/data/routes/rpc.js +4 -1
- package/dist/apps/data/routes/rpc.js.map +1 -1
- package/dist/apps/data/routes/tokenlist.d.ts +36 -36
- package/dist/apps/data/routes/tokens.d.ts +449 -449
- package/dist/apps/data/routes/transactions.d.ts +2 -2
- package/dist/apps/data/routes/transfers.d.ts +81 -81
- package/dist/apps/data/routes/valuation.d.ts +1 -1
- package/dist/apps/data/routes/verified-tokens.d.ts +36 -36
- package/dist/apps/data/routes/webhooks.d.ts +9 -9
- package/dist/apps/data/routes/zones.d.ts +14 -14
- 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/{data/routes/funding.d.ts → funding/App.d.ts} +1640 -3217
- package/dist/apps/funding/App.d.ts.map +1 -0
- package/dist/apps/funding/App.js +61 -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 +1997 -0
- package/dist/apps/funding/routes/deposit-addresses.d.ts.map +1 -0
- package/dist/apps/funding/routes/deposit-addresses.js +778 -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/funding/routes/quotes.d.ts +426 -0
- 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 +1 -0
- package/dist/apps/index.d.ts.map +1 -1
- package/dist/apps/index.js +1 -0
- package/dist/apps/index.js.map +1 -1
- package/dist/apps/management/App.d.ts +430 -165
- package/dist/apps/management/App.d.ts.map +1 -1
- package/dist/apps/management/routes/api-keys.d.ts +298 -21
- package/dist/apps/management/routes/api-keys.d.ts.map +1 -1
- package/dist/apps/management/routes/api-keys.js +75 -1
- package/dist/apps/management/routes/api-keys.js.map +1 -1
- package/dist/apps/management/routes/billing.d.ts +6 -6
- package/dist/apps/management/routes/faucet.d.ts +35 -35
- package/dist/apps/management/routes/invitations.d.ts +122 -122
- package/dist/apps/management/routes/invite-links.d.ts +38 -38
- package/dist/apps/management/routes/members.d.ts +69 -69
- package/dist/apps/management/routes/orgs.d.ts +99 -99
- package/dist/apps/management/routes/projects.d.ts +25 -25
- package/dist/apps/management/routes/scopes.d.ts +1 -1
- package/dist/apps/management/routes/usage.d.ts +72 -72
- package/dist/apps/management/routes/verified-token-requests.d.ts +77 -77
- package/dist/apps/management/routes/webhooks.d.ts +128 -128
- 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 +44 -44
- 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 +2 -0
- package/dist/db/Db.d.ts.map +1 -1
- package/dist/db/Db.js +45 -0
- package/dist/db/Db.js.map +1 -1
- package/dist/db/Schema.d.ts +12 -0
- package/dist/db/Schema.d.ts.map +1 -1
- package/dist/db/Schema.js +20 -0
- package/dist/db/Schema.js.map +1 -1
- package/dist/db/tables/fundingDepositAddresses.d.ts +13 -0
- package/dist/db/tables/fundingDepositAddresses.d.ts.map +1 -1
- package/dist/db/tables/fundingDepositAddresses.js +12 -0
- package/dist/db/tables/fundingDepositAddresses.js.map +1 -1
- 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 +74 -1
- package/dist/db/tables/fundingDeposits.d.ts.map +1 -1
- package/dist/db/tables/fundingDeposits.js +126 -0
- package/dist/db/tables/fundingDeposits.js.map +1 -1
- package/dist/internal/Auth.d.ts +15 -11
- package/dist/internal/Auth.d.ts.map +1 -1
- package/dist/internal/Auth.js +52 -17
- package/dist/internal/Auth.js.map +1 -1
- package/dist/internal/Cache.js +1 -1
- package/dist/internal/Cache.js.map +1 -1
- package/dist/internal/EdgeCache.d.ts +2 -2
- package/dist/internal/EdgeCache.d.ts.map +1 -1
- package/dist/internal/EdgeCache.js +10 -4
- package/dist/internal/EdgeCache.js.map +1 -1
- 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/OpenApi.d.ts +1 -1
- package/dist/internal/OpenApi.js +1 -1
- package/dist/internal/OpenApi.js.map +1 -1
- package/dist/internal/Tidx.d.ts +6 -0
- package/dist/internal/Tidx.d.ts.map +1 -1
- package/dist/internal/Tidx.js +13 -3
- package/dist/internal/Tidx.js.map +1 -1
- package/dist/internal/Viem.d.ts +8 -0
- package/dist/internal/Viem.d.ts.map +1 -1
- package/dist/internal/Viem.js +12 -5
- package/dist/internal/Viem.js.map +1 -1
- package/dist/internal/funding/Deposit.d.ts +42 -0
- package/dist/internal/funding/Deposit.d.ts.map +1 -1
- package/dist/internal/funding/Deposit.js +37 -5
- package/dist/internal/funding/Deposit.js.map +1 -1
- package/dist/internal/funding/Evidence.d.ts +1 -5
- package/dist/internal/funding/Evidence.d.ts.map +1 -1
- package/dist/internal/funding/Evidence.js +4 -3
- package/dist/internal/funding/Evidence.js.map +1 -1
- package/dist/internal/funding/Provider.d.ts +102 -0
- package/dist/internal/funding/Provider.d.ts.map +1 -1
- package/dist/internal/funding/Provider.js +5 -0
- package/dist/internal/funding/Provider.js.map +1 -1
- package/dist/internal/funding/Reconciliation.d.ts +16 -2
- package/dist/internal/funding/Reconciliation.d.ts.map +1 -1
- package/dist/internal/funding/Reconciliation.js +348 -54
- package/dist/internal/funding/Reconciliation.js.map +1 -1
- 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 +2 -2
- package/dist/internal/funding/Subsidy.d.ts.map +1 -1
- package/dist/internal/funding/Subsidy.js +1 -1
- package/dist/internal/funding/Subsidy.js.map +1 -1
- 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 +43 -1
- package/dist/internal/funding/providers/relay.d.ts.map +1 -1
- package/dist/internal/funding/providers/relay.js +438 -27
- package/dist/internal/funding/providers/relay.js.map +1 -1
- package/package.json +3 -3
- package/src/ApiKey.test.ts +35 -0
- package/src/ApiKey.ts +27 -0
- package/src/ApiKeys.test.ts +29 -0
- package/src/ApiKeys.ts +11 -3
- package/src/App.test.ts +55 -5
- package/src/App.ts +79 -5
- package/src/Client.test-d.ts +203 -28
- package/src/admin/apps/api-keys.test.ts +25 -1
- package/src/admin/apps/api-keys.ts +6 -2
- package/src/admin/ui.generated.ts +67 -67
- package/src/analytics/Analytics.ts +4 -0
- package/src/apps/composition.test.ts +130 -3
- package/src/apps/data/App.test.ts +0 -12
- package/src/apps/data/App.ts +4 -8
- package/src/apps/data/routes/balances.test.ts +42 -0
- package/src/apps/data/routes/balances.ts +218 -85
- package/src/apps/data/routes/earn.test.ts +363 -0
- package/src/apps/data/routes/earn.ts +1141 -3
- package/src/apps/data/routes/indexer.ts +2 -1
- package/src/apps/data/routes/rpc.ts +2 -0
- package/src/apps/data/routes/tokens.test.ts +6 -8
- package/src/apps/funding/Access.ts +26 -0
- package/src/apps/funding/App.test.ts +78 -0
- package/src/apps/funding/App.ts +78 -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 +1649 -0
- package/src/apps/funding/routes/deposit-addresses.ts +932 -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 +1236 -0
- package/src/apps/funding/routes/transfers.ts +704 -0
- package/src/apps/index.ts +1 -0
- package/src/apps/management/routes/api-keys.test.ts +98 -0
- package/src/apps/management/routes/api-keys.ts +96 -1
- 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/internal/Policy.test.ts +7 -1
- package/src/cloudflare.ts +279 -0
- package/src/db/Db.ts +71 -0
- package/src/db/Schema.ts +24 -0
- package/src/db/tables/fundingDepositAddresses.ts +28 -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 +239 -0
- package/src/db/tables/fundingDeposits.ts +214 -1
- package/src/internal/Auth.test.ts +205 -5
- package/src/internal/Auth.ts +63 -19
- package/src/internal/Cache.test.ts +37 -3
- package/src/internal/Cache.ts +1 -1
- package/src/internal/EdgeCache.test.ts +7 -7
- package/src/internal/EdgeCache.ts +13 -4
- package/src/internal/IpAllowlist.test.ts +52 -0
- package/src/internal/IpAllowlist.ts +39 -0
- package/src/internal/Log.test.ts +7 -1
- package/src/internal/OpenApi.ts +1 -1
- package/src/internal/Tidx.test.ts +28 -0
- package/src/internal/Tidx.ts +19 -3
- package/src/internal/Viem.test.ts +28 -0
- package/src/internal/Viem.ts +21 -5
- package/src/internal/funding/Deposit.ts +74 -5
- package/src/internal/funding/Evidence.test.ts +2 -2
- package/src/internal/funding/Evidence.ts +4 -9
- package/src/internal/funding/Provider.ts +115 -0
- package/src/internal/funding/Reconciliation.local.test.ts +7 -0
- package/src/internal/funding/Reconciliation.test.ts +1364 -109
- package/src/internal/funding/Reconciliation.ts +467 -88
- package/src/internal/funding/SourceObservation.test.ts +301 -0
- package/src/internal/funding/SourceObservation.ts +267 -0
- package/src/internal/funding/Subsidy.ts +2 -2
- package/src/internal/funding/index.test.ts +1 -0
- package/src/internal/funding/index.ts +1 -0
- package/src/internal/funding/providers/relay.test.ts +94 -4
- package/src/internal/funding/providers/relay.ts +533 -27
- package/dist/apps/data/routes/funding.d.ts.map +0 -1
- package/dist/apps/data/routes/funding.js +0 -1557
- package/dist/apps/data/routes/funding.js.map +0 -1
- package/src/apps/data/routes/funding.test.ts +0 -2994
- package/src/apps/data/routes/funding.ts +0 -1821
package/dist/apps/mcp.js
CHANGED
|
@@ -4,12 +4,14 @@ import * as z from 'zod/mini';
|
|
|
4
4
|
import * as Auth from '../internal/Auth.js';
|
|
5
5
|
import * as OpenApi from '../internal/OpenApi.js';
|
|
6
6
|
import * as Metadata from './metadata.js';
|
|
7
|
-
/**
|
|
8
|
-
const
|
|
7
|
+
/** Required document tag group whose operations surface as MCP tools. */
|
|
8
|
+
const dataTagGroup = 'Data API';
|
|
9
|
+
/** Optional document tag group added when the funding app is mounted. */
|
|
10
|
+
const fundingTagGroup = 'Funding & Bridge API';
|
|
9
11
|
/** Tags inside the group hidden from MCP: partner-shaped CoinGecko mirrors and the MCP endpoint itself. */
|
|
10
12
|
const excludedTags = ['CoinGecko', 'MCP'];
|
|
11
13
|
/** Usage guidance surfaced to MCP clients on initialize. */
|
|
12
|
-
const instructions = "Tempo MCP provides access to the Tempo API's data
|
|
14
|
+
const instructions = "Tempo MCP provides access to the Tempo API's data and inbound funding domains, plus documentation. Authenticated tools accept a Tempo API key sent as an `Authorization: Bearer` header on the HTTP request. List endpoints paginate via `cursor`/`nextCursor`. `docs_*` tools search the Tempo documentation.";
|
|
13
15
|
/** Zod schemas owned by the MCP endpoint's OpenAPI description. */
|
|
14
16
|
export var schema;
|
|
15
17
|
(function (schema) {
|
|
@@ -45,9 +47,8 @@ export var schema;
|
|
|
45
47
|
})(schema || (schema = {}));
|
|
46
48
|
/**
|
|
47
49
|
* The MCP route group: a stateless streamable-HTTP MCP server at `/mcp` whose
|
|
48
|
-
* tools mirror the API's data domain
|
|
49
|
-
*
|
|
50
|
-
* the other route groups:
|
|
50
|
+
* tools mirror the API's data domain and its optional inbound funding domain,
|
|
51
|
+
* plus the remote Tempo docs tools. Mount alongside the other route groups:
|
|
51
52
|
*
|
|
52
53
|
* ```ts
|
|
53
54
|
* const app = App.create(options)
|
|
@@ -172,20 +173,21 @@ const openapi = {
|
|
|
172
173
|
description: 'A hosted Model Context Protocol server: the data domain and Tempo docs exposed as tools.',
|
|
173
174
|
},
|
|
174
175
|
],
|
|
175
|
-
'x-tagGroups': [{ name:
|
|
176
|
+
'x-tagGroups': [{ name: dataTagGroup, tags: ['MCP'] }],
|
|
176
177
|
};
|
|
177
178
|
/** HTTP methods that carry operations in an OpenAPI path item. */
|
|
178
179
|
const methods = ['delete', 'get', 'head', 'options', 'patch', 'post', 'put', 'trace']; // prettier-ignore
|
|
179
180
|
/**
|
|
180
|
-
* Narrows the document to the data
|
|
181
|
-
*
|
|
182
|
-
* operations never surface as tools.
|
|
181
|
+
* Narrows the document to the data and optional inbound funding domains.
|
|
182
|
+
* Management, relay, and session operations never surface as tools.
|
|
183
183
|
*/
|
|
184
184
|
function scope(document) {
|
|
185
|
-
const
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
185
|
+
const groups = document['x-tagGroups'] ?? [];
|
|
186
|
+
const dataGroup = groups.find((entry) => entry.name === dataTagGroup);
|
|
187
|
+
if (!dataGroup)
|
|
188
|
+
throw new Error(`openapi.json is missing the "${dataTagGroup}" tag group`);
|
|
189
|
+
const fundingGroup = groups.find((entry) => entry.name === fundingTagGroup);
|
|
190
|
+
const tags = new Set([...dataGroup.tags, ...(fundingGroup?.tags ?? [])].filter((tag) => !excludedTags.includes(tag)));
|
|
189
191
|
const paths = {};
|
|
190
192
|
for (const [path, item] of Object.entries(document.paths)) {
|
|
191
193
|
// Keep in-domain operations; non-method keys (parameters, summary) ride along.
|
package/dist/apps/mcp.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mcp.js","sourceRoot":"","sources":["../../src/apps/mcp.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgB,IAAI,EAAE,MAAM,MAAM,CAAA;AACzC,OAAO,EAAE,GAAG,IAAI,SAAS,EAAgB,MAAM,OAAO,CAAA;AACtD,OAAO,KAAK,CAAC,MAAM,UAAU,CAAA;AAG7B,OAAO,KAAK,IAAI,MAAM,qBAAqB,CAAA;AAC3C,OAAO,KAAK,OAAO,MAAM,wBAAwB,CAAA;AACjD,OAAO,KAAK,QAAQ,MAAM,eAAe,CAAA;AAEzC,
|
|
1
|
+
{"version":3,"file":"mcp.js","sourceRoot":"","sources":["../../src/apps/mcp.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgB,IAAI,EAAE,MAAM,MAAM,CAAA;AACzC,OAAO,EAAE,GAAG,IAAI,SAAS,EAAgB,MAAM,OAAO,CAAA;AACtD,OAAO,KAAK,CAAC,MAAM,UAAU,CAAA;AAG7B,OAAO,KAAK,IAAI,MAAM,qBAAqB,CAAA;AAC3C,OAAO,KAAK,OAAO,MAAM,wBAAwB,CAAA;AACjD,OAAO,KAAK,QAAQ,MAAM,eAAe,CAAA;AAEzC,yEAAyE;AACzE,MAAM,YAAY,GAAG,UAAU,CAAA;AAE/B,yEAAyE;AACzE,MAAM,eAAe,GAAG,sBAAsB,CAAA;AAE9C,2GAA2G;AAC3G,MAAM,YAAY,GAAG,CAAC,WAAW,EAAE,KAAK,CAAC,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adata.d.ts
CHANGED
|
@@ -4,4 +4,8 @@ import type * as App from '../App.js';
|
|
|
4
4
|
export declare function attach<const app extends Hono<any, any>>(app: app, metadata: App.create.Metadata): app;
|
|
5
5
|
/** Reads the OpenAPI metadata attached to an app instance, if any. */
|
|
6
6
|
export declare function read(app: Hono<any, any>): App.create.Metadata | undefined;
|
|
7
|
+
/** Marks a group whose routes use the root app's default chain access policy. */
|
|
8
|
+
export declare function defaultChain<const app extends Hono<any, any>>(app: app): app;
|
|
9
|
+
/** Returns whether a group uses the root app's default chain access policy. */
|
|
10
|
+
export declare function usesDefaultChain(app: Hono<any, any>): boolean;
|
|
7
11
|
//# sourceMappingURL=metadata.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"metadata.d.ts","sourceRoot":"","sources":["../../src/apps/metadata.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,MAAM,CAAA;AAEhC,OAAO,KAAK,KAAK,GAAG,MAAM,WAAW,CAAA;
|
|
1
|
+
{"version":3,"file":"metadata.d.ts","sourceRoot":"","sources":["../../src/apps/metadata.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,MAAM,CAAA;AAEhC,OAAO,KAAK,KAAK,GAAG,MAAM,WAAW,CAAA;AASrC,gGAAgG;AAChG,wBAAgB,MAAM,CAAC,KAAK,CAAC,GAAG,SAAS,IAAI,CAAC,GAAG,EAAE,GAAG,CAAC,EACrD,GAAG,EAAE,GAAG,EACR,QAAQ,EAAE,GAAG,CAAC,MAAM,CAAC,QAAQ,GAC5B,GAAG,CAGL;AAED,sEAAsE;AACtE,wBAAgB,IAAI,CAAC,GAAG,EAAE,IAAI,CAAC,GAAG,EAAE,GAAG,CAAC,GAAG,GAAG,CAAC,MAAM,CAAC,QAAQ,GAAG,SAAS,CAEzE;AAED,iFAAiF;AACjF,wBAAgB,YAAY,CAAC,KAAK,CAAC,GAAG,SAAS,IAAI,CAAC,GAAG,EAAE,GAAG,CAAC,EAAE,GAAG,EAAE,GAAG,GAAG,GAAG,CAG5E;AAED,+EAA+E;AAC/E,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,IAAI,CAAC,GAAG,EAAE,GAAG,CAAC,GAAG,OAAO,CAE7D"}
|
package/dist/apps/metadata.js
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
// `App.create` reads it back on mount. The `WeakMap` keeps the association off
|
|
4
4
|
// the app's type, so `testClient`/`hc` inference is untouched.
|
|
5
5
|
const registry = new WeakMap();
|
|
6
|
+
const defaultChainRegistry = new WeakSet();
|
|
6
7
|
/** Attaches a group's OpenAPI metadata to its app instance for `create` to collect on mount. */
|
|
7
8
|
export function attach(app, metadata) {
|
|
8
9
|
registry.set(app, metadata);
|
|
@@ -12,4 +13,13 @@ export function attach(app, metadata) {
|
|
|
12
13
|
export function read(app) {
|
|
13
14
|
return registry.get(app);
|
|
14
15
|
}
|
|
16
|
+
/** Marks a group whose routes use the root app's default chain access policy. */
|
|
17
|
+
export function defaultChain(app) {
|
|
18
|
+
defaultChainRegistry.add(app);
|
|
19
|
+
return app;
|
|
20
|
+
}
|
|
21
|
+
/** Returns whether a group uses the root app's default chain access policy. */
|
|
22
|
+
export function usesDefaultChain(app) {
|
|
23
|
+
return defaultChainRegistry.has(app);
|
|
24
|
+
}
|
|
15
25
|
//# sourceMappingURL=metadata.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"metadata.js","sourceRoot":"","sources":["../../src/apps/metadata.ts"],"names":[],"mappings":"AAIA,gFAAgF;AAChF,0EAA0E;AAC1E,+EAA+E;AAC/E,+DAA+D;AAC/D,MAAM,QAAQ,GAAG,IAAI,OAAO,EAAuC,CAAA;
|
|
1
|
+
{"version":3,"file":"metadata.js","sourceRoot":"","sources":["../../src/apps/metadata.ts"],"names":[],"mappings":"AAIA,gFAAgF;AAChF,0EAA0E;AAC1E,+EAA+E;AAC/E,+DAA+D;AAC/D,MAAM,QAAQ,GAAG,IAAI,OAAO,EAAuC,CAAA;AACnE,MAAM,oBAAoB,GAAG,IAAI,OAAO,EAAkB,CAAA;AAE1D,gGAAgG;AAChG,MAAM,UAAU,MAAM,CACpB,GAAQ,EACR,QAA6B;IAE7B,QAAQ,CAAC,GAAG,CAAC,GAAG,EAAE,QAAQ,CAAC,CAAA;IAC3B,OAAO,GAAG,CAAA;AACZ,CAAC;AAED,sEAAsE;AACtE,MAAM,UAAU,IAAI,CAAC,GAAmB;IACtC,OAAO,QAAQ,CAAC,GAAG,CAAC,GAAG,CAAC,CAAA;AAC1B,CAAC;AAED,iFAAiF;AACjF,MAAM,UAAU,YAAY,CAAmC,GAAQ;IACrE,oBAAoB,CAAC,GAAG,CAAC,GAAG,CAAC,CAAA;IAC7B,OAAO,GAAG,CAAA;AACZ,CAAC;AAED,+EAA+E;AAC/E,MAAM,UAAU,gBAAgB,CAAC,GAAmB;IAClD,OAAO,oBAAoB,CAAC,GAAG,CAAC,GAAG,CAAC,CAAA;AACtC,CAAC"}
|
package/dist/apps/mpp/App.d.ts
CHANGED
|
@@ -7,15 +7,16 @@ export declare function mpp(options: mpp.Options): import("hono/hono-base").Hono
|
|
|
7
7
|
"/v1/mpp/validate": {
|
|
8
8
|
$post: {
|
|
9
9
|
output: {
|
|
10
|
+
success: true;
|
|
11
|
+
} | {
|
|
10
12
|
error: {
|
|
11
|
-
code: "
|
|
12
|
-
|
|
13
|
-
message: string;
|
|
13
|
+
code: "already_used" | "broadcast_failed" | "expired" | "insufficient_funds" | "invalid_payment" | "policy_denied" | "screen_rejected" | "simulation_failed" | "temporarily_unavailable" | "unknown" | "unsupported";
|
|
14
|
+
message?: string | undefined;
|
|
14
15
|
};
|
|
15
|
-
|
|
16
|
+
success: false;
|
|
16
17
|
};
|
|
17
18
|
outputFormat: "json";
|
|
18
|
-
status:
|
|
19
|
+
status: 200;
|
|
19
20
|
input: {
|
|
20
21
|
json: {
|
|
21
22
|
challenge: {
|
|
@@ -35,14 +36,14 @@ export declare function mpp(options: mpp.Options): import("hono/hono-base").Hono
|
|
|
35
36
|
} | {
|
|
36
37
|
output: {
|
|
37
38
|
error: {
|
|
38
|
-
code: "
|
|
39
|
+
code: "api_key_malformed";
|
|
39
40
|
details?: readonly Response.error.Detail[] | undefined;
|
|
40
41
|
message: string;
|
|
41
42
|
};
|
|
42
43
|
requestId: string;
|
|
43
44
|
};
|
|
44
45
|
outputFormat: "json";
|
|
45
|
-
status:
|
|
46
|
+
status: 400;
|
|
46
47
|
input: {
|
|
47
48
|
json: {
|
|
48
49
|
challenge: {
|
|
@@ -62,14 +63,14 @@ export declare function mpp(options: mpp.Options): import("hono/hono-base").Hono
|
|
|
62
63
|
} | {
|
|
63
64
|
output: {
|
|
64
65
|
error: {
|
|
65
|
-
code: "
|
|
66
|
+
code: "body_invalid";
|
|
66
67
|
details?: readonly Response.error.Detail[] | undefined;
|
|
67
68
|
message: string;
|
|
68
69
|
};
|
|
69
70
|
requestId: string;
|
|
70
71
|
};
|
|
71
72
|
outputFormat: "json";
|
|
72
|
-
status:
|
|
73
|
+
status: 400;
|
|
73
74
|
input: {
|
|
74
75
|
json: {
|
|
75
76
|
challenge: {
|
|
@@ -89,14 +90,14 @@ export declare function mpp(options: mpp.Options): import("hono/hono-base").Hono
|
|
|
89
90
|
} | {
|
|
90
91
|
output: {
|
|
91
92
|
error: {
|
|
92
|
-
code: "
|
|
93
|
+
code: "api_key_invalid" | "api_key_missing";
|
|
93
94
|
details?: readonly Response.error.Detail[] | undefined;
|
|
94
95
|
message: string;
|
|
95
96
|
};
|
|
96
97
|
requestId: string;
|
|
97
98
|
};
|
|
98
99
|
outputFormat: "json";
|
|
99
|
-
status:
|
|
100
|
+
status: 401;
|
|
100
101
|
input: {
|
|
101
102
|
json: {
|
|
102
103
|
challenge: {
|
|
@@ -116,14 +117,14 @@ export declare function mpp(options: mpp.Options): import("hono/hono-base").Hono
|
|
|
116
117
|
} | {
|
|
117
118
|
output: {
|
|
118
119
|
error: {
|
|
119
|
-
code: "
|
|
120
|
+
code: "api_key_forbidden" | "api_key_ip_forbidden";
|
|
120
121
|
details?: readonly Response.error.Detail[] | undefined;
|
|
121
122
|
message: string;
|
|
122
123
|
};
|
|
123
124
|
requestId: string;
|
|
124
125
|
};
|
|
125
126
|
outputFormat: "json";
|
|
126
|
-
status:
|
|
127
|
+
status: 403;
|
|
127
128
|
input: {
|
|
128
129
|
json: {
|
|
129
130
|
challenge: {
|
|
@@ -142,16 +143,15 @@ export declare function mpp(options: mpp.Options): import("hono/hono-base").Hono
|
|
|
142
143
|
};
|
|
143
144
|
} | {
|
|
144
145
|
output: {
|
|
145
|
-
success: true;
|
|
146
|
-
} | {
|
|
147
146
|
error: {
|
|
148
|
-
code: "
|
|
149
|
-
|
|
147
|
+
code: "payment_required" | "rate_limit_exceeded";
|
|
148
|
+
details?: readonly Response.error.Detail[] | undefined;
|
|
149
|
+
message: string;
|
|
150
150
|
};
|
|
151
|
-
|
|
151
|
+
requestId: string;
|
|
152
152
|
};
|
|
153
153
|
outputFormat: "json";
|
|
154
|
-
status:
|
|
154
|
+
status: 429;
|
|
155
155
|
input: {
|
|
156
156
|
json: {
|
|
157
157
|
challenge: {
|
|
@@ -174,15 +174,22 @@ export declare function mpp(options: mpp.Options): import("hono/hono-base").Hono
|
|
|
174
174
|
"/v1/mpp/broadcast": {
|
|
175
175
|
$post: {
|
|
176
176
|
output: {
|
|
177
|
+
receipt: {
|
|
178
|
+
externalId?: string | undefined;
|
|
179
|
+
method: string;
|
|
180
|
+
reference: string;
|
|
181
|
+
timestamp: string;
|
|
182
|
+
};
|
|
183
|
+
success: true;
|
|
184
|
+
} | {
|
|
177
185
|
error: {
|
|
178
|
-
code: "
|
|
179
|
-
|
|
180
|
-
message: string;
|
|
186
|
+
code: "already_used" | "broadcast_failed" | "expired" | "insufficient_funds" | "invalid_payment" | "policy_denied" | "screen_rejected" | "simulation_failed" | "temporarily_unavailable" | "unknown" | "unsupported";
|
|
187
|
+
message?: string | undefined;
|
|
181
188
|
};
|
|
182
|
-
|
|
189
|
+
success: false;
|
|
183
190
|
};
|
|
184
191
|
outputFormat: "json";
|
|
185
|
-
status:
|
|
192
|
+
status: 200;
|
|
186
193
|
input: {
|
|
187
194
|
json: {
|
|
188
195
|
challenge: {
|
|
@@ -202,14 +209,14 @@ export declare function mpp(options: mpp.Options): import("hono/hono-base").Hono
|
|
|
202
209
|
} | {
|
|
203
210
|
output: {
|
|
204
211
|
error: {
|
|
205
|
-
code: "
|
|
212
|
+
code: "api_key_malformed";
|
|
206
213
|
details?: readonly Response.error.Detail[] | undefined;
|
|
207
214
|
message: string;
|
|
208
215
|
};
|
|
209
216
|
requestId: string;
|
|
210
217
|
};
|
|
211
218
|
outputFormat: "json";
|
|
212
|
-
status:
|
|
219
|
+
status: 400;
|
|
213
220
|
input: {
|
|
214
221
|
json: {
|
|
215
222
|
challenge: {
|
|
@@ -229,14 +236,14 @@ export declare function mpp(options: mpp.Options): import("hono/hono-base").Hono
|
|
|
229
236
|
} | {
|
|
230
237
|
output: {
|
|
231
238
|
error: {
|
|
232
|
-
code: "
|
|
239
|
+
code: "body_invalid";
|
|
233
240
|
details?: readonly Response.error.Detail[] | undefined;
|
|
234
241
|
message: string;
|
|
235
242
|
};
|
|
236
243
|
requestId: string;
|
|
237
244
|
};
|
|
238
245
|
outputFormat: "json";
|
|
239
|
-
status:
|
|
246
|
+
status: 400;
|
|
240
247
|
input: {
|
|
241
248
|
json: {
|
|
242
249
|
challenge: {
|
|
@@ -256,14 +263,14 @@ export declare function mpp(options: mpp.Options): import("hono/hono-base").Hono
|
|
|
256
263
|
} | {
|
|
257
264
|
output: {
|
|
258
265
|
error: {
|
|
259
|
-
code: "
|
|
266
|
+
code: "api_key_invalid" | "api_key_missing";
|
|
260
267
|
details?: readonly Response.error.Detail[] | undefined;
|
|
261
268
|
message: string;
|
|
262
269
|
};
|
|
263
270
|
requestId: string;
|
|
264
271
|
};
|
|
265
272
|
outputFormat: "json";
|
|
266
|
-
status:
|
|
273
|
+
status: 401;
|
|
267
274
|
input: {
|
|
268
275
|
json: {
|
|
269
276
|
challenge: {
|
|
@@ -283,14 +290,14 @@ export declare function mpp(options: mpp.Options): import("hono/hono-base").Hono
|
|
|
283
290
|
} | {
|
|
284
291
|
output: {
|
|
285
292
|
error: {
|
|
286
|
-
code: "
|
|
293
|
+
code: "api_key_forbidden" | "api_key_ip_forbidden";
|
|
287
294
|
details?: readonly Response.error.Detail[] | undefined;
|
|
288
295
|
message: string;
|
|
289
296
|
};
|
|
290
297
|
requestId: string;
|
|
291
298
|
};
|
|
292
299
|
outputFormat: "json";
|
|
293
|
-
status:
|
|
300
|
+
status: 403;
|
|
294
301
|
input: {
|
|
295
302
|
json: {
|
|
296
303
|
challenge: {
|
|
@@ -309,22 +316,15 @@ export declare function mpp(options: mpp.Options): import("hono/hono-base").Hono
|
|
|
309
316
|
};
|
|
310
317
|
} | {
|
|
311
318
|
output: {
|
|
312
|
-
receipt: {
|
|
313
|
-
externalId?: string | undefined;
|
|
314
|
-
method: string;
|
|
315
|
-
reference: string;
|
|
316
|
-
timestamp: string;
|
|
317
|
-
};
|
|
318
|
-
success: true;
|
|
319
|
-
} | {
|
|
320
319
|
error: {
|
|
321
|
-
code: "
|
|
322
|
-
|
|
320
|
+
code: "payment_required" | "rate_limit_exceeded";
|
|
321
|
+
details?: readonly Response.error.Detail[] | undefined;
|
|
322
|
+
message: string;
|
|
323
323
|
};
|
|
324
|
-
|
|
324
|
+
requestId: string;
|
|
325
325
|
};
|
|
326
326
|
outputFormat: "json";
|
|
327
|
-
status:
|
|
327
|
+
status: 429;
|
|
328
328
|
input: {
|
|
329
329
|
json: {
|
|
330
330
|
challenge: {
|
package/dist/cloudflare.d.ts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import { DurableObject as CloudflareDurableObject } from 'cloudflare:workers';
|
|
2
|
+
import * as Funding from './internal/funding/index.js';
|
|
3
|
+
import * as Metrics from './Metrics.js';
|
|
2
4
|
import * as Store from './internal/Store.js';
|
|
3
5
|
type State = ConstructorParameters<typeof CloudflareDurableObject>[0];
|
|
4
6
|
type Environment = ConstructorParameters<typeof CloudflareDurableObject>[1];
|
|
@@ -37,5 +39,53 @@ export declare class DurableObject extends CloudflareDurableObject {
|
|
|
37
39
|
*/
|
|
38
40
|
swap(key: string, expected: null | string, next: string, options?: Store.Store.PutOptions): Promise<boolean>;
|
|
39
41
|
}
|
|
42
|
+
type FundingSourceConfiguration = {
|
|
43
|
+
chainId: string;
|
|
44
|
+
rpcUrls: readonly string[];
|
|
45
|
+
tokenAddress: string;
|
|
46
|
+
};
|
|
47
|
+
type FundingSourceRoute = Funding.SourceObservation.Route;
|
|
48
|
+
type FundingSourceRegisterOptions = FundingSourceConfiguration & {
|
|
49
|
+
route: FundingSourceRoute;
|
|
50
|
+
};
|
|
51
|
+
type FundingSourceSyncOptions = FundingSourceConfiguration & {
|
|
52
|
+
routes: readonly FundingSourceRoute[];
|
|
53
|
+
};
|
|
54
|
+
/** Cloudflare Durable Object that detects EVM funding deposits before provider indexing. */
|
|
55
|
+
export declare class FundingSourceObserver<environment extends FundingSourceObserver.Environment = FundingSourceObserver.Environment> extends CloudflareDurableObject {
|
|
56
|
+
#private;
|
|
57
|
+
/** Durable Object storage and alarm context. */
|
|
58
|
+
protected context: State;
|
|
59
|
+
/** Cloudflare bindings used by the observer. */
|
|
60
|
+
protected environment: environment;
|
|
61
|
+
constructor(ctx: State, env: environment);
|
|
62
|
+
/** Registers one newly created deposit address and starts source observation. */
|
|
63
|
+
register(options: FundingSourceRegisterOptions): Promise<void>;
|
|
64
|
+
/** Replaces the active routes from the database and repairs alarm scheduling. */
|
|
65
|
+
sync(options: FundingSourceSyncOptions): Promise<void>;
|
|
66
|
+
/** Scans confirmed source blocks and persists newly observed deposits. */
|
|
67
|
+
alarm(): Promise<void>;
|
|
68
|
+
/** Reports one source-observer failure. */
|
|
69
|
+
protected capture(cause: unknown): void;
|
|
70
|
+
/** Creates the operational metric sink used by one alarm invocation. */
|
|
71
|
+
protected createMetrics(): Metrics.Metrics;
|
|
72
|
+
}
|
|
73
|
+
export declare namespace FundingSourceObserver {
|
|
74
|
+
/** Cloudflare bindings and deployment metadata used by the observer. */
|
|
75
|
+
type Environment = {
|
|
76
|
+
/** Deployment environment included in operational metrics. */
|
|
77
|
+
ENVIRONMENT?: string | undefined;
|
|
78
|
+
/** Queue that receives deposit-address reconciliation work. */
|
|
79
|
+
FUNDING_RECONCILIATION_QUEUE: {
|
|
80
|
+
/** Enqueues one chain-detected address for reconciliation. */
|
|
81
|
+
send(message: Funding.Provider.Webhook.receive.Dispatchable): Promise<unknown>;
|
|
82
|
+
};
|
|
83
|
+
/** Authoritative Postgres connection exposed through Hyperdrive. */
|
|
84
|
+
HYPERDRIVE: {
|
|
85
|
+
/** PostgreSQL connection string supplied by the Hyperdrive binding. */
|
|
86
|
+
connectionString: string;
|
|
87
|
+
};
|
|
88
|
+
};
|
|
89
|
+
}
|
|
40
90
|
export {};
|
|
41
91
|
//# sourceMappingURL=cloudflare.d.ts.map
|
package/dist/cloudflare.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cloudflare.d.ts","sourceRoot":"","sources":["../src/cloudflare.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,aAAa,IAAI,uBAAuB,EAAE,MAAM,oBAAoB,CAAA;
|
|
1
|
+
{"version":3,"file":"cloudflare.d.ts","sourceRoot":"","sources":["../src/cloudflare.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,aAAa,IAAI,uBAAuB,EAAE,MAAM,oBAAoB,CAAA;AAG7E,OAAO,KAAK,OAAO,MAAM,6BAA6B,CAAA;AACtD,OAAO,KAAK,OAAO,MAAM,cAAc,CAAA;AACvC,OAAO,KAAK,KAAK,MAAM,qBAAqB,CAAA;AAE5C,KAAK,KAAK,GAAG,qBAAqB,CAAC,OAAO,uBAAuB,CAAC,CAAC,CAAC,CAAC,CAAA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AAE,MAAM,CAAA;SACzB,CAAA;KACF,CAAA;CACF"}
|
package/dist/cloudflare.js
CHANGED
|
@@ -3,6 +3,9 @@
|
|
|
3
3
|
// web types like `Response.json`.
|
|
4
4
|
// @ts-ignore
|
|
5
5
|
import { DurableObject as CloudflareDurableObject } from 'cloudflare:workers';
|
|
6
|
+
import * as Db from './db/Db.js';
|
|
7
|
+
import * as Funding from './internal/funding/index.js';
|
|
8
|
+
import * as Metrics from './Metrics.js';
|
|
6
9
|
import * as Store from './internal/Store.js';
|
|
7
10
|
/** Durable Object class that exposes a Tempo API store over Cloudflare RPC. */
|
|
8
11
|
export class DurableObject extends CloudflareDurableObject {
|
|
@@ -55,4 +58,179 @@ export class DurableObject extends CloudflareDurableObject {
|
|
|
55
58
|
return this.#store.swap(key, expected, next, options);
|
|
56
59
|
}
|
|
57
60
|
}
|
|
61
|
+
const fundingSourceAlarmIntervalMs = 500;
|
|
62
|
+
const fundingSourceRetryIntervalMs = 2_000;
|
|
63
|
+
/** Cloudflare Durable Object that detects EVM funding deposits before provider indexing. */
|
|
64
|
+
export class FundingSourceObserver extends CloudflareDurableObject {
|
|
65
|
+
/** Durable Object storage and alarm context. */
|
|
66
|
+
context;
|
|
67
|
+
/** Cloudflare bindings used by the observer. */
|
|
68
|
+
environment;
|
|
69
|
+
constructor(ctx, env) {
|
|
70
|
+
super(ctx, env);
|
|
71
|
+
this.context = ctx;
|
|
72
|
+
this.environment = env;
|
|
73
|
+
void ctx.blockConcurrencyWhile(async () => {
|
|
74
|
+
ctx.storage.sql.exec('CREATE TABLE IF NOT EXISTS configuration (id INTEGER PRIMARY KEY CHECK (id = 1), value TEXT NOT NULL)');
|
|
75
|
+
ctx.storage.sql.exec('CREATE TABLE IF NOT EXISTS backfills (id TEXT PRIMARY KEY)');
|
|
76
|
+
ctx.storage.sql.exec('CREATE TABLE IF NOT EXISTS routes (id TEXT PRIMARY KEY, address TEXT NOT NULL UNIQUE)');
|
|
77
|
+
ctx.storage.sql.exec('CREATE TABLE IF NOT EXISTS state (key TEXT PRIMARY KEY, value TEXT NOT NULL)');
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
/** Registers one newly created deposit address and starts source observation. */
|
|
81
|
+
async register(options) {
|
|
82
|
+
const configuration = serializeFundingSourceConfiguration(options);
|
|
83
|
+
const route = this.context.storage.sql
|
|
84
|
+
.exec('SELECT id, address FROM routes WHERE id = ?', options.route.id)
|
|
85
|
+
.toArray()[0];
|
|
86
|
+
this.context.storage.transactionSync(() => {
|
|
87
|
+
this.context.storage.sql.exec('INSERT OR REPLACE INTO configuration (id, value) VALUES (1, ?)', configuration);
|
|
88
|
+
this.context.storage.sql.exec('INSERT OR REPLACE INTO routes (id, address) VALUES (?, ?)', options.route.id, options.route.address.toLowerCase());
|
|
89
|
+
if (!route || route.address.toLowerCase() !== options.route.address.toLowerCase())
|
|
90
|
+
this.context.storage.sql.exec('INSERT OR IGNORE INTO backfills (id) VALUES (?)', options.route.id);
|
|
91
|
+
});
|
|
92
|
+
await this.#ensureAlarm();
|
|
93
|
+
}
|
|
94
|
+
/** Replaces the active routes from the database and repairs alarm scheduling. */
|
|
95
|
+
async sync(options) {
|
|
96
|
+
const configuration = serializeFundingSourceConfiguration(options);
|
|
97
|
+
const existing = new Map(this.context.storage.sql
|
|
98
|
+
.exec('SELECT id, address FROM routes ORDER BY id')
|
|
99
|
+
.toArray()
|
|
100
|
+
.map((route) => [route.id, route.address.toLowerCase()]));
|
|
101
|
+
const changed = options.routes.filter((route) => existing.get(route.id) !== route.address.toLowerCase());
|
|
102
|
+
this.context.storage.transactionSync(() => {
|
|
103
|
+
this.context.storage.sql.exec('INSERT OR REPLACE INTO configuration (id, value) VALUES (1, ?)', configuration);
|
|
104
|
+
this.context.storage.sql.exec('DELETE FROM routes');
|
|
105
|
+
for (const route of options.routes)
|
|
106
|
+
this.context.storage.sql.exec('INSERT INTO routes (id, address) VALUES (?, ?)', route.id, route.address.toLowerCase());
|
|
107
|
+
this.context.storage.sql.exec('DELETE FROM backfills WHERE id NOT IN (SELECT id FROM routes)');
|
|
108
|
+
for (const route of changed)
|
|
109
|
+
this.context.storage.sql.exec('INSERT OR IGNORE INTO backfills (id) VALUES (?)', route.id);
|
|
110
|
+
});
|
|
111
|
+
if (options.routes.length === 0) {
|
|
112
|
+
await this.context.storage.deleteAlarm();
|
|
113
|
+
return;
|
|
114
|
+
}
|
|
115
|
+
await this.#ensureAlarm();
|
|
116
|
+
}
|
|
117
|
+
/** Scans confirmed source blocks and persists newly observed deposits. */
|
|
118
|
+
async alarm() {
|
|
119
|
+
const metrics = this.createMetrics();
|
|
120
|
+
const configuration = this.#readConfiguration();
|
|
121
|
+
const routes = this.context.storage.sql
|
|
122
|
+
.exec('SELECT id, address FROM routes ORDER BY id')
|
|
123
|
+
.toArray();
|
|
124
|
+
if (!configuration || routes.length === 0)
|
|
125
|
+
return;
|
|
126
|
+
try {
|
|
127
|
+
const cursor = this.context.storage.sql
|
|
128
|
+
.exec("SELECT value FROM state WHERE key = 'cursor'")
|
|
129
|
+
.toArray()[0];
|
|
130
|
+
const result = await Funding.SourceObservation.scan({
|
|
131
|
+
chainId: configuration.chainId,
|
|
132
|
+
...(cursor ? { cursor: BigInt(cursor.value) } : {}),
|
|
133
|
+
routes,
|
|
134
|
+
rpcUrls: configuration.rpcUrls,
|
|
135
|
+
tokenAddress: configuration.tokenAddress,
|
|
136
|
+
});
|
|
137
|
+
const backfills = this.context.storage.sql
|
|
138
|
+
.exec('SELECT routes.id, routes.address FROM routes INNER JOIN backfills ON backfills.id = routes.id ORDER BY routes.id')
|
|
139
|
+
.toArray();
|
|
140
|
+
// Backfill new routes independently so the main cursor retains any older shard backlog.
|
|
141
|
+
const backfill = await (async () => {
|
|
142
|
+
if (!cursor || backfills.length === 0)
|
|
143
|
+
return undefined;
|
|
144
|
+
return Funding.SourceObservation.scan({
|
|
145
|
+
chainId: configuration.chainId,
|
|
146
|
+
routes: backfills,
|
|
147
|
+
rpcUrls: configuration.rpcUrls,
|
|
148
|
+
tokenAddress: configuration.tokenAddress,
|
|
149
|
+
});
|
|
150
|
+
})();
|
|
151
|
+
const database = Db.get(() => Db.postgres({ connectionString: this.environment.HYPERDRIVE.connectionString }));
|
|
152
|
+
const routesById = new Map(routes.map((route) => [route.id, route]));
|
|
153
|
+
const observations = new Map([...result.observations, ...(backfill?.observations ?? [])].map((observation) => [
|
|
154
|
+
`${observation.addressId}:${observation.transactionHash.toLowerCase()}:${observation.transferIndex}`,
|
|
155
|
+
observation,
|
|
156
|
+
])).values();
|
|
157
|
+
for (const observation of observations) {
|
|
158
|
+
const route = routesById.get(observation.addressId);
|
|
159
|
+
if (!route)
|
|
160
|
+
continue;
|
|
161
|
+
const persisted = await Funding.SourceObservation.observe(database, {
|
|
162
|
+
...observation,
|
|
163
|
+
recipient: route.address,
|
|
164
|
+
});
|
|
165
|
+
if (persisted.type === 'ignored' ||
|
|
166
|
+
persisted.record.providerRequestId !== null ||
|
|
167
|
+
Funding.Deposit.isTerminal(persisted.record.status))
|
|
168
|
+
continue;
|
|
169
|
+
await this.environment.FUNDING_RECONCILIATION_QUEUE.send({
|
|
170
|
+
addressId: observation.addressId,
|
|
171
|
+
trigger: 'chain',
|
|
172
|
+
type: 'funding:deposit-address:reconcile',
|
|
173
|
+
});
|
|
174
|
+
metrics.count('funding_source_observer_deposit_count', 1, {
|
|
175
|
+
chain: configuration.chainId,
|
|
176
|
+
outcome: persisted.type,
|
|
177
|
+
});
|
|
178
|
+
}
|
|
179
|
+
this.context.storage.transactionSync(() => {
|
|
180
|
+
this.context.storage.sql.exec("INSERT OR REPLACE INTO state (key, value) VALUES ('cursor', ?)", result.cursor.toString());
|
|
181
|
+
for (const route of backfills)
|
|
182
|
+
this.context.storage.sql.exec('DELETE FROM backfills WHERE id = ?', route.id);
|
|
183
|
+
});
|
|
184
|
+
metrics.count('funding_source_observer_scan_count', 1, {
|
|
185
|
+
chain: configuration.chainId,
|
|
186
|
+
outcome: 'completed',
|
|
187
|
+
});
|
|
188
|
+
metrics.gauge('funding_source_observer_block_lag', Math.max(0, Number(result.head - result.cursor)), { chain: configuration.chainId });
|
|
189
|
+
await this.context.storage.setAlarm(result.cursor < result.head ? Date.now() : Date.now() + fundingSourceAlarmIntervalMs);
|
|
190
|
+
}
|
|
191
|
+
catch (cause) {
|
|
192
|
+
metrics.count('funding_source_observer_scan_count', 1, {
|
|
193
|
+
chain: configuration.chainId,
|
|
194
|
+
outcome: 'failed',
|
|
195
|
+
});
|
|
196
|
+
this.capture(cause);
|
|
197
|
+
await this.context.storage.setAlarm(Date.now() + fundingSourceRetryIntervalMs);
|
|
198
|
+
}
|
|
199
|
+
finally {
|
|
200
|
+
metrics.flush();
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
/** Reports one source-observer failure. */
|
|
204
|
+
capture(cause) {
|
|
205
|
+
console.error(cause);
|
|
206
|
+
}
|
|
207
|
+
/** Creates the operational metric sink used by one alarm invocation. */
|
|
208
|
+
createMetrics() {
|
|
209
|
+
return Metrics.cloudflare({
|
|
210
|
+
enabled: Boolean(this.environment.ENVIRONMENT),
|
|
211
|
+
environment: this.environment.ENVIRONMENT ?? 'development',
|
|
212
|
+
service: 'tapimo',
|
|
213
|
+
});
|
|
214
|
+
}
|
|
215
|
+
#configuration() {
|
|
216
|
+
return this.context.storage.sql
|
|
217
|
+
.exec('SELECT value FROM configuration WHERE id = 1')
|
|
218
|
+
.toArray()[0]?.value;
|
|
219
|
+
}
|
|
220
|
+
async #ensureAlarm() {
|
|
221
|
+
if ((await this.context.storage.getAlarm()) === null)
|
|
222
|
+
await this.context.storage.setAlarm(Date.now());
|
|
223
|
+
}
|
|
224
|
+
#readConfiguration() {
|
|
225
|
+
const value = this.#configuration();
|
|
226
|
+
return value ? JSON.parse(value) : undefined;
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
function serializeFundingSourceConfiguration(options) {
|
|
230
|
+
return JSON.stringify({
|
|
231
|
+
chainId: options.chainId,
|
|
232
|
+
rpcUrls: options.rpcUrls,
|
|
233
|
+
tokenAddress: options.tokenAddress.toLowerCase(),
|
|
234
|
+
});
|
|
235
|
+
}
|
|
58
236
|
//# sourceMappingURL=cloudflare.js.map
|