Skip to content
This repository has been archived by the owner on Mar 16, 2023. It is now read-only.

Commit

Permalink
feat(sdk): set gas price dynamicly
Browse files Browse the repository at this point in the history
  • Loading branch information
joeandrews committed Feb 19, 2020
1 parent 00654f2 commit 202c80b
Showing 1 changed file with 15 additions and 6 deletions.
21 changes: 15 additions & 6 deletions packages/extension/src/utils/Web3Service.js
Original file line number Diff line number Diff line change
Expand Up @@ -365,12 +365,21 @@ class Web3Service {
gsnContract.setProvider(gsnProvider);

return {
send: async (...args) => this.triggerMethod('send', {
method: gsnContract.methods[methodName],
fromAddress: signingInfo.address,
args,
web3,
}),
send: async (...args) => {
let gasPrice;
try {
gasPrice = await web3.eth.getGasPrice();
} catch (e) {
console.log(e);
}
return this.triggerMethod('send', {
method: gsnContract.methods[methodName],
fromAddress: signingInfo.address,
args,
gasPrice: gasPrice ? gasPrice * 2 : 18000000000, // set gas price 100% higher than last few blocks median to ensure we get in the block
web3,
});
},
};
},
};
Expand Down

0 comments on commit 202c80b

Please sign in to comment.