@atomiqlabs/base 12.0.4 → 13.0.4
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/btc/BitcoinNetwork.d.ts +5 -0
- package/dist/btc/BitcoinNetwork.js +5 -0
- package/dist/btc/rpc/BitcoinRpc.d.ts +168 -7
- package/dist/btcrelay/BtcRelay.d.ts +115 -6
- package/dist/btcrelay/synchronizer/RelaySynchronizer.d.ts +55 -14
- package/dist/btcrelay/types/BtcBlock.d.ts +32 -0
- package/dist/btcrelay/types/BtcHeader.d.ts +23 -0
- package/dist/btcrelay/types/BtcStoredHeader.d.ts +26 -0
- package/dist/btcrelay/utils/StatePredictorUtils.d.ts +5 -0
- package/dist/btcrelay/utils/StatePredictorUtils.js +5 -0
- package/dist/chains/ChainData.d.ts +41 -1
- package/dist/chains/ChainInterface.d.ts +44 -1
- package/dist/chains/ChainInterface.js +5 -0
- package/dist/chains/ChainType.d.ts +7 -1
- package/dist/errors/CannotInitializeATAError.d.ts +5 -0
- package/dist/errors/CannotInitializeATAError.js +5 -0
- package/dist/errors/SignatureVerificationError.d.ts +5 -0
- package/dist/errors/SignatureVerificationError.js +5 -0
- package/dist/errors/SwapDataVerificationError.d.ts +5 -0
- package/dist/errors/SwapDataVerificationError.js +5 -0
- package/dist/errors/TransactionRevertedError.d.ts +5 -0
- package/dist/errors/TransactionRevertedError.js +5 -0
- package/dist/events/ChainEvents.d.ts +40 -2
- package/dist/events/types/ChainEvent.d.ts +8 -0
- package/dist/events/types/ChainEvent.js +5 -0
- package/dist/events/types/spv_vault/SpvVaultClaimEvent.d.ts +29 -0
- package/dist/events/types/spv_vault/SpvVaultClaimEvent.js +5 -0
- package/dist/events/types/spv_vault/SpvVaultCloseEvent.d.ts +13 -0
- package/dist/events/types/spv_vault/SpvVaultCloseEvent.js +7 -0
- package/dist/events/types/spv_vault/SpvVaultDepositEvent.d.ts +12 -0
- package/dist/events/types/spv_vault/SpvVaultDepositEvent.js +5 -0
- package/dist/events/types/spv_vault/SpvVaultEvent.d.ts +18 -2
- package/dist/events/types/spv_vault/SpvVaultEvent.js +10 -0
- package/dist/events/types/spv_vault/SpvVaultFrontEvent.d.ts +22 -0
- package/dist/events/types/spv_vault/SpvVaultFrontEvent.js +5 -0
- package/dist/events/types/spv_vault/SpvVaultOpenEvent.d.ts +11 -0
- package/dist/events/types/spv_vault/SpvVaultOpenEvent.js +5 -0
- package/dist/events/types/swap/ClaimEvent.d.ts +8 -0
- package/dist/events/types/swap/ClaimEvent.js +6 -0
- package/dist/events/types/swap/InitializeEvent.d.ts +13 -2
- package/dist/events/types/swap/InitializeEvent.js +6 -0
- package/dist/events/types/swap/RefundEvent.d.ts +5 -0
- package/dist/events/types/swap/RefundEvent.js +9 -0
- package/dist/events/types/swap/SwapEvent.d.ts +15 -2
- package/dist/events/types/swap/SwapEvent.js +10 -0
- package/dist/lockable/Lockable.d.ts +18 -0
- package/dist/lockable/Lockable.js +18 -0
- package/dist/messaging/Messenger.d.ts +32 -0
- package/dist/messaging/messages/Message.d.ts +24 -1
- package/dist/messaging/messages/Message.js +23 -0
- package/dist/messaging/messages/SwapClaimWitnessMessage.d.ts +22 -4
- package/dist/messaging/messages/SwapClaimWitnessMessage.js +12 -0
- package/dist/spv_swap/SpvVaultContract.d.ts +18 -10
- package/dist/spv_swap/SpvVaultData.d.ts +76 -0
- package/dist/spv_swap/SpvVaultData.js +19 -0
- package/dist/spv_swap/SpvWithdrawalState.d.ts +46 -0
- package/dist/spv_swap/SpvWithdrawalState.js +19 -0
- package/dist/spv_swap/SpvWithdrawalTransactionData.d.ts +94 -3
- package/dist/spv_swap/SpvWithdrawalTransactionData.js +81 -4
- package/dist/storage/IStorageManager.d.ts +37 -0
- package/dist/storage/StorageObject.d.ts +8 -0
- package/dist/swaps/ChainSwapType.d.ts +22 -0
- package/dist/swaps/ChainSwapType.js +22 -0
- package/dist/swaps/SwapCommitState.d.ts +50 -0
- package/dist/swaps/SwapCommitState.js +20 -0
- package/dist/swaps/SwapContract.d.ts +58 -2
- package/dist/swaps/SwapData.d.ts +147 -6
- package/dist/swaps/SwapData.js +20 -0
- package/dist/utils/BigIntBufferUtils.d.ts +5 -0
- package/dist/utils/BigIntBufferUtils.js +6 -1
- package/package.json +5 -3
- package/src/btc/BitcoinNetwork.ts +5 -1
- package/src/btc/rpc/BitcoinRpc.ts +175 -8
- package/src/btcrelay/BtcRelay.ts +121 -7
- package/src/btcrelay/synchronizer/RelaySynchronizer.ts +51 -10
- package/src/btcrelay/types/BtcBlock.ts +40 -0
- package/src/btcrelay/types/BtcHeader.ts +31 -3
- package/src/btcrelay/types/BtcStoredHeader.ts +31 -0
- package/src/btcrelay/utils/StatePredictorUtils.ts +5 -0
- package/src/chains/ChainData.ts +41 -1
- package/src/chains/ChainInterface.ts +47 -0
- package/src/chains/ChainType.ts +10 -3
- package/src/errors/CannotInitializeATAError.ts +5 -1
- package/src/errors/SignatureVerificationError.ts +5 -1
- package/src/errors/SwapDataVerificationError.ts +5 -1
- package/src/errors/TransactionRevertedError.ts +5 -1
- package/src/events/ChainEvents.ts +44 -2
- package/src/events/types/ChainEvent.ts +8 -0
- package/src/events/types/spv_vault/SpvVaultClaimEvent.ts +29 -0
- package/src/events/types/spv_vault/SpvVaultCloseEvent.ts +13 -0
- package/src/events/types/spv_vault/SpvVaultDepositEvent.ts +13 -0
- package/src/events/types/spv_vault/SpvVaultEvent.ts +18 -3
- package/src/events/types/spv_vault/SpvVaultFrontEvent.ts +22 -0
- package/src/events/types/spv_vault/SpvVaultOpenEvent.ts +11 -0
- package/src/events/types/swap/ClaimEvent.ts +9 -2
- package/src/events/types/swap/InitializeEvent.ts +14 -4
- package/src/events/types/swap/RefundEvent.ts +6 -1
- package/src/events/types/swap/SwapEvent.ts +15 -3
- package/src/lockable/Lockable.ts +18 -2
- package/src/messaging/Messenger.ts +37 -0
- package/src/messaging/messages/Message.ts +24 -3
- package/src/messaging/messages/SwapClaimWitnessMessage.ts +23 -6
- package/src/spv_swap/SpvVaultContract.ts +19 -12
- package/src/spv_swap/SpvVaultData.ts +84 -0
- package/src/spv_swap/SpvWithdrawalState.ts +46 -1
- package/src/spv_swap/SpvWithdrawalTransactionData.ts +102 -7
- package/src/storage/IStorageManager.ts +41 -0
- package/src/storage/StorageObject.ts +8 -2
- package/src/swaps/ChainSwapType.ts +22 -0
- package/src/swaps/SwapCommitState.ts +50 -0
- package/src/swaps/SwapContract.ts +58 -2
- package/src/swaps/SwapData.ts +160 -7
- package/src/utils/BigIntBufferUtils.ts +6 -1
|
@@ -3,6 +3,11 @@ import { BitcoinRpc } from "../btc/rpc/BitcoinRpc";
|
|
|
3
3
|
import { BitcoinNetwork } from "../btc/BitcoinNetwork";
|
|
4
4
|
import { IStorageManager } from "../storage/IStorageManager";
|
|
5
5
|
import { StorageObject } from "../storage/StorageObject";
|
|
6
|
+
/**
|
|
7
|
+
* A type defining tokens available on the selected chain, indexed by ticker
|
|
8
|
+
*
|
|
9
|
+
* @category Tokens
|
|
10
|
+
*/
|
|
6
11
|
export type BaseTokenType<T extends string = string> = {
|
|
7
12
|
[ticker in T]: {
|
|
8
13
|
address: string;
|
|
@@ -10,6 +15,11 @@ export type BaseTokenType<T extends string = string> = {
|
|
|
10
15
|
displayDecimals?: number;
|
|
11
16
|
};
|
|
12
17
|
};
|
|
18
|
+
/**
|
|
19
|
+
* A comprehensive chain data type for a specific chain
|
|
20
|
+
*
|
|
21
|
+
* @category Chains
|
|
22
|
+
*/
|
|
13
23
|
export type ChainData<T extends ChainType> = {
|
|
14
24
|
chainId: ChainType["ChainId"];
|
|
15
25
|
chainInterface: T["ChainInterface"];
|
|
@@ -21,11 +31,41 @@ export type ChainData<T extends ChainType> = {
|
|
|
21
31
|
spvVaultDataConstructor: new (data: any) => T["SpvVaultData"];
|
|
22
32
|
spvVaultWithdrawalDataConstructor: new (data: any) => T["SpvVaultWithdrawalData"];
|
|
23
33
|
};
|
|
34
|
+
/**
|
|
35
|
+
* An initializer function that returns populated {@link ChainData} for a given chain based on the passed
|
|
36
|
+
* arguments
|
|
37
|
+
*
|
|
38
|
+
* @category Chains
|
|
39
|
+
*/
|
|
24
40
|
export type ChainInitializerFn<O, C extends ChainType> = (options: O, bitcoinRpc: BitcoinRpc<any>, network: BitcoinNetwork, storageCtor: <T extends StorageObject>(name: string) => IStorageManager<T>) => ChainData<C>;
|
|
41
|
+
/**
|
|
42
|
+
* Chain definition containing
|
|
43
|
+
*
|
|
44
|
+
* @category Chains
|
|
45
|
+
*/
|
|
25
46
|
export type ChainInitializer<O, C extends ChainType, T extends BaseTokenType> = {
|
|
47
|
+
/**
|
|
48
|
+
* Chain identifier string
|
|
49
|
+
*/
|
|
26
50
|
chainId: C["ChainId"];
|
|
27
|
-
|
|
51
|
+
/**
|
|
52
|
+
* Initializer function returning the {@link ChainData}
|
|
53
|
+
*/
|
|
28
54
|
initializer: ChainInitializerFn<O, C>;
|
|
55
|
+
/**
|
|
56
|
+
* Available tokens on the chain
|
|
57
|
+
*/
|
|
29
58
|
tokens: T;
|
|
59
|
+
/**
|
|
60
|
+
* Chain type
|
|
61
|
+
*
|
|
62
|
+
* NOTE: This is just a type reference, should not be used as value
|
|
63
|
+
*/
|
|
64
|
+
chainType: C;
|
|
65
|
+
/**
|
|
66
|
+
* The type of the options to be passed to the initializer function
|
|
67
|
+
*
|
|
68
|
+
* NOTE: This is just a type reference, should not be used as value
|
|
69
|
+
*/
|
|
30
70
|
options: O;
|
|
31
71
|
};
|
|
@@ -1,16 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @category Chain
|
|
3
|
+
*/
|
|
1
4
|
export type TransactionConfirmationOptions = {
|
|
2
5
|
waitForConfirmation?: boolean;
|
|
3
6
|
abortSignal?: AbortSignal;
|
|
4
7
|
feeRate?: string;
|
|
5
8
|
};
|
|
9
|
+
/**
|
|
10
|
+
* Defines of a signer, contains an address getter and optionally init() & stop() functions
|
|
11
|
+
* to initiate internal processes inside the signer (if required and exposed)
|
|
12
|
+
*
|
|
13
|
+
* @category Signer
|
|
14
|
+
*/
|
|
6
15
|
export type AbstractSigner = {
|
|
7
16
|
type: "AtomiqAbstractSigner";
|
|
8
17
|
getAddress: () => string;
|
|
9
18
|
init?: () => Promise<void>;
|
|
10
19
|
stop?: () => Promise<void>;
|
|
11
20
|
};
|
|
21
|
+
/**
|
|
22
|
+
* Type guard for the {@link AbstractSigner} type
|
|
23
|
+
*
|
|
24
|
+
* @param val
|
|
25
|
+
*/
|
|
12
26
|
export declare function isAbstractSigner(val: any): val is AbstractSigner;
|
|
13
|
-
|
|
27
|
+
/**
|
|
28
|
+
* An interface representing a smart chain, allowing basic operations on the chain and reading chain data
|
|
29
|
+
*/
|
|
30
|
+
export interface ChainInterface<TX = any, SignedTX = any, Signer extends AbstractSigner = AbstractSigner, ChainId extends string = string, NativeSigner = any> {
|
|
31
|
+
/**
|
|
32
|
+
* Chain identifier string
|
|
33
|
+
*/
|
|
14
34
|
readonly chainId: ChainId;
|
|
15
35
|
/**
|
|
16
36
|
* Returns the token balance of a specific address
|
|
@@ -74,6 +94,18 @@ export interface ChainInterface<TX = any, Signer extends AbstractSigner = Abstra
|
|
|
74
94
|
* @param txData Serialized transaction data string
|
|
75
95
|
*/
|
|
76
96
|
deserializeTx(txData: string): Promise<TX>;
|
|
97
|
+
/**
|
|
98
|
+
* Serializes a given transaction to a string
|
|
99
|
+
*
|
|
100
|
+
* @param signedTX Transaction to serialize
|
|
101
|
+
*/
|
|
102
|
+
serializeSignedTx(signedTX: SignedTX): Promise<string>;
|
|
103
|
+
/**
|
|
104
|
+
* Deserializes a transaction from string
|
|
105
|
+
*
|
|
106
|
+
* @param txData Serialized transaction data string
|
|
107
|
+
*/
|
|
108
|
+
deserializeSignedTx(txData: string): Promise<SignedTX>;
|
|
77
109
|
/**
|
|
78
110
|
* Returns the status of the given serialized transaction
|
|
79
111
|
*
|
|
@@ -106,6 +138,17 @@ export interface ChainInterface<TX = any, Signer extends AbstractSigner = Abstra
|
|
|
106
138
|
* @param onBeforePublish Callback called before a tx is broadcast
|
|
107
139
|
*/
|
|
108
140
|
sendAndConfirm(signer: Signer, txs: TX[], waitForConfirmation?: boolean, abortSignal?: AbortSignal, parallel?: boolean, onBeforePublish?: (txId: string, rawTx: string) => Promise<void>): Promise<string[]>;
|
|
141
|
+
/**
|
|
142
|
+
* Sends already signed transactions and optionally waits for their confirmation
|
|
143
|
+
*
|
|
144
|
+
* @param signedTxs Signed transactions to be sent
|
|
145
|
+
* @param waitForConfirmation Whether to wait for transaction confirmation (if parallel is not specified,
|
|
146
|
+
* every transaction's confirmation except the last one is awaited)
|
|
147
|
+
* @param abortSignal Abort signal
|
|
148
|
+
* @param parallel Whether to send all transactions in parallel or one by one (always waiting for the previous TX to confirm)
|
|
149
|
+
* @param onBeforePublish Callback called before a tx is broadcast
|
|
150
|
+
*/
|
|
151
|
+
sendSignedAndConfirm(signedTxs: SignedTX[], waitForConfirmation?: boolean, abortSignal?: AbortSignal, parallel?: boolean, onBeforePublish?: (txId: string, rawTx: string) => Promise<void>): Promise<string[]>;
|
|
109
152
|
/**
|
|
110
153
|
* Callback called when transaction is being replaced (used for EVM, when fee is bumped on an unconfirmed tx)
|
|
111
154
|
*
|
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.isAbstractSigner = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Type guard for the {@link AbstractSigner} type
|
|
6
|
+
*
|
|
7
|
+
* @param val
|
|
8
|
+
*/
|
|
4
9
|
function isAbstractSigner(val) {
|
|
5
10
|
return typeof (val) === "object" && val.type === "AtomiqAbstractSigner" && typeof (val.getAddress) === "function";
|
|
6
11
|
}
|
|
@@ -6,11 +6,17 @@ 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
|
-
|
|
9
|
+
/**
|
|
10
|
+
* A comprehensive unified type struct for a given chain, contains all the type definitions of a given chain
|
|
11
|
+
*
|
|
12
|
+
* @category Chains
|
|
13
|
+
*/
|
|
14
|
+
export type ChainType<ChainId extends string = string, PreFetchData = any, PreFetchVerification = any, TXType = any, SignedTXType = 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, SignedTXType, Signer, ChainId, NativeSigner> = ChainInterface<TXType, SignedTXType, Signer, ChainId, NativeSigner>, E extends ChainEvents<T> = ChainEvents<T>, B extends BtcRelay<any, TXType, any, Signer> = BtcRelay<any, TXType, any, Signer>, SpvWithdrawalData extends SpvWithdrawalTransactionData = SpvWithdrawalTransactionData, SpvData extends SpvVaultData<SpvWithdrawalData> = SpvVaultData<SpvWithdrawalData>, SpvContract extends SpvVaultContract<TXType, Signer, ChainId, SpvWithdrawalData, SpvData> = SpvVaultContract<TXType, Signer, ChainId, SpvWithdrawalData, SpvData>> = {
|
|
10
15
|
ChainId: ChainId;
|
|
11
16
|
PreFetchData: PreFetchData;
|
|
12
17
|
PreFetchVerification: PreFetchVerification;
|
|
13
18
|
TX: TXType;
|
|
19
|
+
SignedTXType: SignedTXType;
|
|
14
20
|
Signer: Signer;
|
|
15
21
|
ChainInterface: I;
|
|
16
22
|
Data: T;
|
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.CannotInitializeATAError = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Represents a Solana-specific error when an ATA (associated token account) couldn't be initialized
|
|
6
|
+
*
|
|
7
|
+
* @category Errors
|
|
8
|
+
*/
|
|
4
9
|
class CannotInitializeATAError extends Error {
|
|
5
10
|
constructor(msg) {
|
|
6
11
|
super(msg);
|
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.SignatureVerificationError = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Represents a signature verification error
|
|
6
|
+
*
|
|
7
|
+
* @category Errors
|
|
8
|
+
*/
|
|
4
9
|
class SignatureVerificationError extends Error {
|
|
5
10
|
constructor(msg) {
|
|
6
11
|
super(msg);
|
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.SwapDataVerificationError = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Represents an error or inconsistency when verifying {@link SwapData}
|
|
6
|
+
*
|
|
7
|
+
* @category Errors
|
|
8
|
+
*/
|
|
4
9
|
class SwapDataVerificationError extends Error {
|
|
5
10
|
constructor(msg) {
|
|
6
11
|
super(msg);
|
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.TransactionRevertedError = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Indicates that the sent transaction has reverted (i.e. was confirmed but the execution failed)
|
|
6
|
+
*
|
|
7
|
+
* @category Errors
|
|
8
|
+
*/
|
|
4
9
|
class TransactionRevertedError extends Error {
|
|
5
10
|
constructor(msg) {
|
|
6
11
|
super(msg);
|
|
@@ -1,9 +1,47 @@
|
|
|
1
1
|
import { SwapData } from "../swaps/SwapData";
|
|
2
2
|
import { ChainEvent } from "./types/ChainEvent";
|
|
3
|
+
/**
|
|
4
|
+
* A type of the on-chain event listener callback
|
|
5
|
+
*
|
|
6
|
+
* @category Events
|
|
7
|
+
*/
|
|
3
8
|
export type EventListener<T extends SwapData> = (obj: ChainEvent<T>[]) => Promise<boolean>;
|
|
4
|
-
|
|
5
|
-
|
|
9
|
+
/**
|
|
10
|
+
* An interface defining an on-chain events listener, allowing registering callbacks to receive on-chain events
|
|
11
|
+
*
|
|
12
|
+
* @category Events
|
|
13
|
+
*/
|
|
14
|
+
export interface ChainEvents<T extends SwapData, S extends any = any> {
|
|
15
|
+
/**
|
|
16
|
+
* Initializes the chains event listener, by default this initiates a websocket events subscription or
|
|
17
|
+
* HTTP polling for new events.
|
|
18
|
+
*
|
|
19
|
+
* @param noAutomaticPoll When this flag is passed the listener doesn't initiate the websocket events subscription
|
|
20
|
+
* or HTTP polling, instead it relies on the implementor calling the {@link ChainEvents.poll} to fetch new events
|
|
21
|
+
*/
|
|
22
|
+
init(noAutomaticPoll?: boolean): Promise<void>;
|
|
23
|
+
/**
|
|
24
|
+
* Registers a new listener to listen for on-chain events
|
|
25
|
+
*
|
|
26
|
+
* @param cbk
|
|
27
|
+
*/
|
|
6
28
|
registerListener(cbk: EventListener<T>): void;
|
|
29
|
+
/**
|
|
30
|
+
* Unregisters a previously registered events listener, returning `true` if success, `false` if failed
|
|
31
|
+
*
|
|
32
|
+
* @param cbk
|
|
33
|
+
*/
|
|
7
34
|
unregisterListener(cbk: EventListener<T>): boolean;
|
|
35
|
+
/**
|
|
36
|
+
* Stops the event listener's polling and websocket subscription
|
|
37
|
+
*/
|
|
8
38
|
stop(): Promise<void>;
|
|
39
|
+
/**
|
|
40
|
+
* Triggers a single poll on the events instance, usually ran automatically, but should be called manually
|
|
41
|
+
* when initiated with `noAutomaticPoll`=`true`
|
|
42
|
+
*
|
|
43
|
+
* @param currentState The current state of the chain events
|
|
44
|
+
* @returns The new state that should be saved, persisted and passed to the subsequent `poll()` call
|
|
45
|
+
*/
|
|
46
|
+
poll(currentState?: S): Promise<S | null>;
|
|
9
47
|
}
|
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
import { SwapData } from "../../swaps/SwapData";
|
|
2
|
+
/**
|
|
3
|
+
* Represents a processed on-chain event
|
|
4
|
+
*
|
|
5
|
+
* @category Events
|
|
6
|
+
*/
|
|
2
7
|
export declare class ChainEvent<T extends SwapData> {
|
|
8
|
+
/**
|
|
9
|
+
* Event metadata
|
|
10
|
+
*/
|
|
3
11
|
meta?: {
|
|
4
12
|
blockTime: number;
|
|
5
13
|
txId: string;
|
|
@@ -1,12 +1,41 @@
|
|
|
1
1
|
import { SpvVaultEvent, SpvVaultEventType } from "./SpvVaultEvent";
|
|
2
|
+
/**
|
|
3
|
+
* SPV vault (UTXO-controlled vault) Claim event representation, a valid withdrawal from an SPV vault
|
|
4
|
+
*
|
|
5
|
+
* @category Events
|
|
6
|
+
*/
|
|
2
7
|
export declare class SpvVaultClaimEvent extends SpvVaultEvent<SpvVaultEventType.CLAIM> {
|
|
3
8
|
readonly eventType = SpvVaultEventType.CLAIM;
|
|
9
|
+
/**
|
|
10
|
+
* Which bitcoin transaction authorized this claim (withdrawal) from the vault
|
|
11
|
+
*/
|
|
4
12
|
btcTxId: string;
|
|
13
|
+
/**
|
|
14
|
+
* Recipient of the withdrawn funds
|
|
15
|
+
*/
|
|
5
16
|
recipient: string;
|
|
17
|
+
/**
|
|
18
|
+
* If funds should transfered to the execution contract (swap+) this specifies the execution hash of the scheduled
|
|
19
|
+
* execution
|
|
20
|
+
*/
|
|
6
21
|
executionHash: string;
|
|
22
|
+
/**
|
|
23
|
+
* Scaled token amounts that have been claim (withdrawn) from the vault (NOTE: These are scaled by the corresponding vault-defined
|
|
24
|
+
* multiplier for the tokens)
|
|
25
|
+
*/
|
|
7
26
|
amounts: bigint[];
|
|
27
|
+
/**
|
|
28
|
+
* Address of the party which submitted the claim (withdrawal) transaction on the smart chain side
|
|
29
|
+
*/
|
|
8
30
|
caller: string;
|
|
31
|
+
/**
|
|
32
|
+
* If the withdrawal was fronted, this contains an address of the party which fronted it, or 0 address if the
|
|
33
|
+
* withdrawal was not fronted
|
|
34
|
+
*/
|
|
9
35
|
frontingAddress: string;
|
|
36
|
+
/**
|
|
37
|
+
* The sequence of this claim (withdrawal) - i.e. the total number of deposits done before this one
|
|
38
|
+
*/
|
|
10
39
|
withdrawCount: number;
|
|
11
40
|
constructor(owner: string, vaultId: bigint, btcTxId: string, recipient: string, executionHash: string, amounts: bigint[], caller: string, frontingAddress: string, withdrawCount: number);
|
|
12
41
|
}
|
|
@@ -2,6 +2,11 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.SpvVaultClaimEvent = void 0;
|
|
4
4
|
const SpvVaultEvent_1 = require("./SpvVaultEvent");
|
|
5
|
+
/**
|
|
6
|
+
* SPV vault (UTXO-controlled vault) Claim event representation, a valid withdrawal from an SPV vault
|
|
7
|
+
*
|
|
8
|
+
* @category Events
|
|
9
|
+
*/
|
|
5
10
|
class SpvVaultClaimEvent extends SpvVaultEvent_1.SpvVaultEvent {
|
|
6
11
|
constructor(owner, vaultId, btcTxId, recipient, executionHash, amounts, caller, frontingAddress, withdrawCount) {
|
|
7
12
|
super(owner, vaultId);
|
|
@@ -1,7 +1,20 @@
|
|
|
1
1
|
import { SpvVaultEvent, SpvVaultEventType } from "./SpvVaultEvent";
|
|
2
|
+
/**
|
|
3
|
+
* SPV vault (UTXO-controlled vault) Close event representation, a withdrawal with invalid transaction
|
|
4
|
+
* spending the vault UTXO but not correctly comitting the data has been made, this returns the full
|
|
5
|
+
* balance of the vault back to its owner.
|
|
6
|
+
*
|
|
7
|
+
* @category Events
|
|
8
|
+
*/
|
|
2
9
|
export declare class SpvVaultCloseEvent extends SpvVaultEvent<SpvVaultEventType.CLOSE> {
|
|
3
10
|
readonly eventType = SpvVaultEventType.CLOSE;
|
|
11
|
+
/**
|
|
12
|
+
* Bitcoin transaction ID that caused the error and close event to happen
|
|
13
|
+
*/
|
|
4
14
|
btcTxId: string;
|
|
15
|
+
/**
|
|
16
|
+
* A representation of the actual error that has happened
|
|
17
|
+
*/
|
|
5
18
|
error: string;
|
|
6
19
|
constructor(owner: string, vaultId: bigint, btcTxId: string, error: string);
|
|
7
20
|
}
|
|
@@ -2,6 +2,13 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.SpvVaultCloseEvent = void 0;
|
|
4
4
|
const SpvVaultEvent_1 = require("./SpvVaultEvent");
|
|
5
|
+
/**
|
|
6
|
+
* SPV vault (UTXO-controlled vault) Close event representation, a withdrawal with invalid transaction
|
|
7
|
+
* spending the vault UTXO but not correctly comitting the data has been made, this returns the full
|
|
8
|
+
* balance of the vault back to its owner.
|
|
9
|
+
*
|
|
10
|
+
* @category Events
|
|
11
|
+
*/
|
|
5
12
|
class SpvVaultCloseEvent extends SpvVaultEvent_1.SpvVaultEvent {
|
|
6
13
|
constructor(owner, vaultId, btcTxId, error) {
|
|
7
14
|
super(owner, vaultId);
|
|
@@ -1,7 +1,19 @@
|
|
|
1
1
|
import { SpvVaultEvent, SpvVaultEventType } from "./SpvVaultEvent";
|
|
2
|
+
/**
|
|
3
|
+
* SPV vault (UTXO-controlled vault) Deposit event representation, additional funds have been deposited to the SPV vault
|
|
4
|
+
*
|
|
5
|
+
* @category Events
|
|
6
|
+
*/
|
|
2
7
|
export declare class SpvVaultDepositEvent extends SpvVaultEvent<SpvVaultEventType.DEPOSIT> {
|
|
3
8
|
readonly eventType = SpvVaultEventType.DEPOSIT;
|
|
9
|
+
/**
|
|
10
|
+
* Scaled token amounts that have been deposited to the vault (NOTE: These are scaled by the corresponding vault-defined
|
|
11
|
+
* multiplier for the tokens)
|
|
12
|
+
*/
|
|
4
13
|
amounts: bigint[];
|
|
14
|
+
/**
|
|
15
|
+
* The sequence of this deposit - i.e. the total number of deposits done before this one
|
|
16
|
+
*/
|
|
5
17
|
depositCount: number;
|
|
6
18
|
constructor(owner: string, vaultId: bigint, amounts: bigint[], depositCount: number);
|
|
7
19
|
}
|
|
@@ -2,6 +2,11 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.SpvVaultDepositEvent = void 0;
|
|
4
4
|
const SpvVaultEvent_1 = require("./SpvVaultEvent");
|
|
5
|
+
/**
|
|
6
|
+
* SPV vault (UTXO-controlled vault) Deposit event representation, additional funds have been deposited to the SPV vault
|
|
7
|
+
*
|
|
8
|
+
* @category Events
|
|
9
|
+
*/
|
|
5
10
|
class SpvVaultDepositEvent extends SpvVaultEvent_1.SpvVaultEvent {
|
|
6
11
|
constructor(owner, vaultId, amounts, depositCount) {
|
|
7
12
|
super(owner, vaultId);
|
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
import { ChainEvent } from "../ChainEvent";
|
|
2
2
|
import { SwapData } from "../../../swaps/SwapData";
|
|
3
|
+
/**
|
|
4
|
+
* Enum of the various types of SPV vault (UTXO-controlled vault) related events
|
|
5
|
+
*
|
|
6
|
+
* @category Events
|
|
7
|
+
*/
|
|
3
8
|
export declare enum SpvVaultEventType {
|
|
4
9
|
OPEN = 0,
|
|
5
10
|
DEPOSIT = 1,
|
|
@@ -7,9 +12,20 @@ export declare enum SpvVaultEventType {
|
|
|
7
12
|
CLOSE = 3,
|
|
8
13
|
FRONT = 4
|
|
9
14
|
}
|
|
10
|
-
|
|
11
|
-
|
|
15
|
+
/**
|
|
16
|
+
* Represents an SPV vault (UTXO-controlled vault) on-chain event
|
|
17
|
+
*
|
|
18
|
+
* @category Events
|
|
19
|
+
*/
|
|
20
|
+
export declare abstract class SpvVaultEvent<C extends SpvVaultEventType = SpvVaultEventType> extends ChainEvent<SwapData> {
|
|
21
|
+
abstract readonly eventType: C;
|
|
22
|
+
/**
|
|
23
|
+
* Owner of the underlying SPV vault (UTXO-controlled vault)
|
|
24
|
+
*/
|
|
12
25
|
owner: string;
|
|
26
|
+
/**
|
|
27
|
+
* ID of the SPV vault (UTXO-controlled vault)
|
|
28
|
+
*/
|
|
13
29
|
vaultId: bigint;
|
|
14
30
|
constructor(owner: string, vaultId: bigint);
|
|
15
31
|
}
|
|
@@ -2,6 +2,11 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.SpvVaultEvent = exports.SpvVaultEventType = void 0;
|
|
4
4
|
const ChainEvent_1 = require("../ChainEvent");
|
|
5
|
+
/**
|
|
6
|
+
* Enum of the various types of SPV vault (UTXO-controlled vault) related events
|
|
7
|
+
*
|
|
8
|
+
* @category Events
|
|
9
|
+
*/
|
|
5
10
|
var SpvVaultEventType;
|
|
6
11
|
(function (SpvVaultEventType) {
|
|
7
12
|
SpvVaultEventType[SpvVaultEventType["OPEN"] = 0] = "OPEN";
|
|
@@ -10,6 +15,11 @@ var SpvVaultEventType;
|
|
|
10
15
|
SpvVaultEventType[SpvVaultEventType["CLOSE"] = 3] = "CLOSE";
|
|
11
16
|
SpvVaultEventType[SpvVaultEventType["FRONT"] = 4] = "FRONT";
|
|
12
17
|
})(SpvVaultEventType = exports.SpvVaultEventType || (exports.SpvVaultEventType = {}));
|
|
18
|
+
/**
|
|
19
|
+
* Represents an SPV vault (UTXO-controlled vault) on-chain event
|
|
20
|
+
*
|
|
21
|
+
* @category Events
|
|
22
|
+
*/
|
|
13
23
|
class SpvVaultEvent extends ChainEvent_1.ChainEvent {
|
|
14
24
|
constructor(owner, vaultId) {
|
|
15
25
|
super();
|
|
@@ -1,10 +1,32 @@
|
|
|
1
1
|
import { SpvVaultEvent, SpvVaultEventType } from "./SpvVaultEvent";
|
|
2
|
+
/**
|
|
3
|
+
* SPV vault (UTXO-controlled vault) Front event representation, an SPV vault withdrawal was fronted
|
|
4
|
+
*
|
|
5
|
+
* @category Events
|
|
6
|
+
*/
|
|
2
7
|
export declare class SpvVaultFrontEvent extends SpvVaultEvent<SpvVaultEventType.FRONT> {
|
|
3
8
|
readonly eventType = SpvVaultEventType.FRONT;
|
|
9
|
+
/**
|
|
10
|
+
* Withdrawal in this bitcoin transaction is getting fronted
|
|
11
|
+
*/
|
|
4
12
|
btcTxId: string;
|
|
13
|
+
/**
|
|
14
|
+
* Original recipient of the fronted withdrawal
|
|
15
|
+
*/
|
|
5
16
|
recipient: string;
|
|
17
|
+
/**
|
|
18
|
+
* If funds should transfered to the execution contract (swap+) this specifies the execution hash of the scheduled
|
|
19
|
+
* execution
|
|
20
|
+
*/
|
|
6
21
|
executionHash: string;
|
|
22
|
+
/**
|
|
23
|
+
* Scaled token amounts that have been fronted by the fronter (NOTE: These are scaled by the corresponding vault-defined
|
|
24
|
+
* multiplier for the tokens)
|
|
25
|
+
*/
|
|
7
26
|
amounts: bigint[];
|
|
27
|
+
/**
|
|
28
|
+
* Address of the party which fronted the withdrawal
|
|
29
|
+
*/
|
|
8
30
|
frontingAddress: string;
|
|
9
31
|
constructor(owner: string, vaultId: bigint, btcTxId: string, recipient: string, executionHash: string, amounts: bigint[], frontingAddress: string);
|
|
10
32
|
}
|
|
@@ -2,6 +2,11 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.SpvVaultFrontEvent = void 0;
|
|
4
4
|
const SpvVaultEvent_1 = require("./SpvVaultEvent");
|
|
5
|
+
/**
|
|
6
|
+
* SPV vault (UTXO-controlled vault) Front event representation, an SPV vault withdrawal was fronted
|
|
7
|
+
*
|
|
8
|
+
* @category Events
|
|
9
|
+
*/
|
|
5
10
|
class SpvVaultFrontEvent extends SpvVaultEvent_1.SpvVaultEvent {
|
|
6
11
|
constructor(owner, vaultId, btcTxId, recipient, executionHash, amounts, frontingAddress) {
|
|
7
12
|
super(owner, vaultId);
|
|
@@ -1,7 +1,18 @@
|
|
|
1
1
|
import { SpvVaultEvent, SpvVaultEventType } from "./SpvVaultEvent";
|
|
2
|
+
/**
|
|
3
|
+
* SPV vault (UTXO-controlled vault) Open event representation, new SPV vault was opened
|
|
4
|
+
*
|
|
5
|
+
* @category Events
|
|
6
|
+
*/
|
|
2
7
|
export declare class SpvVaultOpenEvent extends SpvVaultEvent<SpvVaultEventType.OPEN> {
|
|
3
8
|
readonly eventType = SpvVaultEventType.OPEN;
|
|
9
|
+
/**
|
|
10
|
+
* Vault ownership utxo transaction ID
|
|
11
|
+
*/
|
|
4
12
|
btcTxId: string;
|
|
13
|
+
/**
|
|
14
|
+
* Vault ownership utxo transaction vout
|
|
15
|
+
*/
|
|
5
16
|
vout: number;
|
|
6
17
|
constructor(owner: string, vaultId: bigint, btcTxId: string, vout: number);
|
|
7
18
|
}
|
|
@@ -2,6 +2,11 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.SpvVaultOpenEvent = void 0;
|
|
4
4
|
const SpvVaultEvent_1 = require("./SpvVaultEvent");
|
|
5
|
+
/**
|
|
6
|
+
* SPV vault (UTXO-controlled vault) Open event representation, new SPV vault was opened
|
|
7
|
+
*
|
|
8
|
+
* @category Events
|
|
9
|
+
*/
|
|
5
10
|
class SpvVaultOpenEvent extends SpvVaultEvent_1.SpvVaultEvent {
|
|
6
11
|
constructor(owner, vaultId, btcTxId, vout) {
|
|
7
12
|
super(owner, vaultId);
|
|
@@ -1,7 +1,15 @@
|
|
|
1
1
|
import { SwapEvent, SwapEventType } from "./SwapEvent";
|
|
2
2
|
import { SwapData } from "../../../swaps/SwapData";
|
|
3
|
+
/**
|
|
4
|
+
* Escrow swap Claim event representation, claimer claimed funds from the escrow
|
|
5
|
+
*
|
|
6
|
+
* @category Events
|
|
7
|
+
*/
|
|
3
8
|
export declare class ClaimEvent<T extends SwapData> extends SwapEvent<T, SwapEventType.CLAIM> {
|
|
4
9
|
readonly eventType: SwapEventType.CLAIM;
|
|
10
|
+
/**
|
|
11
|
+
* The result of the Claim event, usually either a secret pre-image or transaction hash
|
|
12
|
+
*/
|
|
5
13
|
result: string;
|
|
6
14
|
constructor(escrowHash: string, result: string);
|
|
7
15
|
}
|
|
@@ -2,9 +2,15 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.ClaimEvent = void 0;
|
|
4
4
|
const SwapEvent_1 = require("./SwapEvent");
|
|
5
|
+
/**
|
|
6
|
+
* Escrow swap Claim event representation, claimer claimed funds from the escrow
|
|
7
|
+
*
|
|
8
|
+
* @category Events
|
|
9
|
+
*/
|
|
5
10
|
class ClaimEvent extends SwapEvent_1.SwapEvent {
|
|
6
11
|
constructor(escrowHash, result) {
|
|
7
12
|
super(escrowHash);
|
|
13
|
+
this.eventType = SwapEvent_1.SwapEventType.CLAIM;
|
|
8
14
|
this.result = result;
|
|
9
15
|
}
|
|
10
16
|
}
|