Skip to content

Commit

Permalink
Icons hotfix (#6342)
Browse files Browse the repository at this point in the history
* handle raw response from contract call correctly

* fix logic to reveal icons
  • Loading branch information
brunobar79 authored and ibrahimtaveras00 committed Dec 17, 2024
1 parent 8db27d5 commit e0fc97d
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 30 deletions.
11 changes: 8 additions & 3 deletions src/featuresToUnlock/tokenGatedUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand All @@ -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;
}
Expand Down
59 changes: 32 additions & 27 deletions src/featuresToUnlock/unlockableAppIconCheck.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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}`);

Expand All @@ -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;
}
Expand Down

0 comments on commit e0fc97d

Please sign in to comment.