signet.js 0.0.12-beta.11 → 0.0.12-beta.13

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/types/index.d.ts CHANGED
@@ -3,14 +3,8 @@ import { TransactionRequest, Address, SignableMessage, TypedDataDefinition, Hex,
3
3
  import * as bitcoin from 'bitcoinjs-lib';
4
4
  import { EncodeObject } from '@cosmjs/proto-signing';
5
5
  import { TxRaw } from 'cosmjs-types/cosmos/tx/v1beta1/tx.js';
6
- import { KeyPair } from '@near-js/crypto';
7
- import { Action as Action$1 } from '@near-js/transactions';
8
- import { TxExecutionStatus } from '@near-js/types';
9
- import { NetworkId, Action, FinalExecutionOutcome } from '@near-wallet-selector/core';
10
- import { KeyPair as KeyPair$1 } from 'near-api-js';
11
- import * as _solana_web3_js from '@solana/web3.js';
12
- import { PublicKey, AccountMeta, TransactionInstruction, Signer } from '@solana/web3.js';
13
- import { AnchorProvider } from '@coral-xyz/anchor';
6
+ import { AnchorProvider, Idl } from '@coral-xyz/anchor';
7
+ import { PublicKey, Connection, AccountMeta, TransactionInstruction, Signer } from '@solana/web3.js';
14
8
 
15
9
  interface SignArgs {
16
10
  /** The payload to sign as an array of 32 bytes */
@@ -49,7 +43,7 @@ declare abstract class BaseChainSignatureContract {
49
43
  /**
50
44
  * Full contract interface that extends BaseChainSignatureContract to provide all Sig Network Smart Contract capabilities.
51
45
  */
52
- declare abstract class ChainSignatureContract$3 extends BaseChainSignatureContract {
46
+ declare abstract class ChainSignatureContract$2 extends BaseChainSignatureContract {
53
47
  /**
54
48
  * Signs a payload using Sig Network MPC.
55
49
  *
@@ -79,20 +73,6 @@ interface RSVSignature {
79
73
  s: string;
80
74
  v: number;
81
75
  }
82
- interface NearNearMpcSignature {
83
- big_r: {
84
- affine_point: string;
85
- };
86
- s: {
87
- scalar: string;
88
- };
89
- recovery_id: number;
90
- }
91
- interface SigNetNearMpcSignature {
92
- big_r: string;
93
- s: string;
94
- recovery_id: number;
95
- }
96
76
  interface SigNetEvmMpcSignature {
97
77
  bigR: {
98
78
  x: bigint;
@@ -101,7 +81,7 @@ interface SigNetEvmMpcSignature {
101
81
  s: bigint;
102
82
  recoveryId: number;
103
83
  }
104
- type MPCSignature = NearNearMpcSignature | SigNetNearMpcSignature | SigNetEvmMpcSignature;
84
+ type MPCSignature = SigNetEvmMpcSignature;
105
85
 
106
86
  declare const ENVS: {
107
87
  readonly TESTNET_DEV: "TESTNET_DEV";
@@ -110,7 +90,6 @@ declare const ENVS: {
110
90
  };
111
91
  declare const CHAINS: {
112
92
  readonly ETHEREUM: "ETHEREUM";
113
- readonly NEAR: "NEAR";
114
93
  readonly SOLANA: "SOLANA";
115
94
  };
116
95
  /**
@@ -127,7 +106,6 @@ declare const ROOT_PUBLIC_KEYS: Record<keyof typeof ENVS, NajPublicKey>;
127
106
  */
128
107
  declare const KDF_CHAIN_IDS: {
129
108
  readonly ETHEREUM: "0x1";
130
- readonly NEAR: "0x18d";
131
109
  readonly SOLANA: "0x800001f5";
132
110
  };
133
111
  /**
@@ -164,7 +142,7 @@ declare const compressPubKey: (uncompressedPubKeySEC1: UncompressedPubKeySEC1) =
164
142
  /**
165
143
  * Converts a NAJ public key to an uncompressed SEC1 public key.
166
144
  *
167
- * @param najPublicKey - The NAJ public key to convert (e.g. secp256k1:3Ww8iFjqTHufye5aRGUvrQqETegR4gVUcW8FX5xzscaN9ENhpkffojsxJwi6N1RbbHMTxYa9UyKeqK3fsMuwxjR5)
145
+ * @param najPublicKey - The NAJ public key to convert (e.g. secp 256k1:3Ww8iFjqTHufye5aRGUvrQqETegR4gVUcW8FX5xzscaN9ENhpkffojsxJwi6N1RbbHMTxYa9UyKeqK3fsMuwxjR5)
168
146
  * @returns The uncompressed SEC1 public key (e.g. 04 || x || y)
169
147
  */
170
148
  declare const najToUncompressedPubKeySEC1: (najPublicKey: NajPublicKey) => UncompressedPubKeySEC1;
@@ -178,18 +156,31 @@ declare const najToUncompressedPubKeySEC1: (najPublicKey: NajPublicKey) => Uncom
178
156
  * @returns The derived child public key in uncompressed SEC1 format (04 || x || y)
179
157
  */
180
158
  declare function deriveChildPublicKey(rootUncompressedPubKeySEC1: UncompressedPubKeySEC1, predecessorId: string, path: string | undefined, chainId: string): UncompressedPubKeySEC1;
159
+ /**
160
+ * Verifies that a secp256k1 signature was created by the expected derived address
161
+ * by recovering the signing address and comparing it with the address derived from the contract.
162
+ *
163
+ * @param signature - The RSV signature to verify
164
+ * @param payload - The original message that was signed (as byte array)
165
+ * @param requesterAddress - The address of the requester
166
+ * @param path - The derivation path used for key generation
167
+ * @param contract - The contract instance for deriving addresses
168
+ * @returns Promise resolving to true if the recovered address matches the expected address
169
+ */
170
+ declare function verifyRecoveredAddress(signature: RSVSignature, payload: number[] | Uint8Array, requesterAddress: string, path: string, contract: BaseChainSignatureContract): Promise<boolean>;
181
171
 
182
172
  declare const cryptography_compressPubKey: typeof compressPubKey;
183
173
  declare const cryptography_deriveChildPublicKey: typeof deriveChildPublicKey;
184
174
  declare const cryptography_najToUncompressedPubKeySEC1: typeof najToUncompressedPubKeySEC1;
185
175
  declare const cryptography_toRSV: typeof toRSV;
176
+ declare const cryptography_verifyRecoveredAddress: typeof verifyRecoveredAddress;
186
177
  declare namespace cryptography {
187
- export { cryptography_compressPubKey as compressPubKey, cryptography_deriveChildPublicKey as deriveChildPublicKey, cryptography_najToUncompressedPubKeySEC1 as najToUncompressedPubKeySEC1, cryptography_toRSV as toRSV };
178
+ export { cryptography_compressPubKey as compressPubKey, cryptography_deriveChildPublicKey as deriveChildPublicKey, cryptography_najToUncompressedPubKeySEC1 as najToUncompressedPubKeySEC1, cryptography_toRSV as toRSV, cryptography_verifyRecoveredAddress as verifyRecoveredAddress };
188
179
  }
189
180
 
190
- declare const index$8_cryptography: typeof cryptography;
191
- declare namespace index$8 {
192
- export { index$8_cryptography as cryptography };
181
+ declare const index$7_cryptography: typeof cryptography;
182
+ declare namespace index$7 {
183
+ export { index$7_cryptography as cryptography };
193
184
  }
194
185
 
195
186
  declare abstract class ChainAdapter<TransactionRequest, UnsignedTransaction> {
@@ -387,18 +378,18 @@ interface EVMFeeProperties {
387
378
  }
388
379
  declare function fetchEVMFeeProperties(client: PublicClient, transaction: TransactionRequest): Promise<EVMFeeProperties>;
389
380
 
390
- type index$7_EVM = EVM;
391
- declare const index$7_EVM: typeof EVM;
392
- type index$7_EVMMessage = EVMMessage;
393
- type index$7_EVMTransactionRequest = EVMTransactionRequest;
394
- type index$7_EVMTypedData = EVMTypedData;
395
- type index$7_EVMUnsignedTransaction = EVMUnsignedTransaction;
396
- declare const index$7_fetchEVMFeeProperties: typeof fetchEVMFeeProperties;
397
- declare namespace index$7 {
398
- export { index$7_EVM as EVM, type index$7_EVMMessage as EVMMessage, type index$7_EVMTransactionRequest as EVMTransactionRequest, type index$7_EVMTypedData as EVMTypedData, type index$7_EVMUnsignedTransaction as EVMUnsignedTransaction, index$7_fetchEVMFeeProperties as fetchEVMFeeProperties };
381
+ type index$6_EVM = EVM;
382
+ declare const index$6_EVM: typeof EVM;
383
+ type index$6_EVMMessage = EVMMessage;
384
+ type index$6_EVMTransactionRequest = EVMTransactionRequest;
385
+ type index$6_EVMTypedData = EVMTypedData;
386
+ type index$6_EVMUnsignedTransaction = EVMUnsignedTransaction;
387
+ declare const index$6_fetchEVMFeeProperties: typeof fetchEVMFeeProperties;
388
+ declare namespace index$6 {
389
+ export { index$6_EVM as EVM, type index$6_EVMMessage as EVMMessage, type index$6_EVMTransactionRequest as EVMTransactionRequest, type index$6_EVMTypedData as EVMTypedData, type index$6_EVMUnsignedTransaction as EVMUnsignedTransaction, index$6_fetchEVMFeeProperties as fetchEVMFeeProperties };
399
390
  }
400
391
 
401
- interface BTCTransaction$1 {
392
+ interface BTCTransaction {
402
393
  vout: Array<{
403
394
  scriptpubkey: string;
404
395
  value: number;
@@ -447,7 +438,7 @@ declare abstract class BTCRpcAdapter {
447
438
  }>;
448
439
  abstract broadcastTransaction(transactionHex: string): Promise<string>;
449
440
  abstract getBalance(address: string): Promise<number>;
450
- abstract getTransaction(txid: string): Promise<BTCTransaction$1>;
441
+ abstract getTransaction(txid: string): Promise<BTCTransaction>;
451
442
  }
452
443
 
453
444
  declare class Mempool extends BTCRpcAdapter {
@@ -461,7 +452,7 @@ declare class Mempool extends BTCRpcAdapter {
461
452
  }>;
462
453
  broadcastTransaction(transactionHex: string): Promise<string>;
463
454
  getBalance(address: string): Promise<number>;
464
- getTransaction(txid: string): Promise<BTCTransaction$1>;
455
+ getTransaction(txid: string): Promise<BTCTransaction>;
465
456
  }
466
457
 
467
458
  declare const BTCRpcAdapters: {
@@ -533,18 +524,19 @@ declare class Bitcoin extends ChainAdapter<BTCTransactionRequest, BTCUnsignedTra
533
524
  broadcastTx(txSerialized: string): Promise<string>;
534
525
  }
535
526
 
536
- type index$6_BTCInput = BTCInput;
537
- type index$6_BTCNetworkIds = BTCNetworkIds;
538
- type index$6_BTCOutput = BTCOutput;
539
- type index$6_BTCRpcAdapter = BTCRpcAdapter;
540
- declare const index$6_BTCRpcAdapter: typeof BTCRpcAdapter;
541
- declare const index$6_BTCRpcAdapters: typeof BTCRpcAdapters;
542
- type index$6_BTCTransactionRequest = BTCTransactionRequest;
543
- type index$6_BTCUnsignedTransaction = BTCUnsignedTransaction;
544
- type index$6_Bitcoin = Bitcoin;
545
- declare const index$6_Bitcoin: typeof Bitcoin;
546
- declare namespace index$6 {
547
- export { type index$6_BTCInput as BTCInput, type index$6_BTCNetworkIds as BTCNetworkIds, type index$6_BTCOutput as BTCOutput, index$6_BTCRpcAdapter as BTCRpcAdapter, index$6_BTCRpcAdapters as BTCRpcAdapters, type BTCTransaction$1 as BTCTransaction, type index$6_BTCTransactionRequest as BTCTransactionRequest, type index$6_BTCUnsignedTransaction as BTCUnsignedTransaction, index$6_Bitcoin as Bitcoin };
527
+ type index$5_BTCInput = BTCInput;
528
+ type index$5_BTCNetworkIds = BTCNetworkIds;
529
+ type index$5_BTCOutput = BTCOutput;
530
+ type index$5_BTCRpcAdapter = BTCRpcAdapter;
531
+ declare const index$5_BTCRpcAdapter: typeof BTCRpcAdapter;
532
+ declare const index$5_BTCRpcAdapters: typeof BTCRpcAdapters;
533
+ type index$5_BTCTransaction = BTCTransaction;
534
+ type index$5_BTCTransactionRequest = BTCTransactionRequest;
535
+ type index$5_BTCUnsignedTransaction = BTCUnsignedTransaction;
536
+ type index$5_Bitcoin = Bitcoin;
537
+ declare const index$5_Bitcoin: typeof Bitcoin;
538
+ declare namespace index$5 {
539
+ export { type index$5_BTCInput as BTCInput, type index$5_BTCNetworkIds as BTCNetworkIds, type index$5_BTCOutput as BTCOutput, index$5_BTCRpcAdapter as BTCRpcAdapter, index$5_BTCRpcAdapters as BTCRpcAdapters, type index$5_BTCTransaction as BTCTransaction, type index$5_BTCTransactionRequest as BTCTransactionRequest, type index$5_BTCUnsignedTransaction as BTCUnsignedTransaction, index$5_Bitcoin as Bitcoin };
548
540
  }
549
541
 
550
542
  type CosmosNetworkIds = string;
@@ -606,178 +598,19 @@ declare class Cosmos extends ChainAdapter<CosmosTransactionRequest, CosmosUnsign
606
598
  broadcastTx(txSerialized: string): Promise<string>;
607
599
  }
608
600
 
609
- type index$5_Cosmos = Cosmos;
610
- declare const index$5_Cosmos: typeof Cosmos;
611
- type index$5_CosmosNetworkIds = CosmosNetworkIds;
612
- type index$5_CosmosTransactionRequest = CosmosTransactionRequest;
613
- type index$5_CosmosUnsignedTransaction = CosmosUnsignedTransaction;
614
- declare namespace index$5 {
615
- export { index$5_Cosmos as Cosmos, type index$5_CosmosNetworkIds as CosmosNetworkIds, type index$5_CosmosTransactionRequest as CosmosTransactionRequest, type index$5_CosmosUnsignedTransaction as CosmosUnsignedTransaction };
616
- }
617
-
618
- type index$4_ChainAdapter<TransactionRequest, UnsignedTransaction> = ChainAdapter<TransactionRequest, UnsignedTransaction>;
619
- declare const index$4_ChainAdapter: typeof ChainAdapter;
601
+ type index$4_Cosmos = Cosmos;
602
+ declare const index$4_Cosmos: typeof Cosmos;
603
+ type index$4_CosmosNetworkIds = CosmosNetworkIds;
604
+ type index$4_CosmosTransactionRequest = CosmosTransactionRequest;
605
+ type index$4_CosmosUnsignedTransaction = CosmosUnsignedTransaction;
620
606
  declare namespace index$4 {
621
- export { index$4_ChainAdapter as ChainAdapter, index$6 as btc, index$5 as cosmos, index$7 as evm };
622
- }
623
-
624
- type ChainSignatureContractIds = string;
625
- type NearNetworkIds = 'mainnet' | 'testnet';
626
- interface ChainProvider {
627
- providerUrl: string;
628
- contract: ChainSignatureContractIds;
629
- }
630
- interface NearAuthentication {
631
- networkId: NearNetworkIds;
632
- accountId: string;
633
- }
634
- interface SuccessResponse {
635
- transactionHash: string;
636
- success: true;
637
- }
638
- interface FailureResponse {
639
- success: false;
640
- errorMessage: string;
641
- }
642
- type Response = SuccessResponse | FailureResponse;
643
- type EVMChainConfigWithProviders = ChainProvider;
644
- interface EVMRequest {
645
- transaction: EVMTransactionRequest;
646
- chainConfig: EVMChainConfigWithProviders;
647
- nearAuthentication: NearAuthentication;
648
- fastAuthRelayerUrl?: string;
649
- derivationPath: KeyDerivationPath;
650
- }
651
- type BTCChainConfigWithProviders = ChainProvider & {
652
- network: BTCNetworkIds;
653
- };
654
- interface BitcoinRequest {
655
- transaction: BTCTransactionRequest;
656
- chainConfig: BTCChainConfigWithProviders;
657
- nearAuthentication: NearAuthentication;
658
- fastAuthRelayerUrl?: string;
659
- derivationPath: KeyDerivationPath;
660
- }
661
- interface CosmosChainConfig {
662
- contract: ChainSignatureContractIds;
663
- chainId: CosmosNetworkIds;
664
- }
665
- interface CosmosRequest {
666
- chainConfig: CosmosChainConfig;
667
- transaction: CosmosTransactionRequest;
668
- nearAuthentication: NearAuthentication;
669
- derivationPath: KeyDerivationPath;
670
- fastAuthRelayerUrl?: string;
671
- }
672
-
673
- declare const EVMTransaction: (req: EVMRequest, keyPair: KeyPair) => Promise<Response>;
674
- declare const BTCTransaction: (req: BitcoinRequest, keyPair: KeyPair) => Promise<Response>;
675
- declare const CosmosTransaction: (req: CosmosRequest, keyPair: KeyPair) => Promise<Response>;
676
-
677
- declare const keypair_BTCTransaction: typeof BTCTransaction;
678
- declare const keypair_CosmosTransaction: typeof CosmosTransaction;
679
- declare const keypair_EVMTransaction: typeof EVMTransaction;
680
- declare namespace keypair {
681
- export { keypair_BTCTransaction as BTCTransaction, keypair_CosmosTransaction as CosmosTransaction, keypair_EVMTransaction as EVMTransaction };
607
+ export { index$4_Cosmos as Cosmos, type index$4_CosmosNetworkIds as CosmosNetworkIds, type index$4_CosmosTransactionRequest as CosmosTransactionRequest, type index$4_CosmosUnsignedTransaction as CosmosUnsignedTransaction };
682
608
  }
683
609
 
684
- declare const signAndSend_keypair: typeof keypair;
685
- declare namespace signAndSend {
686
- export { signAndSend_keypair as keypair };
687
- }
688
-
689
- declare const mpcPayloadsToChainSigTransaction: ({ networkId, contractId, hashesToSign, path, }: {
690
- networkId: NetworkId;
691
- contractId: ChainSignatureContractIds;
692
- hashesToSign: HashToSign[];
693
- path: KeyDerivationPath;
694
- }) => Promise<{
695
- receiverId: string;
696
- actions: Action[];
697
- }>;
698
- declare const responseToMpcSignature: ({ response, }: {
699
- response: FinalExecutionOutcome;
700
- }) => RSVSignature | undefined;
701
- interface SendTransactionOptions {
702
- until: TxExecutionStatus;
703
- retryCount: number;
704
- delay: number;
705
- nodeUrl: string;
706
- }
707
- declare const sendTransactionUntil: ({ accountId, keypair, networkId, receiverId, actions, nonce, options, }: {
708
- accountId: string;
709
- keypair: KeyPair$1;
710
- networkId: NetworkId;
711
- receiverId: string;
712
- actions: Action$1[];
713
- nonce?: number;
714
- options?: SendTransactionOptions;
715
- }) => Promise<FinalExecutionOutcome>;
716
-
717
- type transaction_SendTransactionOptions = SendTransactionOptions;
718
- declare const transaction_mpcPayloadsToChainSigTransaction: typeof mpcPayloadsToChainSigTransaction;
719
- declare const transaction_responseToMpcSignature: typeof responseToMpcSignature;
720
- declare const transaction_sendTransactionUntil: typeof sendTransactionUntil;
721
- declare namespace transaction {
722
- export { type transaction_SendTransactionOptions as SendTransactionOptions, transaction_mpcPayloadsToChainSigTransaction as mpcPayloadsToChainSigTransaction, transaction_responseToMpcSignature as responseToMpcSignature, transaction_sendTransactionUntil as sendTransactionUntil };
723
- }
724
-
725
- interface ChainSignatureContractArgs {
726
- networkId: NearNetworkIds;
727
- contractId: ChainSignatureContractIds;
728
- accountId?: string;
729
- keypair?: KeyPair;
730
- rootPublicKey?: NajPublicKey;
731
- sendTransactionOptions?: SendTransactionOptions;
732
- }
733
- /**
734
- * Implementation of the ChainSignatureContract for NEAR chains.
735
- *
736
- * This class provides an interface to interact with the ChainSignatures contract
737
- * deployed on NEAR. It supports both view methods (which don't require authentication)
738
- * and change methods (which require a valid NEAR account and keypair).
739
- *
740
- * @extends AbstractChainSignatureContract
741
- */
742
- declare class ChainSignatureContract$2 extends ChainSignatureContract$3 {
743
- private readonly networkId;
744
- private readonly contractId;
745
- private readonly accountId;
746
- private readonly keypair;
747
- private readonly rootPublicKey?;
748
- private readonly sendTransactionOptions?;
749
- /**
750
- * Creates a new instance of the ChainSignatureContract for NEAR chains.
751
- *
752
- * @param args - Configuration options for the contract
753
- * @param args.networkId - The NEAR network ID (e.g. 'testnet', 'mainnet')
754
- * @param args.contractId - The contract ID of the deployed ChainSignatures contract
755
- * @param args.accountId - Optional NEAR account ID for signing transactions. Required for change methods.
756
- * @param args.keypair - Optional NEAR KeyPair for signing transactions. Required for change methods.
757
- * @param args.rootPublicKey - Optional root public key for the contract. If not provided, it will be derived from the contract ID.
758
- * @param args.sendTransactionOptions - Optional configuration for transaction sending behavior.
759
- */
760
- constructor({ networkId, contractId, accountId, keypair, rootPublicKey, sendTransactionOptions, }: ChainSignatureContractArgs);
761
- private getContract;
762
- getCurrentSignatureDeposit(): Promise<BN>;
763
- getDerivedPublicKey(args: {
764
- path: string;
765
- predecessor: string;
766
- }): Promise<UncompressedPubKeySEC1>;
767
- getPublicKey(): Promise<UncompressedPubKeySEC1>;
768
- sign(args: SignArgs, options?: {
769
- nonce?: number;
770
- }): Promise<RSVSignature>;
771
- private requireAccount;
772
- }
773
-
774
- declare const utils$2: {
775
- transaction: typeof transaction;
776
- signAndSend: typeof signAndSend;
777
- };
778
-
610
+ type index$3_ChainAdapter<TransactionRequest, UnsignedTransaction> = ChainAdapter<TransactionRequest, UnsignedTransaction>;
611
+ declare const index$3_ChainAdapter: typeof ChainAdapter;
779
612
  declare namespace index$3 {
780
- export { ChainSignatureContract$2 as ChainSignatureContract, utils$2 as utils };
613
+ export { index$3_ChainAdapter as ChainAdapter, index$5 as btc, index$4 as cosmos, index$6 as evm };
781
614
  }
782
615
 
783
616
  declare const abi: ({
@@ -947,7 +780,7 @@ interface SignatureErrorData {
947
780
  * once it's available. The sign method handles this process automatically by polling
948
781
  * for the signature using the requestId.
949
782
  */
950
- declare class ChainSignatureContract$1 extends ChainSignatureContract$3 {
783
+ declare class ChainSignatureContract$1 extends ChainSignatureContract$2 {
951
784
  private readonly publicClient;
952
785
  private readonly walletClient;
953
786
  private readonly contractAddress;
@@ -1090,7 +923,575 @@ declare namespace errors {
1090
923
  export { errors_ResponseError as ResponseError, errors_SignatureContractError as SignatureContractError, errors_SignatureNotFoundError as SignatureNotFoundError, errors_SigningError as SigningError };
1091
924
  }
1092
925
 
1093
- declare class ChainSignatureContract extends ChainSignatureContract$3 {
926
+ /**
927
+ * Program IDL in camelCase format in order to be used in JS/TS.
928
+ *
929
+ * Note that this is only a type helper and is not the actual IDL. The original
930
+ * IDL can be found at `target/idl/chain_signatures_project.json`.
931
+ */
932
+ interface ChainSignaturesProject {
933
+ address: '4uvZW8K4g4jBg7dzPNbb9XDxJLFBK7V6iC76uofmYvEU';
934
+ metadata: {
935
+ name: 'chainSignaturesProject';
936
+ version: '0.1.0';
937
+ spec: '0.1.0';
938
+ description: 'Created with Anchor';
939
+ };
940
+ instructions: [
941
+ {
942
+ name: 'initialize';
943
+ discriminator: [175, 175, 109, 31, 13, 152, 155, 237];
944
+ accounts: [
945
+ {
946
+ name: 'programState';
947
+ writable: true;
948
+ pda: {
949
+ seeds: [
950
+ {
951
+ kind: 'const';
952
+ value: [
953
+ 112,
954
+ 114,
955
+ 111,
956
+ 103,
957
+ 114,
958
+ 97,
959
+ 109,
960
+ 45,
961
+ 115,
962
+ 116,
963
+ 97,
964
+ 116,
965
+ 101
966
+ ];
967
+ }
968
+ ];
969
+ };
970
+ },
971
+ {
972
+ name: 'admin';
973
+ writable: true;
974
+ signer: true;
975
+ },
976
+ {
977
+ name: 'systemProgram';
978
+ address: '11111111111111111111111111111111';
979
+ }
980
+ ];
981
+ args: [
982
+ {
983
+ name: 'signatureDeposit';
984
+ type: 'u64';
985
+ }
986
+ ];
987
+ },
988
+ {
989
+ name: 'respond';
990
+ discriminator: [72, 65, 227, 97, 42, 255, 147, 12];
991
+ accounts: [
992
+ {
993
+ name: 'responder';
994
+ signer: true;
995
+ }
996
+ ];
997
+ args: [
998
+ {
999
+ name: 'requestIds';
1000
+ type: {
1001
+ vec: {
1002
+ array: ['u8', 32];
1003
+ };
1004
+ };
1005
+ },
1006
+ {
1007
+ name: 'signatures';
1008
+ type: {
1009
+ vec: {
1010
+ defined: {
1011
+ name: 'signature';
1012
+ };
1013
+ };
1014
+ };
1015
+ }
1016
+ ];
1017
+ },
1018
+ {
1019
+ name: 'respondError';
1020
+ discriminator: [3, 170, 41, 132, 72, 184, 252, 69];
1021
+ accounts: [
1022
+ {
1023
+ name: 'responder';
1024
+ signer: true;
1025
+ }
1026
+ ];
1027
+ args: [
1028
+ {
1029
+ name: 'requestIds';
1030
+ type: {
1031
+ vec: {
1032
+ array: ['u8', 32];
1033
+ };
1034
+ };
1035
+ },
1036
+ {
1037
+ name: 'errors';
1038
+ type: {
1039
+ vec: 'string';
1040
+ };
1041
+ }
1042
+ ];
1043
+ },
1044
+ {
1045
+ name: 'sign';
1046
+ discriminator: [5, 221, 155, 46, 237, 91, 28, 236];
1047
+ accounts: [
1048
+ {
1049
+ name: 'programState';
1050
+ writable: true;
1051
+ pda: {
1052
+ seeds: [
1053
+ {
1054
+ kind: 'const';
1055
+ value: [
1056
+ 112,
1057
+ 114,
1058
+ 111,
1059
+ 103,
1060
+ 114,
1061
+ 97,
1062
+ 109,
1063
+ 45,
1064
+ 115,
1065
+ 116,
1066
+ 97,
1067
+ 116,
1068
+ 101
1069
+ ];
1070
+ }
1071
+ ];
1072
+ };
1073
+ },
1074
+ {
1075
+ name: 'requester';
1076
+ writable: true;
1077
+ signer: true;
1078
+ },
1079
+ {
1080
+ name: 'feePayer';
1081
+ writable: true;
1082
+ signer: true;
1083
+ optional: true;
1084
+ },
1085
+ {
1086
+ name: 'systemProgram';
1087
+ address: '11111111111111111111111111111111';
1088
+ }
1089
+ ];
1090
+ args: [
1091
+ {
1092
+ name: 'payload';
1093
+ type: {
1094
+ array: ['u8', 32];
1095
+ };
1096
+ },
1097
+ {
1098
+ name: 'keyVersion';
1099
+ type: 'u32';
1100
+ },
1101
+ {
1102
+ name: 'path';
1103
+ type: 'string';
1104
+ },
1105
+ {
1106
+ name: 'algo';
1107
+ type: 'string';
1108
+ },
1109
+ {
1110
+ name: 'dest';
1111
+ type: 'string';
1112
+ },
1113
+ {
1114
+ name: 'params';
1115
+ type: 'string';
1116
+ }
1117
+ ];
1118
+ },
1119
+ {
1120
+ name: 'updateDeposit';
1121
+ discriminator: [126, 116, 15, 164, 238, 179, 155, 59];
1122
+ accounts: [
1123
+ {
1124
+ name: 'programState';
1125
+ writable: true;
1126
+ pda: {
1127
+ seeds: [
1128
+ {
1129
+ kind: 'const';
1130
+ value: [
1131
+ 112,
1132
+ 114,
1133
+ 111,
1134
+ 103,
1135
+ 114,
1136
+ 97,
1137
+ 109,
1138
+ 45,
1139
+ 115,
1140
+ 116,
1141
+ 97,
1142
+ 116,
1143
+ 101
1144
+ ];
1145
+ }
1146
+ ];
1147
+ };
1148
+ },
1149
+ {
1150
+ name: 'admin';
1151
+ writable: true;
1152
+ signer: true;
1153
+ relations: ['programState'];
1154
+ },
1155
+ {
1156
+ name: 'systemProgram';
1157
+ address: '11111111111111111111111111111111';
1158
+ }
1159
+ ];
1160
+ args: [
1161
+ {
1162
+ name: 'newDeposit';
1163
+ type: 'u64';
1164
+ }
1165
+ ];
1166
+ },
1167
+ {
1168
+ name: 'withdrawFunds';
1169
+ discriminator: [241, 36, 29, 111, 208, 31, 104, 217];
1170
+ accounts: [
1171
+ {
1172
+ name: 'programState';
1173
+ writable: true;
1174
+ pda: {
1175
+ seeds: [
1176
+ {
1177
+ kind: 'const';
1178
+ value: [
1179
+ 112,
1180
+ 114,
1181
+ 111,
1182
+ 103,
1183
+ 114,
1184
+ 97,
1185
+ 109,
1186
+ 45,
1187
+ 115,
1188
+ 116,
1189
+ 97,
1190
+ 116,
1191
+ 101
1192
+ ];
1193
+ }
1194
+ ];
1195
+ };
1196
+ },
1197
+ {
1198
+ name: 'admin';
1199
+ writable: true;
1200
+ signer: true;
1201
+ relations: ['programState'];
1202
+ },
1203
+ {
1204
+ name: 'recipient';
1205
+ docs: ['function by checking it is not the zero address.'];
1206
+ writable: true;
1207
+ },
1208
+ {
1209
+ name: 'systemProgram';
1210
+ address: '11111111111111111111111111111111';
1211
+ }
1212
+ ];
1213
+ args: [
1214
+ {
1215
+ name: 'amount';
1216
+ type: 'u64';
1217
+ }
1218
+ ];
1219
+ }
1220
+ ];
1221
+ accounts: [
1222
+ {
1223
+ name: 'programState';
1224
+ discriminator: [77, 209, 137, 229, 149, 67, 167, 230];
1225
+ }
1226
+ ];
1227
+ events: [
1228
+ {
1229
+ name: 'depositUpdatedEvent';
1230
+ discriminator: [215, 193, 53, 27, 221, 101, 249, 108];
1231
+ },
1232
+ {
1233
+ name: 'fundsWithdrawnEvent';
1234
+ discriminator: [86, 232, 194, 4, 211, 69, 172, 202];
1235
+ },
1236
+ {
1237
+ name: 'signatureErrorEvent';
1238
+ discriminator: [42, 28, 210, 105, 9, 196, 189, 51];
1239
+ },
1240
+ {
1241
+ name: 'signatureRequestedEvent';
1242
+ discriminator: [171, 129, 105, 91, 154, 49, 160, 34];
1243
+ },
1244
+ {
1245
+ name: 'signatureRespondedEvent';
1246
+ discriminator: [118, 146, 248, 151, 194, 93, 18, 86];
1247
+ }
1248
+ ];
1249
+ errors: [
1250
+ {
1251
+ code: 6000;
1252
+ name: 'insufficientDeposit';
1253
+ msg: 'Insufficient deposit amount';
1254
+ },
1255
+ {
1256
+ code: 6001;
1257
+ name: 'invalidInputLength';
1258
+ msg: 'Arrays must have the same length';
1259
+ },
1260
+ {
1261
+ code: 6002;
1262
+ name: 'unauthorized';
1263
+ msg: 'Unauthorized access';
1264
+ },
1265
+ {
1266
+ code: 6003;
1267
+ name: 'insufficientFunds';
1268
+ msg: 'Insufficient funds for withdrawal';
1269
+ },
1270
+ {
1271
+ code: 6004;
1272
+ name: 'invalidRecipient';
1273
+ msg: 'Invalid recipient address';
1274
+ }
1275
+ ];
1276
+ types: [
1277
+ {
1278
+ name: 'affinePoint';
1279
+ type: {
1280
+ kind: 'struct';
1281
+ fields: [
1282
+ {
1283
+ name: 'x';
1284
+ type: {
1285
+ array: ['u8', 32];
1286
+ };
1287
+ },
1288
+ {
1289
+ name: 'y';
1290
+ type: {
1291
+ array: ['u8', 32];
1292
+ };
1293
+ }
1294
+ ];
1295
+ };
1296
+ },
1297
+ {
1298
+ name: 'depositUpdatedEvent';
1299
+ type: {
1300
+ kind: 'struct';
1301
+ fields: [
1302
+ {
1303
+ name: 'oldDeposit';
1304
+ type: 'u64';
1305
+ },
1306
+ {
1307
+ name: 'newDeposit';
1308
+ type: 'u64';
1309
+ }
1310
+ ];
1311
+ };
1312
+ },
1313
+ {
1314
+ name: 'fundsWithdrawnEvent';
1315
+ type: {
1316
+ kind: 'struct';
1317
+ fields: [
1318
+ {
1319
+ name: 'amount';
1320
+ type: 'u64';
1321
+ },
1322
+ {
1323
+ name: 'recipient';
1324
+ type: 'pubkey';
1325
+ }
1326
+ ];
1327
+ };
1328
+ },
1329
+ {
1330
+ name: 'programState';
1331
+ type: {
1332
+ kind: 'struct';
1333
+ fields: [
1334
+ {
1335
+ name: 'admin';
1336
+ type: 'pubkey';
1337
+ },
1338
+ {
1339
+ name: 'signatureDeposit';
1340
+ type: 'u64';
1341
+ }
1342
+ ];
1343
+ };
1344
+ },
1345
+ {
1346
+ name: 'signature';
1347
+ type: {
1348
+ kind: 'struct';
1349
+ fields: [
1350
+ {
1351
+ name: 'bigR';
1352
+ type: {
1353
+ defined: {
1354
+ name: 'affinePoint';
1355
+ };
1356
+ };
1357
+ },
1358
+ {
1359
+ name: 's';
1360
+ type: {
1361
+ array: ['u8', 32];
1362
+ };
1363
+ },
1364
+ {
1365
+ name: 'recoveryId';
1366
+ type: 'u8';
1367
+ }
1368
+ ];
1369
+ };
1370
+ },
1371
+ {
1372
+ name: 'signatureErrorEvent';
1373
+ type: {
1374
+ kind: 'struct';
1375
+ fields: [
1376
+ {
1377
+ name: 'requestId';
1378
+ type: {
1379
+ array: ['u8', 32];
1380
+ };
1381
+ },
1382
+ {
1383
+ name: 'responder';
1384
+ type: 'pubkey';
1385
+ },
1386
+ {
1387
+ name: 'error';
1388
+ type: 'string';
1389
+ }
1390
+ ];
1391
+ };
1392
+ },
1393
+ {
1394
+ name: 'signatureRequestedEvent';
1395
+ type: {
1396
+ kind: 'struct';
1397
+ fields: [
1398
+ {
1399
+ name: 'sender';
1400
+ type: 'pubkey';
1401
+ },
1402
+ {
1403
+ name: 'payload';
1404
+ type: {
1405
+ array: ['u8', 32];
1406
+ };
1407
+ },
1408
+ {
1409
+ name: 'keyVersion';
1410
+ type: 'u32';
1411
+ },
1412
+ {
1413
+ name: 'deposit';
1414
+ type: 'u64';
1415
+ },
1416
+ {
1417
+ name: 'chainId';
1418
+ type: 'u64';
1419
+ },
1420
+ {
1421
+ name: 'path';
1422
+ type: 'string';
1423
+ },
1424
+ {
1425
+ name: 'algo';
1426
+ type: 'string';
1427
+ },
1428
+ {
1429
+ name: 'dest';
1430
+ type: 'string';
1431
+ },
1432
+ {
1433
+ name: 'params';
1434
+ type: 'string';
1435
+ },
1436
+ {
1437
+ name: 'feePayer';
1438
+ type: {
1439
+ option: 'pubkey';
1440
+ };
1441
+ }
1442
+ ];
1443
+ };
1444
+ },
1445
+ {
1446
+ name: 'signatureRespondedEvent';
1447
+ type: {
1448
+ kind: 'struct';
1449
+ fields: [
1450
+ {
1451
+ name: 'requestId';
1452
+ type: {
1453
+ array: ['u8', 32];
1454
+ };
1455
+ },
1456
+ {
1457
+ name: 'responder';
1458
+ type: 'pubkey';
1459
+ },
1460
+ {
1461
+ name: 'signature';
1462
+ type: {
1463
+ defined: {
1464
+ name: 'signature';
1465
+ };
1466
+ };
1467
+ }
1468
+ ];
1469
+ };
1470
+ }
1471
+ ];
1472
+ }
1473
+
1474
+ interface AffinePoint {
1475
+ x: number[];
1476
+ y: number[];
1477
+ }
1478
+ interface Signature {
1479
+ bigR: AffinePoint;
1480
+ s: number[];
1481
+ recoveryId: number;
1482
+ }
1483
+ interface SignatureRespondedEvent {
1484
+ requestId: number[];
1485
+ responder: PublicKey;
1486
+ signature: Signature;
1487
+ }
1488
+ interface SignatureErrorEvent {
1489
+ requestId: number[];
1490
+ responder: PublicKey;
1491
+ error: string;
1492
+ }
1493
+
1494
+ declare class ChainSignatureContract extends ChainSignatureContract$2 {
1094
1495
  private readonly provider;
1095
1496
  private readonly program;
1096
1497
  private readonly programId;
@@ -1102,19 +1503,24 @@ declare class ChainSignatureContract extends ChainSignatureContract$3 {
1102
1503
  * @param args - Configuration options for the contract
1103
1504
  * @param args.provider - An Anchor Provider for interacting with Solana
1104
1505
  * @param args.programId - The program ID as a string or PublicKey
1105
- * @param args.rootPublicKey - Optional root public key. If not provided, it will be derived from the program ID
1106
- * @param args.requesterAddress - Provider wallet address is always the fee payer but requester can be overridden
1506
+ * @param args.config - Optional configuration
1507
+ * @param args.config.rootPublicKey - Optional root public key. If not provided, it will be derived from the program ID
1508
+ * @param args.config.requesterAddress - Provider wallet address is always the fee payer but requester can be overridden
1509
+ * @param args.config.idl - Optional custom IDL. If not provided, the default ChainSignatures IDL will be used
1107
1510
  */
1108
1511
  constructor(args: {
1109
1512
  provider: AnchorProvider;
1110
1513
  programId: string | PublicKey;
1111
- rootPublicKey?: NajPublicKey;
1112
- requesterAddress?: string;
1514
+ config?: {
1515
+ rootPublicKey?: NajPublicKey;
1516
+ requesterAddress?: string;
1517
+ idl?: ChainSignaturesProject & Idl;
1518
+ };
1113
1519
  });
1114
1520
  /**
1115
1521
  * Gets the connection from the provider
1116
1522
  */
1117
- get connection(): _solana_web3_js.Connection;
1523
+ get connection(): Connection;
1118
1524
  getCurrentSignatureDeposit(): Promise<BN>;
1119
1525
  /**
1120
1526
  * Get the Program State PDA
@@ -1142,7 +1548,7 @@ declare class ChainSignatureContract extends ChainSignatureContract$3 {
1142
1548
  * Polls for signature or error events matching the given requestId starting from the solana transaction with signature afterSignature.
1143
1549
  * Returns a signature, error data, or undefined if nothing is found.
1144
1550
  */
1145
- pollForRequestId({ requestId, payload, path, afterSignature, options, }: {
1551
+ pollForRequestId({ requestId, payload: _payload, path: _path, afterSignature, options, }: {
1146
1552
  requestId: string;
1147
1553
  payload: number[];
1148
1554
  path: string;
@@ -1153,10 +1559,19 @@ declare class ChainSignatureContract extends ChainSignatureContract$3 {
1153
1559
  * Parses transaction logs for signature or error events.
1154
1560
  */
1155
1561
  private parseLogsForEvents;
1562
+ private mapEventToResult;
1156
1563
  /**
1157
1564
  * Generates the request ID for a signature request allowing to track the response.
1158
1565
  */
1159
1566
  getRequestId(args: SignArgs, options?: SignOptions['sign']): string;
1567
+ /**
1568
+ * Subscribes to program events using Anchor's EventParser for regular events,
1569
+ * and CPI parsing for emit_cpi!-emitted events. Returns an unsubscribe fn.
1570
+ */
1571
+ subscribeToEvents(handlers: {
1572
+ onSignatureResponded?: (event: SignatureRespondedEvent, slot: number) => Promise<void> | void;
1573
+ onSignatureError?: (event: SignatureErrorEvent, slot: number) => Promise<void> | void;
1574
+ }): Promise<() => Promise<void>>;
1160
1575
  }
1161
1576
 
1162
1577
  declare const utils: {
@@ -1370,14 +1785,15 @@ declare const utils: {
1370
1785
 
1371
1786
  type index$1_ChainSignatureContract = ChainSignatureContract;
1372
1787
  declare const index$1_ChainSignatureContract: typeof ChainSignatureContract;
1788
+ type index$1_ChainSignaturesProject = ChainSignaturesProject;
1373
1789
  declare const index$1_utils: typeof utils;
1374
1790
  declare namespace index$1 {
1375
- export { index$1_ChainSignatureContract as ChainSignatureContract, index$1_utils as utils };
1791
+ export { index$1_ChainSignatureContract as ChainSignatureContract, type index$1_ChainSignaturesProject as ChainSignaturesProject, index$1_utils as utils };
1376
1792
  }
1377
1793
 
1378
1794
  type index_SignArgs = SignArgs;
1379
1795
  declare namespace index {
1380
- export { ChainSignatureContract$3 as ChainSignatureContract, type index_SignArgs as SignArgs, index$2 as evm, index$3 as near, index$1 as solana };
1796
+ export { ChainSignatureContract$2 as ChainSignatureContract, type index_SignArgs as SignArgs, index$2 as evm, index$1 as solana };
1381
1797
  }
1382
1798
 
1383
- export { type CompressedPubKeySEC1, type HashToSign, type KeyDerivationPath, type MPCSignature, type NajPublicKey, type NearNearMpcSignature, type RSVSignature, type SigNetEvmMpcSignature, type SigNetNearMpcSignature, type UncompressedPubKeySEC1, index$4 as chainAdapters, constants, index as contracts, index$8 as utils };
1799
+ export { type CompressedPubKeySEC1, type HashToSign, type KeyDerivationPath, type MPCSignature, type NajPublicKey, type RSVSignature, type SigNetEvmMpcSignature, type UncompressedPubKeySEC1, index$3 as chainAdapters, constants, index as contracts, index$7 as utils };