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 4e77dfe
Showing 1 changed file with 5 additions and 4 deletions.
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 4e77dfe

Please sign in to comment.