Skip to content

Commit f385cf0

Browse files
committed
Enhance constructor argument processing in interaction_existing_contract.ts by improving whitespace and control character handling. Update sandbox workflow to strip ANSI codes from constructor args for cleaner output.
1 parent b4f2c63 commit f385cf0

File tree

2 files changed

+14
-5
lines changed

2 files changed

+14
-5
lines changed

.github/workflows/sandbox.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -138,8 +138,8 @@ jobs:
138138
PK_OUTGOING=$(grep -o "Master Outgoing Viewing: 0x[a-fA-F0-9]*" "$TEMP_OUTPUT" | head -1 | sed 's/Master Outgoing Viewing: //' || echo "")
139139
PK_TAGGING=$(grep -o "Master Tagging: 0x[a-fA-F0-9]*" "$TEMP_OUTPUT" | head -1 | sed 's/Master Tagging: //' || echo "")
140140
141-
# Extract constructor args (JSON array)
142-
CONSTRUCTOR_ARGS=$(grep "Constructor args:" "$TEMP_OUTPUT" | sed 's/.*Constructor args: //' || echo "")
141+
# Extract constructor args (JSON array), strip ANSI codes, and trim whitespace
142+
CONSTRUCTOR_ARGS=$(grep "Constructor args:" "$TEMP_OUTPUT" | sed 's/.*Constructor args: //' | sed 's/\x1b\[[0-9;]*m//g' | tr -d '\n\r' | sed 's/[[:space:]]*$//' || echo "")
143143
144144
rm "$TEMP_OUTPUT"
145145

scripts/interaction_existing_contract.ts

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,12 +52,21 @@ async function main() {
5252
// Parse constructor args
5353
let constructorArgs;
5454
try {
55-
// Remove any surrounding quotes that might have been added
56-
const cleanedJson = constructorArgsJson.trim().replace(/^['"]|['"]$/g, '');
55+
// Remove any surrounding quotes, whitespace, and control characters
56+
let cleanedJson = constructorArgsJson.trim();
57+
// Remove surrounding quotes (single or double)
58+
cleanedJson = cleanedJson.replace(/^['"]|['"]$/g, '');
59+
// Remove any trailing whitespace or control characters
60+
cleanedJson = cleanedJson.replace(/[\s\r\n]+$/, '');
61+
5762
logger.info(`Parsing constructor args: ${cleanedJson}`);
63+
logger.info(`Constructor args length: ${cleanedJson.length}`);
64+
5865
constructorArgs = JSON.parse(cleanedJson).map((arg: string) => AztecAddress.fromString(arg));
5966
} catch (error) {
60-
logger.error(`Failed to parse constructor args: ${constructorArgsJson}`);
67+
logger.error(`Failed to parse constructor args`);
68+
logger.error(`Raw value: ${JSON.stringify(constructorArgsJson)}`);
69+
logger.error(`Raw value length: ${constructorArgsJson.length}`);
6170
logger.error(`Error: ${error}`);
6271
throw error;
6372
}

0 commit comments

Comments
 (0)