@zama-fhe/relayer-sdk 0.4.0 → 0.4.2

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.
@@ -18,6 +18,7 @@ export async function inputProofCommand(options) {
18
18
 
19
19
  const { publicKey, publicParams } = await loadFhevmPublicKeyConfig(
20
20
  config,
21
+ zamaFhevmApiKey,
21
22
  options,
22
23
  );
23
24
 
@@ -3,7 +3,7 @@ import { loadFhevmPublicKeyConfig } from '../pubkeyCache.js';
3
3
 
4
4
  // npx . pubkey fetch
5
5
  export async function pubkeyFetchCommand(options) {
6
- const { config } = parseCommonOptions(options);
6
+ const { config, zamaFhevmApiKey } = parseCommonOptions(options);
7
7
 
8
- await loadFhevmPublicKeyConfig(config, options);
8
+ await loadFhevmPublicKeyConfig(config, zamaFhevmApiKey, options);
9
9
  }
@@ -41,6 +41,7 @@ export async function testFHETestAddCommand(options) {
41
41
 
42
42
  const { publicKey, publicParams } = await loadFhevmPublicKeyConfig(
43
43
  config,
44
+ zamaFhevmApiKey,
44
45
  options,
45
46
  );
46
47
 
@@ -14,13 +14,14 @@ import {
14
14
  // npx . zkproof generate --values 123:euint32 true:ebool 1234567890123456789:euint256 0xb2a8A265dD5A27026693Aa6cE87Fb21Ac197b6b9:eaddress
15
15
  // npx . zkproof generate --contract-address 0xb2a8A265dD5A27026693Aa6cE87Fb21Ac197b6b9 --user-address 0x37AC010c1c566696326813b840319B58Bb5840E4 --values 123:euint32
16
16
  export async function zkProofGenerateCommand(options) {
17
- const { config } = parseCommonOptions(options);
17
+ const { config, zamaFhevmApiKey } = parseCommonOptions(options);
18
18
 
19
19
  const fheTypedValues = valueColumnTypeListToFheTypedValues(options.values);
20
20
  const arr = fheTypedValuesToBuilderFunctionWithArg(fheTypedValues);
21
21
 
22
22
  const { publicKey, publicParams } = await loadFhevmPublicKeyConfig(
23
23
  config,
24
+ zamaFhevmApiKey,
24
25
  options,
25
26
  );
26
27
 
@@ -19,7 +19,16 @@ export function getFhevmPubKeyCacheInfo(name) {
19
19
  };
20
20
  }
21
21
 
22
- export async function loadFhevmPublicKeyConfig(config, options) {
22
+ export async function loadFhevmPublicKeyConfig(
23
+ config,
24
+ zamaFhevmApiKey,
25
+ options,
26
+ ) {
27
+ const instanceOptions = {
28
+ //...(options.verbose === true ? { debug: true } : {}),
29
+ auth: { __type: 'ApiKeyHeader', value: zamaFhevmApiKey },
30
+ };
31
+
23
32
  const res = loadFhevmPubKeyFromCache({ ...options, name: config.name });
24
33
  if (res) {
25
34
  const pk = res.pk.toBytes();
@@ -48,6 +57,7 @@ export async function loadFhevmPublicKeyConfig(config, options) {
48
57
  const fhevm = await createRelayerFhevm({
49
58
  ...config.fhevmInstanceConfig,
50
59
  defaultRelayerVersion: config.version,
60
+ ...instanceOptions,
51
61
  });
52
62
 
53
63
  logCLI(`Relayer url: ${fhevm.relayerVersionUrl}`, options);
@@ -5,17 +5,18 @@ import { logCLI } from './utils.js';
5
5
  export async function publicDecrypt(handles, config, zamaFhevmApiKey, options) {
6
6
  const { publicKey, publicParams } = await loadFhevmPublicKeyConfig(
7
7
  config,
8
+ zamaFhevmApiKey,
8
9
  options,
9
10
  );
10
11
 
12
+ const timeout =
13
+ options.timeout !== undefined ? Number(options.timeout) : undefined;
14
+
11
15
  const instanceOptions = {
12
16
  //...(options.verbose === true ? { debug: true } : {}),
13
17
  auth: { __type: 'ApiKeyHeader', value: zamaFhevmApiKey },
14
18
  };
15
19
 
16
- const timeout =
17
- options.timeout !== undefined ? Number(options.timeout) : undefined;
18
-
19
20
  try {
20
21
  const instance = await getInstance(
21
22
  {
@@ -13,6 +13,7 @@ export async function userDecrypt({
13
13
  }) {
14
14
  const { publicKey, publicParams } = await loadFhevmPublicKeyConfig(
15
15
  config,
16
+ zamaFhevmApiKey,
16
17
  options,
17
18
  );
18
19
 
@@ -35461,7 +35461,7 @@ async function Z1(i) {
35461
35461
  const { instance: e, module: r } = await um(await i, t);
35462
35462
  return wm(e, r);
35463
35463
  }
35464
- const eo = "0.4.0", Vo = "@zama-fhe/relayer-sdk";
35464
+ const eo = "0.4.2", Vo = "@zama-fhe/relayer-sdk";
35465
35465
  class st extends Error {
35466
35466
  name = "RelayerErrorBase";
35467
35467
  _details;
@@ -39322,7 +39322,7 @@ class Sp extends LA {
39322
39322
  }
39323
39323
  }
39324
39324
  function HA(i, t) {
39325
- if (L(i, "label", t), !(i.label === "malformed_json" || i.label === "request_error" || i.label === "not_ready_for_decryption"))
39325
+ if (L(i, "label", t), !(i.label === "malformed_json" || i.label === "request_error" || i.label === "not_ready_for_decryption" || i.label === "not_allowed_on_host_acl"))
39326
39326
  throw new ct({
39327
39327
  objName: t,
39328
39328
  property: "label",
@@ -39330,7 +39330,8 @@ function HA(i, t) {
39330
39330
  expectedValue: [
39331
39331
  "malformed_json",
39332
39332
  "request_error",
39333
- "not_ready_for_decryption"
39333
+ "not_ready_for_decryption",
39334
+ "not_allowed_on_host_acl"
39334
39335
  ],
39335
39336
  type: typeof i.label,
39336
39337
  // === "string"
@@ -39373,16 +39374,18 @@ function WA(i, t) {
39373
39374
  function ZA(i, t) {
39374
39375
  L(i, "label", t, [
39375
39376
  "protocol_paused",
39377
+ "insufficient_balance",
39378
+ "insufficient_allowance",
39376
39379
  "gateway_not_reachable",
39377
- "readiness_check_timedout",
39378
- "response_timedout"
39380
+ "readiness_check_timed_out",
39381
+ "response_timed_out"
39379
39382
  ]), L(i, "message", t);
39380
39383
  }
39381
39384
  function ca(i, t) {
39382
39385
  L(i, "status", t, "failed"), ti(i, "error", t), $R(i.error, `${t}.error`);
39383
39386
  }
39384
39387
  function $R(i, t) {
39385
- if (L(i, "label", t), i.label === "malformed_json" || i.label === "request_error" || i.label === "not_ready_for_decryption")
39388
+ if (L(i, "label", t), i.label === "malformed_json" || i.label === "request_error" || i.label === "not_ready_for_decryption" || i.label === "not_allowed_on_host_acl")
39386
39389
  HA(i, t);
39387
39390
  else if (i.label === "missing_fields" || i.label === "validation_failed")
39388
39391
  JA(i, t);
@@ -39392,7 +39395,7 @@ function $R(i, t) {
39392
39395
  QA(i, t);
39393
39396
  else if (i.label === "internal_server_error")
39394
39397
  $A(i, t);
39395
- else if (i.label === "readiness_check_timedout" || i.label === "response_timedout" || i.label === "protocol_paused" || i.label === "gateway_not_reachable")
39398
+ else if (i.label === "readiness_check_timed_out" || i.label === "response_timed_out" || i.label === "protocol_paused" || i.label === "insufficient_balance" || i.label === "insufficient_allowance" || i.label === "gateway_not_reachable")
39396
39399
  ZA(i, t);
39397
39400
  else
39398
39401
  throw new ct({
@@ -39403,22 +39406,25 @@ function $R(i, t) {
39403
39406
  "malformed_json",
39404
39407
  "request_error",
39405
39408
  "not_ready_for_decryption",
39409
+ "not_allowed_on_host_acl",
39406
39410
  "missing_fields",
39407
39411
  "validation_failed",
39408
39412
  "rate_limited",
39409
39413
  "internal_server_error",
39410
39414
  "protocol_paused",
39415
+ "insufficient_balance",
39416
+ "insufficient_allowance",
39411
39417
  "protocol_overload",
39412
39418
  "gateway_not_reachable",
39413
- "readiness_check_timedout",
39414
- "response_timedout"
39419
+ "readiness_check_timed_out",
39420
+ "response_timed_out"
39415
39421
  ],
39416
39422
  type: typeof i.label,
39417
39423
  value: i.label
39418
39424
  });
39419
39425
  }
39420
39426
  function Dw(i, t) {
39421
- if (ca(i, t), i.error.label === "malformed_json" || i.error.label === "request_error" || i.error.label === "not_ready_for_decryption")
39427
+ if (ca(i, t), i.error.label === "malformed_json" || i.error.label === "request_error" || i.error.label === "not_ready_for_decryption" || i.error.label === "not_allowed_on_host_acl")
39422
39428
  HA(i.error, `${t}.error`);
39423
39429
  else if (i.error.label === "missing_fields" || i.error.label === "validation_failed")
39424
39430
  JA(i.error, `${t}.error`);
@@ -39431,6 +39437,7 @@ function Dw(i, t) {
39431
39437
  "malformed_json",
39432
39438
  "request_error",
39433
39439
  "not_ready_for_decryption",
39440
+ "not_allowed_on_host_acl",
39434
39441
  "missing_fields",
39435
39442
  "validation_failed"
39436
39443
  ],