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