@@ -13,7 +13,7 @@ const fs = require('fs');
1313const path = require ( 'path' ) ;
1414const 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' ] ;
1717const ARGS = new Set ( process . argv . slice ( 2 ) ) ;
1818const 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 && ! / ^ h t t p s ? : \/ \/ \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 ( ! / ^ 0 x [ a - f A - F 0 - 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
123130async function main ( ) {
0 commit comments