From 25656530b83634e17641d5cd914718ed2870c7c5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20=27birdy=27=20Danjou?= Date: Fri, 3 Jan 2025 14:12:13 +0100 Subject: [PATCH] chore: replace reencrypt by decrypt --- src/sdk/index.ts | 34 ++++++++++++++++++++++++++-------- 1 file changed, 26 insertions(+), 8 deletions(-) diff --git a/src/sdk/index.ts b/src/sdk/index.ts index 528c410..af229dc 100644 --- a/src/sdk/index.ts +++ b/src/sdk/index.ts @@ -28,6 +28,17 @@ export type FhevmInstance = { contractAddress: string, delegatedAccount?: string, ) => EIP712; + decrypt: ( + handle: bigint, + privateKey: string, + publicKey: string, + signature: string, + contractAddress: string, + userAddress: string, + ) => Promise; + /** + * @deprecated This method is replaced by decrypt, using same parameters + */ reencrypt: ( handle: bigint, privateKey: string, @@ -74,6 +85,14 @@ export const createInstance = async ( const publicParamsData = await getPublicParams(config); const kmsSigners = await getKMSSigners(provider, config); + const decrypt = reencryptRequest( + kmsSigners, + chainId, + kmsContractAddress, + aclContractAddress, + cleanURL(config.gatewayUrl), + provider, + ); return { createEncryptedInput: createEncryptedInput( @@ -86,14 +105,13 @@ export const createInstance = async ( ), generateKeypair, createEIP712: createEIP712(chainId), - reencrypt: reencryptRequest( - kmsSigners, - chainId, - kmsContractAddress, - aclContractAddress, - cleanURL(config.gatewayUrl), - provider, - ), + decrypt, + reencrypt(...params) { + console.warn( + "Warning: 'reencrypt' is deprecated and will be removed in future versions. Please use 'decrypt' instead, which accepts the same parameters.", + ); + return decrypt(...params); + }, getPublicKey: () => publicKeyData.publicKey ? {