Skip to content

Commit

Permalink
Merge branch 'main' into feat/display-snap-name
Browse files Browse the repository at this point in the history
  • Loading branch information
k-g-j authored Oct 18, 2024
2 parents cbd2df6 + c74bb78 commit 73b5448
Show file tree
Hide file tree
Showing 88 changed files with 4,397 additions and 2,475 deletions.
8 changes: 1 addition & 7 deletions .depcheckrc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
ignores:
- '@metamask/oss-attribution-generator'
- 'webpack-cli'
- '@react-native-community/datetimepicker'
- '@react-native-community/slider'
- 'patch-package'
- '@lavamoat/allow-scripts'
Expand Down Expand Up @@ -48,22 +49,17 @@ ignores:
- 'rn-nodeify'

## Unused devDependencies to investigate
- '@ethersproject/abi'
- '@metamask/swappable-obj-proxy'
- '@react-native-picker/picker'
- '@rnhooks/keyboard'
- '@segment/sovran-react-native'
- '@tradle/react-native-http'
- 'asyncstorage-down'
- 'buffer'
- 'd3-shape'
- 'dnode'
- 'eciesjs'
- 'eth-block-tracker'
- 'eth-json-rpc-infura'
- 'events'
- 'https-browserify'
- 'obs-store'
- 'path'
- 'pbkdf2'
- 'pify'
Expand All @@ -72,11 +68,9 @@ ignores:
- 'react-native-aes-crypto'
- 'react-native-aes-crypto-forked'
- 'react-native-crypto'
- 'react-native-flash-message'
- 'react-native-level-fs'
- 'react-native-os'
- 'react-native-randombytes'
- 'react-native-redash'
- 'react-native-swipe-gestures'
- 'react-native-tcp'
- 'socket.io-client'
Expand Down
2 changes: 1 addition & 1 deletion .detoxrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ module.exports = {
configurations: {
'ios.sim.apiSpecs': {
device: 'ios.simulator',
app: 'ios.qa',
app: process.env.CI ? 'ios.qa' :'ios.debug',
testRunner: {
args: {
"$0": "node e2e/api-specs/run-api-spec-tests.js",
Expand Down
11 changes: 1 addition & 10 deletions app/components/Nav/App/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,6 @@ import OptionsSheet from '../../UI/SelectOptionSheet/OptionsSheet';
import FoxLoader from '../../../components/UI/FoxLoader';
import { AppStateEventProcessor } from '../../../core/AppStateEventListener';
import MultiRpcModal from '../../../components/Views/MultiRpcModal/MultiRpcModal';
import { trace, TraceName, TraceOperation } from '../../../util/trace';

const clearStackNavigatorOptions = {
headerShown: false,
Expand Down Expand Up @@ -355,15 +354,7 @@ const App = (props) => {
setOnboarded(!!existingUser);
try {
if (existingUser) {
await trace(
{
name: TraceName.BiometricAuthentication,
op: TraceOperation.BiometricAuthentication,
},
async () => {
await Authentication.appTriggeredAuth();
},
);
await Authentication.appTriggeredAuth();
// we need to reset the navigator here so that the user cannot go back to the login screen
navigator.reset({ routes: [{ name: Routes.ONBOARDING.HOME_NAV }] });
} else {
Expand Down
4 changes: 2 additions & 2 deletions app/components/UI/CollectibleContracts/index.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ describe('CollectibleContracts', () => {
AccountsController: MOCK_ACCOUNTS_CONTROLLER_STATE,
NftController: {
allNfts: {
[MOCK_ADDRESS]: {
[MOCK_ADDRESS.toLowerCase()]: {
'0x1': [
{
address: '0x72b1FDb6443338A158DeC2FbF411B71aeB157A42',
Expand Down Expand Up @@ -131,7 +131,7 @@ describe('CollectibleContracts', () => {
},
},
allNftContracts: {
[MOCK_ADDRESS]: {
[MOCK_ADDRESS.toLowerCase()]: {
'0x1': [
{
address: '0x72b1FDb6443338A158DeC2FbF411B71aeB157A42',
Expand Down
22 changes: 4 additions & 18 deletions app/components/UI/LedgerModals/LedgerConfirmationModal.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -407,24 +407,10 @@ describe('LedgerConfirmationModal', () => {
});

it('calls onRejection when user refuses confirmation', async () => {
const onRejection = jest.fn();
(useLedgerBluetooth as jest.Mock).mockReturnValue({
isSendingLedgerCommands: true,
isAppLaunchConfirmationNeeded: false,
ledgerLogicToRun: jest.fn(),
error: LedgerCommunicationErrors.UserRefusedConfirmation,
});

renderWithProvider(
<LedgerConfirmationModal
onConfirmation={jest.fn()}
onRejection={onRejection}
deviceId={'test'}
/>,
checkLedgerCommunicationErrorFlow(
LedgerCommunicationErrors.UserRefusedConfirmation,
strings('ledger.user_reject_transaction'),
strings('ledger.user_reject_transaction_message'),
);
// eslint-disable-next-line no-empty-function
await act(async () => {});

expect(onRejection).toHaveBeenCalled();
});
});
9 changes: 7 additions & 2 deletions app/components/UI/LedgerModals/LedgerConfirmationModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,10 @@ const LedgerConfirmationModal = ({
});
break;
case LedgerCommunicationErrors.UserRefusedConfirmation:
onReject();
setErrorDetails({
title: strings('ledger.user_reject_transaction'),
subtitle: strings('ledger.user_reject_transaction_message'),
});
break;
case LedgerCommunicationErrors.LedgerHasPendingConfirmation:
setErrorDetails({
Expand Down Expand Up @@ -275,7 +278,9 @@ const LedgerConfirmationModal = ({
isRetryHide={
ledgerError === LedgerCommunicationErrors.UnknownError ||
ledgerError === LedgerCommunicationErrors.NonceTooLow ||
ledgerError === LedgerCommunicationErrors.NotSupported
ledgerError === LedgerCommunicationErrors.NotSupported ||
ledgerError === LedgerCommunicationErrors.BlindSignError ||
ledgerError === LedgerCommunicationErrors.UserRefusedConfirmation
}
/>
</View>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { renderScreen } from '../../../../../util/test/renderWithProvider';
import Routes from '../../../../../constants/navigation/Routes';
import { backgroundState } from '../../../../../util/test/initial-root-state';
import { BN } from 'ethereumjs-util';
import { Stake } from '../../sdk/stakeSdkProvider';

function render(Component: React.ComponentType) {
return renderScreen(
Expand Down Expand Up @@ -51,6 +52,17 @@ jest.mock('../../../../../selectors/currencyRateController.ts', () => ({
}));

const mockBalanceBN = new BN('1500000000000000000');

jest.mock('../../hooks/useStakeContext.ts', () => ({
useStakeContext: jest.fn(() => {
const stakeContext: Stake = {
setSdkType: jest.fn(),
sdkService: undefined
}
return stakeContext
})
}))

jest.mock('../../hooks/useBalance', () => ({
__esModule: true,
default: () => ({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import styleSheet from './StakeInputView.styles';
import useStakingInputHandlers from '../../hooks/useStakingInput';
import useBalance from '../../hooks/useBalance';
import InputDisplay from '../../components/InputDisplay';
import { useStakeContext } from '../../hooks/useStakeContext';

const StakeInputView = () => {
const title = strings('stake.stake_eth');
Expand All @@ -43,6 +44,9 @@ const StakeInputView = () => {
estimatedAnnualRewards,
} = useStakingInputHandlers(balanceWei);


const { sdkService } = useStakeContext();

const navigateToLearnMoreModal = () => {
navigation.navigate('StakeModals', {
screen: Routes.STAKING.MODALS.LEARN_MORE,
Expand All @@ -57,7 +61,8 @@ const StakeInputView = () => {
amountFiat: fiatAmount,
},
});
}, [amountWei, fiatAmount, navigation]);
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [amountWei, fiatAmount, navigation, sdkService]);

const balanceText = strings('stake.balance');

Expand Down
2 changes: 1 addition & 1 deletion app/components/UI/Stake/hooks/useBalance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ const useBalance = () => {
[balanceWei, conversionRate],
);

return { balance, balanceFiat, balanceWei, balanceFiatNumber };
return { balance, balanceFiat, balanceWei, balanceFiatNumber, conversionRate, currentCurrency };
};

export default useBalance;
7 changes: 7 additions & 0 deletions app/components/UI/Stake/hooks/useStakeContext.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { useContext } from 'react';
import { Stake, StakeContext } from '../sdk/stakeSdkProvider';

export const useStakeContext = () => {
const context = useContext(StakeContext);
return context as Stake;
};
44 changes: 26 additions & 18 deletions app/components/UI/Stake/routes/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import LearnMoreModal from '../components/LearnMoreModal';
import Routes from '../../../../constants/navigation/Routes';
import StakeConfirmationView from '../Views/StakeConfirmationView/StakeConfirmationView';
import UnstakeInputView from '../Views/UnstakeInputView/UnstakeInputView';
import { StakeSDKProvider } from '../sdk/stakeSdkProvider';
const Stack = createStackNavigator();
const ModalStack = createStackNavigator();

Expand All @@ -18,28 +19,35 @@ const clearStackNavigatorOptions = {

// Regular Stack for Screens
const StakeScreenStack = () => (
<Stack.Navigator>
<Stack.Screen name={Routes.STAKING.STAKE} component={StakeInputView} />
<Stack.Screen name={Routes.STAKING.UNSTAKE} component={UnstakeInputView} />
<Stack.Screen
name={Routes.STAKING.STAKE_CONFIRMATION}
component={StakeConfirmationView}
/>
</Stack.Navigator>
<StakeSDKProvider>
<Stack.Navigator>
<Stack.Screen name={Routes.STAKING.STAKE} component={StakeInputView} />
<Stack.Screen
name={Routes.STAKING.UNSTAKE}
component={UnstakeInputView}
/>
<Stack.Screen
name={Routes.STAKING.STAKE_CONFIRMATION}
component={StakeConfirmationView}
/>
</Stack.Navigator>
</StakeSDKProvider>
);

// Modal Stack for Modals
const StakeModalStack = () => (
<ModalStack.Navigator
mode={'modal'}
screenOptions={clearStackNavigatorOptions}
>
<ModalStack.Screen
name={Routes.STAKING.MODALS.LEARN_MORE}
component={LearnMoreModal}
options={{ headerShown: false }}
/>
</ModalStack.Navigator>
<StakeSDKProvider>
<ModalStack.Navigator
mode={'modal'}
screenOptions={clearStackNavigatorOptions}
>
<ModalStack.Screen
name={Routes.STAKING.MODALS.LEARN_MORE}
component={LearnMoreModal}
options={{ headerShown: false }}
/>
</ModalStack.Navigator>
</StakeSDKProvider>
);

export { StakeScreenStack, StakeModalStack };
Loading

0 comments on commit 73b5448

Please sign in to comment.