@inco/js 0.1.24 → 0.1.26

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.
@@ -52442,18 +52442,23 @@ function getCovalidatorGrpcHelper(chain, network, cluster) {
52442
52442
  class Lightning {
52443
52443
  _deployment;
52444
52444
  covalidatorUrl;
52445
+ executorAddress;
52446
+ eciesPublicKey;
52447
+ chainId;
52445
52448
  encryptor;
52446
52449
  ephemeralKeypair;
52447
52450
  kmsClient;
52448
52451
  constructor(_deployment, covalidatorUrl) {
52449
52452
  this._deployment = _deployment;
52450
52453
  this.covalidatorUrl = covalidatorUrl;
52454
+ this.executorAddress = parseAddress(_deployment.executorAddress);
52455
+ this.eciesPublicKey = parse3(HexString, _deployment.eciesPublicKey);
52456
+ this.chainId = BigInt(_deployment.chainId);
52451
52457
  this.ephemeralKeypair = generateSecp256k1Keypair();
52452
- const eciesPubKey = decodeSecp256k1PublicKey(hexToBytes(parse3(HexString, _deployment.eciesPublicKey)));
52453
52458
  this.kmsClient = getKmsClient(covalidatorUrl);
52454
52459
  this.encryptor = getEciesEncryptor({
52455
52460
  scheme: encryptionSchemes.ecies,
52456
- pubKeyA: eciesPubKey,
52461
+ pubKeyA: decodeSecp256k1PublicKey(hexToBytes(parse3(HexString, _deployment.eciesPublicKey))),
52457
52462
  privKeyB: this.ephemeralKeypair
52458
52463
  });
52459
52464
  }
@@ -52464,11 +52469,16 @@ class Lightning {
52464
52469
  }
52465
52470
  return new Lightning(deployment, Lightning.getCovalidatorUrl(deployment));
52466
52471
  }
52467
- static local({ EXECUTOR_ADDRESS, ECIES_PUBLIC_KEY }, { chainId, covalidatorUrl }) {
52472
+ static custom({
52473
+ executorAddress,
52474
+ eciesPublicKey,
52475
+ chainId,
52476
+ covalidatorUrl
52477
+ }) {
52468
52478
  return new Lightning({
52469
52479
  chainId: String(chainId),
52470
- executorAddress: EXECUTOR_ADDRESS,
52471
- eciesPublicKey: ECIES_PUBLIC_KEY
52480
+ executorAddress,
52481
+ eciesPublicKey
52472
52482
  }, covalidatorUrl);
52473
52483
  }
52474
52484
  static latestDeployment(pepper, chainId) {
@@ -52484,9 +52494,6 @@ class Lightning {
52484
52494
  get deployment() {
52485
52495
  return { ...this._deployment };
52486
52496
  }
52487
- get chainId() {
52488
- return BigInt(this._deployment.chainId);
52489
- }
52490
52497
  async encrypt(value6, { accountAddress, dappAddress }) {
52491
52498
  const { ciphertext } = await this.encryptor({
52492
52499
  plaintext: Lightning.plaintextFromValue(value6),
@@ -71266,18 +71266,23 @@ function getCovalidatorGrpcHelper(chain, network, cluster) {
71266
71266
  class Lightning {
71267
71267
  _deployment;
71268
71268
  covalidatorUrl;
71269
+ executorAddress;
71270
+ eciesPublicKey;
71271
+ chainId;
71269
71272
  encryptor;
71270
71273
  ephemeralKeypair;
71271
71274
  kmsClient;
71272
71275
  constructor(_deployment, covalidatorUrl) {
71273
71276
  this._deployment = _deployment;
71274
71277
  this.covalidatorUrl = covalidatorUrl;
71278
+ this.executorAddress = parseAddress(_deployment.executorAddress);
71279
+ this.eciesPublicKey = parse3(HexString, _deployment.eciesPublicKey);
71280
+ this.chainId = BigInt(_deployment.chainId);
71275
71281
  this.ephemeralKeypair = generateSecp256k1Keypair();
71276
- const eciesPubKey = decodeSecp256k1PublicKey(hexToBytes(parse3(HexString, _deployment.eciesPublicKey)));
71277
71282
  this.kmsClient = getKmsClient(covalidatorUrl);
71278
71283
  this.encryptor = getEciesEncryptor({
71279
71284
  scheme: encryptionSchemes.ecies,
71280
- pubKeyA: eciesPubKey,
71285
+ pubKeyA: decodeSecp256k1PublicKey(hexToBytes(parse3(HexString, _deployment.eciesPublicKey))),
71281
71286
  privKeyB: this.ephemeralKeypair
71282
71287
  });
71283
71288
  }
@@ -71288,11 +71293,16 @@ class Lightning {
71288
71293
  }
71289
71294
  return new Lightning(deployment, Lightning.getCovalidatorUrl(deployment));
71290
71295
  }
71291
- static local({ EXECUTOR_ADDRESS, ECIES_PUBLIC_KEY }, { chainId, covalidatorUrl }) {
71296
+ static custom({
71297
+ executorAddress,
71298
+ eciesPublicKey,
71299
+ chainId,
71300
+ covalidatorUrl
71301
+ }) {
71292
71302
  return new Lightning({
71293
71303
  chainId: String(chainId),
71294
- executorAddress: EXECUTOR_ADDRESS,
71295
- eciesPublicKey: ECIES_PUBLIC_KEY
71304
+ executorAddress,
71305
+ eciesPublicKey
71296
71306
  }, covalidatorUrl);
71297
71307
  }
71298
71308
  static latestDeployment(pepper, chainId) {
@@ -71308,9 +71318,6 @@ class Lightning {
71308
71318
  get deployment() {
71309
71319
  return { ...this._deployment };
71310
71320
  }
71311
- get chainId() {
71312
- return BigInt(this._deployment.chainId);
71313
- }
71314
71321
  async encrypt(value6, { accountAddress, dappAddress }) {
71315
71322
  const { ciphertext } = await this.encryptor({
71316
71323
  plaintext: Lightning.plaintextFromValue(value6),
@@ -1,8 +1,7 @@
1
1
  import { Account, Chain, Transport, WalletClient } from 'viem';
2
- import { HexString } from '../binary';
2
+ import { Address, HexString } from '../binary';
3
3
  import { EciesScheme } from '../encryption';
4
4
  import { lightningDeployments } from '../generated/lightning';
5
- import { LocalNodeEnv } from '../local';
6
5
  import type { Reencryptor } from '../reencryption';
7
6
  type TupleToUnion<T> = T extends readonly unknown[] ? T[number] : never;
8
7
  type ToBigInt<T extends string> = T extends `${infer N extends bigint}` ? N : never;
@@ -32,23 +31,36 @@ export type DeploymentSlice = {
32
31
  * The Lightning class provides a convenient way to interact with the Inco Lightning contract by binding to a specific
33
32
  * deployment.
34
33
  */
35
- export declare class Lightning<T extends DeploymentSlice> {
34
+ export declare class Lightning<T extends DeploymentSlice = DeploymentSlice> {
36
35
  private readonly _deployment;
37
36
  readonly covalidatorUrl: string;
37
+ readonly executorAddress: Address;
38
+ readonly eciesPublicKey: HexString;
39
+ readonly chainId: bigint;
38
40
  private readonly encryptor;
39
41
  private readonly ephemeralKeypair;
40
42
  private readonly kmsClient;
41
- constructor(_deployment: T, covalidatorUrl: string);
43
+ private constructor();
42
44
  /**
43
45
  * Get a Lightning deployment by name or executor address on a particular chain.
44
46
  *
45
47
  * @param id this is an object containing either the pair of name and chainId or the executorAddress and chainId
46
48
  */
47
49
  static at(id: DeploymentId): Lightning<Deployment>;
48
- static local({ EXECUTOR_ADDRESS, ECIES_PUBLIC_KEY }: LocalNodeEnv, { chainId, covalidatorUrl }: {
50
+ /**
51
+ * Get a Lightning deployment for a local or custom node
52
+ *
53
+ * @param executorAddress the address of the executor contract on the host chain
54
+ * @param eciesPublicKey the public ECIES key of the Lightning deployment used for encryption
55
+ * @param chainId the chainId of the host chain
56
+ * @param covalidatorUrl the gRPC endpoint of the covalidator
57
+ */
58
+ static custom({ executorAddress, eciesPublicKey, chainId, covalidatorUrl, }: {
59
+ executorAddress: string;
60
+ eciesPublicKey: string;
49
61
  chainId: bigint;
50
62
  covalidatorUrl: string;
51
- }): Lightning<DeploymentSlice>;
63
+ }): Lightning;
52
64
  /**
53
65
  * Get the latest deployment for a given pepper, which usually denotes a family of deployments distinct from their
54
66
  * version such as 'devnet', 'testnet', 'mainnet', etc.
@@ -67,10 +79,6 @@ export declare class Lightning<T extends DeploymentSlice> {
67
79
  */
68
80
  static latest<P extends Pepper>(pepper: P, chainId: ChainId): Lightning<Deployment>;
69
81
  get deployment(): T;
70
- /**
71
- * Get the chainId of the deployment to which this Lightning instance is bound.
72
- */
73
- get chainId(): bigint;
74
82
  /**
75
83
  * Encrypt a value using the public ECIES key of the Lightning deployment.
76
84
  *
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@inco/js",
3
- "version": "0.1.24",
3
+ "version": "0.1.26",
4
4
  "repository": "https://github.com/Inco-fhevm/inco-monorepo",
5
5
  "scripts": {
6
6
  "test": "bun run lint && bun run test:tsc && bun run test:unit",