Skip to content

Commit e0fc97d

Browse files
brunobar79ibrahimtaveras00
authored andcommitted
Icons hotfix (#6342)
* handle raw response from contract call correctly * fix logic to reveal icons
1 parent 8db27d5 commit e0fc97d

File tree

2 files changed

+40
-30
lines changed

2 files changed

+40
-30
lines changed

src/featuresToUnlock/tokenGatedUtils.ts

+8-3
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,10 @@ export const checkIfWalletsOwnNft = async (
4343

4444
const data = iface.encodeFunctionData('areOwners(address[], address[])', [tokenAddresses, walletsToCheck]);
4545
const found = await p.call({ to: TOKEN_GATE_CHECKER_ADDRESS[network], data });
46-
return found;
46+
if (found === '0x0000000000000000000000000000000000000000000000000000000000000000') {
47+
return false;
48+
}
49+
return true;
4750
} catch (e) {
4851
return false;
4952
}
@@ -69,8 +72,10 @@ export const checkIfWalletsOwnNft1155 = async (
6972
const iface = new Interface(tokenGateCheckerAbi);
7073
const data = iface.encodeFunctionData('areOwners(TokenInfo[], address[])', [tokenInfo, walletsToCheck]);
7174
const found = await p.call({ to: TOKEN_GATE_CHECKER_ADDRESS[network], data });
72-
73-
return found;
75+
if (found === '0x0000000000000000000000000000000000000000000000000000000000000000') {
76+
return false;
77+
}
78+
return true;
7479
} catch (e) {
7580
return false;
7681
}

src/featuresToUnlock/unlockableAppIconCheck.ts

+32-27
Original file line numberDiff line numberDiff line change
@@ -27,34 +27,38 @@ export const unlockableAppIconCheck = async (appIconKey: UnlockableAppIconKey, w
2727
logger.debug(`[unlockableAppIconCheck]: ${appIconKey} was handled? ${handled}`);
2828

2929
try {
30-
const found = (
31-
await Promise.all(
32-
(Object.keys(appIcon.unlockingNFTs) as TokenGateCheckerNetwork[]).map(async network => {
33-
const nfts = appIcon.unlockingNFTs[network];
34-
if (!nfts) return;
35-
logger.debug(`[unlockableAppIconCheck]: Checking ${appIconKey} on network ${network}`);
36-
const non1155s: EthereumAddress[] = [];
37-
const all1155s: TokenInfo[] = [];
30+
const promises = (Object.keys(appIcon.unlockingNFTs) as TokenGateCheckerNetwork[]).map(network => {
31+
const nfts = appIcon.unlockingNFTs[network];
32+
if (!nfts) return;
33+
logger.debug(`[unlockableAppIconCheck]: Checking ${appIconKey} on network ${network}`);
34+
const non1155s: EthereumAddress[] = [];
35+
const all1155s: TokenInfo[] = [];
3836

39-
const values = Object.values(nfts);
40-
values.forEach(value => {
41-
if (typeof value === 'string') {
42-
non1155s.push(value);
43-
} else {
44-
all1155s.push(value);
45-
}
46-
});
47-
const allChecks = [];
48-
if (non1155s.length > 0) {
49-
allChecks.push(checkIfWalletsOwnNft(non1155s, network, walletsToCheck));
50-
}
51-
if (all1155s.length > 0) {
52-
allChecks.push(checkIfWalletsOwnNft1155(all1155s, network, walletsToCheck));
53-
}
54-
return Promise.all(allChecks);
55-
})
56-
)
57-
).some(result => !!result);
37+
const values = Object.values(nfts);
38+
values.forEach(value => {
39+
if (typeof value === 'string') {
40+
non1155s.push(value);
41+
} else {
42+
all1155s.push(value);
43+
}
44+
});
45+
const allChecks = [];
46+
if (non1155s.length > 0) {
47+
allChecks.push(checkIfWalletsOwnNft(non1155s, network, walletsToCheck));
48+
}
49+
if (all1155s.length > 0) {
50+
allChecks.push(checkIfWalletsOwnNft1155(all1155s, network, walletsToCheck));
51+
}
52+
return allChecks;
53+
});
54+
55+
const allPromises = promises.flat();
56+
const results = await Promise.all(allPromises);
57+
58+
const found = results.some(result => !!result);
59+
if (!found) {
60+
unlockableAppIconStorage.set(appIconKey, false);
61+
}
5862

5963
logger.debug(`[unlockableAppIconCheck]: ${appIconKey} check result: ${found}`);
6064

@@ -65,6 +69,7 @@ export const unlockableAppIconCheck = async (appIconKey: UnlockableAppIconKey, w
6569
if (found) {
6670
unlockableAppIconStorage.set(appIconKey, true);
6771
logger.debug(`[unlockableAppIconCheck]: Feature check ${appIconKey} set to true. Wont show up anymore!`);
72+
6873
Navigation.handleAction(Routes.APP_ICON_UNLOCK_SHEET, { appIconKey });
6974
return true;
7075
}

0 commit comments

Comments
 (0)