@@ -49,87 +49,40 @@ task(TASK_RUN).setAction(async (args, hre, runSuper) => {
4949 } ,
5050 hre . hardhatArguments ,
5151 path . resolve ( args . script ) ,
52- )
53- } )
52+ ) ;
53+ } ) ;
5454
55- subtask ( TASK_NODE_POLKAVM_CREATE_SERVER , "Creates a JSON-RPC server for PolkaVM node" )
56- . addOptionalParam ( "nodePath" , "Path to the node binary file" , undefined , types . string )
57- . addOptionalParam (
58- "adapterPath" ,
59- "Path to the Eth Rpc Adapter binary file" ,
60- undefined ,
61- types . string ,
62- )
55+ subtask ( TASK_NODE_POLKAVM_CREATE_SERVER , 'Creates a JSON-RPC server for PolkaVM node' )
56+ . addOptionalParam ( 'nodePath' , 'Path to the node binary file' , undefined , types . string )
57+ . addOptionalParam ( 'adapterPath' , 'Path to the Eth Rpc Adapter binary file' , undefined , types . string )
6358 . setAction ( async ( { nodePath, adapterPath } : { nodePath : string ; adapterPath : string } ) => {
64- const server : JsonRpcServer = new JsonRpcServer ( nodePath , adapterPath )
65- return server
66- } )
59+ const server : JsonRpcServer = new JsonRpcServer ( nodePath , adapterPath ) ;
60+ return server ;
61+ } ) ;
6762
68- task ( TASK_NODE , "Start a PolkaVM Node" ) . setAction (
69- async ( args : TaskArguments , { network, run } , runSuper ) => {
70- if ( network . polkavm !== true || network . name !== HARDHAT_NETWORK_NAME ) {
71- return await runSuper ( )
72- }
63+ task ( TASK_NODE , 'Start a PolkaVM Node' ) . setAction ( async ( args : TaskArguments , { network, run } , runSuper ) => {
64+ if ( network . polkavm !== true || network . name !== HARDHAT_NETWORK_NAME ) {
65+ return await runSuper ( ) ;
66+ }
7367
74- await run ( TASK_NODE_POLKAVM , args )
75- } ,
76- )
68+ await run ( TASK_NODE_POLKAVM , args ) ;
69+ } ) ;
7770
78- task ( TASK_NODE_POLKAVM , "Starts a JSON-RPC server for PolkaVM node" )
79- . addOptionalParam (
80- "nodeBinaryPath" ,
81- "Path to the substrate node binary" ,
82- undefined ,
83- types . string ,
84- )
85- . addOptionalParam (
86- "rpcPort" ,
87- "Port where the node will listen on - default: 8000" ,
88- undefined ,
89- types . int ,
90- )
91- . addOptionalParam (
92- "adapterBinaryPath" ,
93- "Path to the eth-rpc-adapter binary" ,
94- undefined ,
95- types . string ,
96- )
97- . addOptionalParam (
98- "adapterEndpoint" ,
99- "Endpoint to which the adapter will connect to - default: ws://localhost:8000" ,
100- undefined ,
101- types . string ,
102- )
103- . addOptionalParam (
104- "adapterPort" ,
105- "Port where the adapter will listen on - default: 8545 " ,
106- undefined ,
107- types . int ,
108- )
109- . addOptionalParam (
110- "dev" ,
111- "Whether to run the adapter in dev mode - default: false" ,
112- undefined ,
113- types . boolean ,
114- )
115- . addOptionalParam (
116- "buildBlockMode" ,
117- "Build block mode for @acala-network/chopsticks" ,
118- undefined ,
119- types . string ,
120- )
121- . addOptionalParam (
122- "fork" ,
123- "Endpoint to fork a live chain using @acala-network/chopsticks" ,
124- undefined ,
125- types . string ,
126- )
71+ task ( TASK_NODE_POLKAVM , 'Starts a JSON-RPC server for PolkaVM node' )
72+ . addOptionalParam ( 'nodeBinaryPath' , 'Path to the substrate node binary' , undefined , types . string )
73+ . addOptionalParam ( 'rpcPort' , 'Port where the node will listen on - default: 8000' , undefined , types . int )
74+ . addOptionalParam ( 'adapterBinaryPath' , 'Path to the eth-rpc-adapter binary' , undefined , types . string )
12775 . addOptionalParam (
128- "forkBlockNumber" ,
129- "Block hash or block number from where to fork" ,
76+ 'adapterEndpoint' ,
77+ 'Endpoint to which the adapter will connect to - default: ws://localhost:8000' ,
13078 undefined ,
13179 types . string ,
13280 )
81+ . addOptionalParam ( 'adapterPort' , 'Port where the adapter will listen on - default: 8545 ' , undefined , types . int )
82+ . addOptionalParam ( 'dev' , 'Whether to run the adapter in dev mode - default: false' , undefined , types . boolean )
83+ . addOptionalParam ( 'buildBlockMode' , 'Build block mode for @acala-network/chopsticks' , undefined , types . string )
84+ . addOptionalParam ( 'fork' , 'Endpoint to fork a live chain using @acala-network/chopsticks' , undefined , types . string )
85+ . addOptionalParam ( 'forkBlockNumber' , 'Block hash or block number from where to fork' , undefined , types . string )
13386 . setAction (
13487 async (
13588 {
@@ -143,15 +96,15 @@ task(TASK_NODE_POLKAVM, "Starts a JSON-RPC server for PolkaVM node")
14396 fork,
14497 forkBlockNumber,
14598 } : {
146- nodeBinaryPath : string
147- rpcPort : number
148- adapterBinaryPath : string
149- adapterEndpoint : string
150- adapterPort : number
151- dev : boolean
152- buildBlockMode : " Instant" | " Manual" | " Batch"
153- fork : string
154- forkBlockNumber : string
99+ nodeBinaryPath : string ;
100+ rpcPort : number ;
101+ adapterBinaryPath : string ;
102+ adapterEndpoint : string ;
103+ adapterPort : number ;
104+ dev : boolean ;
105+ buildBlockMode : ' Instant' | ' Manual' | ' Batch' ;
106+ fork : string ;
107+ forkBlockNumber : string ;
155108 } ,
156109 { run, config, userConfig } ,
157110 ) => {
@@ -173,14 +126,12 @@ task(TASK_NODE_POLKAVM, "Starts a JSON-RPC server for PolkaVM node")
173126 fork,
174127 forkBlockNumber,
175128 } ,
176- )
129+ ) ;
177130
178- const nodePath = nodeBinaryPath
179- ? nodeBinaryPath
180- : userConfig . networks ?. hardhat ?. nodeConfig ?. nodeBinaryPath
131+ const nodePath = nodeBinaryPath ? nodeBinaryPath : userConfig . networks ?. hardhat ?. nodeConfig ?. nodeBinaryPath ;
181132 const adapterPath = adapterBinaryPath
182133 ? adapterBinaryPath
183- : userConfig . networks ?. hardhat ?. adapterConfig ?. adapterBinaryPath
134+ : userConfig . networks ?. hardhat ?. adapterConfig ?. adapterBinaryPath ;
184135
185136 const server : RpcServer = await run ( TASK_NODE_POLKAVM_CREATE_SERVER , {
186137 nodePath,
@@ -189,6 +140,7 @@ task(TASK_NODE_POLKAVM, "Starts a JSON-RPC server for PolkaVM node")
189140
190141 try {
191142 await server . listen ( commandArgs . nodeCommands , commandArgs . adapterCommands )
143+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
192144 } catch ( error : any ) {
193145 throw new PolkaVMNodePluginError ( `Failed when running node: ${ error . message } ` )
194146 }
@@ -248,33 +200,35 @@ task(
248200 ? userConfig . networks . hardhat . nodeConfig . rpcPort
249201 : NODE_START_PORT ,
250202 MAX_PORT_ATTEMPTS ,
251- )
203+ ) ;
204+
252205 const currentAdapterPort = await getAvailablePort (
253206 userConfig . networks ?. hardhat ?. adapterConfig ?. adapterPort
254207 ? userConfig . networks . hardhat . adapterConfig . adapterPort
255208 : ETH_RPC_ADAPTER_START_PORT ,
256209 MAX_PORT_ATTEMPTS ,
257- )
210+ ) ;
258211
259212 const nCommands : NodeConfig = Object . assign ( { } , userConfig . networks ?. hardhat ?. nodeConfig , {
260213 port : currentNodePort ,
261- } )
262- const aCommands : AdapterConfig = Object . assign (
263- { } ,
264- userConfig . networks ?. hardhat ?. adapterConfig ,
265- { adapterPort : currentAdapterPort } ,
266- )
214+ } ) ;
215+ const aCommands : AdapterConfig = Object . assign ( { } , userConfig . networks ?. hardhat ?. adapterConfig , {
216+ adapterPort : currentAdapterPort ,
217+ } ) ;
218+
267219 const commandArgs = constructCommandArgs ( {
268220 forking : config . networks . hardhat . forking ,
269221 forkBlockNumber : config . networks . hardhat . forking ?. blockNumber ,
270222 nodeCommands : nCommands ,
271223 adapterCommands : aCommands ,
272- } )
224+ } ) ;
225+
273226
274227 const server = new JsonRpcServer (
275228 userConfig . networks ?. hardhat ?. nodeConfig ?. nodeBinaryPath ,
276229 userConfig . networks ?. hardhat ?. adapterConfig ?. adapterBinaryPath ,
277- )
230+ ) ;
231+
278232
279233 try {
280234 await server . listen ( commandArgs . nodeCommands , commandArgs . adapterCommands , false )
@@ -300,6 +254,7 @@ task(
300254
301255 process . exitCode = testFailures
302256 return testFailures
257+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
303258 } catch ( error : any ) {
304259 throw new PolkaVMNodePluginError ( `Failed when running node: ${ error . message } ` )
305260 }
0 commit comments