signet.js 0.0.1-beta.1 → 0.0.1-beta.11

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.
Files changed (83) hide show
  1. package/LICENSE +19 -0
  2. package/README.md +41 -14
  3. package/browser/index.cjs +3 -0
  4. package/browser/index.cjs.map +1 -0
  5. package/browser/index.d.cts +693 -0
  6. package/browser/index.d.ts +693 -0
  7. package/browser/index.js +3 -0
  8. package/browser/index.js.map +1 -0
  9. package/node/index.cjs +3 -0
  10. package/node/index.cjs.map +1 -0
  11. package/node/index.d.cts +693 -0
  12. package/node/index.d.ts +693 -0
  13. package/node/index.js +3 -0
  14. package/node/index.js.map +1 -0
  15. package/package.json +43 -14
  16. package/src/chains/Bitcoin/BTCRpcAdapter/BTCRpcAdapter.d.ts +0 -10
  17. package/src/chains/Bitcoin/BTCRpcAdapter/BTCRpcAdapter.js +0 -2
  18. package/src/chains/Bitcoin/BTCRpcAdapter/Mempool/Mempool.d.ts +0 -15
  19. package/src/chains/Bitcoin/BTCRpcAdapter/Mempool/Mempool.js +0 -69
  20. package/src/chains/Bitcoin/BTCRpcAdapter/Mempool/index.d.ts +0 -1
  21. package/src/chains/Bitcoin/BTCRpcAdapter/Mempool/index.js +0 -1
  22. package/src/chains/Bitcoin/BTCRpcAdapter/Mempool/types.d.ts +0 -69
  23. package/src/chains/Bitcoin/BTCRpcAdapter/Mempool/types.js +0 -1
  24. package/src/chains/Bitcoin/BTCRpcAdapter/index.d.ts +0 -5
  25. package/src/chains/Bitcoin/BTCRpcAdapter/index.js +0 -5
  26. package/src/chains/Bitcoin/Bitcoin.d.ts +0 -66
  27. package/src/chains/Bitcoin/Bitcoin.js +0 -197
  28. package/src/chains/Bitcoin/types.d.ts +0 -42
  29. package/src/chains/Bitcoin/types.js +0 -1
  30. package/src/chains/Bitcoin/utils.d.ts +0 -2
  31. package/src/chains/Bitcoin/utils.js +0 -13
  32. package/src/chains/Chain.d.ts +0 -89
  33. package/src/chains/Chain.js +0 -9
  34. package/src/chains/ChainSignatureContract.d.ts +0 -62
  35. package/src/chains/ChainSignatureContract.js +0 -7
  36. package/src/chains/Cosmos/Cosmos.d.ts +0 -49
  37. package/src/chains/Cosmos/Cosmos.js +0 -156
  38. package/src/chains/Cosmos/types.d.ts +0 -30
  39. package/src/chains/Cosmos/types.js +0 -1
  40. package/src/chains/Cosmos/utils.d.ts +0 -2
  41. package/src/chains/Cosmos/utils.js +0 -27
  42. package/src/chains/EVM/EVM.d.ts +0 -40
  43. package/src/chains/EVM/EVM.js +0 -108
  44. package/src/chains/EVM/types.d.ts +0 -5
  45. package/src/chains/EVM/types.js +0 -1
  46. package/src/chains/EVM/utils.d.ts +0 -7
  47. package/src/chains/EVM/utils.js +0 -14
  48. package/src/chains/index.d.ts +0 -12
  49. package/src/chains/index.js +0 -12
  50. package/src/chains/types.d.ts +0 -31
  51. package/src/chains/types.js +0 -1
  52. package/src/chains/utils.d.ts +0 -12
  53. package/src/chains/utils.js +0 -27
  54. package/src/index.d.ts +0 -2
  55. package/src/index.js +0 -2
  56. package/src/utils/chains/index.d.ts +0 -1
  57. package/src/utils/chains/index.js +0 -1
  58. package/src/utils/chains/near/account.d.ts +0 -13
  59. package/src/utils/chains/near/account.js +0 -22
  60. package/src/utils/chains/near/constants.d.ts +0 -3
  61. package/src/utils/chains/near/constants.js +0 -3
  62. package/src/utils/chains/near/contract.d.ts +0 -39
  63. package/src/utils/chains/near/contract.js +0 -101
  64. package/src/utils/chains/near/index.d.ts +0 -3
  65. package/src/utils/chains/near/index.js +0 -3
  66. package/src/utils/chains/near/relayer/index.d.ts +0 -1
  67. package/src/utils/chains/near/relayer/index.js +0 -1
  68. package/src/utils/chains/near/relayer/relayer.d.ts +0 -8
  69. package/src/utils/chains/near/relayer/relayer.js +0 -33
  70. package/src/utils/chains/near/relayer/types.d.ts +0 -22
  71. package/src/utils/chains/near/relayer/types.js +0 -1
  72. package/src/utils/chains/near/signAndSend/index.d.ts +0 -1
  73. package/src/utils/chains/near/signAndSend/index.js +0 -1
  74. package/src/utils/chains/near/signAndSend/keypair.d.ts +0 -6
  75. package/src/utils/chains/near/signAndSend/keypair.js +0 -126
  76. package/src/utils/chains/near/transactionBuilder.d.ts +0 -26
  77. package/src/utils/chains/near/transactionBuilder.js +0 -72
  78. package/src/utils/chains/near/types.d.ts +0 -47
  79. package/src/utils/chains/near/types.js +0 -1
  80. package/src/utils/index.d.ts +0 -1
  81. package/src/utils/index.js +0 -1
  82. package/vocs.config.d.ts +0 -3
  83. package/vocs.config.js +0 -71
@@ -1,69 +0,0 @@
1
- export interface BTCFeeRecommendation {
2
- fastestFee: number;
3
- halfHourFee: number;
4
- hourFee: number;
5
- economyFee: number;
6
- minimumFee: number;
7
- }
8
- interface BTCAddressStats {
9
- funded_txo_count: number;
10
- funded_txo_sum: number;
11
- spent_txo_count: number;
12
- spent_txo_sum: number;
13
- tx_count: number;
14
- }
15
- export interface BTCAddressInfo {
16
- address: string;
17
- chain_stats: BTCAddressStats;
18
- mempool_stats: BTCAddressStats;
19
- }
20
- export interface Transaction {
21
- txid: string;
22
- version: number;
23
- locktime: number;
24
- vin: Array<{
25
- txid: string;
26
- vout: number;
27
- prevout: {
28
- scriptpubkey: string;
29
- scriptpubkey_asm: string;
30
- scriptpubkey_type: string;
31
- scriptpubkey_address: string;
32
- value: number;
33
- };
34
- scriptsig: string;
35
- scriptsig_asm: string;
36
- witness: string[];
37
- is_coinbase: boolean;
38
- sequence: number;
39
- }>;
40
- vout: Array<{
41
- scriptpubkey: string;
42
- scriptpubkey_asm: string;
43
- scriptpubkey_type: string;
44
- scriptpubkey_address: string;
45
- value: number;
46
- }>;
47
- size: number;
48
- weight: number;
49
- sigops?: number;
50
- fee: number;
51
- status: {
52
- confirmed: boolean;
53
- block_height: number;
54
- block_hash: string;
55
- block_time: number;
56
- };
57
- }
58
- export interface UTXO {
59
- txid: string;
60
- vout: number;
61
- status: {
62
- confirmed: boolean;
63
- block_height: number;
64
- block_hash: string;
65
- block_time: number;
66
- };
67
- value: number;
68
- }
69
- export {};
@@ -1 +0,0 @@
1
- export {};
@@ -1,5 +0,0 @@
1
- import { Mempool } from './Mempool';
2
- export { BTCRpcAdapter } from './BTCRpcAdapter';
3
- export declare const BTCRpcAdapters: {
4
- Mempool: typeof Mempool;
5
- };
@@ -1,5 +0,0 @@
1
- import { Mempool } from './Mempool';
2
- export { BTCRpcAdapter } from './BTCRpcAdapter';
3
- export const BTCRpcAdapters = {
4
- Mempool,
5
- };
@@ -1,66 +0,0 @@
1
- import * as bitcoin from 'bitcoinjs-lib';
2
- import type { MPCPayloads, RSVSignature, KeyDerivationPath, ChainSignatureContract, BTCRpcAdapter, BTCNetworkIds, BTCTransactionRequest, BTCUnsignedTransaction } from '@chains';
3
- import { Chain } from '@chains';
4
- /**
5
- * Implementation of the Chain interface for Bitcoin network.
6
- * Handles interactions with both Bitcoin mainnet and testnet, supporting P2WPKH transactions.
7
- */
8
- export declare class Bitcoin extends Chain<BTCTransactionRequest, BTCUnsignedTransaction> {
9
- private static readonly SATOSHIS_PER_BTC;
10
- private readonly network;
11
- private readonly btcRpcAdapter;
12
- private readonly contract;
13
- /**
14
- * Creates a new Bitcoin chain instance
15
- * @param params - Configuration parameters
16
- * @param params.network - Network identifier (mainnet/testnet)
17
- * @param params.contract - Instance of the chain signature contract for MPC operations
18
- * @param params.btcRpcAdapter - Bitcoin RPC adapter for network interactions
19
- */
20
- constructor({ network, contract, btcRpcAdapter, }: {
21
- network: BTCNetworkIds;
22
- contract: ChainSignatureContract;
23
- btcRpcAdapter: BTCRpcAdapter;
24
- });
25
- /**
26
- * Converts satoshis to BTC
27
- * @param satoshis - Amount in satoshis
28
- * @returns Amount in BTC
29
- */
30
- static toBTC(satoshis: number): number;
31
- /**
32
- * Converts BTC to satoshis
33
- * @param btc - Amount in BTC
34
- * @returns Amount in satoshis (rounded)
35
- */
36
- static toSatoshi(btc: number): number;
37
- private fetchTransaction;
38
- private static parseRSVSignature;
39
- /**
40
- * Creates a Partially Signed Bitcoin Transaction (PSBT)
41
- * @param params - Parameters for creating the PSBT
42
- * @param params.transactionRequest - Transaction request containing inputs and outputs
43
- * @returns Created PSBT instance
44
- */
45
- createPSBT({ transactionRequest, }: {
46
- transactionRequest: BTCTransactionRequest;
47
- }): Promise<bitcoin.Psbt>;
48
- getBalance(address: string): Promise<string>;
49
- deriveAddressAndPublicKey(predecessor: string, path: KeyDerivationPath): Promise<{
50
- address: string;
51
- publicKey: string;
52
- }>;
53
- setTransaction(transaction: BTCUnsignedTransaction, storageKey: string): void;
54
- getTransaction(storageKey: string, options?: {
55
- remove?: boolean;
56
- }): BTCUnsignedTransaction | undefined;
57
- getMPCPayloadAndTransaction(transactionRequest: BTCTransactionRequest): Promise<{
58
- transaction: BTCUnsignedTransaction;
59
- mpcPayloads: MPCPayloads;
60
- }>;
61
- addSignature({ transaction: { psbt, publicKey }, mpcSignatures, }: {
62
- transaction: BTCUnsignedTransaction;
63
- mpcSignatures: RSVSignature[];
64
- }): string;
65
- broadcastTx(txSerialized: string): Promise<string>;
66
- }
@@ -1,197 +0,0 @@
1
- import * as bitcoin from 'bitcoinjs-lib';
2
- import { Chain, utils } from '@chains';
3
- import { parseBTCNetwork } from '@chains/Bitcoin/utils';
4
- /**
5
- * Implementation of the Chain interface for Bitcoin network.
6
- * Handles interactions with both Bitcoin mainnet and testnet, supporting P2WPKH transactions.
7
- */
8
- export class Bitcoin extends Chain {
9
- /**
10
- * Creates a new Bitcoin chain instance
11
- * @param params - Configuration parameters
12
- * @param params.network - Network identifier (mainnet/testnet)
13
- * @param params.contract - Instance of the chain signature contract for MPC operations
14
- * @param params.btcRpcAdapter - Bitcoin RPC adapter for network interactions
15
- */
16
- constructor({ network, contract, btcRpcAdapter, }) {
17
- super();
18
- this.network = network;
19
- this.btcRpcAdapter = btcRpcAdapter;
20
- this.contract = contract;
21
- }
22
- /**
23
- * Converts satoshis to BTC
24
- * @param satoshis - Amount in satoshis
25
- * @returns Amount in BTC
26
- */
27
- static toBTC(satoshis) {
28
- return satoshis / Bitcoin.SATOSHIS_PER_BTC;
29
- }
30
- /**
31
- * Converts BTC to satoshis
32
- * @param btc - Amount in BTC
33
- * @returns Amount in satoshis (rounded)
34
- */
35
- static toSatoshi(btc) {
36
- return Math.round(btc * Bitcoin.SATOSHIS_PER_BTC);
37
- }
38
- async fetchTransaction(transactionId) {
39
- const data = await this.btcRpcAdapter.getTransaction(transactionId);
40
- const tx = new bitcoin.Transaction();
41
- data.vout.forEach((vout) => {
42
- const scriptPubKey = Buffer.from(vout.scriptpubkey, 'hex');
43
- tx.addOutput(scriptPubKey, Number(vout.value));
44
- });
45
- return tx;
46
- }
47
- static parseRSVSignature(signature) {
48
- const r = signature.r.padStart(64, '0');
49
- const s = signature.s.padStart(64, '0');
50
- const rawSignature = Buffer.from(r + s, 'hex');
51
- if (rawSignature.length !== 64) {
52
- throw new Error('Invalid signature length.');
53
- }
54
- return rawSignature;
55
- }
56
- /**
57
- * Creates a Partially Signed Bitcoin Transaction (PSBT)
58
- * @param params - Parameters for creating the PSBT
59
- * @param params.transactionRequest - Transaction request containing inputs and outputs
60
- * @returns Created PSBT instance
61
- */
62
- async createPSBT({ transactionRequest, }) {
63
- const { inputs, outputs } = transactionRequest.inputs && transactionRequest.outputs
64
- ? transactionRequest
65
- : await this.btcRpcAdapter.selectUTXOs(transactionRequest.from, [
66
- {
67
- address: transactionRequest.to,
68
- value: parseFloat(transactionRequest.value),
69
- },
70
- ]);
71
- const psbt = new bitcoin.Psbt({ network: parseBTCNetwork(this.network) });
72
- await Promise.all(inputs.map(async (input) => {
73
- if (!input.scriptPubKey) {
74
- const transaction = await this.fetchTransaction(input.txid);
75
- const prevOut = transaction.outs[input.vout];
76
- input.scriptPubKey = prevOut.script;
77
- }
78
- // Prepare the input as P2WPKH
79
- psbt.addInput({
80
- hash: input.txid,
81
- index: input.vout,
82
- witnessUtxo: {
83
- script: input.scriptPubKey,
84
- value: input.value,
85
- },
86
- });
87
- }));
88
- outputs.forEach((out) => {
89
- if (out.address) {
90
- psbt.addOutput({
91
- address: out.address,
92
- value: out.value,
93
- });
94
- }
95
- else if (out.script) {
96
- psbt.addOutput({
97
- script: out.script,
98
- value: out.value,
99
- });
100
- }
101
- });
102
- return psbt;
103
- }
104
- async getBalance(address) {
105
- const balance = await this.btcRpcAdapter.getBalance(address);
106
- return Bitcoin.toBTC(balance).toString();
107
- }
108
- async deriveAddressAndPublicKey(predecessor, path) {
109
- const uncompressedPubKey = await this.contract.getDerivedPublicKey({
110
- path,
111
- predecessor,
112
- });
113
- if (!uncompressedPubKey) {
114
- throw new Error('Failed to get derived public key');
115
- }
116
- const derivedKey = utils.compressPubKey(uncompressedPubKey);
117
- const publicKeyBuffer = Buffer.from(derivedKey, 'hex');
118
- const network = parseBTCNetwork(this.network);
119
- const payment = bitcoin.payments.p2wpkh({
120
- pubkey: publicKeyBuffer,
121
- network,
122
- });
123
- const { address } = payment;
124
- if (!address) {
125
- throw new Error('Failed to generate Bitcoin address');
126
- }
127
- return { address, publicKey: derivedKey };
128
- }
129
- setTransaction(transaction, storageKey) {
130
- window.localStorage.setItem(storageKey, JSON.stringify({
131
- psbt: transaction.psbt.toHex(),
132
- publicKey: transaction.publicKey,
133
- }));
134
- }
135
- getTransaction(storageKey, options) {
136
- const txSerialized = window.localStorage.getItem(storageKey);
137
- if (!txSerialized)
138
- return undefined;
139
- if (options?.remove) {
140
- window.localStorage.removeItem(storageKey);
141
- }
142
- const transactionJSON = JSON.parse(txSerialized);
143
- return {
144
- psbt: bitcoin.Psbt.fromHex(transactionJSON.psbt),
145
- publicKey: transactionJSON.publicKey,
146
- };
147
- }
148
- async getMPCPayloadAndTransaction(transactionRequest) {
149
- const publicKeyBuffer = Buffer.from(transactionRequest.publicKey, 'hex');
150
- const psbt = await this.createPSBT({
151
- transactionRequest,
152
- });
153
- // We can't double sign a PSBT, therefore we serialize the payload before to return it
154
- const psbtHex = psbt.toHex();
155
- const mpcPayloads = [];
156
- const mockKeyPair = (index) => ({
157
- publicKey: publicKeyBuffer,
158
- sign: (hash) => {
159
- mpcPayloads.push({
160
- index,
161
- payload: Array.from(hash),
162
- });
163
- // Return dummy signature to satisfy the interface
164
- return Buffer.alloc(64);
165
- },
166
- });
167
- for (let index = 0; index < psbt.inputCount; index++) {
168
- psbt.signInput(index, mockKeyPair(index));
169
- }
170
- return {
171
- transaction: {
172
- psbt: bitcoin.Psbt.fromHex(psbtHex),
173
- publicKey: transactionRequest.publicKey,
174
- },
175
- mpcPayloads: mpcPayloads.sort((a, b) => a.index - b.index),
176
- };
177
- }
178
- addSignature({ transaction: { psbt, publicKey }, mpcSignatures, }) {
179
- const publicKeyBuffer = Buffer.from(publicKey, 'hex');
180
- const keyPair = (index) => ({
181
- publicKey: publicKeyBuffer,
182
- sign: () => {
183
- const mpcSignature = mpcSignatures[index];
184
- return Bitcoin.parseRSVSignature(mpcSignature);
185
- },
186
- });
187
- for (let index = 0; index < psbt.inputCount; index++) {
188
- psbt.signInput(index, keyPair(index));
189
- }
190
- psbt.finalizeAllInputs();
191
- return psbt.extractTransaction().toHex();
192
- }
193
- async broadcastTx(txSerialized) {
194
- return await this.btcRpcAdapter.broadcastTransaction(txSerialized);
195
- }
196
- }
197
- Bitcoin.SATOSHIS_PER_BTC = 100000000;
@@ -1,42 +0,0 @@
1
- import type * as bitcoin from 'bitcoinjs-lib';
2
- export interface BTCTransaction {
3
- vout: Array<{
4
- scriptpubkey: string;
5
- value: number;
6
- }>;
7
- }
8
- export interface BTCInput {
9
- txid: string;
10
- vout: number;
11
- value: number;
12
- scriptPubKey: Buffer;
13
- }
14
- export type BTCOutput = {
15
- value: number;
16
- } & ({
17
- address: string;
18
- script?: never;
19
- } | {
20
- address?: never;
21
- script: Buffer;
22
- });
23
- export type BTCTransactionRequest = {
24
- publicKey: string;
25
- } & ({
26
- inputs: BTCInput[];
27
- outputs: BTCOutput[];
28
- from?: never;
29
- to?: never;
30
- value?: never;
31
- } | {
32
- inputs?: never;
33
- outputs?: never;
34
- from: string;
35
- to: string;
36
- value: string;
37
- });
38
- export interface BTCUnsignedTransaction {
39
- psbt: bitcoin.Psbt;
40
- publicKey: string;
41
- }
42
- export type BTCNetworkIds = 'mainnet' | 'testnet' | 'regtest';
@@ -1 +0,0 @@
1
- export {};
@@ -1,2 +0,0 @@
1
- import * as bitcoin from 'bitcoinjs-lib';
2
- export declare function parseBTCNetwork(network: string): bitcoin.networks.Network;
@@ -1,13 +0,0 @@
1
- import * as bitcoin from 'bitcoinjs-lib';
2
- export function parseBTCNetwork(network) {
3
- switch (network.toLowerCase()) {
4
- case 'mainnet':
5
- return bitcoin.networks.bitcoin;
6
- case 'testnet':
7
- return bitcoin.networks.testnet;
8
- case 'regtest':
9
- return bitcoin.networks.regtest;
10
- default:
11
- throw new Error(`Unknown Bitcoin network: ${network}`);
12
- }
13
- }
@@ -1,89 +0,0 @@
1
- import type { KeyDerivationPath, MPCPayloads, RSVSignature } from '@chains';
2
- /**
3
- * Core interface for blockchain implementations.
4
- * Provides a standardized way to interact with different blockchain networks through a common set of methods.
5
- *
6
- * @typeParam TransactionRequest - The type of transaction request specific to the blockchain
7
- * @typeParam UnsignedTransaction - The type of unsigned transaction specific to the blockchain
8
- */
9
- export declare abstract class Chain<TransactionRequest, UnsignedTransaction> {
10
- /**
11
- * Gets the native token balance for a given address
12
- *
13
- * @param address - The blockchain address to check
14
- * @returns Promise resolving to the balance as a string, formatted according to the chain's decimal places (e.g. ETH, BTC, etc.)
15
- * @throws Error if the balance fetch fails or the address is invalid
16
- */
17
- abstract getBalance(address: string): Promise<string>;
18
- /**
19
- * Derives an address and public key from a signer ID and derivation path.
20
- * Uses MPC (Multi-Party Computation) to derive the key pair securely.
21
- *
22
- * @param predecessor - The signer ID used to call the sign function on ChainSignatureContract
23
- * @param path - The derivation path that uniquely identifies this key pair
24
- * @returns Promise resolving to the derived address and its corresponding public key
25
- * @throws Error if key derivation fails or the signer ID is invalid
26
- */
27
- abstract deriveAddressAndPublicKey(predecessor: string, path: KeyDerivationPath): Promise<{
28
- address: string;
29
- publicKey: string;
30
- }>;
31
- /**
32
- * Stores an unsigned transaction in local storage for later use.
33
- * This method persists transaction data between page reloads and browser sessions.
34
- * Particularly useful for browser-based wallets that need to maintain transaction state.
35
- *
36
- * @param transaction - The unsigned transaction to store
37
- * @param storageKey - Unique key to identify the stored transaction
38
- */
39
- abstract setTransaction(transaction: UnsignedTransaction, storageKey: string): void;
40
- /**
41
- * Retrieves a previously stored transaction from local storage.
42
- *
43
- * @param storageKey - The key used to store the transaction
44
- * @param options - Additional options
45
- * @param options.remove - If true, removes the transaction from storage after retrieval
46
- * @returns The stored transaction or undefined if not found
47
- */
48
- abstract getTransaction(storageKey: string, options?: {
49
- remove?: boolean;
50
- }): UnsignedTransaction | undefined;
51
- /**
52
- * Prepares a transaction for MPC signing by creating the necessary payloads.
53
- * This method handles chain-specific transaction preparation including:
54
- * - Fee calculation
55
- * - Nonce/sequence management
56
- * - UTXO selection (for UTXO-based chains)
57
- * - Transaction encoding
58
- *
59
- * @param transactionRequest - The transaction request containing parameters like recipient, amount, etc.
60
- * @returns Promise resolving to the unsigned transaction and MPC payloads for signing
61
- * @throws Error if transaction preparation fails
62
- */
63
- abstract getMPCPayloadAndTransaction(transactionRequest: TransactionRequest): Promise<{
64
- transaction: UnsignedTransaction;
65
- mpcPayloads: MPCPayloads;
66
- }>;
67
- /**
68
- * Adds MPC-generated signatures to an unsigned transaction.
69
- * The signatures are applied according to the chain's specific signing scheme.
70
- *
71
- * @param params - Parameters for adding signatures
72
- * @param params.transaction - The unsigned transaction to sign
73
- * @param params.mpcSignatures - Array of RSV signatures generated through MPC
74
- * @returns The serialized signed transaction ready for broadcast
75
- * @throws Error if signature application fails
76
- */
77
- abstract addSignature(params: {
78
- transaction: UnsignedTransaction;
79
- mpcSignatures: RSVSignature[];
80
- }): string;
81
- /**
82
- * Broadcasts a signed transaction to the network.
83
- *
84
- * @param txSerialized - The serialized signed transaction
85
- * @returns Promise resolving to the transaction hash/ID
86
- * @throws Error if broadcast fails or transaction is rejected
87
- */
88
- abstract broadcastTx(txSerialized: string): Promise<string>;
89
- }
@@ -1,9 +0,0 @@
1
- /**
2
- * Core interface for blockchain implementations.
3
- * Provides a standardized way to interact with different blockchain networks through a common set of methods.
4
- *
5
- * @typeParam TransactionRequest - The type of transaction request specific to the blockchain
6
- * @typeParam UnsignedTransaction - The type of unsigned transaction specific to the blockchain
7
- */
8
- export class Chain {
9
- }
@@ -1,62 +0,0 @@
1
- import type BN from 'bn.js';
2
- import type { RSVSignature, UncompressedPubKeySEC1 } from '@chains';
3
- /**
4
- * Arguments for the sign method
5
- */
6
- export interface SignArgs {
7
- /** The payload to sign as an array of 32 bytes */
8
- payload: number[];
9
- /** The derivation path for key generation */
10
- path: string;
11
- /** Version of the key to use */
12
- key_version: number;
13
- }
14
- /**
15
- * Abstract class defining the interface for chain signature contracts.
16
- * This contract handles MPC (Multi-Party Computation) operations for secure key derivation and signing.
17
- * It serves as a bridge between the blockchain implementations and the MPC infrastructure.
18
- */
19
- export declare abstract class ChainSignatureContract {
20
- /**
21
- * Gets the current signature deposit required by the contract.
22
- * This deposit amount helps manage network congestion.
23
- *
24
- * @returns Promise resolving to the required deposit amount as a BigNumber
25
- * @throws Error if the deposit check fails
26
- */
27
- abstract getCurrentSignatureDeposit(): Promise<BN>;
28
- /**
29
- * Gets the public key associated with this contract.
30
- * This is the root public key from which child keys can be derived.
31
- *
32
- * @returns Promise resolving to the uncompressed public key
33
- * @throws Error if public key retrieval fails
34
- */
35
- abstract getPublicKey(): Promise<UncompressedPubKeySEC1>;
36
- /**
37
- * Signs a payload using MPC.
38
- * This is the core signing operation that coordinates with the MPC infrastructure.
39
- *
40
- * @param args - Arguments for the signing operation
41
- * @param args.payload - The data to sign
42
- * @param args.path - Derivation path for the signing key
43
- * @param args.key_version - Version of the key to use
44
- * @returns Promise resolving to the RSV signature
45
- * @throws Error if signing fails or is rejected
46
- */
47
- abstract sign(args: SignArgs & Record<string, unknown>): Promise<RSVSignature>;
48
- /**
49
- * Derives a child public key using a derivation path and predecessor.
50
- * This method implements hierarchical deterministic key derivation.
51
- *
52
- * @param args - Arguments for key derivation
53
- * @param args.path - The derivation path to use
54
- * @param args.predecessor - The predecessor key (usually a NEAR account) that controls this derived key
55
- * @returns Promise resolving to the derived uncompressed public key
56
- * @throws Error if key derivation fails
57
- */
58
- abstract getDerivedPublicKey(args: {
59
- path: string;
60
- predecessor: string;
61
- } & Record<string, unknown>): Promise<UncompressedPubKeySEC1>;
62
- }
@@ -1,7 +0,0 @@
1
- /**
2
- * Abstract class defining the interface for chain signature contracts.
3
- * This contract handles MPC (Multi-Party Computation) operations for secure key derivation and signing.
4
- * It serves as a bridge between the blockchain implementations and the MPC infrastructure.
5
- */
6
- export class ChainSignatureContract {
7
- }
@@ -1,49 +0,0 @@
1
- import type { MPCPayloads, RSVSignature, KeyDerivationPath, CosmosNetworkIds, CosmosTransactionRequest, CosmosUnsignedTransaction, ChainSignatureContract } from '@chains';
2
- import { Chain } from '@chains';
3
- /**
4
- * Implementation of the Chain interface for Cosmos-based networks.
5
- * Handles interactions with Cosmos SDK chains like Cosmos Hub, Osmosis, etc.
6
- */
7
- export declare class Cosmos extends Chain<CosmosTransactionRequest, CosmosUnsignedTransaction> {
8
- private readonly registry;
9
- private readonly chainId;
10
- private readonly contract;
11
- private readonly endpoints?;
12
- /**
13
- * Creates a new Cosmos chain instance
14
- * @param params - Configuration parameters
15
- * @param params.chainId - Chain id for the Cosmos network
16
- * @param params.contract - Instance of the chain signature contract for MPC operations
17
- * @param params.endpoints - Optional RPC and REST endpoints
18
- * @param params.endpoints.rpcUrl - Optional RPC endpoint URL
19
- * @param params.endpoints.restUrl - Optional REST endpoint URL
20
- */
21
- constructor({ chainId, contract, endpoints, }: {
22
- contract: ChainSignatureContract;
23
- chainId: CosmosNetworkIds;
24
- endpoints?: {
25
- rpcUrl?: string;
26
- restUrl?: string;
27
- };
28
- });
29
- private parseRSVSignature;
30
- private getChainInfo;
31
- getBalance(address: string): Promise<string>;
32
- deriveAddressAndPublicKey(predecessor: string, path: KeyDerivationPath): Promise<{
33
- address: string;
34
- publicKey: string;
35
- }>;
36
- setTransaction(transaction: CosmosUnsignedTransaction, storageKey: string): void;
37
- getTransaction(storageKey: string, options?: {
38
- remove?: boolean;
39
- }): CosmosUnsignedTransaction | undefined;
40
- getMPCPayloadAndTransaction(transactionRequest: CosmosTransactionRequest): Promise<{
41
- transaction: CosmosUnsignedTransaction;
42
- mpcPayloads: MPCPayloads;
43
- }>;
44
- addSignature({ transaction, mpcSignatures, }: {
45
- transaction: CosmosUnsignedTransaction;
46
- mpcSignatures: RSVSignature[];
47
- }): string;
48
- broadcastTx(txSerialized: string): Promise<string>;
49
- }