Skip to content

Commit

Permalink
Merge branch 'develop' into @matthew/fix-frame-drops
Browse files Browse the repository at this point in the history
  • Loading branch information
walmat authored Jun 7, 2024
2 parents 184e1ea + 6642231 commit b20aa2c
Show file tree
Hide file tree
Showing 49 changed files with 783 additions and 669 deletions.
9 changes: 5 additions & 4 deletions .github/workflows/macstadium-e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,8 @@ jobs:
restore-keys: |
${{ runner.os }}-yarn-
- name: Install dependencies and pods
run: |
yarn setup-ci
yarn install-pods
- name: Install dependencies
run: yarn setup-ci

- name: Check for frozen lockfile
run: yarn check-lockfile
Expand All @@ -58,6 +56,9 @@ jobs:
- name: Rebuild detox cache
run: ./node_modules/.bin/detox clean-framework-cache && ./node_modules/.bin/detox build-framework-cache

- name: Install pods
run: yarn install-pods

- name: Build the app in release mode
run: ./node_modules/.bin/detox build --configuration ios.sim.release | xcpretty --color

Expand Down
19 changes: 19 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,25 @@ and this project adheres to [Semantic Versioning](http://semver.org/)

### Fixed

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

### Added

- Added IDFA check on app launch (#5653)
- Added parallel tests for e2e (#5786)

### Changed

- Changed the size of the coin icon (#5771)
- Updates to Swaps v2 (#5768, #5765, #5772, #5766, #5757, #5776, #5775, #5780, #5778, #5779, #5784, #5782, #5754, #5783, #5791, #5795)
- Bumped reanimated (#5683)

### Fixed

- Fixed a bug where incorrect data would show in pending transactions (#5777)
- Fixed a bug where the swap warning flashes when typing a larger number (#5769)
- Fixed UX on receive sheet QR Code (#5672)

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

### 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 @@ -148,8 +148,8 @@ android {
applicationId "me.rainbow"
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
versionCode 214
versionName "1.9.25"
versionCode 215
versionName "1.9.26"
missingDimensionStrategy 'react-native-camera', 'general'
renderscriptTargetApi 23
renderscriptSupportModeEnabled true
Expand Down
3 changes: 3 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,14 @@ It needs to be an import statement because otherwise it doesn't load properly
likely because of typescript.
*/
import '@walletconnect/react-native-compat';
import { initSentry } from '@/logger/sentry';
import { analytics } from './src/analytics';
import { StartTime } from './src/performance/start-time';
import { PerformanceTracking } from './src/performance/tracking';
import { PerformanceMetrics } from './src/performance/tracking/types/PerformanceMetrics';

initSentry();

analytics.track('Started executing JavaScript bundle');
PerformanceTracking.logDirectly(PerformanceMetrics.loadJSBundle, Date.now() - StartTime.START_TIME);
PerformanceTracking.startMeasuring(PerformanceMetrics.loadRootAppComponent);
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 @@ -1666,7 +1666,7 @@
"$(PROJECT_DIR)",
);
LLVM_LTO = YES;
MARKETING_VERSION = 1.9.25;
MARKETING_VERSION = 1.9.26;
OTHER_CFLAGS = "$(inherited)";
OTHER_CPLUSPLUSFLAGS = "$(OTHER_CFLAGS)";
OTHER_LDFLAGS = (
Expand Down Expand Up @@ -1728,7 +1728,7 @@
"$(PROJECT_DIR)",
);
LLVM_LTO = YES;
MARKETING_VERSION = 1.9.25;
MARKETING_VERSION = 1.9.26;
OTHER_CFLAGS = "$(inherited)";
OTHER_CPLUSPLUSFLAGS = "$(OTHER_CFLAGS)";
OTHER_LDFLAGS = (
Expand Down Expand Up @@ -1835,7 +1835,7 @@
"$(PROJECT_DIR)",
);
LLVM_LTO = YES;
MARKETING_VERSION = 1.9.25;
MARKETING_VERSION = 1.9.26;
OTHER_CFLAGS = "$(inherited)";
OTHER_CPLUSPLUSFLAGS = "$(OTHER_CFLAGS)";
OTHER_LDFLAGS = (
Expand Down Expand Up @@ -1943,7 +1943,7 @@
"$(PROJECT_DIR)",
);
LLVM_LTO = YES;
MARKETING_VERSION = 1.9.25;
MARKETING_VERSION = 1.9.26;
OTHER_CFLAGS = "$(inherited)";
OTHER_CPLUSPLUSFLAGS = "$(OTHER_CFLAGS)";
OTHER_LDFLAGS = (
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.25-1",
"version": "1.9.26-1",
"private": true,
"scripts": {
"setup": "yarn install && yarn graphql-codegen:install && yarn ds:install && yarn allow-scripts && yarn postinstall && yarn graphql-codegen",
Expand Down
15 changes: 5 additions & 10 deletions src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ import { InitialRouteContext } from '@/navigation/initialRoute';
import Routes from '@/navigation/routesNames';
import { Portal } from '@/react-native-cool-modals/Portal';
import { NotificationsHandler } from '@/notifications/NotificationsHandler';
import { initSentry, sentryRoutingInstrumentation } from '@/logger/sentry';
import { analyticsV2 } from '@/analytics';
import { getOrCreateDeviceId, securelyHashWalletAddress } from '@/analytics/utils';
import { logger, RainbowError } from '@/logger';
Expand All @@ -57,9 +56,10 @@ import { handleReviewPromptAction } from '@/utils/reviewAlert';
import { initializeRemoteConfig } from '@/model/remoteConfig';
import { RemoteCardsSync } from './state/sync/RemoteCardsSync';
import { RemotePromoSheetSync } from './state/sync/RemotePromoSheetSync';
import { IS_DEV } from './env';
import { checkIdentifierOnLaunch } from './model/backup';

if (__DEV__) {
if (IS_DEV) {
reactNativeDisableYellowBox && LogBox.ignoreAllLogs();
(showNetworkRequests || showNetworkResponses) && monitorNetwork(showNetworkRequests, showNetworkResponses);
}
Expand Down Expand Up @@ -218,17 +218,13 @@ class OldApp extends Component {
updateBalancesAfter(isL2 ? 10000 : 5000, isL2, network);
};

handleSentryNavigationIntegration = () => {
sentryRoutingInstrumentation?.registerNavigationContainer(this.navigatorRef);
};

render() {
return (
<Portal>
<View style={containerStyle}>
{this.state.initialRoute && (
<InitialRouteContext.Provider value={this.state.initialRoute}>
<RoutesComponent onReady={this.handleSentryNavigationIntegration} ref={this.handleNavigatorRef} />
<RoutesComponent ref={this.handleNavigatorRef} />
<PortalConsumer />
</InitialRouteContext.Provider>
)}
Expand Down Expand Up @@ -257,9 +253,7 @@ function Root() {

React.useEffect(() => {
async function initializeApplication() {
await initSentry(); // must be set up immediately
await initializeRemoteConfig();
// must happen immediately, but after Sentry
await migrate();

const isReturningUser = ls.device.get(['isReturningUser']);
Expand Down Expand Up @@ -339,7 +333,7 @@ function Root() {
// init complete, load the rest of the app
setInitializing(false);
})
.catch(e => {
.catch(() => {
logger.error(new RainbowError(`initializeApplication failed`));

// for failure, continue to rest of the app for now
Expand Down Expand Up @@ -369,6 +363,7 @@ function Root() {
);
}

/** Wrapping Root allows Sentry to accurately track startup times */
const RootWithSentry = Sentry.wrap(Root);

const PlaygroundWithReduxStore = () => (
Expand Down
102 changes: 75 additions & 27 deletions src/__swaps__/safe-math/SafeMath.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,35 @@
// Utility function to remove the decimal point and keep track of the number of decimal places
const removeDecimalWorklet = (num: string): [bigint, number] => {
'worklet';
const parts = num.split('.');
const decimalPlaces = parts.length === 2 ? parts[1].length : 0;
const bigIntNum = BigInt(parts.join(''));
let decimalPlaces = 0;
let bigIntNum: bigint;

if (/[eE]/.test(num)) {
const [base, exponent] = num.split(/[eE]/);
const exp = Number(exponent);
const parts = base.split('.');
const baseDecimalPlaces = parts.length === 2 ? parts[1].length : 0;
const bigIntBase = BigInt(parts.join(''));

if (exp >= 0) {
decimalPlaces = baseDecimalPlaces - exp;
bigIntNum = bigIntBase * BigInt(10) ** BigInt(exp);
} else {
decimalPlaces = baseDecimalPlaces - exp;
bigIntNum = bigIntBase;
}
} else {
const parts = num.split('.');
decimalPlaces = parts.length === 2 ? parts[1].length : 0;
bigIntNum = BigInt(parts.join(''));
}

return [bigIntNum, decimalPlaces];
};

const isNumberStringWorklet = (value: string): boolean => {
'worklet';
return /^-?\d+(\.\d+)?$/.test(value);
return /^-?\d+(\.\d+)?([eE][-+]?\d+)?$/.test(value);
};

const isZeroWorklet = (value: string): boolean => {
Expand All @@ -21,7 +41,7 @@ const isZeroWorklet = (value: string): boolean => {
};

// Utility function to scale the number up to 20 decimal places
const scaleUpWorklet = (bigIntNum: bigint, decimalPlaces: number): bigint => {
export const scaleUpWorklet = (bigIntNum: bigint, decimalPlaces: number): bigint => {
'worklet';
const scaleFactor = BigInt(10) ** BigInt(20);
return (bigIntNum * scaleFactor) / BigInt(10) ** BigInt(decimalPlaces);
Expand All @@ -43,7 +63,11 @@ const formatResultWorklet = (result: bigint): string => {
// Helper function to handle string and number input types
const toStringWorklet = (value: string | number): string => {
'worklet';
return typeof value === 'number' ? value.toString() : value;
const ret = typeof value === 'number' ? value.toString() : value;
if (/^\d+\.$/.test(ret)) {
return ret.slice(0, -1);
}
return ret;
};

// Converts a numeric string to a scaled integer string, preserving the specified decimal places
Expand Down Expand Up @@ -171,27 +195,6 @@ export function modWorklet(num1: string | number, num2: string | number): string
return formatResultWorklet(result);
}

// Power function
export function powWorklet(base: string | number, exponent: string | number): string {
'worklet';
const baseStr = toStringWorklet(base);
const exponentStr = toStringWorklet(exponent);

if (!isNumberStringWorklet(baseStr) || !isNumberStringWorklet(exponentStr)) {
throw new Error('Arguments must be a numeric string or number');
}
if (isZeroWorklet(baseStr)) {
return '0';
}
if (isZeroWorklet(exponentStr)) {
return '1';
}
const [bigIntBase, decimalPlaces] = removeDecimalWorklet(baseStr);
const scaledBigIntBase = scaleUpWorklet(bigIntBase, decimalPlaces);
const result = scaledBigIntBase ** BigInt(exponentStr) / BigInt(10) ** BigInt(20);
return formatResultWorklet(result);
}

// Logarithm base 10 function
export function log10Worklet(num: string | number): string {
'worklet';
Expand Down Expand Up @@ -291,6 +294,41 @@ export function lessThanOrEqualToWorklet(num1: string | number, num2: string | n
return scaledBigInt1 <= scaledBigInt2;
}

// Power function
export function powWorklet(base: string | number, exponent: string | number): string {
'worklet';
const baseStr = toStringWorklet(base);
const exponentStr = toStringWorklet(exponent);

if (!isNumberStringWorklet(baseStr) || !isNumberStringWorklet(exponentStr)) {
throw new Error('Arguments must be a numeric string or number');
}
if (isZeroWorklet(baseStr)) {
return '0';
}
if (isZeroWorklet(exponentStr)) {
return '1';
}
if (exponentStr === '1') {
return baseStr;
}

if (lessThanWorklet(exponentStr, 0)) {
return divWorklet(1, powWorklet(base, Math.abs(Number(exponent))));
}

const [bigIntBase, decimalPlaces] = removeDecimalWorklet(baseStr);
let result;
if (decimalPlaces > 0) {
const scaledBigIntBase = scaleUpWorklet(bigIntBase, decimalPlaces);
result = scaledBigIntBase ** BigInt(exponentStr) / BigInt(10) ** BigInt(20);
return formatResultWorklet(result);
} else {
result = bigIntBase ** BigInt(exponentStr);
return result.toString();
}
}

// toFixed function
export function toFixedWorklet(num: string | number, decimalPlaces: number): string {
'worklet';
Expand Down Expand Up @@ -366,3 +404,13 @@ export function roundWorklet(num: string | number): string {

return formatResultWorklet(roundBigInt);
}

export function minWorklet(numA: string | number, numB: string | number) {
'worklet';
return lessThanOrEqualToWorklet(numA, numB) ? numA : numB;
}

export function maxWorklet(numA: string | number, numB: string | number) {
'worklet';
return greaterThanOrEqualToWorklet(numA, numB) ? numA : numB;
}
8 changes: 8 additions & 0 deletions src/__swaps__/safe-math/__tests__/SafeMath.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,16 +31,22 @@ const RESULTS = {
ceil: '1243426',
floor: '1243425',
toScaledInteger: '57464009350560633',
negativePow: '0.001',
negativeExp: '6.0895415516156',
};

const VALUE_A = '1243425.345';
const VALUE_B = '3819.24';
const VALUE_C = '2';
const VALUE_D = '1243425.745';
const VALUE_E = '0.057464009350560633';
const VALUE_F = '147887324';
const VALUE_G = '4.11769e-8';
const NEGATIVE_VALUE = '-2412.12';
const ZERO = '0';
const ONE = '1';
const TEN = '10';
const MINUS_3 = '-3';
const NON_NUMERIC_STRING = 'abc';

describe('SafeMath', () => {
Expand Down Expand Up @@ -76,6 +82,7 @@ describe('SafeMath', () => {
expect(mulWorklet(VALUE_A, VALUE_B)).toBe(RESULTS.mul);
expect(mulWorklet(Number(VALUE_A), VALUE_B)).toBe(RESULTS.mul);
expect(mulWorklet(VALUE_A, Number(VALUE_B))).toBe(RESULTS.mul);
expect(mulWorklet(VALUE_F, VALUE_G)).toBe(RESULTS.negativeExp);
});

test('divWorklet', () => {
Expand Down Expand Up @@ -108,6 +115,7 @@ describe('SafeMath', () => {
expect(powWorklet(VALUE_A, VALUE_C)).toBe(RESULTS.pow);
expect(powWorklet(Number(VALUE_A), VALUE_C)).toBe(RESULTS.pow);
expect(powWorklet(VALUE_A, Number(VALUE_C))).toBe(RESULTS.pow);
expect(powWorklet(TEN, Number(MINUS_3))).toBe(RESULTS.negativePow);
});

test('log10Worklet', () => {
Expand Down
Loading

0 comments on commit b20aa2c

Please sign in to comment.