@atomiqlabs/base 9.1.0 → 10.0.0-dev.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.
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/spv_swap/SpvVaultContract.d.ts +16 -4
- package/dist/spv_swap/SpvWithdrawalTransactionData.d.ts +1 -0
- package/dist/swaps/SwapCommitState.d.ts +38 -0
- package/dist/swaps/SwapCommitState.js +11 -0
- package/dist/swaps/SwapContract.d.ts +15 -9
- package/package.json +1 -1
- package/src/index.ts +1 -1
- package/src/spv_swap/SpvVaultContract.ts +17 -4
- package/src/spv_swap/SpvWithdrawalTransactionData.ts +2 -0
- package/src/swaps/SwapCommitState.ts +39 -0
- package/src/swaps/SwapContract.ts +15 -9
- package/dist/swaps/SwapCommitStatus.d.ts +0 -7
- package/dist/swaps/SwapCommitStatus.js +0 -11
- package/src/swaps/SwapCommitStatus.ts +0 -8
package/dist/index.d.ts
CHANGED
|
@@ -16,7 +16,7 @@ export * from "./storage/StorageObject";
|
|
|
16
16
|
export * from "./swaps/SwapContract";
|
|
17
17
|
export * from "./swaps/SwapData";
|
|
18
18
|
export * from "./swaps/ChainSwapType";
|
|
19
|
-
export * from "./swaps/
|
|
19
|
+
export * from "./swaps/SwapCommitState";
|
|
20
20
|
export * from "./errors/SignatureVerificationError";
|
|
21
21
|
export * from "./errors/CannotInitializeATAError";
|
|
22
22
|
export * from "./errors/SwapDataVerificationError";
|
package/dist/index.js
CHANGED
|
@@ -32,7 +32,7 @@ __exportStar(require("./storage/StorageObject"), exports);
|
|
|
32
32
|
__exportStar(require("./swaps/SwapContract"), exports);
|
|
33
33
|
__exportStar(require("./swaps/SwapData"), exports);
|
|
34
34
|
__exportStar(require("./swaps/ChainSwapType"), exports);
|
|
35
|
-
__exportStar(require("./swaps/
|
|
35
|
+
__exportStar(require("./swaps/SwapCommitState"), exports);
|
|
36
36
|
__exportStar(require("./errors/SignatureVerificationError"), exports);
|
|
37
37
|
__exportStar(require("./errors/CannotInitializeATAError"), exports);
|
|
38
38
|
__exportStar(require("./errors/SwapDataVerificationError"), exports);
|
|
@@ -103,6 +103,14 @@ export interface SpvVaultContract<TX = any, Signer extends AbstractSigner = Abst
|
|
|
103
103
|
* @param tokenData Data about the tokens in the vault
|
|
104
104
|
*/
|
|
105
105
|
createVaultData(owner: string, vaultId: bigint, utxo: string, confirmations: number, tokenData: SpvVaultTokenData[]): Promise<Data>;
|
|
106
|
+
/**
|
|
107
|
+
* Returns the party which currently fronted the withdrawal transaction
|
|
108
|
+
*
|
|
109
|
+
* @param owner Owner of the vault
|
|
110
|
+
* @param vaultId Vault ID
|
|
111
|
+
* @param withdrawal Withdrawal transaction to check the fronting for
|
|
112
|
+
*/
|
|
113
|
+
getFronterAddress(owner: string, vaultId: bigint, withdrawal: WithdrawalTX): Promise<string | null>;
|
|
106
114
|
/**
|
|
107
115
|
* Returns current vault data
|
|
108
116
|
*
|
|
@@ -156,32 +164,36 @@ export interface SpvVaultContract<TX = any, Signer extends AbstractSigner = Abst
|
|
|
156
164
|
* Returns the fee in native token base units to claim the swap
|
|
157
165
|
*
|
|
158
166
|
* @param signer Signer claiming the swap
|
|
167
|
+
* @param vault
|
|
159
168
|
* @param withdrawalData Withdrawal to claim
|
|
160
169
|
* @param feeRate Optional fee rate (fetched on-demand if not provided)
|
|
161
170
|
*/
|
|
162
|
-
getClaimFee(signer: string, withdrawalData: WithdrawalTX, feeRate?: string): Promise<bigint>;
|
|
171
|
+
getClaimFee(signer: string, vault: Data, withdrawalData: WithdrawalTX, feeRate?: string): Promise<bigint>;
|
|
163
172
|
/**
|
|
164
173
|
* Returns raw fee (not including any refunds we might get that would make the getClaimFee negative) for claiming the swap
|
|
165
174
|
*
|
|
166
175
|
* @param signer Signer claiming the swap
|
|
176
|
+
* @param vault
|
|
167
177
|
* @param withdrawalData Withdrawal to claim
|
|
168
178
|
* @param feeRate Optional fee rate (fetched on-demand if not provided)
|
|
169
179
|
*/
|
|
170
|
-
getRawClaimFee?(signer: string, withdrawalData: WithdrawalTX, feeRate?: string): Promise<bigint>;
|
|
180
|
+
getRawClaimFee?(signer: string, vault: Data, withdrawalData: WithdrawalTX, feeRate?: string): Promise<bigint>;
|
|
171
181
|
/**
|
|
172
182
|
* Returns the fee in native token base units to claim the swap
|
|
173
183
|
*
|
|
174
184
|
* @param signer Signer claiming the swap
|
|
185
|
+
* @param vault
|
|
175
186
|
* @param withdrawalData Withdrawal to claim
|
|
176
187
|
* @param feeRate Optional fee rate (fetched on-demand if not provided)
|
|
177
188
|
*/
|
|
178
|
-
getFrontFee(signer: string, withdrawalData: WithdrawalTX, feeRate?: string): Promise<bigint>;
|
|
189
|
+
getFrontFee(signer: string, vault: Data, withdrawalData: WithdrawalTX, feeRate?: string): Promise<bigint>;
|
|
179
190
|
/**
|
|
180
191
|
* Returns raw fee (not including any refunds we might get that would make the getClaimFee negative) for claiming the swap
|
|
181
192
|
*
|
|
182
193
|
* @param signer Signer claiming the swap
|
|
194
|
+
* @param vault
|
|
183
195
|
* @param withdrawalData Withdrawal to claim
|
|
184
196
|
* @param feeRate Optional fee rate (fetched on-demand if not provided)
|
|
185
197
|
*/
|
|
186
|
-
getRawFrontFee?(signer: string, withdrawalData: WithdrawalTX, feeRate?: string): Promise<bigint>;
|
|
198
|
+
getRawFrontFee?(signer: string, vault: Data, withdrawalData: WithdrawalTX, feeRate?: string): Promise<bigint>;
|
|
187
199
|
}
|
|
@@ -28,6 +28,7 @@ export declare abstract class SpvWithdrawalTransactionData implements StorageObj
|
|
|
28
28
|
serialize(): any;
|
|
29
29
|
getRecipient(): string;
|
|
30
30
|
abstract isRecipient(address: string): boolean;
|
|
31
|
+
abstract getFrontingId(): string;
|
|
31
32
|
getOutputWithoutFees(): bigint[];
|
|
32
33
|
getCallerFee(): bigint[];
|
|
33
34
|
getFrontingFee(): bigint[];
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
export declare enum SwapCommitStateType {
|
|
2
|
+
EXPIRED = 0,
|
|
3
|
+
NOT_COMMITED = 1,
|
|
4
|
+
COMMITED = 2,
|
|
5
|
+
PAID = 3,
|
|
6
|
+
REFUNDABLE = 4
|
|
7
|
+
}
|
|
8
|
+
export type SwapNotCommitedState = {
|
|
9
|
+
type: SwapCommitStateType.NOT_COMMITED;
|
|
10
|
+
getRefundTxId?: () => Promise<string>;
|
|
11
|
+
getTxBlock?: () => Promise<{
|
|
12
|
+
blockHeight: number;
|
|
13
|
+
blockTime: number;
|
|
14
|
+
}>;
|
|
15
|
+
};
|
|
16
|
+
export type SwapExpiredState = {
|
|
17
|
+
type: SwapCommitStateType.EXPIRED;
|
|
18
|
+
getRefundTxId?: () => Promise<string>;
|
|
19
|
+
getTxBlock?: () => Promise<{
|
|
20
|
+
blockHeight: number;
|
|
21
|
+
blockTime: number;
|
|
22
|
+
}>;
|
|
23
|
+
};
|
|
24
|
+
export type SwapRefundableState = {
|
|
25
|
+
type: SwapCommitStateType.REFUNDABLE;
|
|
26
|
+
};
|
|
27
|
+
export type SwapCommitedState = {
|
|
28
|
+
type: SwapCommitStateType.COMMITED;
|
|
29
|
+
};
|
|
30
|
+
export type SwapPaidState = {
|
|
31
|
+
type: SwapCommitStateType.PAID;
|
|
32
|
+
getClaimTxId: () => Promise<string>;
|
|
33
|
+
getTxBlock: () => Promise<{
|
|
34
|
+
blockHeight: number;
|
|
35
|
+
blockTime: number;
|
|
36
|
+
}>;
|
|
37
|
+
};
|
|
38
|
+
export type SwapCommitState = SwapNotCommitedState | SwapExpiredState | SwapRefundableState | SwapCommitedState | SwapPaidState;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SwapCommitStateType = void 0;
|
|
4
|
+
var SwapCommitStateType;
|
|
5
|
+
(function (SwapCommitStateType) {
|
|
6
|
+
SwapCommitStateType[SwapCommitStateType["EXPIRED"] = 0] = "EXPIRED";
|
|
7
|
+
SwapCommitStateType[SwapCommitStateType["NOT_COMMITED"] = 1] = "NOT_COMMITED";
|
|
8
|
+
SwapCommitStateType[SwapCommitStateType["COMMITED"] = 2] = "COMMITED";
|
|
9
|
+
SwapCommitStateType[SwapCommitStateType["PAID"] = 3] = "PAID";
|
|
10
|
+
SwapCommitStateType[SwapCommitStateType["REFUNDABLE"] = 4] = "REFUNDABLE";
|
|
11
|
+
})(SwapCommitStateType = exports.SwapCommitStateType || (exports.SwapCommitStateType = {}));
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
import { SwapData } from "./SwapData";
|
|
3
3
|
import { BtcStoredHeader } from "../btcrelay/types/BtcStoredHeader";
|
|
4
|
-
import { SwapCommitStatus } from "./SwapCommitStatus";
|
|
5
4
|
import { ChainSwapType } from "./ChainSwapType";
|
|
6
5
|
import { RelaySynchronizer } from "../btcrelay/synchronizer/RelaySynchronizer";
|
|
7
6
|
import { Buffer } from "buffer";
|
|
8
7
|
import { AbstractSigner, TransactionConfirmationOptions } from "../chains/ChainInterface";
|
|
8
|
+
import { SwapCommitState } from "./SwapCommitState";
|
|
9
9
|
export type IntermediaryReputationType = {
|
|
10
10
|
[key in ChainSwapType]: {
|
|
11
11
|
successVolume: bigint;
|
|
@@ -50,12 +50,13 @@ export interface SwapContract<T extends SwapData = SwapData, TX = any, PreFetchD
|
|
|
50
50
|
/**
|
|
51
51
|
* Returns the unsigned transactions required for initializing a non-payIn swap (BTC -> SC)
|
|
52
52
|
*
|
|
53
|
+
* @param sender Transaction sender address, must be either offerer or claimer
|
|
53
54
|
* @param swapData Swap to init
|
|
54
55
|
* @param signature Signature data from the offerer
|
|
55
56
|
* @param skipChecks Whether to skip verification of the signature & checking if the swap is already committed
|
|
56
57
|
* @param feeRate Fee rate to use for the transaction
|
|
57
58
|
*/
|
|
58
|
-
txsInit(swapData: T, signature: SignatureData, skipChecks?: boolean, feeRate?: string): Promise<TX[]>;
|
|
59
|
+
txsInit(sender: string, swapData: T, signature: SignatureData, skipChecks?: boolean, feeRate?: string): Promise<TX[]>;
|
|
59
60
|
/**
|
|
60
61
|
* Signs & sends transactions required for claiming an HTLC swap
|
|
61
62
|
*
|
|
@@ -182,12 +183,12 @@ export interface SwapContract<T extends SwapData = SwapData, TX = any, PreFetchD
|
|
|
182
183
|
*/
|
|
183
184
|
isCommited(swapData: T): Promise<boolean>;
|
|
184
185
|
/**
|
|
185
|
-
* Returns the full status of the swap, expiry is
|
|
186
|
+
* Returns the full status of the swap, expiry is handled by the isExpired function so also requires a signer/sender
|
|
186
187
|
*
|
|
187
188
|
* @param signer
|
|
188
189
|
* @param swapData
|
|
189
190
|
*/
|
|
190
|
-
getCommitStatus(signer: string, swapData: T): Promise<
|
|
191
|
+
getCommitStatus(signer: string, swapData: T): Promise<SwapCommitState>;
|
|
191
192
|
/**
|
|
192
193
|
* Checks whether a given swap is refundable by us, i.e. it is already expired, we are offerer & swap is committed on-chain
|
|
193
194
|
*
|
|
@@ -217,13 +218,14 @@ export interface SwapContract<T extends SwapData = SwapData, TX = any, PreFetchD
|
|
|
217
218
|
/**
|
|
218
219
|
* Checks whether a signature is a valid initialization signature for a given swap
|
|
219
220
|
*
|
|
221
|
+
* @param sender Address of the sender of the transaction (must be either offerer or claimer)
|
|
220
222
|
* @param swapData Swap to initialize
|
|
221
223
|
* @param signature Signature data
|
|
222
224
|
* @param feeRate Fee rate used for the authorization
|
|
223
225
|
* @param preFetchedVerificationData Optional pre-fetched data required for signature validation
|
|
224
226
|
* @returns {Buffer | null} The message being signed if valid or null if invalid signature
|
|
225
227
|
*/
|
|
226
|
-
isValidInitAuthorization(swapData: T, signature: SignatureData, feeRate?: string, preFetchedVerificationData?: PreFetchVerification): Promise<Buffer | null>;
|
|
228
|
+
isValidInitAuthorization(sender: string, swapData: T, signature: SignatureData, feeRate?: string, preFetchedVerificationData?: PreFetchVerification): Promise<Buffer | null>;
|
|
227
229
|
/**
|
|
228
230
|
* Returns the expiry timestamp (UNIX milliseconds) of the authorization
|
|
229
231
|
*
|
|
@@ -306,17 +308,19 @@ export interface SwapContract<T extends SwapData = SwapData, TX = any, PreFetchD
|
|
|
306
308
|
/**
|
|
307
309
|
* Returns the fee in native token base units to commit (initiate) the swap
|
|
308
310
|
*
|
|
311
|
+
* @param signer
|
|
309
312
|
* @param swapData Swap to initiate
|
|
310
313
|
* @param feeRate Optional fee rate (fetched on-demand if not provided)
|
|
311
314
|
*/
|
|
312
|
-
getCommitFee(swapData: T, feeRate?: string): Promise<bigint>;
|
|
315
|
+
getCommitFee(signer: string, swapData: T, feeRate?: string): Promise<bigint>;
|
|
313
316
|
/**
|
|
314
317
|
* Returns raw fee (not including any account deposits we might need) for initiating the swap
|
|
315
318
|
*
|
|
319
|
+
* @param signer
|
|
316
320
|
* @param swapData Swap to initiate
|
|
317
321
|
* @param feeRate Optional fee rate (fetched on-demand if not provided)
|
|
318
322
|
*/
|
|
319
|
-
getRawCommitFee?(swapData: T, feeRate?: string): Promise<bigint>;
|
|
323
|
+
getRawCommitFee?(signer: string, swapData: T, feeRate?: string): Promise<bigint>;
|
|
320
324
|
/**
|
|
321
325
|
* Returns the fee in native token base units to claim the swap
|
|
322
326
|
*
|
|
@@ -336,17 +340,19 @@ export interface SwapContract<T extends SwapData = SwapData, TX = any, PreFetchD
|
|
|
336
340
|
/**
|
|
337
341
|
* Returns the fee in native token base units to refund the swap
|
|
338
342
|
*
|
|
343
|
+
* @param signer
|
|
339
344
|
* @param swapData Swap to refund
|
|
340
345
|
* @param feeRate Optional fee rate (fetched on-demand if not provided)
|
|
341
346
|
*/
|
|
342
|
-
getRefundFee(swapData: T, feeRate?: string): Promise<bigint>;
|
|
347
|
+
getRefundFee(signer: string, swapData: T, feeRate?: string): Promise<bigint>;
|
|
343
348
|
/**
|
|
344
349
|
* Returns raw fee (not including any refunds we might get that would make the getRefundFee negative) for claiming the swap
|
|
345
350
|
*
|
|
351
|
+
* @param signer
|
|
346
352
|
* @param swapData Swap to claim
|
|
347
353
|
* @param feeRate Optional fee rate (fetched on-demand if not provided)
|
|
348
354
|
*/
|
|
349
|
-
getRawRefundFee?(swapData: T, feeRate?: string): Promise<bigint>;
|
|
355
|
+
getRawRefundFee?(signer: string, swapData: T, feeRate?: string): Promise<bigint>;
|
|
350
356
|
/**
|
|
351
357
|
* Returns the fee rate for committing (initializing) a payIn swap
|
|
352
358
|
*
|
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -16,7 +16,7 @@ export * from "./storage/StorageObject";
|
|
|
16
16
|
export * from "./swaps/SwapContract";
|
|
17
17
|
export * from "./swaps/SwapData";
|
|
18
18
|
export * from "./swaps/ChainSwapType";
|
|
19
|
-
export * from "./swaps/
|
|
19
|
+
export * from "./swaps/SwapCommitState";
|
|
20
20
|
|
|
21
21
|
export * from "./errors/SignatureVerificationError";
|
|
22
22
|
export * from "./errors/CannotInitializeATAError"
|
|
@@ -127,6 +127,15 @@ export interface SpvVaultContract<
|
|
|
127
127
|
*/
|
|
128
128
|
createVaultData(owner: string, vaultId: bigint, utxo: string, confirmations: number, tokenData: SpvVaultTokenData[]): Promise<Data>;
|
|
129
129
|
|
|
130
|
+
/**
|
|
131
|
+
* Returns the party which currently fronted the withdrawal transaction
|
|
132
|
+
*
|
|
133
|
+
* @param owner Owner of the vault
|
|
134
|
+
* @param vaultId Vault ID
|
|
135
|
+
* @param withdrawal Withdrawal transaction to check the fronting for
|
|
136
|
+
*/
|
|
137
|
+
getFronterAddress(owner: string, vaultId: bigint, withdrawal: WithdrawalTX): Promise<string | null>;
|
|
138
|
+
|
|
130
139
|
/**
|
|
131
140
|
* Returns current vault data
|
|
132
141
|
*
|
|
@@ -183,36 +192,40 @@ export interface SpvVaultContract<
|
|
|
183
192
|
* Returns the fee in native token base units to claim the swap
|
|
184
193
|
*
|
|
185
194
|
* @param signer Signer claiming the swap
|
|
195
|
+
* @param vault
|
|
186
196
|
* @param withdrawalData Withdrawal to claim
|
|
187
197
|
* @param feeRate Optional fee rate (fetched on-demand if not provided)
|
|
188
198
|
*/
|
|
189
|
-
getClaimFee(signer: string, withdrawalData: WithdrawalTX, feeRate?: string): Promise<bigint>;
|
|
199
|
+
getClaimFee(signer: string, vault: Data, withdrawalData: WithdrawalTX, feeRate?: string): Promise<bigint>;
|
|
190
200
|
|
|
191
201
|
/**
|
|
192
202
|
* Returns raw fee (not including any refunds we might get that would make the getClaimFee negative) for claiming the swap
|
|
193
203
|
*
|
|
194
204
|
* @param signer Signer claiming the swap
|
|
205
|
+
* @param vault
|
|
195
206
|
* @param withdrawalData Withdrawal to claim
|
|
196
207
|
* @param feeRate Optional fee rate (fetched on-demand if not provided)
|
|
197
208
|
*/
|
|
198
|
-
getRawClaimFee?(signer: string, withdrawalData: WithdrawalTX, feeRate?: string): Promise<bigint>;
|
|
209
|
+
getRawClaimFee?(signer: string, vault: Data, withdrawalData: WithdrawalTX, feeRate?: string): Promise<bigint>;
|
|
199
210
|
|
|
200
211
|
/**
|
|
201
212
|
* Returns the fee in native token base units to claim the swap
|
|
202
213
|
*
|
|
203
214
|
* @param signer Signer claiming the swap
|
|
215
|
+
* @param vault
|
|
204
216
|
* @param withdrawalData Withdrawal to claim
|
|
205
217
|
* @param feeRate Optional fee rate (fetched on-demand if not provided)
|
|
206
218
|
*/
|
|
207
|
-
getFrontFee(signer: string, withdrawalData: WithdrawalTX, feeRate?: string): Promise<bigint>;
|
|
219
|
+
getFrontFee(signer: string, vault: Data, withdrawalData: WithdrawalTX, feeRate?: string): Promise<bigint>;
|
|
208
220
|
|
|
209
221
|
/**
|
|
210
222
|
* Returns raw fee (not including any refunds we might get that would make the getClaimFee negative) for claiming the swap
|
|
211
223
|
*
|
|
212
224
|
* @param signer Signer claiming the swap
|
|
225
|
+
* @param vault
|
|
213
226
|
* @param withdrawalData Withdrawal to claim
|
|
214
227
|
* @param feeRate Optional fee rate (fetched on-demand if not provided)
|
|
215
228
|
*/
|
|
216
|
-
getRawFrontFee?(signer: string, withdrawalData: WithdrawalTX, feeRate?: string): Promise<bigint>;
|
|
229
|
+
getRawFrontFee?(signer: string, vault: Data, withdrawalData: WithdrawalTX, feeRate?: string): Promise<bigint>;
|
|
217
230
|
|
|
218
231
|
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
export enum SwapCommitStateType {
|
|
2
|
+
EXPIRED=0,
|
|
3
|
+
NOT_COMMITED=1,
|
|
4
|
+
COMMITED=2,
|
|
5
|
+
PAID=3,
|
|
6
|
+
REFUNDABLE=4
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export type SwapNotCommitedState = {
|
|
10
|
+
type: SwapCommitStateType.NOT_COMMITED,
|
|
11
|
+
getRefundTxId?: () => Promise<string>,
|
|
12
|
+
getTxBlock?: () => Promise<{blockHeight: number, blockTime: number}>
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
export type SwapExpiredState = {
|
|
16
|
+
type: SwapCommitStateType.EXPIRED,
|
|
17
|
+
getRefundTxId?: () => Promise<string>,
|
|
18
|
+
getTxBlock?: () => Promise<{blockHeight: number, blockTime: number}>
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
export type SwapRefundableState = {
|
|
22
|
+
type: SwapCommitStateType.REFUNDABLE
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
export type SwapCommitedState = {
|
|
26
|
+
type: SwapCommitStateType.COMMITED
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
export type SwapPaidState = {
|
|
30
|
+
type: SwapCommitStateType.PAID,
|
|
31
|
+
getClaimTxId: () => Promise<string>,
|
|
32
|
+
getTxBlock: () => Promise<{blockHeight: number, blockTime: number}>
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
export type SwapCommitState = SwapNotCommitedState |
|
|
36
|
+
SwapExpiredState |
|
|
37
|
+
SwapRefundableState |
|
|
38
|
+
SwapCommitedState |
|
|
39
|
+
SwapPaidState;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import {SwapData} from "./SwapData";
|
|
2
2
|
import {BtcStoredHeader} from "../btcrelay/types/BtcStoredHeader";
|
|
3
|
-
import {SwapCommitStatus} from "./SwapCommitStatus";
|
|
4
3
|
import {ChainSwapType} from "./ChainSwapType";
|
|
5
4
|
import {RelaySynchronizer} from "../btcrelay/synchronizer/RelaySynchronizer";
|
|
6
5
|
import {Buffer} from "buffer";
|
|
7
6
|
import {AbstractSigner, TransactionConfirmationOptions} from "../chains/ChainInterface";
|
|
7
|
+
import {SwapCommitState} from "./SwapCommitState";
|
|
8
8
|
|
|
9
9
|
export type IntermediaryReputationType = {
|
|
10
10
|
[key in ChainSwapType]: {
|
|
@@ -64,12 +64,13 @@ export interface SwapContract<
|
|
|
64
64
|
/**
|
|
65
65
|
* Returns the unsigned transactions required for initializing a non-payIn swap (BTC -> SC)
|
|
66
66
|
*
|
|
67
|
+
* @param sender Transaction sender address, must be either offerer or claimer
|
|
67
68
|
* @param swapData Swap to init
|
|
68
69
|
* @param signature Signature data from the offerer
|
|
69
70
|
* @param skipChecks Whether to skip verification of the signature & checking if the swap is already committed
|
|
70
71
|
* @param feeRate Fee rate to use for the transaction
|
|
71
72
|
*/
|
|
72
|
-
txsInit(swapData: T, signature: SignatureData, skipChecks?: boolean, feeRate?: string): Promise<TX[]>;
|
|
73
|
+
txsInit(sender: string, swapData: T, signature: SignatureData, skipChecks?: boolean, feeRate?: string): Promise<TX[]>;
|
|
73
74
|
|
|
74
75
|
/**
|
|
75
76
|
* Signs & sends transactions required for claiming an HTLC swap
|
|
@@ -229,12 +230,12 @@ export interface SwapContract<
|
|
|
229
230
|
isCommited(swapData: T): Promise<boolean>;
|
|
230
231
|
|
|
231
232
|
/**
|
|
232
|
-
* Returns the full status of the swap, expiry is
|
|
233
|
+
* Returns the full status of the swap, expiry is handled by the isExpired function so also requires a signer/sender
|
|
233
234
|
*
|
|
234
235
|
* @param signer
|
|
235
236
|
* @param swapData
|
|
236
237
|
*/
|
|
237
|
-
getCommitStatus(signer: string, swapData: T): Promise<
|
|
238
|
+
getCommitStatus(signer: string, swapData: T): Promise<SwapCommitState>;
|
|
238
239
|
|
|
239
240
|
/**
|
|
240
241
|
* Checks whether a given swap is refundable by us, i.e. it is already expired, we are offerer & swap is committed on-chain
|
|
@@ -269,13 +270,14 @@ export interface SwapContract<
|
|
|
269
270
|
/**
|
|
270
271
|
* Checks whether a signature is a valid initialization signature for a given swap
|
|
271
272
|
*
|
|
273
|
+
* @param sender Address of the sender of the transaction (must be either offerer or claimer)
|
|
272
274
|
* @param swapData Swap to initialize
|
|
273
275
|
* @param signature Signature data
|
|
274
276
|
* @param feeRate Fee rate used for the authorization
|
|
275
277
|
* @param preFetchedVerificationData Optional pre-fetched data required for signature validation
|
|
276
278
|
* @returns {Buffer | null} The message being signed if valid or null if invalid signature
|
|
277
279
|
*/
|
|
278
|
-
isValidInitAuthorization(swapData: T, signature: SignatureData, feeRate?: string, preFetchedVerificationData?: PreFetchVerification): Promise<Buffer | null>;
|
|
280
|
+
isValidInitAuthorization(sender: string, swapData: T, signature: SignatureData, feeRate?: string, preFetchedVerificationData?: PreFetchVerification): Promise<Buffer | null>;
|
|
279
281
|
|
|
280
282
|
/**
|
|
281
283
|
* Returns the expiry timestamp (UNIX milliseconds) of the authorization
|
|
@@ -382,18 +384,20 @@ export interface SwapContract<
|
|
|
382
384
|
/**
|
|
383
385
|
* Returns the fee in native token base units to commit (initiate) the swap
|
|
384
386
|
*
|
|
387
|
+
* @param signer
|
|
385
388
|
* @param swapData Swap to initiate
|
|
386
389
|
* @param feeRate Optional fee rate (fetched on-demand if not provided)
|
|
387
390
|
*/
|
|
388
|
-
getCommitFee(swapData: T, feeRate?: string): Promise<bigint>;
|
|
391
|
+
getCommitFee(signer: string, swapData: T, feeRate?: string): Promise<bigint>;
|
|
389
392
|
|
|
390
393
|
/**
|
|
391
394
|
* Returns raw fee (not including any account deposits we might need) for initiating the swap
|
|
392
395
|
*
|
|
396
|
+
* @param signer
|
|
393
397
|
* @param swapData Swap to initiate
|
|
394
398
|
* @param feeRate Optional fee rate (fetched on-demand if not provided)
|
|
395
399
|
*/
|
|
396
|
-
getRawCommitFee?(swapData: T, feeRate?: string): Promise<bigint>;
|
|
400
|
+
getRawCommitFee?(signer: string, swapData: T, feeRate?: string): Promise<bigint>;
|
|
397
401
|
|
|
398
402
|
/**
|
|
399
403
|
* Returns the fee in native token base units to claim the swap
|
|
@@ -416,18 +420,20 @@ export interface SwapContract<
|
|
|
416
420
|
/**
|
|
417
421
|
* Returns the fee in native token base units to refund the swap
|
|
418
422
|
*
|
|
423
|
+
* @param signer
|
|
419
424
|
* @param swapData Swap to refund
|
|
420
425
|
* @param feeRate Optional fee rate (fetched on-demand if not provided)
|
|
421
426
|
*/
|
|
422
|
-
getRefundFee(swapData: T, feeRate?: string): Promise<bigint>;
|
|
427
|
+
getRefundFee(signer: string, swapData: T, feeRate?: string): Promise<bigint>;
|
|
423
428
|
|
|
424
429
|
/**
|
|
425
430
|
* Returns raw fee (not including any refunds we might get that would make the getRefundFee negative) for claiming the swap
|
|
426
431
|
*
|
|
432
|
+
* @param signer
|
|
427
433
|
* @param swapData Swap to claim
|
|
428
434
|
* @param feeRate Optional fee rate (fetched on-demand if not provided)
|
|
429
435
|
*/
|
|
430
|
-
getRawRefundFee?(swapData: T, feeRate?: string): Promise<bigint>;
|
|
436
|
+
getRawRefundFee?(signer: string, swapData: T, feeRate?: string): Promise<bigint>;
|
|
431
437
|
|
|
432
438
|
/**
|
|
433
439
|
* Returns the fee rate for committing (initializing) a payIn swap
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.SwapCommitStatus = void 0;
|
|
4
|
-
var SwapCommitStatus;
|
|
5
|
-
(function (SwapCommitStatus) {
|
|
6
|
-
SwapCommitStatus[SwapCommitStatus["EXPIRED"] = 0] = "EXPIRED";
|
|
7
|
-
SwapCommitStatus[SwapCommitStatus["NOT_COMMITED"] = 1] = "NOT_COMMITED";
|
|
8
|
-
SwapCommitStatus[SwapCommitStatus["COMMITED"] = 2] = "COMMITED";
|
|
9
|
-
SwapCommitStatus[SwapCommitStatus["PAID"] = 3] = "PAID";
|
|
10
|
-
SwapCommitStatus[SwapCommitStatus["REFUNDABLE"] = 4] = "REFUNDABLE";
|
|
11
|
-
})(SwapCommitStatus = exports.SwapCommitStatus || (exports.SwapCommitStatus = {}));
|