Fixes related to the use of accounts and signatures
This commit is contained in:
parent
73f2ea6b85
commit
e197a66384
|
@ -66,8 +66,7 @@ class MessageProcessor {
|
||||||
const inputValidation = await this._validateInput(contract, input);
|
const inputValidation = await this._validateInput(contract, input);
|
||||||
if(!inputValidation.success){
|
if(!inputValidation.success){
|
||||||
// TODO Log?
|
// TODO Log?
|
||||||
reply(inputValidation);
|
return inputValidation;
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(strategy || contract.strategy){
|
if(strategy || contract.strategy){
|
||||||
|
|
|
@ -159,10 +159,10 @@ events.on('server:listen', (shhOptions, settings) => {
|
||||||
|
|
||||||
const input = extractInput(message);
|
const input = extractInput(message);
|
||||||
const inputCheckSum = JSum.digest({input}, 'SHA256', 'hex');
|
const inputCheckSum = JSum.digest({input}, 'SHA256', 'hex');
|
||||||
|
|
||||||
const reply = replyFunction(message, inputCheckSum);
|
const reply = replyFunction(message, inputCheckSum);
|
||||||
|
|
||||||
if(cache.get(inputCheckSum)){
|
if(cache.get(inputCheckSum) && input.action != 'availability'){
|
||||||
reply("Duplicated message received");
|
reply("Duplicated message received");
|
||||||
} else {
|
} else {
|
||||||
let validationResult;
|
let validationResult;
|
||||||
|
@ -180,8 +180,9 @@ events.on('server:listen', (shhOptions, settings) => {
|
||||||
);
|
);
|
||||||
if(validationResult.success && validationResult.message) {
|
if(validationResult.success && validationResult.message) {
|
||||||
cache.put(inputCheckSum, (new Date().getTime()), 86400000);
|
cache.put(inputCheckSum, (new Date().getTime()), 86400000);
|
||||||
reply(validationResult.message);
|
|
||||||
}
|
}
|
||||||
|
reply(validationResult.message);
|
||||||
|
|
||||||
|
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
|
|
@ -35,6 +35,7 @@ class TransferSNT extends Component {
|
||||||
super(props);
|
super(props);
|
||||||
this.state = {
|
this.state = {
|
||||||
topic: '0x534e5443',
|
topic: '0x534e5443',
|
||||||
|
account: '',
|
||||||
to: '0x0000000000000000000000000000000000000000',
|
to: '0x0000000000000000000000000000000000000000',
|
||||||
amount: 0,
|
amount: 0,
|
||||||
gasPrice: 0,
|
gasPrice: 0,
|
||||||
|
@ -80,9 +81,9 @@ class TransferSNT extends Component {
|
||||||
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const accounts = await web3.eth.getAccounts();
|
this.setState({account: web3.eth.defaultAccount});
|
||||||
|
|
||||||
const s = new StatusGasRelayer.SNTController(SNTController.options.address, accounts[0])
|
const s = new StatusGasRelayer.SNTController(SNTController.options.address, web3.eth.defaultAccount)
|
||||||
.transferSNT(this.state.to, this.state.amount)
|
.transferSNT(this.state.to, this.state.amount)
|
||||||
.setGas(this.state.gasPrice);
|
.setGas(this.state.gasPrice);
|
||||||
|
|
||||||
|
@ -95,7 +96,7 @@ class TransferSNT extends Component {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
obtainRelayers = async event => {
|
obtainRelayers = async (event) => {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
|
|
||||||
const {web3, kid, skid} = this.props;
|
const {web3, kid, skid} = this.props;
|
||||||
|
@ -108,9 +109,7 @@ class TransferSNT extends Component {
|
||||||
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const accounts = await web3.eth.getAccounts();
|
const s = new StatusGasRelayer.AvailableRelayers(Contracts.SNT, SNTController.options.address, this.state.account)
|
||||||
|
|
||||||
const s = new StatusGasRelayer.AvailableRelayers(Contracts.SNT, SNTController.options.address, accounts[0])
|
|
||||||
.setRelayersSymKeyID(skid)
|
.setRelayersSymKeyID(skid)
|
||||||
.setAsymmetricKeyID(kid)
|
.setAsymmetricKeyID(kid)
|
||||||
.setGas(STT.options.address, this.state.gasPrice);
|
.setGas(STT.options.address, this.state.gasPrice);
|
||||||
|
@ -148,9 +147,7 @@ class TransferSNT extends Component {
|
||||||
this.props.clearMessages();
|
this.props.clearMessages();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const accounts = await web3.eth.getAccounts();
|
const s = new StatusGasRelayer.SNTController(SNTController.options.address, this.state.account)
|
||||||
|
|
||||||
const s = new StatusGasRelayer.SNTController(SNTController.options.address, accounts[0])
|
|
||||||
.transferSNT(this.state.to, this.state.amount)
|
.transferSNT(this.state.to, this.state.amount)
|
||||||
.setGas(this.state.gasPrice)
|
.setGas(this.state.gasPrice)
|
||||||
.setRelayer(relayer)
|
.setRelayer(relayer)
|
||||||
|
|
|
@ -25,6 +25,7 @@ export const Messages = {
|
||||||
|
|
||||||
const relayerSymmmetricKeyID = "0xd0d905c1c62b810b787141430417caf2b3f54cffadb395b7bb39fdeb8f17266b";
|
const relayerSymmmetricKeyID = "0xd0d905c1c62b810b787141430417caf2b3f54cffadb395b7bb39fdeb8f17266b";
|
||||||
const emptyBytesSha = "0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470";
|
const emptyBytesSha = "0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470";
|
||||||
|
|
||||||
class StatusGasRelayer {
|
class StatusGasRelayer {
|
||||||
constructor(build, web3) {
|
constructor(build, web3) {
|
||||||
if (arguments.length !== 2 || !this.validateBuild(build)) throw new Error("Invalid build");
|
if (arguments.length !== 2 || !this.validateBuild(build)) throw new Error("Invalid build");
|
||||||
|
@ -246,7 +247,7 @@ class IdentityGasRelayedAction extends Action {
|
||||||
throw new Error("Function not allowed");
|
throw new Error("Function not allowed");
|
||||||
}
|
}
|
||||||
|
|
||||||
const signedMessage = await web3.eth.sign(hashedMessage, this.accountAddress);
|
const signedMessage = await web3.eth.personal.sign(hashedMessage, this.accountAddress);
|
||||||
|
|
||||||
return signedMessage;
|
return signedMessage;
|
||||||
}
|
}
|
||||||
|
@ -371,7 +372,7 @@ class SNTControllerAction extends Action {
|
||||||
throw new Error("Function not allowed");
|
throw new Error("Function not allowed");
|
||||||
}
|
}
|
||||||
|
|
||||||
const signedMessage = await web3.eth.sign(hashedMessage, this.accountAddress);
|
const signedMessage = await web3.eth.personal.sign(hashedMessage, this.accountAddress);
|
||||||
|
|
||||||
return signedMessage;
|
return signedMessage;
|
||||||
}
|
}
|
||||||
|
@ -410,7 +411,7 @@ class SNTControllerAction extends Action {
|
||||||
default:
|
default:
|
||||||
throw new Error("Function not allowed");
|
throw new Error("Function not allowed");
|
||||||
}
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
'contract': this.contractAddress,
|
'contract': this.contractAddress,
|
||||||
'address': this.accountAddress,
|
'address': this.accountAddress,
|
||||||
|
|
Loading…
Reference in New Issue