Simplified processing logic

This commit is contained in:
Richard Ramos 2018-05-21 11:36:26 -04:00
parent 2a80f52717
commit 888355231b
3 changed files with 2 additions and 33 deletions

View File

@ -24,15 +24,12 @@
"tokens": {
"0x0000000000000000000000000000000000000000": {
"minRelayFactor": 1,
"name": "Ethereum",
"symbol": "ETH"
},
"0xD10e6dAe987Dcc0B3ADaA375C9f59690a4C97a27": {
"minRelayFactor": 10000,
"name": "Random Test Token",
"symbol": "RDN",
"pricePlugin": "../plugins/token-utils.js"
"name": "Status Network Token",
"symbol": "SNT"
}
},

View File

@ -12,7 +12,6 @@ class ContractSettings {
}
process(){
this._setTokenPricePlugin();
this._processContracts();
}
@ -28,15 +27,6 @@ class ContractSettings {
return this.web3.utils.toHex(contractName).slice(0, 10);
}
_setTokenPricePlugin(){
for(let token in this.tokens){
if(this.tokens[token].pricePlugin !== undefined){
let PricePlugin = require(this.tokens[token].pricePlugin);
this.tokens[token].pricePlugin = new PricePlugin(this.tokens[token]);
}
}
}
_obtainContractBytecode(topicName){
if(this.contracts[topicName].isIdentity) return;

View File

@ -96,14 +96,6 @@ class MessageProcessor {
}
}
_getFactor(input, contract, gasToken){
if(contract.allowedFunctions[input.functionName].isToken){
return this.web3.utils.toBN(this.settings.getToken(gasToken).pricePlugin.getFactor());
} else {
return this.web3.utils.toBN(1);
}
}
async getBalance(token, input, gasToken){
// Determining balances of token used
if(token.symbol == "ETH"){
@ -186,11 +178,6 @@ class MessageProcessor {
}
const latestBlock = await web3.eth.getBlock("latest");
const factor = this._getFactor(input, contract, gasToken);
const balanceInETH = balance.div(factor);
const gasPriceInETH = gasPrice.div(factor);
let estimatedGas = 0;
try {
estimatedGas = await this._estimateGas(input, latestBlock.gasLimit);
@ -202,11 +189,6 @@ class MessageProcessor {
return this._reply("Transaction will revert", message);
}
const estimatedGasInTokens = estimatedGas.mul(gasPrice).mul(factor);
if(estimatedGasInToken < token.minRelayFactor){
return this._reply("estimatedGasInTokens below accepted minimum", message);
}
let p = {
from: this.config.node.blockchain.account,
to: input.address,