Skip to content

Commit

Permalink
Update echo_server RunLog to take jobId in ctor
Browse files Browse the repository at this point in the history
  • Loading branch information
dimroc committed May 4, 2018
1 parent 3cfdbcc commit 9e0cf50
Show file tree
Hide file tree
Showing 7 changed files with 38 additions and 31 deletions.
24 changes: 8 additions & 16 deletions examples/echo_server/chainlink_deployer.js
Original file line number Diff line number Diff line change
@@ -1,24 +1,16 @@
let fs = require("fs");
let request = require("request");
let url = "http://chainlink:twochains@localhost:6688/v2/specs";
const fs = require("fs");
const request = require("request-promise");
const util = require('util');
const url = "http://chainlink:twochains@localhost:6688/v2/specs";

module.exports = {
// Deploys chainlink jobs.
job: function(filename, callback, callbackError) {
fs.readFile(filename, 'utf8', (err, file) => {
job: async function(filename) {
let readFile = util.promisify(fs.readFile);
return await readFile(filename, 'utf8').then((file) => {
let data = JSON.parse(file);
console.log(`Posting to ${url}:\n`, data);
request.post(url, {json: data},
function (error, response, body) {
if (!error && response && response.statusCode == 200) {
callback(error, response, body);
} else {
if (callbackError) {
callbackError(error, response);
}
}
}
);
return request.post(url, {json: data});
});
}
};
2 changes: 1 addition & 1 deletion examples/echo_server/contracts/RunLog.sol
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ contract RunLog is Chainlinked {
bytes32 private externalId;
bytes32 private jobId;

function RunLog(address _link, address _oracle, bytes32 _jobId) public {
constructor(address _link, address _oracle, bytes32 _jobId) public {
setLinkToken(_link);
setOracle(_oracle);
jobId = _jobId;
Expand Down
4 changes: 0 additions & 4 deletions examples/echo_server/create_runlog_job

This file was deleted.

11 changes: 5 additions & 6 deletions examples/echo_server/migrations/5_run_log.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,10 @@ let Oracle = artifacts.require("../node_modules/smartcontractkit/chainlink/solid
let RunLog = artifacts.require("./RunLog.sol");

module.exports = function(truffleDeployer) {
console.log(`Create Chainlink Job`);
chainlinkDeployer.job("only_jobid_logs_job.json", function(error, response, body) {
console.log(`Deploying Consumer Contract with JobID ${body.id}`);
truffleDeployer.deploy(RunLog, LinkToken.address, Oracle.address, body.id);
}, function(error) {
console.log("chainlink error:", error);
truffleDeployer.then(async () => {
await chainlinkDeployer.job("only_jobid_logs_job.json").then(async function(body) {
console.log(`Deploying Consumer Contract with JobID ${body.id}`);
await truffleDeployer.deploy(RunLog, LinkToken.address, Oracle.address, body.id);
}).catch(console.log);
});
};
6 changes: 3 additions & 3 deletions examples/echo_server/migrations/6_transfer_link.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ let LinkToken = artifacts.require("../node_modules/smartcontractkit/chainlink/so
let RunLog = artifacts.require("./RunLog.sol");
let devnetAddress = "0x9CA9d2D5E04012C9Ed24C0e513C9bfAa4A2dD77f";

module.exports = async function(deployer) {
await LinkToken.deployed().then(async function(linkInstance) {
module.exports = function(deployer) {
LinkToken.deployed().then(async function(linkInstance) {
await RunLog.deployed().then(async function(runLogInstance) {
await linkInstance.transfer(runLogInstance.address, web3.toWei(1000));
await linkInstance.transfer(devnetAddress, web3.toWei(1000));
});
}).catch(console.log);
});
};
1 change: 1 addition & 0 deletions examples/echo_server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"express": "^4.16.2",
"linkToken": "github:smartcontractkit/linktoken",
"openzeppelin-solidity": "^1.6.0",
"request-promise": "^4.2.2",
"solidity-cborutils": "github:smartcontractkit/solidity-cborutils",
"truffle": "^4.1.6",
"truffle-contract": "^3.0.3"
Expand Down
21 changes: 20 additions & 1 deletion examples/echo_server/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -5132,6 +5132,21 @@ replace-ext@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/replace-ext/-/replace-ext-1.0.0.tgz#de63128373fcbf7c3ccfa4de5a480c45a67958eb"

[email protected]:
version "1.1.1"
resolved "https://registry.yarnpkg.com/request-promise-core/-/request-promise-core-1.1.1.tgz#3eee00b2c5aa83239cfb04c5700da36f81cd08b6"
dependencies:
lodash "^4.13.1"

request-promise@^4.2.2:
version "4.2.2"
resolved "https://registry.yarnpkg.com/request-promise/-/request-promise-4.2.2.tgz#d1ea46d654a6ee4f8ee6a4fea1018c22911904b4"
dependencies:
bluebird "^3.5.0"
request-promise-core "1.1.1"
stealthy-require "^1.1.0"
tough-cookie ">=2.3.3"

request@2, request@^2.74.0:
version "2.85.0"
resolved "https://registry.yarnpkg.com/request/-/request-2.85.0.tgz#5a03615a47c61420b3eb99b7dba204f83603e1fa"
Expand Down Expand Up @@ -5676,6 +5691,10 @@ statuses@~1.3.1:
version "1.3.1"
resolved "https://registry.yarnpkg.com/statuses/-/statuses-1.3.1.tgz#faf51b9eb74aaef3b3acf4ad5f61abf24cb7b93e"

stealthy-require@^1.1.0:
version "1.1.1"
resolved "https://registry.yarnpkg.com/stealthy-require/-/stealthy-require-1.1.1.tgz#35b09875b4ff49f26a777e509b3090a3226bf24b"

stream-browserify@^2.0.1:
version "2.0.1"
resolved "https://registry.yarnpkg.com/stream-browserify/-/stream-browserify-2.0.1.tgz#66266ee5f9bdb9940a4e4514cafb43bb71e5c9db"
Expand Down Expand Up @@ -5940,7 +5959,7 @@ to-regex@^3.0.1, to-regex@^3.0.2:
regex-not "^1.0.2"
safe-regex "^1.1.0"

tough-cookie@~2.3.0, tough-cookie@~2.3.3:
tough-cookie@>=2.3.3, tough-cookie@~2.3.0, tough-cookie@~2.3.3:
version "2.3.4"
resolved "https://registry.yarnpkg.com/tough-cookie/-/tough-cookie-2.3.4.tgz#ec60cee38ac675063ffc97a5c18970578ee83655"
dependencies:
Expand Down

0 comments on commit 9e0cf50

Please sign in to comment.