@atomiqlabs/chain-solana 13.5.13 → 13.5.14
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/LICENSE +201 -201
- package/README.md +73 -73
- package/dist/index.d.ts +81 -81
- package/dist/index.js +102 -102
- package/dist/node/index.d.ts +9 -9
- package/dist/node/index.js +13 -13
- package/dist/solana/SolanaChainType.d.ts +15 -15
- package/dist/solana/SolanaChainType.js +2 -2
- package/dist/solana/SolanaChains.d.ts +12 -12
- package/dist/solana/SolanaChains.js +45 -45
- package/dist/solana/SolanaInitializer.d.ts +94 -94
- package/dist/solana/SolanaInitializer.js +174 -174
- package/dist/solana/btcrelay/SolanaBtcRelay.d.ts +222 -222
- package/dist/solana/btcrelay/SolanaBtcRelay.js +455 -455
- package/dist/solana/btcrelay/headers/SolanaBtcHeader.d.ts +84 -84
- package/dist/solana/btcrelay/headers/SolanaBtcHeader.js +70 -70
- package/dist/solana/btcrelay/headers/SolanaBtcStoredHeader.d.ts +92 -92
- package/dist/solana/btcrelay/headers/SolanaBtcStoredHeader.js +109 -109
- package/dist/solana/btcrelay/program/programIdl.json +671 -671
- package/dist/solana/chain/SolanaAction.d.ts +26 -26
- package/dist/solana/chain/SolanaAction.js +87 -87
- package/dist/solana/chain/SolanaChainInterface.d.ts +224 -224
- package/dist/solana/chain/SolanaChainInterface.js +275 -275
- package/dist/solana/chain/SolanaModule.d.ts +14 -14
- package/dist/solana/chain/SolanaModule.js +13 -13
- package/dist/solana/chain/modules/SolanaAddresses.d.ts +8 -8
- package/dist/solana/chain/modules/SolanaAddresses.js +22 -22
- package/dist/solana/chain/modules/SolanaBlocks.d.ts +32 -32
- package/dist/solana/chain/modules/SolanaBlocks.js +78 -78
- package/dist/solana/chain/modules/SolanaEvents.d.ts +68 -68
- package/dist/solana/chain/modules/SolanaEvents.js +238 -238
- package/dist/solana/chain/modules/SolanaFees.d.ts +189 -189
- package/dist/solana/chain/modules/SolanaFees.js +434 -434
- package/dist/solana/chain/modules/SolanaSignatures.d.ts +24 -24
- package/dist/solana/chain/modules/SolanaSignatures.js +39 -39
- package/dist/solana/chain/modules/SolanaSlots.d.ts +33 -33
- package/dist/solana/chain/modules/SolanaSlots.js +72 -72
- package/dist/solana/chain/modules/SolanaTokens.d.ts +123 -123
- package/dist/solana/chain/modules/SolanaTokens.js +242 -242
- package/dist/solana/chain/modules/SolanaTransactions.d.ts +149 -149
- package/dist/solana/chain/modules/SolanaTransactions.js +445 -445
- package/dist/solana/connection/ConnectionWithRetries.d.ts +35 -35
- package/dist/solana/connection/ConnectionWithRetries.js +86 -71
- package/dist/solana/events/SolanaChainEvents.d.ts +45 -45
- package/dist/solana/events/SolanaChainEvents.js +108 -108
- package/dist/solana/events/SolanaChainEventsBrowser.d.ts +205 -205
- package/dist/solana/events/SolanaChainEventsBrowser.js +404 -404
- package/dist/solana/program/SolanaProgramBase.d.ts +73 -73
- package/dist/solana/program/SolanaProgramBase.js +54 -54
- package/dist/solana/program/SolanaProgramModule.d.ts +8 -8
- package/dist/solana/program/SolanaProgramModule.js +11 -11
- package/dist/solana/program/modules/SolanaProgramEvents.d.ts +53 -53
- package/dist/solana/program/modules/SolanaProgramEvents.js +117 -117
- package/dist/solana/swaps/SolanaSwapData.d.ts +333 -333
- package/dist/solana/swaps/SolanaSwapData.js +535 -535
- package/dist/solana/swaps/SolanaSwapModule.d.ts +11 -11
- package/dist/solana/swaps/SolanaSwapModule.js +12 -12
- package/dist/solana/swaps/SolanaSwapProgram.d.ts +376 -376
- package/dist/solana/swaps/SolanaSwapProgram.js +769 -769
- package/dist/solana/swaps/SwapTypeEnum.d.ts +11 -11
- package/dist/solana/swaps/SwapTypeEnum.js +43 -43
- package/dist/solana/swaps/modules/SolanaDataAccount.d.ts +95 -95
- package/dist/solana/swaps/modules/SolanaDataAccount.js +232 -232
- package/dist/solana/swaps/modules/SolanaLpVault.d.ts +69 -69
- package/dist/solana/swaps/modules/SolanaLpVault.js +171 -171
- package/dist/solana/swaps/modules/SwapClaim.d.ts +126 -126
- package/dist/solana/swaps/modules/SwapClaim.js +294 -294
- package/dist/solana/swaps/modules/SwapInit.d.ts +213 -213
- package/dist/solana/swaps/modules/SwapInit.js +658 -658
- package/dist/solana/swaps/modules/SwapRefund.d.ts +87 -87
- package/dist/solana/swaps/modules/SwapRefund.js +293 -293
- package/dist/solana/swaps/programIdl.json +945 -945
- package/dist/solana/swaps/programTypes.d.ts +943 -943
- package/dist/solana/swaps/programTypes.js +945 -945
- package/dist/solana/swaps/v1/programIdl.json +945 -945
- package/dist/solana/swaps/v1/programTypes.d.ts +943 -943
- package/dist/solana/swaps/v1/programTypes.js +945 -945
- package/dist/solana/swaps/v2/programIdl.json +952 -952
- package/dist/solana/swaps/v2/programTypes.d.ts +950 -950
- package/dist/solana/swaps/v2/programTypes.js +952 -952
- package/dist/solana/wallet/SolanaKeypairWallet.d.ts +29 -29
- package/dist/solana/wallet/SolanaKeypairWallet.js +50 -50
- package/dist/solana/wallet/SolanaSigner.d.ts +30 -30
- package/dist/solana/wallet/SolanaSigner.js +30 -30
- package/dist/utils/Utils.d.ts +58 -58
- package/dist/utils/Utils.js +170 -170
- package/node/index.d.ts +1 -1
- package/node/index.js +3 -3
- package/package.json +46 -46
- package/src/index.ts +87 -87
- package/src/node/index.ts +9 -9
- package/src/solana/SolanaChainType.ts +32 -32
- package/src/solana/SolanaChains.ts +46 -46
- package/src/solana/SolanaInitializer.ts +278 -278
- package/src/solana/btcrelay/SolanaBtcRelay.ts +615 -615
- package/src/solana/btcrelay/headers/SolanaBtcHeader.ts +116 -116
- package/src/solana/btcrelay/headers/SolanaBtcStoredHeader.ts +148 -148
- package/src/solana/btcrelay/program/programIdl.json +670 -670
- package/src/solana/chain/SolanaAction.ts +109 -109
- package/src/solana/chain/SolanaChainInterface.ts +404 -404
- package/src/solana/chain/SolanaModule.ts +20 -20
- package/src/solana/chain/modules/SolanaAddresses.ts +20 -20
- package/src/solana/chain/modules/SolanaBlocks.ts +89 -89
- package/src/solana/chain/modules/SolanaEvents.ts +271 -271
- package/src/solana/chain/modules/SolanaFees.ts +522 -522
- package/src/solana/chain/modules/SolanaSignatures.ts +39 -39
- package/src/solana/chain/modules/SolanaSlots.ts +85 -85
- package/src/solana/chain/modules/SolanaTokens.ts +300 -300
- package/src/solana/chain/modules/SolanaTransactions.ts +503 -503
- package/src/solana/connection/ConnectionWithRetries.ts +113 -96
- package/src/solana/events/SolanaChainEvents.ts +127 -127
- package/src/solana/events/SolanaChainEventsBrowser.ts +495 -495
- package/src/solana/program/SolanaProgramBase.ts +119 -119
- package/src/solana/program/SolanaProgramModule.ts +15 -15
- package/src/solana/program/modules/SolanaProgramEvents.ts +157 -157
- package/src/solana/swaps/SolanaSwapData.ts +735 -735
- package/src/solana/swaps/SolanaSwapModule.ts +19 -19
- package/src/solana/swaps/SolanaSwapProgram.ts +1074 -1074
- package/src/solana/swaps/SwapTypeEnum.ts +30 -30
- package/src/solana/swaps/modules/SolanaDataAccount.ts +302 -302
- package/src/solana/swaps/modules/SolanaLpVault.ts +208 -208
- package/src/solana/swaps/modules/SwapClaim.ts +387 -387
- package/src/solana/swaps/modules/SwapInit.ts +785 -785
- package/src/solana/swaps/modules/SwapRefund.ts +353 -353
- package/src/solana/swaps/v1/programIdl.json +944 -944
- package/src/solana/swaps/v1/programTypes.ts +1885 -1885
- package/src/solana/swaps/v2/programIdl.json +951 -951
- package/src/solana/swaps/v2/programTypes.ts +1899 -1899
- package/src/solana/wallet/SolanaKeypairWallet.ts +56 -56
- package/src/solana/wallet/SolanaSigner.ts +43 -43
- package/src/utils/Utils.ts +194 -194
|
@@ -1,222 +1,222 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
|
-
/// <reference types="node" />
|
|
3
|
-
import { PublicKey, Signer, Transaction } from "@solana/web3.js";
|
|
4
|
-
import { SolanaBtcStoredHeader } from "./headers/SolanaBtcStoredHeader";
|
|
5
|
-
import { BitcoinNetwork, BitcoinRpc, BtcBlock, BtcRelay } from "@atomiqlabs/base";
|
|
6
|
-
import { SolanaProgramBase } from "../program/SolanaProgramBase";
|
|
7
|
-
import { SolanaAction } from "../chain/SolanaAction";
|
|
8
|
-
import { Buffer } from "buffer";
|
|
9
|
-
import { SolanaSigner } from "../wallet/SolanaSigner";
|
|
10
|
-
import { SolanaChainInterface } from "../chain/SolanaChainInterface";
|
|
11
|
-
/**
|
|
12
|
-
* Solana BTC relay (bitcoin light client) program representation.
|
|
13
|
-
*
|
|
14
|
-
* @category BTC Relay
|
|
15
|
-
*/
|
|
16
|
-
export declare class SolanaBtcRelay<B extends BtcBlock> extends SolanaProgramBase<any> implements BtcRelay<SolanaBtcStoredHeader, {
|
|
17
|
-
tx: Transaction;
|
|
18
|
-
signers: Signer[];
|
|
19
|
-
}, B, SolanaSigner> {
|
|
20
|
-
/**
|
|
21
|
-
* Creates initialization action for initializing the btc relay
|
|
22
|
-
*
|
|
23
|
-
* @param signer
|
|
24
|
-
* @param header
|
|
25
|
-
* @param epochStart
|
|
26
|
-
* @param pastBlocksTimestamps
|
|
27
|
-
* @private
|
|
28
|
-
*/
|
|
29
|
-
private Initialize;
|
|
30
|
-
/**
|
|
31
|
-
* Creates verify action to be used with the swap program, specifies the action to be firstIxBeforeComputeBudget,
|
|
32
|
-
* such that the verify instruction will always be the 0th in the transaction, this is required because
|
|
33
|
-
* swap program expects the verify instruction to be at the 0th position
|
|
34
|
-
*
|
|
35
|
-
* @param signer
|
|
36
|
-
* @param reversedTxId
|
|
37
|
-
* @param confirmations
|
|
38
|
-
* @param position
|
|
39
|
-
* @param reversedMerkleProof
|
|
40
|
-
* @param committedHeader
|
|
41
|
-
*/
|
|
42
|
-
Verify(signer: PublicKey, reversedTxId: Buffer, confirmations: number, position: number, reversedMerkleProof: Buffer[], committedHeader: SolanaBtcStoredHeader): Promise<SolanaAction>;
|
|
43
|
-
/**
|
|
44
|
-
* Creates an action that closes a fork account and refunds rent to the signer.
|
|
45
|
-
*
|
|
46
|
-
* @param signer Signer paying and receiving rent refund
|
|
47
|
-
* @param forkId Fork account identifier to close
|
|
48
|
-
*/
|
|
49
|
-
private CloseForkAccount;
|
|
50
|
-
/**
|
|
51
|
-
* PDA of the relay main state account.
|
|
52
|
-
*/
|
|
53
|
-
private readonly BtcRelayMainState;
|
|
54
|
-
/**
|
|
55
|
-
* PDA helper for per-header topic accounts.
|
|
56
|
-
*/
|
|
57
|
-
private readonly BtcRelayHeader;
|
|
58
|
-
/**
|
|
59
|
-
* PDA helper for fork state accounts.
|
|
60
|
-
*/
|
|
61
|
-
private readonly BtcRelayFork;
|
|
62
|
-
/**
|
|
63
|
-
* Bitcoin RPC client used for bitcoin chain lookups.
|
|
64
|
-
*
|
|
65
|
-
* @internal
|
|
66
|
-
*/
|
|
67
|
-
_bitcoinRpc: BitcoinRpc<B>;
|
|
68
|
-
/**
|
|
69
|
-
* @inheritDoc
|
|
70
|
-
*/
|
|
71
|
-
readonly maxHeadersPerTx: number;
|
|
72
|
-
/**
|
|
73
|
-
* @inheritDoc
|
|
74
|
-
*/
|
|
75
|
-
readonly maxForkHeadersPerTx: number;
|
|
76
|
-
/**
|
|
77
|
-
* @inheritDoc
|
|
78
|
-
*/
|
|
79
|
-
readonly maxShortForkHeadersPerTx: number;
|
|
80
|
-
/**
|
|
81
|
-
* @param chainInterface Underlying chain interface to use for the Solana chain operations
|
|
82
|
-
* @param bitcoinRpc Bitcoin RPC instance to use for read access to the bitcoin blockchain
|
|
83
|
-
* @param programAddress Optional Solana on-chain program address, defaults to the cannonical deployment
|
|
84
|
-
* @param bitcoinNetwork
|
|
85
|
-
* @param contractVersion
|
|
86
|
-
*/
|
|
87
|
-
constructor(chainInterface: SolanaChainInterface, bitcoinRpc: BitcoinRpc<B>, programAddress?: string, bitcoinNetwork?: BitcoinNetwork, contractVersion?: "v1" | "v2");
|
|
88
|
-
/**
|
|
89
|
-
* Gets set of block commitments representing current main chain from the mainState
|
|
90
|
-
*
|
|
91
|
-
* @param mainState
|
|
92
|
-
* @private
|
|
93
|
-
*/
|
|
94
|
-
private getBlockCommitmentsSet;
|
|
95
|
-
/**
|
|
96
|
-
* Computes subsequent committed headers as they will appear on the blockchain when transactions
|
|
97
|
-
* are submitted & confirmed
|
|
98
|
-
*
|
|
99
|
-
* @param initialStoredHeader
|
|
100
|
-
* @param syncedHeaders
|
|
101
|
-
* @private
|
|
102
|
-
*/
|
|
103
|
-
private computeCommitedHeaders;
|
|
104
|
-
/**
|
|
105
|
-
* A common logic for submitting blockheaders in a transaction
|
|
106
|
-
*
|
|
107
|
-
* @param signer
|
|
108
|
-
* @param headers headers to sync to the btc relay
|
|
109
|
-
* @param storedHeader current latest stored block header for a given fork
|
|
110
|
-
* @param forkId forkId to submit to, forkId=0 means main chain
|
|
111
|
-
* @param feeRate feeRate for the transaction
|
|
112
|
-
* @param createTx transaction generator function
|
|
113
|
-
* @private
|
|
114
|
-
*/
|
|
115
|
-
private _saveHeaders;
|
|
116
|
-
/**
|
|
117
|
-
* @inheritDoc
|
|
118
|
-
*/
|
|
119
|
-
getTipData(): Promise<{
|
|
120
|
-
commitHash: string;
|
|
121
|
-
blockhash: string;
|
|
122
|
-
chainWork: Buffer;
|
|
123
|
-
blockheight: number;
|
|
124
|
-
} | null>;
|
|
125
|
-
/**
|
|
126
|
-
* @inheritDoc
|
|
127
|
-
*/
|
|
128
|
-
retrieveLogAndBlockheight(blockData: {
|
|
129
|
-
blockhash: string;
|
|
130
|
-
}, requiredBlockheight?: number): Promise<{
|
|
131
|
-
header: SolanaBtcStoredHeader;
|
|
132
|
-
height: number;
|
|
133
|
-
} | null>;
|
|
134
|
-
/**
|
|
135
|
-
* @inheritDoc
|
|
136
|
-
*/
|
|
137
|
-
retrieveLogByCommitHash(commitmentHashStr: string, blockData: {
|
|
138
|
-
blockhash: string;
|
|
139
|
-
}): Promise<SolanaBtcStoredHeader | null>;
|
|
140
|
-
/**
|
|
141
|
-
* @inheritDoc
|
|
142
|
-
*/
|
|
143
|
-
retrieveLatestKnownBlockLog(): Promise<{
|
|
144
|
-
resultStoredHeader: SolanaBtcStoredHeader;
|
|
145
|
-
resultBitcoinHeader: B;
|
|
146
|
-
} | null>;
|
|
147
|
-
/**
|
|
148
|
-
* @inheritDoc
|
|
149
|
-
*/
|
|
150
|
-
saveInitialHeader(signer: string, header: B, epochStart: number, pastBlocksTimestamps: number[], feeRate?: string): Promise<{
|
|
151
|
-
tx: Transaction;
|
|
152
|
-
signers: Signer[];
|
|
153
|
-
}>;
|
|
154
|
-
/**
|
|
155
|
-
* @inheritDoc
|
|
156
|
-
*/
|
|
157
|
-
saveMainHeaders(signer: string, mainHeaders: BtcBlock[], storedHeader: SolanaBtcStoredHeader, feeRate?: string): Promise<{
|
|
158
|
-
forkId: number;
|
|
159
|
-
lastStoredHeader: SolanaBtcStoredHeader;
|
|
160
|
-
tx: {
|
|
161
|
-
tx: Transaction;
|
|
162
|
-
signers: never[];
|
|
163
|
-
};
|
|
164
|
-
computedCommitedHeaders: SolanaBtcStoredHeader[];
|
|
165
|
-
}>;
|
|
166
|
-
/**
|
|
167
|
-
* @inheritDoc
|
|
168
|
-
*/
|
|
169
|
-
saveNewForkHeaders(signer: string, forkHeaders: BtcBlock[], storedHeader: SolanaBtcStoredHeader, tipWork: Buffer, feeRate?: string): Promise<{
|
|
170
|
-
forkId: number;
|
|
171
|
-
lastStoredHeader: SolanaBtcStoredHeader;
|
|
172
|
-
tx: {
|
|
173
|
-
tx: Transaction;
|
|
174
|
-
signers: never[];
|
|
175
|
-
};
|
|
176
|
-
computedCommitedHeaders: SolanaBtcStoredHeader[];
|
|
177
|
-
}>;
|
|
178
|
-
/**
|
|
179
|
-
* @inheritDoc
|
|
180
|
-
*/
|
|
181
|
-
saveForkHeaders(signer: string, forkHeaders: BtcBlock[], storedHeader: SolanaBtcStoredHeader, forkId: number, tipWork: Buffer, feeRate?: string): Promise<{
|
|
182
|
-
forkId: number;
|
|
183
|
-
lastStoredHeader: SolanaBtcStoredHeader;
|
|
184
|
-
tx: {
|
|
185
|
-
tx: Transaction;
|
|
186
|
-
signers: never[];
|
|
187
|
-
};
|
|
188
|
-
computedCommitedHeaders: SolanaBtcStoredHeader[];
|
|
189
|
-
}>;
|
|
190
|
-
/**
|
|
191
|
-
* @inheritDoc
|
|
192
|
-
*/
|
|
193
|
-
saveShortForkHeaders(signer: string, forkHeaders: BtcBlock[], storedHeader: SolanaBtcStoredHeader, tipWork: Buffer, feeRate?: string): Promise<{
|
|
194
|
-
forkId: number;
|
|
195
|
-
lastStoredHeader: SolanaBtcStoredHeader;
|
|
196
|
-
tx: {
|
|
197
|
-
tx: Transaction;
|
|
198
|
-
signers: never[];
|
|
199
|
-
};
|
|
200
|
-
computedCommitedHeaders: SolanaBtcStoredHeader[];
|
|
201
|
-
}>;
|
|
202
|
-
/**
|
|
203
|
-
* @inheritDoc
|
|
204
|
-
*/
|
|
205
|
-
sweepForkData(signer: SolanaSigner, lastSweepId?: number): Promise<number | null>;
|
|
206
|
-
/**
|
|
207
|
-
* @inheritDoc
|
|
208
|
-
*/
|
|
209
|
-
estimateSynchronizeFee(requiredBlockheight: number, feeRate?: string): Promise<bigint>;
|
|
210
|
-
/**
|
|
211
|
-
* @inheritDoc
|
|
212
|
-
*/
|
|
213
|
-
getFeePerBlock(feeRate?: string): Promise<bigint>;
|
|
214
|
-
/**
|
|
215
|
-
* @inheritDoc
|
|
216
|
-
*/
|
|
217
|
-
getMainFeeRate(signer: string | null): Promise<string>;
|
|
218
|
-
/**
|
|
219
|
-
* @inheritDoc
|
|
220
|
-
*/
|
|
221
|
-
getForkFeeRate(signer: string, forkId: number): Promise<string>;
|
|
222
|
-
}
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
/// <reference types="node" />
|
|
3
|
+
import { PublicKey, Signer, Transaction } from "@solana/web3.js";
|
|
4
|
+
import { SolanaBtcStoredHeader } from "./headers/SolanaBtcStoredHeader";
|
|
5
|
+
import { BitcoinNetwork, BitcoinRpc, BtcBlock, BtcRelay } from "@atomiqlabs/base";
|
|
6
|
+
import { SolanaProgramBase } from "../program/SolanaProgramBase";
|
|
7
|
+
import { SolanaAction } from "../chain/SolanaAction";
|
|
8
|
+
import { Buffer } from "buffer";
|
|
9
|
+
import { SolanaSigner } from "../wallet/SolanaSigner";
|
|
10
|
+
import { SolanaChainInterface } from "../chain/SolanaChainInterface";
|
|
11
|
+
/**
|
|
12
|
+
* Solana BTC relay (bitcoin light client) program representation.
|
|
13
|
+
*
|
|
14
|
+
* @category BTC Relay
|
|
15
|
+
*/
|
|
16
|
+
export declare class SolanaBtcRelay<B extends BtcBlock> extends SolanaProgramBase<any> implements BtcRelay<SolanaBtcStoredHeader, {
|
|
17
|
+
tx: Transaction;
|
|
18
|
+
signers: Signer[];
|
|
19
|
+
}, B, SolanaSigner> {
|
|
20
|
+
/**
|
|
21
|
+
* Creates initialization action for initializing the btc relay
|
|
22
|
+
*
|
|
23
|
+
* @param signer
|
|
24
|
+
* @param header
|
|
25
|
+
* @param epochStart
|
|
26
|
+
* @param pastBlocksTimestamps
|
|
27
|
+
* @private
|
|
28
|
+
*/
|
|
29
|
+
private Initialize;
|
|
30
|
+
/**
|
|
31
|
+
* Creates verify action to be used with the swap program, specifies the action to be firstIxBeforeComputeBudget,
|
|
32
|
+
* such that the verify instruction will always be the 0th in the transaction, this is required because
|
|
33
|
+
* swap program expects the verify instruction to be at the 0th position
|
|
34
|
+
*
|
|
35
|
+
* @param signer
|
|
36
|
+
* @param reversedTxId
|
|
37
|
+
* @param confirmations
|
|
38
|
+
* @param position
|
|
39
|
+
* @param reversedMerkleProof
|
|
40
|
+
* @param committedHeader
|
|
41
|
+
*/
|
|
42
|
+
Verify(signer: PublicKey, reversedTxId: Buffer, confirmations: number, position: number, reversedMerkleProof: Buffer[], committedHeader: SolanaBtcStoredHeader): Promise<SolanaAction>;
|
|
43
|
+
/**
|
|
44
|
+
* Creates an action that closes a fork account and refunds rent to the signer.
|
|
45
|
+
*
|
|
46
|
+
* @param signer Signer paying and receiving rent refund
|
|
47
|
+
* @param forkId Fork account identifier to close
|
|
48
|
+
*/
|
|
49
|
+
private CloseForkAccount;
|
|
50
|
+
/**
|
|
51
|
+
* PDA of the relay main state account.
|
|
52
|
+
*/
|
|
53
|
+
private readonly BtcRelayMainState;
|
|
54
|
+
/**
|
|
55
|
+
* PDA helper for per-header topic accounts.
|
|
56
|
+
*/
|
|
57
|
+
private readonly BtcRelayHeader;
|
|
58
|
+
/**
|
|
59
|
+
* PDA helper for fork state accounts.
|
|
60
|
+
*/
|
|
61
|
+
private readonly BtcRelayFork;
|
|
62
|
+
/**
|
|
63
|
+
* Bitcoin RPC client used for bitcoin chain lookups.
|
|
64
|
+
*
|
|
65
|
+
* @internal
|
|
66
|
+
*/
|
|
67
|
+
_bitcoinRpc: BitcoinRpc<B>;
|
|
68
|
+
/**
|
|
69
|
+
* @inheritDoc
|
|
70
|
+
*/
|
|
71
|
+
readonly maxHeadersPerTx: number;
|
|
72
|
+
/**
|
|
73
|
+
* @inheritDoc
|
|
74
|
+
*/
|
|
75
|
+
readonly maxForkHeadersPerTx: number;
|
|
76
|
+
/**
|
|
77
|
+
* @inheritDoc
|
|
78
|
+
*/
|
|
79
|
+
readonly maxShortForkHeadersPerTx: number;
|
|
80
|
+
/**
|
|
81
|
+
* @param chainInterface Underlying chain interface to use for the Solana chain operations
|
|
82
|
+
* @param bitcoinRpc Bitcoin RPC instance to use for read access to the bitcoin blockchain
|
|
83
|
+
* @param programAddress Optional Solana on-chain program address, defaults to the cannonical deployment
|
|
84
|
+
* @param bitcoinNetwork
|
|
85
|
+
* @param contractVersion
|
|
86
|
+
*/
|
|
87
|
+
constructor(chainInterface: SolanaChainInterface, bitcoinRpc: BitcoinRpc<B>, programAddress?: string, bitcoinNetwork?: BitcoinNetwork, contractVersion?: "v1" | "v2");
|
|
88
|
+
/**
|
|
89
|
+
* Gets set of block commitments representing current main chain from the mainState
|
|
90
|
+
*
|
|
91
|
+
* @param mainState
|
|
92
|
+
* @private
|
|
93
|
+
*/
|
|
94
|
+
private getBlockCommitmentsSet;
|
|
95
|
+
/**
|
|
96
|
+
* Computes subsequent committed headers as they will appear on the blockchain when transactions
|
|
97
|
+
* are submitted & confirmed
|
|
98
|
+
*
|
|
99
|
+
* @param initialStoredHeader
|
|
100
|
+
* @param syncedHeaders
|
|
101
|
+
* @private
|
|
102
|
+
*/
|
|
103
|
+
private computeCommitedHeaders;
|
|
104
|
+
/**
|
|
105
|
+
* A common logic for submitting blockheaders in a transaction
|
|
106
|
+
*
|
|
107
|
+
* @param signer
|
|
108
|
+
* @param headers headers to sync to the btc relay
|
|
109
|
+
* @param storedHeader current latest stored block header for a given fork
|
|
110
|
+
* @param forkId forkId to submit to, forkId=0 means main chain
|
|
111
|
+
* @param feeRate feeRate for the transaction
|
|
112
|
+
* @param createTx transaction generator function
|
|
113
|
+
* @private
|
|
114
|
+
*/
|
|
115
|
+
private _saveHeaders;
|
|
116
|
+
/**
|
|
117
|
+
* @inheritDoc
|
|
118
|
+
*/
|
|
119
|
+
getTipData(): Promise<{
|
|
120
|
+
commitHash: string;
|
|
121
|
+
blockhash: string;
|
|
122
|
+
chainWork: Buffer;
|
|
123
|
+
blockheight: number;
|
|
124
|
+
} | null>;
|
|
125
|
+
/**
|
|
126
|
+
* @inheritDoc
|
|
127
|
+
*/
|
|
128
|
+
retrieveLogAndBlockheight(blockData: {
|
|
129
|
+
blockhash: string;
|
|
130
|
+
}, requiredBlockheight?: number): Promise<{
|
|
131
|
+
header: SolanaBtcStoredHeader;
|
|
132
|
+
height: number;
|
|
133
|
+
} | null>;
|
|
134
|
+
/**
|
|
135
|
+
* @inheritDoc
|
|
136
|
+
*/
|
|
137
|
+
retrieveLogByCommitHash(commitmentHashStr: string, blockData: {
|
|
138
|
+
blockhash: string;
|
|
139
|
+
}): Promise<SolanaBtcStoredHeader | null>;
|
|
140
|
+
/**
|
|
141
|
+
* @inheritDoc
|
|
142
|
+
*/
|
|
143
|
+
retrieveLatestKnownBlockLog(): Promise<{
|
|
144
|
+
resultStoredHeader: SolanaBtcStoredHeader;
|
|
145
|
+
resultBitcoinHeader: B;
|
|
146
|
+
} | null>;
|
|
147
|
+
/**
|
|
148
|
+
* @inheritDoc
|
|
149
|
+
*/
|
|
150
|
+
saveInitialHeader(signer: string, header: B, epochStart: number, pastBlocksTimestamps: number[], feeRate?: string): Promise<{
|
|
151
|
+
tx: Transaction;
|
|
152
|
+
signers: Signer[];
|
|
153
|
+
}>;
|
|
154
|
+
/**
|
|
155
|
+
* @inheritDoc
|
|
156
|
+
*/
|
|
157
|
+
saveMainHeaders(signer: string, mainHeaders: BtcBlock[], storedHeader: SolanaBtcStoredHeader, feeRate?: string): Promise<{
|
|
158
|
+
forkId: number;
|
|
159
|
+
lastStoredHeader: SolanaBtcStoredHeader;
|
|
160
|
+
tx: {
|
|
161
|
+
tx: Transaction;
|
|
162
|
+
signers: never[];
|
|
163
|
+
};
|
|
164
|
+
computedCommitedHeaders: SolanaBtcStoredHeader[];
|
|
165
|
+
}>;
|
|
166
|
+
/**
|
|
167
|
+
* @inheritDoc
|
|
168
|
+
*/
|
|
169
|
+
saveNewForkHeaders(signer: string, forkHeaders: BtcBlock[], storedHeader: SolanaBtcStoredHeader, tipWork: Buffer, feeRate?: string): Promise<{
|
|
170
|
+
forkId: number;
|
|
171
|
+
lastStoredHeader: SolanaBtcStoredHeader;
|
|
172
|
+
tx: {
|
|
173
|
+
tx: Transaction;
|
|
174
|
+
signers: never[];
|
|
175
|
+
};
|
|
176
|
+
computedCommitedHeaders: SolanaBtcStoredHeader[];
|
|
177
|
+
}>;
|
|
178
|
+
/**
|
|
179
|
+
* @inheritDoc
|
|
180
|
+
*/
|
|
181
|
+
saveForkHeaders(signer: string, forkHeaders: BtcBlock[], storedHeader: SolanaBtcStoredHeader, forkId: number, tipWork: Buffer, feeRate?: string): Promise<{
|
|
182
|
+
forkId: number;
|
|
183
|
+
lastStoredHeader: SolanaBtcStoredHeader;
|
|
184
|
+
tx: {
|
|
185
|
+
tx: Transaction;
|
|
186
|
+
signers: never[];
|
|
187
|
+
};
|
|
188
|
+
computedCommitedHeaders: SolanaBtcStoredHeader[];
|
|
189
|
+
}>;
|
|
190
|
+
/**
|
|
191
|
+
* @inheritDoc
|
|
192
|
+
*/
|
|
193
|
+
saveShortForkHeaders(signer: string, forkHeaders: BtcBlock[], storedHeader: SolanaBtcStoredHeader, tipWork: Buffer, feeRate?: string): Promise<{
|
|
194
|
+
forkId: number;
|
|
195
|
+
lastStoredHeader: SolanaBtcStoredHeader;
|
|
196
|
+
tx: {
|
|
197
|
+
tx: Transaction;
|
|
198
|
+
signers: never[];
|
|
199
|
+
};
|
|
200
|
+
computedCommitedHeaders: SolanaBtcStoredHeader[];
|
|
201
|
+
}>;
|
|
202
|
+
/**
|
|
203
|
+
* @inheritDoc
|
|
204
|
+
*/
|
|
205
|
+
sweepForkData(signer: SolanaSigner, lastSweepId?: number): Promise<number | null>;
|
|
206
|
+
/**
|
|
207
|
+
* @inheritDoc
|
|
208
|
+
*/
|
|
209
|
+
estimateSynchronizeFee(requiredBlockheight: number, feeRate?: string): Promise<bigint>;
|
|
210
|
+
/**
|
|
211
|
+
* @inheritDoc
|
|
212
|
+
*/
|
|
213
|
+
getFeePerBlock(feeRate?: string): Promise<bigint>;
|
|
214
|
+
/**
|
|
215
|
+
* @inheritDoc
|
|
216
|
+
*/
|
|
217
|
+
getMainFeeRate(signer: string | null): Promise<string>;
|
|
218
|
+
/**
|
|
219
|
+
* @inheritDoc
|
|
220
|
+
*/
|
|
221
|
+
getForkFeeRate(signer: string, forkId: number): Promise<string>;
|
|
222
|
+
}
|