signet.js 0.3.0 → 0.3.1-beta.1

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.cjs CHANGED
@@ -177,7 +177,7 @@ const EPSILON_DERIVATION_PREFIX_V2 = "sig.network v2.0.0 epsilon derivation";
177
177
  * @param keyVersion - Key version controlling which derivation prefix to use (legacy v1 for 0, CAIP-2 v2 otherwise)
178
178
  * @returns The derived child public key in uncompressed SEC1 format (04 || x || y)
179
179
  */
180
- function deriveChildPublicKey(rootUncompressedPubKeySEC1, predecessorId, path = "", chainId, keyVersion) {
180
+ function deriveChildPublicKey(rootUncompressedPubKeySEC1, predecessorId, path = "", chainId, _keyVersion) {
181
181
  const ec = new EC("secp256k1");
182
182
  const derivationPath = `${EPSILON_DERIVATION_PREFIX_V2}:${chainId}:${predecessorId}:${path}`;
183
183
  let scalarHex = "";
@@ -262,7 +262,7 @@ var EVM = class extends ChainAdapter {
262
262
  async attachGasAndNonce(transaction) {
263
263
  const fees = await fetchEVMFeeProperties(this.client, transaction);
264
264
  const nonce = await this.client.getTransactionCount({ address: transaction.from });
265
- const { from, ...rest } = transaction;
265
+ const { from: _from, ...rest } = transaction;
266
266
  return {
267
267
  ...fees,
268
268
  nonce,
@@ -1391,7 +1391,39 @@ const getRootPublicKey = (contractAddress, chain) => {
1391
1391
 
1392
1392
  //#endregion
1393
1393
  //#region src/contracts/evm/utils.ts
1394
- const getRequestId = (request) => {
1394
+ /**
1395
+ * Generates a unique request ID for EVM signature requests using keccak256 hashing.
1396
+ *
1397
+ * The request ID is computed by ABI-encoding the request parameters and hashing
1398
+ * the result. This ID is used to track signature requests and match them with
1399
+ * responses from the MPC network.
1400
+ *
1401
+ * @param request - The signature request parameters
1402
+ * @param request.address - The address of the requester (EVM address format)
1403
+ * @param request.payload - The data payload to be signed as a hex string
1404
+ * @param request.path - The derivation path for the signing key
1405
+ * @param request.keyVersion - The version of the signing key
1406
+ * @param request.chainId - The chain ID where the request originated
1407
+ * @param request.algo - The signing algorithm identifier
1408
+ * @param request.dest - The destination identifier for the signature
1409
+ * @param request.params - Additional parameters for the signing process
1410
+ * @returns The keccak256 hash of the encoded request as a hex string
1411
+ *
1412
+ * @example
1413
+ * ```typescript
1414
+ * const requestId = getRequestIdRespond({
1415
+ * address: '0x1234...abcd',
1416
+ * payload: '0xdeadbeef',
1417
+ * path: 'ethereum,1',
1418
+ * keyVersion: 0,
1419
+ * chainId: 1n,
1420
+ * algo: '',
1421
+ * dest: '',
1422
+ * params: '',
1423
+ * })
1424
+ * ```
1425
+ */
1426
+ const getRequestIdRespond$1 = (request) => {
1395
1427
  return (0, viem.keccak256)((0, viem.encodeAbiParameters)([
1396
1428
  { type: "address" },
1397
1429
  { type: "bytes" },
@@ -1598,7 +1630,7 @@ var ChainSignatureContract$2 = class extends ChainSignatureContract {
1598
1630
  }) {
1599
1631
  if (!this.walletClient.account) throw new Error("Wallet client account required to compute requestId");
1600
1632
  if (!this.publicClient.chain?.id) throw new Error("Public client chain required to compute requestId");
1601
- return getRequestId({
1633
+ return getRequestIdRespond$1({
1602
1634
  payload: `0x${Buffer.from(args.payload).toString("hex")}`,
1603
1635
  path: args.path,
1604
1636
  keyVersion: args.key_version,
@@ -1652,6 +1684,7 @@ var ChainSignatureContract$2 = class extends ChainSignatureContract {
1652
1684
  //#region src/contracts/evm/index.ts
1653
1685
  var evm_exports = /* @__PURE__ */ __export({
1654
1686
  ChainSignatureContract: () => ChainSignatureContract$2,
1687
+ getRequestIdRespond: () => getRequestIdRespond$1,
1655
1688
  utils: () => utils$1
1656
1689
  });
1657
1690
  const utils$1 = {
@@ -2765,17 +2798,103 @@ var CpiEventParser = class {
2765
2798
 
2766
2799
  //#endregion
2767
2800
  //#region src/contracts/solana/utils.ts
2768
- function generateRequestIdSolana({ address: address$1, payload, path, keyVersion, chainId, algo, dest, params }) {
2769
- const payloadHex = "0x" + Buffer.from(payload).toString("hex");
2801
+ /**
2802
+ * Generates a unique request ID for Solana signature requests using keccak256 hashing.
2803
+ *
2804
+ * The request ID is computed by ABI-encoding the request parameters and hashing
2805
+ * the result. This ID is used to track signature requests and match them with
2806
+ * responses from the MPC network.
2807
+ *
2808
+ * @param request - The signature request parameters
2809
+ * @param request.address - The sender's address (Solana public key as string)
2810
+ * @param request.payload - The data payload to be signed
2811
+ * @param request.path - The derivation path for the signing key
2812
+ * @param request.keyVersion - The version of the signing key
2813
+ * @param request.chainId - The CAIP-2 chain identifier (e.g., 'solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp')
2814
+ * @param request.algo - The signing algorithm identifier
2815
+ * @param request.dest - The destination identifier for the signature
2816
+ * @param request.params - Additional parameters for the signing process
2817
+ * @returns The keccak256 hash of the encoded request as a hex string
2818
+ *
2819
+ * @example
2820
+ * ```typescript
2821
+ * const requestId = getRequestIdRespond({
2822
+ * address: 'So11111111111111111111111111111111111111112',
2823
+ * payload: new Uint8Array([1, 2, 3, 4]),
2824
+ * path: 'solana,1',
2825
+ * keyVersion: 0,
2826
+ * chainId: 'solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp',
2827
+ * algo: '',
2828
+ * dest: '',
2829
+ * params: '',
2830
+ * })
2831
+ * ```
2832
+ */
2833
+ function getRequestIdRespond(request) {
2834
+ const payloadHex = "0x" + Buffer.from(request.payload).toString("hex");
2770
2835
  return (0, viem.keccak256)((0, viem.encodeAbiParameters)((0, viem.parseAbiParameters)("string, bytes, string, uint32, string, string, string, string"), [
2771
- address$1,
2836
+ request.address,
2772
2837
  payloadHex,
2773
- path,
2774
- keyVersion,
2775
- chainId,
2776
- algo,
2777
- dest,
2778
- params
2838
+ request.path,
2839
+ request.keyVersion,
2840
+ request.chainId,
2841
+ request.algo,
2842
+ request.dest,
2843
+ request.params
2844
+ ]));
2845
+ }
2846
+ /**
2847
+ * Generates a unique request ID for bidirectional sign operations using keccak256 hashing.
2848
+ *
2849
+ * Unlike `getRequestIdRespond`, this function uses packed encoding (solidityPacked)
2850
+ * instead of standard ABI encoding. This is used for cross-chain bidirectional
2851
+ * signing flows where the request originates from a different chain.
2852
+ *
2853
+ * @param request - The bidirectional signature request parameters
2854
+ * @param request.sender - The sender's address (Solana public key as string)
2855
+ * @param request.payload - The data payload to be signed
2856
+ * @param request.caip2Id - The CAIP-2 chain identifier (e.g., 'solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp')
2857
+ * @param request.keyVersion - The version of the signing key
2858
+ * @param request.path - The derivation path for the signing key
2859
+ * @param request.algo - The signing algorithm identifier
2860
+ * @param request.dest - The destination identifier for the signature
2861
+ * @param request.params - Additional parameters for the signing process
2862
+ * @returns The keccak256 hash of the packed encoded request as a hex string
2863
+ *
2864
+ * @example
2865
+ * ```typescript
2866
+ * const requestId = getRequestIdBidirectional({
2867
+ * sender: 'So11111111111111111111111111111111111111112',
2868
+ * payload: new Uint8Array([1, 2, 3, 4]),
2869
+ * caip2Id: 'solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp',
2870
+ * keyVersion: 0,
2871
+ * path: 'ethereum,1',
2872
+ * algo: '',
2873
+ * dest: '',
2874
+ * params: '',
2875
+ * })
2876
+ * ```
2877
+ */
2878
+ function getRequestIdBidirectional(request) {
2879
+ const payloadHex = `0x${Buffer.from(request.payload).toString("hex")}`;
2880
+ return (0, viem.keccak256)((0, viem.encodePacked)([
2881
+ "string",
2882
+ "bytes",
2883
+ "string",
2884
+ "uint32",
2885
+ "string",
2886
+ "string",
2887
+ "string",
2888
+ "string"
2889
+ ], [
2890
+ request.sender,
2891
+ payloadHex,
2892
+ request.caip2Id,
2893
+ request.keyVersion,
2894
+ request.path,
2895
+ request.algo,
2896
+ request.dest,
2897
+ request.params
2779
2898
  ]));
2780
2899
  }
2781
2900
 
@@ -3081,7 +3200,7 @@ var ChainSignatureContract$1 = class extends ChainSignatureContract {
3081
3200
  dest: "",
3082
3201
  params: ""
3083
3202
  }) {
3084
- return generateRequestIdSolana({
3203
+ return getRequestIdRespond({
3085
3204
  payload: args.payload,
3086
3205
  path: args.path,
3087
3206
  keyVersion: args.key_version,
@@ -3098,6 +3217,8 @@ var ChainSignatureContract$1 = class extends ChainSignatureContract {
3098
3217
  //#region src/contracts/solana/index.ts
3099
3218
  var solana_exports = /* @__PURE__ */ __export({
3100
3219
  ChainSignatureContract: () => ChainSignatureContract$1,
3220
+ getRequestIdBidirectional: () => getRequestIdBidirectional,
3221
+ getRequestIdRespond: () => getRequestIdRespond,
3101
3222
  utils: () => utils
3102
3223
  });
3103
3224
  const utils = {
package/dist/index.d.cts CHANGED
@@ -158,7 +158,7 @@ declare const najToUncompressedPubKeySEC1: (najPublicKey: NajPublicKey) => Uncom
158
158
  * @param keyVersion - Key version controlling which derivation prefix to use (legacy v1 for 0, CAIP-2 v2 otherwise)
159
159
  * @returns The derived child public key in uncompressed SEC1 format (04 || x || y)
160
160
  */
161
- declare function deriveChildPublicKey(rootUncompressedPubKeySEC1: UncompressedPubKeySEC1, predecessorId: string, path: string | undefined, chainId: string, keyVersion: number): UncompressedPubKeySEC1;
161
+ declare function deriveChildPublicKey(rootUncompressedPubKeySEC1: UncompressedPubKeySEC1, predecessorId: string, path: string | undefined, chainId: string, _keyVersion: number): UncompressedPubKeySEC1;
162
162
  /**
163
163
  * Verifies that a secp256k1 signature was created by the expected derived address
164
164
  * by recovering the signing address and comparing it with the address derived from the contract.
@@ -771,6 +771,16 @@ interface SignatureErrorData {
771
771
  requestId: string;
772
772
  error: string;
773
773
  }
774
+ interface RequestIdArgs {
775
+ address: Address;
776
+ payload: Hex;
777
+ path: string;
778
+ keyVersion: number;
779
+ chainId: bigint;
780
+ algo: string;
781
+ dest: string;
782
+ params: string;
783
+ }
774
784
  //#endregion
775
785
  //#region src/contracts/evm/ChainSignaturesContract.d.ts
776
786
  /**
@@ -882,8 +892,43 @@ declare class ChainSignatureContract$2 extends ChainSignatureContract {
882
892
  */
883
893
  getSignatureFromEvents(requestId: Hex, fromBlock: bigint): Promise<RSVSignature | undefined>;
884
894
  }
895
+ //#endregion
896
+ //#region src/contracts/evm/utils.d.ts
897
+ /**
898
+ * Generates a unique request ID for EVM signature requests using keccak256 hashing.
899
+ *
900
+ * The request ID is computed by ABI-encoding the request parameters and hashing
901
+ * the result. This ID is used to track signature requests and match them with
902
+ * responses from the MPC network.
903
+ *
904
+ * @param request - The signature request parameters
905
+ * @param request.address - The address of the requester (EVM address format)
906
+ * @param request.payload - The data payload to be signed as a hex string
907
+ * @param request.path - The derivation path for the signing key
908
+ * @param request.keyVersion - The version of the signing key
909
+ * @param request.chainId - The chain ID where the request originated
910
+ * @param request.algo - The signing algorithm identifier
911
+ * @param request.dest - The destination identifier for the signature
912
+ * @param request.params - Additional parameters for the signing process
913
+ * @returns The keccak256 hash of the encoded request as a hex string
914
+ *
915
+ * @example
916
+ * ```typescript
917
+ * const requestId = getRequestIdRespond({
918
+ * address: '0x1234...abcd',
919
+ * payload: '0xdeadbeef',
920
+ * path: 'ethereum,1',
921
+ * keyVersion: 0,
922
+ * chainId: 1n,
923
+ * algo: '',
924
+ * dest: '',
925
+ * params: '',
926
+ * })
927
+ * ```
928
+ */
929
+ declare const getRequestIdRespond$1: (request: RequestIdArgs) => `0x${string}`;
885
930
  declare namespace index_d_exports$3 {
886
- export { ChainSignatureContract$2 as ChainSignatureContract, utils$1 as utils };
931
+ export { ChainSignatureContract$2 as ChainSignatureContract, RequestIdArgs, getRequestIdRespond$1 as getRequestIdRespond, utils$1 as utils };
887
932
  }
888
933
  declare const utils$1: {
889
934
  ChainSignaturesContractABI: typeof ChainSignaturesContractABI_d_exports;
@@ -1640,8 +1685,96 @@ declare class ChainSignatureContract$1 extends ChainSignatureContract {
1640
1685
  */
1641
1686
  getRequestId(args: SignArgs, options?: SignOptions['sign']): string;
1642
1687
  }
1688
+ //#endregion
1689
+ //#region src/contracts/solana/utils.d.ts
1690
+ interface SolanaRequestIdArgs {
1691
+ address: string;
1692
+ payload: Uint8Array | number[];
1693
+ path: string;
1694
+ keyVersion: number;
1695
+ chainId: string;
1696
+ algo: string;
1697
+ dest: string;
1698
+ params: string;
1699
+ }
1700
+ interface SolanaBidirectionalRequestIdArgs {
1701
+ sender: string;
1702
+ payload: Uint8Array | number[];
1703
+ caip2Id: string;
1704
+ keyVersion: number;
1705
+ path: string;
1706
+ algo: string;
1707
+ dest: string;
1708
+ params: string;
1709
+ }
1710
+ /**
1711
+ * Generates a unique request ID for Solana signature requests using keccak256 hashing.
1712
+ *
1713
+ * The request ID is computed by ABI-encoding the request parameters and hashing
1714
+ * the result. This ID is used to track signature requests and match them with
1715
+ * responses from the MPC network.
1716
+ *
1717
+ * @param request - The signature request parameters
1718
+ * @param request.address - The sender's address (Solana public key as string)
1719
+ * @param request.payload - The data payload to be signed
1720
+ * @param request.path - The derivation path for the signing key
1721
+ * @param request.keyVersion - The version of the signing key
1722
+ * @param request.chainId - The CAIP-2 chain identifier (e.g., 'solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp')
1723
+ * @param request.algo - The signing algorithm identifier
1724
+ * @param request.dest - The destination identifier for the signature
1725
+ * @param request.params - Additional parameters for the signing process
1726
+ * @returns The keccak256 hash of the encoded request as a hex string
1727
+ *
1728
+ * @example
1729
+ * ```typescript
1730
+ * const requestId = getRequestIdRespond({
1731
+ * address: 'So11111111111111111111111111111111111111112',
1732
+ * payload: new Uint8Array([1, 2, 3, 4]),
1733
+ * path: 'solana,1',
1734
+ * keyVersion: 0,
1735
+ * chainId: 'solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp',
1736
+ * algo: '',
1737
+ * dest: '',
1738
+ * params: '',
1739
+ * })
1740
+ * ```
1741
+ */
1742
+ declare function getRequestIdRespond(request: SolanaRequestIdArgs): string;
1743
+ /**
1744
+ * Generates a unique request ID for bidirectional sign operations using keccak256 hashing.
1745
+ *
1746
+ * Unlike `getRequestIdRespond`, this function uses packed encoding (solidityPacked)
1747
+ * instead of standard ABI encoding. This is used for cross-chain bidirectional
1748
+ * signing flows where the request originates from a different chain.
1749
+ *
1750
+ * @param request - The bidirectional signature request parameters
1751
+ * @param request.sender - The sender's address (Solana public key as string)
1752
+ * @param request.payload - The data payload to be signed
1753
+ * @param request.caip2Id - The CAIP-2 chain identifier (e.g., 'solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp')
1754
+ * @param request.keyVersion - The version of the signing key
1755
+ * @param request.path - The derivation path for the signing key
1756
+ * @param request.algo - The signing algorithm identifier
1757
+ * @param request.dest - The destination identifier for the signature
1758
+ * @param request.params - Additional parameters for the signing process
1759
+ * @returns The keccak256 hash of the packed encoded request as a hex string
1760
+ *
1761
+ * @example
1762
+ * ```typescript
1763
+ * const requestId = getRequestIdBidirectional({
1764
+ * sender: 'So11111111111111111111111111111111111111112',
1765
+ * payload: new Uint8Array([1, 2, 3, 4]),
1766
+ * caip2Id: 'solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp',
1767
+ * keyVersion: 0,
1768
+ * path: 'ethereum,1',
1769
+ * algo: '',
1770
+ * dest: '',
1771
+ * params: '',
1772
+ * })
1773
+ * ```
1774
+ */
1775
+ declare function getRequestIdBidirectional(request: SolanaBidirectionalRequestIdArgs): string;
1643
1776
  declare namespace index_d_exports$4 {
1644
- export { ChainSignatureContract$1 as ChainSignatureContract, ChainSignaturesProject, utils };
1777
+ export { ChainSignatureContract$1 as ChainSignatureContract, ChainSignaturesProject, SolanaBidirectionalRequestIdArgs, SolanaRequestIdArgs, getRequestIdBidirectional, getRequestIdRespond, utils };
1645
1778
  }
1646
1779
  declare const utils: {
1647
1780
  ChainSignaturesContractIdl: {
package/dist/index.d.ts CHANGED
@@ -3,6 +3,7 @@ import * as bitcoin from "bitcoinjs-lib";
3
3
  import { EncodeObject } from "@cosmjs/proto-signing";
4
4
  import { TxRaw } from "cosmjs-types/cosmos/tx/v1beta1/tx.js";
5
5
  import BN from "bn.js";
6
+ import "viem/chains";
6
7
  import { AnchorProvider, Idl } from "@coral-xyz/anchor";
7
8
  import { AccountMeta, Connection, PublicKey, Signer, TransactionInstruction } from "@solana/web3.js";
8
9
 
@@ -156,7 +157,7 @@ declare const najToUncompressedPubKeySEC1: (najPublicKey: NajPublicKey) => Uncom
156
157
  * @param keyVersion - Key version controlling which derivation prefix to use (legacy v1 for 0, CAIP-2 v2 otherwise)
157
158
  * @returns The derived child public key in uncompressed SEC1 format (04 || x || y)
158
159
  */
159
- declare function deriveChildPublicKey(rootUncompressedPubKeySEC1: UncompressedPubKeySEC1, predecessorId: string, path: string | undefined, chainId: string, keyVersion: number): UncompressedPubKeySEC1;
160
+ declare function deriveChildPublicKey(rootUncompressedPubKeySEC1: UncompressedPubKeySEC1, predecessorId: string, path: string | undefined, chainId: string, _keyVersion: number): UncompressedPubKeySEC1;
160
161
  /**
161
162
  * Verifies that a secp256k1 signature was created by the expected derived address
162
163
  * by recovering the signing address and comparing it with the address derived from the contract.
@@ -769,6 +770,16 @@ interface SignatureErrorData {
769
770
  requestId: string;
770
771
  error: string;
771
772
  }
773
+ interface RequestIdArgs {
774
+ address: Address;
775
+ payload: Hex;
776
+ path: string;
777
+ keyVersion: number;
778
+ chainId: bigint;
779
+ algo: string;
780
+ dest: string;
781
+ params: string;
782
+ }
772
783
  //#endregion
773
784
  //#region src/contracts/evm/ChainSignaturesContract.d.ts
774
785
  /**
@@ -880,8 +891,43 @@ declare class ChainSignatureContract$2 extends ChainSignatureContract {
880
891
  */
881
892
  getSignatureFromEvents(requestId: Hex, fromBlock: bigint): Promise<RSVSignature | undefined>;
882
893
  }
894
+ //#endregion
895
+ //#region src/contracts/evm/utils.d.ts
896
+ /**
897
+ * Generates a unique request ID for EVM signature requests using keccak256 hashing.
898
+ *
899
+ * The request ID is computed by ABI-encoding the request parameters and hashing
900
+ * the result. This ID is used to track signature requests and match them with
901
+ * responses from the MPC network.
902
+ *
903
+ * @param request - The signature request parameters
904
+ * @param request.address - The address of the requester (EVM address format)
905
+ * @param request.payload - The data payload to be signed as a hex string
906
+ * @param request.path - The derivation path for the signing key
907
+ * @param request.keyVersion - The version of the signing key
908
+ * @param request.chainId - The chain ID where the request originated
909
+ * @param request.algo - The signing algorithm identifier
910
+ * @param request.dest - The destination identifier for the signature
911
+ * @param request.params - Additional parameters for the signing process
912
+ * @returns The keccak256 hash of the encoded request as a hex string
913
+ *
914
+ * @example
915
+ * ```typescript
916
+ * const requestId = getRequestIdRespond({
917
+ * address: '0x1234...abcd',
918
+ * payload: '0xdeadbeef',
919
+ * path: 'ethereum,1',
920
+ * keyVersion: 0,
921
+ * chainId: 1n,
922
+ * algo: '',
923
+ * dest: '',
924
+ * params: '',
925
+ * })
926
+ * ```
927
+ */
928
+ declare const getRequestIdRespond$1: (request: RequestIdArgs) => `0x${string}`;
883
929
  declare namespace index_d_exports$3 {
884
- export { ChainSignatureContract$2 as ChainSignatureContract, utils$1 as utils };
930
+ export { ChainSignatureContract$2 as ChainSignatureContract, RequestIdArgs, getRequestIdRespond$1 as getRequestIdRespond, utils$1 as utils };
885
931
  }
886
932
  declare const utils$1: {
887
933
  ChainSignaturesContractABI: typeof ChainSignaturesContractABI_d_exports;
@@ -1638,8 +1684,96 @@ declare class ChainSignatureContract$1 extends ChainSignatureContract {
1638
1684
  */
1639
1685
  getRequestId(args: SignArgs, options?: SignOptions['sign']): string;
1640
1686
  }
1687
+ //#endregion
1688
+ //#region src/contracts/solana/utils.d.ts
1689
+ interface SolanaRequestIdArgs {
1690
+ address: string;
1691
+ payload: Uint8Array | number[];
1692
+ path: string;
1693
+ keyVersion: number;
1694
+ chainId: string;
1695
+ algo: string;
1696
+ dest: string;
1697
+ params: string;
1698
+ }
1699
+ interface SolanaBidirectionalRequestIdArgs {
1700
+ sender: string;
1701
+ payload: Uint8Array | number[];
1702
+ caip2Id: string;
1703
+ keyVersion: number;
1704
+ path: string;
1705
+ algo: string;
1706
+ dest: string;
1707
+ params: string;
1708
+ }
1709
+ /**
1710
+ * Generates a unique request ID for Solana signature requests using keccak256 hashing.
1711
+ *
1712
+ * The request ID is computed by ABI-encoding the request parameters and hashing
1713
+ * the result. This ID is used to track signature requests and match them with
1714
+ * responses from the MPC network.
1715
+ *
1716
+ * @param request - The signature request parameters
1717
+ * @param request.address - The sender's address (Solana public key as string)
1718
+ * @param request.payload - The data payload to be signed
1719
+ * @param request.path - The derivation path for the signing key
1720
+ * @param request.keyVersion - The version of the signing key
1721
+ * @param request.chainId - The CAIP-2 chain identifier (e.g., 'solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp')
1722
+ * @param request.algo - The signing algorithm identifier
1723
+ * @param request.dest - The destination identifier for the signature
1724
+ * @param request.params - Additional parameters for the signing process
1725
+ * @returns The keccak256 hash of the encoded request as a hex string
1726
+ *
1727
+ * @example
1728
+ * ```typescript
1729
+ * const requestId = getRequestIdRespond({
1730
+ * address: 'So11111111111111111111111111111111111111112',
1731
+ * payload: new Uint8Array([1, 2, 3, 4]),
1732
+ * path: 'solana,1',
1733
+ * keyVersion: 0,
1734
+ * chainId: 'solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp',
1735
+ * algo: '',
1736
+ * dest: '',
1737
+ * params: '',
1738
+ * })
1739
+ * ```
1740
+ */
1741
+ declare function getRequestIdRespond(request: SolanaRequestIdArgs): string;
1742
+ /**
1743
+ * Generates a unique request ID for bidirectional sign operations using keccak256 hashing.
1744
+ *
1745
+ * Unlike `getRequestIdRespond`, this function uses packed encoding (solidityPacked)
1746
+ * instead of standard ABI encoding. This is used for cross-chain bidirectional
1747
+ * signing flows where the request originates from a different chain.
1748
+ *
1749
+ * @param request - The bidirectional signature request parameters
1750
+ * @param request.sender - The sender's address (Solana public key as string)
1751
+ * @param request.payload - The data payload to be signed
1752
+ * @param request.caip2Id - The CAIP-2 chain identifier (e.g., 'solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp')
1753
+ * @param request.keyVersion - The version of the signing key
1754
+ * @param request.path - The derivation path for the signing key
1755
+ * @param request.algo - The signing algorithm identifier
1756
+ * @param request.dest - The destination identifier for the signature
1757
+ * @param request.params - Additional parameters for the signing process
1758
+ * @returns The keccak256 hash of the packed encoded request as a hex string
1759
+ *
1760
+ * @example
1761
+ * ```typescript
1762
+ * const requestId = getRequestIdBidirectional({
1763
+ * sender: 'So11111111111111111111111111111111111111112',
1764
+ * payload: new Uint8Array([1, 2, 3, 4]),
1765
+ * caip2Id: 'solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp',
1766
+ * keyVersion: 0,
1767
+ * path: 'ethereum,1',
1768
+ * algo: '',
1769
+ * dest: '',
1770
+ * params: '',
1771
+ * })
1772
+ * ```
1773
+ */
1774
+ declare function getRequestIdBidirectional(request: SolanaBidirectionalRequestIdArgs): string;
1641
1775
  declare namespace index_d_exports$4 {
1642
- export { ChainSignatureContract$1 as ChainSignatureContract, ChainSignaturesProject, utils };
1776
+ export { ChainSignatureContract$1 as ChainSignatureContract, ChainSignaturesProject, SolanaBidirectionalRequestIdArgs, SolanaRequestIdArgs, getRequestIdBidirectional, getRequestIdRespond, utils };
1643
1777
  }
1644
1778
  declare const utils: {
1645
1779
  ChainSignaturesContractIdl: {
package/dist/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import { t as __export } from "./chunk-BAz01cYq.js";
2
2
  import { base58 } from "@scure/base";
3
3
  import elliptic from "elliptic";
4
- import { concat, concatHex, createPublicClient, encodeAbiParameters, encodeFunctionData, getAddress, hashMessage, hashTypedData, hexToBigInt, http, isAddress, keccak256, numberToHex, pad, parseAbiParameters, parseTransaction, recoverAddress, serializeTransaction, toBytes, withRetry } from "viem";
4
+ import { concat, concatHex, createPublicClient, encodeAbiParameters, encodeFunctionData, encodePacked, getAddress, hashMessage, hashTypedData, hexToBigInt, http, isAddress, keccak256, numberToHex, pad, parseAbiParameters, parseTransaction, recoverAddress, serializeTransaction, toBytes, withRetry } from "viem";
5
5
  import * as bitcoin from "bitcoinjs-lib";
6
6
  import coinselect from "coinselect";
7
7
  import { encodeSecp256k1Pubkey } from "@cosmjs/amino";
@@ -134,7 +134,7 @@ const EPSILON_DERIVATION_PREFIX_V2 = "sig.network v2.0.0 epsilon derivation";
134
134
  * @param keyVersion - Key version controlling which derivation prefix to use (legacy v1 for 0, CAIP-2 v2 otherwise)
135
135
  * @returns The derived child public key in uncompressed SEC1 format (04 || x || y)
136
136
  */
137
- function deriveChildPublicKey(rootUncompressedPubKeySEC1, predecessorId, path = "", chainId, keyVersion) {
137
+ function deriveChildPublicKey(rootUncompressedPubKeySEC1, predecessorId, path = "", chainId, _keyVersion) {
138
138
  const ec = new EC("secp256k1");
139
139
  const derivationPath = `${EPSILON_DERIVATION_PREFIX_V2}:${chainId}:${predecessorId}:${path}`;
140
140
  let scalarHex = "";
@@ -219,7 +219,7 @@ var EVM = class extends ChainAdapter {
219
219
  async attachGasAndNonce(transaction) {
220
220
  const fees = await fetchEVMFeeProperties(this.client, transaction);
221
221
  const nonce = await this.client.getTransactionCount({ address: transaction.from });
222
- const { from, ...rest } = transaction;
222
+ const { from: _from, ...rest } = transaction;
223
223
  return {
224
224
  ...fees,
225
225
  nonce,
@@ -1348,7 +1348,39 @@ const getRootPublicKey = (contractAddress, chain) => {
1348
1348
 
1349
1349
  //#endregion
1350
1350
  //#region src/contracts/evm/utils.ts
1351
- const getRequestId = (request) => {
1351
+ /**
1352
+ * Generates a unique request ID for EVM signature requests using keccak256 hashing.
1353
+ *
1354
+ * The request ID is computed by ABI-encoding the request parameters and hashing
1355
+ * the result. This ID is used to track signature requests and match them with
1356
+ * responses from the MPC network.
1357
+ *
1358
+ * @param request - The signature request parameters
1359
+ * @param request.address - The address of the requester (EVM address format)
1360
+ * @param request.payload - The data payload to be signed as a hex string
1361
+ * @param request.path - The derivation path for the signing key
1362
+ * @param request.keyVersion - The version of the signing key
1363
+ * @param request.chainId - The chain ID where the request originated
1364
+ * @param request.algo - The signing algorithm identifier
1365
+ * @param request.dest - The destination identifier for the signature
1366
+ * @param request.params - Additional parameters for the signing process
1367
+ * @returns The keccak256 hash of the encoded request as a hex string
1368
+ *
1369
+ * @example
1370
+ * ```typescript
1371
+ * const requestId = getRequestIdRespond({
1372
+ * address: '0x1234...abcd',
1373
+ * payload: '0xdeadbeef',
1374
+ * path: 'ethereum,1',
1375
+ * keyVersion: 0,
1376
+ * chainId: 1n,
1377
+ * algo: '',
1378
+ * dest: '',
1379
+ * params: '',
1380
+ * })
1381
+ * ```
1382
+ */
1383
+ const getRequestIdRespond$1 = (request) => {
1352
1384
  return keccak256(encodeAbiParameters([
1353
1385
  { type: "address" },
1354
1386
  { type: "bytes" },
@@ -1555,7 +1587,7 @@ var ChainSignatureContract$2 = class extends ChainSignatureContract {
1555
1587
  }) {
1556
1588
  if (!this.walletClient.account) throw new Error("Wallet client account required to compute requestId");
1557
1589
  if (!this.publicClient.chain?.id) throw new Error("Public client chain required to compute requestId");
1558
- return getRequestId({
1590
+ return getRequestIdRespond$1({
1559
1591
  payload: `0x${Buffer.from(args.payload).toString("hex")}`,
1560
1592
  path: args.path,
1561
1593
  keyVersion: args.key_version,
@@ -1609,6 +1641,7 @@ var ChainSignatureContract$2 = class extends ChainSignatureContract {
1609
1641
  //#region src/contracts/evm/index.ts
1610
1642
  var evm_exports = /* @__PURE__ */ __export({
1611
1643
  ChainSignatureContract: () => ChainSignatureContract$2,
1644
+ getRequestIdRespond: () => getRequestIdRespond$1,
1612
1645
  utils: () => utils$1
1613
1646
  });
1614
1647
  const utils$1 = {
@@ -2722,17 +2755,103 @@ var CpiEventParser = class {
2722
2755
 
2723
2756
  //#endregion
2724
2757
  //#region src/contracts/solana/utils.ts
2725
- function generateRequestIdSolana({ address: address$1, payload, path, keyVersion, chainId, algo, dest, params }) {
2726
- const payloadHex = "0x" + Buffer.from(payload).toString("hex");
2758
+ /**
2759
+ * Generates a unique request ID for Solana signature requests using keccak256 hashing.
2760
+ *
2761
+ * The request ID is computed by ABI-encoding the request parameters and hashing
2762
+ * the result. This ID is used to track signature requests and match them with
2763
+ * responses from the MPC network.
2764
+ *
2765
+ * @param request - The signature request parameters
2766
+ * @param request.address - The sender's address (Solana public key as string)
2767
+ * @param request.payload - The data payload to be signed
2768
+ * @param request.path - The derivation path for the signing key
2769
+ * @param request.keyVersion - The version of the signing key
2770
+ * @param request.chainId - The CAIP-2 chain identifier (e.g., 'solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp')
2771
+ * @param request.algo - The signing algorithm identifier
2772
+ * @param request.dest - The destination identifier for the signature
2773
+ * @param request.params - Additional parameters for the signing process
2774
+ * @returns The keccak256 hash of the encoded request as a hex string
2775
+ *
2776
+ * @example
2777
+ * ```typescript
2778
+ * const requestId = getRequestIdRespond({
2779
+ * address: 'So11111111111111111111111111111111111111112',
2780
+ * payload: new Uint8Array([1, 2, 3, 4]),
2781
+ * path: 'solana,1',
2782
+ * keyVersion: 0,
2783
+ * chainId: 'solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp',
2784
+ * algo: '',
2785
+ * dest: '',
2786
+ * params: '',
2787
+ * })
2788
+ * ```
2789
+ */
2790
+ function getRequestIdRespond(request) {
2791
+ const payloadHex = "0x" + Buffer.from(request.payload).toString("hex");
2727
2792
  return keccak256(encodeAbiParameters(parseAbiParameters("string, bytes, string, uint32, string, string, string, string"), [
2728
- address$1,
2793
+ request.address,
2729
2794
  payloadHex,
2730
- path,
2731
- keyVersion,
2732
- chainId,
2733
- algo,
2734
- dest,
2735
- params
2795
+ request.path,
2796
+ request.keyVersion,
2797
+ request.chainId,
2798
+ request.algo,
2799
+ request.dest,
2800
+ request.params
2801
+ ]));
2802
+ }
2803
+ /**
2804
+ * Generates a unique request ID for bidirectional sign operations using keccak256 hashing.
2805
+ *
2806
+ * Unlike `getRequestIdRespond`, this function uses packed encoding (solidityPacked)
2807
+ * instead of standard ABI encoding. This is used for cross-chain bidirectional
2808
+ * signing flows where the request originates from a different chain.
2809
+ *
2810
+ * @param request - The bidirectional signature request parameters
2811
+ * @param request.sender - The sender's address (Solana public key as string)
2812
+ * @param request.payload - The data payload to be signed
2813
+ * @param request.caip2Id - The CAIP-2 chain identifier (e.g., 'solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp')
2814
+ * @param request.keyVersion - The version of the signing key
2815
+ * @param request.path - The derivation path for the signing key
2816
+ * @param request.algo - The signing algorithm identifier
2817
+ * @param request.dest - The destination identifier for the signature
2818
+ * @param request.params - Additional parameters for the signing process
2819
+ * @returns The keccak256 hash of the packed encoded request as a hex string
2820
+ *
2821
+ * @example
2822
+ * ```typescript
2823
+ * const requestId = getRequestIdBidirectional({
2824
+ * sender: 'So11111111111111111111111111111111111111112',
2825
+ * payload: new Uint8Array([1, 2, 3, 4]),
2826
+ * caip2Id: 'solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp',
2827
+ * keyVersion: 0,
2828
+ * path: 'ethereum,1',
2829
+ * algo: '',
2830
+ * dest: '',
2831
+ * params: '',
2832
+ * })
2833
+ * ```
2834
+ */
2835
+ function getRequestIdBidirectional(request) {
2836
+ const payloadHex = `0x${Buffer.from(request.payload).toString("hex")}`;
2837
+ return keccak256(encodePacked([
2838
+ "string",
2839
+ "bytes",
2840
+ "string",
2841
+ "uint32",
2842
+ "string",
2843
+ "string",
2844
+ "string",
2845
+ "string"
2846
+ ], [
2847
+ request.sender,
2848
+ payloadHex,
2849
+ request.caip2Id,
2850
+ request.keyVersion,
2851
+ request.path,
2852
+ request.algo,
2853
+ request.dest,
2854
+ request.params
2736
2855
  ]));
2737
2856
  }
2738
2857
 
@@ -3038,7 +3157,7 @@ var ChainSignatureContract$1 = class extends ChainSignatureContract {
3038
3157
  dest: "",
3039
3158
  params: ""
3040
3159
  }) {
3041
- return generateRequestIdSolana({
3160
+ return getRequestIdRespond({
3042
3161
  payload: args.payload,
3043
3162
  path: args.path,
3044
3163
  keyVersion: args.key_version,
@@ -3055,6 +3174,8 @@ var ChainSignatureContract$1 = class extends ChainSignatureContract {
3055
3174
  //#region src/contracts/solana/index.ts
3056
3175
  var solana_exports = /* @__PURE__ */ __export({
3057
3176
  ChainSignatureContract: () => ChainSignatureContract$1,
3177
+ getRequestIdBidirectional: () => getRequestIdBidirectional,
3178
+ getRequestIdRespond: () => getRequestIdRespond,
3058
3179
  utils: () => utils
3059
3180
  });
3060
3181
  const utils = {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "signet.js",
3
- "version": "0.3.0",
3
+ "version": "0.3.1-beta.1",
4
4
  "description": "A TypeScript library for handling multi-chain transactions and signatures using Signet MPC",
5
5
  "type": "module",
6
6
  "exports": {
@@ -61,28 +61,26 @@
61
61
  "@aa-sdk/core": "^4.13.0",
62
62
  "@account-kit/infra": "^4.13.0",
63
63
  "@account-kit/smart-contracts": "^4.13.0",
64
+ "@eslint/js": "^9.18.0",
64
65
  "@noble/curves": "^1.8.1",
65
66
  "@nomicfoundation/hardhat-toolbox": "^5.0.0",
66
67
  "@types/bn.js": "^5.1.5",
67
68
  "@types/elliptic": "^6.4.18",
68
69
  "@types/node": "^22.10.10",
69
- "@typescript-eslint/eslint-plugin": "^6.21.0",
70
- "babel-jest": "^29.7.0",
70
+ "@types/react": "^19.0.0",
71
71
  "dotenv": "^16.4.5",
72
- "eslint": "^8.57.0",
73
- "eslint-config-prettier": "^9.1.0",
74
- "eslint-config-standard-with-typescript": "^43.0.1",
75
- "eslint-plugin-import": "^2.29.1",
76
- "eslint-plugin-n": "^16.6.2",
77
- "eslint-plugin-prettier": "^5.1.3",
78
- "eslint-plugin-promise": "^6.1.1",
72
+ "eslint": "^9.18.0",
73
+ "eslint-config-prettier": "^10.0.0",
74
+ "eslint-plugin-import-x": "^4.6.0",
79
75
  "hardhat": "^2.22.18",
80
- "jest": "^29.7.0",
81
- "prettier": "^3.2.5",
76
+ "prettier": "^3.8.0",
77
+ "react": "^19.0.0",
78
+ "react-dom": "^19.0.0",
82
79
  "tsdown": "^0.16.6",
83
- "typescript": "^5.4.3",
80
+ "typescript": "^5.9.3",
81
+ "typescript-eslint": "^8.21.0",
84
82
  "vitest": "^3.0.4",
85
- "vocs": "1.0.0-alpha.62"
83
+ "vocs": "^1.4.1"
86
84
  },
87
85
  "dependencies": {
88
86
  "@coral-xyz/anchor": "^0.31.0",