From e42b54ddcbb49ac797c2d96c60ba4c0a5cf282a4 Mon Sep 17 00:00:00 2001 From: root Date: Fri, 21 Aug 2026 19:24:25 +0000 Subject: [PATCH] fix(scripts): support Vec<(Address, u32)> in invoke.mjs parseArg The release() contract function accepts recipients as Vec<(Address, u32)>, but parseArg() only handled scalar types (address, u32, i128). This made it impossible to invoke release or release_issue from the CLI. Adds vec-tuple-address-u32 type that parses a JSON array of [address, bps] pairs and encodes them as the correct Soroban ScVal tuple vector. Usage: node scripts/invoke.mjs release issue_id 'vec-tuple-address-u32:[["GADDR...",5000],["GADDR...",5000]]' Closes #156 --- scripts/invoke.mjs | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/scripts/invoke.mjs b/scripts/invoke.mjs index b7b912b..bc771c3 100644 --- a/scripts/invoke.mjs +++ b/scripts/invoke.mjs @@ -24,6 +24,24 @@ function parseArg(raw) { if (type === "address") return nativeToScVal(new Address(value), { type: "address" }); if (type === "u32") return nativeToScVal(parseInt(value, 10), { type: "u32" }); if (type === "i128") return nativeToScVal(BigInt(value), { type: "i128" }); + // Support Vec<(Address, u32)> for release() recipients parameter. + // Format: vec-tuple-address-u32:[["GADDR...",5000],["GADDR...",5000]] + if (type === "vec-tuple-address-u32") { + const parsed = JSON.parse(value); + if (!Array.isArray(parsed)) { + throw new Error("vec-tuple-address-u32 value must be a JSON array of [address, bps] pairs"); + } + const tuples = parsed.map((pair) => { + if (!Array.isArray(pair) || pair.length !== 2) { + throw new Error("Each element must be a 2-element array [address, bps]"); + } + return nativeToScVal( + [new Address(pair[0]), nativeToScVal(parseInt(pair[1], 10), { type: "u32" })], + { type: "tuple" } + ); + }); + return nativeToScVal(tuples, { type: "vec" }); + } throw new Error(`Unknown arg type: ${type}`); }