@atomiqlabs/base 11.0.0 → 12.0.0
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/chains/ChainInterface.d.ts +25 -2
- package/dist/chains/ChainInterface.js +5 -0
- package/dist/chains/ChainType.d.ts +2 -1
- package/dist/errors/TransactionRevertedError.d.ts +3 -0
- package/dist/errors/TransactionRevertedError.js +11 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +4 -0
- package/dist/messaging/Messenger.d.ts +8 -0
- package/dist/messaging/Messenger.js +2 -0
- package/dist/messaging/messages/Message.d.ts +11 -0
- package/dist/messaging/messages/Message.js +22 -0
- package/dist/messaging/messages/SwapClaimWitnessMessage.d.ts +10 -0
- package/dist/messaging/messages/SwapClaimWitnessMessage.js +28 -0
- package/dist/spv_swap/SpvVaultContract.d.ts +78 -7
- package/dist/spv_swap/SpvWithdrawalTransactionData.d.ts +1 -0
- package/dist/swaps/SwapContract.d.ts +20 -4
- package/dist/swaps/SwapData.d.ts +1 -0
- package/dist/swaps/SwapData.js +3 -0
- package/package.json +1 -1
- package/src/chains/ChainInterface.ts +30 -3
- package/src/chains/ChainType.ts +4 -2
- package/src/errors/TransactionRevertedError.ts +11 -0
- package/src/index.ts +5 -0
- package/src/messaging/Messenger.ts +11 -0
- package/src/messaging/messages/Message.ts +25 -0
- package/src/messaging/messages/SwapClaimWitnessMessage.ts +34 -0
- package/src/spv_swap/SpvVaultContract.ts +59 -7
- package/src/spv_swap/SpvWithdrawalTransactionData.ts +2 -0
- package/src/swaps/SwapContract.ts +16 -4
- package/src/swaps/SwapData.ts +4 -0
- package/dist/swaps/SwapCommitStatus.d.ts +0 -7
- package/dist/swaps/SwapCommitStatus.js +0 -11
|
@@ -4,9 +4,13 @@ export type TransactionConfirmationOptions = {
|
|
|
4
4
|
feeRate?: string;
|
|
5
5
|
};
|
|
6
6
|
export type AbstractSigner = {
|
|
7
|
+
type: "AtomiqAbstractSigner";
|
|
7
8
|
getAddress: () => string;
|
|
9
|
+
init?: () => Promise<void>;
|
|
10
|
+
stop?: () => Promise<void>;
|
|
8
11
|
};
|
|
9
|
-
export
|
|
12
|
+
export declare function isAbstractSigner(val: any): val is AbstractSigner;
|
|
13
|
+
export interface ChainInterface<TX = any, Signer extends AbstractSigner = AbstractSigner, ChainId extends string = string, NativeSigner = any> {
|
|
10
14
|
readonly chainId: ChainId;
|
|
11
15
|
/**
|
|
12
16
|
* Returns the token balance of a specific address
|
|
@@ -23,8 +27,15 @@ export interface ChainInterface<TX = any, Signer extends AbstractSigner = Abstra
|
|
|
23
27
|
* Checks if a given string is a valid wallet address
|
|
24
28
|
*
|
|
25
29
|
* @param address
|
|
30
|
+
* @param lenient Whether a lenient parsing should be used (i.e. don't strictly enforce the Starknet address lengths)
|
|
26
31
|
*/
|
|
27
|
-
isValidAddress(address: string): boolean;
|
|
32
|
+
isValidAddress(address: string, lenient?: boolean): boolean;
|
|
33
|
+
/**
|
|
34
|
+
* Normalizes a given address i.e. pads it to the specific size
|
|
35
|
+
*
|
|
36
|
+
* @param address
|
|
37
|
+
*/
|
|
38
|
+
normalizeAddress(address: string): string;
|
|
28
39
|
/**
|
|
29
40
|
* Checks if a given string is a valid token identifier
|
|
30
41
|
*
|
|
@@ -75,6 +86,14 @@ export interface ChainInterface<TX = any, Signer extends AbstractSigner = Abstra
|
|
|
75
86
|
* @param txId Transaction ID
|
|
76
87
|
*/
|
|
77
88
|
getTxIdStatus(txId: string): Promise<"not_found" | "pending" | "success" | "reverted">;
|
|
89
|
+
/**
|
|
90
|
+
* Returns the latest known finalized block data (this is a block with 100% certainty of not getting re-org, i.e.
|
|
91
|
+
* a block already committed on L1)
|
|
92
|
+
*/
|
|
93
|
+
getFinalizedBlock(): Promise<{
|
|
94
|
+
height: number;
|
|
95
|
+
blockHash: string;
|
|
96
|
+
}>;
|
|
78
97
|
/**
|
|
79
98
|
* Signs, sends a batch of transaction and optionally waits for their confirmation
|
|
80
99
|
*
|
|
@@ -107,4 +126,8 @@ export interface ChainInterface<TX = any, Signer extends AbstractSigner = Abstra
|
|
|
107
126
|
* Returns randomly generated signer
|
|
108
127
|
*/
|
|
109
128
|
randomSigner(): Signer;
|
|
129
|
+
/**
|
|
130
|
+
* Wraps a native chain signer object to an atomiq-understandable AbstractSigner
|
|
131
|
+
*/
|
|
132
|
+
wrapSigner(signer: NativeSigner): Promise<Signer>;
|
|
110
133
|
}
|
|
@@ -1,2 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isAbstractSigner = void 0;
|
|
4
|
+
function isAbstractSigner(val) {
|
|
5
|
+
return typeof (val) === "object" && val.type === "AtomiqAbstractSigner" && typeof (val.getAddress) === "function";
|
|
6
|
+
}
|
|
7
|
+
exports.isAbstractSigner = isAbstractSigner;
|
|
@@ -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
|
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.TransactionRevertedError = void 0;
|
|
4
|
+
class TransactionRevertedError extends Error {
|
|
5
|
+
constructor(msg) {
|
|
6
|
+
super(msg);
|
|
7
|
+
// Set the prototype explicitly.
|
|
8
|
+
Object.setPrototypeOf(this, TransactionRevertedError.prototype);
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
exports.TransactionRevertedError = TransactionRevertedError;
|
package/dist/index.d.ts
CHANGED
|
@@ -20,6 +20,7 @@ export * from "./swaps/SwapCommitState";
|
|
|
20
20
|
export * from "./errors/SignatureVerificationError";
|
|
21
21
|
export * from "./errors/CannotInitializeATAError";
|
|
22
22
|
export * from "./errors/SwapDataVerificationError";
|
|
23
|
+
export * from "./errors/TransactionRevertedError";
|
|
23
24
|
export * from "./chains/ChainType";
|
|
24
25
|
export * from "./chains/ChainData";
|
|
25
26
|
export * from "./utils/BigIntBufferUtils";
|
|
@@ -36,3 +37,6 @@ export * from "./events/types/spv_vault/SpvVaultClaimEvent";
|
|
|
36
37
|
export * from "./events/types/spv_vault/SpvVaultDepositEvent";
|
|
37
38
|
export * from "./events/types/spv_vault/SpvVaultOpenEvent";
|
|
38
39
|
export * from "./events/types/spv_vault/SpvVaultFrontEvent";
|
|
40
|
+
export * from "./messaging/Messenger";
|
|
41
|
+
export * from "./messaging/messages/Message";
|
|
42
|
+
export * from "./messaging/messages/SwapClaimWitnessMessage";
|
package/dist/index.js
CHANGED
|
@@ -36,6 +36,7 @@ __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);
|
|
39
|
+
__exportStar(require("./errors/TransactionRevertedError"), exports);
|
|
39
40
|
__exportStar(require("./chains/ChainType"), exports);
|
|
40
41
|
__exportStar(require("./chains/ChainData"), exports);
|
|
41
42
|
__exportStar(require("./utils/BigIntBufferUtils"), exports);
|
|
@@ -52,3 +53,6 @@ __exportStar(require("./events/types/spv_vault/SpvVaultClaimEvent"), exports);
|
|
|
52
53
|
__exportStar(require("./events/types/spv_vault/SpvVaultDepositEvent"), exports);
|
|
53
54
|
__exportStar(require("./events/types/spv_vault/SpvVaultOpenEvent"), exports);
|
|
54
55
|
__exportStar(require("./events/types/spv_vault/SpvVaultFrontEvent"), exports);
|
|
56
|
+
__exportStar(require("./messaging/Messenger"), exports);
|
|
57
|
+
__exportStar(require("./messaging/messages/Message"), exports);
|
|
58
|
+
__exportStar(require("./messaging/messages/SwapClaimWitnessMessage"), exports);
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { Message } from "./messages/Message";
|
|
2
|
+
export interface Messenger {
|
|
3
|
+
init(): Promise<void>;
|
|
4
|
+
broadcast(msg: Message): Promise<void>;
|
|
5
|
+
subscribe(callback: (msg: Message) => void): Promise<void>;
|
|
6
|
+
unsubscribe(callback: (msg: Message) => void): Promise<boolean>;
|
|
7
|
+
stop(): Promise<void>;
|
|
8
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export declare enum MessageType {
|
|
2
|
+
SWAP_CLAIM_WITNESS = 0
|
|
3
|
+
}
|
|
4
|
+
export declare abstract class Message {
|
|
5
|
+
abstract type: MessageType;
|
|
6
|
+
static deserializers: {
|
|
7
|
+
[type: number]: (obj: any) => Message;
|
|
8
|
+
};
|
|
9
|
+
serialize(): any;
|
|
10
|
+
static deserialize(message: any): Message;
|
|
11
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Message = exports.MessageType = void 0;
|
|
4
|
+
var MessageType;
|
|
5
|
+
(function (MessageType) {
|
|
6
|
+
MessageType[MessageType["SWAP_CLAIM_WITNESS"] = 0] = "SWAP_CLAIM_WITNESS";
|
|
7
|
+
})(MessageType = exports.MessageType || (exports.MessageType = {}));
|
|
8
|
+
class Message {
|
|
9
|
+
serialize() {
|
|
10
|
+
return {
|
|
11
|
+
type: this.type
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
static deserialize(message) {
|
|
15
|
+
const deserializer = Message.deserializers[message.type];
|
|
16
|
+
if (deserializer == null)
|
|
17
|
+
throw new Error("Unknown message type " + message.type);
|
|
18
|
+
return deserializer(message);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
exports.Message = Message;
|
|
22
|
+
Message.deserializers = {};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { SwapData } from "../../swaps/SwapData";
|
|
2
|
+
import { Message, MessageType } from "./Message";
|
|
3
|
+
export declare class SwapClaimWitnessMessage<T extends SwapData> extends Message {
|
|
4
|
+
type: MessageType;
|
|
5
|
+
swapData: T;
|
|
6
|
+
witness: string;
|
|
7
|
+
constructor(swapData: T, witness: string);
|
|
8
|
+
serialize(): any;
|
|
9
|
+
static deserialize(obj: any): SwapClaimWitnessMessage<SwapData>;
|
|
10
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SwapClaimWitnessMessage = void 0;
|
|
4
|
+
const SwapData_1 = require("../../swaps/SwapData");
|
|
5
|
+
const Message_1 = require("./Message");
|
|
6
|
+
class SwapClaimWitnessMessage extends Message_1.Message {
|
|
7
|
+
constructor(swapData, witness) {
|
|
8
|
+
super();
|
|
9
|
+
this.type = Message_1.MessageType.SWAP_CLAIM_WITNESS;
|
|
10
|
+
this.swapData = swapData;
|
|
11
|
+
this.witness = witness;
|
|
12
|
+
}
|
|
13
|
+
serialize() {
|
|
14
|
+
return {
|
|
15
|
+
...super.serialize(),
|
|
16
|
+
swapData: this.swapData.serialize(),
|
|
17
|
+
witness: this.witness
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
static deserialize(obj) {
|
|
21
|
+
if (obj == null || typeof (obj.witness) !== "string" || typeof (obj.swapData) !== "object") {
|
|
22
|
+
throw new Error("Invalid format!");
|
|
23
|
+
}
|
|
24
|
+
return new SwapClaimWitnessMessage(SwapData_1.SwapData.deserialize(obj.swapData), obj.witness);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
exports.SwapClaimWitnessMessage = SwapClaimWitnessMessage;
|
|
28
|
+
Message_1.Message.deserializers[Message_1.MessageType.SWAP_CLAIM_WITNESS] = SwapClaimWitnessMessage.deserialize;
|
|
@@ -103,6 +103,26 @@ 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>;
|
|
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
|
+
}>;
|
|
106
126
|
/**
|
|
107
127
|
* Returns current vault data
|
|
108
128
|
*
|
|
@@ -110,17 +130,64 @@ export interface SpvVaultContract<TX = any, Signer extends AbstractSigner = Abst
|
|
|
110
130
|
* @param vaultId Vault ID
|
|
111
131
|
*/
|
|
112
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
|
+
}>;
|
|
113
166
|
/**
|
|
114
167
|
* Returns all currently opened vaults
|
|
115
168
|
* NOTE: This will take a long time, since the implementation will have to go through all the prior events
|
|
116
169
|
*/
|
|
117
170
|
getAllVaults(owner?: string): Promise<Data[]>;
|
|
118
171
|
/**
|
|
119
|
-
* Returns current state of the withdrawal
|
|
172
|
+
* Returns current state of the withdrawal, optionally
|
|
173
|
+
* only check withdrawals from the provided block height
|
|
174
|
+
*
|
|
175
|
+
* @param withdrawalTx
|
|
176
|
+
* @param scStartBlockheight
|
|
177
|
+
*/
|
|
178
|
+
getWithdrawalState(withdrawalTx: WithdrawalTX, scStartBlockheight?: number): Promise<SpvWithdrawalState>;
|
|
179
|
+
/**
|
|
180
|
+
* Returns current state of the withdrawals, optionally
|
|
181
|
+
* only check withdrawals from the provided block height
|
|
120
182
|
*
|
|
121
|
-
* @param
|
|
183
|
+
* @param withdrawalTxs Object with the withdrawal tx to check + an optional start blockheight
|
|
122
184
|
*/
|
|
123
|
-
|
|
185
|
+
getWithdrawalStates(withdrawalTxs: {
|
|
186
|
+
withdrawal: WithdrawalTX;
|
|
187
|
+
scStartBlockheight?: number;
|
|
188
|
+
}[]): Promise<{
|
|
189
|
+
[btcTxId: string]: SpvWithdrawalState;
|
|
190
|
+
}>;
|
|
124
191
|
/**
|
|
125
192
|
* Parses withdrawal data from the parsed bitcoin transaction
|
|
126
193
|
*
|
|
@@ -156,32 +223,36 @@ export interface SpvVaultContract<TX = any, Signer extends AbstractSigner = Abst
|
|
|
156
223
|
* Returns the fee in native token base units to claim the swap
|
|
157
224
|
*
|
|
158
225
|
* @param signer Signer claiming the swap
|
|
226
|
+
* @param vault
|
|
159
227
|
* @param withdrawalData Withdrawal to claim
|
|
160
228
|
* @param feeRate Optional fee rate (fetched on-demand if not provided)
|
|
161
229
|
*/
|
|
162
|
-
getClaimFee(signer: string, withdrawalData: WithdrawalTX, feeRate?: string): Promise<bigint>;
|
|
230
|
+
getClaimFee(signer: string, vault: Data, withdrawalData: WithdrawalTX, feeRate?: string): Promise<bigint>;
|
|
163
231
|
/**
|
|
164
232
|
* Returns raw fee (not including any refunds we might get that would make the getClaimFee negative) for claiming the swap
|
|
165
233
|
*
|
|
166
234
|
* @param signer Signer claiming the swap
|
|
235
|
+
* @param vault
|
|
167
236
|
* @param withdrawalData Withdrawal to claim
|
|
168
237
|
* @param feeRate Optional fee rate (fetched on-demand if not provided)
|
|
169
238
|
*/
|
|
170
|
-
getRawClaimFee?(signer: string, withdrawalData: WithdrawalTX, feeRate?: string): Promise<bigint>;
|
|
239
|
+
getRawClaimFee?(signer: string, vault: Data, withdrawalData: WithdrawalTX, feeRate?: string): Promise<bigint>;
|
|
171
240
|
/**
|
|
172
241
|
* Returns the fee in native token base units to claim the swap
|
|
173
242
|
*
|
|
174
243
|
* @param signer Signer claiming the swap
|
|
244
|
+
* @param vault
|
|
175
245
|
* @param withdrawalData Withdrawal to claim
|
|
176
246
|
* @param feeRate Optional fee rate (fetched on-demand if not provided)
|
|
177
247
|
*/
|
|
178
|
-
getFrontFee(signer: string, withdrawalData: WithdrawalTX, feeRate?: string): Promise<bigint>;
|
|
248
|
+
getFrontFee(signer: string, vault: Data, withdrawalData: WithdrawalTX, feeRate?: string): Promise<bigint>;
|
|
179
249
|
/**
|
|
180
250
|
* Returns raw fee (not including any refunds we might get that would make the getClaimFee negative) for claiming the swap
|
|
181
251
|
*
|
|
182
252
|
* @param signer Signer claiming the swap
|
|
253
|
+
* @param vault
|
|
183
254
|
* @param withdrawalData Withdrawal to claim
|
|
184
255
|
* @param feeRate Optional fee rate (fetched on-demand if not provided)
|
|
185
256
|
*/
|
|
186
|
-
getRawFrontFee?(signer: string, withdrawalData: WithdrawalTX, feeRate?: string): Promise<bigint>;
|
|
257
|
+
getRawFrontFee?(signer: string, vault: Data, withdrawalData: WithdrawalTX, feeRate?: string): Promise<bigint>;
|
|
187
258
|
}
|
|
@@ -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[];
|
|
@@ -33,6 +33,7 @@ export interface SwapContract<T extends SwapData = SwapData, TX = any, PreFetchD
|
|
|
33
33
|
readonly claimWithSecretTimeout: number;
|
|
34
34
|
readonly claimWithTxDataTimeout: number;
|
|
35
35
|
readonly refundTimeout: number;
|
|
36
|
+
readonly supportsInitWithoutClaimer?: boolean;
|
|
36
37
|
/**
|
|
37
38
|
* Initializes the swap contract
|
|
38
39
|
*/
|
|
@@ -189,6 +190,17 @@ export interface SwapContract<T extends SwapData = SwapData, TX = any, PreFetchD
|
|
|
189
190
|
* @param swapData
|
|
190
191
|
*/
|
|
191
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
|
+
}>;
|
|
192
204
|
/**
|
|
193
205
|
* Checks whether a given swap is refundable by us, i.e. it is already expired, we are offerer & swap is committed on-chain
|
|
194
206
|
*
|
|
@@ -308,17 +320,19 @@ export interface SwapContract<T extends SwapData = SwapData, TX = any, PreFetchD
|
|
|
308
320
|
/**
|
|
309
321
|
* Returns the fee in native token base units to commit (initiate) the swap
|
|
310
322
|
*
|
|
323
|
+
* @param signer
|
|
311
324
|
* @param swapData Swap to initiate
|
|
312
325
|
* @param feeRate Optional fee rate (fetched on-demand if not provided)
|
|
313
326
|
*/
|
|
314
|
-
getCommitFee(swapData: T, feeRate?: string): Promise<bigint>;
|
|
327
|
+
getCommitFee(signer: string, swapData: T, feeRate?: string): Promise<bigint>;
|
|
315
328
|
/**
|
|
316
329
|
* Returns raw fee (not including any account deposits we might need) for initiating the swap
|
|
317
330
|
*
|
|
331
|
+
* @param signer
|
|
318
332
|
* @param swapData Swap to initiate
|
|
319
333
|
* @param feeRate Optional fee rate (fetched on-demand if not provided)
|
|
320
334
|
*/
|
|
321
|
-
getRawCommitFee?(swapData: T, feeRate?: string): Promise<bigint>;
|
|
335
|
+
getRawCommitFee?(signer: string, swapData: T, feeRate?: string): Promise<bigint>;
|
|
322
336
|
/**
|
|
323
337
|
* Returns the fee in native token base units to claim the swap
|
|
324
338
|
*
|
|
@@ -338,17 +352,19 @@ export interface SwapContract<T extends SwapData = SwapData, TX = any, PreFetchD
|
|
|
338
352
|
/**
|
|
339
353
|
* Returns the fee in native token base units to refund the swap
|
|
340
354
|
*
|
|
355
|
+
* @param signer
|
|
341
356
|
* @param swapData Swap to refund
|
|
342
357
|
* @param feeRate Optional fee rate (fetched on-demand if not provided)
|
|
343
358
|
*/
|
|
344
|
-
getRefundFee(swapData: T, feeRate?: string): Promise<bigint>;
|
|
359
|
+
getRefundFee(signer: string, swapData: T, feeRate?: string): Promise<bigint>;
|
|
345
360
|
/**
|
|
346
361
|
* Returns raw fee (not including any refunds we might get that would make the getRefundFee negative) for claiming the swap
|
|
347
362
|
*
|
|
363
|
+
* @param signer
|
|
348
364
|
* @param swapData Swap to claim
|
|
349
365
|
* @param feeRate Optional fee rate (fetched on-demand if not provided)
|
|
350
366
|
*/
|
|
351
|
-
getRawRefundFee?(swapData: T, feeRate?: string): Promise<bigint>;
|
|
367
|
+
getRawRefundFee?(signer: string, swapData: T, feeRate?: string): Promise<bigint>;
|
|
352
368
|
/**
|
|
353
369
|
* Returns the fee rate for committing (initializing) a payIn swap
|
|
354
370
|
*
|
package/dist/swaps/SwapData.d.ts
CHANGED
package/dist/swaps/SwapData.js
CHANGED
package/package.json
CHANGED
|
@@ -5,13 +5,21 @@ export type TransactionConfirmationOptions = {
|
|
|
5
5
|
};
|
|
6
6
|
|
|
7
7
|
export type AbstractSigner = {
|
|
8
|
-
|
|
8
|
+
type: "AtomiqAbstractSigner",
|
|
9
|
+
getAddress: () => string,
|
|
10
|
+
init?: () => Promise<void>,
|
|
11
|
+
stop?: () => Promise<void>
|
|
9
12
|
};
|
|
10
13
|
|
|
14
|
+
export function isAbstractSigner(val: any): val is AbstractSigner {
|
|
15
|
+
return typeof(val)==="object" && val.type==="AtomiqAbstractSigner" && typeof(val.getAddress)==="function";
|
|
16
|
+
}
|
|
17
|
+
|
|
11
18
|
export interface ChainInterface<
|
|
12
19
|
TX = any,
|
|
13
20
|
Signer extends AbstractSigner = AbstractSigner,
|
|
14
|
-
ChainId extends string = string
|
|
21
|
+
ChainId extends string = string,
|
|
22
|
+
NativeSigner = any
|
|
15
23
|
> {
|
|
16
24
|
|
|
17
25
|
readonly chainId: ChainId;
|
|
@@ -33,8 +41,16 @@ export interface ChainInterface<
|
|
|
33
41
|
* Checks if a given string is a valid wallet address
|
|
34
42
|
*
|
|
35
43
|
* @param address
|
|
44
|
+
* @param lenient Whether a lenient parsing should be used (i.e. don't strictly enforce the Starknet address lengths)
|
|
45
|
+
*/
|
|
46
|
+
isValidAddress(address: string, lenient?: boolean): boolean;
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Normalizes a given address i.e. pads it to the specific size
|
|
50
|
+
*
|
|
51
|
+
* @param address
|
|
36
52
|
*/
|
|
37
|
-
|
|
53
|
+
normalizeAddress(address: string): string;
|
|
38
54
|
|
|
39
55
|
/**
|
|
40
56
|
* Checks if a given string is a valid token identifier
|
|
@@ -93,6 +109,12 @@ export interface ChainInterface<
|
|
|
93
109
|
*/
|
|
94
110
|
getTxIdStatus(txId: string): Promise<"not_found" | "pending" | "success" | "reverted">;
|
|
95
111
|
|
|
112
|
+
/**
|
|
113
|
+
* Returns the latest known finalized block data (this is a block with 100% certainty of not getting re-org, i.e.
|
|
114
|
+
* a block already committed on L1)
|
|
115
|
+
*/
|
|
116
|
+
getFinalizedBlock(): Promise<{height: number, blockHash: string}>;
|
|
117
|
+
|
|
96
118
|
/**
|
|
97
119
|
* Signs, sends a batch of transaction and optionally waits for their confirmation
|
|
98
120
|
*
|
|
@@ -130,4 +152,9 @@ export interface ChainInterface<
|
|
|
130
152
|
*/
|
|
131
153
|
randomSigner(): Signer;
|
|
132
154
|
|
|
155
|
+
/**
|
|
156
|
+
* Wraps a native chain signer object to an atomiq-understandable AbstractSigner
|
|
157
|
+
*/
|
|
158
|
+
wrapSigner(signer: NativeSigner): Promise<Signer>;
|
|
159
|
+
|
|
133
160
|
}
|
package/src/chains/ChainType.ts
CHANGED
|
@@ -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
|
}
|
package/src/index.ts
CHANGED
|
@@ -21,6 +21,7 @@ export * from "./swaps/SwapCommitState";
|
|
|
21
21
|
export * from "./errors/SignatureVerificationError";
|
|
22
22
|
export * from "./errors/CannotInitializeATAError"
|
|
23
23
|
export * from "./errors/SwapDataVerificationError";
|
|
24
|
+
export * from "./errors/TransactionRevertedError";
|
|
24
25
|
|
|
25
26
|
export * from "./chains/ChainType";
|
|
26
27
|
export * from "./chains/ChainData";
|
|
@@ -44,3 +45,7 @@ export * from "./events/types/spv_vault/SpvVaultClaimEvent";
|
|
|
44
45
|
export * from "./events/types/spv_vault/SpvVaultDepositEvent";
|
|
45
46
|
export * from "./events/types/spv_vault/SpvVaultOpenEvent";
|
|
46
47
|
export * from "./events/types/spv_vault/SpvVaultFrontEvent";
|
|
48
|
+
|
|
49
|
+
export * from "./messaging/Messenger";
|
|
50
|
+
export * from "./messaging/messages/Message";
|
|
51
|
+
export * from "./messaging/messages/SwapClaimWitnessMessage";
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import {Message} from "./messages/Message";
|
|
2
|
+
|
|
3
|
+
export interface Messenger {
|
|
4
|
+
|
|
5
|
+
init(): Promise<void>;
|
|
6
|
+
broadcast(msg: Message): Promise<void>;
|
|
7
|
+
subscribe(callback: (msg: Message) => void): Promise<void>;
|
|
8
|
+
unsubscribe(callback: (msg: Message) => void): Promise<boolean>;
|
|
9
|
+
stop(): Promise<void>;
|
|
10
|
+
|
|
11
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
|
|
2
|
+
export enum MessageType {
|
|
3
|
+
SWAP_CLAIM_WITNESS = 0,
|
|
4
|
+
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
export abstract class Message {
|
|
8
|
+
|
|
9
|
+
abstract type: MessageType;
|
|
10
|
+
|
|
11
|
+
static deserializers: {[type: number]: (obj: any) => Message} = {};
|
|
12
|
+
|
|
13
|
+
serialize(): any {
|
|
14
|
+
return {
|
|
15
|
+
type: this.type
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
static deserialize(message: any): Message {
|
|
20
|
+
const deserializer = Message.deserializers[message.type];
|
|
21
|
+
if(deserializer==null) throw new Error("Unknown message type " + message.type);
|
|
22
|
+
return deserializer(message);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import {SwapData} from "../../swaps/SwapData";
|
|
2
|
+
import {Message, MessageType} from "./Message";
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
export class SwapClaimWitnessMessage<T extends SwapData> extends Message {
|
|
6
|
+
|
|
7
|
+
type = MessageType.SWAP_CLAIM_WITNESS;
|
|
8
|
+
swapData: T;
|
|
9
|
+
witness: string;
|
|
10
|
+
|
|
11
|
+
constructor(swapData: T, witness: string) {
|
|
12
|
+
super();
|
|
13
|
+
this.swapData = swapData;
|
|
14
|
+
this.witness = witness;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
serialize() {
|
|
18
|
+
return {
|
|
19
|
+
...super.serialize(),
|
|
20
|
+
swapData: this.swapData.serialize(),
|
|
21
|
+
witness: this.witness
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
static deserialize(obj: any) {
|
|
26
|
+
if(obj==null || typeof(obj.witness)!=="string" || typeof(obj.swapData)!=="object") {
|
|
27
|
+
throw new Error("Invalid format!");
|
|
28
|
+
}
|
|
29
|
+
return new SwapClaimWitnessMessage(SwapData.deserialize(obj.swapData), obj.witness);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
Message.deserializers[MessageType.SWAP_CLAIM_WITNESS] = SwapClaimWitnessMessage.deserialize;
|
|
@@ -127,6 +127,22 @@ 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
|
+
|
|
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
|
+
|
|
130
146
|
/**
|
|
131
147
|
* Returns current vault data
|
|
132
148
|
*
|
|
@@ -135,6 +151,28 @@ export interface SpvVaultContract<
|
|
|
135
151
|
*/
|
|
136
152
|
getVaultData(owner: string, vaultId: bigint): Promise<Data>;
|
|
137
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
|
+
|
|
138
176
|
/**
|
|
139
177
|
* Returns all currently opened vaults
|
|
140
178
|
* NOTE: This will take a long time, since the implementation will have to go through all the prior events
|
|
@@ -142,11 +180,21 @@ export interface SpvVaultContract<
|
|
|
142
180
|
getAllVaults(owner?: string): Promise<Data[]>;
|
|
143
181
|
|
|
144
182
|
/**
|
|
145
|
-
* Returns current state of the withdrawal
|
|
183
|
+
* Returns current state of the withdrawal, optionally
|
|
184
|
+
* only check withdrawals from the provided block height
|
|
185
|
+
*
|
|
186
|
+
* @param withdrawalTx
|
|
187
|
+
* @param scStartBlockheight
|
|
188
|
+
*/
|
|
189
|
+
getWithdrawalState(withdrawalTx: WithdrawalTX, scStartBlockheight?: number): Promise<SpvWithdrawalState>;
|
|
190
|
+
|
|
191
|
+
/**
|
|
192
|
+
* Returns current state of the withdrawals, optionally
|
|
193
|
+
* only check withdrawals from the provided block height
|
|
146
194
|
*
|
|
147
|
-
* @param
|
|
195
|
+
* @param withdrawalTxs Object with the withdrawal tx to check + an optional start blockheight
|
|
148
196
|
*/
|
|
149
|
-
|
|
197
|
+
getWithdrawalStates(withdrawalTxs: {withdrawal: WithdrawalTX, scStartBlockheight?: number}[]): Promise<{[btcTxId: string]: SpvWithdrawalState}>;
|
|
150
198
|
|
|
151
199
|
/**
|
|
152
200
|
* Parses withdrawal data from the parsed bitcoin transaction
|
|
@@ -183,36 +231,40 @@ export interface SpvVaultContract<
|
|
|
183
231
|
* Returns the fee in native token base units to claim the swap
|
|
184
232
|
*
|
|
185
233
|
* @param signer Signer claiming the swap
|
|
234
|
+
* @param vault
|
|
186
235
|
* @param withdrawalData Withdrawal to claim
|
|
187
236
|
* @param feeRate Optional fee rate (fetched on-demand if not provided)
|
|
188
237
|
*/
|
|
189
|
-
getClaimFee(signer: string, withdrawalData: WithdrawalTX, feeRate?: string): Promise<bigint>;
|
|
238
|
+
getClaimFee(signer: string, vault: Data, withdrawalData: WithdrawalTX, feeRate?: string): Promise<bigint>;
|
|
190
239
|
|
|
191
240
|
/**
|
|
192
241
|
* Returns raw fee (not including any refunds we might get that would make the getClaimFee negative) for claiming the swap
|
|
193
242
|
*
|
|
194
243
|
* @param signer Signer claiming the swap
|
|
244
|
+
* @param vault
|
|
195
245
|
* @param withdrawalData Withdrawal to claim
|
|
196
246
|
* @param feeRate Optional fee rate (fetched on-demand if not provided)
|
|
197
247
|
*/
|
|
198
|
-
getRawClaimFee?(signer: string, withdrawalData: WithdrawalTX, feeRate?: string): Promise<bigint>;
|
|
248
|
+
getRawClaimFee?(signer: string, vault: Data, withdrawalData: WithdrawalTX, feeRate?: string): Promise<bigint>;
|
|
199
249
|
|
|
200
250
|
/**
|
|
201
251
|
* Returns the fee in native token base units to claim the swap
|
|
202
252
|
*
|
|
203
253
|
* @param signer Signer claiming the swap
|
|
254
|
+
* @param vault
|
|
204
255
|
* @param withdrawalData Withdrawal to claim
|
|
205
256
|
* @param feeRate Optional fee rate (fetched on-demand if not provided)
|
|
206
257
|
*/
|
|
207
|
-
getFrontFee(signer: string, withdrawalData: WithdrawalTX, feeRate?: string): Promise<bigint>;
|
|
258
|
+
getFrontFee(signer: string, vault: Data, withdrawalData: WithdrawalTX, feeRate?: string): Promise<bigint>;
|
|
208
259
|
|
|
209
260
|
/**
|
|
210
261
|
* Returns raw fee (not including any refunds we might get that would make the getClaimFee negative) for claiming the swap
|
|
211
262
|
*
|
|
212
263
|
* @param signer Signer claiming the swap
|
|
264
|
+
* @param vault
|
|
213
265
|
* @param withdrawalData Withdrawal to claim
|
|
214
266
|
* @param feeRate Optional fee rate (fetched on-demand if not provided)
|
|
215
267
|
*/
|
|
216
|
-
getRawFrontFee?(signer: string, withdrawalData: WithdrawalTX, feeRate?: string): Promise<bigint>;
|
|
268
|
+
getRawFrontFee?(signer: string, vault: Data, withdrawalData: WithdrawalTX, feeRate?: string): Promise<bigint>;
|
|
217
269
|
|
|
218
270
|
}
|
|
@@ -44,6 +44,7 @@ export interface SwapContract<
|
|
|
44
44
|
readonly claimWithSecretTimeout: number;
|
|
45
45
|
readonly claimWithTxDataTimeout: number;
|
|
46
46
|
readonly refundTimeout: number;
|
|
47
|
+
readonly supportsInitWithoutClaimer?: boolean;
|
|
47
48
|
|
|
48
49
|
/**
|
|
49
50
|
* Initializes the swap contract
|
|
@@ -237,6 +238,13 @@ export interface SwapContract<
|
|
|
237
238
|
*/
|
|
238
239
|
getCommitStatus(signer: string, swapData: T): Promise<SwapCommitState>;
|
|
239
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
|
+
|
|
240
248
|
/**
|
|
241
249
|
* Checks whether a given swap is refundable by us, i.e. it is already expired, we are offerer & swap is committed on-chain
|
|
242
250
|
*
|
|
@@ -384,18 +392,20 @@ export interface SwapContract<
|
|
|
384
392
|
/**
|
|
385
393
|
* Returns the fee in native token base units to commit (initiate) the swap
|
|
386
394
|
*
|
|
395
|
+
* @param signer
|
|
387
396
|
* @param swapData Swap to initiate
|
|
388
397
|
* @param feeRate Optional fee rate (fetched on-demand if not provided)
|
|
389
398
|
*/
|
|
390
|
-
getCommitFee(swapData: T, feeRate?: string): Promise<bigint>;
|
|
399
|
+
getCommitFee(signer: string, swapData: T, feeRate?: string): Promise<bigint>;
|
|
391
400
|
|
|
392
401
|
/**
|
|
393
402
|
* Returns raw fee (not including any account deposits we might need) for initiating the swap
|
|
394
403
|
*
|
|
404
|
+
* @param signer
|
|
395
405
|
* @param swapData Swap to initiate
|
|
396
406
|
* @param feeRate Optional fee rate (fetched on-demand if not provided)
|
|
397
407
|
*/
|
|
398
|
-
getRawCommitFee?(swapData: T, feeRate?: string): Promise<bigint>;
|
|
408
|
+
getRawCommitFee?(signer: string, swapData: T, feeRate?: string): Promise<bigint>;
|
|
399
409
|
|
|
400
410
|
/**
|
|
401
411
|
* Returns the fee in native token base units to claim the swap
|
|
@@ -418,18 +428,20 @@ export interface SwapContract<
|
|
|
418
428
|
/**
|
|
419
429
|
* Returns the fee in native token base units to refund the swap
|
|
420
430
|
*
|
|
431
|
+
* @param signer
|
|
421
432
|
* @param swapData Swap to refund
|
|
422
433
|
* @param feeRate Optional fee rate (fetched on-demand if not provided)
|
|
423
434
|
*/
|
|
424
|
-
getRefundFee(swapData: T, feeRate?: string): Promise<bigint>;
|
|
435
|
+
getRefundFee(signer: string, swapData: T, feeRate?: string): Promise<bigint>;
|
|
425
436
|
|
|
426
437
|
/**
|
|
427
438
|
* Returns raw fee (not including any refunds we might get that would make the getRefundFee negative) for claiming the swap
|
|
428
439
|
*
|
|
440
|
+
* @param signer
|
|
429
441
|
* @param swapData Swap to claim
|
|
430
442
|
* @param feeRate Optional fee rate (fetched on-demand if not provided)
|
|
431
443
|
*/
|
|
432
|
-
getRawRefundFee?(swapData: T, feeRate?: string): Promise<bigint>;
|
|
444
|
+
getRawRefundFee?(signer: string, swapData: T, feeRate?: string): Promise<bigint>;
|
|
433
445
|
|
|
434
446
|
/**
|
|
435
447
|
* Returns the fee rate for committing (initializing) a payIn swap
|
package/src/swaps/SwapData.ts
CHANGED
|
@@ -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 = {}));
|