Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/develop' into feat/upgrade_redirect
Browse files Browse the repository at this point in the history
  • Loading branch information
richardo2016x committed Jun 5, 2024
2 parents ff6cd14 + 32db62b commit 24a3fd1
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 4 deletions.
6 changes: 5 additions & 1 deletion apps/mobile/src/core/apis/buildinProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { notificationService, preferenceService } from '../services';
import providerController from '@/core/controllers/provider';
import { findChain } from '@/utils/chain';
import { sendRequest } from './provider';
import { setGlobalProvider } from './globalProvider';

interface StateProvider {
accounts: string[] | null;
Expand Down Expand Up @@ -211,8 +212,11 @@ const provider = new EthereumProvider();

// window.dispatchEvent(new Event('ethereum#initialized'));

export default {
const buildinProvider = {
currentProvider: new Proxy(provider, {
deleteProperty: () => true,
}),
};
setGlobalProvider(buildinProvider);

export default buildinProvider;
11 changes: 11 additions & 0 deletions apps/mobile/src/core/apis/globalProvider.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
const store = {
provider: null,
};

export function setGlobalProvider(provider: any) {
store.provider = provider;
}

export function getGlobalProvider(): any {
return store.provider;
}
6 changes: 5 additions & 1 deletion apps/mobile/src/core/controllers/provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@ import { INTERNAL_REQUEST_SESSION } from '@/constant';
import { matomoRequestEvent } from '@/utils/analytics';
import { stats } from '@/utils/stats';
import { StatsData } from '../services/notification';
import buildinProvider from '../apis/buildinProvider';
import { ethers } from 'ethers';
import { getGlobalProvider } from '../apis/globalProvider';
// import eventBus from '@/eventBus';

const reportSignText = (params: {
Expand Down Expand Up @@ -466,6 +466,10 @@ class ProviderController extends BaseController {
let opts;
opts = extra;
if (currentAccount.type === KEYRING_TYPE.GnosisKeyring) {
const buildinProvider = getGlobalProvider();
if (!buildinProvider?.currentProvider) {
throw new Error('buildinProvider not found');
}
buildinProvider.currentProvider.currentAccount =
approvalRes!.account!.address;
buildinProvider.currentProvider.currentAccountType =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ import { GnosisTransactionItem } from './GnosisTransactionItem';
import { AccountSelectPopup } from '@/components/AccountSelectPopup';
import { intToHex } from '@/utils/number';
import { toast } from '@/components/Toast';
import { StackActions, useNavigation } from '@react-navigation/native';
import { RootNames } from '@/constant/layout';

export type ConfirmationProps = {
owner: string;
Expand Down Expand Up @@ -269,7 +271,7 @@ export const GnosisTransactionQueueList = (props: {
setSubmitDrawerVisible(true);
},
);

const navigation = useNavigation();
const handleConfirm = async (account: KeyringAccountWithAlias) => {
if (!safeInfo) {
return;
Expand Down Expand Up @@ -312,6 +314,11 @@ export const GnosisTransactionQueueList = (props: {
setSubmitDrawerVisible(false);
setSubmitTransaction(null);
reload?.();
navigation.dispatch(
StackActions.replace(RootNames.StackRoot, {
screen: RootNames.Home,
}),
);
} catch (e: any) {
// toast.info(e.message || JSON.stringify(e));
console.log('execGnosisTransaction error', e);
Expand Down
10 changes: 9 additions & 1 deletion apps/mobile/src/screens/Home/components/HomeTopArea.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,15 @@ export const HomeTopArea = () => {
<BadgeText count={item.badge} style={item.badgeStyle} />
)}
</View>
<Text style={styles.actionText}>{item.title}</Text>
<Text
style={[
styles.actionText,
{
fontSize: actions.length > 4 ? 13 : 14,
},
]}>
{item.title}
</Text>
</TouchableView>
))}
</View>
Expand Down

0 comments on commit 24a3fd1

Please sign in to comment.