From 60cab94e1c97e0def915fd67355bc6443d30951a Mon Sep 17 00:00:00 2001 From: lza_menace Date: Tue, 3 Jan 2023 22:41:14 -0800 Subject: [PATCH] more conservatively check rpc --- src/styles/main.css | 1 + src/template/Sections.jsx | 56 ++++++++++++++++++++++++--------------- 2 files changed, 35 insertions(+), 22 deletions(-) diff --git a/src/styles/main.css b/src/styles/main.css index 53dffae..5d32c0a 100644 --- a/src/styles/main.css +++ b/src/styles/main.css @@ -94,6 +94,7 @@ nav::before { ::-webkit-scrollbar-thumb { background: var(--accent); -webkit-border-radius: 1ex; + border-radius: 1ex; } ::-webkit-scrollbar-corner { diff --git a/src/template/Sections.jsx b/src/template/Sections.jsx index 9433bef..754eabe 100644 --- a/src/template/Sections.jsx +++ b/src/template/Sections.jsx @@ -193,6 +193,7 @@ function Section3() { abi: MainABI, enabled: isConnected } + // Fetch this stuff and cache aggressively since it doesn't change useContractReads({ contracts: [ { @@ -203,6 +204,29 @@ function Section3() { ...defOpt, functionName: 'bombPrice' }, + { + ...defOpt, + functionName: 'unaboomerMaxSupply' + }, + { + ...defOpt, + functionName: 'unaboomerSurvivorCount' + } + ], + watch: false, + cacheTime: 30_000, + onSuccess(data) { + handleStateChange({ + unaboomerPrice: data[0].toString(), + bombPrice: data[1].toString(), + unaboomerMaxSupply: data[2].toString(), + unaboomerSurvivorCount: data[3].toString() + }); + } + }); + // Fetch this stuff more frequently as it updates constantly + useContractReads({ + contracts: [ { ...defOpt, functionName: 'unaboomerBalance', @@ -232,31 +256,19 @@ function Section3() { { ...defOpt, functionName: 'leaderboardPointer' - }, - { - ...defOpt, - functionName: 'unaboomerMaxSupply' - }, - { - ...defOpt, - functionName: 'unaboomerSurvivorCount' } ], watch: true, - cacheTime: 3_000, + cacheTime: 6_000, onSuccess(data) { handleStateChange({ - unaboomerPrice: data[0].toString(), - bombPrice: data[1].toString(), - unaboomerBalance: data[2].toString(), - bombBalance: data[3].toString(), - unaboomerSupply: data[4].toString(), - bombSupply: data[5].toString(), - bombsExploded: data[6].toString(), - unaboomersKilled: data[7].toString(), - leaderboardPointer: data[8].toString(), - unaboomerMaxSupply: data[9].toString(), - unaboomerSurvivorCount: data[10].toString() + unaboomerBalance: data[0].toString(), + bombBalance: data[1].toString(), + unaboomerSupply: data[2].toString(), + bombSupply: data[3].toString(), + bombsExploded: data[4].toString(), + unaboomersKilled: data[5].toString(), + leaderboardPointer: data[6].toString(), }); } }); @@ -267,7 +279,7 @@ function Section3() { functionName: 'leaderboard', args: [options.leaderboardPointer], watch: true, - cacheTime: 3_000, + cacheTime: 8_000, onSuccess: async (data) => { handleStateChange({ leaderAddress: data, @@ -281,7 +293,7 @@ function Section3() { functionName: 'killCount', args: [options.leaderAddress], watch: true, - cacheTime: 3_000, + cacheTime: 8_000, onSuccess(data) { handleStateChange({ leaderKillCount: data.toString(),