Skip to content

Commit

Permalink
Fix/get gas price in scripts (#3219)
Browse files Browse the repository at this point in the history
* Update getGasPrice in set-stake

* Update set-ask getGasPrice

* Version update
  • Loading branch information
Mihajlo-Pavlovic authored Jun 21, 2024
1 parent fe9ffa9 commit 91fba2c
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 7 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "origintrail_node",
"version": "6.5.0",
"version": "6.5.0+hotfix.1",
"description": "OTNode V6",
"main": "index.js",
"type": "module",
Expand Down
10 changes: 8 additions & 2 deletions scripts/set-ask.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,17 @@ const devEnvironment =
process.env.NODE_ENV === NODE_ENVIRONMENTS.DEVELOPMENT ||
process.env.NODE_ENV === NODE_ENVIRONMENTS.TEST;

async function getGasPrice(gasPriceOracleLink) {
async function getGasPrice(gasPriceOracleLink, hubContractAddress, provider) {
if (!gasPriceOracleLink) {
return devEnvironment ? undefined : 8;
}
try {
if (
hubContractAddress === '0x6C861Cb69300C34DfeF674F7C00E734e840C29C0' ||
hubContractAddress === '0x144eDa5cbf8926327cb2cceef168A121F0E4A299'
) {
return provider.getGasPrice();
}
let gasPrice;
const response = await axios.get(gasPriceOracleLink);
if (
Expand Down Expand Up @@ -62,7 +68,7 @@ async function setAsk(rpcEndpoint, ask, walletPrivateKey, hubContractAddress, ga

const askWei = ethers.utils.parseEther(ask);

const gasPrice = await getGasPrice(gasPriceOracleLink);
const gasPrice = await getGasPrice(gasPriceOracleLink, hubContractAddress, provider);

const tx = await profile.setAsk(identityId, askWei, {
gasPrice,
Expand Down
10 changes: 8 additions & 2 deletions scripts/set-stake.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,17 @@ const devEnvironment =
process.env.NODE_ENV === NODE_ENVIRONMENTS.DEVELOPMENT ||
process.env.NODE_ENV === NODE_ENVIRONMENTS.TEST;

async function getGasPrice(gasPriceOracleLink) {
async function getGasPrice(gasPriceOracleLink, hubContractAddress, provider) {
if (!gasPriceOracleLink) {
return devEnvironment ? undefined : 8;
}
try {
if (
hubContractAddress === '0x6C861Cb69300C34DfeF674F7C00E734e840C29C0' ||
hubContractAddress === '0x144eDa5cbf8926327cb2cceef168A121F0E4A299'
) {
return provider.getGasPrice();
}
let gasPrice;
const response = await axios.get(gasPriceOracleLink);
if (
Expand Down Expand Up @@ -80,7 +86,7 @@ async function setStake(

const stakeWei = ethers.utils.parseEther(stake);

const gasPrice = await getGasPrice(gasPriceOracleLink);
const gasPrice = await getGasPrice(gasPriceOracleLink, hubContractAddress, provider);

let tx = await tokenContract.increaseAllowance(stakingContractAddress, stakeWei, {
gasPrice,
Expand Down

0 comments on commit 91fba2c

Please sign in to comment.