@atomiqlabs/base 13.3.0 → 13.4.2

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.
@@ -1,4 +1,5 @@
1
1
  /// <reference types="node" />
2
+ import { BitcoinNetwork } from "../btc/BitcoinNetwork";
2
3
  /**
3
4
  * @category Chains
4
5
  */
@@ -118,6 +119,12 @@ export interface ChainInterface<TX = any, SignedTX = any, Signer extends Abstrac
118
119
  * @param txData Serialized transaction data string
119
120
  */
120
121
  deserializeSignedTx(txData: string): Promise<SignedTX>;
122
+ /**
123
+ * Returns the transaction ID of the signed transaction
124
+ *
125
+ * @param signedTX Signed transaction to get the transaction ID of
126
+ */
127
+ getTxId?(signedTX: SignedTX): Promise<string>;
121
128
  /**
122
129
  * Returns the status of the given serialized transaction
123
130
  *
@@ -185,4 +192,11 @@ export interface ChainInterface<TX = any, SignedTX = any, Signer extends Abstrac
185
192
  * Wraps a native chain signer object to an atomiq-understandable AbstractSigner
186
193
  */
187
194
  wrapSigner(signer: NativeSigner): Promise<Signer>;
195
+ /**
196
+ * Verifies whether the set network of this chain interface matches the passed bitcoin network (i.e. mainnet should
197
+ * use mainnet networks and testnets should use testnet networks)
198
+ *
199
+ * @throws {Error} When the underlying network doesn't match
200
+ */
201
+ verifyNetwork?(bitcoinNetwork: BitcoinNetwork): Promise<void>;
188
202
  }
@@ -32,6 +32,7 @@ export declare enum SwapCommitStateType {
32
32
  */
33
33
  export type SwapNotCommitedState = {
34
34
  type: SwapCommitStateType.NOT_COMMITED;
35
+ getInitTxId?: () => Promise<string>;
35
36
  getRefundTxId?: () => Promise<string>;
36
37
  getTxBlock?: () => Promise<{
37
38
  blockHeight: number;
@@ -45,6 +46,7 @@ export type SwapNotCommitedState = {
45
46
  */
46
47
  export type SwapExpiredState = {
47
48
  type: SwapCommitStateType.EXPIRED;
49
+ getInitTxId?: () => Promise<string>;
48
50
  getRefundTxId?: () => Promise<string>;
49
51
  getTxBlock?: () => Promise<{
50
52
  blockHeight: number;
@@ -58,6 +60,7 @@ export type SwapExpiredState = {
58
60
  */
59
61
  export type SwapRefundableState = {
60
62
  type: SwapCommitStateType.REFUNDABLE;
63
+ getInitTxId?: () => Promise<string>;
61
64
  };
62
65
  /**
63
66
  * The escrow is active on-chain and can be claimed
@@ -66,6 +69,7 @@ export type SwapRefundableState = {
66
69
  */
67
70
  export type SwapCommitedState = {
68
71
  type: SwapCommitStateType.COMMITED;
72
+ getInitTxId?: () => Promise<string>;
69
73
  };
70
74
  /**
71
75
  * The escrow has been finalized and funds claimed by the claimer
@@ -74,6 +78,7 @@ export type SwapCommitedState = {
74
78
  */
75
79
  export type SwapPaidState = {
76
80
  type: SwapCommitStateType.PAID;
81
+ getInitTxId?: () => Promise<string>;
77
82
  getClaimTxId: () => Promise<string>;
78
83
  getClaimResult: () => Promise<string>;
79
84
  getTxBlock: () => Promise<{
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atomiqlabs/base",
3
- "version": "13.3.0",
3
+ "version": "13.4.2",
4
4
  "description": "Base classes and interfaces for atomiq protocol",
5
5
  "main": "./dist/index.js",
6
6
  "types:": "./dist/index.d.ts",
@@ -1,3 +1,5 @@
1
+ import {BitcoinNetwork} from "../btc/BitcoinNetwork";
2
+
1
3
  /**
2
4
  * @category Chains
3
5
  */
@@ -142,6 +144,13 @@ export interface ChainInterface<
142
144
  */
143
145
  deserializeSignedTx(txData: string): Promise<SignedTX>;
144
146
 
147
+ /**
148
+ * Returns the transaction ID of the signed transaction
149
+ *
150
+ * @param signedTX Signed transaction to get the transaction ID of
151
+ */
152
+ getTxId?(signedTX: SignedTX): Promise<string>;
153
+
145
154
  /**
146
155
  * Returns the status of the given serialized transaction
147
156
  *
@@ -216,4 +225,12 @@ export interface ChainInterface<
216
225
  */
217
226
  wrapSigner(signer: NativeSigner): Promise<Signer>;
218
227
 
228
+ /**
229
+ * Verifies whether the set network of this chain interface matches the passed bitcoin network (i.e. mainnet should
230
+ * use mainnet networks and testnets should use testnet networks)
231
+ *
232
+ * @throws {Error} When the underlying network doesn't match
233
+ */
234
+ verifyNetwork?(bitcoinNetwork: BitcoinNetwork): Promise<void>;
235
+
219
236
  }
@@ -33,6 +33,7 @@ export enum SwapCommitStateType {
33
33
  */
34
34
  export type SwapNotCommitedState = {
35
35
  type: SwapCommitStateType.NOT_COMMITED,
36
+ getInitTxId?: () => Promise<string>,
36
37
  getRefundTxId?: () => Promise<string>,
37
38
  getTxBlock?: () => Promise<{blockHeight: number, blockTime: number}>
38
39
  };
@@ -44,6 +45,7 @@ export type SwapNotCommitedState = {
44
45
  */
45
46
  export type SwapExpiredState = {
46
47
  type: SwapCommitStateType.EXPIRED,
48
+ getInitTxId?: () => Promise<string>,
47
49
  getRefundTxId?: () => Promise<string>,
48
50
  getTxBlock?: () => Promise<{blockHeight: number, blockTime: number}>
49
51
  };
@@ -54,7 +56,8 @@ export type SwapExpiredState = {
54
56
  * @category Swaps
55
57
  */
56
58
  export type SwapRefundableState = {
57
- type: SwapCommitStateType.REFUNDABLE
59
+ type: SwapCommitStateType.REFUNDABLE,
60
+ getInitTxId?: () => Promise<string>
58
61
  };
59
62
 
60
63
  /**
@@ -63,7 +66,8 @@ export type SwapRefundableState = {
63
66
  * @category Swaps
64
67
  */
65
68
  export type SwapCommitedState = {
66
- type: SwapCommitStateType.COMMITED
69
+ type: SwapCommitStateType.COMMITED,
70
+ getInitTxId?: () => Promise<string>
67
71
  };
68
72
 
69
73
  /**
@@ -73,6 +77,7 @@ export type SwapCommitedState = {
73
77
  */
74
78
  export type SwapPaidState = {
75
79
  type: SwapCommitStateType.PAID,
80
+ getInitTxId?: () => Promise<string>,
76
81
  getClaimTxId: () => Promise<string>,
77
82
  getClaimResult: () => Promise<string>,
78
83
  getTxBlock: () => Promise<{blockHeight: number, blockTime: number}>