88import type { MethodHandler , BioAccount } from '../types'
99import { BioErrorCodes } from '../types'
1010import { HandlerContext } from './context'
11+ import { enqueueMiniappSheet } from '../sheet-queue'
1112import {
1213 toHexChainId ,
1314 parseHexChainId ,
@@ -132,7 +133,10 @@ export const handleEthRequestAccounts: MethodHandler = async (_params, context)
132133 }
133134
134135 const chainId = getCurrentChainId ( context . appId )
135- const wallet = await showWalletPicker ( { chainId, app : { name : context . appName , icon : context . appIcon } } )
136+
137+ const wallet = await enqueueMiniappSheet ( context . appId , ( ) =>
138+ showWalletPicker ( { chainId, app : { name : context . appName , icon : context . appIcon } } ) ,
139+ )
136140 if ( ! wallet ) {
137141 throw Object . assign ( new Error ( 'User rejected' ) , { code : BioErrorCodes . USER_REJECTED } )
138142 }
@@ -173,12 +177,14 @@ export const handleSwitchChain: MethodHandler = async (params, context) => {
173177
174178 // Show confirmation dialog
175179 if ( _showChainSwitchConfirm ) {
176- const approved = await _showChainSwitchConfirm ( {
177- fromChainId : currentChainId ,
178- toChainId : targetChainId ,
179- appName : context . appName ,
180- appIcon : context . appIcon ,
181- } )
180+ const approved = await enqueueMiniappSheet ( context . appId , ( ) =>
181+ _showChainSwitchConfirm ( {
182+ fromChainId : currentChainId ,
183+ toChainId : targetChainId ,
184+ appName : context . appName ,
185+ appIcon : context . appIcon ,
186+ } ) ,
187+ )
182188 if ( ! approved ) {
183189 throw Object . assign ( new Error ( 'User rejected' ) , { code : BioErrorCodes . USER_REJECTED } )
184190 }
@@ -211,7 +217,9 @@ export const handlePersonalSign: MethodHandler = async (params, context) => {
211217 throw Object . assign ( new Error ( 'Signing dialog not available' ) , { code : BioErrorCodes . INTERNAL_ERROR } )
212218 }
213219
214- const result = await showSigningDialog ( { message, address, appName : context . appName } )
220+ const result = await enqueueMiniappSheet ( context . appId , ( ) =>
221+ showSigningDialog ( { message, address, appName : context . appName } ) ,
222+ )
215223 if ( ! result ) {
216224 throw Object . assign ( new Error ( 'User rejected' ) , { code : BioErrorCodes . USER_REJECTED } )
217225 }
@@ -243,11 +251,13 @@ export const handleSignTypedDataV4: MethodHandler = async (params, context) => {
243251 // Format typed data for display
244252 const displayMessage = JSON . stringify ( data , null , 2 )
245253
246- const result = await showSigningDialog ( {
247- message : displayMessage ,
248- address,
249- appName : context . appName ,
250- } )
254+ const result = await enqueueMiniappSheet ( context . appId , ( ) =>
255+ showSigningDialog ( {
256+ message : displayMessage ,
257+ address,
258+ appName : context . appName ,
259+ } ) ,
260+ )
251261 if ( ! result ) {
252262 throw Object . assign ( new Error ( 'User rejected' ) , { code : BioErrorCodes . USER_REJECTED } )
253263 }
@@ -272,7 +282,7 @@ export const handleEthSendTransaction: MethodHandler = async (params, context) =
272282 tx . chainId = getCurrentChainId ( context . appId )
273283 }
274284
275- const result = await showTransactionDialog ( { tx, appName : context . appName } )
285+ const result = await enqueueMiniappSheet ( context . appId , ( ) => showTransactionDialog ( { tx, appName : context . appName } ) )
276286 if ( ! result ) {
277287 throw Object . assign ( new Error ( 'User rejected' ) , { code : BioErrorCodes . USER_REJECTED } )
278288 }
0 commit comments