Updated relayer to validate token balances and show messages in console
This commit is contained in:
parent
b3ee694a3a
commit
a655a0bbf5
|
@ -9,6 +9,7 @@ class MessageProcessor {
|
|||
|
||||
_reply(text, message, receipt){
|
||||
if(message.sig !== undefined){
|
||||
console.log(text);
|
||||
this.web3.shh.post({
|
||||
pubKey: message.sig,
|
||||
sig: this.kId,
|
||||
|
@ -86,7 +87,6 @@ class MessageProcessor {
|
|||
console.error(error);
|
||||
} else {
|
||||
this._extractInput(message);
|
||||
|
||||
const contract = this.settings.getContractByTopic(message.topic);
|
||||
|
||||
console.info("Processing request to: %s, %s", message.input.address, message.input.functionName);
|
||||
|
|
|
@ -81,10 +81,10 @@ class IdentityStrategy {
|
|||
const gasPrice = this.web3.utils.toBN(params('_gasPrice'));
|
||||
const gasLimit = this.web3.utils.toBN(params('_gasLimit'));
|
||||
if(this.contract.allowedFunctions[message.input.functionName].isToken){
|
||||
const Token = new this.web3.eth.Contract(erc20ABI);
|
||||
const Token = new this.web3.eth.Contract(erc20ABI.abi);
|
||||
Token.options.address = params('_baseToken');
|
||||
// const baseToken = new this.web3.utils.BN(await Token.methods.balanceOf(message.input.address).call());
|
||||
if(balance.lt(this.web3.utils.BN(params('_value')))){
|
||||
const tokenBalance = new this.web3.utils.BN(await Token.methods.balanceOf(message.input.address).call());
|
||||
if(tokenBalance.lt(this.web3.utils.toBN(params('_value')))){
|
||||
return {success: false, message: "Identity has not enough balance for specified value"};
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue