@atomiqlabs/chain-evm 1.0.0-dev.22

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 (146) hide show
  1. package/LICENSE +201 -0
  2. package/dist/chains/citrea/CitreaChainType.d.ts +13 -0
  3. package/dist/chains/citrea/CitreaChainType.js +2 -0
  4. package/dist/chains/citrea/CitreaInitializer.d.ts +30 -0
  5. package/dist/chains/citrea/CitreaInitializer.js +120 -0
  6. package/dist/evm/btcrelay/BtcRelayAbi.d.ts +198 -0
  7. package/dist/evm/btcrelay/BtcRelayAbi.js +261 -0
  8. package/dist/evm/btcrelay/BtcRelayTypechain.d.ts +172 -0
  9. package/dist/evm/btcrelay/BtcRelayTypechain.js +2 -0
  10. package/dist/evm/btcrelay/EVMBtcRelay.d.ts +188 -0
  11. package/dist/evm/btcrelay/EVMBtcRelay.js +419 -0
  12. package/dist/evm/btcrelay/headers/EVMBtcHeader.d.ts +33 -0
  13. package/dist/evm/btcrelay/headers/EVMBtcHeader.js +84 -0
  14. package/dist/evm/btcrelay/headers/EVMBtcStoredHeader.d.ts +56 -0
  15. package/dist/evm/btcrelay/headers/EVMBtcStoredHeader.js +123 -0
  16. package/dist/evm/chain/EVMChainInterface.d.ts +51 -0
  17. package/dist/evm/chain/EVMChainInterface.js +90 -0
  18. package/dist/evm/chain/EVMModule.d.ts +9 -0
  19. package/dist/evm/chain/EVMModule.js +13 -0
  20. package/dist/evm/chain/modules/ERC20Abi.d.ts +168 -0
  21. package/dist/evm/chain/modules/ERC20Abi.js +225 -0
  22. package/dist/evm/chain/modules/EVMAddresses.d.ts +9 -0
  23. package/dist/evm/chain/modules/EVMAddresses.js +26 -0
  24. package/dist/evm/chain/modules/EVMBlocks.d.ts +20 -0
  25. package/dist/evm/chain/modules/EVMBlocks.js +64 -0
  26. package/dist/evm/chain/modules/EVMEvents.d.ts +36 -0
  27. package/dist/evm/chain/modules/EVMEvents.js +122 -0
  28. package/dist/evm/chain/modules/EVMFees.d.ts +35 -0
  29. package/dist/evm/chain/modules/EVMFees.js +73 -0
  30. package/dist/evm/chain/modules/EVMSignatures.d.ts +29 -0
  31. package/dist/evm/chain/modules/EVMSignatures.js +68 -0
  32. package/dist/evm/chain/modules/EVMTokens.d.ts +49 -0
  33. package/dist/evm/chain/modules/EVMTokens.js +105 -0
  34. package/dist/evm/chain/modules/EVMTransactions.d.ts +89 -0
  35. package/dist/evm/chain/modules/EVMTransactions.js +216 -0
  36. package/dist/evm/contract/EVMContractBase.d.ts +22 -0
  37. package/dist/evm/contract/EVMContractBase.js +34 -0
  38. package/dist/evm/contract/EVMContractModule.d.ts +8 -0
  39. package/dist/evm/contract/EVMContractModule.js +11 -0
  40. package/dist/evm/contract/modules/EVMContractEvents.d.ts +42 -0
  41. package/dist/evm/contract/modules/EVMContractEvents.js +75 -0
  42. package/dist/evm/events/EVMChainEvents.d.ts +22 -0
  43. package/dist/evm/events/EVMChainEvents.js +67 -0
  44. package/dist/evm/events/EVMChainEventsBrowser.d.ts +86 -0
  45. package/dist/evm/events/EVMChainEventsBrowser.js +294 -0
  46. package/dist/evm/spv_swap/EVMSpvVaultContract.d.ts +64 -0
  47. package/dist/evm/spv_swap/EVMSpvVaultContract.js +410 -0
  48. package/dist/evm/spv_swap/EVMSpvVaultData.d.ts +38 -0
  49. package/dist/evm/spv_swap/EVMSpvVaultData.js +159 -0
  50. package/dist/evm/spv_swap/EVMSpvWithdrawalData.d.ts +19 -0
  51. package/dist/evm/spv_swap/EVMSpvWithdrawalData.js +55 -0
  52. package/dist/evm/spv_swap/SpvVaultContractAbi.d.ts +91 -0
  53. package/dist/evm/spv_swap/SpvVaultContractAbi.js +849 -0
  54. package/dist/evm/spv_swap/SpvVaultContractTypechain.d.ts +450 -0
  55. package/dist/evm/spv_swap/SpvVaultContractTypechain.js +2 -0
  56. package/dist/evm/swaps/EVMSwapContract.d.ts +192 -0
  57. package/dist/evm/swaps/EVMSwapContract.js +373 -0
  58. package/dist/evm/swaps/EVMSwapData.d.ts +64 -0
  59. package/dist/evm/swaps/EVMSwapData.js +254 -0
  60. package/dist/evm/swaps/EVMSwapModule.d.ts +9 -0
  61. package/dist/evm/swaps/EVMSwapModule.js +11 -0
  62. package/dist/evm/swaps/EscrowManagerAbi.d.ts +120 -0
  63. package/dist/evm/swaps/EscrowManagerAbi.js +985 -0
  64. package/dist/evm/swaps/EscrowManagerTypechain.d.ts +475 -0
  65. package/dist/evm/swaps/EscrowManagerTypechain.js +2 -0
  66. package/dist/evm/swaps/handlers/IHandler.d.ts +13 -0
  67. package/dist/evm/swaps/handlers/IHandler.js +2 -0
  68. package/dist/evm/swaps/handlers/claim/ClaimHandlers.d.ts +10 -0
  69. package/dist/evm/swaps/handlers/claim/ClaimHandlers.js +13 -0
  70. package/dist/evm/swaps/handlers/claim/HashlockClaimHandler.d.ts +20 -0
  71. package/dist/evm/swaps/handlers/claim/HashlockClaimHandler.js +39 -0
  72. package/dist/evm/swaps/handlers/claim/btc/BitcoinNoncedOutputClaimHandler.d.ts +24 -0
  73. package/dist/evm/swaps/handlers/claim/btc/BitcoinNoncedOutputClaimHandler.js +59 -0
  74. package/dist/evm/swaps/handlers/claim/btc/BitcoinOutputClaimHandler.d.ts +25 -0
  75. package/dist/evm/swaps/handlers/claim/btc/BitcoinOutputClaimHandler.js +51 -0
  76. package/dist/evm/swaps/handlers/claim/btc/BitcoinTxIdClaimHandler.d.ts +21 -0
  77. package/dist/evm/swaps/handlers/claim/btc/BitcoinTxIdClaimHandler.js +28 -0
  78. package/dist/evm/swaps/handlers/claim/btc/IBitcoinClaimHandler.d.ts +48 -0
  79. package/dist/evm/swaps/handlers/claim/btc/IBitcoinClaimHandler.js +63 -0
  80. package/dist/evm/swaps/handlers/refund/TimelockRefundHandler.d.ts +17 -0
  81. package/dist/evm/swaps/handlers/refund/TimelockRefundHandler.js +28 -0
  82. package/dist/evm/swaps/modules/EVMLpVault.d.ts +69 -0
  83. package/dist/evm/swaps/modules/EVMLpVault.js +131 -0
  84. package/dist/evm/swaps/modules/EVMSwapClaim.d.ts +53 -0
  85. package/dist/evm/swaps/modules/EVMSwapClaim.js +101 -0
  86. package/dist/evm/swaps/modules/EVMSwapInit.d.ts +88 -0
  87. package/dist/evm/swaps/modules/EVMSwapInit.js +241 -0
  88. package/dist/evm/swaps/modules/EVMSwapRefund.d.ts +62 -0
  89. package/dist/evm/swaps/modules/EVMSwapRefund.js +132 -0
  90. package/dist/evm/typechain/common.d.ts +50 -0
  91. package/dist/evm/typechain/common.js +2 -0
  92. package/dist/evm/wallet/EVMSigner.d.ts +9 -0
  93. package/dist/evm/wallet/EVMSigner.js +16 -0
  94. package/dist/index.d.ts +37 -0
  95. package/dist/index.js +53 -0
  96. package/dist/utils/Utils.d.ts +15 -0
  97. package/dist/utils/Utils.js +71 -0
  98. package/package.json +37 -0
  99. package/src/chains/citrea/CitreaChainType.ts +28 -0
  100. package/src/chains/citrea/CitreaInitializer.ts +167 -0
  101. package/src/evm/btcrelay/BtcRelayAbi.ts +258 -0
  102. package/src/evm/btcrelay/BtcRelayTypechain.ts +371 -0
  103. package/src/evm/btcrelay/EVMBtcRelay.ts +517 -0
  104. package/src/evm/btcrelay/headers/EVMBtcHeader.ts +110 -0
  105. package/src/evm/btcrelay/headers/EVMBtcStoredHeader.ts +153 -0
  106. package/src/evm/chain/EVMChainInterface.ts +157 -0
  107. package/src/evm/chain/EVMModule.ts +21 -0
  108. package/src/evm/chain/modules/ERC20Abi.ts +222 -0
  109. package/src/evm/chain/modules/EVMAddresses.ts +24 -0
  110. package/src/evm/chain/modules/EVMBlocks.ts +75 -0
  111. package/src/evm/chain/modules/EVMEvents.ts +139 -0
  112. package/src/evm/chain/modules/EVMFees.ts +105 -0
  113. package/src/evm/chain/modules/EVMSignatures.ts +76 -0
  114. package/src/evm/chain/modules/EVMTokens.ts +115 -0
  115. package/src/evm/chain/modules/EVMTransactions.ts +246 -0
  116. package/src/evm/contract/EVMContractBase.ts +63 -0
  117. package/src/evm/contract/EVMContractModule.ts +16 -0
  118. package/src/evm/contract/modules/EVMContractEvents.ts +102 -0
  119. package/src/evm/events/EVMChainEvents.ts +81 -0
  120. package/src/evm/events/EVMChainEventsBrowser.ts +390 -0
  121. package/src/evm/spv_swap/EVMSpvVaultContract.ts +533 -0
  122. package/src/evm/spv_swap/EVMSpvVaultData.ts +201 -0
  123. package/src/evm/spv_swap/EVMSpvWithdrawalData.ts +70 -0
  124. package/src/evm/spv_swap/SpvVaultContractAbi.ts +846 -0
  125. package/src/evm/spv_swap/SpvVaultContractTypechain.ts +685 -0
  126. package/src/evm/swaps/EVMSwapContract.ts +590 -0
  127. package/src/evm/swaps/EVMSwapData.ts +367 -0
  128. package/src/evm/swaps/EVMSwapModule.ts +16 -0
  129. package/src/evm/swaps/EscrowManagerAbi.ts +982 -0
  130. package/src/evm/swaps/EscrowManagerTypechain.ts +723 -0
  131. package/src/evm/swaps/handlers/IHandler.ts +17 -0
  132. package/src/evm/swaps/handlers/claim/ClaimHandlers.ts +20 -0
  133. package/src/evm/swaps/handlers/claim/HashlockClaimHandler.ts +47 -0
  134. package/src/evm/swaps/handlers/claim/btc/BitcoinNoncedOutputClaimHandler.ts +82 -0
  135. package/src/evm/swaps/handlers/claim/btc/BitcoinOutputClaimHandler.ts +76 -0
  136. package/src/evm/swaps/handlers/claim/btc/BitcoinTxIdClaimHandler.ts +46 -0
  137. package/src/evm/swaps/handlers/claim/btc/IBitcoinClaimHandler.ts +115 -0
  138. package/src/evm/swaps/handlers/refund/TimelockRefundHandler.ts +38 -0
  139. package/src/evm/swaps/modules/EVMLpVault.ts +153 -0
  140. package/src/evm/swaps/modules/EVMSwapClaim.ts +141 -0
  141. package/src/evm/swaps/modules/EVMSwapInit.ts +292 -0
  142. package/src/evm/swaps/modules/EVMSwapRefund.ts +198 -0
  143. package/src/evm/typechain/common.ts +131 -0
  144. package/src/evm/wallet/EVMSigner.ts +23 -0
  145. package/src/index.ts +44 -0
  146. package/src/utils/Utils.ts +81 -0
@@ -0,0 +1,261 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.BtcRelayAbi = void 0;
4
+ exports.BtcRelayAbi = [
5
+ {
6
+ "inputs": [
7
+ {
8
+ "components": [
9
+ {
10
+ "internalType": "bytes32[5]",
11
+ "name": "data",
12
+ "type": "bytes32[5]"
13
+ }
14
+ ],
15
+ "internalType": "struct StoredBlockHeader",
16
+ "name": "storedHeader",
17
+ "type": "tuple"
18
+ },
19
+ {
20
+ "internalType": "bool",
21
+ "name": "clampBlockTarget",
22
+ "type": "bool"
23
+ }
24
+ ],
25
+ "stateMutability": "nonpayable",
26
+ "type": "constructor"
27
+ },
28
+ {
29
+ "anonymous": false,
30
+ "inputs": [
31
+ {
32
+ "indexed": true,
33
+ "internalType": "bytes32",
34
+ "name": "commitHash",
35
+ "type": "bytes32"
36
+ },
37
+ {
38
+ "indexed": true,
39
+ "internalType": "bytes32",
40
+ "name": "blockHash",
41
+ "type": "bytes32"
42
+ },
43
+ {
44
+ "indexed": true,
45
+ "internalType": "uint256",
46
+ "name": "forkId",
47
+ "type": "uint256"
48
+ },
49
+ {
50
+ "indexed": false,
51
+ "internalType": "address",
52
+ "name": "submitter",
53
+ "type": "address"
54
+ },
55
+ {
56
+ "indexed": false,
57
+ "internalType": "uint256",
58
+ "name": "startHeight",
59
+ "type": "uint256"
60
+ }
61
+ ],
62
+ "name": "ChainReorg",
63
+ "type": "event"
64
+ },
65
+ {
66
+ "anonymous": false,
67
+ "inputs": [
68
+ {
69
+ "indexed": true,
70
+ "internalType": "bytes32",
71
+ "name": "commitHash",
72
+ "type": "bytes32"
73
+ },
74
+ {
75
+ "indexed": true,
76
+ "internalType": "bytes32",
77
+ "name": "blockHash",
78
+ "type": "bytes32"
79
+ },
80
+ {
81
+ "indexed": true,
82
+ "internalType": "uint256",
83
+ "name": "forkId",
84
+ "type": "uint256"
85
+ }
86
+ ],
87
+ "name": "StoreForkHeader",
88
+ "type": "event"
89
+ },
90
+ {
91
+ "anonymous": false,
92
+ "inputs": [
93
+ {
94
+ "indexed": true,
95
+ "internalType": "bytes32",
96
+ "name": "commitHash",
97
+ "type": "bytes32"
98
+ },
99
+ {
100
+ "indexed": true,
101
+ "internalType": "bytes32",
102
+ "name": "blockHash",
103
+ "type": "bytes32"
104
+ }
105
+ ],
106
+ "name": "StoreHeader",
107
+ "type": "event"
108
+ },
109
+ {
110
+ "inputs": [],
111
+ "name": "getBlockheight",
112
+ "outputs": [
113
+ {
114
+ "internalType": "uint32",
115
+ "name": "blockheight",
116
+ "type": "uint32"
117
+ }
118
+ ],
119
+ "stateMutability": "view",
120
+ "type": "function"
121
+ },
122
+ {
123
+ "inputs": [],
124
+ "name": "getChainwork",
125
+ "outputs": [
126
+ {
127
+ "internalType": "uint224",
128
+ "name": "chainWork",
129
+ "type": "uint224"
130
+ }
131
+ ],
132
+ "stateMutability": "view",
133
+ "type": "function"
134
+ },
135
+ {
136
+ "inputs": [
137
+ {
138
+ "internalType": "uint256",
139
+ "name": "height",
140
+ "type": "uint256"
141
+ }
142
+ ],
143
+ "name": "getCommitHash",
144
+ "outputs": [
145
+ {
146
+ "internalType": "bytes32",
147
+ "name": "",
148
+ "type": "bytes32"
149
+ }
150
+ ],
151
+ "stateMutability": "view",
152
+ "type": "function"
153
+ },
154
+ {
155
+ "inputs": [],
156
+ "name": "getTipCommitHash",
157
+ "outputs": [
158
+ {
159
+ "internalType": "bytes32",
160
+ "name": "",
161
+ "type": "bytes32"
162
+ }
163
+ ],
164
+ "stateMutability": "view",
165
+ "type": "function"
166
+ },
167
+ {
168
+ "inputs": [
169
+ {
170
+ "internalType": "uint256",
171
+ "name": "forkId",
172
+ "type": "uint256"
173
+ },
174
+ {
175
+ "internalType": "bytes",
176
+ "name": "data",
177
+ "type": "bytes"
178
+ }
179
+ ],
180
+ "name": "submitForkBlockheaders",
181
+ "outputs": [],
182
+ "stateMutability": "nonpayable",
183
+ "type": "function"
184
+ },
185
+ {
186
+ "inputs": [
187
+ {
188
+ "internalType": "bytes",
189
+ "name": "data",
190
+ "type": "bytes"
191
+ }
192
+ ],
193
+ "name": "submitMainBlockheaders",
194
+ "outputs": [],
195
+ "stateMutability": "nonpayable",
196
+ "type": "function"
197
+ },
198
+ {
199
+ "inputs": [
200
+ {
201
+ "internalType": "bytes",
202
+ "name": "data",
203
+ "type": "bytes"
204
+ }
205
+ ],
206
+ "name": "submitShortForkBlockheaders",
207
+ "outputs": [],
208
+ "stateMutability": "nonpayable",
209
+ "type": "function"
210
+ },
211
+ {
212
+ "inputs": [
213
+ {
214
+ "components": [
215
+ {
216
+ "internalType": "bytes32[5]",
217
+ "name": "data",
218
+ "type": "bytes32[5]"
219
+ }
220
+ ],
221
+ "internalType": "struct StoredBlockHeader",
222
+ "name": "storedHeader",
223
+ "type": "tuple"
224
+ }
225
+ ],
226
+ "name": "verifyBlockheader",
227
+ "outputs": [
228
+ {
229
+ "internalType": "uint256",
230
+ "name": "confirmations",
231
+ "type": "uint256"
232
+ }
233
+ ],
234
+ "stateMutability": "view",
235
+ "type": "function"
236
+ },
237
+ {
238
+ "inputs": [
239
+ {
240
+ "internalType": "uint256",
241
+ "name": "height",
242
+ "type": "uint256"
243
+ },
244
+ {
245
+ "internalType": "bytes32",
246
+ "name": "commitmentHash",
247
+ "type": "bytes32"
248
+ }
249
+ ],
250
+ "name": "verifyBlockheaderHash",
251
+ "outputs": [
252
+ {
253
+ "internalType": "uint256",
254
+ "name": "confirmations",
255
+ "type": "uint256"
256
+ }
257
+ ],
258
+ "stateMutability": "view",
259
+ "type": "function"
260
+ }
261
+ ];
@@ -0,0 +1,172 @@
1
+ import type { BaseContract, BigNumberish, BytesLike, FunctionFragment, Result, Interface, EventFragment, AddressLike, ContractRunner, ContractMethod, Listener } from "ethers";
2
+ import type { TypedContractEvent, TypedDeferredTopicFilter, TypedEventLog, TypedLogDescription, TypedListener, TypedContractMethod } from "../typechain/common";
3
+ export type StoredBlockHeaderStruct = {
4
+ data: [BytesLike, BytesLike, BytesLike, BytesLike, BytesLike];
5
+ };
6
+ export type StoredBlockHeaderStructOutput = [
7
+ data: [string, string, string, string, string]
8
+ ] & {
9
+ data: [string, string, string, string, string];
10
+ };
11
+ export interface BtcRelayInterface extends Interface {
12
+ getFunction(nameOrSignature: "getBlockheight" | "getChainwork" | "getCommitHash" | "getTipCommitHash" | "submitForkBlockheaders" | "submitMainBlockheaders" | "submitShortForkBlockheaders" | "verifyBlockheader" | "verifyBlockheaderHash"): FunctionFragment;
13
+ getEvent(nameOrSignatureOrTopic: "ChainReorg" | "StoreForkHeader" | "StoreHeader"): EventFragment;
14
+ encodeFunctionData(functionFragment: "getBlockheight", values?: undefined): string;
15
+ encodeFunctionData(functionFragment: "getChainwork", values?: undefined): string;
16
+ encodeFunctionData(functionFragment: "getCommitHash", values: [BigNumberish]): string;
17
+ encodeFunctionData(functionFragment: "getTipCommitHash", values?: undefined): string;
18
+ encodeFunctionData(functionFragment: "submitForkBlockheaders", values: [BigNumberish, BytesLike]): string;
19
+ encodeFunctionData(functionFragment: "submitMainBlockheaders", values: [BytesLike]): string;
20
+ encodeFunctionData(functionFragment: "submitShortForkBlockheaders", values: [BytesLike]): string;
21
+ encodeFunctionData(functionFragment: "verifyBlockheader", values: [StoredBlockHeaderStruct]): string;
22
+ encodeFunctionData(functionFragment: "verifyBlockheaderHash", values: [BigNumberish, BytesLike]): string;
23
+ decodeFunctionResult(functionFragment: "getBlockheight", data: BytesLike): Result;
24
+ decodeFunctionResult(functionFragment: "getChainwork", data: BytesLike): Result;
25
+ decodeFunctionResult(functionFragment: "getCommitHash", data: BytesLike): Result;
26
+ decodeFunctionResult(functionFragment: "getTipCommitHash", data: BytesLike): Result;
27
+ decodeFunctionResult(functionFragment: "submitForkBlockheaders", data: BytesLike): Result;
28
+ decodeFunctionResult(functionFragment: "submitMainBlockheaders", data: BytesLike): Result;
29
+ decodeFunctionResult(functionFragment: "submitShortForkBlockheaders", data: BytesLike): Result;
30
+ decodeFunctionResult(functionFragment: "verifyBlockheader", data: BytesLike): Result;
31
+ decodeFunctionResult(functionFragment: "verifyBlockheaderHash", data: BytesLike): Result;
32
+ }
33
+ export declare namespace ChainReorgEvent {
34
+ type InputTuple = [
35
+ commitHash: BytesLike,
36
+ blockHash: BytesLike,
37
+ forkId: BigNumberish,
38
+ submitter: AddressLike,
39
+ startHeight: BigNumberish
40
+ ];
41
+ type OutputTuple = [
42
+ commitHash: string,
43
+ blockHash: string,
44
+ forkId: bigint,
45
+ submitter: string,
46
+ startHeight: bigint
47
+ ];
48
+ interface OutputObject {
49
+ commitHash: string;
50
+ blockHash: string;
51
+ forkId: bigint;
52
+ submitter: string;
53
+ startHeight: bigint;
54
+ }
55
+ type Event = TypedContractEvent<InputTuple, OutputTuple, OutputObject>;
56
+ type Filter = TypedDeferredTopicFilter<Event>;
57
+ type Log = TypedEventLog<Event>;
58
+ type LogDescription = TypedLogDescription<Event>;
59
+ }
60
+ export declare namespace StoreForkHeaderEvent {
61
+ type InputTuple = [
62
+ commitHash: BytesLike,
63
+ blockHash: BytesLike,
64
+ forkId: BigNumberish
65
+ ];
66
+ type OutputTuple = [
67
+ commitHash: string,
68
+ blockHash: string,
69
+ forkId: bigint
70
+ ];
71
+ interface OutputObject {
72
+ commitHash: string;
73
+ blockHash: string;
74
+ forkId: bigint;
75
+ }
76
+ type Event = TypedContractEvent<InputTuple, OutputTuple, OutputObject>;
77
+ type Filter = TypedDeferredTopicFilter<Event>;
78
+ type Log = TypedEventLog<Event>;
79
+ type LogDescription = TypedLogDescription<Event>;
80
+ }
81
+ export declare namespace StoreHeaderEvent {
82
+ type InputTuple = [commitHash: BytesLike, blockHash: BytesLike];
83
+ type OutputTuple = [commitHash: string, blockHash: string];
84
+ interface OutputObject {
85
+ commitHash: string;
86
+ blockHash: string;
87
+ }
88
+ type Event = TypedContractEvent<InputTuple, OutputTuple, OutputObject>;
89
+ type Filter = TypedDeferredTopicFilter<Event>;
90
+ type Log = TypedEventLog<Event>;
91
+ type LogDescription = TypedLogDescription<Event>;
92
+ }
93
+ export interface BtcRelay extends BaseContract {
94
+ connect(runner?: ContractRunner | null): BtcRelay;
95
+ waitForDeployment(): Promise<this>;
96
+ interface: BtcRelayInterface;
97
+ queryFilter<TCEvent extends TypedContractEvent>(event: TCEvent, fromBlockOrBlockhash?: string | number | undefined, toBlock?: string | number | undefined): Promise<Array<TypedEventLog<TCEvent>>>;
98
+ queryFilter<TCEvent extends TypedContractEvent>(filter: TypedDeferredTopicFilter<TCEvent>, fromBlockOrBlockhash?: string | number | undefined, toBlock?: string | number | undefined): Promise<Array<TypedEventLog<TCEvent>>>;
99
+ on<TCEvent extends TypedContractEvent>(event: TCEvent, listener: TypedListener<TCEvent>): Promise<this>;
100
+ on<TCEvent extends TypedContractEvent>(filter: TypedDeferredTopicFilter<TCEvent>, listener: TypedListener<TCEvent>): Promise<this>;
101
+ once<TCEvent extends TypedContractEvent>(event: TCEvent, listener: TypedListener<TCEvent>): Promise<this>;
102
+ once<TCEvent extends TypedContractEvent>(filter: TypedDeferredTopicFilter<TCEvent>, listener: TypedListener<TCEvent>): Promise<this>;
103
+ listeners<TCEvent extends TypedContractEvent>(event: TCEvent): Promise<Array<TypedListener<TCEvent>>>;
104
+ listeners(eventName?: string): Promise<Array<Listener>>;
105
+ removeAllListeners<TCEvent extends TypedContractEvent>(event?: TCEvent): Promise<this>;
106
+ getBlockheight: TypedContractMethod<[], [bigint], "view">;
107
+ getChainwork: TypedContractMethod<[], [bigint], "view">;
108
+ getCommitHash: TypedContractMethod<[height: BigNumberish], [string], "view">;
109
+ getTipCommitHash: TypedContractMethod<[], [string], "view">;
110
+ submitForkBlockheaders: TypedContractMethod<[
111
+ forkId: BigNumberish,
112
+ data: BytesLike
113
+ ], [
114
+ void
115
+ ], "nonpayable">;
116
+ submitMainBlockheaders: TypedContractMethod<[
117
+ data: BytesLike
118
+ ], [
119
+ void
120
+ ], "nonpayable">;
121
+ submitShortForkBlockheaders: TypedContractMethod<[
122
+ data: BytesLike
123
+ ], [
124
+ void
125
+ ], "nonpayable">;
126
+ verifyBlockheader: TypedContractMethod<[
127
+ storedHeader: StoredBlockHeaderStruct
128
+ ], [
129
+ bigint
130
+ ], "view">;
131
+ verifyBlockheaderHash: TypedContractMethod<[
132
+ height: BigNumberish,
133
+ commitmentHash: BytesLike
134
+ ], [
135
+ bigint
136
+ ], "view">;
137
+ getFunction<T extends ContractMethod = ContractMethod>(key: string | FunctionFragment): T;
138
+ getFunction(nameOrSignature: "getBlockheight"): TypedContractMethod<[], [bigint], "view">;
139
+ getFunction(nameOrSignature: "getChainwork"): TypedContractMethod<[], [bigint], "view">;
140
+ getFunction(nameOrSignature: "getCommitHash"): TypedContractMethod<[height: BigNumberish], [string], "view">;
141
+ getFunction(nameOrSignature: "getTipCommitHash"): TypedContractMethod<[], [string], "view">;
142
+ getFunction(nameOrSignature: "submitForkBlockheaders"): TypedContractMethod<[
143
+ forkId: BigNumberish,
144
+ data: BytesLike
145
+ ], [
146
+ void
147
+ ], "nonpayable">;
148
+ getFunction(nameOrSignature: "submitMainBlockheaders"): TypedContractMethod<[data: BytesLike], [void], "nonpayable">;
149
+ getFunction(nameOrSignature: "submitShortForkBlockheaders"): TypedContractMethod<[data: BytesLike], [void], "nonpayable">;
150
+ getFunction(nameOrSignature: "verifyBlockheader"): TypedContractMethod<[
151
+ storedHeader: StoredBlockHeaderStruct
152
+ ], [
153
+ bigint
154
+ ], "view">;
155
+ getFunction(nameOrSignature: "verifyBlockheaderHash"): TypedContractMethod<[
156
+ height: BigNumberish,
157
+ commitmentHash: BytesLike
158
+ ], [
159
+ bigint
160
+ ], "view">;
161
+ getEvent(key: "ChainReorg"): TypedContractEvent<ChainReorgEvent.InputTuple, ChainReorgEvent.OutputTuple, ChainReorgEvent.OutputObject>;
162
+ getEvent(key: "StoreForkHeader"): TypedContractEvent<StoreForkHeaderEvent.InputTuple, StoreForkHeaderEvent.OutputTuple, StoreForkHeaderEvent.OutputObject>;
163
+ getEvent(key: "StoreHeader"): TypedContractEvent<StoreHeaderEvent.InputTuple, StoreHeaderEvent.OutputTuple, StoreHeaderEvent.OutputObject>;
164
+ filters: {
165
+ "ChainReorg(bytes32,bytes32,uint256,address,uint256)": TypedContractEvent<ChainReorgEvent.InputTuple, ChainReorgEvent.OutputTuple, ChainReorgEvent.OutputObject>;
166
+ ChainReorg: TypedContractEvent<ChainReorgEvent.InputTuple, ChainReorgEvent.OutputTuple, ChainReorgEvent.OutputObject>;
167
+ "StoreForkHeader(bytes32,bytes32,uint256)": TypedContractEvent<StoreForkHeaderEvent.InputTuple, StoreForkHeaderEvent.OutputTuple, StoreForkHeaderEvent.OutputObject>;
168
+ StoreForkHeader: TypedContractEvent<StoreForkHeaderEvent.InputTuple, StoreForkHeaderEvent.OutputTuple, StoreForkHeaderEvent.OutputObject>;
169
+ "StoreHeader(bytes32,bytes32)": TypedContractEvent<StoreHeaderEvent.InputTuple, StoreHeaderEvent.OutputTuple, StoreHeaderEvent.OutputObject>;
170
+ StoreHeader: TypedContractEvent<StoreHeaderEvent.InputTuple, StoreHeaderEvent.OutputTuple, StoreHeaderEvent.OutputObject>;
171
+ };
172
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,188 @@
1
+ /// <reference types="node" />
2
+ /// <reference types="node" />
3
+ import { BitcoinNetwork, BitcoinRpc, BtcBlock, BtcRelay, RelaySynchronizer } from "@atomiqlabs/base";
4
+ import { EVMBtcHeader } from "./headers/EVMBtcHeader";
5
+ import { EVMContractBase } from "../contract/EVMContractBase";
6
+ import { BtcRelay as BtcRelayTypechain } from "./BtcRelayTypechain";
7
+ import { EVMBtcStoredHeader } from "./headers/EVMBtcStoredHeader";
8
+ import { EVMSigner } from "../wallet/EVMSigner";
9
+ import { EVMTx } from "../chain/modules/EVMTransactions";
10
+ import { EVMChainInterface } from "../chain/EVMChainInterface";
11
+ export declare class EVMBtcRelay<B extends BtcBlock> extends EVMContractBase<BtcRelayTypechain> implements BtcRelay<EVMBtcStoredHeader, EVMTx, B, EVMSigner> {
12
+ SaveMainHeaders(signer: string, mainHeaders: EVMBtcHeader[], storedHeader: EVMBtcStoredHeader, feeRate: string): Promise<EVMTx>;
13
+ SaveShortForkHeaders(signer: string, forkHeaders: EVMBtcHeader[], storedHeader: EVMBtcStoredHeader, feeRate: string): Promise<EVMTx>;
14
+ SaveLongForkHeaders(signer: string, forkId: number, forkHeaders: EVMBtcHeader[], storedHeader: EVMBtcStoredHeader, feeRate: string, totalForkHeaders?: number): Promise<EVMTx>;
15
+ bitcoinRpc: BitcoinRpc<B>;
16
+ readonly maxHeadersPerTx: number;
17
+ readonly maxForkHeadersPerTx: number;
18
+ readonly maxShortForkHeadersPerTx: number;
19
+ constructor(chainInterface: EVMChainInterface<any>, bitcoinRpc: BitcoinRpc<B>, bitcoinNetwork: BitcoinNetwork, contractAddress: string, contractDeploymentHeight?: number);
20
+ /**
21
+ * Computes subsequent commited headers as they will appear on the blockchain when transactions
22
+ * are submitted & confirmed
23
+ *
24
+ * @param initialStoredHeader
25
+ * @param syncedHeaders
26
+ * @private
27
+ */
28
+ private computeCommitedHeaders;
29
+ /**
30
+ * A common logic for submitting blockheaders in a transaction
31
+ *
32
+ * @param signer
33
+ * @param headers headers to sync to the btc relay
34
+ * @param storedHeader current latest stored block header for a given fork
35
+ * @param tipWork work of the current tip in a given fork
36
+ * @param forkId forkId to submit to, forkId=0 means main chain, forkId=-1 means short fork
37
+ * @param feeRate feeRate for the transaction
38
+ * @param totalForkHeaders Total number of headers in a fork
39
+ * @private
40
+ */
41
+ private _saveHeaders;
42
+ private findStoredBlockheaderInTraces;
43
+ private getBlock;
44
+ private getBlockHeight;
45
+ /**
46
+ * Returns data about current main chain tip stored in the btc relay
47
+ */
48
+ getTipData(): Promise<{
49
+ commitHash: string;
50
+ blockhash: string;
51
+ chainWork: Buffer;
52
+ blockheight: number;
53
+ }>;
54
+ /**
55
+ * Retrieves blockheader with a specific blockhash, returns null if requiredBlockheight is provided and
56
+ * btc relay contract is not synced up to the desired blockheight
57
+ *
58
+ * @param blockData
59
+ * @param requiredBlockheight
60
+ */
61
+ retrieveLogAndBlockheight(blockData: {
62
+ blockhash: string;
63
+ }, requiredBlockheight?: number): Promise<{
64
+ header: EVMBtcStoredHeader;
65
+ height: number;
66
+ } | null>;
67
+ /**
68
+ * Retrieves blockheader data by blockheader's commit hash,
69
+ *
70
+ * @param commitmentHashStr
71
+ * @param blockData
72
+ */
73
+ retrieveLogByCommitHash(commitmentHashStr: string, blockData: {
74
+ blockhash: string;
75
+ }): Promise<EVMBtcStoredHeader>;
76
+ /**
77
+ * Retrieves latest known stored blockheader & blockheader from bitcoin RPC that is in the main chain
78
+ */
79
+ retrieveLatestKnownBlockLog(): Promise<{
80
+ resultStoredHeader: EVMBtcStoredHeader;
81
+ resultBitcoinHeader: B;
82
+ }>;
83
+ /**
84
+ * Saves blockheaders as a bitcoin main chain to the btc relay
85
+ *
86
+ * @param signer
87
+ * @param mainHeaders
88
+ * @param storedHeader
89
+ * @param feeRate
90
+ */
91
+ saveMainHeaders(signer: string, mainHeaders: BtcBlock[], storedHeader: EVMBtcStoredHeader, feeRate?: string): Promise<{
92
+ forkId: number;
93
+ lastStoredHeader: EVMBtcStoredHeader;
94
+ tx: import("ethers").TransactionRequest;
95
+ computedCommitedHeaders: EVMBtcStoredHeader[];
96
+ }>;
97
+ /**
98
+ * Creates a new long fork and submits the headers to it
99
+ *
100
+ * @param signer
101
+ * @param forkHeaders
102
+ * @param storedHeader
103
+ * @param tipWork
104
+ * @param feeRate
105
+ */
106
+ saveNewForkHeaders(signer: string, forkHeaders: BtcBlock[], storedHeader: EVMBtcStoredHeader, tipWork: Buffer, feeRate?: string): Promise<{
107
+ forkId: number;
108
+ lastStoredHeader: EVMBtcStoredHeader;
109
+ tx: import("ethers").TransactionRequest;
110
+ computedCommitedHeaders: EVMBtcStoredHeader[];
111
+ }>;
112
+ /**
113
+ * Continues submitting blockheaders to a given fork
114
+ *
115
+ * @param signer
116
+ * @param forkHeaders
117
+ * @param storedHeader
118
+ * @param forkId
119
+ * @param tipWork
120
+ * @param feeRate
121
+ */
122
+ saveForkHeaders(signer: string, forkHeaders: BtcBlock[], storedHeader: EVMBtcStoredHeader, forkId: number, tipWork: Buffer, feeRate?: string): Promise<{
123
+ forkId: number;
124
+ lastStoredHeader: EVMBtcStoredHeader;
125
+ tx: import("ethers").TransactionRequest;
126
+ computedCommitedHeaders: EVMBtcStoredHeader[];
127
+ }>;
128
+ /**
129
+ * Submits short fork with given blockheaders
130
+ *
131
+ * @param signer
132
+ * @param forkHeaders
133
+ * @param storedHeader
134
+ * @param tipWork
135
+ * @param feeRate
136
+ */
137
+ saveShortForkHeaders(signer: string, forkHeaders: BtcBlock[], storedHeader: EVMBtcStoredHeader, tipWork: Buffer, feeRate?: string): Promise<{
138
+ forkId: number;
139
+ lastStoredHeader: EVMBtcStoredHeader;
140
+ tx: import("ethers").TransactionRequest;
141
+ computedCommitedHeaders: EVMBtcStoredHeader[];
142
+ }>;
143
+ /**
144
+ * Estimate required synchronization fee (worst case) to synchronize btc relay to the required blockheight
145
+ *
146
+ * @param requiredBlockheight
147
+ * @param feeRate
148
+ */
149
+ estimateSynchronizeFee(requiredBlockheight: number, feeRate?: string): Promise<bigint>;
150
+ /**
151
+ * Returns fee required (in SOL) to synchronize a single block to btc relay
152
+ *
153
+ * @param feeRate
154
+ */
155
+ getFeePerBlock(feeRate?: string): Promise<bigint>;
156
+ /**
157
+ * Gets fee rate required for submitting blockheaders to the main chain
158
+ */
159
+ getMainFeeRate(signer: string | null): Promise<string>;
160
+ /**
161
+ * Gets fee rate required for submitting blockheaders to the specific fork
162
+ */
163
+ getForkFeeRate(signer: string, forkId: number): Promise<string>;
164
+ saveInitialHeader(signer: string, header: B, epochStart: number, pastBlocksTimestamps: number[], feeRate?: string): Promise<EVMTx>;
165
+ /**
166
+ * Gets committed header, identified by blockhash & blockheight, determines required BTC relay blockheight based on
167
+ * requiredConfirmations
168
+ * If synchronizer is passed & blockhash is not found, it produces transactions to sync up the btc relay to the
169
+ * current chain tip & adds them to the txs array
170
+ *
171
+ * @param signer
172
+ * @param btcRelay
173
+ * @param btcTxs
174
+ * @param txs solana transaction array, in case we need to synchronize the btc relay ourselves the synchronization
175
+ * txns are added here
176
+ * @param synchronizer optional synchronizer to use to synchronize the btc relay in case it is not yet synchronized
177
+ * to the required blockheight
178
+ * @param feeRate Fee rate to use for synchronization transactions
179
+ * @private
180
+ */
181
+ static getCommitedHeadersAndSynchronize(signer: string, btcRelay: EVMBtcRelay<any>, btcTxs: {
182
+ blockheight: number;
183
+ requiredConfirmations: number;
184
+ blockhash: string;
185
+ }[], txs: EVMTx[], synchronizer?: RelaySynchronizer<EVMBtcStoredHeader, EVMTx, any>, feeRate?: string): Promise<{
186
+ [blockhash: string]: EVMBtcStoredHeader;
187
+ }>;
188
+ }