From 2140183c412dd7ee0145477d6e1affa661718c8d Mon Sep 17 00:00:00 2001 From: Philip Hutchins Date: Wed, 19 Jan 2022 16:04:21 -0500 Subject: [PATCH 1/3] Adding handling for errors parsing grant round funds --- app/src/utils/data/grantRounds.ts | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/app/src/utils/data/grantRounds.ts b/app/src/utils/data/grantRounds.ts index d9c7d787..19e84437 100644 --- a/app/src/utils/data/grantRounds.ts +++ b/app/src/utils/data/grantRounds.ts @@ -203,7 +203,15 @@ export async function getGrantRound(blockNumber: number, grantRoundAddress: stri matchingToken = SUPPORTED_TOKENS_MAPPING[matchingTokenAddress]; donationToken = SUPPORTED_TOKENS_MAPPING[donationTokenAddress]; // record the funds as a human readable number - funds = parseFloat(formatUnits(BigNumber.from(funds), SUPPORTED_TOKENS_MAPPING[matchingTokenAddress].decimals)); + try { + funds = parseFloat( + formatUnits(BigNumber.from(funds), SUPPORTED_TOKENS_MAPPING[matchingTokenAddress].decimals) + ); + } catch { + // If parsing funds for the round fails, ignore the round + console.log('Failed to parse funds for round'); + return undefined; + } } else if (LocalForageData && _lsBlockNumber < blockNumber) { // get updated metadata const [newMetaPtr, balance] = await Promise.all([ @@ -213,7 +221,13 @@ export async function getGrantRound(blockNumber: number, grantRoundAddress: stri // update to the new metaPtr metaPtr = newMetaPtr; // update to the new balance - funds = parseFloat(formatUnits(balance, SUPPORTED_TOKENS_MAPPING[matchingTokenAddress].decimals)).toString(); + try { + funds = parseFloat(formatUnits(balance, SUPPORTED_TOKENS_MAPPING[matchingTokenAddress].decimals)).toString(); + } catch { + // If parsing funds for the round fails, ignore the round + console.log('Failed to update funds from metadata'); + return undefined; + } } // build status against now (unix) const now = Date.now() / 1000; From 5b780bbd00ae250f3b337f946493c1c68d04a17f Mon Sep 17 00:00:00 2001 From: Philip Hutchins Date: Thu, 20 Jan 2022 12:18:53 -0500 Subject: [PATCH 2/3] Replacing undefined return with empty object --- app/src/utils/data/grantRounds.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/src/utils/data/grantRounds.ts b/app/src/utils/data/grantRounds.ts index 19e84437..e76ca04e 100644 --- a/app/src/utils/data/grantRounds.ts +++ b/app/src/utils/data/grantRounds.ts @@ -210,7 +210,7 @@ export async function getGrantRound(blockNumber: number, grantRoundAddress: stri } catch { // If parsing funds for the round fails, ignore the round console.log('Failed to parse funds for round'); - return undefined; + return {}; } } else if (LocalForageData && _lsBlockNumber < blockNumber) { // get updated metadata @@ -226,7 +226,7 @@ export async function getGrantRound(blockNumber: number, grantRoundAddress: stri } catch { // If parsing funds for the round fails, ignore the round console.log('Failed to update funds from metadata'); - return undefined; + return {}; } } // build status against now (unix) From efee30854671eac6d39424f0579713f1ab74045a Mon Sep 17 00:00:00 2001 From: Philip Hutchins Date: Wed, 26 Jan 2022 11:27:09 -0500 Subject: [PATCH 3/3] Publish - @dgrants/app@0.2.43-5b780bb.0 - @dgrants/contracts@0.2.31-5b780bb.0 - @dgrants/dcurve@0.2.33-5b780bb.0 - @dgrants/types@0.2.31-5b780bb.0 --- app/package.json | 8 ++++---- contracts/package.json | 4 ++-- dcurve/package.json | 4 ++-- types/package.json | 2 +- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/app/package.json b/app/package.json index 79e5091b..32ec9c3b 100644 --- a/app/package.json +++ b/app/package.json @@ -1,6 +1,6 @@ { "name": "@dgrants/app", - "version": "0.2.42-3aadf31.0", + "version": "0.2.43-5b780bb.0", "private": true, "scripts": { "clean": "rimraf dist", @@ -14,9 +14,9 @@ "prettier": "prettier --write ." }, "dependencies": { - "@dgrants/contracts": "^0.2.30-3aadf31.0", - "@dgrants/dcurve": "^0.2.32-3aadf31.0", - "@dgrants/types": "^0.2.30-3aadf31.0", + "@dgrants/contracts": "^0.2.31-5b780bb.0", + "@dgrants/dcurve": "^0.2.33-5b780bb.0", + "@dgrants/types": "^0.2.31-5b780bb.0", "@fusion-icons/vue": "^0.0.0", "@headlessui/vue": "^1.2.0", "@tailwindcss/aspect-ratio": "^0.2.1", diff --git a/contracts/package.json b/contracts/package.json index f7849982..b0728cf2 100644 --- a/contracts/package.json +++ b/contracts/package.json @@ -1,8 +1,8 @@ { "name": "@dgrants/contracts", - "version": "0.2.30-3aadf31.0", + "version": "0.2.31-5b780bb.0", "devDependencies": { - "@dgrants/types": "^0.2.30-3aadf31.0", + "@dgrants/types": "^0.2.31-5b780bb.0", "@nomiclabs/hardhat-ethers": "^2.0.2", "@nomiclabs/hardhat-waffle": "^2.0.1", "@openzeppelin/contracts": "3.4.1-solc-0.7-2", diff --git a/dcurve/package.json b/dcurve/package.json index bb644c44..0fea0d0a 100644 --- a/dcurve/package.json +++ b/dcurve/package.json @@ -1,6 +1,6 @@ { "name": "@dgrants/dcurve", - "version": "0.2.32-3aadf31.0", + "version": "0.2.33-5b780bb.0", "private": true, "description": "distribution generator for GrantCLR in dgrants", "keywords": [ @@ -29,7 +29,7 @@ "extends": "../package.json" }, "dependencies": { - "@dgrants/contracts": "^0.2.30-3aadf31.0", + "@dgrants/contracts": "^0.2.31-5b780bb.0", "@dgrants/utils": "^0.2.15-8a7e113.0", "buffer": "^6.0.3", "ethers": "^5.4.6" diff --git a/types/package.json b/types/package.json index 12600cd4..5150afdc 100644 --- a/types/package.json +++ b/types/package.json @@ -1,6 +1,6 @@ { "name": "@dgrants/types", - "version": "0.2.30-3aadf31.0", + "version": "0.2.31-5b780bb.0", "types": "src/index.d.ts", "scripts": { "build": "tsc -b .",