From 3d809802f09ada5ab467ff4295d37b47b2e122fb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20=27birdy=27=20Danjou?= Date: Wed, 6 Dec 2023 15:33:04 +0100 Subject: [PATCH] fix() decode public key --- src/fhevmjs.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/fhevmjs.ts b/src/fhevmjs.ts index ccb759f..a4d7e59 100644 --- a/src/fhevmjs.ts +++ b/src/fhevmjs.ts @@ -1,3 +1,4 @@ +import { AbiCoder } from 'ethers'; import { BrowserProvider, getAddress } from 'ethers'; import { ExportedContractKeypairs, FhevmInstance, createInstance, initFhevm } from 'fhevmjs'; @@ -13,10 +14,12 @@ export const createFhevmInstance = async (account: string) => { const provider = new BrowserProvider(window.ethereum); const network = await provider.getNetwork(); const chainId = +network.chainId.toString(); - const publicKey = await provider.call({ + const ret = await provider.call({ to: '0x000000000000000000000000000000000000005d', data: '0xd9d47bb001', }); + const decoded = AbiCoder.defaultAbiCoder().decode(['bytes'], ret); + const publicKey = decoded[0]; const strKP = getStorage(account); const keypairs: ExportedContractKeypairs | undefined = strKP ? JSON.parse(strKP) : undefined; instances[account] = await createInstance({ chainId, publicKey, keypairs });