Skip to content

Commit

Permalink
Add scaffolding for handlers
Browse files Browse the repository at this point in the history
  • Loading branch information
Arkadiy Kukarkin committed Dec 14, 2016
1 parent 2d303c7 commit 5fa7f4f
Showing 1 changed file with 23 additions and 1 deletion.
24 changes: 23 additions & 1 deletion src/peer/repl/commands/oracle.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,12 @@ module.exports = {
// can use http://eth3.augur.net:8545 testnet public node
'default': 'http://localhost:8545'
})
.option('namespace', {
'alias': 'ns',
'type': 'string',
'describe': 'which namespace to act as oracle for',
'demand': true
})
.help()
},
handler: (opts: {dir?: string, remotePeer?: string, identityPath: string, rpc: string}) => {
Expand Down Expand Up @@ -56,8 +62,9 @@ module.exports = {
console.error(`Unable to connect to ethereum RPC:`, rpc)
process.exit(-1)
} else {
// listener entrypoint here
console.log(`Connected to ethereum RPC:`, rpc)
// ope.watch(orderPlacedHandler)
// oce.watch(orderCompletedHandler)
}
}).catch(err => {
console.log(err)
Expand All @@ -71,3 +78,18 @@ function initEth(rpc: string): Web3 {
web3.setProvider(new web3.providers.HttpProvider(rpc));
return web3
}

function orderPlacedHandler(err, event) {
// listen for OrderPlaced event, call completeOrder

// registration (write)
// token.completeOrder(config.namespace, thing,
// config.namespaceOwner, {from: account});

// lookup (read)
// token.completeOrder(thing.id, buyer,
// thing.owner, {from: account});
}

function orderCompletedHandler(err, event){
}

0 comments on commit 5fa7f4f

Please sign in to comment.