@@ -12,9 +12,6 @@ dotenv.config();
1212
1313dayjs . extend ( utc ) ;
1414
15- const etherscanApiKey = process . env . PNK_DROP_ETHERSCAN_API_KEY ;
16- const alchemyApiKey = process . env . PNK_DROP_ALCHEMY_API_KEY ;
17-
1815const argv = yargs ( hideBin ( process . argv ) )
1916 . env ( "PNK_DROP" )
2017 . strict ( true )
@@ -59,6 +56,9 @@ const argv = yargs(hideBin(process.argv))
5956 . option ( "to-block" , {
6057 description : "The block to end the query for events" ,
6158 } )
59+ . option ( "json-rpc-url" , {
60+ description : "The JSON RPC URL to connect to" ,
61+ } )
6262 . option ( "infura-api-key" , {
6363 description : "The Infura API key" ,
6464 } )
@@ -76,7 +76,8 @@ const argv = yargs(hideBin(process.argv))
7676 } )
7777 . demand ( [ "kleros-liquid-address" , "period" , "amount" , "chain-id" , "start-date" , "end-date" ] )
7878 . boolean ( [ "save-s3" , "save-local" , "save-ipfs" ] )
79- . string ( [ "kleros-liquid-address" , "infura-api-key" , "etherscan-api-key" , "alchemy-api-key" ] )
79+ . string ( [ "kleros-liquid-address" , "json-rpc-url" , "infura-api-key" , "etherscan-api-key" , "alchemy-api-key" ] )
80+ . conflicts ( "json-rpc-url" , [ "infura-api-key" , "etherscan-api-key" , "alchemy-api-key" ] )
8081 . number ( [ "chain-id" , "from-block" , "to-block" , "period" ] )
8182 . coerce ( [ "amount" ] , ( value ) => utils . parseEther ( String ( value ) ) )
8283 . coerce ( [ "start-date" ] , ( value ) => dayjs . utc ( value ) . startOf ( "day" ) )
@@ -104,16 +105,21 @@ const {
104105 startDate,
105106 endDate,
106107 fromBlock,
108+ jsonRpcUrl,
107109 infuraApiKey,
110+ etherscanApiKey,
111+ alchemyApiKey,
108112} = normalizeArgs ( argv ) ;
109113
110114endDate . isBefore ( startDate ) && throwError ( new Error ( "End date cannot be before start date" ) ) ;
111115
112- const provider = getDefaultProvider ( chainId , {
113- etherscan : etherscanApiKey ,
114- alchemy : alchemyApiKey ,
115- infura : infuraApiKey ,
116- } ) ;
116+ const provider = jsonRpcUrl
117+ ? getDefaultProvider ( jsonRpcUrl )
118+ : getDefaultProvider ( chainId , {
119+ etherscan : etherscanApiKey ,
120+ alchemy : alchemyApiKey ,
121+ infura : infuraApiKey ,
122+ } ) ;
117123
118124( async ( ) => {
119125 try {
0 commit comments