@inco/js 0.1.25 → 0.1.27

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
  }
@@ -52489,9 +52494,6 @@ class Lightning {
52489
52494
  get deployment() {
52490
52495
  return { ...this._deployment };
52491
52496
  }
52492
- get chainId() {
52493
- return BigInt(this._deployment.chainId);
52494
- }
52495
52497
  async encrypt(value6, { accountAddress, dappAddress }) {
52496
52498
  const { ciphertext } = await this.encryptor({
52497
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
  }
@@ -71313,9 +71318,6 @@ class Lightning {
71313
71318
  get deployment() {
71314
71319
  return { ...this._deployment };
71315
71320
  }
71316
- get chainId() {
71317
- return BigInt(this._deployment.chainId);
71318
- }
71319
71321
  async encrypt(value6, { accountAddress, dappAddress }) {
71320
71322
  const { ciphertext } = await this.encryptor({
71321
71323
  plaintext: Lightning.plaintextFromValue(value6),
@@ -1,10 +1,12 @@
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
5
  import type { Reencryptor } from '../reencryption';
6
6
  type TupleToUnion<T> = T extends readonly unknown[] ? T[number] : never;
7
- type ToBigInt<T extends string> = T extends `${infer N extends bigint}` ? N : never;
7
+ type ToBigInt<T extends number | string | bigint> = `${T}` extends `${infer N extends bigint}` ? N : never;
8
+ type ToNumber<T extends number | string | bigint> = `${T}` extends `${infer N extends number}` ? N : never;
9
+ type Numberish<T extends number | string | bigint> = T | ToBigInt<T> | ToNumber<T>;
8
10
  type ValuesToBigInt<T> = {
9
11
  [K in keyof T]: T[K] extends string ? ToBigInt<T[K]> : never;
10
12
  };
@@ -16,7 +18,7 @@ export type DeploymentByName = DistributedPick<DeploymentWithBigIntChainId, 'nam
16
18
  export type DeploymentByExecutor = DistributedPick<DeploymentWithBigIntChainId, 'executorAddress' | 'chainId'>;
17
19
  export type DeploymentId = DeploymentByName | DeploymentByExecutor;
18
20
  export type Pepper = Deployment['pepper'];
19
- export type ChainId = ToBigInt<Deployment['chainId']>;
21
+ export type ChainId = Numberish<Deployment['chainId']>;
20
22
  export type SupportedNativeType = boolean | bigint | number;
21
23
  export type EncryptionContext = {
22
24
  accountAddress: string;
@@ -31,9 +33,12 @@ export type DeploymentSlice = {
31
33
  * The Lightning class provides a convenient way to interact with the Inco Lightning contract by binding to a specific
32
34
  * deployment.
33
35
  */
34
- export declare class Lightning<T extends DeploymentSlice> {
36
+ export declare class Lightning<T extends DeploymentSlice = DeploymentSlice> {
35
37
  private readonly _deployment;
36
38
  readonly covalidatorUrl: string;
39
+ readonly executorAddress: Address;
40
+ readonly eciesPublicKey: HexString;
41
+ readonly chainId: bigint;
37
42
  private readonly encryptor;
38
43
  private readonly ephemeralKeypair;
39
44
  private readonly kmsClient;
@@ -57,7 +62,7 @@ export declare class Lightning<T extends DeploymentSlice> {
57
62
  eciesPublicKey: string;
58
63
  chainId: bigint;
59
64
  covalidatorUrl: string;
60
- }): Lightning<DeploymentSlice>;
65
+ }): Lightning;
61
66
  /**
62
67
  * Get the latest deployment for a given pepper, which usually denotes a family of deployments distinct from their
63
68
  * version such as 'devnet', 'testnet', 'mainnet', etc.
@@ -76,10 +81,6 @@ export declare class Lightning<T extends DeploymentSlice> {
76
81
  */
77
82
  static latest<P extends Pepper>(pepper: P, chainId: ChainId): Lightning<Deployment>;
78
83
  get deployment(): T;
79
- /**
80
- * Get the chainId of the deployment to which this Lightning instance is bound.
81
- */
82
- get chainId(): bigint;
83
84
  /**
84
85
  * Encrypt a value using the public ECIES key of the Lightning deployment.
85
86
  *
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@inco/js",
3
- "version": "0.1.25",
3
+ "version": "0.1.27",
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",