Skip to content

Commit 599a3d1

Browse files
committed
fix: TransferTo optional env
1 parent 19cab9b commit 599a3d1

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

scripts/setup-envs.js

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ const fs = require('fs');
1313
const path = require('path');
1414
const readline = require('readline');
1515

16-
const VARS = ['PRIVATE_KEY', 'CHAIN_RPC', 'PARENT_CHAIN_RPC', 'L1_RPC'];
16+
const VARS = ['PRIVATE_KEY', 'CHAIN_RPC', 'PARENT_CHAIN_RPC', 'L1_RPC', 'TransferTo'];
1717
const ARGS = new Set(process.argv.slice(2));
1818
const UPDATE_EXISTING = ARGS.has('--update');
1919

@@ -32,7 +32,7 @@ async function promptForValues() {
3232
const rl = readline.createInterface({ input: process.stdin, output: process.stdout });
3333
const ask = (q) => new Promise((res) => rl.question(q, (ans) => res(ans.trim())));
3434
for (const v of VARS) {
35-
const optional = v === 'L1_RPC';
35+
const optional = v === 'L1_RPC' || v === 'TransferTo';
3636
const existing = process.env[v] ? ` [default: ${process.env[v]}]` : '';
3737
const prompt = optional ? `${v} (optional)${existing}: ` : `${v}${existing}: `;
3838
const ans = await ask(prompt);
@@ -118,6 +118,13 @@ function validate(values) {
118118
if (values.L1_RPC && !/^https?:\/\/\S+$/i.test(String(values.L1_RPC))) {
119119
throw new Error('L1_RPC must be an http(s) URL if provided.');
120120
}
121+
if (values.TransferTo) {
122+
const addr = String(values.TransferTo).trim();
123+
if (!/^0x[a-fA-F0-9]{40}$/.test(addr)) {
124+
throw new Error('TransferTo must be a valid 0x-prefixed Ethereum address.');
125+
}
126+
values.TransferTo = addr;
127+
}
121128
}
122129

123130
async function main() {

0 commit comments

Comments
 (0)