@secondlayer/subgraphs 7.2.0 → 7.3.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/index.d.ts +10 -2
- package/dist/index.js +195 -127
- package/dist/index.js.map +5 -5
- package/dist/runtime/replay.js +30 -12
- package/dist/runtime/replay.js.map +4 -4
- package/dist/schema/index.js +3 -3
- package/dist/schema/index.js.map +1 -1
- package/dist/testing/index.js +1691 -1627
- package/dist/testing/index.js.map +7 -7
- package/dist/verification.js +3 -3
- package/dist/verification.js.map +1 -1
- package/dist/verify/index.js +101 -39
- package/dist/verify/index.js.map +5 -5
- package/package.json +2 -2
package/dist/runtime/replay.js
CHANGED
|
@@ -17,7 +17,7 @@ import { createHash } from "node:crypto";
|
|
|
17
17
|
// package.json
|
|
18
18
|
var package_default = {
|
|
19
19
|
name: "@secondlayer/subgraphs",
|
|
20
|
-
version: "7.
|
|
20
|
+
version: "7.3.0",
|
|
21
21
|
description: "Describe the Stacks data you want as one TypeScript file; it fills itself and survives reorgs.",
|
|
22
22
|
license: "MIT",
|
|
23
23
|
repository: {
|
|
@@ -77,7 +77,7 @@ var package_default = {
|
|
|
77
77
|
prepublishOnly: "bun run build"
|
|
78
78
|
},
|
|
79
79
|
dependencies: {
|
|
80
|
-
"@secondlayer/shared": "^13.
|
|
80
|
+
"@secondlayer/shared": "^13.2.0",
|
|
81
81
|
"@secondlayer/stacks": "^6.4.0",
|
|
82
82
|
"@secondlayer/verify": "^0.6.0",
|
|
83
83
|
esbuild: "^0.28.2",
|
|
@@ -1166,6 +1166,8 @@ function databaseChainDataReader(db) {
|
|
|
1166
1166
|
};
|
|
1167
1167
|
}
|
|
1168
1168
|
var THROUGH_TIP = Number.MAX_SAFE_INTEGER;
|
|
1169
|
+
var TRAIT_REFRESH_MS = 5000;
|
|
1170
|
+
var TRAIT_OVERLAP_MS = 5 * 60000;
|
|
1169
1171
|
var traitCaches = new WeakMap;
|
|
1170
1172
|
function traitCacheFor(client) {
|
|
1171
1173
|
let cache = traitCaches.get(client);
|
|
@@ -1200,7 +1202,8 @@ function oneWithdrawalPerSweep(rows) {
|
|
|
1200
1202
|
}
|
|
1201
1203
|
return [...bySweep.values()];
|
|
1202
1204
|
}
|
|
1203
|
-
function hostedChainDataReader(client) {
|
|
1205
|
+
function hostedChainDataReader(client, opts = {}) {
|
|
1206
|
+
const now = opts.now ?? Date.now;
|
|
1204
1207
|
return {
|
|
1205
1208
|
async sbtcEvents(fromHeight, toHeight, topics) {
|
|
1206
1209
|
if (topics.length === 0)
|
|
@@ -1211,19 +1214,34 @@ function hostedChainDataReader(client) {
|
|
|
1211
1214
|
async traitContractIds(trait, asOfBlock) {
|
|
1212
1215
|
const cache = traitCacheFor(client);
|
|
1213
1216
|
let entry = cache.get(trait);
|
|
1214
|
-
|
|
1215
|
-
|
|
1216
|
-
const
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
|
|
1217
|
+
const due = !entry || asOfBlock > entry.checkedThrough && now() - entry.fetchedAt >= TRAIT_REFRESH_MS;
|
|
1218
|
+
if (due) {
|
|
1219
|
+
const since = entry?.classifiedThrough == null ? undefined : new Date(entry.classifiedThrough - TRAIT_OVERLAP_MS);
|
|
1220
|
+
const rows = await client.listContractsByTrait(trait, since ? { classifiedAfter: since } : undefined);
|
|
1221
|
+
const members = entry?.members ?? new Map;
|
|
1222
|
+
let classifiedThrough = entry?.classifiedThrough ?? null;
|
|
1223
|
+
for (const r of rows) {
|
|
1224
|
+
members.set(r.contract_id, Number(r.block_height));
|
|
1225
|
+
if (r.classified_at) {
|
|
1226
|
+
classifiedThrough = Math.max(classifiedThrough ?? 0, new Date(r.classified_at).getTime());
|
|
1227
|
+
}
|
|
1228
|
+
}
|
|
1220
1229
|
entry = {
|
|
1221
1230
|
members,
|
|
1222
|
-
|
|
1231
|
+
classifiedThrough,
|
|
1232
|
+
checkedThrough: asOfBlock,
|
|
1233
|
+
fetchedAt: now()
|
|
1223
1234
|
};
|
|
1224
1235
|
cache.set(trait, entry);
|
|
1225
1236
|
}
|
|
1226
|
-
|
|
1237
|
+
if (!entry)
|
|
1238
|
+
return [];
|
|
1239
|
+
const ids = [];
|
|
1240
|
+
for (const [contractId, height] of entry.members) {
|
|
1241
|
+
if (height <= asOfBlock)
|
|
1242
|
+
ids.push(contractId);
|
|
1243
|
+
}
|
|
1244
|
+
return ids;
|
|
1227
1245
|
},
|
|
1228
1246
|
async settlementsConfirmedAfter(after) {
|
|
1229
1247
|
const withdrawals = oneWithdrawalPerSweep(await client.fetchSettledWithdrawals(after));
|
|
@@ -2085,5 +2103,5 @@ export {
|
|
|
2085
2103
|
replayWebhook
|
|
2086
2104
|
};
|
|
2087
2105
|
|
|
2088
|
-
//# debugId=
|
|
2106
|
+
//# debugId=E8EBA7C326C2348864756E2164756E21
|
|
2089
2107
|
//# sourceMappingURL=replay.js.map
|