Updated message formats

This commit is contained in:
Richard Ramos 2018-08-06 22:28:53 -04:00
parent 77e37eb872
commit 52d48128de
3 changed files with 10 additions and 14 deletions

View File

@ -12,12 +12,12 @@
"port": 8545
},
"blockchain": {
"account": "0x47B9F15c410E2f254E5e065ca515379b090c63e1"
"account": "0x91b3c570ace45716010e162cbbc1b27cd1a10b65"
},
"whisper": {
"symKey": "0xd0d905c1c62b810b787141430417caf2b3f54cffadb395b7bb39fdeb8f17266b",
"ttl": 20,
"minPow": 0.8,
"ttl": 1000,
"minPow": 0.2,
"powTime": 1000
}
},
@ -51,7 +51,7 @@
"IdentityGasRelay": {
"abiFile": "../abi/IdentityGasRelay.json",
"isIdentity": true,
"factoryAddress": "0x9AA17f02d8f6Bc2553d06c60f99Bcc97Cd5E5A89",
"factoryAddress": "0x0391a4eeDA5e6e9eEF5B672E3494c19bcE9Bc976",
"kernelVerification": "isKernel(bytes32)",
"allowedFunctions": [
{

View File

@ -7,7 +7,7 @@ class MessageProcessor {
this.kId = kId;
}
_reply(text, message){
_reply(text, message, receipt){
if(message.sig !== undefined){
this.web3.shh.post({
pubKey: message.sig,
@ -16,7 +16,7 @@ class MessageProcessor {
powTarget:this.config.node.whisper.minPow,
powTime: this.config.node.whisper.powTime,
topic: message.topic,
payload: this.web3.utils.fromAscii(text)
payload: this.web3.utils.fromAscii(JSON.stringify({message:text, receipt}, null, " "))
}).catch(console.error);
}
}
@ -59,8 +59,8 @@ class MessageProcessor {
};
try {
let parsedObj = JSON.parse(this.web3.utils.toAscii(message.payload));
const msg = this.web3.utils.toAscii(message.payload);
let parsedObj = JSON.parse(msg);
obj.address = parsedObj.address;
obj.functionName = parsedObj.encodedFunctionCall.slice(0, 10);
obj.functionParameters = "0x" + parsedObj.encodedFunctionCall.slice(10);
@ -114,11 +114,7 @@ class MessageProcessor {
return this.web3.eth.sendTransaction(p);
})
.then((receipt) => {
return this._reply("Transaction mined;" +
receipt.transactionHash +
';' +
JSON.stringify(receipt),
message);
return this._reply("Transaction mined", message, receipt);
}).catch((err) => {
this._reply("Couldn't mine transaction: " + err.message, message);
// TODO log this?

View File

@ -102,7 +102,7 @@ class IdentityStrategy {
try {
estimatedGas = await this._estimateGas(message, latestBlock.gasLimit);
if(gasLimit.lt(estimatedGas)) {
return {success: false, message: "Gas limit below estimated gas"};
return {success: false, message: "Gas limit below estimated gas (" + estimatedGas + ")"};
}
} catch(exc){
if(exc.message.indexOf("revert") > -1) return {success: false, message: "Transaction will revert"};