From 11230ec1ca772e2814ff05566391943753f70cc3 Mon Sep 17 00:00:00 2001 From: Mikhala Date: Mon, 1 Jul 2024 09:24:16 +0800 Subject: [PATCH] add comments --- packages/passport/sdk/src/utils/string.ts | 2 +- packages/passport/sdk/src/zkEvm/personalSign.ts | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/passport/sdk/src/utils/string.ts b/packages/passport/sdk/src/utils/string.ts index 15a15acf48..77c3c50c1e 100644 --- a/packages/passport/sdk/src/utils/string.ts +++ b/packages/passport/sdk/src/utils/string.ts @@ -4,8 +4,8 @@ export const hexToString = async (hex: string) => { if (!hex) return hex; try { + // Ensures Buffer is available when using the browser bundle of the SDK if (typeof window !== 'undefined' && !window.Buffer) { - // Use dynamic import to load Buffer const bufferModule = await import('buffer'); window.Buffer = bufferModule.Buffer; } diff --git a/packages/passport/sdk/src/zkEvm/personalSign.ts b/packages/passport/sdk/src/zkEvm/personalSign.ts index 369ad2b742..19aa5a722f 100644 --- a/packages/passport/sdk/src/zkEvm/personalSign.ts +++ b/packages/passport/sdk/src/zkEvm/personalSign.ts @@ -38,6 +38,7 @@ export const personalSign = async ({ throw new JsonRpcError(RpcErrorCode.INVALID_PARAMS, 'personal_sign requires the signer to be the from address'); } + // Convert message into a string if it's a hex const payload = await hexToString(message); const { chainId } = await rpcProvider.detectNetwork(); flow.addEvent('endDetectNetwork');