From 1b9ef67bf67edeb21c0c2d5eb7529037919a444f Mon Sep 17 00:00:00 2001 From: 0xidkfa Date: Sun, 29 Jan 2023 12:40:27 -0800 Subject: [PATCH] Changing JsonRpcProvider to StaticJsonRpcProvider, which eliminates unnecessary calls to eth_chainId --- .gitignore | 2 ++ src/components/ui/MimTokenBlock.vue | 2 +- src/helpers/glpApr/contracts.js | 2 +- src/helpers/stargateFarmApy.js | 2 +- src/mixins/farmPools.js | 2 +- src/plugins/connectWallet/index.js | 4 ++-- 6 files changed, 8 insertions(+), 6 deletions(-) diff --git a/.gitignore b/.gitignore index 0035d70c2..0849805c2 100644 --- a/.gitignore +++ b/.gitignore @@ -22,3 +22,5 @@ pnpm-debug.log* *.njsproj *.sln *.sw? + +.prettierignore \ No newline at end of file diff --git a/src/components/ui/MimTokenBlock.vue b/src/components/ui/MimTokenBlock.vue index 55fc8f714..983813c4e 100644 --- a/src/components/ui/MimTokenBlock.vue +++ b/src/components/ui/MimTokenBlock.vue @@ -87,7 +87,7 @@ export default { }, async initContract() { - const defaultProvider = new providers.JsonRpcProvider( + const defaultProvider = new providers.StaticJsonRpcProvider( "https://mainnet.infura.io/v3/9aa3d95b3bc440fa88ea12eaa4456161" ); diff --git a/src/helpers/glpApr/contracts.js b/src/helpers/glpApr/contracts.js index e0ea06288..9a1d495e2 100644 --- a/src/helpers/glpApr/contracts.js +++ b/src/helpers/glpApr/contracts.js @@ -17,7 +17,7 @@ const { GmxGlpWrapperAddress, } = require("./constants"); -const provider = new providers.JsonRpcProvider(rpc); +const provider = new providers.StaticJsonRpcProvider(rpc); module.exports.getGlpManagerContract = () => new Contract(glpManagerAddress, GlpManager.abi, provider); diff --git a/src/helpers/stargateFarmApy.js b/src/helpers/stargateFarmApy.js index afa7b521f..049d87826 100644 --- a/src/helpers/stargateFarmApy.js +++ b/src/helpers/stargateFarmApy.js @@ -5,7 +5,7 @@ const { Percent, CurrencyAmount, Token } = require("@uniswap/sdk"); import lpStakingAbi from "@/utils/abi/StargateLPStaking"; import poolAbi from "@/utils/abi/StargatePool"; -const provider = new providers.JsonRpcProvider(url); +const provider = new providers.StaticJsonRpcProvider(url); const YEAR = 31536000; const stgToken = new Token(1, "0xAf5191B0De278C7286d6C7CC6ab6BB8A73bA2Cd6", 18); diff --git a/src/mixins/farmPools.js b/src/mixins/farmPools.js index 44bac7c96..5a08f4890 100644 --- a/src/mixins/farmPools.js +++ b/src/mixins/farmPools.js @@ -34,7 +34,7 @@ export default { }); } - return new this.$ethers.providers.JsonRpcProvider(networkRpc); + return new this.$ethers.providers.StaticJsonRpcProvider(networkRpc); }, }, methods: { diff --git a/src/plugins/connectWallet/index.js b/src/plugins/connectWallet/index.js index 10d03da87..a85b627e5 100644 --- a/src/plugins/connectWallet/index.js +++ b/src/plugins/connectWallet/index.js @@ -85,7 +85,7 @@ const subscribeProvider = async (provider, isCoinbase) => { const initWithoutConnect = async () => { const chainId = +(localStorage.getItem("MAGIC_MONEY_CHAIN_ID") || 1); - const provider = new ethers.providers.JsonRpcProvider( + const provider = new ethers.providers.StaticJsonRpcProvider( walletconnect.options.rpc[chainId] ); @@ -98,7 +98,7 @@ const initWithoutConnect = async () => { }; const checkSanctionAddress = async (address) => { - const provider = new ethers.providers.JsonRpcProvider( + const provider = new ethers.providers.StaticJsonRpcProvider( "https://mainnet.infura.io/v3/9aa3d95b3bc440fa88ea12eaa4456161" );