diff --git a/src/contracts/Dispenser.ts b/src/contracts/Dispenser.ts index 7e646168..d63a1f73 100644 --- a/src/contracts/Dispenser.ts +++ b/src/contracts/Dispenser.ts @@ -57,19 +57,19 @@ export class Dispenser extends SmartContractWithAddress { if (estimateGas) return estGas // Call createFixedRate contract method - const trxReceipt = await this.contract.methods - .create( - dtAddress, - this.web3.utils.toWei(maxTokens), - this.web3.utils.toWei(maxBalance), - address, - allowedSwapper - ) - .send({ - from: address, - gas: estGas + 1, - gasPrice: await this.getFairGasPrice() - }) + const trxReceipt = await sendTx( + address, + estGas + 1, + this.web3, + this.config, + this.contract.methods.create, + dtAddress, + this.web3.utils.toWei(maxTokens), + this.web3.utils.toWei(maxBalance), + address, + allowedSwapper + ) + return trxReceipt } @@ -97,17 +97,17 @@ export class Dispenser extends SmartContractWithAddress { ) if (estimateGas) return estGas - const trxReceipt = await this.contract.methods - .activate( - dtAddress, - this.web3.utils.toWei(maxTokens), - this.web3.utils.toWei(maxBalance) - ) - .send({ - from: address, - gas: estGas + 1, - gasPrice: await this.getFairGasPrice() - }) + const trxReceipt = await sendTx( + address, + estGas + 1, + this.web3, + this.config, + this.contract.methods.activate, + dtAddress, + this.web3.utils.toWei(maxTokens), + this.web3.utils.toWei(maxBalance) + ) + return trxReceipt } @@ -129,11 +129,15 @@ export class Dispenser extends SmartContractWithAddress { ) if (estimateGas) return estGas - const trxReceipt = await this.contract.methods.deactivate(dtAddress).send({ - from: address, - gas: estGas + 1, - gasPrice: await this.getFairGasPrice() - }) + const trxReceipt = await sendTx( + address, + estGas + 1, + this.web3, + this.config, + this.contract.methods.deactivate, + dtAddress + ) + return trxReceipt } @@ -158,13 +162,15 @@ export class Dispenser extends SmartContractWithAddress { ) if (estimateGas) return estGas - const trxReceipt = await this.contract.methods - .setAllowedSwapper(dtAddress, newAllowedSwapper) - .send({ - from: address, - gas: estGas + 1, - gasPrice: await this.getFairGasPrice() - }) + const trxReceipt = await sendTx( + address, + estGas + 1, + this.web3, + this.config, + this.contract.methods.setAllowedSwapper, + dtAddress, + newAllowedSwapper + ) return trxReceipt } @@ -194,13 +200,16 @@ export class Dispenser extends SmartContractWithAddress { ) if (estimateGas) return estGas - const trxReceipt = await this.contract.methods - .dispense(dtAddress, this.web3.utils.toWei(amount), destination) - .send({ - from: address, - gas: estGas + 1, - gasPrice: await this.getFairGasPrice() - }) + const trxReceipt = await sendTx( + address, + estGas + 1, + this.web3, + this.config, + this.contract.methods.dispense, + dtAddress, + this.web3.utils.toWei(amount), + destination + ) return trxReceipt } @@ -222,11 +231,15 @@ export class Dispenser extends SmartContractWithAddress { ) if (estimateGas) return estGas - const trxReceipt = await this.contract.methods.ownerWithdraw(dtAddress).send({ - from: address, - gas: estGas + 1, - gasPrice: await this.getFairGasPrice() - }) + const trxReceipt = await sendTx( + address, + estGas + 1, + this.web3, + this.config, + this.contract.methods.ownerWithdraw, + dtAddress + ) + return trxReceipt } diff --git a/src/contracts/NFT.ts b/src/contracts/NFT.ts index 93c36871..ef28653f 100644 --- a/src/contracts/NFT.ts +++ b/src/contracts/NFT.ts @@ -770,12 +770,15 @@ export class Nft extends SmartContract { valueHex ) - // Call setData function of the contract - const trxReceipt = await nftContract.methods.setNewData(keyHash, valueHex).send({ - from: address, - gas: estGas + 1, - gasPrice: await this.getFairGasPrice() - }) + const trxReceipt = await sendTx( + address, + estGas + 1, + this.web3, + this.config, + nftContract.methods.setNewData, + keyHash, + valueHex + ) return trxReceipt } diff --git a/src/utils/TokenUtils.ts b/src/utils/TokenUtils.ts index 324e5c4d..0b14b5c7 100644 --- a/src/utils/TokenUtils.ts +++ b/src/utils/TokenUtils.ts @@ -96,11 +96,15 @@ export async function approveWei( if (estimateGas) return estGas try { - result = await tokenContract.methods.approve(spender, amount).send({ - from: account, - gas: estGas + 1, - gasPrice: await getFairGasPrice(web3, null) - }) + result = await sendTx( + account, + estGas + 1, + this.web3, + this.config, + tokenContract.methods.approve, + spender, + amount + ) } catch (e) { LoggerInstance.error( `ERROR: Failed to approve spender to spend tokens : ${e.message}`