@atomiqlabs/base 10.0.0-dev.10 → 10.0.0-dev.14

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -8,7 +8,7 @@ export type AbstractSigner = {
8
8
  init?: () => Promise<void>;
9
9
  stop?: () => Promise<void>;
10
10
  };
11
- export interface ChainInterface<TX = any, Signer extends AbstractSigner = AbstractSigner, ChainId extends string = string> {
11
+ export interface ChainInterface<TX = any, Signer extends AbstractSigner = AbstractSigner, ChainId extends string = string, NativeSigner = any> {
12
12
  readonly chainId: ChainId;
13
13
  /**
14
14
  * Returns the token balance of a specific address
@@ -109,4 +109,8 @@ export interface ChainInterface<TX = any, Signer extends AbstractSigner = Abstra
109
109
  * Returns randomly generated signer
110
110
  */
111
111
  randomSigner(): Signer;
112
+ /**
113
+ * Wraps a native chain signer object to an atomiq-understandable AbstractSigner
114
+ */
115
+ wrapSigner(signer: NativeSigner): Signer;
112
116
  }
@@ -6,7 +6,7 @@ import { AbstractSigner, ChainInterface } from "./ChainInterface";
6
6
  import { SpvVaultData } from "../spv_swap/SpvVaultData";
7
7
  import { SpvVaultContract } from "../spv_swap/SpvVaultContract";
8
8
  import { SpvWithdrawalTransactionData } from "../spv_swap/SpvWithdrawalTransactionData";
9
- export type ChainType<ChainId extends string = string, PreFetchData = any, PreFetchVerification = any, TXType = any, Signer extends AbstractSigner = AbstractSigner, T extends SwapData = SwapData, C extends SwapContract<T, TXType, PreFetchData, PreFetchVerification, Signer, ChainId> = SwapContract<T, TXType, PreFetchData, PreFetchVerification, Signer, ChainId>, I extends ChainInterface<TXType, Signer, ChainId> = ChainInterface<TXType, Signer, ChainId>, E extends ChainEvents<T> = ChainEvents<T>, B extends BtcRelay<any, TXType, any, Signer> = BtcRelay<any, TXType, any, Signer>, SpvData extends SpvVaultData = SpvVaultData, SpvWithdrawalData extends SpvWithdrawalTransactionData = SpvWithdrawalTransactionData, SpvContract extends SpvVaultContract<TXType, Signer, ChainId, SpvData, SpvWithdrawalData> = SpvVaultContract<TXType, Signer, ChainId, SpvData, SpvWithdrawalData>> = {
9
+ export type ChainType<ChainId extends string = string, PreFetchData = any, PreFetchVerification = any, TXType = any, Signer extends AbstractSigner = AbstractSigner, NativeSigner = any, T extends SwapData = SwapData, C extends SwapContract<T, TXType, PreFetchData, PreFetchVerification, Signer, ChainId> = SwapContract<T, TXType, PreFetchData, PreFetchVerification, Signer, ChainId>, I extends ChainInterface<TXType, Signer, ChainId, NativeSigner> = ChainInterface<TXType, Signer, ChainId, NativeSigner>, E extends ChainEvents<T> = ChainEvents<T>, B extends BtcRelay<any, TXType, any, Signer> = BtcRelay<any, TXType, any, Signer>, SpvData extends SpvVaultData = SpvVaultData, SpvWithdrawalData extends SpvWithdrawalTransactionData = SpvWithdrawalTransactionData, SpvContract extends SpvVaultContract<TXType, Signer, ChainId, SpvData, SpvWithdrawalData> = SpvVaultContract<TXType, Signer, ChainId, SpvData, SpvWithdrawalData>> = {
10
10
  ChainId: ChainId;
11
11
  PreFetchData: PreFetchData;
12
12
  PreFetchVerification: PreFetchVerification;
@@ -20,4 +20,5 @@ export type ChainType<ChainId extends string = string, PreFetchData = any, PreFe
20
20
  SpvVaultData: SpvData;
21
21
  SpvVaultContract: SpvContract;
22
22
  SpvVaultWithdrawalData: SpvWithdrawalData;
23
+ NativeSigner: NativeSigner;
23
24
  };
@@ -111,6 +111,18 @@ export interface SpvVaultContract<TX = any, Signer extends AbstractSigner = Abst
111
111
  * @param withdrawal Withdrawal transaction to check the fronting for
112
112
  */
113
113
  getFronterAddress(owner: string, vaultId: bigint, withdrawal: WithdrawalTX): Promise<string | null>;
114
+ /**
115
+ * Returns the parties which currently fronted the withdrawal transactions
116
+ *
117
+ * @param withdrawals withdrawals to query
118
+ */
119
+ getFronterAddresses(withdrawals: {
120
+ owner: string;
121
+ vaultId: bigint;
122
+ withdrawal: WithdrawalTX;
123
+ }[]): Promise<{
124
+ [btcTxId: string]: string | null;
125
+ }>;
114
126
  /**
115
127
  * Returns current vault data
116
128
  *
@@ -118,6 +130,39 @@ export interface SpvVaultContract<TX = any, Signer extends AbstractSigner = Abst
118
130
  * @param vaultId Vault ID
119
131
  */
120
132
  getVaultData(owner: string, vaultId: bigint): Promise<Data>;
133
+ /**
134
+ * Returns current vault data for multiple vaults
135
+ *
136
+ * @param vaults Vault data to query
137
+ */
138
+ getMultipleVaultData(vaults: {
139
+ owner: string;
140
+ vaultId: bigint;
141
+ }[]): Promise<{
142
+ [owner: string]: {
143
+ [vaultId: string]: Data;
144
+ };
145
+ }>;
146
+ /**
147
+ * Returns the latest utxo of a vault (or null if vault closed or not found)
148
+ *
149
+ * @param owner Owner of the vault
150
+ * @param vaultId Vault ID
151
+ */
152
+ getVaultLatestUtxo(owner: string, vaultId: bigint): Promise<string | null>;
153
+ /**
154
+ * Returns the latest utxos of for multiple vaults (or null if vault closed or not found)
155
+ *
156
+ * @param vaults Vault data to query
157
+ */
158
+ getVaultLatestUtxos(vaults: {
159
+ owner: string;
160
+ vaultId: bigint;
161
+ }[]): Promise<{
162
+ [owner: string]: {
163
+ [vaultId: string]: string | null;
164
+ };
165
+ }>;
121
166
  /**
122
167
  * Returns all currently opened vaults
123
168
  * NOTE: This will take a long time, since the implementation will have to go through all the prior events
@@ -129,6 +174,14 @@ export interface SpvVaultContract<TX = any, Signer extends AbstractSigner = Abst
129
174
  * @param btcTxId
130
175
  */
131
176
  getWithdrawalState(btcTxId: string): Promise<SpvWithdrawalState>;
177
+ /**
178
+ * Returns current state of the withdrawals as specified by the bitcoin transaction IDs
179
+ *
180
+ * @param btcTxIds
181
+ */
182
+ getWithdrawalStates(btcTxIds: string[]): Promise<{
183
+ [btcTxId: string]: SpvWithdrawalState;
184
+ }>;
132
185
  /**
133
186
  * Parses withdrawal data from the parsed bitcoin transaction
134
187
  *
@@ -190,6 +190,17 @@ export interface SwapContract<T extends SwapData = SwapData, TX = any, PreFetchD
190
190
  * @param swapData
191
191
  */
192
192
  getCommitStatus(signer: string, swapData: T): Promise<SwapCommitState>;
193
+ /**
194
+ * Returns the full status of the passed swaps, expiry is handled by the isExpired function so also requires a signer/sender
195
+ *
196
+ * @param request
197
+ */
198
+ getCommitStatuses(request: {
199
+ signer: string;
200
+ swapData: T;
201
+ }[]): Promise<{
202
+ [escrowHash: string]: SwapCommitState;
203
+ }>;
193
204
  /**
194
205
  * Checks whether a given swap is refundable by us, i.e. it is already expired, we are offerer & swap is committed on-chain
195
206
  *
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atomiqlabs/base",
3
- "version": "10.0.0-dev.10",
3
+ "version": "10.0.0-dev.14",
4
4
  "description": "Base classes and interfaces for atomiq protocol",
5
5
  "main": "./dist/index.js",
6
6
  "types:": "./dist/index.d.ts",
@@ -13,7 +13,8 @@ export type AbstractSigner = {
13
13
  export interface ChainInterface<
14
14
  TX = any,
15
15
  Signer extends AbstractSigner = AbstractSigner,
16
- ChainId extends string = string
16
+ ChainId extends string = string,
17
+ NativeSigner = any
17
18
  > {
18
19
 
19
20
  readonly chainId: ChainId;
@@ -132,4 +133,9 @@ export interface ChainInterface<
132
133
  */
133
134
  randomSigner(): Signer;
134
135
 
136
+ /**
137
+ * Wraps a native chain signer object to an atomiq-understandable AbstractSigner
138
+ */
139
+ wrapSigner(signer: NativeSigner): Signer;
140
+
135
141
  }
@@ -13,9 +13,10 @@ export type ChainType<
13
13
  PreFetchVerification = any,
14
14
  TXType = any,
15
15
  Signer extends AbstractSigner = AbstractSigner,
16
+ NativeSigner = any,
16
17
  T extends SwapData = SwapData,
17
18
  C extends SwapContract<T, TXType, PreFetchData, PreFetchVerification, Signer, ChainId> = SwapContract<T, TXType, PreFetchData, PreFetchVerification, Signer, ChainId>,
18
- I extends ChainInterface<TXType, Signer, ChainId> = ChainInterface<TXType, Signer, ChainId>,
19
+ I extends ChainInterface<TXType, Signer, ChainId, NativeSigner> = ChainInterface<TXType, Signer, ChainId, NativeSigner>,
19
20
  E extends ChainEvents<T> = ChainEvents<T>,
20
21
  B extends BtcRelay<any, TXType, any, Signer> = BtcRelay<any, TXType, any, Signer>,
21
22
  SpvData extends SpvVaultData = SpvVaultData,
@@ -34,5 +35,6 @@ export type ChainType<
34
35
  BtcRelay: B,
35
36
  SpvVaultData: SpvData,
36
37
  SpvVaultContract: SpvContract,
37
- SpvVaultWithdrawalData: SpvWithdrawalData
38
+ SpvVaultWithdrawalData: SpvWithdrawalData,
39
+ NativeSigner: NativeSigner
38
40
  }
@@ -136,6 +136,13 @@ export interface SpvVaultContract<
136
136
  */
137
137
  getFronterAddress(owner: string, vaultId: bigint, withdrawal: WithdrawalTX): Promise<string | null>;
138
138
 
139
+ /**
140
+ * Returns the parties which currently fronted the withdrawal transactions
141
+ *
142
+ * @param withdrawals withdrawals to query
143
+ */
144
+ getFronterAddresses(withdrawals: {owner: string, vaultId: bigint, withdrawal: WithdrawalTX}[]): Promise<{[btcTxId: string]: string | null}>;
145
+
139
146
  /**
140
147
  * Returns current vault data
141
148
  *
@@ -144,6 +151,28 @@ export interface SpvVaultContract<
144
151
  */
145
152
  getVaultData(owner: string, vaultId: bigint): Promise<Data>;
146
153
 
154
+ /**
155
+ * Returns current vault data for multiple vaults
156
+ *
157
+ * @param vaults Vault data to query
158
+ */
159
+ getMultipleVaultData(vaults: {owner: string, vaultId: bigint}[]): Promise<{[owner: string]: {[vaultId: string]: Data}}>;
160
+
161
+ /**
162
+ * Returns the latest utxo of a vault (or null if vault closed or not found)
163
+ *
164
+ * @param owner Owner of the vault
165
+ * @param vaultId Vault ID
166
+ */
167
+ getVaultLatestUtxo(owner: string, vaultId: bigint): Promise<string | null>;
168
+
169
+ /**
170
+ * Returns the latest utxos of for multiple vaults (or null if vault closed or not found)
171
+ *
172
+ * @param vaults Vault data to query
173
+ */
174
+ getVaultLatestUtxos(vaults: {owner: string, vaultId: bigint}[]): Promise<{[owner: string]: {[vaultId: string]: string | null}}>;
175
+
147
176
  /**
148
177
  * Returns all currently opened vaults
149
178
  * NOTE: This will take a long time, since the implementation will have to go through all the prior events
@@ -157,6 +186,13 @@ export interface SpvVaultContract<
157
186
  */
158
187
  getWithdrawalState(btcTxId: string): Promise<SpvWithdrawalState>;
159
188
 
189
+ /**
190
+ * Returns current state of the withdrawals as specified by the bitcoin transaction IDs
191
+ *
192
+ * @param btcTxIds
193
+ */
194
+ getWithdrawalStates(btcTxIds: string[]): Promise<{[btcTxId: string]: SpvWithdrawalState}>;
195
+
160
196
  /**
161
197
  * Parses withdrawal data from the parsed bitcoin transaction
162
198
  *
@@ -238,6 +238,13 @@ export interface SwapContract<
238
238
  */
239
239
  getCommitStatus(signer: string, swapData: T): Promise<SwapCommitState>;
240
240
 
241
+ /**
242
+ * Returns the full status of the passed swaps, expiry is handled by the isExpired function so also requires a signer/sender
243
+ *
244
+ * @param request
245
+ */
246
+ getCommitStatuses(request: {signer: string, swapData: T}[]): Promise<{[escrowHash: string]: SwapCommitState}>;
247
+
241
248
  /**
242
249
  * Checks whether a given swap is refundable by us, i.e. it is already expired, we are offerer & swap is committed on-chain
243
250
  *