@interfold/sdk 0.6.0 → 0.8.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.
package/dist/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { PublicClient, WalletClient, Chain, Hash, Abi, Log, Address } from 'viem';
2
- import { C as ContractAddresses, E as E3, a as E3RequestParams, F as FailureReason, b as E3Stage } from './types-s67c2A1z.js';
3
- export { c as CommitteeSize, v as validateCommitteeSize } from './types-s67c2A1z.js';
2
+ import { C as ContractAddresses, E as E3RequestParams, a as E3, F as FailureReason, b as E3Stage } from './types-Cwx_flfX.js';
3
+ export { c as CommitteeSize, v as validateCommitteeSize } from './types-Cwx_flfX.js';
4
4
  import { ThresholdBfvParamsPresetName, BfvParams, EncryptedValueAndPublicInputs, VerifiableEncryptionResult } from './crypto/index.js';
5
5
  export { ThresholdBfvParamsPresetNames, computeCiphertextCommitment, computePublicKeyCommitment, encryptNumber, encryptNumberAndGenInputs, encryptNumberAndGenProof, encryptVector, encryptVectorAndGenInputs, encryptVectorAndGenProof, generateProof, generatePublicKey, getThresholdBfvParamsSet } from './crypto/index.js';
6
6
  import { AllEventTypes, EventCallback } from './events/index.js';
@@ -43,15 +43,8 @@ declare class InterfoldSDK {
43
43
  encryptVectorAndGenInputs(data: BigUint64Array, publicKey: Uint8Array): Promise<EncryptedValueAndPublicInputs>;
44
44
  encryptVectorAndGenProof(data: BigUint64Array, publicKey: Uint8Array): Promise<VerifiableEncryptionResult>;
45
45
  approveFeeToken(amount: bigint): Promise<Hash>;
46
- requestE3(params: {
47
- committeeSize: number;
48
- inputWindow: [bigint, bigint];
49
- e3Program: `0x${string}`;
50
- paramSet: number;
51
- computeProviderParams: `0x${string}`;
52
- customParams?: `0x${string}`;
53
- gasLimit?: bigint;
54
- }): Promise<Hash>;
46
+ requestE3(params: E3RequestParams): Promise<Hash>;
47
+ cancelE3(e3Id: bigint): Promise<Hash>;
55
48
  getE3PublicKey(e3Id: bigint): Promise<`0x${string}`>;
56
49
  publishCiphertextOutput(e3Id: bigint, ciphertextOutput: `0x${string}`, ciphertextCommitment: `0x${string}`, proof: `0x${string}`, gasLimit?: bigint): Promise<Hash>;
57
50
  getE3(e3Id: bigint): Promise<E3>;
package/dist/index.js CHANGED
@@ -12,6 +12,7 @@ import {
12
12
  createPublicClient,
13
13
  createWalletClient,
14
14
  http,
15
+ zeroHash,
15
16
  webSocket
16
17
  } from "viem";
17
18
  import { privateKeyToAccount } from "viem/accounts";
@@ -276,6 +277,12 @@ var ContractClient = class _ContractClient {
276
277
  throw new SDKError("No account connected", "NO_ACCOUNT");
277
278
  }
278
279
  const committeeSize = validateCommitteeSize(params.committeeSize);
280
+ const maxFee = params.maxFee ?? await this.getE3Quote(params);
281
+ const expectedCryptoConfigId = await this.publicClient.readContract({
282
+ address: this.contracts.interfold,
283
+ abi: Interfold__factory.abi,
284
+ functionName: "activeCryptoConfigId"
285
+ });
279
286
  const { request } = await this.publicClient.simulateContract({
280
287
  address: this.contracts.interfold,
281
288
  abi: Interfold__factory.abi,
@@ -287,7 +294,10 @@ var ContractClient = class _ContractClient {
287
294
  e3Program: params.e3Program,
288
295
  paramSet: params.paramSet,
289
296
  computeProviderParams: params.computeProviderParams,
290
- customParams: params.customParams || "0x"
297
+ customParams: params.customParams || "0x",
298
+ expectedFeeToken: this.contracts.feeToken,
299
+ expectedCryptoConfigId,
300
+ maxFee
291
301
  }
292
302
  ],
293
303
  account,
@@ -298,6 +308,27 @@ var ContractClient = class _ContractClient {
298
308
  throw new SDKError(`Failed to request E3: ${error}`, "REQUEST_E3_FAILED");
299
309
  }
300
310
  }
311
+ async cancelE3(e3Id) {
312
+ if (!this.walletClient) {
313
+ throw new SDKError("Wallet client required for write operations", "NO_WALLET");
314
+ }
315
+ const account = this.walletClient.account;
316
+ if (!account) {
317
+ throw new SDKError("No account connected", "NO_ACCOUNT");
318
+ }
319
+ try {
320
+ const { request } = await this.publicClient.simulateContract({
321
+ address: this.contracts.interfold,
322
+ abi: Interfold__factory.abi,
323
+ functionName: "cancelE3",
324
+ args: [e3Id],
325
+ account
326
+ });
327
+ return await this.walletClient.writeContract(request);
328
+ } catch (error) {
329
+ throw new SDKError(`Failed to cancel E3: ${error}`, "CANCEL_E3_FAILED");
330
+ }
331
+ }
301
332
  async publishCiphertextOutput(e3Id, ciphertextOutput, ciphertextCommitment, proof, gasLimit) {
302
333
  if (!this.walletClient) {
303
334
  throw new SDKError("Wallet client required for write operations", "NO_WALLET");
@@ -347,7 +378,10 @@ var ContractClient = class _ContractClient {
347
378
  e3Program: requestParams.e3Program,
348
379
  paramSet: requestParams.paramSet,
349
380
  computeProviderParams: requestParams.computeProviderParams,
350
- customParams: requestParams.customParams || "0x"
381
+ customParams: requestParams.customParams || "0x",
382
+ expectedFeeToken: this.contracts.feeToken,
383
+ expectedCryptoConfigId: zeroHash,
384
+ maxFee: requestParams.maxFee ?? 0n
351
385
  }
352
386
  ]
353
387
  });
@@ -436,7 +470,6 @@ var InterfoldEventType = /* @__PURE__ */ ((InterfoldEventType2) => {
436
470
  InterfoldEventType2["PLAINTEXT_OUTPUT_PUBLISHED"] = "PlaintextOutputPublished";
437
471
  InterfoldEventType2["E3_PROGRAM_REGISTERED"] = "E3ProgramRegistered";
438
472
  InterfoldEventType2["ENCRYPTION_SCHEME_ENABLED"] = "EncryptionSchemeEnabled";
439
- InterfoldEventType2["ENCRYPTION_SCHEME_DISABLED"] = "EncryptionSchemeDisabled";
440
473
  InterfoldEventType2["CIPHERNODE_REGISTRY_SET"] = "CiphernodeRegistrySet";
441
474
  InterfoldEventType2["MAX_DURATION_SET"] = "MaxDurationSet";
442
475
  InterfoldEventType2["PARAM_SET_REGISTERED"] = "ParamSetRegistered";
@@ -978,6 +1011,9 @@ var InterfoldSDK = class _InterfoldSDK {
978
1011
  async requestE3(params) {
979
1012
  return this.contractClient.requestE3(params);
980
1013
  }
1014
+ async cancelE3(e3Id) {
1015
+ return this.contractClient.cancelE3(e3Id);
1016
+ }
981
1017
  async getE3PublicKey(e3Id) {
982
1018
  return this.contractClient.getE3PublicKey(e3Id);
983
1019
  }