Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: improve error handling on shim #527

Merged
merged 1 commit into from
Feb 1, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions container/shim/src/bin/shim.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,20 @@ import { trapServer } from "../utils/trap.js";
if (!NODE_ID.match(/^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/)) {
debug("Invalid node ID, deleting node ID file");
await fs.unlink(NODE_ID_FILE_PATH);
throw new Error("Invalid node ID");
process.exit(1);
}

debug("Saturn L1 Node");
debug.extend("id")(NODE_ID);
debug.extend("version")(VERSION);

if (!validateAddressString(FIL_WALLET_ADDRESS)) throw new Error("Invalid wallet address");
if (!validateAddressString(FIL_WALLET_ADDRESS)) {
debug("Invalid wallet address, please update FIL_WALLET_ADDRESS environment variable");
process.exit(1);
}
if (!FIL_WALLET_ADDRESS.startsWith("f") && NETWORK === "main") {
throw new Error("Invalid testnet wallet address for Saturn Main Network");
debug("Invalid testnet wallet address for Saturn Main Network");
process.exit(1);
}

debug.extend("important")("===== IMPORTANT =====");
Expand All @@ -43,7 +47,7 @@ setTimeout(async function () {
await register(true).catch((err) => {
debug(`Failed to register ${err.name} ${err.message}`);
// we don't try again if we fail the initial registration
joaosa marked this conversation as resolved.
Show resolved Hide resolved
process.exit(0);
process.exit(1);
});
}

Expand Down
Loading