@atomiqlabs/chain-evm 1.1.20 → 2.0.7

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 (143) hide show
  1. package/dist/chains/alpen/AlpenChainType.d.ts +6 -2
  2. package/dist/chains/alpen/AlpenInitializer.d.ts +24 -0
  3. package/dist/chains/alpen/AlpenInitializer.js +21 -14
  4. package/dist/chains/botanix/BotanixChainType.d.ts +6 -2
  5. package/dist/chains/botanix/BotanixInitializer.d.ts +24 -0
  6. package/dist/chains/botanix/BotanixInitializer.js +19 -10
  7. package/dist/chains/citrea/CitreaBtcRelay.js +2 -0
  8. package/dist/chains/citrea/CitreaChainType.d.ts +6 -2
  9. package/dist/chains/citrea/CitreaFees.d.ts +4 -1
  10. package/dist/chains/citrea/CitreaFees.js +10 -9
  11. package/dist/chains/citrea/CitreaInitializer.d.ts +24 -0
  12. package/dist/chains/citrea/CitreaInitializer.js +22 -11
  13. package/dist/chains/goat/GoatChainType.d.ts +6 -2
  14. package/dist/chains/goat/GoatInitializer.d.ts +24 -0
  15. package/dist/chains/goat/GoatInitializer.js +20 -13
  16. package/dist/evm/btcrelay/EVMBtcRelay.d.ts +8 -6
  17. package/dist/evm/btcrelay/EVMBtcRelay.js +33 -16
  18. package/dist/evm/btcrelay/headers/EVMBtcHeader.d.ts +4 -1
  19. package/dist/evm/btcrelay/headers/EVMBtcHeader.js +7 -0
  20. package/dist/evm/btcrelay/headers/EVMBtcStoredHeader.d.ts +3 -0
  21. package/dist/evm/btcrelay/headers/EVMBtcStoredHeader.js +3 -0
  22. package/dist/evm/chain/EVMChainInterface.d.ts +20 -5
  23. package/dist/evm/chain/EVMChainInterface.js +15 -2
  24. package/dist/evm/chain/EVMModule.d.ts +1 -1
  25. package/dist/evm/chain/modules/EVMAddresses.d.ts +3 -0
  26. package/dist/evm/chain/modules/EVMAddresses.js +3 -0
  27. package/dist/evm/chain/modules/EVMBlocks.d.ts +3 -0
  28. package/dist/evm/chain/modules/EVMBlocks.js +8 -1
  29. package/dist/evm/chain/modules/EVMEvents.d.ts +6 -3
  30. package/dist/evm/chain/modules/EVMEvents.js +16 -6
  31. package/dist/evm/chain/modules/EVMFees.d.ts +5 -2
  32. package/dist/evm/chain/modules/EVMFees.js +15 -10
  33. package/dist/evm/chain/modules/EVMSignatures.d.ts +3 -0
  34. package/dist/evm/chain/modules/EVMSignatures.js +3 -0
  35. package/dist/evm/chain/modules/EVMTokens.d.ts +5 -1
  36. package/dist/evm/chain/modules/EVMTokens.js +4 -0
  37. package/dist/evm/chain/modules/EVMTransactions.d.ts +21 -4
  38. package/dist/evm/chain/modules/EVMTransactions.js +96 -11
  39. package/dist/evm/contract/EVMContractBase.d.ts +2 -2
  40. package/dist/evm/contract/EVMContractBase.js +2 -1
  41. package/dist/evm/contract/EVMContractModule.d.ts +3 -3
  42. package/dist/evm/contract/modules/EVMContractEvents.d.ts +4 -4
  43. package/dist/evm/contract/modules/EVMContractEvents.js +11 -3
  44. package/dist/evm/events/EVMChainEvents.d.ts +1 -1
  45. package/dist/evm/events/EVMChainEvents.js +19 -5
  46. package/dist/evm/events/EVMChainEventsBrowser.d.ts +17 -23
  47. package/dist/evm/events/EVMChainEventsBrowser.js +50 -39
  48. package/dist/evm/providers/JsonRpcProviderWithRetries.d.ts +4 -1
  49. package/dist/evm/providers/JsonRpcProviderWithRetries.js +3 -0
  50. package/dist/evm/providers/ReconnectingWebSocketProvider.js +4 -1
  51. package/dist/evm/providers/SocketProvider.js +1 -1
  52. package/dist/evm/providers/WebSocketProviderWithRetries.d.ts +3 -0
  53. package/dist/evm/providers/WebSocketProviderWithRetries.js +3 -0
  54. package/dist/evm/spv_swap/EVMSpvVaultContract.d.ts +10 -7
  55. package/dist/evm/spv_swap/EVMSpvVaultContract.js +15 -7
  56. package/dist/evm/spv_swap/EVMSpvVaultData.d.ts +4 -1
  57. package/dist/evm/spv_swap/EVMSpvVaultData.js +9 -0
  58. package/dist/evm/spv_swap/EVMSpvWithdrawalData.d.ts +4 -1
  59. package/dist/evm/spv_swap/EVMSpvWithdrawalData.js +3 -0
  60. package/dist/evm/swaps/EVMSwapContract.d.ts +9 -37
  61. package/dist/evm/swaps/EVMSwapContract.js +50 -32
  62. package/dist/evm/swaps/EVMSwapData.d.ts +10 -6
  63. package/dist/evm/swaps/EVMSwapData.js +51 -9
  64. package/dist/evm/swaps/EVMSwapModule.d.ts +1 -2
  65. package/dist/evm/swaps/EscrowManagerAbi.d.ts +1 -1
  66. package/dist/evm/swaps/handlers/IHandler.d.ts +1 -1
  67. package/dist/evm/swaps/handlers/claim/HashlockClaimHandler.d.ts +3 -0
  68. package/dist/evm/swaps/handlers/claim/HashlockClaimHandler.js +3 -0
  69. package/dist/evm/swaps/handlers/claim/btc/BitcoinNoncedOutputClaimHandler.d.ts +3 -0
  70. package/dist/evm/swaps/handlers/claim/btc/BitcoinNoncedOutputClaimHandler.js +3 -0
  71. package/dist/evm/swaps/handlers/claim/btc/BitcoinOutputClaimHandler.d.ts +3 -0
  72. package/dist/evm/swaps/handlers/claim/btc/BitcoinOutputClaimHandler.js +3 -0
  73. package/dist/evm/swaps/handlers/claim/btc/BitcoinTxIdClaimHandler.d.ts +3 -0
  74. package/dist/evm/swaps/handlers/claim/btc/BitcoinTxIdClaimHandler.js +3 -0
  75. package/dist/evm/swaps/handlers/claim/btc/IBitcoinClaimHandler.d.ts +1 -1
  76. package/dist/evm/swaps/handlers/claim/btc/IBitcoinClaimHandler.js +2 -0
  77. package/dist/evm/swaps/handlers/refund/TimelockRefundHandler.d.ts +3 -0
  78. package/dist/evm/swaps/handlers/refund/TimelockRefundHandler.js +3 -0
  79. package/dist/evm/swaps/modules/EVMSwapInit.d.ts +1 -1
  80. package/dist/evm/swaps/modules/EVMSwapInit.js +4 -3
  81. package/dist/evm/swaps/modules/EVMSwapRefund.js +3 -4
  82. package/dist/evm/typechain/common.d.ts +2 -1
  83. package/dist/evm/wallet/EVMBrowserSigner.d.ts +6 -1
  84. package/dist/evm/wallet/EVMBrowserSigner.js +15 -1
  85. package/dist/evm/wallet/EVMPersistentSigner.d.ts +1 -1
  86. package/dist/evm/wallet/EVMPersistentSigner.js +6 -3
  87. package/dist/evm/wallet/EVMSigner.d.ts +4 -0
  88. package/dist/evm/wallet/EVMSigner.js +4 -0
  89. package/dist/index.d.ts +13 -36
  90. package/dist/index.js +20 -36
  91. package/package.json +7 -4
  92. package/src/chains/alpen/AlpenChainType.ts +7 -2
  93. package/src/chains/alpen/AlpenInitializer.ts +37 -16
  94. package/src/chains/botanix/BotanixChainType.ts +7 -2
  95. package/src/chains/botanix/BotanixInitializer.ts +35 -12
  96. package/src/chains/citrea/CitreaBtcRelay.ts +1 -0
  97. package/src/chains/citrea/CitreaChainType.ts +7 -2
  98. package/src/chains/citrea/CitreaFees.ts +12 -10
  99. package/src/chains/citrea/CitreaInitializer.ts +37 -13
  100. package/src/chains/goat/GoatChainType.ts +7 -2
  101. package/src/chains/goat/GoatInitializer.ts +36 -15
  102. package/src/evm/btcrelay/EVMBtcRelay.ts +47 -32
  103. package/src/evm/btcrelay/headers/EVMBtcHeader.ts +6 -1
  104. package/src/evm/btcrelay/headers/EVMBtcStoredHeader.ts +3 -0
  105. package/src/evm/chain/EVMChainInterface.ts +38 -8
  106. package/src/evm/chain/EVMModule.ts +1 -1
  107. package/src/evm/chain/modules/EVMAddresses.ts +3 -0
  108. package/src/evm/chain/modules/EVMBlocks.ts +7 -1
  109. package/src/evm/chain/modules/EVMEvents.ts +27 -15
  110. package/src/evm/chain/modules/EVMFees.ts +18 -11
  111. package/src/evm/chain/modules/EVMSignatures.ts +3 -0
  112. package/src/evm/chain/modules/EVMTokens.ts +5 -2
  113. package/src/evm/chain/modules/EVMTransactions.ts +135 -34
  114. package/src/evm/contract/EVMContractBase.ts +5 -3
  115. package/src/evm/contract/EVMContractModule.ts +3 -3
  116. package/src/evm/contract/modules/EVMContractEvents.ts +22 -16
  117. package/src/evm/events/EVMChainEvents.ts +16 -7
  118. package/src/evm/events/EVMChainEventsBrowser.ts +74 -54
  119. package/src/evm/providers/JsonRpcProviderWithRetries.ts +4 -1
  120. package/src/evm/providers/ReconnectingWebSocketProvider.ts +4 -3
  121. package/src/evm/providers/SocketProvider.ts +1 -1
  122. package/src/evm/providers/WebSocketProviderWithRetries.ts +3 -1
  123. package/src/evm/spv_swap/EVMSpvVaultContract.ts +26 -19
  124. package/src/evm/spv_swap/EVMSpvVaultData.ts +9 -2
  125. package/src/evm/spv_swap/EVMSpvWithdrawalData.ts +4 -2
  126. package/src/evm/swaps/EVMSwapContract.ts +46 -37
  127. package/src/evm/swaps/EVMSwapData.ts +40 -16
  128. package/src/evm/swaps/EVMSwapModule.ts +1 -2
  129. package/src/evm/swaps/handlers/IHandler.ts +1 -1
  130. package/src/evm/swaps/handlers/claim/HashlockClaimHandler.ts +3 -0
  131. package/src/evm/swaps/handlers/claim/btc/BitcoinNoncedOutputClaimHandler.ts +6 -3
  132. package/src/evm/swaps/handlers/claim/btc/BitcoinOutputClaimHandler.ts +5 -2
  133. package/src/evm/swaps/handlers/claim/btc/BitcoinTxIdClaimHandler.ts +3 -0
  134. package/src/evm/swaps/handlers/claim/btc/IBitcoinClaimHandler.ts +2 -1
  135. package/src/evm/swaps/handlers/refund/TimelockRefundHandler.ts +3 -0
  136. package/src/evm/swaps/modules/EVMSwapInit.ts +6 -8
  137. package/src/evm/swaps/modules/EVMSwapRefund.ts +3 -8
  138. package/src/evm/typechain/common.ts +2 -1
  139. package/src/evm/wallet/EVMBrowserSigner.ts +16 -2
  140. package/src/evm/wallet/EVMPersistentSigner.ts +20 -19
  141. package/src/evm/wallet/EVMSigner.ts +4 -1
  142. package/src/index.ts +19 -43
  143. package/src/utils/Utils.ts +4 -4
@@ -1,6 +1,6 @@
1
1
  import { ChainType } from "@atomiqlabs/base";
2
2
  import { EVMPreFetchVerification } from "../../evm/swaps/modules/EVMSwapInit";
3
- import { EVMTx } from "../../evm/chain/modules/EVMTransactions";
3
+ import { EVMTx, SignedEVMTx } from "../../evm/chain/modules/EVMTransactions";
4
4
  import { EVMSigner } from "../../evm/wallet/EVMSigner";
5
5
  import { EVMSwapData } from "../../evm/swaps/EVMSwapData";
6
6
  import { EVMChainInterface } from "../../evm/chain/EVMChainInterface";
@@ -11,4 +11,8 @@ import { EVMSwapContract } from "../../evm/swaps/EVMSwapContract";
11
11
  import { EVMBtcRelay } from "../../evm/btcrelay/EVMBtcRelay";
12
12
  import { EVMSpvVaultContract } from "../../evm/spv_swap/EVMSpvVaultContract";
13
13
  import { Signer } from "ethers";
14
- export type AlpenChainType = ChainType<"ALPEN", never, EVMPreFetchVerification, EVMTx, EVMSigner, Signer, EVMSwapData, EVMSwapContract<"ALPEN">, EVMChainInterface<"ALPEN">, EVMChainEventsBrowser, EVMBtcRelay<any>, EVMSpvVaultData, EVMSpvWithdrawalData, EVMSpvVaultContract<"ALPEN">>;
14
+ /**
15
+ * Type definition for the Alpen chain implementation
16
+ * @category Networks/Alpen
17
+ */
18
+ export type AlpenChainType = ChainType<"ALPEN", never, EVMPreFetchVerification, EVMTx, SignedEVMTx, EVMSigner, Signer, EVMSwapData, EVMSwapContract<"ALPEN">, EVMChainInterface<"ALPEN">, EVMChainEventsBrowser, EVMBtcRelay<any>, EVMSpvWithdrawalData, EVMSpvVaultData, EVMSpvVaultContract<"ALPEN">>;
@@ -3,8 +3,20 @@ import { JsonRpcApiProvider } from "ethers";
3
3
  import { EVMConfiguration, EVMRetryPolicy } from "../../evm/chain/EVMChainInterface";
4
4
  import { EVMFees } from "../../evm/chain/modules/EVMFees";
5
5
  import { AlpenChainType } from "./AlpenChainType";
6
+ /**
7
+ * Token assets available on Alpen
8
+ * @category Networks/Alpen
9
+ */
6
10
  export type AlpenAssetsType = BaseTokenType<"BTC">;
11
+ /**
12
+ * Default Alpen token assets configuration
13
+ * @category Networks/Alpen
14
+ */
7
15
  export declare const AlpenAssets: AlpenAssetsType;
16
+ /**
17
+ * Configuration options for initializing Alpen chain
18
+ * @category Networks/Alpen
19
+ */
8
20
  export type AlpenOptions = {
9
21
  rpcUrl: string | JsonRpcApiProvider;
10
22
  retryPolicy?: EVMRetryPolicy;
@@ -25,6 +37,18 @@ export type AlpenOptions = {
25
37
  fees?: EVMFees;
26
38
  evmConfig?: Omit<EVMConfiguration, "safeBlockTag" | "finalizedBlockTag">;
27
39
  };
40
+ /**
41
+ * Initialize Alpen chain integration
42
+ * @category Networks/Alpen
43
+ */
28
44
  export declare function initializeAlpen(options: AlpenOptions, bitcoinRpc: BitcoinRpc<any>, network: BitcoinNetwork): ChainData<AlpenChainType>;
45
+ /**
46
+ * Type definition for the Alpen chain initializer
47
+ * @category Networks/Alpen
48
+ */
29
49
  export type AlpenInitializerType = ChainInitializer<AlpenOptions, AlpenChainType, AlpenAssetsType>;
50
+ /**
51
+ * Alpen chain initializer instance
52
+ * @category Networks/Alpen
53
+ */
30
54
  export declare const AlpenInitializer: AlpenInitializerType;
@@ -13,7 +13,7 @@ const EVMSwapData_1 = require("../../evm/swaps/EVMSwapData");
13
13
  const EVMSpvVaultData_1 = require("../../evm/spv_swap/EVMSpvVaultData");
14
14
  const EVMSpvWithdrawalData_1 = require("../../evm/spv_swap/EVMSpvWithdrawalData");
15
15
  const AlpenChainIds = {
16
- MAINNET: null,
16
+ MAINNET: -1,
17
17
  TESTNET: 8150,
18
18
  TESTNET4: 8150
19
19
  };
@@ -76,6 +76,15 @@ const AlpenContractAddresses = {
76
76
  }
77
77
  }
78
78
  };
79
+ const chainTypeMapping = {
80
+ [base_1.BitcoinNetwork.MAINNET]: "MAINNET",
81
+ [base_1.BitcoinNetwork.TESTNET]: "TESTNET",
82
+ [base_1.BitcoinNetwork.TESTNET4]: "TESTNET4",
83
+ };
84
+ /**
85
+ * Default Alpen token assets configuration
86
+ * @category Networks/Alpen
87
+ */
79
88
  exports.AlpenAssets = {
80
89
  BTC: {
81
90
  address: "0x0000000000000000000000000000000000000000",
@@ -83,20 +92,14 @@ exports.AlpenAssets = {
83
92
  displayDecimals: 8
84
93
  }
85
94
  };
95
+ /**
96
+ * Initialize Alpen chain integration
97
+ * @category Networks/Alpen
98
+ */
86
99
  function initializeAlpen(options, bitcoinRpc, network) {
87
- if (options.chainType == null) {
88
- switch (network) {
89
- case base_1.BitcoinNetwork.MAINNET:
90
- options.chainType = "MAINNET";
91
- break;
92
- case base_1.BitcoinNetwork.TESTNET:
93
- options.chainType = "TESTNET";
94
- break;
95
- case base_1.BitcoinNetwork.TESTNET4:
96
- options.chainType = "TESTNET4";
97
- break;
98
- }
99
- }
100
+ options.chainType ?? (options.chainType = chainTypeMapping[network]);
101
+ if (options.chainType == null)
102
+ throw new Error("Please specify chainType in options!");
100
103
  const defaultContractAddresses = AlpenContractAddresses[options.chainType];
101
104
  const chainId = AlpenChainIds[options.chainType];
102
105
  const provider = typeof (options.rpcUrl) === "string" ?
@@ -142,6 +145,10 @@ function initializeAlpen(options, bitcoinRpc, network) {
142
145
  }
143
146
  exports.initializeAlpen = initializeAlpen;
144
147
  ;
148
+ /**
149
+ * Alpen chain initializer instance
150
+ * @category Networks/Alpen
151
+ */
145
152
  exports.AlpenInitializer = {
146
153
  chainId: "ALPEN",
147
154
  chainType: null,
@@ -1,6 +1,6 @@
1
1
  import { ChainType } from "@atomiqlabs/base";
2
2
  import { EVMPreFetchVerification } from "../../evm/swaps/modules/EVMSwapInit";
3
- import { EVMTx } from "../../evm/chain/modules/EVMTransactions";
3
+ import { EVMTx, SignedEVMTx } from "../../evm/chain/modules/EVMTransactions";
4
4
  import { EVMSigner } from "../../evm/wallet/EVMSigner";
5
5
  import { EVMSwapData } from "../../evm/swaps/EVMSwapData";
6
6
  import { EVMChainInterface } from "../../evm/chain/EVMChainInterface";
@@ -11,4 +11,8 @@ import { EVMSwapContract } from "../../evm/swaps/EVMSwapContract";
11
11
  import { EVMBtcRelay } from "../../evm/btcrelay/EVMBtcRelay";
12
12
  import { EVMSpvVaultContract } from "../../evm/spv_swap/EVMSpvVaultContract";
13
13
  import { Signer } from "ethers";
14
- export type BotanixChainType = ChainType<"BOTANIX", never, EVMPreFetchVerification, EVMTx, EVMSigner, Signer, EVMSwapData, EVMSwapContract<"BOTANIX">, EVMChainInterface<"BOTANIX">, EVMChainEventsBrowser, EVMBtcRelay<any>, EVMSpvVaultData, EVMSpvWithdrawalData, EVMSpvVaultContract<"BOTANIX">>;
14
+ /**
15
+ * Type definition for the Botanix chain implementation
16
+ * @category Networks/Botanix
17
+ */
18
+ export type BotanixChainType = ChainType<"BOTANIX", never, EVMPreFetchVerification, EVMTx, SignedEVMTx, EVMSigner, Signer, EVMSwapData, EVMSwapContract<"BOTANIX">, EVMChainInterface<"BOTANIX">, EVMChainEventsBrowser, EVMBtcRelay<any>, EVMSpvWithdrawalData, EVMSpvVaultData, EVMSpvVaultContract<"BOTANIX">>;
@@ -3,8 +3,20 @@ import { JsonRpcApiProvider } from "ethers";
3
3
  import { EVMConfiguration, EVMRetryPolicy } from "../../evm/chain/EVMChainInterface";
4
4
  import { EVMFees } from "../../evm/chain/modules/EVMFees";
5
5
  import { BotanixChainType } from "./BotanixChainType";
6
+ /**
7
+ * Token assets available on Botanix
8
+ * @category Networks/Botanix
9
+ */
6
10
  export type BotanixAssetsType = BaseTokenType<"BTC">;
11
+ /**
12
+ * Default Botanix token assets configuration
13
+ * @category Networks/Botanix
14
+ */
7
15
  export declare const BotanixAssets: BotanixAssetsType;
16
+ /**
17
+ * Configuration options for initializing Botanix chain
18
+ * @category Networks/Botanix
19
+ */
8
20
  export type BotanixOptions = {
9
21
  rpcUrl: string | JsonRpcApiProvider;
10
22
  retryPolicy?: EVMRetryPolicy;
@@ -25,6 +37,18 @@ export type BotanixOptions = {
25
37
  fees?: EVMFees;
26
38
  evmConfig?: Omit<EVMConfiguration, "safeBlockTag" | "finalizedBlockTag">;
27
39
  };
40
+ /**
41
+ * Initialize Botanix chain integration
42
+ * @category Networks/Botanix
43
+ */
28
44
  export declare function initializeBotanix(options: BotanixOptions, bitcoinRpc: BitcoinRpc<any>, network: BitcoinNetwork): ChainData<BotanixChainType>;
45
+ /**
46
+ * Type definition for the Botanix chain initializer
47
+ * @category Networks/Botanix
48
+ */
29
49
  export type BotanixInitializerType = ChainInitializer<BotanixOptions, BotanixChainType, BotanixAssetsType>;
50
+ /**
51
+ * Botanix chain initializer instance
52
+ * @category Networks/Botanix
53
+ */
30
54
  export declare const BotanixInitializer: BotanixInitializerType;
@@ -56,6 +56,14 @@ const BotanixContractAddresses = {
56
56
  }
57
57
  }
58
58
  };
59
+ const chainTypeMapping = {
60
+ [base_1.BitcoinNetwork.MAINNET]: "MAINNET",
61
+ [base_1.BitcoinNetwork.TESTNET]: "TESTNET",
62
+ };
63
+ /**
64
+ * Default Botanix token assets configuration
65
+ * @category Networks/Botanix
66
+ */
59
67
  exports.BotanixAssets = {
60
68
  BTC: {
61
69
  address: "0x0000000000000000000000000000000000000000",
@@ -63,17 +71,14 @@ exports.BotanixAssets = {
63
71
  displayDecimals: 8
64
72
  }
65
73
  };
74
+ /**
75
+ * Initialize Botanix chain integration
76
+ * @category Networks/Botanix
77
+ */
66
78
  function initializeBotanix(options, bitcoinRpc, network) {
67
- if (options.chainType == null) {
68
- switch (network) {
69
- case base_1.BitcoinNetwork.MAINNET:
70
- options.chainType = "MAINNET";
71
- break;
72
- case base_1.BitcoinNetwork.TESTNET:
73
- options.chainType = "TESTNET";
74
- break;
75
- }
76
- }
79
+ options.chainType ?? (options.chainType = chainTypeMapping[network]);
80
+ if (options.chainType == null)
81
+ throw new Error("Please specify chainType in options!");
77
82
  const defaultContractAddresses = BotanixContractAddresses[options.chainType];
78
83
  const chainId = BotanixChainIds[options.chainType];
79
84
  const provider = typeof (options.rpcUrl) === "string" ?
@@ -123,6 +128,10 @@ function initializeBotanix(options, bitcoinRpc, network) {
123
128
  }
124
129
  exports.initializeBotanix = initializeBotanix;
125
130
  ;
131
+ /**
132
+ * Botanix chain initializer instance
133
+ * @category Networks/Botanix
134
+ */
126
135
  exports.BotanixInitializer = {
127
136
  chainId: "BOTANIX",
128
137
  chainType: null,
@@ -15,6 +15,8 @@ class CitreaBtcRelay extends EVMBtcRelay_1.EVMBtcRelay {
15
15
  async estimateSynchronizeFee(requiredBlockheight, feeRate) {
16
16
  feeRate ?? (feeRate = await this.Chain.Fees.getFeeRate());
17
17
  const tipData = await this.getTipData();
18
+ if (tipData == null)
19
+ throw new Error("Cannot get relay tip data, relay not initialized?");
18
20
  const currBlockheight = tipData.blockheight;
19
21
  const blockheightDelta = requiredBlockheight - currBlockheight;
20
22
  if (blockheightDelta <= 0)
@@ -1,6 +1,6 @@
1
1
  import { ChainType } from "@atomiqlabs/base";
2
2
  import { EVMPreFetchVerification } from "../../evm/swaps/modules/EVMSwapInit";
3
- import { EVMTx } from "../../evm/chain/modules/EVMTransactions";
3
+ import { EVMTx, SignedEVMTx } from "../../evm/chain/modules/EVMTransactions";
4
4
  import { EVMSigner } from "../../evm/wallet/EVMSigner";
5
5
  import { EVMSwapData } from "../../evm/swaps/EVMSwapData";
6
6
  import { EVMChainInterface } from "../../evm/chain/EVMChainInterface";
@@ -11,4 +11,8 @@ import { CitreaSwapContract } from "./CitreaSwapContract";
11
11
  import { CitreaBtcRelay } from "./CitreaBtcRelay";
12
12
  import { CitreaSpvVaultContract } from "./CitreaSpvVaultContract";
13
13
  import { Signer } from "ethers";
14
- export type CitreaChainType = ChainType<"CITREA", never, EVMPreFetchVerification, EVMTx, EVMSigner, Signer, EVMSwapData, CitreaSwapContract, EVMChainInterface<"CITREA">, EVMChainEventsBrowser, CitreaBtcRelay<any>, EVMSpvVaultData, EVMSpvWithdrawalData, CitreaSpvVaultContract>;
14
+ /**
15
+ * Type definition for the Citrea chain implementation
16
+ * @category Networks/Citrea
17
+ */
18
+ export type CitreaChainType = ChainType<"CITREA", never, EVMPreFetchVerification, EVMTx, SignedEVMTx, EVMSigner, Signer, EVMSwapData, CitreaSwapContract, EVMChainInterface<"CITREA">, EVMChainEventsBrowser, CitreaBtcRelay<any>, EVMSpvWithdrawalData, EVMSpvVaultData, CitreaSpvVaultContract>;
@@ -1,10 +1,13 @@
1
1
  import { EVMFees } from "../../evm/chain/modules/EVMFees";
2
+ /**
3
+ * @category Networks/Citrea
4
+ */
2
5
  export declare class CitreaFees extends EVMFees {
3
6
  static readonly StateDiffSize: {
4
7
  APPROVE_DIFF_SIZE: number;
5
8
  };
6
9
  protected readonly logger: import("../../utils/Utils").LoggerType;
7
- private _blockFeeCache;
10
+ private _blockFeeCache?;
8
11
  /**
9
12
  * Gets evm fee rate
10
13
  *
@@ -3,11 +3,13 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.CitreaFees = void 0;
4
4
  const EVMFees_1 = require("../../evm/chain/modules/EVMFees");
5
5
  const Utils_1 = require("../../utils/Utils");
6
+ /**
7
+ * @category Networks/Citrea
8
+ */
6
9
  class CitreaFees extends EVMFees_1.EVMFees {
7
10
  constructor() {
8
11
  super(...arguments);
9
12
  this.logger = (0, Utils_1.getLogger)("CitreaFees: ");
10
- this._blockFeeCache = null;
11
13
  }
12
14
  /**
13
15
  * Gets evm fee rate
@@ -29,16 +31,15 @@ class CitreaFees extends EVMFees_1.EVMFees {
29
31
  */
30
32
  async getFeeRate() {
31
33
  if (this._blockFeeCache == null || Date.now() - this._blockFeeCache.timestamp > this.MAX_FEE_AGE) {
32
- let obj = {
34
+ let obj;
35
+ this._blockFeeCache = obj = {
33
36
  timestamp: Date.now(),
34
- feeRate: null
37
+ feeRate: this.__getFeeRate().catch(e => {
38
+ if (this._blockFeeCache === obj)
39
+ delete this._blockFeeCache;
40
+ throw e;
41
+ })
35
42
  };
36
- obj.feeRate = this.__getFeeRate().catch(e => {
37
- if (this._blockFeeCache === obj)
38
- this._blockFeeCache = null;
39
- throw e;
40
- });
41
- this._blockFeeCache = obj;
42
43
  }
43
44
  let { baseFee, l1Fee } = await this._blockFeeCache.feeRate;
44
45
  if (baseFee > this.maxFeeRatePerGas)
@@ -3,8 +3,20 @@ import { JsonRpcApiProvider } from "ethers";
3
3
  import { EVMConfiguration, EVMRetryPolicy } from "../../evm/chain/EVMChainInterface";
4
4
  import { CitreaChainType } from "./CitreaChainType";
5
5
  import { CitreaFees } from "./CitreaFees";
6
+ /**
7
+ * Token assets available on Citrea
8
+ * @category Networks/Citrea
9
+ */
6
10
  export type CitreaAssetsType = BaseTokenType<"CBTC" | "WBTC" | "USDC">;
11
+ /**
12
+ * Default Citrea token assets configuration
13
+ * @category Networks/Citrea
14
+ */
7
15
  export declare const CitreaAssets: CitreaAssetsType;
16
+ /**
17
+ * Configuration options for initializing Citrea chain
18
+ * @category Networks/Citrea
19
+ */
8
20
  export type CitreaOptions = {
9
21
  rpcUrl: string | JsonRpcApiProvider;
10
22
  retryPolicy?: EVMRetryPolicy;
@@ -25,6 +37,18 @@ export type CitreaOptions = {
25
37
  fees?: CitreaFees;
26
38
  evmConfig?: Omit<EVMConfiguration, "safeBlockTag" | "finalizedBlockTag">;
27
39
  };
40
+ /**
41
+ * Initialize Citrea chain integration
42
+ * @category Networks/Citrea
43
+ */
28
44
  export declare function initializeCitrea(options: CitreaOptions, bitcoinRpc: BitcoinRpc<any>, network: BitcoinNetwork): ChainData<CitreaChainType>;
45
+ /**
46
+ * Type definition for the Citrea chain initializer
47
+ * @category Networks/Citrea
48
+ */
29
49
  export type CitreaInitializerType = ChainInitializer<CitreaOptions, CitreaChainType, CitreaAssetsType>;
50
+ /**
51
+ * Citrea chain initializer instance
52
+ * @category Networks/Citrea
53
+ */
30
54
  export declare const CitreaInitializer: CitreaInitializerType;
@@ -57,6 +57,14 @@ const CitreaContractAddresses = {
57
57
  }
58
58
  }
59
59
  };
60
+ const chainTypeMapping = {
61
+ [base_1.BitcoinNetwork.MAINNET]: "MAINNET",
62
+ [base_1.BitcoinNetwork.TESTNET4]: "TESTNET4",
63
+ };
64
+ /**
65
+ * Default Citrea token assets configuration
66
+ * @category Networks/Citrea
67
+ */
60
68
  exports.CitreaAssets = {
61
69
  CBTC: {
62
70
  address: "0x0000000000000000000000000000000000000000",
@@ -69,24 +77,23 @@ exports.CitreaAssets = {
69
77
  displayDecimals: 8
70
78
  },
71
79
  USDC: {
72
- address: "0x2C8abD2A528D19AFc33d2ebA507c0F405c131335",
80
+ address: "0xE045e6c36cF77FAA2CfB54466D71A3aEF7bbE839",
73
81
  decimals: 6,
74
82
  displayDecimals: 6
75
83
  }
76
84
  };
85
+ /**
86
+ * Initialize Citrea chain integration
87
+ * @category Networks/Citrea
88
+ */
77
89
  function initializeCitrea(options, bitcoinRpc, network) {
78
- if (options.chainType == null) {
79
- switch (network) {
80
- case base_1.BitcoinNetwork.TESTNET4:
81
- options.chainType = "TESTNET4";
82
- break;
83
- case base_1.BitcoinNetwork.MAINNET:
84
- options.chainType = "MAINNET";
85
- break;
86
- }
87
- }
90
+ options.chainType ?? (options.chainType = chainTypeMapping[network]);
91
+ if (options.chainType == null)
92
+ throw new Error("Please specify chainType in options!");
88
93
  const defaultContractAddresses = CitreaContractAddresses[options.chainType];
89
94
  const chainId = CitreaChainIds[options.chainType];
95
+ if (chainId == null)
96
+ throw new Error("Invalid chainId due to wrong chainType specified, check the passed chainType!");
90
97
  const provider = typeof (options.rpcUrl) === "string" ?
91
98
  (options.rpcUrl.startsWith("ws")
92
99
  ? new ethers_1.WebSocketProvider(options.rpcUrl, { name: "Citrea", chainId })
@@ -131,6 +138,10 @@ function initializeCitrea(options, bitcoinRpc, network) {
131
138
  }
132
139
  exports.initializeCitrea = initializeCitrea;
133
140
  ;
141
+ /**
142
+ * Citrea chain initializer instance
143
+ * @category Networks/Citrea
144
+ */
134
145
  exports.CitreaInitializer = {
135
146
  chainId: "CITREA",
136
147
  chainType: null,
@@ -1,6 +1,6 @@
1
1
  import { ChainType } from "@atomiqlabs/base";
2
2
  import { EVMPreFetchVerification } from "../../evm/swaps/modules/EVMSwapInit";
3
- import { EVMTx } from "../../evm/chain/modules/EVMTransactions";
3
+ import { EVMTx, SignedEVMTx } from "../../evm/chain/modules/EVMTransactions";
4
4
  import { EVMSigner } from "../../evm/wallet/EVMSigner";
5
5
  import { EVMSwapData } from "../../evm/swaps/EVMSwapData";
6
6
  import { EVMChainInterface } from "../../evm/chain/EVMChainInterface";
@@ -11,4 +11,8 @@ import { EVMSwapContract } from "../../evm/swaps/EVMSwapContract";
11
11
  import { EVMBtcRelay } from "../../evm/btcrelay/EVMBtcRelay";
12
12
  import { EVMSpvVaultContract } from "../../evm/spv_swap/EVMSpvVaultContract";
13
13
  import { Signer } from "ethers";
14
- export type GoatChainType = ChainType<"GOAT", never, EVMPreFetchVerification, EVMTx, EVMSigner, Signer, EVMSwapData, EVMSwapContract<"GOAT">, EVMChainInterface<"GOAT">, EVMChainEventsBrowser, EVMBtcRelay<any>, EVMSpvVaultData, EVMSpvWithdrawalData, EVMSpvVaultContract<"GOAT">>;
14
+ /**
15
+ * Type definition for the GOAT Network chain implementation
16
+ * @category Networks/GOAT
17
+ */
18
+ export type GoatChainType = ChainType<"GOAT", never, EVMPreFetchVerification, EVMTx, SignedEVMTx, EVMSigner, Signer, EVMSwapData, EVMSwapContract<"GOAT">, EVMChainInterface<"GOAT">, EVMChainEventsBrowser, EVMBtcRelay<any>, EVMSpvWithdrawalData, EVMSpvVaultData, EVMSpvVaultContract<"GOAT">>;
@@ -3,8 +3,20 @@ import { JsonRpcApiProvider } from "ethers";
3
3
  import { EVMConfiguration, EVMRetryPolicy } from "../../evm/chain/EVMChainInterface";
4
4
  import { EVMFees } from "../../evm/chain/modules/EVMFees";
5
5
  import { GoatChainType } from "./GoatChainType";
6
+ /**
7
+ * Token assets available on GOAT Network
8
+ * @category Networks/GOAT
9
+ */
6
10
  export type GoatAssetsType = BaseTokenType<"BTC" | "PBTC" | "_PBTC_DEV">;
11
+ /**
12
+ * Default GOAT Network token assets configuration
13
+ * @category Networks/GOAT
14
+ */
7
15
  export declare const GoatAssets: GoatAssetsType;
16
+ /**
17
+ * Configuration options for initializing GOAT Network chain
18
+ * @category Networks/GOAT
19
+ */
8
20
  export type GoatOptions = {
9
21
  rpcUrl: string | JsonRpcApiProvider;
10
22
  retryPolicy?: EVMRetryPolicy;
@@ -25,6 +37,18 @@ export type GoatOptions = {
25
37
  fees?: EVMFees;
26
38
  evmConfig?: Omit<EVMConfiguration, "safeBlockTag" | "finalizedBlockTag">;
27
39
  };
40
+ /**
41
+ * Initialize GOAT Network chain integration
42
+ * @category Networks/GOAT
43
+ */
28
44
  export declare function initializeGoat(options: GoatOptions, bitcoinRpc: BitcoinRpc<any>, network: BitcoinNetwork): ChainData<GoatChainType>;
45
+ /**
46
+ * Type definition for the GOAT Network chain initializer
47
+ * @category Networks/GOAT
48
+ */
29
49
  export type GoatInitializerType = ChainInitializer<GoatOptions, GoatChainType, GoatAssetsType>;
50
+ /**
51
+ * GOAT Network chain initializer instance
52
+ * @category Networks/GOAT
53
+ */
30
54
  export declare const GoatInitializer: GoatInitializerType;
@@ -76,6 +76,15 @@ const GoatContractAddresses = {
76
76
  }
77
77
  }
78
78
  };
79
+ const chainTypeMapping = {
80
+ [base_1.BitcoinNetwork.MAINNET]: "MAINNET",
81
+ [base_1.BitcoinNetwork.TESTNET]: "TESTNET",
82
+ [base_1.BitcoinNetwork.TESTNET4]: "TESTNET4",
83
+ };
84
+ /**
85
+ * Default GOAT Network token assets configuration
86
+ * @category Networks/GOAT
87
+ */
79
88
  exports.GoatAssets = {
80
89
  BTC: {
81
90
  address: "0x0000000000000000000000000000000000000000",
@@ -93,20 +102,14 @@ exports.GoatAssets = {
93
102
  displayDecimals: 8
94
103
  }
95
104
  };
105
+ /**
106
+ * Initialize GOAT Network chain integration
107
+ * @category Networks/GOAT
108
+ */
96
109
  function initializeGoat(options, bitcoinRpc, network) {
97
- if (options.chainType == null) {
98
- switch (network) {
99
- case base_1.BitcoinNetwork.MAINNET:
100
- options.chainType = "MAINNET";
101
- break;
102
- case base_1.BitcoinNetwork.TESTNET:
103
- options.chainType = "TESTNET";
104
- break;
105
- case base_1.BitcoinNetwork.TESTNET4:
106
- options.chainType = "TESTNET4";
107
- break;
108
- }
109
- }
110
+ options.chainType ?? (options.chainType = chainTypeMapping[network]);
111
+ if (options.chainType == null)
112
+ throw new Error("Please specify chainType in options!");
110
113
  const defaultContractAddresses = GoatContractAddresses[options.chainType];
111
114
  const chainId = GoatChainIds[options.chainType];
112
115
  const provider = typeof (options.rpcUrl) === "string" ?
@@ -152,6 +155,10 @@ function initializeGoat(options, bitcoinRpc, network) {
152
155
  }
153
156
  exports.initializeGoat = initializeGoat;
154
157
  ;
158
+ /**
159
+ * GOAT Network chain initializer instance
160
+ * @category Networks/GOAT
161
+ */
155
162
  exports.GoatInitializer = {
156
163
  chainId: "GOAT",
157
164
  chainType: null,
@@ -8,6 +8,9 @@ import { EVMBtcStoredHeader } from "./headers/EVMBtcStoredHeader";
8
8
  import { EVMSigner } from "../wallet/EVMSigner";
9
9
  import { EVMTx } from "../chain/modules/EVMTransactions";
10
10
  import { EVMChainInterface } from "../chain/EVMChainInterface";
11
+ /**
12
+ * @category BTC Relay
13
+ */
11
14
  export declare class EVMBtcRelay<B extends BtcBlock> extends EVMContractBase<BtcRelayTypechain> implements BtcRelay<EVMBtcStoredHeader, EVMTx, B, EVMSigner> {
12
15
  static GasCosts: {
13
16
  GAS_PER_BLOCKHEADER: number;
@@ -39,7 +42,6 @@ export declare class EVMBtcRelay<B extends BtcBlock> extends EVMContractBase<Btc
39
42
  * @param signer
40
43
  * @param headers headers to sync to the btc relay
41
44
  * @param storedHeader current latest stored block header for a given fork
42
- * @param tipWork work of the current tip in a given fork
43
45
  * @param forkId forkId to submit to, forkId=0 means main chain, forkId=-1 means short fork
44
46
  * @param feeRate feeRate for the transaction
45
47
  * @param totalForkHeaders Total number of headers in a fork
@@ -59,7 +61,7 @@ export declare class EVMBtcRelay<B extends BtcBlock> extends EVMContractBase<Btc
59
61
  blockhash: string;
60
62
  chainWork: Buffer;
61
63
  blockheight: number;
62
- }>;
64
+ } | null>;
63
65
  /**
64
66
  * Retrieves blockheader with a specific blockhash, returns null if requiredBlockheight is provided and
65
67
  * btc relay contract is not synced up to the desired blockheight
@@ -72,7 +74,7 @@ export declare class EVMBtcRelay<B extends BtcBlock> extends EVMContractBase<Btc
72
74
  }, requiredBlockheight?: number): Promise<{
73
75
  header: EVMBtcStoredHeader;
74
76
  height: number;
75
- }>;
77
+ } | null>;
76
78
  /**
77
79
  * Retrieves blockheader data by blockheader's commit hash,
78
80
  *
@@ -81,14 +83,14 @@ export declare class EVMBtcRelay<B extends BtcBlock> extends EVMContractBase<Btc
81
83
  */
82
84
  retrieveLogByCommitHash(commitmentHashStr: string, blockData: {
83
85
  blockhash: string;
84
- }): Promise<EVMBtcStoredHeader>;
86
+ }): Promise<EVMBtcStoredHeader | null>;
85
87
  /**
86
88
  * Retrieves latest known stored blockheader & blockheader from bitcoin RPC that is in the main chain
87
89
  */
88
90
  retrieveLatestKnownBlockLog(): Promise<{
89
91
  resultStoredHeader: EVMBtcStoredHeader;
90
92
  resultBitcoinHeader: B;
91
- }>;
93
+ } | null>;
92
94
  /**
93
95
  * Saves blockheaders as a bitcoin main chain to the btc relay
94
96
  *
@@ -193,5 +195,5 @@ export declare class EVMBtcRelay<B extends BtcBlock> extends EVMContractBase<Btc
193
195
  blockhash: string;
194
196
  }[], txs: EVMTx[], synchronizer?: RelaySynchronizer<EVMBtcStoredHeader, EVMTx, any>, feeRate?: string): Promise<{
195
197
  [blockhash: string]: EVMBtcStoredHeader;
196
- }>;
198
+ } | null>;
197
199
  }