autrace 0.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/build/src/AccountUpdateAnalyzer.d.ts +17 -0
- package/build/src/AccountUpdateAnalyzer.js +88 -0
- package/build/src/AccountUpdateAnalyzer.js.map +1 -0
- package/build/src/AccountUpdateTrace.d.ts +16 -0
- package/build/src/AccountUpdateTrace.js +232 -0
- package/build/src/AccountUpdateTrace.js.map +1 -0
- package/build/src/AsciiVisualiser.d.ts +12 -0
- package/build/src/AsciiVisualiser.js +130 -0
- package/build/src/AsciiVisualiser.js.map +1 -0
- package/build/src/ContractAnalyser.d.ts +26 -0
- package/build/src/ContractAnalyser.js +171 -0
- package/build/src/ContractAnalyser.js.map +1 -0
- package/build/src/Interface.d.ts +172 -0
- package/build/src/Interface.js +2 -0
- package/build/src/Interface.js.map +1 -0
- package/build/src/Visualiser.d.ts +26 -0
- package/build/src/Visualiser.js +450 -0
- package/build/src/Visualiser.js.map +1 -0
- package/build/src/autrace.d.ts +27 -0
- package/build/src/autrace.js +335 -0
- package/build/src/autrace.js.map +1 -0
- package/build/src/index.d.ts +3 -0
- package/build/src/index.js +4 -0
- package/build/src/index.js.map +1 -0
- package/package.json +27 -0
@@ -0,0 +1,17 @@
|
|
1
|
+
import { AccountUpdate } from "o1js";
|
2
|
+
import { AccountUpdateRelationship } from "./Interface.js";
|
3
|
+
export declare class AccountUpdateAnalyzer {
|
4
|
+
private auRelationships;
|
5
|
+
private currentDepth;
|
6
|
+
private parentStack;
|
7
|
+
constructor();
|
8
|
+
processAccountUpdate(au: AccountUpdate): void;
|
9
|
+
private extractMethodInfo;
|
10
|
+
private extractStateChanges;
|
11
|
+
getRelationships(): Map<string, AccountUpdateRelationship>;
|
12
|
+
getHierarchicalView(): {
|
13
|
+
id: string;
|
14
|
+
label: string;
|
15
|
+
children: any[];
|
16
|
+
}[];
|
17
|
+
}
|
@@ -0,0 +1,88 @@
|
|
1
|
+
export class AccountUpdateAnalyzer {
|
2
|
+
constructor() {
|
3
|
+
this.currentDepth = 0;
|
4
|
+
this.parentStack = []; // Stack to track parent AUs
|
5
|
+
this.auRelationships = new Map();
|
6
|
+
}
|
7
|
+
processAccountUpdate(au) {
|
8
|
+
const auId = au.id.toString();
|
9
|
+
const callDepth = au.body.callDepth || 0;
|
10
|
+
// Manage parent stack based on call depth
|
11
|
+
while (this.currentDepth >= callDepth && this.parentStack.length > 0) {
|
12
|
+
this.parentStack.pop();
|
13
|
+
this.currentDepth--;
|
14
|
+
}
|
15
|
+
const parentId = this.parentStack.length > 0 ? this.parentStack[this.parentStack.length - 1] : undefined;
|
16
|
+
const methodInfo = this.extractMethodInfo(au);
|
17
|
+
// Create relationship entry
|
18
|
+
const relationship = {
|
19
|
+
id: auId,
|
20
|
+
label: au.label || 'Unnamed Update',
|
21
|
+
parentId,
|
22
|
+
children: [],
|
23
|
+
depth: callDepth,
|
24
|
+
method: this.extractMethodInfo(au),
|
25
|
+
stateChanges: this.extractStateChanges(au)
|
26
|
+
};
|
27
|
+
// Update parent's children array
|
28
|
+
if (parentId) {
|
29
|
+
const parentRelationship = this.auRelationships.get(parentId);
|
30
|
+
if (parentRelationship) {
|
31
|
+
parentRelationship.children.push(auId);
|
32
|
+
}
|
33
|
+
}
|
34
|
+
this.auRelationships.set(auId, relationship);
|
35
|
+
// Update stack for next iterations
|
36
|
+
this.parentStack.push(auId);
|
37
|
+
this.currentDepth = callDepth;
|
38
|
+
}
|
39
|
+
extractMethodInfo(au) {
|
40
|
+
if (!au.label)
|
41
|
+
return undefined;
|
42
|
+
const parts = au.label.split('.');
|
43
|
+
if (parts.length >= 2) {
|
44
|
+
return {
|
45
|
+
contract: parts[0],
|
46
|
+
name: parts[1].replace('()', '')
|
47
|
+
};
|
48
|
+
}
|
49
|
+
return undefined;
|
50
|
+
}
|
51
|
+
extractStateChanges(au) {
|
52
|
+
const changes = [];
|
53
|
+
if (au.body?.update?.appState) {
|
54
|
+
au.body.update.appState.forEach((state, index) => {
|
55
|
+
if (state) {
|
56
|
+
changes.push({
|
57
|
+
field: `appState[${index}]`,
|
58
|
+
value: state
|
59
|
+
});
|
60
|
+
}
|
61
|
+
});
|
62
|
+
}
|
63
|
+
return changes.length > 0 ? changes : undefined;
|
64
|
+
}
|
65
|
+
getRelationships() {
|
66
|
+
return this.auRelationships;
|
67
|
+
}
|
68
|
+
getHierarchicalView() {
|
69
|
+
// Get root level AUs (those without parents)
|
70
|
+
const roots = Array.from(this.auRelationships.values())
|
71
|
+
.filter(r => !r.parentId);
|
72
|
+
// Recursively build tree
|
73
|
+
const buildTree = (auRelationship) => {
|
74
|
+
return {
|
75
|
+
id: auRelationship.id,
|
76
|
+
label: auRelationship.label,
|
77
|
+
method: auRelationship.method,
|
78
|
+
stateChanges: auRelationship.stateChanges,
|
79
|
+
children: auRelationship.children.map(childId => {
|
80
|
+
const child = this.auRelationships.get(childId);
|
81
|
+
return child ? buildTree(child) : null;
|
82
|
+
}).filter(x => x)
|
83
|
+
};
|
84
|
+
};
|
85
|
+
return roots.map(root => buildTree(root));
|
86
|
+
}
|
87
|
+
}
|
88
|
+
//# sourceMappingURL=AccountUpdateAnalyzer.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"AccountUpdateAnalyzer.js","sourceRoot":"","sources":["../../src/AccountUpdateAnalyzer.ts"],"names":[],"mappings":"AAGA,MAAM,OAAO,qBAAqB;IAK9B;QAHQ,iBAAY,GAAW,CAAC,CAAC;QACzB,gBAAW,GAAa,EAAE,CAAC,CAAE,4BAA4B;QAG7D,IAAI,CAAC,eAAe,GAAG,IAAI,GAAG,EAAE,CAAC;IACrC,CAAC;IAEM,oBAAoB,CAAC,EAAiB;QACzC,MAAM,IAAI,GAAG,EAAE,CAAC,EAAE,CAAC,QAAQ,EAAE,CAAC;QAC9B,MAAM,SAAS,GAAG,EAAE,CAAC,IAAI,CAAC,SAAS,IAAI,CAAC,CAAC;QAEzC,0CAA0C;QAC1C,OAAO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AyC,EAAE,EAAE;YACjE,OAAO;gBACH,EAAE,EAAE,cAAc,CAAC,EAAE;gBACrB,KAAK,EAAE,cAAc,CAAC,KAAK;gBAC3B,MAAM,EAAE,cAAc,CAAC,MAAM;gBAC7B,YAAY,EAAE,cAAc,CAAC,YAAY;gBACzC,QAAQ,EAAE,cAAc,CAAC,QAAQ,CAAC,GAAG,CAAC,OAAO,CAAC,EAAE;oBAC5C,MAAM,KAAK,GAAG,IAAI,CAAC,eAAe,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;oBAChD,OAAO,KAAK,CAAC,CAAC,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;gBAC3C,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;aACpB,CAAC;QACN,CAAC,CAAC;QAEF,OAAO,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC;IAC9C,CAAC;CAEJ"}
|
@@ -0,0 +1,16 @@
|
|
1
|
+
import { TreeSnapshot, TreeOperation } from './Interface';
|
2
|
+
export declare class AccountUpdateTrace {
|
3
|
+
private snapshots;
|
4
|
+
private currentTree;
|
5
|
+
private getLeafNodeValue;
|
6
|
+
private traverseNodesRecursively;
|
7
|
+
private keysUpdated;
|
8
|
+
private deleteFromSet;
|
9
|
+
private keysRemoved;
|
10
|
+
private keysAdded;
|
11
|
+
private getLeafNodeValueRecursive;
|
12
|
+
private traverseFirstLevelNodes;
|
13
|
+
private compareAUTrees;
|
14
|
+
takeSnapshot(transaction: any, operation: TreeOperation): TreeSnapshot;
|
15
|
+
getSnapshots(): TreeSnapshot[];
|
16
|
+
}
|
@@ -0,0 +1,232 @@
|
|
1
|
+
import { PublicKey } from 'o1js';
|
2
|
+
export class AccountUpdateTrace {
|
3
|
+
constructor() {
|
4
|
+
this.snapshots = [];
|
5
|
+
this.getLeafNodeValue = (tree, key) => {
|
6
|
+
//console.log(tree)
|
7
|
+
if (typeof tree !== 'object' || tree === null) {
|
8
|
+
return undefined;
|
9
|
+
}
|
10
|
+
if (tree.hasOwnProperty(key)) {
|
11
|
+
return tree[key];
|
12
|
+
}
|
13
|
+
};
|
14
|
+
this.traverseNodesRecursively = (tree) => {
|
15
|
+
const keys = new Set();
|
16
|
+
for (const key in tree) {
|
17
|
+
keys.add(key);
|
18
|
+
if (typeof tree[key] === 'object' && tree[key] !== null && !Array.isArray(tree[key])) {
|
19
|
+
const childKeys = this.traverseNodesRecursively(tree[key]);
|
20
|
+
for (const childKey of childKeys) {
|
21
|
+
keys.add(`${key}.${childKey}`); // Use dot notation for nested keys
|
22
|
+
}
|
23
|
+
}
|
24
|
+
}
|
25
|
+
return keys;
|
26
|
+
};
|
27
|
+
this.keysUpdated = (a, b, keyList) => {
|
28
|
+
const keysUpdatedList = [];
|
29
|
+
for (const key of keyList) {
|
30
|
+
let oldValue = this.getLeafNodeValue(a, key);
|
31
|
+
//console.log(`OLD VALUE ${key}: `, oldValue)
|
32
|
+
let newValue = this.getLeafNodeValue(b, key);
|
33
|
+
//console.log(`NEW VALUE ${key}: `, newValue)
|
34
|
+
//console.log(`Type of ${key}: `, typeof(newValue))
|
35
|
+
if (oldValue instanceof PublicKey && newValue instanceof PublicKey) {
|
36
|
+
oldValue = oldValue.toBase58();
|
37
|
+
newValue = newValue.toBase58();
|
38
|
+
//console.log('Public key old value: ', oldValue)
|
39
|
+
//console.log('Public key new value: ', newValue)
|
40
|
+
}
|
41
|
+
if (newValue !== oldValue) {
|
42
|
+
keysUpdatedList.push({
|
43
|
+
field: key,
|
44
|
+
oldValue: oldValue,
|
45
|
+
newValue: newValue
|
46
|
+
});
|
47
|
+
}
|
48
|
+
}
|
49
|
+
return keysUpdatedList;
|
50
|
+
};
|
51
|
+
this.deleteFromSet = (set, toDelete) => {
|
52
|
+
for (const item of toDelete) {
|
53
|
+
set.delete(item);
|
54
|
+
}
|
55
|
+
return set;
|
56
|
+
};
|
57
|
+
this.keysRemoved = (a, b) => {
|
58
|
+
let keysRemovedList = [];
|
59
|
+
for (const key of a) {
|
60
|
+
if (!b.has(key)) {
|
61
|
+
keysRemovedList.push(key);
|
62
|
+
}
|
63
|
+
}
|
64
|
+
return keysRemovedList;
|
65
|
+
};
|
66
|
+
this.keysAdded = (a, b) => {
|
67
|
+
let keysAddedList = [];
|
68
|
+
for (const key of b) {
|
69
|
+
if (!a.has(key)) {
|
70
|
+
keysAddedList.push(key);
|
71
|
+
}
|
72
|
+
}
|
73
|
+
return keysAddedList;
|
74
|
+
};
|
75
|
+
this.getLeafNodeValueRecursive = (tree, key) => {
|
76
|
+
const keyParts = key.split('.');
|
77
|
+
let value = tree;
|
78
|
+
for (const part of keyParts) {
|
79
|
+
if (value && typeof value === 'object' && part in value) {
|
80
|
+
value = value[part];
|
81
|
+
}
|
82
|
+
else {
|
83
|
+
return undefined; // Key not found
|
84
|
+
}
|
85
|
+
}
|
86
|
+
return value;
|
87
|
+
};
|
88
|
+
this.traverseFirstLevelNodes = (tree) => {
|
89
|
+
const firstLevelKeys = Object.keys(tree);
|
90
|
+
//console.log('First-Level Keys:', firstLevelKeys);
|
91
|
+
return firstLevelKeys;
|
92
|
+
};
|
93
|
+
/*private compareTxnTree = (treeA: any, treeB: any): ChangeLog => {
|
94
|
+
const changes: ChangeLog = {
|
95
|
+
added: [], removed: [], updated: []
|
96
|
+
}
|
97
|
+
|
98
|
+
const keysTreeA = this.traverseFirstLevelNodes(treeA)
|
99
|
+
const keysTreeB = this.traverseFirstLevelNodes(treeB)
|
100
|
+
|
101
|
+
for ( const key of keysTreeB ) {
|
102
|
+
if ( key === 'accountUpdates') {
|
103
|
+
const oldAUTree = this.getLeafNodeValue(treeA, key)
|
104
|
+
const newAUtree = this.getLeafNodeValue(treeB, key)
|
105
|
+
this.compareAUTrees(oldAUTree, newAUtree)
|
106
|
+
}
|
107
|
+
const oldValue = this.getLeafNodeValue(treeA, key)
|
108
|
+
const newValue = this.getLeafNodeValue(treeB, key)
|
109
|
+
if ( oldValue !== newValue ) {
|
110
|
+
changes.updated.push({
|
111
|
+
path: 'transaction',
|
112
|
+
changes: [{
|
113
|
+
field: key,
|
114
|
+
oldValue: oldValue,
|
115
|
+
newValue: newValue
|
116
|
+
}]
|
117
|
+
})
|
118
|
+
}
|
119
|
+
}
|
120
|
+
return changes
|
121
|
+
}*/
|
122
|
+
this.compareAUTrees = (oldAUArray, newAUArray, path = 'accountUpdate'
|
123
|
+
//path: string = 'transaction'
|
124
|
+
) => {
|
125
|
+
const changes = {
|
126
|
+
added: [], removed: [], updated: []
|
127
|
+
};
|
128
|
+
const validOldAUArray = Array.isArray(oldAUArray) ? oldAUArray : [];
|
129
|
+
const validNewAUArray = Array.isArray(newAUArray) ? newAUArray : [];
|
130
|
+
const oldAUMap = new Map((validOldAUArray || []).map((node) => [node.id, node]));
|
131
|
+
const newAUMap = new Map((validNewAUArray || []).map((node) => [node.id, node]));
|
132
|
+
const compareAUItemsRecursive = (a, b, path) => {
|
133
|
+
const keysA = this.traverseNodesRecursively(a);
|
134
|
+
const keysB = this.traverseNodesRecursively(b);
|
135
|
+
//console.log('Keys A: ',keysA)
|
136
|
+
//console.log('Keys B: ',keysB)
|
137
|
+
const keysRemovedList = this.keysRemoved(keysA, keysB);
|
138
|
+
for (const key of keysRemovedList) {
|
139
|
+
const value = this.getLeafNodeValueRecursive(a, key);
|
140
|
+
changes.removed.push({
|
141
|
+
path: `${path}.${key}`,
|
142
|
+
node: { key, value }
|
143
|
+
});
|
144
|
+
}
|
145
|
+
const keysAddedList = this.keysAdded(keysA, keysB);
|
146
|
+
for (const key of keysAddedList) {
|
147
|
+
let value;
|
148
|
+
if (key.includes('proof')) {
|
149
|
+
value = this.getLeafNodeValueRecursive(b, key);
|
150
|
+
//console.log('Value: ', value)
|
151
|
+
if (value.length > 50) {
|
152
|
+
value = `${value.slice(0, 50)}...`;
|
153
|
+
}
|
154
|
+
}
|
155
|
+
else {
|
156
|
+
value = this.getLeafNodeValueRecursive(b, key);
|
157
|
+
}
|
158
|
+
changes.added.push({
|
159
|
+
path: `${path}.${key}`,
|
160
|
+
node: { key, value }
|
161
|
+
});
|
162
|
+
}
|
163
|
+
let keysB_modified = keysB;
|
164
|
+
keysB_modified = this.deleteFromSet(keysB_modified, keysAddedList);
|
165
|
+
const keysUpdatedList = this.keysUpdated(a, b, keysB_modified);
|
166
|
+
for (const { field, oldValue, newValue } of keysUpdatedList) {
|
167
|
+
if (typeof oldValue === 'function' || typeof newValue === 'function') {
|
168
|
+
continue;
|
169
|
+
}
|
170
|
+
if (typeof oldValue !== 'object' || typeof newValue !== 'object') {
|
171
|
+
/*console.log('Field: ', field)*/
|
172
|
+
//console.log('Old Value: ', oldValue)
|
173
|
+
//console.log('New Value: ', newValue)
|
174
|
+
changes.updated.push({
|
175
|
+
path: `${path}.${field}`,
|
176
|
+
changes: [{
|
177
|
+
field,
|
178
|
+
oldValue,
|
179
|
+
newValue: newValue === undefined ? {} : newValue
|
180
|
+
}],
|
181
|
+
});
|
182
|
+
}
|
183
|
+
else {
|
184
|
+
compareAUItemsRecursive(oldValue, newValue, `${path}.${field}`);
|
185
|
+
}
|
186
|
+
}
|
187
|
+
};
|
188
|
+
// Find removed and updated elements
|
189
|
+
if (Array.isArray(oldAUArray) && oldAUArray.length > 0) {
|
190
|
+
for (const oldAUArrayItem of oldAUArray) {
|
191
|
+
const currentPath = `${path}[${oldAUArray.indexOf(oldAUArrayItem)}]`;
|
192
|
+
if (!newAUMap.has(oldAUArrayItem.id)) {
|
193
|
+
changes.removed.push({
|
194
|
+
path: currentPath,
|
195
|
+
node: oldAUArrayItem
|
196
|
+
});
|
197
|
+
}
|
198
|
+
else {
|
199
|
+
const newAUArrayItem = newAUMap.get(oldAUArrayItem.id);
|
200
|
+
//compareAUItems(oldAUArrayItem, newAUArrayItem, currentPath)
|
201
|
+
compareAUItemsRecursive(oldAUArrayItem, newAUArrayItem, currentPath);
|
202
|
+
}
|
203
|
+
}
|
204
|
+
}
|
205
|
+
for (const newAUArrayItem of newAUArray) {
|
206
|
+
const currentPath = `${path}[${newAUArray.indexOf(newAUArrayItem)}]`;
|
207
|
+
if (!oldAUMap.has(newAUArrayItem.id)) {
|
208
|
+
changes.added.push({
|
209
|
+
path: currentPath,
|
210
|
+
node: newAUArrayItem
|
211
|
+
});
|
212
|
+
}
|
213
|
+
}
|
214
|
+
return changes;
|
215
|
+
};
|
216
|
+
}
|
217
|
+
takeSnapshot(transaction, operation) {
|
218
|
+
const snapshot = {
|
219
|
+
operation,
|
220
|
+
timestamp: Date.now(),
|
221
|
+
tree: transaction,
|
222
|
+
changes: this.compareAUTrees(this.currentTree, transaction)
|
223
|
+
};
|
224
|
+
this.snapshots.push(snapshot);
|
225
|
+
this.currentTree = transaction;
|
226
|
+
return snapshot;
|
227
|
+
}
|
228
|
+
getSnapshots() {
|
229
|
+
return this.snapshots;
|
230
|
+
}
|
231
|
+
}
|
232
|
+
//# sourceMappingURL=AccountUpdateTrace.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"AccountUpdateTrace.js","sourceRoot":"","sources":["../../src/AccountUpdateTrace.ts"],"names":[],"mappings":"AAAA,OAAO,EAAiB,SAAS,EAAc,MAAM,MAAM,CAAC;AAG5D,MAAM,OAAO,kBAAkB;IAA/B;QACY,cAAS,GAAmB,EAAE,CAAC;QAI/B,qBAAgB,GAAG,CAAC,IAAS,EAAE,GAAW,EAAO,EAAE;YACvD,mBAAmB;YACnB,IAAI,OAAO,IAAI,KAAK,QAAQ,IAAI,IAAI,KAAK,IAAI,EAAE,CAAC;gBAC9C,OAAO,SAAS,CAAC;YACnB,CAAC;YAED,IAAI,IAAI,CAAC,cAAc,CAAC,GAAG,CAAC,EAAE,CAAC;gBAC7B,OAAO,IAAI,CAAC,GAAG,CAAC,CAAA;YAClB,CAAC;QACL,CAAC,CAAA;QAEO,6BAAwB,GAAG,CAAC,IAAS,EAAe,EAAE;YAC1D,MAAM,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AC,IAAI,CAAC,WAAW,EAAE,WAAW,CAAC;SAC9D,CAAC;QAEF,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QAC9B,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC;QAC/B,OAAO,QAAQ,CAAC;IACpB,CAAC;IAEM,YAAY;QACf,OAAO,IAAI,CAAC,SAAS,CAAC;IAC1B,CAAC;CACJ"}
|
@@ -0,0 +1,12 @@
|
|
1
|
+
import { TreeSnapshot } from "./Interface";
|
2
|
+
export declare class ASCIITreeVisualizer {
|
3
|
+
private readonly INDENT;
|
4
|
+
private readonly COLORS;
|
5
|
+
private readonly SYMBOLS;
|
6
|
+
private formatValue;
|
7
|
+
private stringifyWithBigInt;
|
8
|
+
private visualizeChanges;
|
9
|
+
visualizeChangeSummary(snapshots: TreeSnapshot[]): string;
|
10
|
+
private formatHeader;
|
11
|
+
private formatPhase;
|
12
|
+
}
|
@@ -0,0 +1,130 @@
|
|
1
|
+
export class ASCIITreeVisualizer {
|
2
|
+
constructor() {
|
3
|
+
this.INDENT = ' ';
|
4
|
+
this.COLORS = {
|
5
|
+
reset: '\x1b[0m',
|
6
|
+
green: '\x1b[32m',
|
7
|
+
red: '\x1b[31m',
|
8
|
+
blue: '\x1b[34m',
|
9
|
+
yellow: '\x1b[33m',
|
10
|
+
purple: '\x1b[35m',
|
11
|
+
gray: '\x1b[90m',
|
12
|
+
white: '\x1b[37m',
|
13
|
+
bold: '\x1b[1m'
|
14
|
+
};
|
15
|
+
this.SYMBOLS = {
|
16
|
+
added: '+',
|
17
|
+
removed: '-',
|
18
|
+
modified: '•',
|
19
|
+
arrow: '→',
|
20
|
+
bullet: '∙',
|
21
|
+
branch: '├',
|
22
|
+
leaf: '└',
|
23
|
+
vertical: '│',
|
24
|
+
};
|
25
|
+
this.stringifyWithBigInt = (obj) => {
|
26
|
+
return JSON.stringify(obj, (key, value) => (typeof value === 'bigint' ? value.toString() : value));
|
27
|
+
};
|
28
|
+
}
|
29
|
+
formatValue(value) {
|
30
|
+
if (value === null || value === undefined)
|
31
|
+
return 'null';
|
32
|
+
if (Array.isArray(value)) {
|
33
|
+
return `[${value.map(v => this.formatValue(v)).join(', ')}]`;
|
34
|
+
}
|
35
|
+
if (typeof value === 'object') {
|
36
|
+
if (value._value !== undefined) {
|
37
|
+
return value._value.toString();
|
38
|
+
}
|
39
|
+
// Handle special cases
|
40
|
+
if (value.hash) {
|
41
|
+
return `{hash: "${value.hash.substring(0, 8)}..."}`;
|
42
|
+
}
|
43
|
+
const str = JSON.stringify(value);
|
44
|
+
if (str.length > 50) {
|
45
|
+
return `${str.substring(0, 47)}...`;
|
46
|
+
}
|
47
|
+
return str;
|
48
|
+
}
|
49
|
+
const str = value.toString();
|
50
|
+
if (str.length > 50) {
|
51
|
+
if (str.startsWith('B62')) {
|
52
|
+
return `${str.substring(0, 8)}...`;
|
53
|
+
}
|
54
|
+
return `${str.substring(0, 47)}...`;
|
55
|
+
}
|
56
|
+
return str;
|
57
|
+
}
|
58
|
+
visualizeChanges(changes) {
|
59
|
+
let result = '';
|
60
|
+
if (changes.added.length > 0) {
|
61
|
+
result += `${this.COLORS.green}${this.SYMBOLS.branch} Added:${this.COLORS.reset}\n`;
|
62
|
+
changes.added.forEach((item, i) => {
|
63
|
+
const isLast = i === changes.added.length - 1;
|
64
|
+
const prefix = isLast ? this.SYMBOLS.leaf : this.SYMBOLS.branch;
|
65
|
+
result += `${this.COLORS.green}${prefix} ${this.SYMBOLS.added} ${item.path}${this.COLORS.reset}\n`;
|
66
|
+
const addPrefix = isLast ? this.SYMBOLS.leaf : this.SYMBOLS.branch;
|
67
|
+
result += `${this.COLORS.green} ${addPrefix} ${this.stringifyWithBigInt(item.node)} ${this.COLORS.reset}\n`;
|
68
|
+
});
|
69
|
+
}
|
70
|
+
if (changes.updated.length > 0) {
|
71
|
+
if (changes.added.length > 0)
|
72
|
+
result += '\n';
|
73
|
+
result += `${this.COLORS.yellow}${this.SYMBOLS.branch} Modified:${this.COLORS.reset}\n`;
|
74
|
+
changes.updated.forEach((mod, i) => {
|
75
|
+
const isLast = i === changes.updated.length - 1;
|
76
|
+
const prefix = isLast ? this.SYMBOLS.leaf : this.SYMBOLS.branch;
|
77
|
+
result += `${this.COLORS.yellow}${prefix} ${this.SYMBOLS.modified} ${mod.path}${this.COLORS.reset}\n`;
|
78
|
+
mod.changes.forEach((change, j) => {
|
79
|
+
const changePrefix = j === mod.changes.length - 1 ? this.SYMBOLS.leaf : this.SYMBOLS.branch;
|
80
|
+
result += `${this.COLORS.gray} ${changePrefix} ${change.field}: ${this.COLORS.reset}` +
|
81
|
+
`${this.formatValue(change.oldValue)} ${this.SYMBOLS.arrow} ${this.formatValue(change.newValue)}\n`;
|
82
|
+
});
|
83
|
+
});
|
84
|
+
}
|
85
|
+
if (changes.removed.length > 0) {
|
86
|
+
if (changes.added.length > 0 || changes.updated.length > 0)
|
87
|
+
result += '\n';
|
88
|
+
result += `${this.COLORS.red}${this.SYMBOLS.branch} Removed:${this.COLORS.reset}\n`;
|
89
|
+
changes.removed.forEach((item, i) => {
|
90
|
+
const isLast = i === changes.removed.length - 1;
|
91
|
+
const prefix = isLast ? this.SYMBOLS.leaf : this.SYMBOLS.branch;
|
92
|
+
result += `${this.COLORS.red}${prefix} ${this.SYMBOLS.removed} ${item.path}${this.COLORS.reset}\n`;
|
93
|
+
const removePrefix = i === changes.removed.length - 1 ? this.SYMBOLS.leaf : this.SYMBOLS.branch;
|
94
|
+
result += `${this.COLORS.red} ${removePrefix} ${this.stringifyWithBigInt(item.node)} ${this.COLORS.reset}\n`;
|
95
|
+
//result += `${this.COLORS.red}${prefix} ${this.SYMBOLS.removed} ${item}${this.COLORS.reset}\n`;
|
96
|
+
});
|
97
|
+
}
|
98
|
+
return result;
|
99
|
+
}
|
100
|
+
visualizeChangeSummary(snapshots) {
|
101
|
+
let result = this.formatHeader('Transaction Evolution Summary');
|
102
|
+
snapshots.forEach((snapshot, index) => {
|
103
|
+
result += this.formatPhase(snapshot.operation, snapshot.timestamp);
|
104
|
+
if (index === 0) {
|
105
|
+
const accountUpdates = Array.isArray(snapshot.tree) ? snapshot.tree.length : 0;
|
106
|
+
result += `${this.COLORS.gray}${this.SYMBOLS.bullet} Created transaction with ${accountUpdates} account updates${this.COLORS.reset}\n`;
|
107
|
+
}
|
108
|
+
else {
|
109
|
+
const hasChanges = Object.values(snapshot.changes).some(arr => arr.length > 0);
|
110
|
+
if (hasChanges) {
|
111
|
+
result += this.visualizeChanges(snapshot.changes);
|
112
|
+
}
|
113
|
+
else {
|
114
|
+
result += `${this.COLORS.gray}${this.SYMBOLS.bullet} No changes${this.COLORS.reset}\n`;
|
115
|
+
}
|
116
|
+
}
|
117
|
+
result += '\n';
|
118
|
+
});
|
119
|
+
return result;
|
120
|
+
}
|
121
|
+
formatHeader(text) {
|
122
|
+
const line = '═'.repeat(text.length + 4);
|
123
|
+
return `${this.COLORS.blue}╔${line}╗\n║ ${text} ║\n╚${line}╝${this.COLORS.reset}\n`;
|
124
|
+
}
|
125
|
+
formatPhase(phase, timestamp) {
|
126
|
+
const date = new Date(timestamp).toLocaleTimeString();
|
127
|
+
return `${this.COLORS.bold}${this.COLORS.purple}▶ ${phase.toUpperCase()} ${this.COLORS.gray}(${date})${this.COLORS.reset}\n`;
|
128
|
+
}
|
129
|
+
}
|
130
|
+
//# sourceMappingURL=AsciiVisualiser.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"AsciiVisualiser.js","sourceRoot":"","sources":["../../src/AsciiVisualiser.ts"],"names":[],"mappings":"AAGA,MAAM,OAAO,mBAAmB;IAAhC;QACqB,WAAM,GAAG,IAAI,CAAC;QACd,WAAM,GAAG;YACtB,KAAK,EAAE,SAAS;YAChB,KAAK,EAAE,UAAU;YACjB,GAAG,EAAE,UAAU;YACf,IAAI,EAAE,UAAU;YAChB,MAAM,EAAE,UAAU;YAClB,MAAM,EAAE,UAAU;YAClB,IAAI,EAAE,UAAU;YAChB,KAA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@@
|
|
1
|
+
import { SmartContract } from "o1js";
|
2
|
+
import { ContractAnalysis } from "./Interface.js";
|
3
|
+
export declare class SmartContractAnalyzer {
|
4
|
+
private contracts;
|
5
|
+
constructor();
|
6
|
+
analyzeContractInstance: (instance: SmartContract) => void;
|
7
|
+
getContracts(): Map<string, ContractAnalysis>;
|
8
|
+
getContract(contractName: string): ContractAnalysis | undefined;
|
9
|
+
private extractStateFields;
|
10
|
+
private extractMethods;
|
11
|
+
private extractChildCalls;
|
12
|
+
private extractStateChanges;
|
13
|
+
private extractPermissions;
|
14
|
+
buildRelationshipGraph: () => Map<string, {
|
15
|
+
parents: string[];
|
16
|
+
children: Array<{
|
17
|
+
contract?: string;
|
18
|
+
method: string;
|
19
|
+
}>;
|
20
|
+
stateAccess: Array<{
|
21
|
+
field: string;
|
22
|
+
operations: ("get" | "set")[];
|
23
|
+
}>;
|
24
|
+
state: string;
|
25
|
+
}>;
|
26
|
+
}
|