Ignore badly formatted message
This commit is contained in:
parent
2a9262c4b9
commit
2d287c43f3
|
@ -8,6 +8,11 @@ import {
|
|||
} from "tabler-react";
|
||||
|
||||
const TX_STATES = {Success: '0x1', Fail: '0x0', Any: ''};
|
||||
const EVENT = 'event';
|
||||
const FUNCTION = 'function';
|
||||
const CONSTRUCTOR = 'constructor';
|
||||
const PURE = 'pure';
|
||||
const VIEW = 'view';
|
||||
|
||||
class ContractLogger extends React.Component {
|
||||
constructor(props) {
|
||||
|
@ -21,7 +26,7 @@ class ContractLogger extends React.Component {
|
|||
}
|
||||
|
||||
return this.props.contract.abiDefinition.filter(method => (
|
||||
method.name !== 'constructor' && method.mutability !== 'view' && method.mutability !== 'pure' && method.constant !== true && method.type === 'function'
|
||||
method.name !== CONSTRUCTOR && method.mutability !== VIEW && method.mutability !== PURE && method.constant !== true && method.type === FUNCTION
|
||||
));
|
||||
}
|
||||
|
||||
|
@ -29,7 +34,7 @@ class ContractLogger extends React.Component {
|
|||
if (!this.props.contract.abiDefinition) {
|
||||
return [];
|
||||
}
|
||||
return this.props.contract.abiDefinition.filter(method => method.type === 'event');
|
||||
return this.props.contract.abiDefinition.filter(method => method.type === EVENT);
|
||||
}
|
||||
|
||||
updateState(key, value) {
|
||||
|
|
|
@ -215,7 +215,12 @@ export function *watchLogout() {
|
|||
function createChannel(socket) {
|
||||
return eventChannel(emit => {
|
||||
socket.onmessage = ((message) => {
|
||||
emit(JSON.parse(message.data));
|
||||
try {
|
||||
emit(JSON.parse(message.data));
|
||||
} catch(_error) {
|
||||
// Ignore the message if not formatted correctly
|
||||
// For example message like outputDone (for live reload)
|
||||
}
|
||||
});
|
||||
return () => {
|
||||
socket.close();
|
||||
|
|
|
@ -374,8 +374,8 @@ class BlockchainConnector {
|
|||
plugin.registerAPICall(
|
||||
'ws',
|
||||
'/embark-api/blockchain/contracts/event',
|
||||
(ws, _req) => {
|
||||
this.events.on('blockchain:contracts:event', function(data) {
|
||||
(ws) => {
|
||||
this.events.on('blockchain:contracts:event', (data) => {
|
||||
ws.send(JSON.stringify(data), () => {});
|
||||
});
|
||||
}
|
||||
|
@ -640,9 +640,12 @@ class BlockchainConnector {
|
|||
this.contractsSubscriptions.push(eventEmitter);
|
||||
eventEmitter.on('data', (data) => {
|
||||
const dataWithName = Object.assign(data, {name: contractObject.className});
|
||||
this.contractsEvents.push(dataWithName)
|
||||
this.events.emit('blockchain:contract:event', dataWithName);
|
||||
this.contractsEvents.push(dataWithName);
|
||||
this.events.emit('blockchain:contracts:event', dataWithName);
|
||||
});
|
||||
eventEmitter.on('error', () => {
|
||||
console.log('error')
|
||||
})
|
||||
});
|
||||
callback();
|
||||
});
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
pragma solidity ^0.4.25;
|
||||
|
||||
contract SimpleStorage {
|
||||
event SetCalled(uint x);
|
||||
uint public storedData;
|
||||
|
||||
constructor(uint initialValue) public {
|
||||
|
@ -10,7 +9,6 @@ contract SimpleStorage {
|
|||
|
||||
function set(uint x) public {
|
||||
storedData = x;
|
||||
emit SetCalled(x);
|
||||
}
|
||||
|
||||
function get() public view returns (uint retVal) {
|
||||
|
|
Loading…
Reference in New Issue