diff --git a/crypto/test-vectors/dump-test-vectors.sh b/crypto/test-vectors/dump-test-vectors.sh index dec202e4..a3c8c832 100755 --- a/crypto/test-vectors/dump-test-vectors.sh +++ b/crypto/test-vectors/dump-test-vectors.sh @@ -2,9 +2,12 @@ set -e +#Allows nix to provide the binary from a derivation +EXPORT_TEST_VECTORS=${EXPORT_TEST_VECTORS:="cargo run -p export_test_vectors --"} + pushd ../../../mina/src/lib/crypto/proof-systems/poseidon/export_test_vectors - cargo run -p export_test_vectors -- hex kimchi ../../../../../../../bindings/crypto/test-vectors/testVectors.json - cargo run -p export_test_vectors -- hex legacy ../../../../../../../bindings/crypto/test-vectors/testVectorsLegacy.json + $EXPORT_TEST_VECTORS hex kimchi ../../../../../../../bindings/crypto/test-vectors/testVectors.json + $EXPORT_TEST_VECTORS hex legacy ../../../../../../../bindings/crypto/test-vectors/testVectorsLegacy.json popd echo "// @gen this file is generated - don't edit it directly" > $1 diff --git a/scripts/update-o1js-bindings.sh b/scripts/update-o1js-bindings.sh index a5776eda..d2349ddc 100755 --- a/scripts/update-o1js-bindings.sh +++ b/scripts/update-o1js-bindings.sh @@ -13,6 +13,7 @@ WEB_BINDINGS="src/bindings/compiled/web_bindings" # 1. node build $DIR_PATH/build-o1js-node-artifacts.sh +cp src/bindings/compiled/_node_bindings/plonk_wasm.d.cts $NODE_BINDINGS/plonk_wasm.d.cts node src/build/copy-to-dist.js chmod -R 777 "$NODE_BINDINGS" @@ -24,17 +25,40 @@ cp "$BINDINGS_PATH"/plonk_wasm* "$NODE_BINDINGS"/ sed -i 's/plonk_wasm.js/plonk_wasm.cjs/' "$NODE_BINDINGS"/o1js_node.bc.cjs -npm run build +if [ -z $JUST_BINDINGS ] +then + npm run build +fi # 2. web build -cp "$BUILD_PATH/o1js_node.bc.map" "_build/o1js_node.bc.map" -dune b $DUNE_PATH/o1js_web.bc.js -cp "_build/o1js_node.bc.map" "$BUILD_PATH/o1js_node.bc.map" - -cp _build/default/$KIMCHI_BINDINGS/js/web/plonk_wasm* $WEB_BINDINGS/ -cp $BUILD_PATH/o1js_web*.js $WEB_BINDINGS/ -chmod -R 666 "$WEB_BINDINGS"/* +# Normally these variables are not defined +# But the nix build uses them +if [ -z $PREBUILT_KIMCHI_BINDINGS_JS_WEB ] || [ -z $PREBUILT_KIMCHI_BINDINGS_JS_NODE_JS ] +then + cp "$BUILD_PATH/o1js_node.bc.map" "_build/o1js_node.bc.map" + dune b $DUNE_PATH/o1js_web.bc.js + cp "_build/o1js_node.bc.map" "$BUILD_PATH/o1js_node.bc.map" + + cp _build/default/$KIMCHI_BINDINGS/js/web/plonk_wasm* $WEB_BINDINGS/ + cp $BUILD_PATH/o1js_web*.js $WEB_BINDINGS/ + chmod -R 666 "$WEB_BINDINGS"/* +else + mkdir -p $WEB_BINDINGS + cp $PREBUILT_KIMCHI_BINDINGS_JS_WEB/*.js \ + $PREBUILT_KIMCHI_BINDINGS_JS_WEB/*.ts \ + $PREBUILT_KIMCHI_BINDINGS_JS_WEB/*.wasm \ + $WEB_BINDINGS + mkdir -p $NODE_BINDINGS + cp $PREBUILT_KIMCHI_BINDINGS_JS_NODE_JS/*.js \ + $PREBUILT_KIMCHI_BINDINGS_JS_NODE_JS/*.ts \ + $PREBUILT_KIMCHI_BINDINGS_JS_NODE_JS/*.wasm \ + $NODE_BINDINGS + rm $NODE_BINDINGS/plonk_wasm.js \ + $NODE_BINDINGS/plonk_wasm.d.ts + dune b $DUNE_PATH/o1js_web.bc.js + cp $BUILD_PATH/o1js_web*.js $WEB_BINDINGS/ +fi # better error messages # `s` is the jsoo representation of the error message string, and `s.c` is the actual JS string @@ -51,12 +75,16 @@ pushd $WEB_BINDINGS mv o1js_web.bc.min.js o1js_web.bc.js popd -npm run build:web +if [ -z $JUST_BINDINGS ] +then + npm run build:web +fi # 3. update MINA_COMMIT file in o1js -pushd "$MINA_PATH" - MINA_COMMIT=$(git rev-parse HEAD) -popd +if [ -z $SKIP_MINA_COMMIT ] +then +MINA_COMMIT=$(git -C src/mina rev-parse HEAD) echo "The mina commit used to generate the backends for node and web is" "$MINA_COMMIT" \ > src/bindings/MINA_COMMIT +fi