@atomiqlabs/chain-solana 12.0.14 → 12.0.15
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/dist/index.d.ts +29 -29
- package/dist/index.js +45 -45
- package/dist/solana/SolanaChainType.d.ts +11 -11
- package/dist/solana/SolanaChainType.js +2 -2
- package/dist/solana/SolanaChains.d.ts +20 -20
- package/dist/solana/SolanaChains.js +25 -25
- package/dist/solana/SolanaInitializer.d.ts +18 -18
- package/dist/solana/SolanaInitializer.js +63 -63
- package/dist/solana/btcrelay/SolanaBtcRelay.d.ts +228 -228
- package/dist/solana/btcrelay/SolanaBtcRelay.js +441 -441
- package/dist/solana/btcrelay/headers/SolanaBtcHeader.d.ts +29 -29
- package/dist/solana/btcrelay/headers/SolanaBtcHeader.js +34 -34
- package/dist/solana/btcrelay/headers/SolanaBtcStoredHeader.d.ts +46 -46
- package/dist/solana/btcrelay/headers/SolanaBtcStoredHeader.js +78 -78
- package/dist/solana/btcrelay/program/programIdl.json +671 -671
- package/dist/solana/chain/SolanaAction.d.ts +26 -26
- package/dist/solana/chain/SolanaAction.js +86 -86
- package/dist/solana/chain/SolanaChainInterface.d.ts +65 -65
- package/dist/solana/chain/SolanaChainInterface.js +125 -125
- 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 +28 -28
- package/dist/solana/chain/modules/SolanaBlocks.js +72 -72
- 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 +121 -121
- package/dist/solana/chain/modules/SolanaFees.js +379 -379
- package/dist/solana/chain/modules/SolanaSignatures.d.ts +23 -23
- package/dist/solana/chain/modules/SolanaSignatures.js +39 -39
- package/dist/solana/chain/modules/SolanaSlots.d.ts +31 -31
- package/dist/solana/chain/modules/SolanaSlots.js +68 -68
- package/dist/solana/chain/modules/SolanaTokens.d.ts +136 -136
- package/dist/solana/chain/modules/SolanaTokens.js +248 -248
- package/dist/solana/chain/modules/SolanaTransactions.d.ts +124 -124
- package/dist/solana/chain/modules/SolanaTransactions.js +323 -323
- package/dist/solana/events/SolanaChainEvents.d.ts +88 -88
- package/dist/solana/events/SolanaChainEvents.js +256 -256
- package/dist/solana/events/SolanaChainEventsBrowser.d.ts +75 -75
- package/dist/solana/events/SolanaChainEventsBrowser.js +172 -172
- package/dist/solana/program/SolanaProgramBase.d.ts +40 -40
- package/dist/solana/program/SolanaProgramBase.js +43 -43
- 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 +114 -114
- package/dist/solana/swaps/SolanaSwapData.d.ts +71 -71
- package/dist/solana/swaps/SolanaSwapData.js +292 -292
- package/dist/solana/swaps/SolanaSwapModule.d.ts +10 -10
- package/dist/solana/swaps/SolanaSwapModule.js +11 -11
- package/dist/solana/swaps/SolanaSwapProgram.d.ts +224 -224
- package/dist/solana/swaps/SolanaSwapProgram.js +570 -570
- package/dist/solana/swaps/SwapTypeEnum.d.ts +11 -11
- package/dist/solana/swaps/SwapTypeEnum.js +42 -42
- package/dist/solana/swaps/modules/SolanaDataAccount.d.ts +94 -94
- package/dist/solana/swaps/modules/SolanaDataAccount.js +231 -231
- package/dist/solana/swaps/modules/SolanaLpVault.d.ts +71 -71
- package/dist/solana/swaps/modules/SolanaLpVault.js +173 -173
- package/dist/solana/swaps/modules/SwapClaim.d.ts +129 -129
- package/dist/solana/swaps/modules/SwapClaim.js +291 -291
- package/dist/solana/swaps/modules/SwapInit.d.ts +217 -217
- package/dist/solana/swaps/modules/SwapInit.js +519 -519
- package/dist/solana/swaps/modules/SwapRefund.d.ts +82 -82
- package/dist/solana/swaps/modules/SwapRefund.js +262 -262
- 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/wallet/SolanaKeypairWallet.d.ts +9 -9
- package/dist/solana/wallet/SolanaKeypairWallet.js +33 -33
- package/dist/solana/wallet/SolanaSigner.d.ts +11 -11
- package/dist/solana/wallet/SolanaSigner.js +17 -17
- package/dist/utils/Utils.d.ts +53 -53
- package/dist/utils/Utils.js +170 -170
- package/package.json +41 -41
- package/src/index.ts +36 -36
- package/src/solana/SolanaChainType.ts +27 -27
- package/src/solana/SolanaChains.ts +23 -23
- package/src/solana/SolanaInitializer.ts +102 -102
- package/src/solana/btcrelay/SolanaBtcRelay.ts +589 -589
- package/src/solana/btcrelay/headers/SolanaBtcHeader.ts +57 -57
- package/src/solana/btcrelay/headers/SolanaBtcStoredHeader.ts +102 -102
- package/src/solana/btcrelay/program/programIdl.json +670 -670
- package/src/solana/chain/SolanaAction.ts +108 -108
- package/src/solana/chain/SolanaChainInterface.ts +192 -192
- package/src/solana/chain/SolanaModule.ts +20 -20
- package/src/solana/chain/modules/SolanaAddresses.ts +20 -20
- package/src/solana/chain/modules/SolanaBlocks.ts +78 -78
- package/src/solana/chain/modules/SolanaEvents.ts +270 -270
- package/src/solana/chain/modules/SolanaFees.ts +450 -450
- package/src/solana/chain/modules/SolanaSignatures.ts +39 -39
- package/src/solana/chain/modules/SolanaSlots.ts +82 -82
- package/src/solana/chain/modules/SolanaTokens.ts +307 -307
- package/src/solana/chain/modules/SolanaTransactions.ts +365 -365
- package/src/solana/events/SolanaChainEvents.ts +299 -299
- package/src/solana/events/SolanaChainEventsBrowser.ts +209 -209
- package/src/solana/program/SolanaProgramBase.ts +79 -79
- package/src/solana/program/SolanaProgramModule.ts +15 -15
- package/src/solana/program/modules/SolanaProgramEvents.ts +155 -155
- package/src/solana/swaps/SolanaSwapData.ts +430 -430
- package/src/solana/swaps/SolanaSwapModule.ts +16 -16
- package/src/solana/swaps/SolanaSwapProgram.ts +854 -854
- package/src/solana/swaps/SwapTypeEnum.ts +29 -29
- package/src/solana/swaps/modules/SolanaDataAccount.ts +307 -307
- package/src/solana/swaps/modules/SolanaLpVault.ts +215 -215
- package/src/solana/swaps/modules/SwapClaim.ts +389 -389
- package/src/solana/swaps/modules/SwapInit.ts +663 -663
- package/src/solana/swaps/modules/SwapRefund.ts +323 -323
- package/src/solana/swaps/programIdl.json +944 -944
- package/src/solana/swaps/programTypes.ts +1885 -1885
- package/src/solana/wallet/SolanaKeypairWallet.ts +36 -36
- package/src/solana/wallet/SolanaSigner.ts +24 -24
- package/src/utils/Utils.ts +180 -180
|
@@ -1,228 +1,228 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
|
-
import { PublicKey, Signer, Transaction } from "@solana/web3.js";
|
|
3
|
-
import { SolanaBtcStoredHeader } from "./headers/SolanaBtcStoredHeader";
|
|
4
|
-
import { BitcoinRpc, BtcBlock, BtcRelay } from "@atomiqlabs/base";
|
|
5
|
-
import { SolanaProgramBase } from "../program/SolanaProgramBase";
|
|
6
|
-
import { SolanaAction } from "../chain/SolanaAction";
|
|
7
|
-
import { Buffer } from "buffer";
|
|
8
|
-
import { SolanaSigner } from "../wallet/SolanaSigner";
|
|
9
|
-
import { SolanaChainInterface } from "../chain/SolanaChainInterface";
|
|
10
|
-
export declare class SolanaBtcRelay<B extends BtcBlock> extends SolanaProgramBase<any> implements BtcRelay<SolanaBtcStoredHeader, {
|
|
11
|
-
tx: Transaction;
|
|
12
|
-
signers: Signer[];
|
|
13
|
-
}, B, SolanaSigner> {
|
|
14
|
-
/**
|
|
15
|
-
* Creates initialization action for initializing the btc relay
|
|
16
|
-
*
|
|
17
|
-
* @param signer
|
|
18
|
-
* @param header
|
|
19
|
-
* @param epochStart
|
|
20
|
-
* @param pastBlocksTimestamps
|
|
21
|
-
* @constructor
|
|
22
|
-
* @private
|
|
23
|
-
*/
|
|
24
|
-
private Initialize;
|
|
25
|
-
/**
|
|
26
|
-
* Creates verify action to be used with the swap program, specifies the action to be firstIxBeforeComputeBudget,
|
|
27
|
-
* such that the verify instruction will always be the 0th in the transaction, this is required because
|
|
28
|
-
* swap program expects the verify instruction to be at the 0th position
|
|
29
|
-
*
|
|
30
|
-
* @param signer
|
|
31
|
-
* @param reversedTxId
|
|
32
|
-
* @param confirmations
|
|
33
|
-
* @param position
|
|
34
|
-
* @param reversedMerkleProof
|
|
35
|
-
* @param committedHeader
|
|
36
|
-
*/
|
|
37
|
-
Verify(signer: PublicKey, reversedTxId: Buffer, confirmations: number, position: number, reversedMerkleProof: Buffer[], committedHeader: SolanaBtcStoredHeader): Promise<SolanaAction>;
|
|
38
|
-
CloseForkAccount(signer: PublicKey, forkId: number): Promise<SolanaAction>;
|
|
39
|
-
BtcRelayMainState: PublicKey;
|
|
40
|
-
BtcRelayHeader: (hash: Buffer) => PublicKey;
|
|
41
|
-
BtcRelayFork: (forkId: number, pubkey: PublicKey) => PublicKey;
|
|
42
|
-
bitcoinRpc: BitcoinRpc<B>;
|
|
43
|
-
readonly maxHeadersPerTx: number;
|
|
44
|
-
readonly maxForkHeadersPerTx: number;
|
|
45
|
-
readonly maxShortForkHeadersPerTx: number;
|
|
46
|
-
constructor(chainInterface: SolanaChainInterface, bitcoinRpc: BitcoinRpc<B>, programAddress?: string);
|
|
47
|
-
/**
|
|
48
|
-
* Gets set of block commitments representing current main chain from the mainState
|
|
49
|
-
*
|
|
50
|
-
* @param mainState
|
|
51
|
-
* @private
|
|
52
|
-
*/
|
|
53
|
-
private getBlockCommitmentsSet;
|
|
54
|
-
/**
|
|
55
|
-
* Computes subsequent commited headers as they will appear on the blockchain when transactions
|
|
56
|
-
* are submitted & confirmed
|
|
57
|
-
*
|
|
58
|
-
* @param initialStoredHeader
|
|
59
|
-
* @param syncedHeaders
|
|
60
|
-
* @private
|
|
61
|
-
*/
|
|
62
|
-
private computeCommitedHeaders;
|
|
63
|
-
/**
|
|
64
|
-
* A common logic for submitting blockheaders in a transaction
|
|
65
|
-
*
|
|
66
|
-
* @param signer
|
|
67
|
-
* @param headers headers to sync to the btc relay
|
|
68
|
-
* @param storedHeader current latest stored block header for a given fork
|
|
69
|
-
* @param tipWork work of the current tip in a given fork
|
|
70
|
-
* @param forkId forkId to submit to, forkId=0 means main chain
|
|
71
|
-
* @param feeRate feeRate for the transaction
|
|
72
|
-
* @param createTx transaction generator function
|
|
73
|
-
* @private
|
|
74
|
-
*/
|
|
75
|
-
private _saveHeaders;
|
|
76
|
-
/**
|
|
77
|
-
* Returns data about current main chain tip stored in the btc relay
|
|
78
|
-
*/
|
|
79
|
-
getTipData(): Promise<{
|
|
80
|
-
commitHash: string;
|
|
81
|
-
blockhash: string;
|
|
82
|
-
chainWork: Buffer;
|
|
83
|
-
blockheight: number;
|
|
84
|
-
}>;
|
|
85
|
-
/**
|
|
86
|
-
* Retrieves blockheader with a specific blockhash, returns null if requiredBlockheight is provided and
|
|
87
|
-
* btc relay contract is not synced up to the desired blockheight
|
|
88
|
-
*
|
|
89
|
-
* @param blockData
|
|
90
|
-
* @param requiredBlockheight
|
|
91
|
-
*/
|
|
92
|
-
retrieveLogAndBlockheight(blockData: {
|
|
93
|
-
blockhash: string;
|
|
94
|
-
}, requiredBlockheight?: number): Promise<{
|
|
95
|
-
header: SolanaBtcStoredHeader;
|
|
96
|
-
height: number;
|
|
97
|
-
} | null>;
|
|
98
|
-
/**
|
|
99
|
-
* Retrieves blockheader data by blockheader's commit hash,
|
|
100
|
-
*
|
|
101
|
-
* @param commitmentHashStr
|
|
102
|
-
* @param blockData
|
|
103
|
-
*/
|
|
104
|
-
retrieveLogByCommitHash(commitmentHashStr: string, blockData: {
|
|
105
|
-
blockhash: string;
|
|
106
|
-
}): Promise<SolanaBtcStoredHeader>;
|
|
107
|
-
/**
|
|
108
|
-
* Retrieves latest known stored blockheader & blockheader from bitcoin RPC that is in the main chain
|
|
109
|
-
*/
|
|
110
|
-
retrieveLatestKnownBlockLog(): Promise<{
|
|
111
|
-
resultStoredHeader: SolanaBtcStoredHeader;
|
|
112
|
-
resultBitcoinHeader: B;
|
|
113
|
-
}>;
|
|
114
|
-
/**
|
|
115
|
-
* Saves initial block header when the btc relay is in uninitialized state
|
|
116
|
-
*
|
|
117
|
-
* @param signer
|
|
118
|
-
* @param header a bitcoin blockheader to submit
|
|
119
|
-
* @param epochStart timestamp of the start of the epoch (block timestamp at blockheight-(blockheight%2016))
|
|
120
|
-
* @param pastBlocksTimestamps timestamp of the past 10 blocks
|
|
121
|
-
* @param feeRate fee rate to use for the transaction
|
|
122
|
-
*/
|
|
123
|
-
saveInitialHeader(signer: string, header: B, epochStart: number, pastBlocksTimestamps: number[], feeRate?: string): Promise<{
|
|
124
|
-
tx: Transaction;
|
|
125
|
-
signers: Signer[];
|
|
126
|
-
}>;
|
|
127
|
-
/**
|
|
128
|
-
* Saves blockheaders as a bitcoin main chain to the btc relay
|
|
129
|
-
*
|
|
130
|
-
* @param signer
|
|
131
|
-
* @param mainHeaders
|
|
132
|
-
* @param storedHeader
|
|
133
|
-
* @param feeRate
|
|
134
|
-
*/
|
|
135
|
-
saveMainHeaders(signer: string, mainHeaders: BtcBlock[], storedHeader: SolanaBtcStoredHeader, feeRate?: string): Promise<{
|
|
136
|
-
forkId: number;
|
|
137
|
-
lastStoredHeader: SolanaBtcStoredHeader;
|
|
138
|
-
tx: {
|
|
139
|
-
tx: Transaction;
|
|
140
|
-
signers: any[];
|
|
141
|
-
};
|
|
142
|
-
computedCommitedHeaders: SolanaBtcStoredHeader[];
|
|
143
|
-
}>;
|
|
144
|
-
/**
|
|
145
|
-
* Creates a new long fork and submits the headers to it
|
|
146
|
-
*
|
|
147
|
-
* @param signer
|
|
148
|
-
* @param forkHeaders
|
|
149
|
-
* @param storedHeader
|
|
150
|
-
* @param tipWork
|
|
151
|
-
* @param feeRate
|
|
152
|
-
*/
|
|
153
|
-
saveNewForkHeaders(signer: string, forkHeaders: BtcBlock[], storedHeader: SolanaBtcStoredHeader, tipWork: Buffer, feeRate?: string): Promise<{
|
|
154
|
-
forkId: number;
|
|
155
|
-
lastStoredHeader: SolanaBtcStoredHeader;
|
|
156
|
-
tx: {
|
|
157
|
-
tx: Transaction;
|
|
158
|
-
signers: any[];
|
|
159
|
-
};
|
|
160
|
-
computedCommitedHeaders: SolanaBtcStoredHeader[];
|
|
161
|
-
}>;
|
|
162
|
-
/**
|
|
163
|
-
* Continues submitting blockheaders to a given fork
|
|
164
|
-
*
|
|
165
|
-
* @param signer
|
|
166
|
-
* @param forkHeaders
|
|
167
|
-
* @param storedHeader
|
|
168
|
-
* @param forkId
|
|
169
|
-
* @param tipWork
|
|
170
|
-
* @param feeRate
|
|
171
|
-
*/
|
|
172
|
-
saveForkHeaders(signer: string, forkHeaders: BtcBlock[], storedHeader: SolanaBtcStoredHeader, forkId: number, tipWork: Buffer, feeRate?: string): Promise<{
|
|
173
|
-
forkId: number;
|
|
174
|
-
lastStoredHeader: SolanaBtcStoredHeader;
|
|
175
|
-
tx: {
|
|
176
|
-
tx: Transaction;
|
|
177
|
-
signers: any[];
|
|
178
|
-
};
|
|
179
|
-
computedCommitedHeaders: SolanaBtcStoredHeader[];
|
|
180
|
-
}>;
|
|
181
|
-
/**
|
|
182
|
-
* Submits short fork with given blockheaders
|
|
183
|
-
*
|
|
184
|
-
* @param signer
|
|
185
|
-
* @param forkHeaders
|
|
186
|
-
* @param storedHeader
|
|
187
|
-
* @param tipWork
|
|
188
|
-
* @param feeRate
|
|
189
|
-
*/
|
|
190
|
-
saveShortForkHeaders(signer: string, forkHeaders: BtcBlock[], storedHeader: SolanaBtcStoredHeader, tipWork: Buffer, feeRate?: string): Promise<{
|
|
191
|
-
forkId: number;
|
|
192
|
-
lastStoredHeader: SolanaBtcStoredHeader;
|
|
193
|
-
tx: {
|
|
194
|
-
tx: Transaction;
|
|
195
|
-
signers: any[];
|
|
196
|
-
};
|
|
197
|
-
computedCommitedHeaders: SolanaBtcStoredHeader[];
|
|
198
|
-
}>;
|
|
199
|
-
/**
|
|
200
|
-
* Sweeps fork data PDAs back to self
|
|
201
|
-
*
|
|
202
|
-
* @param signer
|
|
203
|
-
* @param lastSweepId lastCheckedId returned from the previous sweepForkData() call
|
|
204
|
-
* @returns {number} lastCheckedId that should be passed to the next call of sweepForkData()
|
|
205
|
-
*/
|
|
206
|
-
sweepForkData(signer: SolanaSigner, lastSweepId?: number): Promise<number | null>;
|
|
207
|
-
/**
|
|
208
|
-
* Estimate required synchronization fee (worst case) to synchronize btc relay to the required blockheight
|
|
209
|
-
*
|
|
210
|
-
* @param requiredBlockheight
|
|
211
|
-
* @param feeRate
|
|
212
|
-
*/
|
|
213
|
-
estimateSynchronizeFee(requiredBlockheight: number, feeRate?: string): Promise<bigint>;
|
|
214
|
-
/**
|
|
215
|
-
* Returns fee required (in SOL) to synchronize a single block to btc relay
|
|
216
|
-
*
|
|
217
|
-
* @param feeRate
|
|
218
|
-
*/
|
|
219
|
-
getFeePerBlock(feeRate?: string): Promise<bigint>;
|
|
220
|
-
/**
|
|
221
|
-
* Gets fee rate required for submitting blockheaders to the main chain
|
|
222
|
-
*/
|
|
223
|
-
getMainFeeRate(signer: string | null): Promise<string>;
|
|
224
|
-
/**
|
|
225
|
-
* Gets fee rate required for submitting blockheaders to the specific fork
|
|
226
|
-
*/
|
|
227
|
-
getForkFeeRate(signer: string, forkId: number): Promise<string>;
|
|
228
|
-
}
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import { PublicKey, Signer, Transaction } from "@solana/web3.js";
|
|
3
|
+
import { SolanaBtcStoredHeader } from "./headers/SolanaBtcStoredHeader";
|
|
4
|
+
import { BitcoinRpc, BtcBlock, BtcRelay } from "@atomiqlabs/base";
|
|
5
|
+
import { SolanaProgramBase } from "../program/SolanaProgramBase";
|
|
6
|
+
import { SolanaAction } from "../chain/SolanaAction";
|
|
7
|
+
import { Buffer } from "buffer";
|
|
8
|
+
import { SolanaSigner } from "../wallet/SolanaSigner";
|
|
9
|
+
import { SolanaChainInterface } from "../chain/SolanaChainInterface";
|
|
10
|
+
export declare class SolanaBtcRelay<B extends BtcBlock> extends SolanaProgramBase<any> implements BtcRelay<SolanaBtcStoredHeader, {
|
|
11
|
+
tx: Transaction;
|
|
12
|
+
signers: Signer[];
|
|
13
|
+
}, B, SolanaSigner> {
|
|
14
|
+
/**
|
|
15
|
+
* Creates initialization action for initializing the btc relay
|
|
16
|
+
*
|
|
17
|
+
* @param signer
|
|
18
|
+
* @param header
|
|
19
|
+
* @param epochStart
|
|
20
|
+
* @param pastBlocksTimestamps
|
|
21
|
+
* @constructor
|
|
22
|
+
* @private
|
|
23
|
+
*/
|
|
24
|
+
private Initialize;
|
|
25
|
+
/**
|
|
26
|
+
* Creates verify action to be used with the swap program, specifies the action to be firstIxBeforeComputeBudget,
|
|
27
|
+
* such that the verify instruction will always be the 0th in the transaction, this is required because
|
|
28
|
+
* swap program expects the verify instruction to be at the 0th position
|
|
29
|
+
*
|
|
30
|
+
* @param signer
|
|
31
|
+
* @param reversedTxId
|
|
32
|
+
* @param confirmations
|
|
33
|
+
* @param position
|
|
34
|
+
* @param reversedMerkleProof
|
|
35
|
+
* @param committedHeader
|
|
36
|
+
*/
|
|
37
|
+
Verify(signer: PublicKey, reversedTxId: Buffer, confirmations: number, position: number, reversedMerkleProof: Buffer[], committedHeader: SolanaBtcStoredHeader): Promise<SolanaAction>;
|
|
38
|
+
CloseForkAccount(signer: PublicKey, forkId: number): Promise<SolanaAction>;
|
|
39
|
+
BtcRelayMainState: PublicKey;
|
|
40
|
+
BtcRelayHeader: (hash: Buffer) => PublicKey;
|
|
41
|
+
BtcRelayFork: (forkId: number, pubkey: PublicKey) => PublicKey;
|
|
42
|
+
bitcoinRpc: BitcoinRpc<B>;
|
|
43
|
+
readonly maxHeadersPerTx: number;
|
|
44
|
+
readonly maxForkHeadersPerTx: number;
|
|
45
|
+
readonly maxShortForkHeadersPerTx: number;
|
|
46
|
+
constructor(chainInterface: SolanaChainInterface, bitcoinRpc: BitcoinRpc<B>, programAddress?: string);
|
|
47
|
+
/**
|
|
48
|
+
* Gets set of block commitments representing current main chain from the mainState
|
|
49
|
+
*
|
|
50
|
+
* @param mainState
|
|
51
|
+
* @private
|
|
52
|
+
*/
|
|
53
|
+
private getBlockCommitmentsSet;
|
|
54
|
+
/**
|
|
55
|
+
* Computes subsequent commited headers as they will appear on the blockchain when transactions
|
|
56
|
+
* are submitted & confirmed
|
|
57
|
+
*
|
|
58
|
+
* @param initialStoredHeader
|
|
59
|
+
* @param syncedHeaders
|
|
60
|
+
* @private
|
|
61
|
+
*/
|
|
62
|
+
private computeCommitedHeaders;
|
|
63
|
+
/**
|
|
64
|
+
* A common logic for submitting blockheaders in a transaction
|
|
65
|
+
*
|
|
66
|
+
* @param signer
|
|
67
|
+
* @param headers headers to sync to the btc relay
|
|
68
|
+
* @param storedHeader current latest stored block header for a given fork
|
|
69
|
+
* @param tipWork work of the current tip in a given fork
|
|
70
|
+
* @param forkId forkId to submit to, forkId=0 means main chain
|
|
71
|
+
* @param feeRate feeRate for the transaction
|
|
72
|
+
* @param createTx transaction generator function
|
|
73
|
+
* @private
|
|
74
|
+
*/
|
|
75
|
+
private _saveHeaders;
|
|
76
|
+
/**
|
|
77
|
+
* Returns data about current main chain tip stored in the btc relay
|
|
78
|
+
*/
|
|
79
|
+
getTipData(): Promise<{
|
|
80
|
+
commitHash: string;
|
|
81
|
+
blockhash: string;
|
|
82
|
+
chainWork: Buffer;
|
|
83
|
+
blockheight: number;
|
|
84
|
+
}>;
|
|
85
|
+
/**
|
|
86
|
+
* Retrieves blockheader with a specific blockhash, returns null if requiredBlockheight is provided and
|
|
87
|
+
* btc relay contract is not synced up to the desired blockheight
|
|
88
|
+
*
|
|
89
|
+
* @param blockData
|
|
90
|
+
* @param requiredBlockheight
|
|
91
|
+
*/
|
|
92
|
+
retrieveLogAndBlockheight(blockData: {
|
|
93
|
+
blockhash: string;
|
|
94
|
+
}, requiredBlockheight?: number): Promise<{
|
|
95
|
+
header: SolanaBtcStoredHeader;
|
|
96
|
+
height: number;
|
|
97
|
+
} | null>;
|
|
98
|
+
/**
|
|
99
|
+
* Retrieves blockheader data by blockheader's commit hash,
|
|
100
|
+
*
|
|
101
|
+
* @param commitmentHashStr
|
|
102
|
+
* @param blockData
|
|
103
|
+
*/
|
|
104
|
+
retrieveLogByCommitHash(commitmentHashStr: string, blockData: {
|
|
105
|
+
blockhash: string;
|
|
106
|
+
}): Promise<SolanaBtcStoredHeader>;
|
|
107
|
+
/**
|
|
108
|
+
* Retrieves latest known stored blockheader & blockheader from bitcoin RPC that is in the main chain
|
|
109
|
+
*/
|
|
110
|
+
retrieveLatestKnownBlockLog(): Promise<{
|
|
111
|
+
resultStoredHeader: SolanaBtcStoredHeader;
|
|
112
|
+
resultBitcoinHeader: B;
|
|
113
|
+
}>;
|
|
114
|
+
/**
|
|
115
|
+
* Saves initial block header when the btc relay is in uninitialized state
|
|
116
|
+
*
|
|
117
|
+
* @param signer
|
|
118
|
+
* @param header a bitcoin blockheader to submit
|
|
119
|
+
* @param epochStart timestamp of the start of the epoch (block timestamp at blockheight-(blockheight%2016))
|
|
120
|
+
* @param pastBlocksTimestamps timestamp of the past 10 blocks
|
|
121
|
+
* @param feeRate fee rate to use for the transaction
|
|
122
|
+
*/
|
|
123
|
+
saveInitialHeader(signer: string, header: B, epochStart: number, pastBlocksTimestamps: number[], feeRate?: string): Promise<{
|
|
124
|
+
tx: Transaction;
|
|
125
|
+
signers: Signer[];
|
|
126
|
+
}>;
|
|
127
|
+
/**
|
|
128
|
+
* Saves blockheaders as a bitcoin main chain to the btc relay
|
|
129
|
+
*
|
|
130
|
+
* @param signer
|
|
131
|
+
* @param mainHeaders
|
|
132
|
+
* @param storedHeader
|
|
133
|
+
* @param feeRate
|
|
134
|
+
*/
|
|
135
|
+
saveMainHeaders(signer: string, mainHeaders: BtcBlock[], storedHeader: SolanaBtcStoredHeader, feeRate?: string): Promise<{
|
|
136
|
+
forkId: number;
|
|
137
|
+
lastStoredHeader: SolanaBtcStoredHeader;
|
|
138
|
+
tx: {
|
|
139
|
+
tx: Transaction;
|
|
140
|
+
signers: any[];
|
|
141
|
+
};
|
|
142
|
+
computedCommitedHeaders: SolanaBtcStoredHeader[];
|
|
143
|
+
}>;
|
|
144
|
+
/**
|
|
145
|
+
* Creates a new long fork and submits the headers to it
|
|
146
|
+
*
|
|
147
|
+
* @param signer
|
|
148
|
+
* @param forkHeaders
|
|
149
|
+
* @param storedHeader
|
|
150
|
+
* @param tipWork
|
|
151
|
+
* @param feeRate
|
|
152
|
+
*/
|
|
153
|
+
saveNewForkHeaders(signer: string, forkHeaders: BtcBlock[], storedHeader: SolanaBtcStoredHeader, tipWork: Buffer, feeRate?: string): Promise<{
|
|
154
|
+
forkId: number;
|
|
155
|
+
lastStoredHeader: SolanaBtcStoredHeader;
|
|
156
|
+
tx: {
|
|
157
|
+
tx: Transaction;
|
|
158
|
+
signers: any[];
|
|
159
|
+
};
|
|
160
|
+
computedCommitedHeaders: SolanaBtcStoredHeader[];
|
|
161
|
+
}>;
|
|
162
|
+
/**
|
|
163
|
+
* Continues submitting blockheaders to a given fork
|
|
164
|
+
*
|
|
165
|
+
* @param signer
|
|
166
|
+
* @param forkHeaders
|
|
167
|
+
* @param storedHeader
|
|
168
|
+
* @param forkId
|
|
169
|
+
* @param tipWork
|
|
170
|
+
* @param feeRate
|
|
171
|
+
*/
|
|
172
|
+
saveForkHeaders(signer: string, forkHeaders: BtcBlock[], storedHeader: SolanaBtcStoredHeader, forkId: number, tipWork: Buffer, feeRate?: string): Promise<{
|
|
173
|
+
forkId: number;
|
|
174
|
+
lastStoredHeader: SolanaBtcStoredHeader;
|
|
175
|
+
tx: {
|
|
176
|
+
tx: Transaction;
|
|
177
|
+
signers: any[];
|
|
178
|
+
};
|
|
179
|
+
computedCommitedHeaders: SolanaBtcStoredHeader[];
|
|
180
|
+
}>;
|
|
181
|
+
/**
|
|
182
|
+
* Submits short fork with given blockheaders
|
|
183
|
+
*
|
|
184
|
+
* @param signer
|
|
185
|
+
* @param forkHeaders
|
|
186
|
+
* @param storedHeader
|
|
187
|
+
* @param tipWork
|
|
188
|
+
* @param feeRate
|
|
189
|
+
*/
|
|
190
|
+
saveShortForkHeaders(signer: string, forkHeaders: BtcBlock[], storedHeader: SolanaBtcStoredHeader, tipWork: Buffer, feeRate?: string): Promise<{
|
|
191
|
+
forkId: number;
|
|
192
|
+
lastStoredHeader: SolanaBtcStoredHeader;
|
|
193
|
+
tx: {
|
|
194
|
+
tx: Transaction;
|
|
195
|
+
signers: any[];
|
|
196
|
+
};
|
|
197
|
+
computedCommitedHeaders: SolanaBtcStoredHeader[];
|
|
198
|
+
}>;
|
|
199
|
+
/**
|
|
200
|
+
* Sweeps fork data PDAs back to self
|
|
201
|
+
*
|
|
202
|
+
* @param signer
|
|
203
|
+
* @param lastSweepId lastCheckedId returned from the previous sweepForkData() call
|
|
204
|
+
* @returns {number} lastCheckedId that should be passed to the next call of sweepForkData()
|
|
205
|
+
*/
|
|
206
|
+
sweepForkData(signer: SolanaSigner, lastSweepId?: number): Promise<number | null>;
|
|
207
|
+
/**
|
|
208
|
+
* Estimate required synchronization fee (worst case) to synchronize btc relay to the required blockheight
|
|
209
|
+
*
|
|
210
|
+
* @param requiredBlockheight
|
|
211
|
+
* @param feeRate
|
|
212
|
+
*/
|
|
213
|
+
estimateSynchronizeFee(requiredBlockheight: number, feeRate?: string): Promise<bigint>;
|
|
214
|
+
/**
|
|
215
|
+
* Returns fee required (in SOL) to synchronize a single block to btc relay
|
|
216
|
+
*
|
|
217
|
+
* @param feeRate
|
|
218
|
+
*/
|
|
219
|
+
getFeePerBlock(feeRate?: string): Promise<bigint>;
|
|
220
|
+
/**
|
|
221
|
+
* Gets fee rate required for submitting blockheaders to the main chain
|
|
222
|
+
*/
|
|
223
|
+
getMainFeeRate(signer: string | null): Promise<string>;
|
|
224
|
+
/**
|
|
225
|
+
* Gets fee rate required for submitting blockheaders to the specific fork
|
|
226
|
+
*/
|
|
227
|
+
getForkFeeRate(signer: string, forkId: number): Promise<string>;
|
|
228
|
+
}
|