Skip to content

Commit

Permalink
feat: read state file location from env vars
Browse files Browse the repository at this point in the history
  • Loading branch information
divyangchauhan committed Mar 9, 2024
1 parent a6ddc45 commit f90b660
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
4 changes: 3 additions & 1 deletion relayer-cli/.env.dist
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,6 @@ VEAOUTBOX_ARBGOERLI_TO_GOERLI_ADDRESS=0x906dE43dBef27639b1688Ac46532a16dc07Ce410
VEAOUTBOX_ARBGOERLI_TO_CHIADO_ADDRESS=0xAb53e341121448Ae259Da8fa17f216Cb0e21199C

TRANSACTION_BATCHER_CONTRACT_ADDRESS_GOERLI=0xe7953da7751063d0a41ba727c32c762d3523ade8
TRANSACTION_BATCHER_CONTRACT_ADDRESS_CHIADO=0xcC0a08D4BCC5f91ee9a1587608f7a2975EA75d73
TRANSACTION_BATCHER_CONTRACT_ADDRESS_CHIADO=0xcC0a08D4BCC5f91ee9a1587608f7a2975EA75d73

STATE_DIR="/home/user/vea/relayer-cli/state"
9 changes: 5 additions & 4 deletions relayer-cli/src/devnetRelayExample.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,17 +45,18 @@ async function initialize(chain_id: number): Promise<number> {
}
fs.writeFileSync(lock_file_name, process.pid.toString(), { encoding: "utf8" });

const state_file_name = "./state/" + chain_id + ".json";
const state_file_name_fs_check = "./src/state/" + chain_id + ".json";
if (!fs.existsSync(state_file_name_fs_check)) {
// STATE_DIR is absolute path of the directory where the state files are stored
// STATE_DIR must have trailing slash
const state_file = process.env.STATE_DIR + chain_id + ".json";
if (!fs.existsSync(state_file)) {
// No state file so initialize starting now
const tsnow = Math.floor(Date.now() / 1000);
await updateStateFile(chain_id, tsnow, 0);
}

// print pwd for debugging
console.log(process.cwd());
var chain_state = require(state_file_name);
var chain_state = require(state_file);

let nonce = 0;
if ("nonce" in chain_state) {
Expand Down

0 comments on commit f90b660

Please sign in to comment.