mirror of
https://github.com/status-im/embark-area-51.git
synced 2025-02-20 11:08:08 +00:00
Add endpoint
This commit is contained in:
parent
4c27d34e0c
commit
6ce78dfce3
@ -21,6 +21,7 @@ class BlockchainConnector {
|
|||||||
this.isWeb3Ready = false;
|
this.isWeb3Ready = false;
|
||||||
this.wait = options.wait;
|
this.wait = options.wait;
|
||||||
this.contractsSubscriptions = [];
|
this.contractsSubscriptions = [];
|
||||||
|
this.contractsEvents = [];
|
||||||
|
|
||||||
self.events.setCommandHandler("blockchain:web3:isReady", (cb) => {
|
self.events.setCommandHandler("blockchain:web3:isReady", (cb) => {
|
||||||
cb(self.isWeb3Ready);
|
cb(self.isWeb3Ready);
|
||||||
@ -369,6 +370,24 @@ class BlockchainConnector {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
plugin.registerAPICall(
|
||||||
|
'ws',
|
||||||
|
'/embark-api/blockchain/contracts/event',
|
||||||
|
(ws, _req) => {
|
||||||
|
this.events.on('blockchain:contracts:event', function(data) {
|
||||||
|
ws.send(JSON.stringify(data), () => {});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
plugin.registerAPICall(
|
||||||
|
'get',
|
||||||
|
'/embark-api/blockchain/contracts/events',
|
||||||
|
(_req, res) => {
|
||||||
|
res.send(JSON.stringify(this.contractsEvents));
|
||||||
|
}
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
getAccountsWithTransactionCount(callback) {
|
getAccountsWithTransactionCount(callback) {
|
||||||
@ -620,7 +639,9 @@ class BlockchainConnector {
|
|||||||
const eventEmitter = contract.events.allEvents();
|
const eventEmitter = contract.events.allEvents();
|
||||||
this.contractsSubscriptions.push(eventEmitter);
|
this.contractsSubscriptions.push(eventEmitter);
|
||||||
eventEmitter.on('data', (data) => {
|
eventEmitter.on('data', (data) => {
|
||||||
|
const dataWithName = Object.assign(data, {name: contractObject.className});
|
||||||
|
this.contractsEvents.push(dataWithName)
|
||||||
|
this.events.emit('blockchain:contract:event', dataWithName);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
callback();
|
callback();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user