Skip to content

Commit cd5e886

Browse files
ludamadAztecBot
authored andcommitted
feat: ability to pin protocol contracts
Added a function to pin protocol contracts and create a tarball. Was already in v4
1 parent 7ea253c commit cd5e886

1 file changed

Lines changed: 23 additions & 0 deletions

File tree

noir-projects/noir-contracts/bootstrap.sh

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,13 @@ function build {
222222
rm -rf target
223223
mkdir -p $tmp_dir
224224
local contracts=$(grep -oP "(?<=$folder_name/)[^\"]+" Nargo.toml)
225+
226+
# If pinned contracts exist, extract them and skip their compilation.
227+
if [ -f pinned-protocol-contracts.tar.gz ]; then
228+
echo_stderr "Using pinned-protocol-contracts.tar.gz for pinned contracts."
229+
tar xzf pinned-protocol-contracts.tar.gz -C target
230+
contracts=$(echo "$contracts" | grep -vE "^protocol/|^fees/sponsored_fpc_contract$")
231+
fi
225232
else
226233
local contracts="$@"
227234
fi
@@ -285,6 +292,19 @@ function format {
285292
$NARGO fmt
286293
}
287294

295+
function pin-build {
296+
# Force a real build by removing any existing pinned archive.
297+
rm -f pinned-protocol-contracts.tar.gz
298+
local protocol_contracts=$(grep -oP '(?<=contracts/)[^"]+' Nargo.toml | grep "^protocol/")
299+
local fees_contracts=$(grep -oP '(?<=contracts/)[^"]+' Nargo.toml | grep "^fees/")
300+
build $protocol_contracts $fees_contracts
301+
# Bundle protocol contracts plus SponsoredFPC (FPC is excluded — only SponsoredFPC is pinned).
302+
local protocol_artifacts=$(jq -r '.[]' protocol_contracts.json | sed 's/$/.json/')
303+
echo_stderr "Creating pinned-protocol-contracts.tar.gz..."
304+
(cd target && tar czf ../pinned-protocol-contracts.tar.gz $protocol_artifacts sponsored_fpc_contract-SponsoredFPC.json)
305+
echo_stderr "Done. pinned-protocol-contracts.tar.gz created. Commit it to pin these artifacts."
306+
}
307+
288308
case "$cmd" in
289309
"clean-keys")
290310
for artifact in target/*.json; do
@@ -299,6 +319,9 @@ case "$cmd" in
299319
"compile")
300320
VERBOSE=${VERBOSE:-1} build "$@"
301321
;;
322+
"pin-build")
323+
pin-build
324+
;;
302325
*)
303326
default_cmd_handler "$@"
304327
;;

0 commit comments

Comments
 (0)