diff --git a/README.md b/README.md index 11cac19..5ab8c1d 100644 --- a/README.md +++ b/README.md @@ -2,6 +2,7 @@ To start the application, you need to enter the command `npm start` __Environment variables__: +- `HOST` - network listening address - `PORT` - network listening port - `GETH` - address of geth rpc server - `ACCOUNTS` - list of private keys separated by commas diff --git a/index.js b/index.js index fc4d05c..e3e87bc 100644 --- a/index.js +++ b/index.js @@ -3,6 +3,7 @@ const fastify = require('fastify')({ logger: true }); const web3 = require('./src/web3'); const port = process.env.PORT || '3000'; +const host = process.env.HOST || '127.0.0.1'; const geth = process.env.GETH || 'http://localhost:8545'; const accs = process.env.ACCOUNTS || ''; @@ -11,7 +12,7 @@ fastify.register(require('./src/deploy')); fastify.register(require('./src/read')); fastify.register(require('./src/send')); -fastify.listen(port, function (err, address) { +fastify.listen(port, host, function (err, address) { if (err) { fastify.log.error(err) process.exit(1) diff --git a/package.json b/package.json index 759a49b..1da625c 100644 --- a/package.json +++ b/package.json @@ -6,8 +6,8 @@ "scripts": { "start": "node index.js", "test": "npx mocha", - "test:start": "ACCOUNTS=\"0x321f89f3a648166df5af4dd2c808d91ba190b617ee181bc3e94ed1c08801b1ac,0x43332f8bd112b2ed44d97e791bb609ff6f0e04e984d6823360370b6c6285b213\" node index.js", - "test:ganache": "npx ganache-cli --account \"0x321f89f3a648166df5af4dd2c808d91ba190b617ee181bc3e94ed1c08801b1ac,1000000000000000000000\" --account \"0x43332f8bd112b2ed44d97e791bb609ff6f0e04e984d6823360370b6c6285b213,1000000000000000000000\"" + "test:start": "PORT=8889 GETH=http://127.0.0.1:8888 ACCOUNTS=\"0x321f89f3a648166df5af4dd2c808d91ba190b617ee181bc3e94ed1c08801b1ac,0x43332f8bd112b2ed44d97e791bb609ff6f0e04e984d6823360370b6c6285b213\" node index.js", + "test:ganache": "npx ganache-cli -p 8888 --account \"0x321f89f3a648166df5af4dd2c808d91ba190b617ee181bc3e94ed1c08801b1ac,1000000000000000000000\" --account \"0x43332f8bd112b2ed44d97e791bb609ff6f0e04e984d6823360370b6c6285b213,1000000000000000000000\"" }, "repository": { "type": "git", diff --git a/src/deploy.js b/src/deploy.js index d289632..5e29b92 100644 --- a/src/deploy.js +++ b/src/deploy.js @@ -79,6 +79,7 @@ async function handler(req, reply) { reply.send({ uuid: memory.save({ address: re.contractAddress, bytecode, abi }), address: re.contractAddress, + abi, }); } diff --git a/test/index.test.js b/test/index.test.js index 54da727..b66964d 100644 --- a/test/index.test.js +++ b/test/index.test.js @@ -3,7 +3,7 @@ const assert = require('assert'); const fetch = require('node-fetch'); async function post(method, data) { - const res = await fetch(`http://localhost:3000/${method}`, { + const res = await fetch(`http://localhost:8889/${method}`, { method: 'POST', headers: { 'Content-Type': 'application/json',