-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
39 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"@civex/hardhat-node": patch | ||
--- | ||
|
||
Added conflux node task to hardhat |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,29 @@ | ||
import { type Config, createServer } from '@xcfx/node' | ||
import { subtask, task, types } from 'hardhat/config' | ||
import { HardhatPluginError } from 'hardhat/plugins' | ||
import { TASK_CONFLUX_NODE, TASK_CONFLUX_NODE_SERVER_READY } from './constants' | ||
|
||
subtask(TASK_CONFLUX_NODE_SERVER_READY) | ||
.addParam('nodeConfig', undefined, undefined, types.any) | ||
.addParam('server', undefined, undefined, types.any) | ||
.setAction(async ({ config }: { server: any; config: any }) => { | ||
console.info(`Started HTTP server on port ${config.jsonrpcLocalHttpPort}`) | ||
.addParam('confluxServer', undefined, undefined, types.any) | ||
.setAction(async ({ nodeConfig }: { nodeConfig: any }) => { | ||
console.info( | ||
`Started HTTP server on port ${nodeConfig.jsonrpcLocalHttpPort}`, | ||
) | ||
}) | ||
|
||
task(TASK_CONFLUX_NODE, 'Starts a local conflux node').setAction( | ||
async (_, { network, run }) => { | ||
if (network.name !== 'conflux') { | ||
throw new HardhatPluginError( | ||
'@civex/hardhat-node', | ||
'network must be conflux', | ||
) | ||
} | ||
async (_, { config, run }) => { | ||
const nodeConfig: Config = { | ||
jsonrpcLocalHttpPort: 12539, | ||
...network.config, | ||
...config.conflux, | ||
} | ||
const server = await createServer(nodeConfig) | ||
const confluxServer = await createServer(nodeConfig) | ||
|
||
await server.start() | ||
await confluxServer.start() | ||
|
||
await run(TASK_CONFLUX_NODE_SERVER_READY, { | ||
nodeConfig: nodeConfig, | ||
server, | ||
confluxServer, | ||
}) | ||
}, | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters