diff --git a/apps/mobile/src/core/apis/buildinProvider.ts b/apps/mobile/src/core/apis/buildinProvider.ts index cec4c31e8..32f16eb45 100644 --- a/apps/mobile/src/core/apis/buildinProvider.ts +++ b/apps/mobile/src/core/apis/buildinProvider.ts @@ -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; @@ -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; diff --git a/apps/mobile/src/core/apis/globalProvider.ts b/apps/mobile/src/core/apis/globalProvider.ts new file mode 100644 index 000000000..062cfce55 --- /dev/null +++ b/apps/mobile/src/core/apis/globalProvider.ts @@ -0,0 +1,11 @@ +const store = { + provider: null, +}; + +export function setGlobalProvider(provider: any) { + store.provider = provider; +} + +export function getGlobalProvider(): any { + return store.provider; +} diff --git a/apps/mobile/src/core/controllers/provider.ts b/apps/mobile/src/core/controllers/provider.ts index c4f7daf44..0cb9ca6e6 100644 --- a/apps/mobile/src/core/controllers/provider.ts +++ b/apps/mobile/src/core/controllers/provider.ts @@ -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: { @@ -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 = diff --git a/apps/mobile/src/screens/GnosisTransactionQueue/components/GnosisTransactionQueueList.tsx b/apps/mobile/src/screens/GnosisTransactionQueue/components/GnosisTransactionQueueList.tsx index c8d81a769..59bd73f38 100644 --- a/apps/mobile/src/screens/GnosisTransactionQueue/components/GnosisTransactionQueueList.tsx +++ b/apps/mobile/src/screens/GnosisTransactionQueue/components/GnosisTransactionQueueList.tsx @@ -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; @@ -269,7 +271,7 @@ export const GnosisTransactionQueueList = (props: { setSubmitDrawerVisible(true); }, ); - + const navigation = useNavigation(); const handleConfirm = async (account: KeyringAccountWithAlias) => { if (!safeInfo) { return; @@ -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); diff --git a/apps/mobile/src/screens/Home/components/HomeTopArea.tsx b/apps/mobile/src/screens/Home/components/HomeTopArea.tsx index 13261afa1..c76266618 100644 --- a/apps/mobile/src/screens/Home/components/HomeTopArea.tsx +++ b/apps/mobile/src/screens/Home/components/HomeTopArea.tsx @@ -233,7 +233,15 @@ export const HomeTopArea = () => { )} - {item.title} + 4 ? 13 : 14, + }, + ]}> + {item.title} + ))}