Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion constants/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ export const DEFAULT_PARAMETERS = {
};

export const DEFAULT_GAS_PRICE = {
GNOSIS: '6',
GNOSIS: '1.5',
OTP: '0.001',
BASE: '0.086',
};
Expand Down
35 changes: 2 additions & 33 deletions index.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -276,15 +276,11 @@ const DEFAULT_PARAMETERS = {
};

const DEFAULT_GAS_PRICE = {
GNOSIS: '6',
GNOSIS: '1.5',
OTP: '0.001',
BASE: '0.086',
};

const DEFAULT_GAS_PRICE_WEI = {
GNOSIS: '6000000000',
};

const CHUNK_BYTE_SIZE$1 = 32;

function nodeSupported() {
Expand Down Expand Up @@ -3421,10 +3417,6 @@ class BlockchainServiceBase {
return await web3Instance.eth.getGasPrice();
}

if (this.isGnosis(blockchain.name)) {
return await this.getGnosisGasPrice(blockchain);
}

return this.getDefaultGasPrice(blockchain.name);
} catch (error) {
console.warn(
Expand All @@ -3442,17 +3434,6 @@ class BlockchainServiceBase {
return name.startsWith('gnosis');
}

async getGnosisGasPrice(blockchain) {
try {
const response = await axios.get(blockchain.gasPriceOracleLink);
const fastGasPrice = Number(response?.data?.fast) * 1e9;
return fastGasPrice || DEFAULT_GAS_PRICE_WEI.GNOSIS;
} catch (error) {
console.warn(`Failed to fetch gas price from Gnosis oracle: ${error}`);
return DEFAULT_GAS_PRICE_WEI.GNOSIS;
}
}

getDefaultGasPrice(name) {
let defaultGasPrice;
if (name.startsWith('otp')) {
Expand Down Expand Up @@ -4608,20 +4589,8 @@ class BlockchainServiceBase {
let gasPrice;
if (blockchain.name.startsWith('otp') || blockchain.name.startsWith('base')) {
gasPrice = await web3Instance.eth.getGasPrice();
} else if (blockchain.name.startsWith('gnosis')) {
const response = await axios.get(blockchain.gasPriceOracleLink);
if (blockchain.name.split(':')[1] === '100') {
gasPrice = Number(response.result, 10);
} else if (blockchain.name.split(':')[1] === '10200') {
gasPrice = Math.round((response.data.fast) * 1e9);
}
} else {
gasPrice = Web3.utils.toWei(
blockchain.name.startsWith('otp')
? DEFAULT_GAS_PRICE.OTP
: DEFAULT_GAS_PRICE.GNOSIS,
'Gwei',
);
gasPrice = Web3.utils.toWei(DEFAULT_GAS_PRICE.GNOSIS, 'Gwei');
}
return gasPrice;
} catch (error) {
Expand Down
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": "dkg.js",
"version": "8.1.1-rc.2",
"version": "8.1.1-rc.3",
"description": "Javascript library for interaction with the OriginTrail Decentralized Knowledge Graph",
"main": "index.js",
"exports": {
Expand Down
29 changes: 1 addition & 28 deletions services/blockchain-service/blockchain-service-base.js
Original file line number Diff line number Diff line change
Expand Up @@ -116,10 +116,6 @@ export default class BlockchainServiceBase {
return await web3Instance.eth.getGasPrice();
}

if (this.isGnosis(blockchain.name)) {
return await this.getGnosisGasPrice(blockchain);
}

return this.getDefaultGasPrice(blockchain.name);
} catch (error) {
console.warn(
Expand All @@ -137,17 +133,6 @@ export default class BlockchainServiceBase {
return name.startsWith('gnosis');
}

async getGnosisGasPrice(blockchain) {
try {
const response = await axios.get(blockchain.gasPriceOracleLink);
const fastGasPrice = Number(response?.data?.fast) * 1e9;
return fastGasPrice || DEFAULT_GAS_PRICE_WEI.GNOSIS;
} catch (error) {
console.warn(`Failed to fetch gas price from Gnosis oracle: ${error}`);
return DEFAULT_GAS_PRICE_WEI.GNOSIS;
}
}

getDefaultGasPrice(name) {
let defaultGasPrice;
if (name.startsWith('otp')) {
Expand Down Expand Up @@ -1303,20 +1288,8 @@ export default class BlockchainServiceBase {
let gasPrice;
if (blockchain.name.startsWith('otp') || blockchain.name.startsWith('base')) {
gasPrice = await web3Instance.eth.getGasPrice();
} else if (blockchain.name.startsWith('gnosis')) {
const response = await axios.get(blockchain.gasPriceOracleLink);
if (blockchain.name.split(':')[1] === '100') {
gasPrice = Number(response.result, 10);
} else if (blockchain.name.split(':')[1] === '10200') {
gasPrice = Math.round((response.data.fast) * 1e9);
}
} else {
gasPrice = Web3.utils.toWei(
blockchain.name.startsWith('otp')
? DEFAULT_GAS_PRICE.OTP
: DEFAULT_GAS_PRICE.GNOSIS,
'Gwei',
);
gasPrice = Web3.utils.toWei(DEFAULT_GAS_PRICE.GNOSIS, 'Gwei');
}
return gasPrice;
} catch (error) {
Expand Down