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": { "tokens": {
"0x0000000000000000000000000000000000000000": { "0x0000000000000000000000000000000000000000": {
"minRelayFactor": 1,
"name": "Ethereum", "name": "Ethereum",
"symbol": "ETH" "symbol": "ETH"
}, },
"0xD10e6dAe987Dcc0B3ADaA375C9f59690a4C97a27": { "0xD10e6dAe987Dcc0B3ADaA375C9f59690a4C97a27": {
"minRelayFactor": 10000, "name": "Status Network Token",
"name": "Random Test Token", "symbol": "SNT"
"symbol": "RDN",
"pricePlugin": "../plugins/token-utils.js"
} }
}, },

View File

@ -12,7 +12,6 @@ class ContractSettings {
} }
process(){ process(){
this._setTokenPricePlugin();
this._processContracts(); this._processContracts();
} }
@ -28,15 +27,6 @@ class ContractSettings {
return this.web3.utils.toHex(contractName).slice(0, 10); 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){ _obtainContractBytecode(topicName){
if(this.contracts[topicName].isIdentity) return; 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){ async getBalance(token, input, gasToken){
// Determining balances of token used // Determining balances of token used
if(token.symbol == "ETH"){ if(token.symbol == "ETH"){
@ -186,11 +178,6 @@ class MessageProcessor {
} }
const latestBlock = await web3.eth.getBlock("latest"); 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; let estimatedGas = 0;
try { try {
estimatedGas = await this._estimateGas(input, latestBlock.gasLimit); estimatedGas = await this._estimateGas(input, latestBlock.gasLimit);
@ -202,11 +189,6 @@ class MessageProcessor {
return this._reply("Transaction will revert", message); 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 = { let p = {
from: this.config.node.blockchain.account, from: this.config.node.blockchain.account,
to: input.address, to: input.address,