@gzeoneth/gov-tracker 0.1.2 → 0.2.0-1
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 +3 -0
- package/dist/abis.d.ts +0 -32
- package/dist/abis.d.ts.map +1 -1
- package/dist/abis.js +17 -17
- package/dist/abis.js.map +1 -1
- package/dist/calldata/decoder.d.ts +12 -3
- package/dist/calldata/decoder.d.ts.map +1 -1
- package/dist/calldata/decoder.js +56 -9
- package/dist/calldata/decoder.js.map +1 -1
- package/dist/calldata/index.d.ts +4 -7
- package/dist/calldata/index.d.ts.map +1 -1
- package/dist/calldata/index.js +5 -19
- package/dist/calldata/index.js.map +1 -1
- package/dist/calldata/parameter-decoder.d.ts +11 -2
- package/dist/calldata/parameter-decoder.d.ts.map +1 -1
- package/dist/calldata/parameter-decoder.js +67 -8
- package/dist/calldata/parameter-decoder.js.map +1 -1
- package/dist/calldata/retryable-ticket.d.ts +1 -17
- package/dist/calldata/retryable-ticket.d.ts.map +1 -1
- package/dist/calldata/retryable-ticket.js +10 -17
- package/dist/calldata/retryable-ticket.js.map +1 -1
- package/dist/calldata/signature-lookup.d.ts +0 -11
- package/dist/calldata/signature-lookup.d.ts.map +1 -1
- package/dist/calldata/signature-lookup.js +0 -8
- package/dist/calldata/signature-lookup.js.map +1 -1
- package/dist/cli/lib/cli.d.ts +1 -3
- package/dist/cli/lib/cli.d.ts.map +1 -1
- package/dist/cli/lib/cli.js +12 -27
- package/dist/cli/lib/cli.js.map +1 -1
- package/dist/cli/lib/election-check.d.ts +2 -2
- package/dist/cli/lib/election-check.d.ts.map +1 -1
- package/dist/cli/lib/election-check.js.map +1 -1
- package/dist/cli/lib/json-state.d.ts +2 -29
- package/dist/cli/lib/json-state.d.ts.map +1 -1
- package/dist/cli/lib/json-state.js +12 -56
- package/dist/cli/lib/json-state.js.map +1 -1
- package/dist/cli/monitor.js +1 -2
- package/dist/cli/monitor.js.map +1 -1
- package/dist/constants.d.ts +41 -7
- package/dist/constants.d.ts.map +1 -1
- package/dist/constants.js +64 -4
- package/dist/constants.js.map +1 -1
- package/dist/discovery/timelock-discovery.js +1 -1
- package/dist/discovery/timelock-discovery.js.map +1 -1
- package/dist/election.d.ts.map +1 -1
- package/dist/election.js +7 -4
- package/dist/election.js.map +1 -1
- package/dist/index.d.ts +10 -8
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +35 -26
- package/dist/index.js.map +1 -1
- package/dist/simulation/index.d.ts +3 -4
- package/dist/simulation/index.d.ts.map +1 -1
- package/dist/simulation/index.js +3 -9
- package/dist/simulation/index.js.map +1 -1
- package/dist/simulation/simulation-data.d.ts +6 -31
- package/dist/simulation/simulation-data.d.ts.map +1 -1
- package/dist/simulation/simulation-data.js +25 -58
- package/dist/simulation/simulation-data.js.map +1 -1
- package/dist/stages/{stage-builder.d.ts → builder.d.ts} +14 -9
- package/dist/stages/builder.d.ts.map +1 -0
- package/dist/stages/{stage-builder.js → builder.js} +19 -5
- package/dist/stages/builder.js.map +1 -0
- package/dist/stages/l2-to-l1-message.d.ts +3 -3
- package/dist/stages/l2-to-l1-message.d.ts.map +1 -1
- package/dist/stages/l2-to-l1-message.js +17 -17
- package/dist/stages/l2-to-l1-message.js.map +1 -1
- package/dist/stages/proposal-created.d.ts +2 -2
- package/dist/stages/proposal-created.d.ts.map +1 -1
- package/dist/stages/proposal-created.js +5 -5
- package/dist/stages/proposal-created.js.map +1 -1
- package/dist/stages/proposal-queued.d.ts +2 -2
- package/dist/stages/proposal-queued.d.ts.map +1 -1
- package/dist/stages/proposal-queued.js +11 -11
- package/dist/stages/proposal-queued.js.map +1 -1
- package/dist/stages/retryables.d.ts +7 -7
- package/dist/stages/retryables.d.ts.map +1 -1
- package/dist/stages/retryables.js +75 -61
- package/dist/stages/retryables.js.map +1 -1
- package/dist/stages/timelock.d.ts +3 -24
- package/dist/stages/timelock.d.ts.map +1 -1
- package/dist/stages/timelock.js +47 -39
- package/dist/stages/timelock.js.map +1 -1
- package/dist/stages/{base.d.ts → utils.d.ts} +78 -35
- package/dist/stages/utils.d.ts.map +1 -0
- package/dist/stages/{base.js → utils.js} +211 -63
- package/dist/stages/utils.js.map +1 -0
- package/dist/stages/voting.d.ts +2 -2
- package/dist/stages/voting.d.ts.map +1 -1
- package/dist/stages/voting.js +2 -2
- package/dist/stages/voting.js.map +1 -1
- package/dist/tracker/cache.d.ts +104 -0
- package/dist/tracker/cache.d.ts.map +1 -0
- package/dist/tracker/cache.js +287 -0
- package/dist/tracker/cache.js.map +1 -0
- package/dist/tracker/execute.js +9 -9
- package/dist/tracker/execute.js.map +1 -1
- package/dist/tracker/pipeline.d.ts +3 -32
- package/dist/tracker/pipeline.d.ts.map +1 -1
- package/dist/tracker/pipeline.js +40 -43
- package/dist/tracker/pipeline.js.map +1 -1
- package/dist/tracker/query.js +4 -4
- package/dist/tracker/query.js.map +1 -1
- package/dist/tracker/state.d.ts +88 -81
- package/dist/tracker/state.d.ts.map +1 -1
- package/dist/tracker/state.js +241 -264
- package/dist/tracker/state.js.map +1 -1
- package/dist/tracker.d.ts +4 -4
- package/dist/tracker.d.ts.map +1 -1
- package/dist/tracker.js +24 -22
- package/dist/tracker.js.map +1 -1
- package/dist/types/calldata.d.ts +4 -6
- package/dist/types/calldata.d.ts.map +1 -1
- package/dist/types/core.d.ts +36 -34
- package/dist/types/core.d.ts.map +1 -1
- package/dist/types/core.js +33 -0
- package/dist/types/core.js.map +1 -1
- package/dist/types/cross-chain.d.ts +5 -61
- package/dist/types/cross-chain.d.ts.map +1 -1
- package/dist/types/election.d.ts +3 -6
- package/dist/types/election.d.ts.map +1 -1
- package/dist/types/index.d.ts +7 -7
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/index.js +6 -2
- package/dist/types/index.js.map +1 -1
- package/dist/types/simulation.d.ts +5 -7
- package/dist/types/simulation.d.ts.map +1 -1
- package/dist/types/stages.d.ts +50 -32
- package/dist/types/stages.d.ts.map +1 -1
- package/dist/types/stages.js +10 -1
- package/dist/types/stages.js.map +1 -1
- package/dist/types/tracking.d.ts +3 -30
- package/dist/types/tracking.d.ts.map +1 -1
- package/dist/utils/chain.d.ts +7 -3
- package/dist/utils/chain.d.ts.map +1 -1
- package/dist/utils/chain.js +13 -9
- package/dist/utils/chain.js.map +1 -1
- package/dist/utils/logger.d.ts +9 -3
- package/dist/utils/logger.d.ts.map +1 -1
- package/dist/utils/logger.js +53 -19
- package/dist/utils/logger.js.map +1 -1
- package/dist/utils/rpc-utils.d.ts +7 -8
- package/dist/utils/rpc-utils.d.ts.map +1 -1
- package/dist/utils/rpc-utils.js +20 -2
- package/dist/utils/rpc-utils.js.map +1 -1
- package/dist/utils/salt-computation.d.ts.map +1 -1
- package/dist/utils/salt-computation.js +2 -3
- package/dist/utils/salt-computation.js.map +1 -1
- package/dist/utils/stage-metadata.d.ts +2 -2
- package/dist/utils/stage-metadata.d.ts.map +1 -1
- package/dist/utils/stage-metadata.js +5 -5
- package/dist/utils/stage-metadata.js.map +1 -1
- package/package.json +9 -5
- package/dist/calldata/address-utils.d.ts +0 -23
- package/dist/calldata/address-utils.d.ts.map +0 -1
- package/dist/calldata/address-utils.js +0 -84
- package/dist/calldata/address-utils.js.map +0 -1
- package/dist/calldata/extraction.d.ts +0 -17
- package/dist/calldata/extraction.d.ts.map +0 -1
- package/dist/calldata/extraction.js +0 -56
- package/dist/calldata/extraction.js.map +0 -1
- package/dist/stages/base.d.ts.map +0 -1
- package/dist/stages/base.js.map +0 -1
- package/dist/stages/stage-builder.d.ts.map +0 -1
- package/dist/stages/stage-builder.js.map +0 -1
- package/dist/tracker/context.d.ts +0 -111
- package/dist/tracker/context.d.ts.map +0 -1
- package/dist/tracker/context.js +0 -264
- package/dist/tracker/context.js.map +0 -1
- package/dist/tracker/index.d.ts +0 -18
- package/dist/tracker/index.d.ts.map +0 -1
- package/dist/tracker/index.js +0 -70
- package/dist/tracker/index.js.map +0 -1
- package/dist/types.d.ts +0 -6
- package/dist/types.d.ts.map +0 -1
- package/dist/types.js +0 -22
- package/dist/types.js.map +0 -1
- package/dist/utils/error-classification.d.ts +0 -13
- package/dist/utils/error-classification.d.ts.map +0 -1
- package/dist/utils/error-classification.js +0 -28
- package/dist/utils/error-classification.js.map +0 -1
- package/dist/utils/scoped-logger.d.ts +0 -43
- package/dist/utils/scoped-logger.d.ts.map +0 -1
- package/dist/utils/scoped-logger.js +0 -72
- package/dist/utils/scoped-logger.js.map +0 -1
- package/dist/utils/stage-helpers.d.ts +0 -51
- package/dist/utils/stage-helpers.d.ts.map +0 -1
- package/dist/utils/stage-helpers.js +0 -143
- package/dist/utils/stage-helpers.js.map +0 -1
- package/dist/utils/urls.d.ts +0 -28
- package/dist/utils/urls.d.ts.map +0 -1
- package/dist/utils/urls.js +0 -71
- package/dist/utils/urls.js.map +0 -1
package/dist/tracker/context.js
DELETED
|
@@ -1,264 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* TrackingContext - Functional state management for pipeline tracking
|
|
4
|
-
*
|
|
5
|
-
* This module provides a purely functional approach to tracking context:
|
|
6
|
-
* - TrackingContext interface defines the immutable state shape
|
|
7
|
-
* - Pure functions transform state and derive values
|
|
8
|
-
* - No classes, no mutation, no hidden state
|
|
9
|
-
*
|
|
10
|
-
* Benefits:
|
|
11
|
-
* - Easy testing: just create plain objects
|
|
12
|
-
* - Transparent: can log/inspect full state anytime
|
|
13
|
-
* - Predictable: same input → same output
|
|
14
|
-
* - Composable: mix and match functions freely
|
|
15
|
-
* - Debuggable: save/restore state snapshots
|
|
16
|
-
*/
|
|
17
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
-
exports.getFirstExecutableBlock = exports.getProposalState = exports.getIsElection = exports.getQueueBlockNumber = exports.getFirstCallScheduledData = exports.getProposalId = exports.getGovernorAddress = void 0;
|
|
19
|
-
exports.createTrackingContext = createTrackingContext;
|
|
20
|
-
exports.addStage = addStage;
|
|
21
|
-
exports.isStageCompleted = isStageCompleted;
|
|
22
|
-
exports.getCompletedStage = getCompletedStage;
|
|
23
|
-
exports.getCachedStage = getCachedStage;
|
|
24
|
-
exports.isComplete = isComplete;
|
|
25
|
-
exports.getTimelockAddress = getTimelockAddress;
|
|
26
|
-
exports.getOperationId = getOperationId;
|
|
27
|
-
exports.getCallScheduledData = getCallScheduledData;
|
|
28
|
-
exports.getProposalData = getProposalData;
|
|
29
|
-
exports.getProposalType = getProposalType;
|
|
30
|
-
exports.getVotingEndBlock = getVotingEndBlock;
|
|
31
|
-
exports.getL2ExecutionTxHash = getL2ExecutionTxHash;
|
|
32
|
-
exports.getOutboxExecutionTx = getOutboxExecutionTx;
|
|
33
|
-
exports.getL1ExecutionTxHash = getL1ExecutionTxHash;
|
|
34
|
-
exports.createCheckpoint = createCheckpoint;
|
|
35
|
-
exports.toResult = toResult;
|
|
36
|
-
const ethers_1 = require("ethers");
|
|
37
|
-
const logger_1 = require("../utils/logger");
|
|
38
|
-
const base_1 = require("../stages/base");
|
|
39
|
-
const governor_discovery_1 = require("../discovery/governor-discovery");
|
|
40
|
-
const constants_1 = require("../constants");
|
|
41
|
-
const { tracker: logTracker } = logger_1.loggers;
|
|
42
|
-
// State Creation
|
|
43
|
-
/**
|
|
44
|
-
* Create a new TrackingContext.
|
|
45
|
-
*/
|
|
46
|
-
function createTrackingContext(options) {
|
|
47
|
-
// Initialize stages based on tracking path
|
|
48
|
-
const includeProposal = options.input.type === "governor";
|
|
49
|
-
const addressForPath = options.input.type === "governor"
|
|
50
|
-
? options.input.governorAddress
|
|
51
|
-
: options.input.type === "timelock"
|
|
52
|
-
? options.input.timelockAddress
|
|
53
|
-
: "";
|
|
54
|
-
const initialStages = (0, base_1.initializeStagesForPath)(addressForPath, includeProposal);
|
|
55
|
-
let ctx = {
|
|
56
|
-
providers: options.providers,
|
|
57
|
-
chunkingConfig: options.chunkingConfig ?? constants_1.DEFAULT_CHUNKING_CONFIG,
|
|
58
|
-
onProgress: options.onProgress,
|
|
59
|
-
cacheKey: options.cacheKey,
|
|
60
|
-
input: options.input,
|
|
61
|
-
callScheduledData: options.callScheduledData,
|
|
62
|
-
stages: initialStages,
|
|
63
|
-
stageIndex: 0,
|
|
64
|
-
};
|
|
65
|
-
// Load from checkpoint if provided
|
|
66
|
-
if (options.checkpoint?.cachedData.completedStages?.length) {
|
|
67
|
-
ctx = loadFromCheckpoint(ctx, options.checkpoint);
|
|
68
|
-
}
|
|
69
|
-
return ctx;
|
|
70
|
-
}
|
|
71
|
-
/**
|
|
72
|
-
* Load stages from a checkpoint.
|
|
73
|
-
*/
|
|
74
|
-
function loadFromCheckpoint(ctx, checkpoint) {
|
|
75
|
-
const completedStages = checkpoint.cachedData.completedStages;
|
|
76
|
-
if (!completedStages?.length)
|
|
77
|
-
return ctx;
|
|
78
|
-
logTracker("RESUME: loading %d completed stages from checkpoint", completedStages.length);
|
|
79
|
-
let stages = ctx.stages;
|
|
80
|
-
for (const stage of completedStages) {
|
|
81
|
-
stages = (0, base_1.updateStageInList)(stages, stage);
|
|
82
|
-
}
|
|
83
|
-
return { ...ctx, stages, stageIndex: completedStages.length };
|
|
84
|
-
}
|
|
85
|
-
// Stage Management
|
|
86
|
-
/**
|
|
87
|
-
* Add or update a stage. Returns new context.
|
|
88
|
-
*/
|
|
89
|
-
async function addStage(ctx, stage) {
|
|
90
|
-
const newStages = (0, base_1.updateStageInList)(ctx.stages, stage);
|
|
91
|
-
const newCtx = {
|
|
92
|
-
...ctx,
|
|
93
|
-
stages: newStages,
|
|
94
|
-
stageIndex: ctx.stageIndex + 1,
|
|
95
|
-
};
|
|
96
|
-
await emitProgress(newCtx, stage);
|
|
97
|
-
return newCtx;
|
|
98
|
-
}
|
|
99
|
-
// Stage lookup helper (defined early for use in stage management functions)
|
|
100
|
-
const findStage = (ctx, type) => ctx.stages.find((s) => s.type === type);
|
|
101
|
-
/** Check if a stage is completed (COMPLETED or SKIPPED). */
|
|
102
|
-
function isStageCompleted(ctx, type) {
|
|
103
|
-
const s = findStage(ctx, type);
|
|
104
|
-
return s?.status === "COMPLETED" || s?.status === "SKIPPED";
|
|
105
|
-
}
|
|
106
|
-
/** Get a completed stage for zero-RPC resume. */
|
|
107
|
-
function getCompletedStage(ctx, type) {
|
|
108
|
-
const s = findStage(ctx, type);
|
|
109
|
-
return s?.status === "COMPLETED" || s?.status === "SKIPPED" ? s : undefined;
|
|
110
|
-
}
|
|
111
|
-
/** Get a cached stage (any status). */
|
|
112
|
-
function getCachedStage(ctx, type) {
|
|
113
|
-
return findStage(ctx, type);
|
|
114
|
-
}
|
|
115
|
-
/**
|
|
116
|
-
* Check if all stages are complete.
|
|
117
|
-
*/
|
|
118
|
-
function isComplete(ctx) {
|
|
119
|
-
return (0, base_1.areAllStagesComplete)(ctx.stages);
|
|
120
|
-
}
|
|
121
|
-
// Stage data helpers
|
|
122
|
-
const stageData = (ctx, type) => findStage(ctx, type)?.data;
|
|
123
|
-
const execTx = (s) => s?.transactions?.find((tx) => tx.description === "executed");
|
|
124
|
-
const chainTx = (s, chain) => s?.transactions?.find((tx) => tx.chain === chain);
|
|
125
|
-
// Derived Getters - Input-based
|
|
126
|
-
const getGovernorAddress = (ctx) => ctx.input.type === "governor" ? ctx.input.governorAddress : undefined;
|
|
127
|
-
exports.getGovernorAddress = getGovernorAddress;
|
|
128
|
-
const getProposalId = (ctx) => ctx.input.type === "governor" ? ctx.input.proposalId : undefined;
|
|
129
|
-
exports.getProposalId = getProposalId;
|
|
130
|
-
// Derived Getters - Multi-source lookups
|
|
131
|
-
function getTimelockAddress(ctx) {
|
|
132
|
-
if (ctx.input.type === "timelock")
|
|
133
|
-
return ctx.input.timelockAddress;
|
|
134
|
-
return (stageData(ctx, "PROPOSAL_QUEUED")?.timelockAddress ??
|
|
135
|
-
stageData(ctx, "L2_TIMELOCK")?.timelockAddress);
|
|
136
|
-
}
|
|
137
|
-
function getOperationId(ctx) {
|
|
138
|
-
if (ctx.input.type === "timelock")
|
|
139
|
-
return ctx.input.operationId;
|
|
140
|
-
return (stageData(ctx, "PROPOSAL_QUEUED")?.operationId ??
|
|
141
|
-
stageData(ctx, "L2_TIMELOCK")?.operationId);
|
|
142
|
-
}
|
|
143
|
-
function getCallScheduledData(ctx) {
|
|
144
|
-
if (ctx.callScheduledData)
|
|
145
|
-
return ctx.callScheduledData;
|
|
146
|
-
const qData = stageData(ctx, "PROPOSAL_QUEUED")?.callScheduledData;
|
|
147
|
-
if (qData?.length)
|
|
148
|
-
return (0, base_1.deserializeCallScheduledDataArray)(qData);
|
|
149
|
-
const l2Data = stageData(ctx, "L2_TIMELOCK")?.callScheduledData;
|
|
150
|
-
return l2Data?.length ? (0, base_1.deserializeCallScheduledDataArray)(l2Data) : undefined;
|
|
151
|
-
}
|
|
152
|
-
const getFirstCallScheduledData = (ctx) => getCallScheduledData(ctx)?.[0];
|
|
153
|
-
exports.getFirstCallScheduledData = getFirstCallScheduledData;
|
|
154
|
-
const getQueueBlockNumber = (ctx) => (0, exports.getFirstCallScheduledData)(ctx)?.blockNumber;
|
|
155
|
-
exports.getQueueBlockNumber = getQueueBlockNumber;
|
|
156
|
-
/** Proposal data from PROPOSAL_CREATED stage */
|
|
157
|
-
function getProposalData(ctx) {
|
|
158
|
-
const s = findStage(ctx, "PROPOSAL_CREATED");
|
|
159
|
-
if (!s || s.status === "NOT_STARTED")
|
|
160
|
-
return undefined;
|
|
161
|
-
const data = s.data;
|
|
162
|
-
const tx = s.transactions?.[0];
|
|
163
|
-
if (!data.proposalId ||
|
|
164
|
-
!data.startBlock ||
|
|
165
|
-
!data.endBlock ||
|
|
166
|
-
!data.proposer ||
|
|
167
|
-
!data.targets ||
|
|
168
|
-
!data.values ||
|
|
169
|
-
!data.signatures ||
|
|
170
|
-
!data.calldatas ||
|
|
171
|
-
!tx)
|
|
172
|
-
return undefined;
|
|
173
|
-
return {
|
|
174
|
-
proposalId: data.proposalId,
|
|
175
|
-
proposer: data.proposer,
|
|
176
|
-
description: data.description,
|
|
177
|
-
targets: data.targets,
|
|
178
|
-
values: data.values.map((v) => ethers_1.BigNumber.from(v)),
|
|
179
|
-
signatures: data.signatures,
|
|
180
|
-
calldatas: data.calldatas,
|
|
181
|
-
startBlock: ethers_1.BigNumber.from(data.startBlock),
|
|
182
|
-
endBlock: ethers_1.BigNumber.from(data.endBlock),
|
|
183
|
-
creationBlock: tx.blockNumber,
|
|
184
|
-
creationTxHash: tx.hash,
|
|
185
|
-
};
|
|
186
|
-
}
|
|
187
|
-
function getProposalType(ctx) {
|
|
188
|
-
const data = stageData(ctx, "PROPOSAL_CREATED");
|
|
189
|
-
if (data?.proposalType)
|
|
190
|
-
return data.proposalType;
|
|
191
|
-
const addr = (0, exports.getGovernorAddress)(ctx);
|
|
192
|
-
return addr ? (0, governor_discovery_1.detectProposalType)(addr) : undefined;
|
|
193
|
-
}
|
|
194
|
-
const getIsElection = (ctx) => {
|
|
195
|
-
const type = getProposalType(ctx);
|
|
196
|
-
return type ? (0, governor_discovery_1.isElectionProposal)(type) : false;
|
|
197
|
-
};
|
|
198
|
-
exports.getIsElection = getIsElection;
|
|
199
|
-
const getProposalState = (ctx) => stageData(ctx, "VOTING_ACTIVE")?.proposalState;
|
|
200
|
-
exports.getProposalState = getProposalState;
|
|
201
|
-
function getVotingEndBlock(ctx) {
|
|
202
|
-
const data = stageData(ctx, "VOTING_ACTIVE");
|
|
203
|
-
if (!data?.deadline)
|
|
204
|
-
return undefined;
|
|
205
|
-
const deadline = parseInt(data.deadline, 10);
|
|
206
|
-
const extended = data.extendedDeadline ? parseInt(data.extendedDeadline, 10) : 0;
|
|
207
|
-
return extended > deadline ? extended : deadline;
|
|
208
|
-
}
|
|
209
|
-
function getL2ExecutionTxHash(ctx) {
|
|
210
|
-
const s = findStage(ctx, "L2_TIMELOCK");
|
|
211
|
-
return s?.status === "COMPLETED" ? execTx(s)?.hash : undefined;
|
|
212
|
-
}
|
|
213
|
-
const getFirstExecutableBlock = (ctx) => stageData(ctx, "L2_TO_L1_MESSAGE")?.firstExecutableBlock;
|
|
214
|
-
exports.getFirstExecutableBlock = getFirstExecutableBlock;
|
|
215
|
-
function getOutboxExecutionTx(ctx) {
|
|
216
|
-
const s = findStage(ctx, "L2_TO_L1_MESSAGE");
|
|
217
|
-
if (s?.status !== "COMPLETED")
|
|
218
|
-
return undefined;
|
|
219
|
-
const tx = chainTx(s, "L1");
|
|
220
|
-
return tx ? { hash: tx.hash, blockNumber: tx.blockNumber } : undefined;
|
|
221
|
-
}
|
|
222
|
-
function getL1ExecutionTxHash(ctx) {
|
|
223
|
-
const s = findStage(ctx, "L1_TIMELOCK");
|
|
224
|
-
return s?.status === "COMPLETED" ? execTx(s)?.hash : undefined;
|
|
225
|
-
}
|
|
226
|
-
// Checkpoint & Result
|
|
227
|
-
function createCheckpoint(ctx) {
|
|
228
|
-
const completedStages = ctx.stages.filter((s) => s.status !== "NOT_STARTED");
|
|
229
|
-
const lastProcessedStage = [...ctx.stages].reverse().find((s) => s.status !== "NOT_STARTED")?.type ?? null;
|
|
230
|
-
return {
|
|
231
|
-
version: 1,
|
|
232
|
-
createdAt: Date.now(),
|
|
233
|
-
input: ctx.input,
|
|
234
|
-
lastProcessedStage,
|
|
235
|
-
lastProcessedBlock: { l1: 0, l2: 0, nova: 0 },
|
|
236
|
-
cachedData: { completedStages },
|
|
237
|
-
metadata: { errorCount: 0, lastTrackedAt: Date.now() },
|
|
238
|
-
};
|
|
239
|
-
}
|
|
240
|
-
async function emitProgress(ctx, s) {
|
|
241
|
-
if (!ctx.onProgress)
|
|
242
|
-
return;
|
|
243
|
-
const idx = ctx.stages.findIndex((x) => x.type === s.type);
|
|
244
|
-
await ctx.onProgress({
|
|
245
|
-
stage: s,
|
|
246
|
-
stages: ctx.stages,
|
|
247
|
-
currentIndex: idx >= 0 ? idx : ctx.stageIndex,
|
|
248
|
-
totalStages: ctx.stages.length,
|
|
249
|
-
isComplete: isComplete(ctx),
|
|
250
|
-
});
|
|
251
|
-
}
|
|
252
|
-
function toResult(ctx) {
|
|
253
|
-
return {
|
|
254
|
-
input: ctx.input,
|
|
255
|
-
stages: ctx.stages,
|
|
256
|
-
checkpoint: createCheckpoint(ctx),
|
|
257
|
-
isComplete: isComplete(ctx),
|
|
258
|
-
proposalType: getProposalType(ctx),
|
|
259
|
-
proposalData: getProposalData(ctx),
|
|
260
|
-
currentState: (0, exports.getProposalState)(ctx),
|
|
261
|
-
isElection: (0, exports.getIsElection)(ctx),
|
|
262
|
-
};
|
|
263
|
-
}
|
|
264
|
-
//# sourceMappingURL=context.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"context.js","sourceRoot":"","sources":["../../src/tracker/context.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;AAgGH,sDA6BC;AAwBD,4BAaC;AAOD,4CAGC;AAGD,8CAGC;AAGD,wCAEC;AAKD,gCAEC;AAiBD,gDAMC;AAED,wCAMC;AAED,oDAMC;AAOD,0CA8BC;AAED,0CAKC;AAUD,8CAMC;AAED,oDAGC;AAKD,oDAOC;AAED,oDAGC;AAID,4CAaC;AAcD,4BAWC;AA/VD,mCAA2C;AAC3C,4CAA0C;AAmB1C,yCAKwB;AACxB,wEAAyF;AACzF,4CAAuD;AAEvD,MAAM,EAAE,OAAO,EAAE,UAAU,EAAE,GAAG,gBAAO,CAAC;AA4DxC,iBAAiB;AAEjB;;GAEG;AACH,SAAgB,qBAAqB,CAAC,OAAqC;IACzE,2CAA2C;IAC3C,MAAM,eAAe,GAAG,OAAO,CAAC,KAAK,CAAC,IAAI,KAAK,UAAU,CAAC;IAC1D,MAAM,cAAc,GAClB,OAAO,CAAC,KAAK,CAAC,IAAI,KAAK,UAAU;QAC/B,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,eAAe;QAC/B,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,KAAK,UAAU;YACjC,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,eAAe;YAC/B,CAAC,CAAC,EAAE,CAAC;IAEX,MAAM,aAAa,GAAG,IA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ACJ,CAAC"}
|
package/dist/tracker/index.d.ts
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Tracker module re-exports
|
|
3
|
-
*
|
|
4
|
-
* This module consolidates exports from the tracker subsystem:
|
|
5
|
-
* - context.ts: TrackingContext state management
|
|
6
|
-
* - pipeline.ts: Stage tracking pipeline functions
|
|
7
|
-
* - discovery.ts: Proposal and timelock discovery
|
|
8
|
-
* - query.ts: Cache query operations
|
|
9
|
-
* - execute.ts: Transaction preparation
|
|
10
|
-
* - state.ts: Cache utilities
|
|
11
|
-
*/
|
|
12
|
-
export { Providers, CreateTrackingContextOptions, TrackingContext, createTrackingContext, addStage, isStageCompleted, getCompletedStage, getCachedStage, isComplete, getGovernorAddress, getProposalId, getTimelockAddress, getOperationId, getCallScheduledData, getFirstCallScheduledData, getQueueBlockNumber, getProposalData, getProposalType, getIsElection, getProposalState, getL2ExecutionTxHash, getFirstExecutableBlock, getOutboxExecutionTx, getL1ExecutionTxHash, createCheckpoint, toResult, } from "./context";
|
|
13
|
-
export { trackGovernorPipeline, trackTimelockPipeline } from "./pipeline";
|
|
14
|
-
export { discoverAll, discoverProposals, discoverTimelockOps, DiscoveredProposal, DiscoveredTimelockOp, loadWatermarks, saveWatermarks, WATERMARKS_KEY, } from "./discovery";
|
|
15
|
-
export { listCheckpointKeys, getCheckpoint, getAllCheckpoints, queryIncompleteCheckpoints, getStats, } from "./query";
|
|
16
|
-
export { prepareTransaction } from "./execute";
|
|
17
|
-
export { txHashCacheKey, readCacheStatus } from "./state";
|
|
18
|
-
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/tracker/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAGH,OAAO,EAEL,SAAS,EACT,4BAA4B,EAC5B,eAAe,EAEf,qBAAqB,EAErB,QAAQ,EACR,gBAAgB,EAChB,iBAAiB,EACjB,cAAc,EACd,UAAU,EAEV,kBAAkB,EAClB,aAAa,EACb,kBAAkB,EAClB,cAAc,EACd,oBAAoB,EACpB,yBAAyB,EACzB,mBAAmB,EACnB,eAAe,EACf,eAAe,EACf,aAAa,EACb,gBAAgB,EAChB,oBAAoB,EACpB,uBAAuB,EACvB,oBAAoB,EACpB,oBAAoB,EAEpB,gBAAgB,EAChB,QAAQ,GACT,MAAM,WAAW,CAAC;AAGnB,OAAO,EAAE,qBAAqB,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAC;AAG1E,OAAO,EACL,WAAW,EACX,iBAAiB,EACjB,mBAAmB,EACnB,kBAAkB,EAClB,oBAAoB,EACpB,cAAc,EACd,cAAc,EACd,cAAc,GACf,MAAM,aAAa,CAAC;AAGrB,OAAO,EACL,kBAAkB,EAClB,aAAa,EACb,iBAAiB,EACjB,0BAA0B,EAC1B,QAAQ,GACT,MAAM,SAAS,CAAC;AAGjB,OAAO,EAAE,kBAAkB,EAAE,MAAM,WAAW,CAAC;AAG/C,OAAO,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC"}
|
package/dist/tracker/index.js
DELETED
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* Tracker module re-exports
|
|
4
|
-
*
|
|
5
|
-
* This module consolidates exports from the tracker subsystem:
|
|
6
|
-
* - context.ts: TrackingContext state management
|
|
7
|
-
* - pipeline.ts: Stage tracking pipeline functions
|
|
8
|
-
* - discovery.ts: Proposal and timelock discovery
|
|
9
|
-
* - query.ts: Cache query operations
|
|
10
|
-
* - execute.ts: Transaction preparation
|
|
11
|
-
* - state.ts: Cache utilities
|
|
12
|
-
*/
|
|
13
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
|
-
exports.readCacheStatus = exports.txHashCacheKey = exports.prepareTransaction = exports.getStats = exports.queryIncompleteCheckpoints = exports.getAllCheckpoints = exports.getCheckpoint = exports.listCheckpointKeys = exports.WATERMARKS_KEY = exports.saveWatermarks = exports.loadWatermarks = exports.discoverTimelockOps = exports.discoverProposals = exports.discoverAll = exports.trackTimelockPipeline = exports.trackGovernorPipeline = exports.toResult = exports.createCheckpoint = exports.getL1ExecutionTxHash = exports.getOutboxExecutionTx = exports.getFirstExecutableBlock = exports.getL2ExecutionTxHash = exports.getProposalState = exports.getIsElection = exports.getProposalType = exports.getProposalData = exports.getQueueBlockNumber = exports.getFirstCallScheduledData = exports.getCallScheduledData = exports.getOperationId = exports.getTimelockAddress = exports.getProposalId = exports.getGovernorAddress = exports.isComplete = exports.getCachedStage = exports.getCompletedStage = exports.isStageCompleted = exports.addStage = exports.createTrackingContext = void 0;
|
|
15
|
-
// Context - TrackingContext state management
|
|
16
|
-
var context_1 = require("./context");
|
|
17
|
-
// State creation
|
|
18
|
-
Object.defineProperty(exports, "createTrackingContext", { enumerable: true, get: function () { return context_1.createTrackingContext; } });
|
|
19
|
-
// Stage management
|
|
20
|
-
Object.defineProperty(exports, "addStage", { enumerable: true, get: function () { return context_1.addStage; } });
|
|
21
|
-
Object.defineProperty(exports, "isStageCompleted", { enumerable: true, get: function () { return context_1.isStageCompleted; } });
|
|
22
|
-
Object.defineProperty(exports, "getCompletedStage", { enumerable: true, get: function () { return context_1.getCompletedStage; } });
|
|
23
|
-
Object.defineProperty(exports, "getCachedStage", { enumerable: true, get: function () { return context_1.getCachedStage; } });
|
|
24
|
-
Object.defineProperty(exports, "isComplete", { enumerable: true, get: function () { return context_1.isComplete; } });
|
|
25
|
-
// Derived getters
|
|
26
|
-
Object.defineProperty(exports, "getGovernorAddress", { enumerable: true, get: function () { return context_1.getGovernorAddress; } });
|
|
27
|
-
Object.defineProperty(exports, "getProposalId", { enumerable: true, get: function () { return context_1.getProposalId; } });
|
|
28
|
-
Object.defineProperty(exports, "getTimelockAddress", { enumerable: true, get: function () { return context_1.getTimelockAddress; } });
|
|
29
|
-
Object.defineProperty(exports, "getOperationId", { enumerable: true, get: function () { return context_1.getOperationId; } });
|
|
30
|
-
Object.defineProperty(exports, "getCallScheduledData", { enumerable: true, get: function () { return context_1.getCallScheduledData; } });
|
|
31
|
-
Object.defineProperty(exports, "getFirstCallScheduledData", { enumerable: true, get: function () { return context_1.getFirstCallScheduledData; } });
|
|
32
|
-
Object.defineProperty(exports, "getQueueBlockNumber", { enumerable: true, get: function () { return context_1.getQueueBlockNumber; } });
|
|
33
|
-
Object.defineProperty(exports, "getProposalData", { enumerable: true, get: function () { return context_1.getProposalData; } });
|
|
34
|
-
Object.defineProperty(exports, "getProposalType", { enumerable: true, get: function () { return context_1.getProposalType; } });
|
|
35
|
-
Object.defineProperty(exports, "getIsElection", { enumerable: true, get: function () { return context_1.getIsElection; } });
|
|
36
|
-
Object.defineProperty(exports, "getProposalState", { enumerable: true, get: function () { return context_1.getProposalState; } });
|
|
37
|
-
Object.defineProperty(exports, "getL2ExecutionTxHash", { enumerable: true, get: function () { return context_1.getL2ExecutionTxHash; } });
|
|
38
|
-
Object.defineProperty(exports, "getFirstExecutableBlock", { enumerable: true, get: function () { return context_1.getFirstExecutableBlock; } });
|
|
39
|
-
Object.defineProperty(exports, "getOutboxExecutionTx", { enumerable: true, get: function () { return context_1.getOutboxExecutionTx; } });
|
|
40
|
-
Object.defineProperty(exports, "getL1ExecutionTxHash", { enumerable: true, get: function () { return context_1.getL1ExecutionTxHash; } });
|
|
41
|
-
// Checkpoint
|
|
42
|
-
Object.defineProperty(exports, "createCheckpoint", { enumerable: true, get: function () { return context_1.createCheckpoint; } });
|
|
43
|
-
Object.defineProperty(exports, "toResult", { enumerable: true, get: function () { return context_1.toResult; } });
|
|
44
|
-
// Pipeline - Stage tracking functions
|
|
45
|
-
var pipeline_1 = require("./pipeline");
|
|
46
|
-
Object.defineProperty(exports, "trackGovernorPipeline", { enumerable: true, get: function () { return pipeline_1.trackGovernorPipeline; } });
|
|
47
|
-
Object.defineProperty(exports, "trackTimelockPipeline", { enumerable: true, get: function () { return pipeline_1.trackTimelockPipeline; } });
|
|
48
|
-
// Discovery
|
|
49
|
-
var discovery_1 = require("./discovery");
|
|
50
|
-
Object.defineProperty(exports, "discoverAll", { enumerable: true, get: function () { return discovery_1.discoverAll; } });
|
|
51
|
-
Object.defineProperty(exports, "discoverProposals", { enumerable: true, get: function () { return discovery_1.discoverProposals; } });
|
|
52
|
-
Object.defineProperty(exports, "discoverTimelockOps", { enumerable: true, get: function () { return discovery_1.discoverTimelockOps; } });
|
|
53
|
-
Object.defineProperty(exports, "loadWatermarks", { enumerable: true, get: function () { return discovery_1.loadWatermarks; } });
|
|
54
|
-
Object.defineProperty(exports, "saveWatermarks", { enumerable: true, get: function () { return discovery_1.saveWatermarks; } });
|
|
55
|
-
Object.defineProperty(exports, "WATERMARKS_KEY", { enumerable: true, get: function () { return discovery_1.WATERMARKS_KEY; } });
|
|
56
|
-
// Query
|
|
57
|
-
var query_1 = require("./query");
|
|
58
|
-
Object.defineProperty(exports, "listCheckpointKeys", { enumerable: true, get: function () { return query_1.listCheckpointKeys; } });
|
|
59
|
-
Object.defineProperty(exports, "getCheckpoint", { enumerable: true, get: function () { return query_1.getCheckpoint; } });
|
|
60
|
-
Object.defineProperty(exports, "getAllCheckpoints", { enumerable: true, get: function () { return query_1.getAllCheckpoints; } });
|
|
61
|
-
Object.defineProperty(exports, "queryIncompleteCheckpoints", { enumerable: true, get: function () { return query_1.queryIncompleteCheckpoints; } });
|
|
62
|
-
Object.defineProperty(exports, "getStats", { enumerable: true, get: function () { return query_1.getStats; } });
|
|
63
|
-
// Execute
|
|
64
|
-
var execute_1 = require("./execute");
|
|
65
|
-
Object.defineProperty(exports, "prepareTransaction", { enumerable: true, get: function () { return execute_1.prepareTransaction; } });
|
|
66
|
-
// State utilities
|
|
67
|
-
var state_1 = require("./state");
|
|
68
|
-
Object.defineProperty(exports, "txHashCacheKey", { enumerable: true, get: function () { return state_1.txHashCacheKey; } });
|
|
69
|
-
Object.defineProperty(exports, "readCacheStatus", { enumerable: true, get: function () { return state_1.readCacheStatus; } });
|
|
70
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/tracker/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;GAUG;;;AAEH,6CAA6C;AAC7C,qCAgCmB;AA3BjB,iBAAiB;AACjB,gHAAA,qBAAqB,OAAA;AACrB,mBAAmB;AACnB,mGAAA,QAAQ,OAAA;AACR,2GAAA,gBAAgB,OAAA;AAChB,4GAAA,iBAAiB,OAAA;AACjB,yGAAA,cAAc,OAAA;AACd,qGAAA,UAAU,OAAA;AACV,kBAAkB;AAClB,6GAAA,kBAAkB,OAAA;AAClB,wGAAA,aAAa,OAAA;AACb,6GAAA,kBAAkB,OAAA;AAClB,yGAAA,cAAc,OAAA;AACd,+GAAA,oBAAoB,OAAA;AACpB,oHAAA,yBAAyB,OAAA;AACzB,8GAAA,mBAAmB,OAAA;AACnB,0GAAA,eAAe,OAAA;AACf,0GAAA,eAAe,OAAA;AACf,wGAAA,aAAa,OAAA;AACb,2GAAA,gBAAgB,OAAA;AAChB,+GAAA,oBAAoB,OAAA;AACpB,kHAAA,uBAAuB,OAAA;AACvB,+GAAA,oBAAoB,OAAA;AACpB,+GAAA,oBAAoB,OAAA;AACpB,aAAa;AACb,2GAAA,gBAAgB,OAAA;AAChB,mGAAA,QAAQ,OAAA;AAGV,sCAAsC;AACtC,uCAA0E;AAAjE,iHAAA,qBAAqB,OAAA;AAAE,iHAAA,qBAAqB,OAAA;AAErD,YAAY;AACZ,yCASqB;AARnB,wGAAA,WAAW,OAAA;AACX,8GAAA,iBAAiB,OAAA;AACjB,gHAAA,mBAAmB,OAAA;AAGnB,2GAAA,cAAc,OAAA;AACd,2GAAA,cAAc,OAAA;AACd,2GAAA,cAAc,OAAA;AAGhB,QAAQ;AACR,iCAMiB;AALf,2GAAA,kBAAkB,OAAA;AAClB,sGAAA,aAAa,OAAA;AACb,0GAAA,iBAAiB,OAAA;AACjB,mHAAA,0BAA0B,OAAA;AAC1B,iGAAA,QAAQ,OAAA;AAGV,UAAU;AACV,qCAA+C;AAAtC,6GAAA,kBAAkB,OAAA;AAE3B,kBAAkB;AAClB,iCAA0D;AAAjD,uGAAA,cAAc,OAAA;AAAE,wGAAA,eAAe,OAAA"}
|
package/dist/types.d.ts
DELETED
package/dist/types.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,cAAc,eAAe,CAAC"}
|
package/dist/types.js
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
/**
|
|
18
|
-
* Type definitions for Arbitrum Governance Stage Tracking SDK
|
|
19
|
-
* Re-exports from domain modules in ./types/
|
|
20
|
-
*/
|
|
21
|
-
__exportStar(require("./types/index"), exports);
|
|
22
|
-
//# sourceMappingURL=types.js.map
|
package/dist/types.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA;;;GAGG;AACH,gDAA8B"}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Error Classification Utilities
|
|
3
|
-
*
|
|
4
|
-
* Classifies errors for better error handling and tracking.
|
|
5
|
-
*/
|
|
6
|
-
/**
|
|
7
|
-
* Check if an error is a gas estimation error.
|
|
8
|
-
* Gas estimation errors should not count against consecutive error tracking
|
|
9
|
-
* because they are often temporary (insufficient funds, contract state changes, etc.)
|
|
10
|
-
* and should be retried in the next run.
|
|
11
|
-
*/
|
|
12
|
-
export declare function isGasEstimationError(error: unknown): boolean;
|
|
13
|
-
//# sourceMappingURL=error-classification.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"error-classification.d.ts","sourceRoot":"","sources":["../../src/utils/error-classification.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAe5D"}
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* Error Classification Utilities
|
|
4
|
-
*
|
|
5
|
-
* Classifies errors for better error handling and tracking.
|
|
6
|
-
*/
|
|
7
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
-
exports.isGasEstimationError = isGasEstimationError;
|
|
9
|
-
/**
|
|
10
|
-
* Check if an error is a gas estimation error.
|
|
11
|
-
* Gas estimation errors should not count against consecutive error tracking
|
|
12
|
-
* because they are often temporary (insufficient funds, contract state changes, etc.)
|
|
13
|
-
* and should be retried in the next run.
|
|
14
|
-
*/
|
|
15
|
-
function isGasEstimationError(error) {
|
|
16
|
-
const message = error instanceof Error ? error.message.toLowerCase() : String(error).toLowerCase();
|
|
17
|
-
return (message.includes("gas required exceeds") ||
|
|
18
|
-
message.includes("execution reverted") ||
|
|
19
|
-
message.includes("out of gas") ||
|
|
20
|
-
message.includes("intrinsic gas too low") ||
|
|
21
|
-
message.includes("insufficient funds for gas") ||
|
|
22
|
-
message.includes("cannot estimate gas") ||
|
|
23
|
-
message.includes("gas estimation") ||
|
|
24
|
-
message.includes("transaction may fail") ||
|
|
25
|
-
message.includes("gas limit") ||
|
|
26
|
-
message.includes("revert"));
|
|
27
|
-
}
|
|
28
|
-
//# sourceMappingURL=error-classification.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"error-classification.js","sourceRoot":"","sources":["../../src/utils/error-classification.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;AAQH,oDAeC;AArBD;;;;;GAKG;AACH,SAAgB,oBAAoB,CAAC,KAAc;IACjD,MAAM,OAAO,GACX,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,WAAW,EAAE,CAAC;IACrF,OAAO,CACL,OAAO,CAAC,QAAQ,CAAC,sBAAsB,CAAC;QACxC,OAAO,CAAC,QAAQ,CAAC,oBAAoB,CAAC;QACtC,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAC;QAC9B,OAAO,CAAC,QAAQ,CAAC,uBAAuB,CAAC;QACzC,OAAO,CAAC,QAAQ,CAAC,4BAA4B,CAAC;QAC9C,OAAO,CAAC,QAAQ,CAAC,qBAAqB,CAAC;QACvC,OAAO,CAAC,QAAQ,CAAC,gBAAgB,CAAC;QAClC,OAAO,CAAC,QAAQ,CAAC,sBAAsB,CAAC;QACxC,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAC;QAC7B,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAC3B,CAAC;AACJ,CAAC"}
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Scoped Logger using AsyncLocalStorage
|
|
3
|
-
*
|
|
4
|
-
* Provides automatic context prefixing for concurrent operations.
|
|
5
|
-
* All log calls within a scope automatically include the scope prefix.
|
|
6
|
-
*
|
|
7
|
-
* Usage:
|
|
8
|
-
* import { withScope, scopedLog } from "./scoped-logger";
|
|
9
|
-
*
|
|
10
|
-
* // Create scoped logger
|
|
11
|
-
* const log = scopedLog("gov-tracker:discovery");
|
|
12
|
-
*
|
|
13
|
-
* // Run with scope - all nested logs get the prefix
|
|
14
|
-
* await withScope("core-gov", async () => {
|
|
15
|
-
* log("discovering..."); // outputs: [core-gov] discovering...
|
|
16
|
-
* await nestedFunction(); // nested calls also get prefix
|
|
17
|
-
* });
|
|
18
|
-
*/
|
|
19
|
-
/**
|
|
20
|
-
* Get current scope prefix, or empty string if not in a scope.
|
|
21
|
-
*/
|
|
22
|
-
export declare function getCurrentScope(): string;
|
|
23
|
-
/**
|
|
24
|
-
* Run a function within a logging scope.
|
|
25
|
-
* All scopedLog calls within this function (and nested calls) will
|
|
26
|
-
* automatically include the scope prefix.
|
|
27
|
-
*
|
|
28
|
-
* Scopes can be nested - inner scopes override outer scopes.
|
|
29
|
-
*/
|
|
30
|
-
export declare function withScope<T>(prefix: string, fn: () => T): T;
|
|
31
|
-
/**
|
|
32
|
-
* Create a scoped debug logger.
|
|
33
|
-
* Returns a function that automatically prepends the current scope.
|
|
34
|
-
*
|
|
35
|
-
* Unlike regular debug loggers, the scope is dynamically determined
|
|
36
|
-
* at call time using AsyncLocalStorage.
|
|
37
|
-
*/
|
|
38
|
-
export declare function scopedLog(namespace: string): (fmt: string, ...args: unknown[]) => void;
|
|
39
|
-
/**
|
|
40
|
-
* Create multiple scoped loggers for common namespaces.
|
|
41
|
-
*/
|
|
42
|
-
export declare function createScopedLoggers<K extends string>(namespaces: Record<K, string>): Record<K, (fmt: string, ...args: unknown[]) => void>;
|
|
43
|
-
//# sourceMappingURL=scoped-logger.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"scoped-logger.d.ts","sourceRoot":"","sources":["../../src/utils/scoped-logger.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAWH;;GAEG;AACH,wBAAgB,eAAe,IAAI,MAAM,CAExC;AAED;;;;;;GAMG;AACH,wBAAgB,SAAS,CAAC,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,CAAC,GAAG,CAAC,CAE3D;AAED;;;;;;GAMG;AACH,wBAAgB,SAAS,CAAC,SAAS,EAAE,MAAM,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,OAAO,EAAE,KAAK,IAAI,CAQtF;AAED;;GAEG;AACH,wBAAgB,mBAAmB,CAAC,CAAC,SAAS,MAAM,EAClD,UAAU,EAAE,MAAM,CAAC,CAAC,EAAE,MAAM,CAAC,GAC5B,MAAM,CAAC,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,OAAO,EAAE,KAAK,IAAI,CAAC,CAMtD"}
|
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* Scoped Logger using AsyncLocalStorage
|
|
4
|
-
*
|
|
5
|
-
* Provides automatic context prefixing for concurrent operations.
|
|
6
|
-
* All log calls within a scope automatically include the scope prefix.
|
|
7
|
-
*
|
|
8
|
-
* Usage:
|
|
9
|
-
* import { withScope, scopedLog } from "./scoped-logger";
|
|
10
|
-
*
|
|
11
|
-
* // Create scoped logger
|
|
12
|
-
* const log = scopedLog("gov-tracker:discovery");
|
|
13
|
-
*
|
|
14
|
-
* // Run with scope - all nested logs get the prefix
|
|
15
|
-
* await withScope("core-gov", async () => {
|
|
16
|
-
* log("discovering..."); // outputs: [core-gov] discovering...
|
|
17
|
-
* await nestedFunction(); // nested calls also get prefix
|
|
18
|
-
* });
|
|
19
|
-
*/
|
|
20
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
21
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
22
|
-
};
|
|
23
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
24
|
-
exports.getCurrentScope = getCurrentScope;
|
|
25
|
-
exports.withScope = withScope;
|
|
26
|
-
exports.scopedLog = scopedLog;
|
|
27
|
-
exports.createScopedLoggers = createScopedLoggers;
|
|
28
|
-
const async_hooks_1 = require("async_hooks");
|
|
29
|
-
const debug_1 = __importDefault(require("debug"));
|
|
30
|
-
const scopeStorage = new async_hooks_1.AsyncLocalStorage();
|
|
31
|
-
/**
|
|
32
|
-
* Get current scope prefix, or empty string if not in a scope.
|
|
33
|
-
*/
|
|
34
|
-
function getCurrentScope() {
|
|
35
|
-
return scopeStorage.getStore()?.prefix ?? "";
|
|
36
|
-
}
|
|
37
|
-
/**
|
|
38
|
-
* Run a function within a logging scope.
|
|
39
|
-
* All scopedLog calls within this function (and nested calls) will
|
|
40
|
-
* automatically include the scope prefix.
|
|
41
|
-
*
|
|
42
|
-
* Scopes can be nested - inner scopes override outer scopes.
|
|
43
|
-
*/
|
|
44
|
-
function withScope(prefix, fn) {
|
|
45
|
-
return scopeStorage.run({ prefix }, fn);
|
|
46
|
-
}
|
|
47
|
-
/**
|
|
48
|
-
* Create a scoped debug logger.
|
|
49
|
-
* Returns a function that automatically prepends the current scope.
|
|
50
|
-
*
|
|
51
|
-
* Unlike regular debug loggers, the scope is dynamically determined
|
|
52
|
-
* at call time using AsyncLocalStorage.
|
|
53
|
-
*/
|
|
54
|
-
function scopedLog(namespace) {
|
|
55
|
-
const baseLog = (0, debug_1.default)(namespace);
|
|
56
|
-
return (fmt, ...args) => {
|
|
57
|
-
const scope = getCurrentScope();
|
|
58
|
-
const prefix = scope ? `[${scope}] ` : "";
|
|
59
|
-
baseLog(prefix + fmt, ...args);
|
|
60
|
-
};
|
|
61
|
-
}
|
|
62
|
-
/**
|
|
63
|
-
* Create multiple scoped loggers for common namespaces.
|
|
64
|
-
*/
|
|
65
|
-
function createScopedLoggers(namespaces) {
|
|
66
|
-
const loggers = {};
|
|
67
|
-
for (const [key, ns] of Object.entries(namespaces)) {
|
|
68
|
-
loggers[key] = scopedLog(ns);
|
|
69
|
-
}
|
|
70
|
-
return loggers;
|
|
71
|
-
}
|
|
72
|
-
//# sourceMappingURL=scoped-logger.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"scoped-logger.js","sourceRoot":"","sources":["../../src/utils/scoped-logger.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;GAiBG;;;;;AAcH,0CAEC;AASD,8BAEC;AASD,8BAQC;AAKD,kDAQC;AAvDD,6CAAgD;AAChD,kDAAgC;AAMhC,MAAM,YAAY,GAAG,IAAI,+BAAiB,EAAY,CAAC;AAEvD;;GAEG;AACH,SAAgB,eAAe;IAC7B,OAAO,YAAY,CAAC,QAAQ,EAAE,EAAE,MAAM,IAAI,EAAE,CAAC;AAC/C,CAAC;AAED;;;;;;GAMG;AACH,SAAgB,SAAS,CAAI,MAAc,EAAE,EAAW;IACtD,OAAO,YAAY,CAAC,GAAG,CAAC,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC,CAAC;AAC1C,CAAC;AAED;;;;;;GAMG;AACH,SAAgB,SAAS,CAAC,SAAiB;IACzC,MAAM,OAAO,GAAG,IAAA,eAAW,EAAC,SAAS,CAAC,CAAC;IAEvC,OAAO,CAAC,GAAW,EAAE,GAAG,IAAe,EAAE,EAAE;QACzC,MAAM,KAAK,GAAG,eAAe,EAAE,CAAC;QAChC,MAAM,MAAM,GAAG,KAAK,CAAC,CAAC,CAAC,IAAI,KAAK,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC;QAC1C,OAAO,CAAC,MAAM,GAAG,GAAG,EAAE,GAAG,IAAI,CAAC,CAAC;IACjC,CAAC,CAAC;AACJ,CAAC;AAED;;GAEG;AACH,SAAgB,mBAAmB,CACjC,UAA6B;IAE7B,MAAM,OAAO,GAAG,EAA0D,CAAC;IAC3E,KAAK,M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