Skip to content

Commit

Permalink
Get DA script from environment variable
Browse files Browse the repository at this point in the history
Before it would chdir, assuming it's in the source code,
and call `npx hardhat run ./scripts/<script>`.

Now we get the script from an environment variable.
The contents of the environment variable is passed to `/bin/sh`.
  • Loading branch information
L-as committed Apr 16, 2024
1 parent 16c3653 commit 4e3577c
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions src/app/zeko/sequencer/lib/da_layer.ml
Expand Up @@ -53,10 +53,14 @@ let post_batch (config : Config.t) ~commands ~batch_id ~previous_batch_id =
; ("commands", `List (List.map commands ~f:command_to_yojson))
] )
in
let stdin =
Core.Unix.open_process_out
"cd ../da-layer && npx hardhat run scripts/postBatch.ts"
let postBatchCmd =
match Sys.getenv "DA_POST_BATCH" with
| Some cmd ->
cmd
| None ->
"exec $cd ../da-layer && npx hardhat run scripts/postBatch.ts"
in
let stdin = Core.Unix.open_process_out postBatchCmd in
let pid = UnixLabels.process_out_pid stdin in
Out_channel.output_string stdin payload ;
Out_channel.close stdin ;
Expand All @@ -74,10 +78,14 @@ let get_batches (config : Config.t) ~to_ =
(`Assoc
[ ("address", `String da_contract_address); ("to", `String to_) ] )
in
let stdout, stdin =
Core.Unix.open_process
"cd ../da-layer && npx hardhat run scripts/getBatches.ts"
let getBatchesCmd =
match Sys.getenv "DA_GET_BATCHES" with
| Some cmd ->
cmd
| None ->
"exec $cd ../da-layer && npx hardhat run scripts/getBatches.ts"
in
let stdout, stdin = Core.Unix.open_process getBatchesCmd in
let pid = UnixLabels.process_pid (stdout, stdin) in
Out_channel.output_string stdin payload ;
Out_channel.close stdin ;
Expand Down

0 comments on commit 4e3577c

Please sign in to comment.