@cofhe/sdk 0.3.1 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -165,6 +165,14 @@ type EncryptStepCallbackContext = Record<string, any> & {
165
165
  duration: number;
166
166
  };
167
167
  type EncryptStepCallbackFunction = (state: EncryptStep, context?: EncryptStepCallbackContext) => void;
168
+ /**
169
+ * Decrypted plaintext value returned by view-decryption helpers.
170
+ *
171
+ * This is a scalar JS value (not a wrapper object):
172
+ * - `boolean` for `FheTypes.Bool`
173
+ * - checksummed address `string` for `FheTypes.Uint160`
174
+ * - `bigint` for supported integer utypes
175
+ */
168
176
  type UnsealedItem<U extends FheTypes> = U extends FheTypes.Bool ? boolean : U extends FheTypes.Uint160 ? string : U extends FheUintUTypesType ? bigint : never;
169
177
 
170
178
  /**
@@ -342,7 +350,7 @@ declare abstract class BaseBuilder {
342
350
  * Returns the unsealed item.
343
351
  */
344
352
  type DecryptForViewBuilderParams<U extends FheTypes> = BaseBuilderParams & {
345
- ctHash: bigint;
353
+ ctHash: bigint | string;
346
354
  utype: U;
347
355
  permitHash?: string;
348
356
  permit?: Permit;
@@ -466,12 +474,12 @@ declare class DecryptForViewBuilder<U extends FheTypes> extends BaseBuilder {
466
474
  }
467
475
 
468
476
  type DecryptForTxBuilderParams = BaseBuilderParams & {
469
- ctHash: bigint;
477
+ ctHash: bigint | string;
470
478
  };
471
479
  type DecryptForTxResult = {
472
- ctHash: bigint;
480
+ ctHash: bigint | string;
473
481
  decryptedValue: bigint;
474
- signature: string;
482
+ signature: `0x${string}`;
475
483
  };
476
484
  /**
477
485
  * Type-level gating:
@@ -894,9 +902,9 @@ declare const permits: {
894
902
  getHash: (permit: PermitHashFields) => string;
895
903
  serialize: (permit: Permit) => SerializedPermit;
896
904
  deserialize: (serialized: SerializedPermit) => Permit;
897
- getPermit: (chainId: number, account: string, hash: string) => Promise<Permit | undefined>;
898
- getPermits: (chainId: number, account: string) => Promise<Record<string, Permit>>;
899
- getActivePermit: (chainId: number, account: string) => Promise<Permit | undefined>;
905
+ getPermit: (chainId: number, account: string, hash: string) => Permit | undefined;
906
+ getPermits: (chainId: number, account: string) => Record<string, Permit>;
907
+ getActivePermit: (chainId: number, account: string) => Permit | undefined;
900
908
  getActivePermitHash: (chainId: number, account: string) => string | undefined;
901
909
  removePermit: (chainId: number, account: string, hash: string) => Promise<void>;
902
910
  selectActivePermit: (chainId: number, account: string, hash: string) => void;
@@ -924,9 +932,9 @@ type CofheClient<TConfig extends CofheConfig = CofheConfig> = {
924
932
  /**
925
933
  * @deprecated Use `decryptForView` instead. Kept for backward compatibility.
926
934
  */
927
- decryptHandle<U extends FheTypes>(ctHash: bigint, utype: U): DecryptForViewBuilder<U>;
928
- decryptForView<U extends FheTypes>(ctHash: bigint, utype: U): DecryptForViewBuilder<U>;
929
- decryptForTx(ctHash: bigint): DecryptForTxBuilderUnset;
935
+ decryptHandle<U extends FheTypes>(ctHash: bigint | string, utype: U): DecryptForViewBuilder<U>;
936
+ decryptForView<U extends FheTypes>(ctHash: bigint | string, utype: U): DecryptForViewBuilder<U>;
937
+ decryptForTx(ctHash: bigint | string): DecryptForTxBuilderUnset;
930
938
  permits: CofheClientPermits;
931
939
  };
932
940
  type CofheClientConnectionState = {
@@ -949,10 +957,10 @@ type CofheClientPermits = {
949
957
  createSelf: (options: CreateSelfPermitOptions, clients?: CofheClientPermitsClients) => Promise<SelfPermit>;
950
958
  createSharing: (options: CreateSharingPermitOptions, clients?: CofheClientPermitsClients) => Promise<SharingPermit>;
951
959
  importShared: (options: ImportSharedPermitOptions | string, clients?: CofheClientPermitsClients) => Promise<RecipientPermit>;
952
- getPermit: (hash: string, chainId?: number, account?: string) => Promise<Permit | undefined>;
953
- getPermits: (chainId?: number, account?: string) => Promise<Record<string, Permit>>;
954
- getActivePermit: (chainId?: number, account?: string) => Promise<Permit | undefined>;
955
- getActivePermitHash: (chainId?: number, account?: string) => Promise<string | undefined>;
960
+ getPermit: (hash: string, chainId?: number, account?: string) => Permit | undefined;
961
+ getPermits: (chainId?: number, account?: string) => Record<string, Permit>;
962
+ getActivePermit: (chainId?: number, account?: string) => Permit | undefined;
963
+ getActivePermitHash: (chainId?: number, account?: string) => string | undefined;
956
964
  getOrCreateSelfPermit: (chainId?: number, account?: string, options?: CreateSelfPermitOptions) => Promise<Permit>;
957
965
  getOrCreateSharingPermit: (options: CreateSharingPermitOptions, chainId?: number, account?: string) => Promise<Permit>;
958
966
  selectActivePermit: (hash: string, chainId?: number, account?: string) => void;
@@ -165,6 +165,14 @@ type EncryptStepCallbackContext = Record<string, any> & {
165
165
  duration: number;
166
166
  };
167
167
  type EncryptStepCallbackFunction = (state: EncryptStep, context?: EncryptStepCallbackContext) => void;
168
+ /**
169
+ * Decrypted plaintext value returned by view-decryption helpers.
170
+ *
171
+ * This is a scalar JS value (not a wrapper object):
172
+ * - `boolean` for `FheTypes.Bool`
173
+ * - checksummed address `string` for `FheTypes.Uint160`
174
+ * - `bigint` for supported integer utypes
175
+ */
168
176
  type UnsealedItem<U extends FheTypes> = U extends FheTypes.Bool ? boolean : U extends FheTypes.Uint160 ? string : U extends FheUintUTypesType ? bigint : never;
169
177
 
170
178
  /**
@@ -342,7 +350,7 @@ declare abstract class BaseBuilder {
342
350
  * Returns the unsealed item.
343
351
  */
344
352
  type DecryptForViewBuilderParams<U extends FheTypes> = BaseBuilderParams & {
345
- ctHash: bigint;
353
+ ctHash: bigint | string;
346
354
  utype: U;
347
355
  permitHash?: string;
348
356
  permit?: Permit;
@@ -466,12 +474,12 @@ declare class DecryptForViewBuilder<U extends FheTypes> extends BaseBuilder {
466
474
  }
467
475
 
468
476
  type DecryptForTxBuilderParams = BaseBuilderParams & {
469
- ctHash: bigint;
477
+ ctHash: bigint | string;
470
478
  };
471
479
  type DecryptForTxResult = {
472
- ctHash: bigint;
480
+ ctHash: bigint | string;
473
481
  decryptedValue: bigint;
474
- signature: string;
482
+ signature: `0x${string}`;
475
483
  };
476
484
  /**
477
485
  * Type-level gating:
@@ -894,9 +902,9 @@ declare const permits: {
894
902
  getHash: (permit: PermitHashFields) => string;
895
903
  serialize: (permit: Permit) => SerializedPermit;
896
904
  deserialize: (serialized: SerializedPermit) => Permit;
897
- getPermit: (chainId: number, account: string, hash: string) => Promise<Permit | undefined>;
898
- getPermits: (chainId: number, account: string) => Promise<Record<string, Permit>>;
899
- getActivePermit: (chainId: number, account: string) => Promise<Permit | undefined>;
905
+ getPermit: (chainId: number, account: string, hash: string) => Permit | undefined;
906
+ getPermits: (chainId: number, account: string) => Record<string, Permit>;
907
+ getActivePermit: (chainId: number, account: string) => Permit | undefined;
900
908
  getActivePermitHash: (chainId: number, account: string) => string | undefined;
901
909
  removePermit: (chainId: number, account: string, hash: string) => Promise<void>;
902
910
  selectActivePermit: (chainId: number, account: string, hash: string) => void;
@@ -924,9 +932,9 @@ type CofheClient<TConfig extends CofheConfig = CofheConfig> = {
924
932
  /**
925
933
  * @deprecated Use `decryptForView` instead. Kept for backward compatibility.
926
934
  */
927
- decryptHandle<U extends FheTypes>(ctHash: bigint, utype: U): DecryptForViewBuilder<U>;
928
- decryptForView<U extends FheTypes>(ctHash: bigint, utype: U): DecryptForViewBuilder<U>;
929
- decryptForTx(ctHash: bigint): DecryptForTxBuilderUnset;
935
+ decryptHandle<U extends FheTypes>(ctHash: bigint | string, utype: U): DecryptForViewBuilder<U>;
936
+ decryptForView<U extends FheTypes>(ctHash: bigint | string, utype: U): DecryptForViewBuilder<U>;
937
+ decryptForTx(ctHash: bigint | string): DecryptForTxBuilderUnset;
930
938
  permits: CofheClientPermits;
931
939
  };
932
940
  type CofheClientConnectionState = {
@@ -949,10 +957,10 @@ type CofheClientPermits = {
949
957
  createSelf: (options: CreateSelfPermitOptions, clients?: CofheClientPermitsClients) => Promise<SelfPermit>;
950
958
  createSharing: (options: CreateSharingPermitOptions, clients?: CofheClientPermitsClients) => Promise<SharingPermit>;
951
959
  importShared: (options: ImportSharedPermitOptions | string, clients?: CofheClientPermitsClients) => Promise<RecipientPermit>;
952
- getPermit: (hash: string, chainId?: number, account?: string) => Promise<Permit | undefined>;
953
- getPermits: (chainId?: number, account?: string) => Promise<Record<string, Permit>>;
954
- getActivePermit: (chainId?: number, account?: string) => Promise<Permit | undefined>;
955
- getActivePermitHash: (chainId?: number, account?: string) => Promise<string | undefined>;
960
+ getPermit: (hash: string, chainId?: number, account?: string) => Permit | undefined;
961
+ getPermits: (chainId?: number, account?: string) => Record<string, Permit>;
962
+ getActivePermit: (chainId?: number, account?: string) => Permit | undefined;
963
+ getActivePermitHash: (chainId?: number, account?: string) => string | undefined;
956
964
  getOrCreateSelfPermit: (chainId?: number, account?: string, options?: CreateSelfPermitOptions) => Promise<Permit>;
957
965
  getOrCreateSharingPermit: (options: CreateSharingPermitOptions, chainId?: number, account?: string) => Promise<Permit>;
958
966
  selectActivePermit: (hash: string, chainId?: number, account?: string) => void;