diff --git a/src/webview/client.ts b/src/webview/client.ts index af1c1c91..cbf565af 100644 --- a/src/webview/client.ts +++ b/src/webview/client.ts @@ -125,5 +125,23 @@ export const WebViewApi = () => { break; } }, + + signBotSignature: (appId: string, reloadPublicKey: boolean, method: string, path: string, body: string, callbackFunction: string) => { + switch (getMixinContext().platform) { + case 'iOS': + if (window.webkit && window.webkit.messageHandlers && window.webkit.messageHandlers.signBotSignature) { + window.webkit.messageHandlers.signBotSignature.postMessage([appId, reloadPublicKey, method, path, body, callbackFunction]); + } + break; + case 'Android': + case 'Desktop': + if (window.MixinContext && typeof window.MixinContext.signBotSignature === 'function') { + window.MixinContext.signBotSignature([appId, reloadPublicKey, method, path, body, callbackFunction]); + } + break; + default: + break; + } + }, }; }; diff --git a/src/webview/type.ts b/src/webview/type.ts index ea6824ba..7c7bd951 100644 --- a/src/webview/type.ts +++ b/src/webview/type.ts @@ -25,6 +25,7 @@ export interface Messengers { getAssets: (assets: string[], globalCallBackFuncName: string) => void; getTipAddress: (chainId: string, globalCallBackFuncName: string) => void; tipSign: (chainId: string, message: string, globalCallBackFuncName: string) => void; + signBotSignature: (args: [string, boolean, string, string, string, string]) => void; } declare global { @@ -37,7 +38,8 @@ declare global { close?: { postMessage: Messengers['close'] }; getAssets?: { postMessage: ([params, globalCallBackFuncName]: [string[], string]) => void }; getTipAddress?: { postMessage: ([chainId, globalCallBackFuncName]: [string, string]) => void }; - tipSign?: { postMessage: ([chainId, message, globalCallBackFuncName]: [string, string, string]) => void }; + tipSign?: { postMessage: ([chainId, message, globalCallBackFuncName]: [string, string, string]) => void }; + signBotSignature?: { postMessage: ([appId, reloadPublicKey, method, path, body, callbackFunctionName]: [string, boolean, string, string, string, string]) => void }; }; }; MixinContext?: { @@ -48,6 +50,7 @@ declare global { getAssets?: Messengers['getAssets']; getTipAddress?: Messengers['getTipAddress']; tipSign?: Messengers['tipSign']; + signBotSignature: Messengers['signBotSignature']; }; assetsCallbackFunction?: (res: string) => void; tipAddressCallbackFunction?: (address: string) => void;