Skip to content

Commit

Permalink
feat: add debug mode to detect contextualiers
Browse files Browse the repository at this point in the history
  • Loading branch information
ponyjackal committed Apr 29, 2024
1 parent 6b496c6 commit 22fdc0e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/commands/detectContextualizers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export function registerDetectContextualizersCommand() {
console.log(`Fetching a transaction`);
transaction = await getTransaction(options.hash);

const txResult = contextualizer.contextualize(transaction);
const txResult = contextualizer.contextualize(transaction, true);
if (!txResult.from) {
console.error(
`No matching protocol contextualizer on ${transaction.hash}`,
Expand Down
13 changes: 9 additions & 4 deletions src/helpers/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -234,15 +234,20 @@ function formatSection(section: ContextSummaryVariableType) {
}

export const makeContextualize = (
children: Record<string, (transaction: Transaction) => Transaction>,
children: Record<
string,
(transaction: Transaction, isDebug: boolean) => Transaction
>,
) => {
return (transaction: Transaction): Transaction => {
return (transaction: Transaction, isDebug = false): Transaction => {
for (const [contextualizerName, childContextualizer] of Object.entries(
children,
)) {
const result = childContextualizer(transaction);
const result = childContextualizer(transaction, isDebug);
if (result.context?.summaries?.en.title) {
console.log('contextualizer: ', contextualizerName);
if (isDebug) {
console.log('contextualizer: ', contextualizerName);
}
return result;
}
}
Expand Down

0 comments on commit 22fdc0e

Please sign in to comment.