feat: migrate from @zama-fhe/relayer-sdk to @fhevm/sdk#275
feat: migrate from @zama-fhe/relayer-sdk to @fhevm/sdk#275ghermet wants to merge 7 commits intoprereleasefrom
Conversation
143f44e to
c3e383e
Compare
…ha.1 Replace the CDN-loaded @zama-fhe/relayer-sdk with @fhevm/sdk as a build-time dependency. Workers now use FhevmClient (action-based API) instead of FhevmInstance (method-based). EIP-712 typed data is stored alongside credentials and passed through the full decrypt pipeline for permit parsing. Key changes: - Rewrite web and node workers for @fhevm/sdk client API - Add StoredEIP712 type to credentials for permit reconstruction - Define relayer types locally instead of importing from @zama-fhe/relayer-sdk - Use @fhevm/sdk return types for EIP-712 response data - Pass eip712 through decrypt pipeline (credentials → token → relayer → worker) Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Widen ClearValueType to include `number` for SDK's branded uint8/16/32 - Remove all `as unknown as Hex/string` casts (SDK branded types are subtypes) - Remove redundant `client as FhevmClientInstance` casts after assertClient - Type decrypt result mappings directly as response types - Add missing `eip712` field to cleartext test fixtures - Fix EIP-712 test expectations from string to bigint - Regenerate API reports for updated public surface Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Move @fhevm/sdk/actions/chain imports to dynamic `await import()` in handleCreateEIP712 and handleCreateDelegatedEIP712, matching the existing pattern for @fhevm/sdk/ethers in handleNodeInit. Update API reports. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2201cee to
41df7a9
Compare
The migration from CDN-loaded @zama-fhe/relayer-sdk to build-time @fhevm/sdk bundles WASM binaries (~7.2 MB) inline. Raise limits to match the new architecture: ESM 6 MB, CJS 2 MB. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Escape package names in JSDoc comments so api-extractor does not misinterpret them as TSDoc block tags. Regenerate API reports. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Public API ChangesExpand to see full diffdiff -ru a/react-sdk.api.md b/react-sdk.api.md
--- a/react-sdk.api.md 2026-04-21 09:34:04.620119896 +0000
+++ b/react-sdk.api.md 2026-04-21 09:34:04.653152448 +0000
@@ -5,9 +5,9 @@
```ts
import * as _$_tanstack_react_query0 from '@tanstack/react-query';
-import * as _$_zama_fhe_relayer_sdk_web0 from '@zama-fhe/relayer-sdk/web';
import * as _$_zama_fhe_sdk0 from '@zama-fhe/sdk';
import * as _$react_jsx_runtime0 from 'react/jsx-runtime';
+import * as _$viem from 'viem';
import { Address } from '@zama-fhe/sdk';
import { ApproveUnderlyingParams } from '@zama-fhe/sdk/query';
import { BatchBalancesResult } from '@zama-fhe/sdk';
@@ -25,12 +25,15 @@
import { DelegationStatusData } from '@zama-fhe/sdk/query';
import { EIP712TypedData } from '@zama-fhe/sdk';
import { EncryptParams } from '@zama-fhe/sdk';
+import { EncryptResult } from '@zama-fhe/sdk';
import { FinalizeUnwrapParams } from '@zama-fhe/sdk/query';
import { GenericSigner } from '@zama-fhe/sdk';
import { GenericStorage } from '@zama-fhe/sdk';
import { PaginatedResult } from '@zama-fhe/sdk';
import { PropsWithChildren } from 'react';
+import { PublicDecryptResult } from '@zama-fhe/sdk';
import { PublicKeyData } from '@zama-fhe/sdk';
+import { PublicParamsData } from '@zama-fhe/sdk';
import { ReadonlyToken } from '@zama-fhe/sdk';
import { RelayerSDK } from '@zama-fhe/sdk';
import { ResumeUnshieldParams } from '@zama-fhe/sdk/query';
@@ -49,7 +52,6 @@
import { UserDecryptQueryConfig } from '@zama-fhe/sdk/query';
import { ZamaSDK } from '@zama-fhe/sdk';
import { ZamaSDKEventListener } from '@zama-fhe/sdk';
-import { ZKProofLike } from '@zama-fhe/sdk';
// @public
export function useAllow(options?: UseMutationOptions<void, Error, Address[]>): _$_tanstack_react_query0.UseMutationResult<void, Error, `0x${string}`[], unknown>;
@@ -125,12 +127,7 @@
export function useConfidentialTransferFrom(config: UseZamaConfig, options?: UseMutationOptions<TransactionResult, Error, ConfidentialTransferFromParams, Address>): _$_tanstack_react_query0.UseMutationResult<TransactionResult, Error, ConfidentialTransferFromParams, `0x${string}`>;
// @public
-export function useCreateDelegatedUserDecryptEIP712(): _$_tanstack_react_query0.UseMutationResult<Readonly<{
- types: _$_zama_fhe_relayer_sdk_web0.KmsDelegatedUserDecryptEIP712TypesType;
- primaryType: "DelegatedUserDecryptRequestVerification";
- domain: _$_zama_fhe_relayer_sdk_web0.KmsEIP712DomainType;
- message: _$_zama_fhe_relayer_sdk_web0.KmsDelegatedUserDecryptEIP712MessageType;
-}>, Error, CreateDelegatedUserDecryptEIP712Params, unknown>;
+export function useCreateDelegatedUserDecryptEIP712(): _$_tanstack_react_query0.UseMutationResult<EIP712TypedData, Error, CreateDelegatedUserDecryptEIP712Params, unknown>;
// @public
export function useCreateEIP712(): _$_tanstack_react_query0.UseMutationResult<EIP712TypedData, Error, CreateEIP712Params, unknown>;
@@ -155,16 +152,16 @@
}
// @public
-export function useEncrypt(): _$_tanstack_react_query0.UseMutationResult<Readonly<{
- handles: Uint8Array[];
- inputProof: Uint8Array;
-}>, Error, EncryptParams, unknown>;
+export function useEncrypt(): _$_tanstack_react_query0.UseMutationResult<EncryptResult, Error, EncryptParams, unknown>;
// @public
export function useFinalizeUnwrap(config: UseZamaConfig, options?: UseMutationOptions<TransactionResult, Error, FinalizeUnwrapParams, Address>): _$_tanstack_react_query0.UseMutationResult<TransactionResult, Error, FinalizeUnwrapParams, `0x${string}`>;
// @public
-export function useGenerateKeypair(): _$_tanstack_react_query0.UseMutationResult<_$_zama_fhe_sdk0.KeypairType<`0x${string}`>, Error, void, unknown>;
+export function useGenerateKeypair(): _$_tanstack_react_query0.UseMutationResult<{
+ publicKey: _$viem.Hex;
+ privateKey: _$viem.Hex;
+}, Error, void, unknown>;
// @public
export function useIsAllowed(config: UseIsAllowedConfig): _$_tanstack_react_query0.UseQueryResult<boolean, Error>;
@@ -205,29 +202,19 @@
export function useMetadataSuspense(tokenAddress: Address): _$_tanstack_react_query0.UseSuspenseQueryResult<TokenMetadata, Error>;
// @public
-export function usePublicDecrypt(): _$_tanstack_react_query0.UseMutationResult<Readonly<{
- clearValues: _$_zama_fhe_relayer_sdk_web0.ClearValues;
- abiEncodedClearValues: `0x${string}`;
- decryptionProof: `0x${string}`;
-}>, Error, `0x${string}`[], unknown>;
+export function usePublicDecrypt(): _$_tanstack_react_query0.UseMutationResult<PublicDecryptResult, Error, `0x${string}`[], unknown>;
// @public
export function usePublicKey(): _$_tanstack_react_query0.UseQueryResult<PublicKeyData | null, Error>;
// @public
-export function usePublicParams(bits: number): _$_tanstack_react_query0.UseQueryResult<{
- publicParams: Uint8Array<ArrayBufferLike>;
- publicParamsId: string;
-} | null, Error>;
+export function usePublicParams(bits: number): _$_tanstack_react_query0.UseQueryResult<PublicParamsData | null, Error>;
// @public
export function useReadonlyToken(address: Address): _$_zama_fhe_sdk0.ReadonlyToken;
// @public
-export function useRequestZKProofVerification(): _$_tanstack_react_query0.UseMutationResult<Readonly<{
- handles: Uint8Array[];
- inputProof: Uint8Array;
-}>, Error, ZKProofLike, unknown>;
+export function useRequestZKProofVerification(): _$_tanstack_react_query0.UseMutationResult<EncryptResult, Error, unknown, unknown>;
// @public
export function useResumeUnshield(config: UseZamaConfig, options?: UseMutationOptions<TransactionResult, Error, ResumeUnshieldParams, Address>): _$_tanstack_react_query0.UseMutationResult<TransactionResult, Error, ResumeUnshieldParams, `0x${string}`>;
@@ -305,7 +292,7 @@
export function useUnwrapAll(config: UseZamaConfig, options?: UseMutationOptions<TransactionResult, Error, void, Address>): _$_tanstack_react_query0.UseMutationResult<TransactionResult, Error, void, `0x${string}`>;
// @public
-export function useUserDecrypt(config: UserDecryptQueryConfig, options?: Omit<UseQueryOptions<DecryptResult>, "queryKey" | "queryFn">): _$_tanstack_react_query0.UseQueryResult<Readonly<Record<`0x${string}`, _$_zama_fhe_sdk0.ClearValueType>>, Error>;
+export function useUserDecrypt(config: UserDecryptQueryConfig, options?: Omit<UseQueryOptions<DecryptResult>, "queryKey" | "queryFn">): _$_tanstack_react_query0.UseQueryResult<DecryptResult, Error>;
// @public
export type UseUserDecryptResult = ReturnType<typeof useUserDecrypt>;
diff -ru a/sdk-ethers.api.md b/sdk-ethers.api.md
--- a/sdk-ethers.api.md 2026-04-21 09:34:04.623119874 +0000
+++ b/sdk-ethers.api.md 2026-04-21 09:34:04.652119667 +0000
@@ -6,7 +6,6 @@
import { Abi } from 'viem';
import { Address } from 'viem';
-import { Bytes32Hex } from '@zama-fhe/relayer-sdk/bundle';
import { ContractFunctionArgs } from 'viem';
import { ContractFunctionName } from 'viem';
import { ContractFunctionReturnType } from 'viem';
@@ -15,8 +14,6 @@
import { EIP1193Provider } from 'viem';
import { ethers } from 'ethers';
import { Hex } from 'viem';
-import { KmsDelegatedUserDecryptEIP712Type } from '@zama-fhe/relayer-sdk/bundle';
-import { KmsUserDecryptEIP712Type } from '@zama-fhe/relayer-sdk/bundle';
import { ProviderConnectInfo } from 'viem';
import { ProviderMessage } from 'viem';
import { ProviderRpcError } from 'viem';
diff -ru a/sdk-node.api.md b/sdk-node.api.md
--- a/sdk-node.api.md 2026-04-21 09:34:04.627119846 +0000
+++ b/sdk-node.api.md 2026-04-21 09:34:04.652730255 +0000
@@ -5,23 +5,8 @@
```ts
import { Address } from 'viem';
-import { Bytes32Hex } from '@zama-fhe/relayer-sdk/bundle';
-import { ClearValueType } from '@zama-fhe/relayer-sdk/bundle';
-import { FhevmInstanceConfig } from '@zama-fhe/relayer-sdk/bundle';
-import { FhevmInstanceConfig as FhevmInstanceConfig_2 } from '@zama-fhe/relayer-sdk/node';
import { Hex } from 'viem';
-import { InputProofBytesType } from '@zama-fhe/relayer-sdk/bundle';
-import { InputProofBytesType as InputProofBytesType_2 } from '@zama-fhe/relayer-sdk/node';
-import { KeypairType } from '@zama-fhe/relayer-sdk/bundle';
-import { KeypairType as KeypairType_2 } from '@zama-fhe/relayer-sdk/node';
-import { KmsDelegatedUserDecryptEIP712Type } from '@zama-fhe/relayer-sdk/bundle';
-import { KmsDelegatedUserDecryptEIP712Type as KmsDelegatedUserDecryptEIP712Type_2 } from '@zama-fhe/relayer-sdk/node';
-import { KmsUserDecryptEIP712Type } from '@zama-fhe/relayer-sdk/bundle';
-import { PublicDecryptResults } from '@zama-fhe/relayer-sdk/bundle';
-import * as SDK from '@zama-fhe/relayer-sdk/bundle';
import { Worker as Worker_2 } from 'node:worker_threads';
-import { ZKProofLike } from '@zama-fhe/relayer-sdk/bundle';
-import { ZKProofLike as ZKProofLike_2 } from '@zama-fhe/relayer-sdk/node';
// Warning: (ae-forgotten-export) The symbol "GenericStorage" needs to be exported by the entry point index.d.ts
//
@@ -89,7 +74,7 @@
// (undocumented)
publicDecrypt(handles: Handle[]): Promise<PublicDecryptResponseData>;
// (undocumented)
- requestZKProofVerification(zkProof: ZKProofLike): Promise<RequestZKProofVerificationResponseData>;
+ requestZKProofVerification(zkProof: unknown): Promise<RequestZKProofVerificationResponseData>;
// (undocumented)
protected sendRequest<T>(type: WorkerRequestType, payload: WorkerRequest["payload"], timeoutMs?: number): Promise<T>;
// (undocumented)
@@ -102,7 +87,8 @@
protected abstract wireEvents(worker: TWorker): void;
}
-export { ClearValueType }
+// @public
+export type ClearValueType = number | bigint | boolean | `0x${string}`;
// @public (undocumented)
export type CreateDelegatedEIP712Payload = CreateDelegatedEIP712Request["payload"];
@@ -121,8 +107,10 @@
type: "CREATE_DELEGATED_EIP712";
}
+// Warning: (ae-forgotten-export) The symbol "KmsDelegatedUserDecryptEip712" needs to be exported by the entry point index.d.ts
+//
// @public (undocumented)
-export type CreateDelegatedEIP712ResponseData = KmsDelegatedUserDecryptEIP712Type;
+export type CreateDelegatedEIP712ResponseData = KmsDelegatedUserDecryptEip712;
// @public (undocumented)
export type CreateEIP712Payload = CreateEIP712Request["payload"];
@@ -140,8 +128,10 @@
type: "CREATE_EIP712";
}
+// Warning: (ae-forgotten-export) The symbol "KmsUserDecryptEip712" needs to be exported by the entry point index.d.ts
+//
// @public (undocumented)
-export type CreateEIP712ResponseData = KmsUserDecryptEIP712Type;
+export type CreateEIP712ResponseData = KmsUserDecryptEip712;
// @public
export interface DelegatedUserDecryptParams {
@@ -153,6 +143,10 @@
delegatorAddress: Address;
// (undocumented)
durationDays: number;
+ // Warning: (ae-forgotten-export) The symbol "StoredEIP712" needs to be exported by the entry point index.d.ts
+ //
+ // (undocumented)
+ eip712: StoredEIP712;
// (undocumented)
handles: Handle[];
// (undocumented)
@@ -184,6 +178,7 @@
delegateAddress: Address;
startTimestamp: number;
durationDays: number;
+ eip712: StoredEIP712;
};
// (undocumented)
type: "DELEGATED_USER_DECRYPT";
@@ -196,7 +191,20 @@
}
// @public
-export type EIP712TypedData = KmsUserDecryptEIP712Type | KmsDelegatedUserDecryptEIP712Type;
+export type EIP712TypedData = {
+ readonly domain: {
+ readonly name: string;
+ readonly version: string;
+ readonly chainId: bigint;
+ readonly verifyingContract: `0x${string}`;
+ };
+ readonly types: Record<string, readonly {
+ readonly name: string;
+ readonly type: string;
+ }[]>;
+ readonly primaryType: string;
+ readonly message: Record<string, unknown>;
+};
// @public
export interface EncryptParams {
@@ -224,10 +232,20 @@
}
// @public (undocumented)
-export type EncryptResponseData = InputProofBytesType;
+export interface EncryptResponseData {
+ // (undocumented)
+ handles: Uint8Array[];
+ // (undocumented)
+ inputProof: Uint8Array;
+}
// @public
-export type EncryptResult = InputProofBytesType;
+export interface EncryptResult {
+ // (undocumented)
+ handles: Uint8Array[];
+ // (undocumented)
+ inputProof: Uint8Array;
+}
// Warning: (ae-forgotten-export) The symbol "BaseResponse" needs to be exported by the entry point index.d.ts
//
@@ -409,7 +427,7 @@
// (undocumented)
publicDecrypt(handles: Handle[]): Promise<PublicDecryptResponseData>;
// (undocumented)
- requestZKProofVerification(zkProof: ZKProofLike): Promise<RequestZKProofVerificationResponseData>;
+ requestZKProofVerification(zkProof: unknown): Promise<RequestZKProofVerificationResponseData>;
// (undocumented)
terminate(): void;
// (undocumented)
@@ -437,20 +455,27 @@
// (undocumented)
abiEncodedClearValues: Hex;
// (undocumented)
- clearValues: Readonly<Record<Handle, ClearValueType>>;
+ clearValues: Record<Handle, ClearValueType>;
// (undocumented)
decryptionProof: Hex;
}
// @public
-export type PublicDecryptResult = PublicDecryptResults;
+export interface PublicDecryptResult {
+ // (undocumented)
+ abiEncodedClearValues: Hex;
+ // (undocumented)
+ clearValues: Readonly<Record<Handle, ClearValueType>>;
+ // (undocumented)
+ decryptionProof: Hex;
+}
// @public
export class RelayerNode implements RelayerSDK, Disposable {
[Symbol.dispose](): void;
constructor(config: RelayerNodeConfig);
// (undocumented)
- createDelegatedUserDecryptEIP712(publicKey: Hex, contractAddresses: Address[], delegatorAddress: Address, startTimestamp: number, durationDays?: number): Promise<KmsDelegatedUserDecryptEIP712Type_2>;
+ createDelegatedUserDecryptEIP712(publicKey: Hex, contractAddresses: Address[], delegatorAddress: Address, startTimestamp: number, durationDays?: number): Promise<EIP712TypedData>;
// (undocumented)
createEIP712(publicKey: Hex, contractAddresses: Address[], startTimestamp: number, durationDays?: number): Promise<EIP712TypedData>;
// (undocumented)
@@ -458,7 +483,10 @@
// (undocumented)
encrypt(params: EncryptParams): Promise<EncryptResult>;
// (undocumented)
- generateKeypair(): Promise<KeypairType_2<Hex>>;
+ generateKeypair(): Promise<{
+ publicKey: Hex;
+ privateKey: Hex;
+ }>;
// (undocumented)
getAclAddress(): Promise<Address>;
// Warning: (ae-forgotten-export) The symbol "PublicKeyData" needs to be exported by the entry point index.d.ts
@@ -472,7 +500,7 @@
// (undocumented)
publicDecrypt(handles: Handle[]): Promise<PublicDecryptResult>;
// (undocumented)
- requestZKProofVerification(zkProof: ZKProofLike_2): Promise<InputProofBytesType_2>;
+ requestZKProofVerification(zkProof: unknown): Promise<EncryptResult>;
// (undocumented)
terminate(): void;
// (undocumented)
@@ -488,21 +516,24 @@
// (undocumented)
poolSize?: number;
// (undocumented)
- transports: Record<number, Partial<FhevmInstanceConfig_2>>;
+ transports: Record<number, Partial<FhevmInstanceConfig>>;
}
// @public
export interface RelayerSDK {
- createDelegatedUserDecryptEIP712(publicKey: Hex, contractAddresses: Address[], delegatorAddress: Address, startTimestamp: number, durationDays?: number): Promise<KmsDelegatedUserDecryptEIP712Type>;
+ createDelegatedUserDecryptEIP712(publicKey: Hex, contractAddresses: Address[], delegatorAddress: Address, startTimestamp: number, durationDays?: number): Promise<EIP712TypedData>;
createEIP712(publicKey: Hex, contractAddresses: Address[], startTimestamp: number, durationDays?: number): Promise<EIP712TypedData>;
delegatedUserDecrypt(params: DelegatedUserDecryptParams): Promise<Readonly<Record<Handle, ClearValueType>>>;
encrypt(params: EncryptParams): Promise<EncryptResult>;
- generateKeypair(): Promise<KeypairType<Hex>>;
+ generateKeypair(): Promise<{
+ publicKey: Hex;
+ privateKey: Hex;
+ }>;
getAclAddress(): Promise<Address>;
getPublicKey(): Promise<PublicKeyData | null>;
getPublicParams(bits: number): Promise<PublicParamsData | null>;
publicDecrypt(handles: Handle[]): Promise<PublicDecryptResult>;
- requestZKProofVerification(zkProof: ZKProofLike): Promise<InputProofBytesType>;
+ requestZKProofVerification(zkProof: unknown): Promise<EncryptResult>;
terminate(): void;
userDecrypt(params: UserDecryptParams): Promise<Readonly<Record<Handle, ClearValueType>>>;
}
@@ -511,14 +542,17 @@
export interface RequestZKProofVerificationRequest extends BaseRequest {
// (undocumented)
payload: {
- zkProof: ZKProofLike;
+ zkProof: unknown;
};
// (undocumented)
type: "REQUEST_ZK_PROOF_VERIFICATION";
}
// @public (undocumented)
-export type RequestZKProofVerificationResponseData = InputProofBytesType;
+export interface RequestZKProofVerificationResponseData {
+ // (undocumented)
+ error: string;
+}
// @public
export const SepoliaConfig: {
@@ -559,6 +593,8 @@
// (undocumented)
durationDays: number;
// (undocumented)
+ eip712: StoredEIP712;
+ // (undocumented)
handles: Handle[];
// (undocumented)
privateKey: Hex;
@@ -590,6 +626,7 @@
signerAddress: Address;
startTimestamp: number;
durationDays: number;
+ eip712: StoredEIP712;
};
// (undocumented)
type: "USER_DECRYPT";
@@ -610,6 +647,10 @@
// @public (undocumented)
export type WorkerResponse<T> = SuccessResponse<T> | ErrorResponse;
+// Warnings were encountered during analysis:
+//
+// dist/esm/relayer-sdk.types-CBurl-AZ.d.ts:90:5 - (ae-forgotten-export) The symbol "FhevmInstanceConfig" needs to be exported by the entry point index.d.ts
+
// (No @packageDocumentation comment for this package)
diff -ru a/sdk-query.api.md b/sdk-query.api.md import { Abi } from 'viem'; // @public (undocumented) -export { ClearValueType } // @public (undocumented) // @public (undocumented) // @public // @public
// @public (undocumented) // @public // @public (undocumented)
// @public
// @public (undocumented)
// @public
// @public (undocumented) // @public (undocumented)
// @public // @public
// @public (undocumented) // @public
// @public (undocumented) // @public (undocumented)
+// Warnings were encountered during analysis: |
Replace ethers.JsonRpcProvider with viem's createPublicClient + http transport in both web and node workers. Removes ethers dependency from the worker bundle. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Summary
@zama-fhe/relayer-sdkwith build-time@fhevm/sdk@1.0.0-alpha.1FhevmClientaction-based API (encryptValues,decryptValues,readPublicValuesWithSignatures, etc.)StoredEIP712alongside credentials for permit reconstruction viaparseSignedDecryptionPermitClearValueTypetonumber | bigint | boolean | \0x${string}`` to match SDK's branded uint8/16/32 typesBytesHex,Bytes32Hex) are subtypes of viem'sHex/string@fhevm/sdkin node worker (matching existing pattern)eip712field, bigint EIP-712 expectations)Test plan
pnpm test:coverage— 1521 passed)pnpm build)@fhevm/sdktypes🤖 Generated with Claude Code