signet.js 0.2.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 +317 -136
- package/dist/index.d.cts +161 -39
- package/dist/index.d.ts +162 -39
- package/dist/index.js +318 -137
- package/package.json +15 -15
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,
|
|
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;
|
|
@@ -1550,16 +1595,17 @@ interface Signature {
|
|
|
1550
1595
|
s: number[];
|
|
1551
1596
|
recoveryId: number;
|
|
1552
1597
|
}
|
|
1553
|
-
interface
|
|
1554
|
-
|
|
1555
|
-
responder: PublicKey;
|
|
1598
|
+
interface RespondBidirectionalData {
|
|
1599
|
+
serializedOutput: Buffer;
|
|
1556
1600
|
signature: Signature;
|
|
1557
1601
|
}
|
|
1558
|
-
|
|
1559
|
-
|
|
1560
|
-
|
|
1561
|
-
|
|
1602
|
+
type ChainSignaturesEventName = 'signatureRespondedEvent' | 'signatureErrorEvent' | 'respondBidirectionalEvent';
|
|
1603
|
+
interface EventResultMap {
|
|
1604
|
+
signatureRespondedEvent: RSVSignature;
|
|
1605
|
+
signatureErrorEvent: SignatureErrorData;
|
|
1606
|
+
respondBidirectionalEvent: RespondBidirectionalData;
|
|
1562
1607
|
}
|
|
1608
|
+
type EventResult<E extends ChainSignaturesEventName> = EventResultMap[E];
|
|
1563
1609
|
//#endregion
|
|
1564
1610
|
//#region src/contracts/solana/ChainSignaturesContract.d.ts
|
|
1565
1611
|
declare class ChainSignatureContract$1 extends ChainSignatureContract {
|
|
@@ -1608,8 +1654,8 @@ declare class ChainSignatureContract$1 extends ChainSignatureContract {
|
|
|
1608
1654
|
}): Promise<TransactionInstruction>;
|
|
1609
1655
|
/**
|
|
1610
1656
|
* Sends a transaction to the program to request a signature, then
|
|
1611
|
-
*
|
|
1612
|
-
*
|
|
1657
|
+
* races a WebSocket listener against polling backfill to find the result.
|
|
1658
|
+
* If the signature is not found within the timeout, it will throw an error.
|
|
1613
1659
|
*/
|
|
1614
1660
|
sign(args: SignArgs, options?: Partial<SignOptions> & {
|
|
1615
1661
|
remainingAccounts?: AccountMeta[];
|
|
@@ -1617,42 +1663,118 @@ declare class ChainSignatureContract$1 extends ChainSignatureContract {
|
|
|
1617
1663
|
}): Promise<RSVSignature>;
|
|
1618
1664
|
private sendAndConfirmWithoutWebSocket;
|
|
1619
1665
|
/**
|
|
1620
|
-
*
|
|
1621
|
-
*
|
|
1666
|
+
* Waits for a specific event matching the given requestId by combining
|
|
1667
|
+
* a WebSocket listener (real-time) with polling backfill (resilience).
|
|
1622
1668
|
*/
|
|
1623
|
-
|
|
1624
|
-
|
|
1625
|
-
payload: _payload,
|
|
1626
|
-
path: _path,
|
|
1627
|
-
afterSignature,
|
|
1628
|
-
options
|
|
1629
|
-
}: {
|
|
1669
|
+
waitForEvent<E extends ChainSignaturesEventName>(options: {
|
|
1670
|
+
eventName: E;
|
|
1630
1671
|
requestId: string;
|
|
1631
|
-
|
|
1632
|
-
|
|
1633
|
-
|
|
1634
|
-
|
|
1635
|
-
|
|
1636
|
-
|
|
1637
|
-
|
|
1638
|
-
|
|
1639
|
-
private
|
|
1640
|
-
private
|
|
1672
|
+
signer: PublicKey;
|
|
1673
|
+
afterSignature?: string;
|
|
1674
|
+
timeoutMs?: number;
|
|
1675
|
+
backfillIntervalMs?: number;
|
|
1676
|
+
backfillLimit?: number;
|
|
1677
|
+
signal?: AbortSignal;
|
|
1678
|
+
}): Promise<EventResult<E>>;
|
|
1679
|
+
private mapRespondToResult;
|
|
1680
|
+
private mapRespondErrorToResult;
|
|
1681
|
+
private mapRespondBidirectionalToResult;
|
|
1682
|
+
private mapEventForName;
|
|
1641
1683
|
/**
|
|
1642
1684
|
* Generates the request ID for a signature request allowing to track the response.
|
|
1643
1685
|
*/
|
|
1644
1686
|
getRequestId(args: SignArgs, options?: SignOptions['sign']): string;
|
|
1645
|
-
/**
|
|
1646
|
-
* Subscribes to program events using Anchor's EventParser for regular events,
|
|
1647
|
-
* and CPI parsing for emit_cpi!-emitted events. Returns an unsubscribe fn.
|
|
1648
|
-
*/
|
|
1649
|
-
subscribeToEvents(handlers: {
|
|
1650
|
-
onSignatureResponded?: (event: SignatureRespondedEvent, slot: number) => Promise<void> | void;
|
|
1651
|
-
onSignatureError?: (event: SignatureErrorEvent, slot: number) => Promise<void> | void;
|
|
1652
|
-
}): Promise<() => Promise<void>>;
|
|
1653
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;
|
|
1654
1776
|
declare namespace index_d_exports$4 {
|
|
1655
|
-
export { ChainSignatureContract$1 as ChainSignatureContract, ChainSignaturesProject, utils };
|
|
1777
|
+
export { ChainSignatureContract$1 as ChainSignatureContract, ChainSignaturesProject, SolanaBidirectionalRequestIdArgs, SolanaRequestIdArgs, getRequestIdBidirectional, getRequestIdRespond, utils };
|
|
1656
1778
|
}
|
|
1657
1779
|
declare const utils: {
|
|
1658
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,
|
|
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;
|
|
@@ -1548,16 +1594,17 @@ interface Signature {
|
|
|
1548
1594
|
s: number[];
|
|
1549
1595
|
recoveryId: number;
|
|
1550
1596
|
}
|
|
1551
|
-
interface
|
|
1552
|
-
|
|
1553
|
-
responder: PublicKey;
|
|
1597
|
+
interface RespondBidirectionalData {
|
|
1598
|
+
serializedOutput: Buffer;
|
|
1554
1599
|
signature: Signature;
|
|
1555
1600
|
}
|
|
1556
|
-
|
|
1557
|
-
|
|
1558
|
-
|
|
1559
|
-
|
|
1601
|
+
type ChainSignaturesEventName = 'signatureRespondedEvent' | 'signatureErrorEvent' | 'respondBidirectionalEvent';
|
|
1602
|
+
interface EventResultMap {
|
|
1603
|
+
signatureRespondedEvent: RSVSignature;
|
|
1604
|
+
signatureErrorEvent: SignatureErrorData;
|
|
1605
|
+
respondBidirectionalEvent: RespondBidirectionalData;
|
|
1560
1606
|
}
|
|
1607
|
+
type EventResult<E extends ChainSignaturesEventName> = EventResultMap[E];
|
|
1561
1608
|
//#endregion
|
|
1562
1609
|
//#region src/contracts/solana/ChainSignaturesContract.d.ts
|
|
1563
1610
|
declare class ChainSignatureContract$1 extends ChainSignatureContract {
|
|
@@ -1606,8 +1653,8 @@ declare class ChainSignatureContract$1 extends ChainSignatureContract {
|
|
|
1606
1653
|
}): Promise<TransactionInstruction>;
|
|
1607
1654
|
/**
|
|
1608
1655
|
* Sends a transaction to the program to request a signature, then
|
|
1609
|
-
*
|
|
1610
|
-
*
|
|
1656
|
+
* races a WebSocket listener against polling backfill to find the result.
|
|
1657
|
+
* If the signature is not found within the timeout, it will throw an error.
|
|
1611
1658
|
*/
|
|
1612
1659
|
sign(args: SignArgs, options?: Partial<SignOptions> & {
|
|
1613
1660
|
remainingAccounts?: AccountMeta[];
|
|
@@ -1615,42 +1662,118 @@ declare class ChainSignatureContract$1 extends ChainSignatureContract {
|
|
|
1615
1662
|
}): Promise<RSVSignature>;
|
|
1616
1663
|
private sendAndConfirmWithoutWebSocket;
|
|
1617
1664
|
/**
|
|
1618
|
-
*
|
|
1619
|
-
*
|
|
1665
|
+
* Waits for a specific event matching the given requestId by combining
|
|
1666
|
+
* a WebSocket listener (real-time) with polling backfill (resilience).
|
|
1620
1667
|
*/
|
|
1621
|
-
|
|
1622
|
-
|
|
1623
|
-
payload: _payload,
|
|
1624
|
-
path: _path,
|
|
1625
|
-
afterSignature,
|
|
1626
|
-
options
|
|
1627
|
-
}: {
|
|
1668
|
+
waitForEvent<E extends ChainSignaturesEventName>(options: {
|
|
1669
|
+
eventName: E;
|
|
1628
1670
|
requestId: string;
|
|
1629
|
-
|
|
1630
|
-
|
|
1631
|
-
|
|
1632
|
-
|
|
1633
|
-
|
|
1634
|
-
|
|
1635
|
-
|
|
1636
|
-
|
|
1637
|
-
private
|
|
1638
|
-
private
|
|
1671
|
+
signer: PublicKey;
|
|
1672
|
+
afterSignature?: string;
|
|
1673
|
+
timeoutMs?: number;
|
|
1674
|
+
backfillIntervalMs?: number;
|
|
1675
|
+
backfillLimit?: number;
|
|
1676
|
+
signal?: AbortSignal;
|
|
1677
|
+
}): Promise<EventResult<E>>;
|
|
1678
|
+
private mapRespondToResult;
|
|
1679
|
+
private mapRespondErrorToResult;
|
|
1680
|
+
private mapRespondBidirectionalToResult;
|
|
1681
|
+
private mapEventForName;
|
|
1639
1682
|
/**
|
|
1640
1683
|
* Generates the request ID for a signature request allowing to track the response.
|
|
1641
1684
|
*/
|
|
1642
1685
|
getRequestId(args: SignArgs, options?: SignOptions['sign']): string;
|
|
1643
|
-
/**
|
|
1644
|
-
* Subscribes to program events using Anchor's EventParser for regular events,
|
|
1645
|
-
* and CPI parsing for emit_cpi!-emitted events. Returns an unsubscribe fn.
|
|
1646
|
-
*/
|
|
1647
|
-
subscribeToEvents(handlers: {
|
|
1648
|
-
onSignatureResponded?: (event: SignatureRespondedEvent, slot: number) => Promise<void> | void;
|
|
1649
|
-
onSignatureError?: (event: SignatureErrorEvent, slot: number) => Promise<void> | void;
|
|
1650
|
-
}): Promise<() => Promise<void>>;
|
|
1651
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;
|
|
1652
1775
|
declare namespace index_d_exports$4 {
|
|
1653
|
-
export { ChainSignatureContract$1 as ChainSignatureContract, ChainSignaturesProject, utils };
|
|
1776
|
+
export { ChainSignatureContract$1 as ChainSignatureContract, ChainSignaturesProject, SolanaBidirectionalRequestIdArgs, SolanaRequestIdArgs, getRequestIdBidirectional, getRequestIdRespond, utils };
|
|
1654
1777
|
}
|
|
1655
1778
|
declare const utils: {
|
|
1656
1779
|
ChainSignaturesContractIdl: {
|