From 91fba2ca764172ea1c0383467840655298fb0563 Mon Sep 17 00:00:00 2001 From: Mihajlo Pavlovic Date: Fri, 21 Jun 2024 16:08:15 +0200 Subject: [PATCH] Fix/get gas price in scripts (#3219) * Update getGasPrice in set-stake * Update set-ask getGasPrice * Version update --- package-lock.json | 4 ++-- package.json | 2 +- scripts/set-ask.js | 10 ++++++++-- scripts/set-stake.js | 10 ++++++++-- 4 files changed, 19 insertions(+), 7 deletions(-) diff --git a/package-lock.json b/package-lock.json index dfe3dfd334..6903476aaa 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "origintrail_node", - "version": "6.4.1", + "version": "6.5.0+hotfix.1", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "origintrail_node", - "version": "6.4.1", + "version": "6.5.0+hotfix.1", "license": "ISC", "dependencies": { "@comunica/query-sparql": "^2.4.3", diff --git a/package.json b/package.json index bb88a9c324..d285095aed 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/scripts/set-ask.js b/scripts/set-ask.js index 9c1c3deed4..756927e964 100644 --- a/scripts/set-ask.js +++ b/scripts/set-ask.js @@ -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 ( @@ -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, diff --git a/scripts/set-stake.js b/scripts/set-stake.js index 01f01f76a0..671c814ef6 100644 --- a/scripts/set-stake.js +++ b/scripts/set-stake.js @@ -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 ( @@ -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,