-
Notifications
You must be signed in to change notification settings - Fork 6
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
krzysztofwedrowicz
committed
Aug 31, 2018
1 parent
1fb0e28
commit a25d8ca
Showing
11 changed files
with
4,368 additions
and
2 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 @@ | ||
node_modules |
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,3 @@ | ||
PUBLIC_KEY=0x1df62f291b2e969fb0849d99d9ce41e2f137006e | ||
PRIVATE_KEY=0xb0057716d5917badaf911b193b12b910811c1497b5bada8d7711f758981c3773 | ||
ORACLE_ADDRESS=0xcfeb869f69431e42cdb54a4f4f105c19c080a601 |
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,3 @@ | ||
{ | ||
"extends": "airbnb-base" | ||
} |
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,2 @@ | ||
# Created by .ignore support plugin (hsz.mobi) | ||
node_modules |
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,16 @@ | ||
FROM node:carbon | ||
|
||
# Create app directory | ||
WORKDIR /usr/src/app | ||
|
||
# Install app dependencies | ||
# A wildcard is used to ensure both package.json AND package-lock.json are copied | ||
# where available (npm@5+) | ||
COPY package*.json ./ | ||
|
||
RUN npm install | ||
|
||
# Bundle app source | ||
COPY . . | ||
|
||
CMD [ "npm", "start" ] |
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,104 @@ | ||
{ | ||
"contracts": { | ||
"oracle": { | ||
"abi": [ | ||
{ | ||
"constant": true, | ||
"inputs": [], | ||
"name": "trustedServer", | ||
"outputs": [ | ||
{ | ||
"name": "", | ||
"type": "address" | ||
} | ||
], | ||
"payable": false, | ||
"stateMutability": "view", | ||
"type": "function" | ||
}, | ||
{ | ||
"inputs": [ | ||
{ | ||
"name": "_trustedServer", | ||
"type": "address" | ||
} | ||
], | ||
"payable": false, | ||
"stateMutability": "nonpayable", | ||
"type": "constructor" | ||
}, | ||
{ | ||
"anonymous": false, | ||
"inputs": [ | ||
{ | ||
"indexed": false, | ||
"name": "id", | ||
"type": "bytes32" | ||
}, | ||
{ | ||
"indexed": false, | ||
"name": "url", | ||
"type": "string" | ||
} | ||
], | ||
"name": "DataRequested", | ||
"type": "event" | ||
}, | ||
{ | ||
"anonymous": false, | ||
"inputs": [ | ||
{ | ||
"indexed": false, | ||
"name": "id", | ||
"type": "bytes32" | ||
}, | ||
{ | ||
"indexed": false, | ||
"name": "value", | ||
"type": "string" | ||
} | ||
], | ||
"name": "RequestFulfilled", | ||
"type": "event" | ||
}, | ||
{ | ||
"constant": false, | ||
"inputs": [ | ||
{ | ||
"name": "_url", | ||
"type": "string" | ||
} | ||
], | ||
"name": "request", | ||
"outputs": [ | ||
{ | ||
"name": "id", | ||
"type": "bytes32" | ||
} | ||
], | ||
"payable": false, | ||
"stateMutability": "nonpayable", | ||
"type": "function" | ||
}, | ||
{ | ||
"constant": false, | ||
"inputs": [ | ||
{ | ||
"name": "_id", | ||
"type": "bytes32" | ||
}, | ||
{ | ||
"name": "_value", | ||
"type": "string" | ||
} | ||
], | ||
"name": "fillRequest", | ||
"outputs": [], | ||
"payable": false, | ||
"stateMutability": "nonpayable", | ||
"type": "function" | ||
} | ||
] | ||
} | ||
} | ||
} |
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,15 @@ | ||
version: '3' | ||
services: | ||
app: | ||
build: . | ||
env_file: | ||
- .env | ||
depends_on: | ||
- ganache-cli | ||
command: ["./wait-for-it.sh", "ganache-cli:8545", "--", "npm", "start"] | ||
ganache-cli: | ||
image: "trufflesuite/ganache-cli" | ||
command: ganache-cli -d | ||
ports: | ||
- 8545:8545 | ||
- 8546:8546 |
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,24 @@ | ||
/* eslint no-console: 0 */ | ||
const Web3 = require('web3'); | ||
const config = require('config'); | ||
require('dotenv').config(); | ||
|
||
const localProviderUrl = 'http://127.0.0.1:8545'; | ||
const localProvider = new Web3.providers.WebsocketProvider(localProviderUrl); | ||
const web3 = new Web3(localProvider); | ||
|
||
web3.eth.accounts.wallet.add(process.env.PRIVATE_KEY); | ||
|
||
|
||
const oracleContract = new web3.eth.Contract(config.get('contracts.oracle.abi'), process.env.ORACLE_ADDRESS); | ||
|
||
oracleContract.events.DataRequested() | ||
.on('data', (event) => { | ||
console.log(event); | ||
|
||
oracleContract.methods.fillRequest(event.returnValues.id, '1').send({ | ||
from: process.env.PUBLIC_KEY, | ||
gas: 200000, | ||
}).then(console.log); | ||
}) | ||
.on('error', console.error); |
Oops, something went wrong.