@aztec/ethereum 0.69.0-devnet → 0.69.1-devnet
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/dest/deploy_l1_contracts.js +3 -3
- package/dest/l1_tx_utils.d.ts +24 -9
- package/dest/l1_tx_utils.d.ts.map +1 -1
- package/dest/l1_tx_utils.js +154 -56
- package/dest/test/start_anvil.d.ts.map +1 -1
- package/dest/test/start_anvil.js +15 -8
- package/dest/test/tx_delayer.js +4 -4
- package/dest/utils.d.ts +2 -0
- package/dest/utils.d.ts.map +1 -1
- package/dest/utils.js +95 -2
- package/package.json +3 -4
- package/src/deploy_l1_contracts.ts +2 -2
- package/src/l1_tx_utils.ts +187 -65
- package/src/test/start_anvil.ts +17 -8
- package/src/test/tx_delayer.ts +3 -3
- package/src/utils.ts +109 -0
package/src/test/tx_delayer.ts
CHANGED
|
@@ -27,7 +27,7 @@ export function waitUntilBlock<T extends Client>(client: T, blockNumber: number
|
|
|
27
27
|
return currentBlockNumber >= BigInt(blockNumber);
|
|
28
28
|
},
|
|
29
29
|
`Wait until L1 block ${blockNumber}`,
|
|
30
|
-
|
|
30
|
+
120,
|
|
31
31
|
0.1,
|
|
32
32
|
);
|
|
33
33
|
}
|
|
@@ -52,7 +52,7 @@ export function waitUntilL1Timestamp<T extends Client>(client: T, timestamp: num
|
|
|
52
52
|
return currentTs >= BigInt(timestamp);
|
|
53
53
|
},
|
|
54
54
|
`Wait until L1 timestamp ${timestamp}`,
|
|
55
|
-
|
|
55
|
+
120,
|
|
56
56
|
0.1,
|
|
57
57
|
);
|
|
58
58
|
}
|
|
@@ -144,7 +144,7 @@ export function withDelayer<T extends WalletClient>(
|
|
|
144
144
|
return Promise.resolve(txHash);
|
|
145
145
|
} else {
|
|
146
146
|
const txHash = await client.sendRawTransaction(...args);
|
|
147
|
-
logger.
|
|
147
|
+
logger.verbose(`Sent tx immediately ${txHash}`);
|
|
148
148
|
delayer.txs.push(txHash);
|
|
149
149
|
return txHash;
|
|
150
150
|
}
|
package/src/utils.ts
CHANGED
|
@@ -3,7 +3,9 @@ import { type Logger } from '@aztec/foundation/log';
|
|
|
3
3
|
|
|
4
4
|
import {
|
|
5
5
|
type Abi,
|
|
6
|
+
BaseError,
|
|
6
7
|
type ContractEventName,
|
|
8
|
+
ContractFunctionRevertedError,
|
|
7
9
|
type DecodeEventLogReturnType,
|
|
8
10
|
type Hex,
|
|
9
11
|
type Log,
|
|
@@ -64,3 +66,110 @@ function tryExtractEvent<
|
|
|
64
66
|
}
|
|
65
67
|
}
|
|
66
68
|
}
|
|
69
|
+
|
|
70
|
+
export function prettyLogViemErrorMsg(err: any) {
|
|
71
|
+
if (err instanceof BaseError) {
|
|
72
|
+
const revertError = err.walk(err => err instanceof ContractFunctionRevertedError);
|
|
73
|
+
if (revertError instanceof ContractFunctionRevertedError) {
|
|
74
|
+
const errorName = revertError.data?.errorName ?? '';
|
|
75
|
+
const args =
|
|
76
|
+
revertError.metaMessages && revertError.metaMessages?.length > 1 ? revertError.metaMessages[1].trimStart() : '';
|
|
77
|
+
return `${errorName}${args}`;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
return err?.message ?? err;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
export function formatViemError(error: any): string {
|
|
84
|
+
const truncateHex = (hex: string, length = 100) => {
|
|
85
|
+
if (!hex || typeof hex !== 'string') {
|
|
86
|
+
return hex;
|
|
87
|
+
}
|
|
88
|
+
if (!hex.startsWith('0x')) {
|
|
89
|
+
return hex;
|
|
90
|
+
}
|
|
91
|
+
if (hex.length <= length * 2) {
|
|
92
|
+
return hex;
|
|
93
|
+
}
|
|
94
|
+
return `${hex.slice(0, length)}...${hex.slice(-length)}`;
|
|
95
|
+
};
|
|
96
|
+
|
|
97
|
+
const formatRequestBody = (body: string) => {
|
|
98
|
+
try {
|
|
99
|
+
const parsed = JSON.parse(body);
|
|
100
|
+
|
|
101
|
+
// Recursively process all parameters that might contain hex strings
|
|
102
|
+
const processParams = (obj: any): any => {
|
|
103
|
+
if (Array.isArray(obj)) {
|
|
104
|
+
return obj.map(item => processParams(item));
|
|
105
|
+
}
|
|
106
|
+
if (typeof obj === 'object' && obj !== null) {
|
|
107
|
+
const result: any = {};
|
|
108
|
+
for (const [key, value] of Object.entries(obj)) {
|
|
109
|
+
result[key] = processParams(value);
|
|
110
|
+
}
|
|
111
|
+
return result;
|
|
112
|
+
}
|
|
113
|
+
if (typeof obj === 'string') {
|
|
114
|
+
if (obj.startsWith('0x')) {
|
|
115
|
+
return truncateHex(obj);
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
return obj;
|
|
119
|
+
};
|
|
120
|
+
|
|
121
|
+
// Process the entire request body
|
|
122
|
+
const processed = processParams(parsed);
|
|
123
|
+
return JSON.stringify(processed, null, 2);
|
|
124
|
+
} catch {
|
|
125
|
+
return body;
|
|
126
|
+
}
|
|
127
|
+
};
|
|
128
|
+
|
|
129
|
+
const truncateHexStringsInText = (text: string): string => {
|
|
130
|
+
const hexRegex = /\b0x[a-fA-F0-9]{10,}/g;
|
|
131
|
+
return text.replace(hexRegex, hex => truncateHex(hex));
|
|
132
|
+
};
|
|
133
|
+
|
|
134
|
+
const extractAndFormatRequestBody = (message: string): string => {
|
|
135
|
+
// First handle Request body JSON
|
|
136
|
+
const requestBodyRegex = /Request body: ({[\s\S]*?})\n/g;
|
|
137
|
+
let result = message.replace(requestBodyRegex, (match, body) => {
|
|
138
|
+
return `Request body: ${formatRequestBody(body)}\n`;
|
|
139
|
+
});
|
|
140
|
+
|
|
141
|
+
// Then handle Arguments section
|
|
142
|
+
const argsRegex = /((?:Request |Estimate Gas )?Arguments:[\s\S]*?(?=\n\n|$))/g;
|
|
143
|
+
result = result.replace(argsRegex, section => {
|
|
144
|
+
const lines = section.split('\n');
|
|
145
|
+
const processedLines = lines.map(line => {
|
|
146
|
+
// Check if line contains a colon followed by content
|
|
147
|
+
const colonIndex = line.indexOf(':');
|
|
148
|
+
if (colonIndex !== -1) {
|
|
149
|
+
const [prefix, content] = [line.slice(0, colonIndex + 1), line.slice(colonIndex + 1).trim()];
|
|
150
|
+
// If content contains a hex string, truncate it
|
|
151
|
+
if (content.includes('0x')) {
|
|
152
|
+
const hexMatches = content.match(/0x[a-fA-F0-9]+/g) || [];
|
|
153
|
+
let processedContent = content;
|
|
154
|
+
hexMatches.forEach(hex => {
|
|
155
|
+
processedContent = processedContent.replace(hex, truncateHex(hex));
|
|
156
|
+
});
|
|
157
|
+
return `${prefix} ${processedContent}`;
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
return line;
|
|
161
|
+
});
|
|
162
|
+
return processedLines.join('\n');
|
|
163
|
+
});
|
|
164
|
+
|
|
165
|
+
// Finally, catch any remaining hex strings in the message
|
|
166
|
+
result = truncateHexStringsInText(result);
|
|
167
|
+
|
|
168
|
+
return result;
|
|
169
|
+
};
|
|
170
|
+
|
|
171
|
+
return JSON.stringify({ error: extractAndFormatRequestBody(error?.message || String(error)) }, null, 2).replace(
|
|
172
|
+
/\\n/g,
|
|
173
|
+
'\n',
|
|
174
|
+
);
|
|
175
|
+
}
|