@secondlayer/shared 7.11.2 → 9.0.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.
Files changed (60) hide show
  1. package/dist/src/archive/range-digest.d.ts +16 -169
  2. package/dist/src/archive/semantic-digest-builder.d.ts +16 -169
  3. package/dist/src/archive/status.js +11 -3
  4. package/dist/src/archive/status.js.map +3 -3
  5. package/dist/src/coverage/index.d.ts +15 -169
  6. package/dist/src/crypto/secrets.js +22 -3
  7. package/dist/src/crypto/secrets.js.map +3 -3
  8. package/dist/src/db/index.d.ts +18 -211
  9. package/dist/src/db/index.js +23 -16
  10. package/dist/src/db/index.js.map +4 -4
  11. package/dist/src/db/queries/chain-reorgs.d.ts +16 -169
  12. package/dist/src/db/queries/chain-reorgs.js +23 -16
  13. package/dist/src/db/queries/chain-reorgs.js.map +4 -4
  14. package/dist/src/db/queries/contracts.d.ts +16 -169
  15. package/dist/src/db/queries/instance.d.ts +16 -169
  16. package/dist/src/db/queries/integrity.d.ts +16 -169
  17. package/dist/src/db/queries/subgraph-gaps.d.ts +16 -169
  18. package/dist/src/db/queries/subgraph-operations.d.ts +17 -170
  19. package/dist/src/db/queries/subgraph-operations.js +1 -15
  20. package/dist/src/db/queries/subgraph-operations.js.map +3 -3
  21. package/dist/src/db/queries/subgraphs.d.ts +17 -191
  22. package/dist/src/db/queries/subgraphs.js +30 -1068
  23. package/dist/src/db/queries/subgraphs.js.map +5 -12
  24. package/dist/src/db/queries/subscriptions.d.ts +16 -169
  25. package/dist/src/db/queries/subscriptions.js +22 -3
  26. package/dist/src/db/queries/subscriptions.js.map +3 -3
  27. package/dist/src/db/queries/sync-scope.d.ts +1006 -0
  28. package/dist/src/db/queries/sync-scope.js +116 -0
  29. package/dist/src/db/queries/sync-scope.js.map +10 -0
  30. package/dist/src/db/schema.d.ts +17 -198
  31. package/dist/src/errors.d.ts +1 -22
  32. package/dist/src/errors.js +2 -4
  33. package/dist/src/errors.js.map +3 -3
  34. package/dist/src/index.d.ts +22 -256
  35. package/dist/src/index.js +24 -20
  36. package/dist/src/index.js.map +6 -6
  37. package/dist/src/mode.d.ts +16 -2
  38. package/dist/src/mode.js +25 -4
  39. package/dist/src/mode.js.map +3 -3
  40. package/dist/src/node/local-client.d.ts +16 -169
  41. package/dist/src/runtime/index.d.ts +137 -18
  42. package/dist/src/runtime/index.js +261 -41
  43. package/dist/src/runtime/index.js.map +9 -7
  44. package/dist/src/schemas/index.d.ts +5 -25
  45. package/dist/src/schemas/index.js +1 -2
  46. package/dist/src/schemas/index.js.map +3 -3
  47. package/dist/src/schemas/subgraphs.d.ts +5 -25
  48. package/dist/src/schemas/subgraphs.js +1 -2
  49. package/dist/src/schemas/subgraphs.js.map +3 -3
  50. package/dist/src/streams-rows/index.d.ts +399 -0
  51. package/dist/src/streams-rows/index.js +336 -0
  52. package/dist/src/streams-rows/index.js.map +17 -0
  53. package/dist/src/subgraphs/spec.d.ts +0 -9
  54. package/migrations/0118_drop_retired_control_tables.ts +53 -0
  55. package/migrations/0119_drop_accounts_plan.ts +29 -0
  56. package/migrations/0120_sync_scopes.ts +42 -0
  57. package/package.json +10 -6
  58. package/dist/src/x402.d.ts +0 -47
  59. package/dist/src/x402.js +0 -79
  60. package/dist/src/x402.js.map +0 -10
package/dist/src/x402.js DELETED
@@ -1,79 +0,0 @@
1
- import { createRequire } from "node:module";
2
- var __defProp = Object.defineProperty;
3
- var __returnValue = (v) => v;
4
- function __exportSetter(name, newValue) {
5
- this[name] = __returnValue.bind(null, newValue);
6
- }
7
- var __export = (target, all) => {
8
- for (var name in all)
9
- __defProp(target, name, {
10
- get: all[name],
11
- enumerable: true,
12
- configurable: true,
13
- set: __exportSetter.bind(all, name)
14
- });
15
- };
16
-
17
- // src/x402.ts
18
- var X402_NETWORK = {
19
- mainnet: "stacks:1",
20
- testnet: "stacks:2147483648"
21
- };
22
- var X402_TOKENS = {
23
- STX: {
24
- symbol: "STX",
25
- asset: "STX",
26
- contractId: null,
27
- assetName: null,
28
- assetIdentifier: null,
29
- decimals: 6
30
- },
31
- sBTC: {
32
- symbol: "sBTC",
33
- asset: "SM3VDXK3WZZSA84XXFKAFAF15NNZX32CTSG82JFQ4.sbtc-token",
34
- contractId: "SM3VDXK3WZZSA84XXFKAFAF15NNZX32CTSG82JFQ4.sbtc-token",
35
- assetName: "sbtc-token",
36
- assetIdentifier: "SM3VDXK3WZZSA84XXFKAFAF15NNZX32CTSG82JFQ4.sbtc-token::sbtc-token",
37
- decimals: 8
38
- },
39
- USDCx: {
40
- symbol: "USDCx",
41
- asset: "SP120SBRBQJ00MCWS7TM5R8WJNTTKD5K0HFRC2CNE.usdcx",
42
- contractId: "SP120SBRBQJ00MCWS7TM5R8WJNTTKD5K0HFRC2CNE.usdcx",
43
- assetName: "usdcx-token",
44
- assetIdentifier: "SP120SBRBQJ00MCWS7TM5R8WJNTTKD5K0HFRC2CNE.usdcx::usdcx-token",
45
- decimals: 6
46
- }
47
- };
48
- var X402_TOKEN_SYMBOLS = Object.keys(X402_TOKENS);
49
- function getX402Token(symbol) {
50
- return X402_TOKENS[symbol];
51
- }
52
- var X402_STRIKE_TTL_SECONDS = 24 * 60 * 60;
53
- function x402StrikeKey(principal) {
54
- return `x402:strikes:${principal}`;
55
- }
56
- function toIndexTxId(txid) {
57
- const hex = txid.startsWith("0x") ? txid.slice(2) : txid;
58
- return `0x${hex.toLowerCase()}`;
59
- }
60
- function findX402TokenByAsset(asset) {
61
- for (const symbol of X402_TOKEN_SYMBOLS) {
62
- if (X402_TOKENS[symbol].asset === asset)
63
- return X402_TOKENS[symbol];
64
- }
65
- return;
66
- }
67
- export {
68
- x402StrikeKey,
69
- toIndexTxId,
70
- getX402Token,
71
- findX402TokenByAsset,
72
- X402_TOKEN_SYMBOLS,
73
- X402_TOKENS,
74
- X402_STRIKE_TTL_SECONDS,
75
- X402_NETWORK
76
- };
77
-
78
- //# debugId=AA279D8400B972DA64756E2164756E21
79
- //# sourceMappingURL=x402.js.map
@@ -1,10 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../src/x402.ts"],
4
- "sourcesContent": [
5
- "/**\n * x402 payment-rail shared constants: the v1 token set + CAIP-2 network ids.\n *\n * Single-sourced here (not in the API package) so the SDK/MCP client and the\n * API facilitator agree on asset ids, decimals, and the `accepts[]` asset-string\n * format. All ids are mainnet and confirmed on-chain (2026-06). Per-call prices\n * are NOT here — they are API-local (see `packages/api/src/x402/catalog.ts`) and\n * exposed to clients at runtime via `GET /x402/supported`.\n */\n\n/** CAIP-2 network ids used in x402 v2 `accepts[]` entries. */\nexport const X402_NETWORK = {\n\tmainnet: \"stacks:1\",\n\ttestnet: \"stacks:2147483648\",\n} as const;\n\nexport type X402Network = (typeof X402_NETWORK)[keyof typeof X402_NETWORK];\n\nexport type X402TokenSymbol = \"STX\" | \"sBTC\" | \"USDCx\";\n\nexport type X402Token = {\n\tsymbol: X402TokenSymbol;\n\t/** x402 `asset` string: `\"STX\"` for native, else the `<addr>.<contract>` id. */\n\tasset: string;\n\t/** SIP-010 contract id (`<addr>.<contract>`); `null` for native STX. */\n\tcontractId: string | null;\n\t/** SIP-010 fungible-token asset name (the `::<name>` suffix); `null` for STX. */\n\tassetName: string | null;\n\t/** Fully-qualified SIP-010 asset identifier (`<id>::<name>`); `null` for STX. */\n\tassetIdentifier: string | null;\n\tdecimals: number;\n};\n\n/** v1 token set. sBTC + USDCx ids verified against the deployed mainnet contracts. */\nexport const X402_TOKENS: Record<X402TokenSymbol, X402Token> = {\n\tSTX: {\n\t\tsymbol: \"STX\",\n\t\tasset: \"STX\",\n\t\tcontractId: null,\n\t\tassetName: null,\n\t\tassetIdentifier: null,\n\t\tdecimals: 6,\n\t},\n\tsBTC: {\n\t\tsymbol: \"sBTC\",\n\t\tasset: \"SM3VDXK3WZZSA84XXFKAFAF15NNZX32CTSG82JFQ4.sbtc-token\",\n\t\tcontractId: \"SM3VDXK3WZZSA84XXFKAFAF15NNZX32CTSG82JFQ4.sbtc-token\",\n\t\tassetName: \"sbtc-token\",\n\t\tassetIdentifier:\n\t\t\t\"SM3VDXK3WZZSA84XXFKAFAF15NNZX32CTSG82JFQ4.sbtc-token::sbtc-token\",\n\t\tdecimals: 8,\n\t},\n\tUSDCx: {\n\t\tsymbol: \"USDCx\",\n\t\tasset: \"SP120SBRBQJ00MCWS7TM5R8WJNTTKD5K0HFRC2CNE.usdcx\",\n\t\tcontractId: \"SP120SBRBQJ00MCWS7TM5R8WJNTTKD5K0HFRC2CNE.usdcx\",\n\t\tassetName: \"usdcx-token\",\n\t\tassetIdentifier:\n\t\t\t\"SP120SBRBQJ00MCWS7TM5R8WJNTTKD5K0HFRC2CNE.usdcx::usdcx-token\",\n\t\tdecimals: 6,\n\t},\n} as const;\n\nexport const X402_TOKEN_SYMBOLS = Object.keys(X402_TOKENS) as X402TokenSymbol[];\n\nexport function getX402Token(symbol: X402TokenSymbol): X402Token {\n\treturn X402_TOKENS[symbol];\n}\n\n/**\n * Optimistic-serve reputation: the Redis key + TTL for a payer principal's\n * \"strike\" counter (reverted/dropped payments). Single-sourced so the API gate\n * (reader) and the worker reconciler (writer, on revert) agree without a\n * cross-package import.\n */\nexport const X402_STRIKE_TTL_SECONDS: number = 24 * 60 * 60;\n\nexport function x402StrikeKey(principal: string): string {\n\treturn `x402:strikes:${principal}`;\n}\n\n/**\n * Normalize an x402 payment txid to the form stored in `decoded_events`.\n * Broadcast/ledger txids are bare lowercase hex; the index stores them\n * `0x`-prefixed. Querying `decoded_events` with the bare form silently never\n * matches — which wedged the rail's confirmation layer (optimistic payments\n * reverted + struck the payer; confirmed-tier never confirmed). Idempotent and\n * case-normalizing, so it's safe to apply at every index query site.\n */\nexport function toIndexTxId(txid: string): string {\n\tconst hex = txid.startsWith(\"0x\") ? txid.slice(2) : txid;\n\treturn `0x${hex.toLowerCase()}`;\n}\n\n/** Resolve a token by its x402 `asset` string (the value carried in `accepts[].asset`). */\nexport function findX402TokenByAsset(asset: string): X402Token | undefined {\n\tfor (const symbol of X402_TOKEN_SYMBOLS) {\n\t\tif (X402_TOKENS[symbol].asset === asset) return X402_TOKENS[symbol];\n\t}\n\treturn undefined;\n}\n"
6
- ],
7
- "mappings": ";;;;;;;;;;;;;;;;;AAWO,IAAM,eAAe;AAAA,EAC3B,SAAS;AAAA,EACT,SAAS;AACV;AAoBO,IAAM,cAAkD;AAAA,EAC9D,KAAK;AAAA,IACJ,QAAQ;AAAA,IACR,OAAO;AAAA,IACP,YAAY;AAAA,IACZ,WAAW;AAAA,IACX,iBAAiB;AAAA,IACjB,UAAU;AAAA,EACX;AAAA,EACA,MAAM;AAAA,IACL,QAAQ;AAAA,IACR,OAAO;AAAA,IACP,YAAY;AAAA,IACZ,WAAW;AAAA,IACX,iBACC;AAAA,IACD,UAAU;AAAA,EACX;AAAA,EACA,OAAO;AAAA,IACN,QAAQ;AAAA,IACR,OAAO;AAAA,IACP,YAAY;AAAA,IACZ,WAAW;AAAA,IACX,iBACC;AAAA,IACD,UAAU;AAAA,EACX;AACD;AAEO,IAAM,qBAAqB,OAAO,KAAK,WAAW;AAElD,SAAS,YAAY,CAAC,QAAoC;AAAA,EAChE,OAAO,YAAY;AAAA;AASb,IAAM,0BAAkC,KAAK,KAAK;AAElD,SAAS,aAAa,CAAC,WAA2B;AAAA,EACxD,OAAO,gBAAgB;AAAA;AAWjB,SAAS,WAAW,CAAC,MAAsB;AAAA,EACjD,MAAM,MAAM,KAAK,WAAW,IAAI,IAAI,KAAK,MAAM,CAAC,IAAI;AAAA,EACpD,OAAO,KAAK,IAAI,YAAY;AAAA;AAItB,SAAS,oBAAoB,CAAC,OAAsC;AAAA,EAC1E,WAAW,UAAU,oBAAoB;AAAA,IACxC,IAAI,YAAY,QAAQ,UAAU;AAAA,MAAO,OAAO,YAAY;AAAA,EAC7D;AAAA,EACA;AAAA;",
8
- "debugId": "AA279D8400B972DA64756E2164756E21",
9
- "names": []
10
- }