Skip to content

Commit

Permalink
merge migrations
Browse files Browse the repository at this point in the history
  • Loading branch information
walmat committed Dec 18, 2024
2 parents a672fea + 29ec1a0 commit 854663a
Show file tree
Hide file tree
Showing 7 changed files with 92 additions and 41 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,12 @@ and this project adheres to [Semantic Versioning](http://semver.org/)

### Fixed

## [1.9.50] (https://github.com/rainbow-me/rainbow/releases/tag/v1.9.50)

### Fixed

- Fixed an issue with unlocking app icons (#6342, #6345)

## [1.9.49] (https://github.com/rainbow-me/rainbow/releases/tag/v1.9.49)

### Added
Expand Down
4 changes: 2 additions & 2 deletions android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -135,8 +135,8 @@ android {
applicationId "me.rainbow"
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
versionCode 243
versionName "1.9.50"
versionCode 244
versionName "1.9.51"
missingDimensionStrategy 'react-native-camera', 'general'
renderscriptTargetApi 23
renderscriptSupportModeEnabled true
Expand Down
8 changes: 4 additions & 4 deletions ios/Rainbow.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -1883,7 +1883,7 @@
"$(PROJECT_DIR)",
);
LLVM_LTO = YES;
MARKETING_VERSION = 1.9.50;
MARKETING_VERSION = 1.9.51;
OTHER_CFLAGS = "$(inherited)";
OTHER_LDFLAGS = (
"$(inherited)",
Expand Down Expand Up @@ -1951,7 +1951,7 @@
"$(PROJECT_DIR)",
);
LLVM_LTO = YES;
MARKETING_VERSION = 1.9.50;
MARKETING_VERSION = 1.9.51;
OTHER_CFLAGS = "$(inherited)";
OTHER_LDFLAGS = (
"$(inherited)",
Expand Down Expand Up @@ -2072,7 +2072,7 @@
"$(PROJECT_DIR)",
);
LLVM_LTO = YES;
MARKETING_VERSION = 1.9.50;
MARKETING_VERSION = 1.9.51;
OTHER_CFLAGS = "$(inherited)";
OTHER_LDFLAGS = (
"$(inherited)",
Expand Down Expand Up @@ -2192,7 +2192,7 @@
"$(PROJECT_DIR)",
);
LLVM_LTO = YES;
MARKETING_VERSION = 1.9.50;
MARKETING_VERSION = 1.9.51;
OTHER_CFLAGS = "$(inherited)";
OTHER_LDFLAGS = (
"$(inherited)",
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "Rainbow",
"version": "1.9.50-1",
"version": "1.9.51-1",
"private": true,
"scripts": {
"setup": "yarn graphql-codegen:install && yarn ds:install && yarn allow-scripts && yarn graphql-codegen && yarn fetch:networks",
Expand Down
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
79 changes: 52 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,27 @@ 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!`);

// Temporarily ignore some icons
// We can get rid of this in 2025!
const iconsToIgnore = [
'optimism',
'smol',
'zora',
'golddoge',
'raindoge',
'pooly',
'finiliar',
'zorb',
'poolboy',
'adworld',
'farcaster',
];

if (iconsToIgnore.includes(appIconKey)) {
return false;
}

Navigation.handleAction(Routes.APP_ICON_UNLOCK_SHEET, { appIconKey });
return true;
}
Expand Down
23 changes: 19 additions & 4 deletions src/model/migrations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { findKey, isEmpty, isNumber, keys } from 'lodash';
import uniq from 'lodash/uniq';
import RNFS from 'react-native-fs';
import { MMKV } from 'react-native-mmkv';
import FastImage from 'react-native-fast-image';
import { deprecatedRemoveLocal, getGlobal } from '../handlers/localstorage/common';
import { IMAGE_METADATA } from '../handlers/localstorage/globalSettings';
import { getMigrationVersion, setMigrationVersion } from '../handlers/localstorage/migrations';
Expand Down Expand Up @@ -41,7 +42,8 @@ import { useLegacyFavoriteDappsStore } from '@/state/legacyFavoriteDapps';
import { getAddressAndChainIdFromUniqueId, getUniqueId, getUniqueIdNetwork } from '@/utils/ethereumUtils';
import { UniqueId } from '@/__swaps__/types/assets';
import { userAssetsStore } from '@/state/assets/userAssets';
import FastImage from 'react-native-fast-image';
import { UnlockableAppIconKey, unlockableAppIcons } from '@/appIcons/appIcons';
import { unlockableAppIconStorage } from '@/featuresToUnlock/unlockableAppIconCheck';

export default async function runMigrations() {
// get current version
Expand Down Expand Up @@ -699,9 +701,23 @@ export default async function runMigrations() {

/**
*************** Migration v22 ******************
* Clear FastImage cache to fix mainnet badge sizing issue
* Reset icon checks
*/
const v22 = async () => {
// For each appIcon, delete the handled flag
(Object.keys(unlockableAppIcons) as UnlockableAppIconKey[]).map(appIconKey => {
unlockableAppIconStorage.delete(appIconKey);
logger.debug('Resetting icon status for ' + appIconKey);
});
};

migrations.push(v22);

/**
*************** Migration v23 ******************
* Clear FastImage cache to fix mainnet badge sizing issue
*/
const v23 = () => {
try {
FastImage.clearDiskCache();
} catch (e) {
Expand All @@ -715,7 +731,7 @@ export default async function runMigrations() {
}
};

migrations.push(v22);
migrations.push(v23);

logger.debug(`[runMigrations]: ready to run migrations starting on number ${currentVersion}`);
// await setMigrationVersion(17);
Expand All @@ -726,7 +742,6 @@ export default async function runMigrations() {

for (let i = currentVersion; i < migrations.length; i++) {
logger.debug(`[runMigrations]: Running migration v${i}`);
// @ts-expect-error
await migrations[i].apply(null);
logger.debug(`[runMigrations]: Migration ${i} completed succesfully`);
await setMigrationVersion(i + 1);
Expand Down

0 comments on commit 854663a

Please sign in to comment.