1
0
mirror of https://github.com/oceanprotocol/ocean.js.git synced 2024-11-26 20:39:05 +01:00

replaced missed send calls

This commit is contained in:
Bogdan Fazakas 2022-08-17 12:45:56 +03:00
parent 7500f51f46
commit 585316e34e
3 changed files with 79 additions and 59 deletions

View File

@ -57,19 +57,19 @@ export class Dispenser extends SmartContractWithAddress {
if (estimateGas) return estGas if (estimateGas) return estGas
// Call createFixedRate contract method // Call createFixedRate contract method
const trxReceipt = await this.contract.methods const trxReceipt = await sendTx(
.create( address,
estGas + 1,
this.web3,
this.config,
this.contract.methods.create,
dtAddress, dtAddress,
this.web3.utils.toWei(maxTokens), this.web3.utils.toWei(maxTokens),
this.web3.utils.toWei(maxBalance), this.web3.utils.toWei(maxBalance),
address, address,
allowedSwapper allowedSwapper
) )
.send({
from: address,
gas: estGas + 1,
gasPrice: await this.getFairGasPrice()
})
return trxReceipt return trxReceipt
} }
@ -97,17 +97,17 @@ export class Dispenser extends SmartContractWithAddress {
) )
if (estimateGas) return estGas if (estimateGas) return estGas
const trxReceipt = await this.contract.methods const trxReceipt = await sendTx(
.activate( address,
estGas + 1,
this.web3,
this.config,
this.contract.methods.activate,
dtAddress, dtAddress,
this.web3.utils.toWei(maxTokens), this.web3.utils.toWei(maxTokens),
this.web3.utils.toWei(maxBalance) this.web3.utils.toWei(maxBalance)
) )
.send({
from: address,
gas: estGas + 1,
gasPrice: await this.getFairGasPrice()
})
return trxReceipt return trxReceipt
} }
@ -129,11 +129,15 @@ export class Dispenser extends SmartContractWithAddress {
) )
if (estimateGas) return estGas if (estimateGas) return estGas
const trxReceipt = await this.contract.methods.deactivate(dtAddress).send({ const trxReceipt = await sendTx(
from: address, address,
gas: estGas + 1, estGas + 1,
gasPrice: await this.getFairGasPrice() this.web3,
}) this.config,
this.contract.methods.deactivate,
dtAddress
)
return trxReceipt return trxReceipt
} }
@ -158,13 +162,15 @@ export class Dispenser extends SmartContractWithAddress {
) )
if (estimateGas) return estGas if (estimateGas) return estGas
const trxReceipt = await this.contract.methods const trxReceipt = await sendTx(
.setAllowedSwapper(dtAddress, newAllowedSwapper) address,
.send({ estGas + 1,
from: address, this.web3,
gas: estGas + 1, this.config,
gasPrice: await this.getFairGasPrice() this.contract.methods.setAllowedSwapper,
}) dtAddress,
newAllowedSwapper
)
return trxReceipt return trxReceipt
} }
@ -194,13 +200,16 @@ export class Dispenser extends SmartContractWithAddress {
) )
if (estimateGas) return estGas if (estimateGas) return estGas
const trxReceipt = await this.contract.methods const trxReceipt = await sendTx(
.dispense(dtAddress, this.web3.utils.toWei(amount), destination) address,
.send({ estGas + 1,
from: address, this.web3,
gas: estGas + 1, this.config,
gasPrice: await this.getFairGasPrice() this.contract.methods.dispense,
}) dtAddress,
this.web3.utils.toWei(amount),
destination
)
return trxReceipt return trxReceipt
} }
@ -222,11 +231,15 @@ export class Dispenser extends SmartContractWithAddress {
) )
if (estimateGas) return estGas if (estimateGas) return estGas
const trxReceipt = await this.contract.methods.ownerWithdraw(dtAddress).send({ const trxReceipt = await sendTx(
from: address, address,
gas: estGas + 1, estGas + 1,
gasPrice: await this.getFairGasPrice() this.web3,
}) this.config,
this.contract.methods.ownerWithdraw,
dtAddress
)
return trxReceipt return trxReceipt
} }

View File

@ -770,12 +770,15 @@ export class Nft extends SmartContract {
valueHex valueHex
) )
// Call setData function of the contract const trxReceipt = await sendTx(
const trxReceipt = await nftContract.methods.setNewData(keyHash, valueHex).send({ address,
from: address, estGas + 1,
gas: estGas + 1, this.web3,
gasPrice: await this.getFairGasPrice() this.config,
}) nftContract.methods.setNewData,
keyHash,
valueHex
)
return trxReceipt return trxReceipt
} }

View File

@ -96,11 +96,15 @@ export async function approveWei<G extends boolean = false>(
if (estimateGas) return estGas if (estimateGas) return estGas
try { try {
result = await tokenContract.methods.approve(spender, amount).send({ result = await sendTx(
from: account, account,
gas: estGas + 1, estGas + 1,
gasPrice: await getFairGasPrice(web3, null) this.web3,
}) this.config,
tokenContract.methods.approve,
spender,
amount
)
} catch (e) { } catch (e) {
LoggerInstance.error( LoggerInstance.error(
`ERROR: Failed to approve spender to spend tokens : ${e.message}` `ERROR: Failed to approve spender to spend tokens : ${e.message}`