From e0fc97df4d8c05f8a62fea573d5e2cdb06bce66e Mon Sep 17 00:00:00 2001 From: Bruno Barbieri <1247834+brunobar79@users.noreply.github.com> Date: Tue, 17 Dec 2024 14:57:33 -0500 Subject: [PATCH] Icons hotfix (#6342) * handle raw response from contract call correctly * fix logic to reveal icons --- src/featuresToUnlock/tokenGatedUtils.ts | 11 +++- .../unlockableAppIconCheck.ts | 59 ++++++++++--------- 2 files changed, 40 insertions(+), 30 deletions(-) diff --git a/src/featuresToUnlock/tokenGatedUtils.ts b/src/featuresToUnlock/tokenGatedUtils.ts index f7f1578c14d..52085c56724 100644 --- a/src/featuresToUnlock/tokenGatedUtils.ts +++ b/src/featuresToUnlock/tokenGatedUtils.ts @@ -43,7 +43,10 @@ export const checkIfWalletsOwnNft = async ( const data = iface.encodeFunctionData('areOwners(address[], address[])', [tokenAddresses, walletsToCheck]); const found = await p.call({ to: TOKEN_GATE_CHECKER_ADDRESS[network], data }); - return found; + if (found === '0x0000000000000000000000000000000000000000000000000000000000000000') { + return false; + } + return true; } catch (e) { return false; } @@ -69,8 +72,10 @@ export const checkIfWalletsOwnNft1155 = async ( const iface = new Interface(tokenGateCheckerAbi); const data = iface.encodeFunctionData('areOwners(TokenInfo[], address[])', [tokenInfo, walletsToCheck]); const found = await p.call({ to: TOKEN_GATE_CHECKER_ADDRESS[network], data }); - - return found; + if (found === '0x0000000000000000000000000000000000000000000000000000000000000000') { + return false; + } + return true; } catch (e) { return false; } diff --git a/src/featuresToUnlock/unlockableAppIconCheck.ts b/src/featuresToUnlock/unlockableAppIconCheck.ts index 32300ea0f3a..ddab655a722 100644 --- a/src/featuresToUnlock/unlockableAppIconCheck.ts +++ b/src/featuresToUnlock/unlockableAppIconCheck.ts @@ -27,34 +27,38 @@ export const unlockableAppIconCheck = async (appIconKey: UnlockableAppIconKey, w logger.debug(`[unlockableAppIconCheck]: ${appIconKey} was handled? ${handled}`); try { - const found = ( - await Promise.all( - (Object.keys(appIcon.unlockingNFTs) as TokenGateCheckerNetwork[]).map(async network => { - const nfts = appIcon.unlockingNFTs[network]; - if (!nfts) return; - logger.debug(`[unlockableAppIconCheck]: Checking ${appIconKey} on network ${network}`); - const non1155s: EthereumAddress[] = []; - const all1155s: TokenInfo[] = []; + const promises = (Object.keys(appIcon.unlockingNFTs) as TokenGateCheckerNetwork[]).map(network => { + const nfts = appIcon.unlockingNFTs[network]; + if (!nfts) return; + logger.debug(`[unlockableAppIconCheck]: Checking ${appIconKey} on network ${network}`); + const non1155s: EthereumAddress[] = []; + const all1155s: TokenInfo[] = []; - const values = Object.values(nfts); - values.forEach(value => { - if (typeof value === 'string') { - non1155s.push(value); - } else { - all1155s.push(value); - } - }); - const allChecks = []; - if (non1155s.length > 0) { - allChecks.push(checkIfWalletsOwnNft(non1155s, network, walletsToCheck)); - } - if (all1155s.length > 0) { - allChecks.push(checkIfWalletsOwnNft1155(all1155s, network, walletsToCheck)); - } - return Promise.all(allChecks); - }) - ) - ).some(result => !!result); + const values = Object.values(nfts); + values.forEach(value => { + if (typeof value === 'string') { + non1155s.push(value); + } else { + all1155s.push(value); + } + }); + const allChecks = []; + if (non1155s.length > 0) { + allChecks.push(checkIfWalletsOwnNft(non1155s, network, walletsToCheck)); + } + if (all1155s.length > 0) { + allChecks.push(checkIfWalletsOwnNft1155(all1155s, network, walletsToCheck)); + } + return allChecks; + }); + + const allPromises = promises.flat(); + const results = await Promise.all(allPromises); + + const found = results.some(result => !!result); + if (!found) { + unlockableAppIconStorage.set(appIconKey, false); + } logger.debug(`[unlockableAppIconCheck]: ${appIconKey} check result: ${found}`); @@ -65,6 +69,7 @@ export const unlockableAppIconCheck = async (appIconKey: UnlockableAppIconKey, w if (found) { unlockableAppIconStorage.set(appIconKey, true); logger.debug(`[unlockableAppIconCheck]: Feature check ${appIconKey} set to true. Wont show up anymore!`); + Navigation.handleAction(Routes.APP_ICON_UNLOCK_SHEET, { appIconKey }); return true; }