Skip to content

Commit 2fc80d6

Browse files
committed
support signBotSignature
1 parent e80f483 commit 2fc80d6

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed

src/webview/client.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,5 +125,23 @@ export const WebViewApi = () => {
125125
break;
126126
}
127127
},
128+
129+
signBotSignature: (appId: string, reloadPublicKey: boolean, method: string, path: string, body: string, callbackFunction: string) => {
130+
switch (getMixinContext().platform) {
131+
case 'iOS':
132+
if (window.webkit && window.webkit.messageHandlers && window.webkit.messageHandlers.signBotSignature) {
133+
window.webkit.messageHandlers.signBotSignature.postMessage([appId, reloadPublicKey, method, path, body, callbackFunction]);
134+
}
135+
break;
136+
case 'Android':
137+
case 'Desktop':
138+
if (window.MixinContext && typeof window.MixinContext.signBotSignature === 'function') {
139+
window.MixinContext.signBotSignature([appId, reloadPublicKey, method, path, body, callbackFunction]);
140+
}
141+
break;
142+
default:
143+
break;
144+
}
145+
},
128146
};
129147
};

src/webview/type.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ export interface Messengers {
2525
getAssets: (assets: string[], globalCallBackFuncName: string) => void;
2626
getTipAddress: (chainId: string, globalCallBackFuncName: string) => void;
2727
tipSign: (chainId: string, message: string, globalCallBackFuncName: string) => void;
28+
signBotSignature: (args: [string, boolean, string, string, string, string]) => void;
2829
}
2930

3031
declare global {
@@ -37,7 +38,8 @@ declare global {
3738
close?: { postMessage: Messengers['close'] };
3839
getAssets?: { postMessage: ([params, globalCallBackFuncName]: [string[], string]) => void };
3940
getTipAddress?: { postMessage: ([chainId, globalCallBackFuncName]: [string, string]) => void };
40-
tipSign?: { postMessage: ([chainId, message, globalCallBackFuncName]: [string, string, string]) => void };
41+
tipSign?: { postMessage: ([chainId, message, globalCallBackFuncName]: [string, string, string]) => void };
42+
signBotSignature?: { postMessage: ([appId, reloadPublicKey, method, path, body, callbackFunctionName]: [string, boolean, string, string, string, string]) => void };
4143
};
4244
};
4345
MixinContext?: {
@@ -48,6 +50,7 @@ declare global {
4850
getAssets?: Messengers['getAssets'];
4951
getTipAddress?: Messengers['getTipAddress'];
5052
tipSign?: Messengers['tipSign'];
53+
signBotSignature: Messengers['signBotSignature'];
5154
};
5255
assetsCallbackFunction?: (res: string) => void;
5356
tipAddressCallbackFunction?: (address: string) => void;

0 commit comments

Comments
 (0)