@atomiqlabs/base 13.4.2 → 13.5.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.
Files changed (33) hide show
  1. package/dist/chains/ChainData.d.ts +11 -0
  2. package/dist/events/types/ChainEvent.d.ts +5 -0
  3. package/dist/events/types/ChainEvent.js +3 -0
  4. package/dist/events/types/spv_vault/SpvVaultClaimEvent.d.ts +1 -1
  5. package/dist/events/types/spv_vault/SpvVaultClaimEvent.js +2 -2
  6. package/dist/events/types/spv_vault/SpvVaultCloseEvent.d.ts +1 -1
  7. package/dist/events/types/spv_vault/SpvVaultCloseEvent.js +2 -2
  8. package/dist/events/types/spv_vault/SpvVaultDepositEvent.d.ts +1 -1
  9. package/dist/events/types/spv_vault/SpvVaultDepositEvent.js +2 -2
  10. package/dist/events/types/spv_vault/SpvVaultEvent.d.ts +1 -1
  11. package/dist/events/types/spv_vault/SpvVaultEvent.js +2 -2
  12. package/dist/events/types/spv_vault/SpvVaultFrontEvent.d.ts +1 -1
  13. package/dist/events/types/spv_vault/SpvVaultFrontEvent.js +2 -2
  14. package/dist/events/types/spv_vault/SpvVaultOpenEvent.d.ts +1 -1
  15. package/dist/events/types/spv_vault/SpvVaultOpenEvent.js +2 -2
  16. package/dist/events/types/swap/ClaimEvent.d.ts +1 -1
  17. package/dist/events/types/swap/ClaimEvent.js +2 -2
  18. package/dist/events/types/swap/InitializeEvent.d.ts +1 -1
  19. package/dist/events/types/swap/InitializeEvent.js +2 -2
  20. package/dist/events/types/swap/SwapEvent.d.ts +1 -1
  21. package/dist/events/types/swap/SwapEvent.js +2 -2
  22. package/package.json +1 -1
  23. package/src/chains/ChainData.ts +13 -1
  24. package/src/events/types/ChainEvent.ts +9 -0
  25. package/src/events/types/spv_vault/SpvVaultClaimEvent.ts +3 -2
  26. package/src/events/types/spv_vault/SpvVaultCloseEvent.ts +2 -2
  27. package/src/events/types/spv_vault/SpvVaultDepositEvent.ts +2 -2
  28. package/src/events/types/spv_vault/SpvVaultEvent.ts +2 -2
  29. package/src/events/types/spv_vault/SpvVaultFrontEvent.ts +2 -2
  30. package/src/events/types/spv_vault/SpvVaultOpenEvent.ts +2 -2
  31. package/src/events/types/swap/ClaimEvent.ts +2 -2
  32. package/src/events/types/swap/InitializeEvent.ts +2 -2
  33. package/src/events/types/swap/SwapEvent.ts +2 -2
@@ -30,6 +30,17 @@ export type ChainData<T extends ChainType> = {
30
30
  spvVaultContract: T["SpvVaultContract"];
31
31
  spvVaultDataConstructor: new (data: any) => T["SpvVaultData"];
32
32
  spvVaultWithdrawalDataConstructor: new (data: any) => T["SpvVaultWithdrawalData"];
33
+ defaultVersion?: string;
34
+ versions?: {
35
+ [contractVersion: string]: {
36
+ btcRelay: T["BtcRelay"];
37
+ swapContract: T["Contract"];
38
+ swapDataConstructor: new (data: any) => T["Data"];
39
+ spvVaultContract: T["SpvVaultContract"];
40
+ spvVaultDataConstructor: new (data: any) => T["SpvVaultData"];
41
+ spvVaultWithdrawalDataConstructor: new (data: any) => T["SpvVaultWithdrawalData"];
42
+ };
43
+ };
33
44
  };
34
45
  /**
35
46
  * An initializer function that returns populated {@link ChainData} for a given chain based on the passed
@@ -12,4 +12,9 @@ export declare class ChainEvent<T extends SwapData> {
12
12
  blockTime: number;
13
13
  txId: string;
14
14
  };
15
+ /**
16
+ * Version of the contract that emitted the event
17
+ */
18
+ contractVersion?: string;
19
+ constructor(contractVersion?: string);
15
20
  }
@@ -7,5 +7,8 @@ exports.ChainEvent = void 0;
7
7
  * @category Events
8
8
  */
9
9
  class ChainEvent {
10
+ constructor(contractVersion) {
11
+ this.contractVersion = contractVersion;
12
+ }
10
13
  }
11
14
  exports.ChainEvent = ChainEvent;
@@ -37,5 +37,5 @@ export declare class SpvVaultClaimEvent extends SpvVaultEvent<SpvVaultEventType.
37
37
  * The sequence of this claim (withdrawal) - i.e. the total number of deposits done before this one
38
38
  */
39
39
  withdrawCount: number;
40
- constructor(owner: string, vaultId: bigint, btcTxId: string, recipient: string, executionHash: string, amounts: bigint[], caller: string, frontingAddress: string, withdrawCount: number);
40
+ constructor(owner: string, vaultId: bigint, btcTxId: string, recipient: string, executionHash: string, amounts: bigint[], caller: string, frontingAddress: string, withdrawCount: number, contractVersion?: string);
41
41
  }
@@ -8,8 +8,8 @@ const SpvVaultEvent_1 = require("./SpvVaultEvent");
8
8
  * @category Events
9
9
  */
10
10
  class SpvVaultClaimEvent extends SpvVaultEvent_1.SpvVaultEvent {
11
- constructor(owner, vaultId, btcTxId, recipient, executionHash, amounts, caller, frontingAddress, withdrawCount) {
12
- super(owner, vaultId);
11
+ constructor(owner, vaultId, btcTxId, recipient, executionHash, amounts, caller, frontingAddress, withdrawCount, contractVersion) {
12
+ super(owner, vaultId, contractVersion);
13
13
  this.eventType = SpvVaultEvent_1.SpvVaultEventType.CLAIM;
14
14
  this.btcTxId = btcTxId;
15
15
  this.recipient = recipient;
@@ -16,5 +16,5 @@ export declare class SpvVaultCloseEvent extends SpvVaultEvent<SpvVaultEventType.
16
16
  * A representation of the actual error that has happened
17
17
  */
18
18
  error: string;
19
- constructor(owner: string, vaultId: bigint, btcTxId: string, error: string);
19
+ constructor(owner: string, vaultId: bigint, btcTxId: string, error: string, contractVersion?: string);
20
20
  }
@@ -10,8 +10,8 @@ const SpvVaultEvent_1 = require("./SpvVaultEvent");
10
10
  * @category Events
11
11
  */
12
12
  class SpvVaultCloseEvent extends SpvVaultEvent_1.SpvVaultEvent {
13
- constructor(owner, vaultId, btcTxId, error) {
14
- super(owner, vaultId);
13
+ constructor(owner, vaultId, btcTxId, error, contractVersion) {
14
+ super(owner, vaultId, contractVersion);
15
15
  this.eventType = SpvVaultEvent_1.SpvVaultEventType.CLOSE;
16
16
  this.btcTxId = btcTxId;
17
17
  this.error = error;
@@ -15,5 +15,5 @@ export declare class SpvVaultDepositEvent extends SpvVaultEvent<SpvVaultEventTyp
15
15
  * The sequence of this deposit - i.e. the total number of deposits done before this one
16
16
  */
17
17
  depositCount: number;
18
- constructor(owner: string, vaultId: bigint, amounts: bigint[], depositCount: number);
18
+ constructor(owner: string, vaultId: bigint, amounts: bigint[], depositCount: number, contractVersion?: string);
19
19
  }
@@ -8,8 +8,8 @@ const SpvVaultEvent_1 = require("./SpvVaultEvent");
8
8
  * @category Events
9
9
  */
10
10
  class SpvVaultDepositEvent extends SpvVaultEvent_1.SpvVaultEvent {
11
- constructor(owner, vaultId, amounts, depositCount) {
12
- super(owner, vaultId);
11
+ constructor(owner, vaultId, amounts, depositCount, contractVersion) {
12
+ super(owner, vaultId, contractVersion);
13
13
  this.eventType = SpvVaultEvent_1.SpvVaultEventType.DEPOSIT;
14
14
  this.amounts = amounts;
15
15
  this.depositCount = depositCount;
@@ -27,5 +27,5 @@ export declare abstract class SpvVaultEvent<C extends SpvVaultEventType = SpvVau
27
27
  * ID of the SPV vault (UTXO-controlled vault)
28
28
  */
29
29
  vaultId: bigint;
30
- constructor(owner: string, vaultId: bigint);
30
+ constructor(owner: string, vaultId: bigint, contractVersion?: string);
31
31
  }
@@ -21,8 +21,8 @@ var SpvVaultEventType;
21
21
  * @category Events
22
22
  */
23
23
  class SpvVaultEvent extends ChainEvent_1.ChainEvent {
24
- constructor(owner, vaultId) {
25
- super();
24
+ constructor(owner, vaultId, contractVersion) {
25
+ super(contractVersion);
26
26
  this.owner = owner;
27
27
  this.vaultId = vaultId;
28
28
  }
@@ -28,5 +28,5 @@ export declare class SpvVaultFrontEvent extends SpvVaultEvent<SpvVaultEventType.
28
28
  * Address of the party which fronted the withdrawal
29
29
  */
30
30
  frontingAddress: string;
31
- constructor(owner: string, vaultId: bigint, btcTxId: string, recipient: string, executionHash: string, amounts: bigint[], frontingAddress: string);
31
+ constructor(owner: string, vaultId: bigint, btcTxId: string, recipient: string, executionHash: string, amounts: bigint[], frontingAddress: string, contractVersion?: string);
32
32
  }
@@ -8,8 +8,8 @@ const SpvVaultEvent_1 = require("./SpvVaultEvent");
8
8
  * @category Events
9
9
  */
10
10
  class SpvVaultFrontEvent extends SpvVaultEvent_1.SpvVaultEvent {
11
- constructor(owner, vaultId, btcTxId, recipient, executionHash, amounts, frontingAddress) {
12
- super(owner, vaultId);
11
+ constructor(owner, vaultId, btcTxId, recipient, executionHash, amounts, frontingAddress, contractVersion) {
12
+ super(owner, vaultId, contractVersion);
13
13
  this.eventType = SpvVaultEvent_1.SpvVaultEventType.FRONT;
14
14
  this.btcTxId = btcTxId;
15
15
  this.recipient = recipient;
@@ -14,5 +14,5 @@ export declare class SpvVaultOpenEvent extends SpvVaultEvent<SpvVaultEventType.O
14
14
  * Vault ownership utxo transaction vout
15
15
  */
16
16
  vout: number;
17
- constructor(owner: string, vaultId: bigint, btcTxId: string, vout: number);
17
+ constructor(owner: string, vaultId: bigint, btcTxId: string, vout: number, contractVersion?: string);
18
18
  }
@@ -8,8 +8,8 @@ const SpvVaultEvent_1 = require("./SpvVaultEvent");
8
8
  * @category Events
9
9
  */
10
10
  class SpvVaultOpenEvent extends SpvVaultEvent_1.SpvVaultEvent {
11
- constructor(owner, vaultId, btcTxId, vout) {
12
- super(owner, vaultId);
11
+ constructor(owner, vaultId, btcTxId, vout, contractVersion) {
12
+ super(owner, vaultId, contractVersion);
13
13
  this.eventType = SpvVaultEvent_1.SpvVaultEventType.OPEN;
14
14
  this.btcTxId = btcTxId;
15
15
  this.vout = vout;
@@ -11,5 +11,5 @@ export declare class ClaimEvent<T extends SwapData> extends SwapEvent<T, SwapEve
11
11
  * The result of the Claim event, usually either a secret pre-image or transaction hash
12
12
  */
13
13
  result: string;
14
- constructor(escrowHash: string, result: string);
14
+ constructor(escrowHash: string, result: string, contractVersion?: string);
15
15
  }
@@ -8,8 +8,8 @@ const SwapEvent_1 = require("./SwapEvent");
8
8
  * @category Events
9
9
  */
10
10
  class ClaimEvent extends SwapEvent_1.SwapEvent {
11
- constructor(escrowHash, result) {
12
- super(escrowHash);
11
+ constructor(escrowHash, result, contractVersion) {
12
+ super(escrowHash, contractVersion);
13
13
  this.eventType = SwapEvent_1.SwapEventType.CLAIM;
14
14
  this.result = result;
15
15
  }
@@ -16,5 +16,5 @@ export declare class InitializeEvent<T extends SwapData> extends SwapEvent<T, Sw
16
16
  * A getter for the actual full swap data that was used to initialize the escrow swap
17
17
  */
18
18
  swapData: () => Promise<T | null>;
19
- constructor(escrowHash: string, swapType: ChainSwapType, swapData: () => Promise<T | null>);
19
+ constructor(escrowHash: string, swapType: ChainSwapType, swapData: () => Promise<T | null>, contractVersion?: string);
20
20
  }
@@ -8,8 +8,8 @@ const SwapEvent_1 = require("./SwapEvent");
8
8
  * @category Events
9
9
  */
10
10
  class InitializeEvent extends SwapEvent_1.SwapEvent {
11
- constructor(escrowHash, swapType, swapData) {
12
- super(escrowHash);
11
+ constructor(escrowHash, swapType, swapData, contractVersion) {
12
+ super(escrowHash, contractVersion);
13
13
  this.eventType = SwapEvent_1.SwapEventType.INITIALIZE;
14
14
  this.swapType = swapType;
15
15
  this.swapData = swapData;
@@ -21,5 +21,5 @@ export declare abstract class SwapEvent<T extends SwapData, C extends SwapEventT
21
21
  * Identifier of the escrow, usually a hash of the full escrow swap data
22
22
  */
23
23
  escrowHash: string;
24
- constructor(escrowHash: string);
24
+ constructor(escrowHash: string, contractVersion?: string);
25
25
  }
@@ -19,8 +19,8 @@ var SwapEventType;
19
19
  * @category Events
20
20
  */
21
21
  class SwapEvent extends ChainEvent_1.ChainEvent {
22
- constructor(escrowHash) {
23
- super();
22
+ constructor(escrowHash, contractVersion) {
23
+ super(contractVersion);
24
24
  this.escrowHash = escrowHash;
25
25
  }
26
26
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atomiqlabs/base",
3
- "version": "13.4.2",
3
+ "version": "13.5.0",
4
4
  "description": "Base classes and interfaces for atomiq protocol",
5
5
  "main": "./dist/index.js",
6
6
  "types:": "./dist/index.d.ts",
@@ -31,7 +31,19 @@ export type ChainData<T extends ChainType> = {
31
31
  swapDataConstructor: new (data: any) => T["Data"],
32
32
  spvVaultContract: T["SpvVaultContract"],
33
33
  spvVaultDataConstructor: new (data: any) => T["SpvVaultData"],
34
- spvVaultWithdrawalDataConstructor: new (data: any) => T["SpvVaultWithdrawalData"]
34
+ spvVaultWithdrawalDataConstructor: new (data: any) => T["SpvVaultWithdrawalData"],
35
+
36
+ defaultVersion?: string,
37
+ versions?: {
38
+ [contractVersion: string]: {
39
+ btcRelay: T["BtcRelay"],
40
+ swapContract: T["Contract"],
41
+ swapDataConstructor: new (data: any) => T["Data"],
42
+ spvVaultContract: T["SpvVaultContract"],
43
+ spvVaultDataConstructor: new (data: any) => T["SpvVaultData"],
44
+ spvVaultWithdrawalDataConstructor: new (data: any) => T["SpvVaultWithdrawalData"],
45
+ }
46
+ }
35
47
  };
36
48
 
37
49
  /**
@@ -15,4 +15,13 @@ export class ChainEvent<T extends SwapData> {
15
15
  txId: string
16
16
  };
17
17
 
18
+ /**
19
+ * Version of the contract that emitted the event
20
+ */
21
+ contractVersion?: string;
22
+
23
+ constructor(contractVersion?: string) {
24
+ this.contractVersion = contractVersion;
25
+ }
26
+
18
27
  }
@@ -45,9 +45,10 @@ export class SpvVaultClaimEvent extends SpvVaultEvent<SpvVaultEventType.CLAIM> {
45
45
  constructor(
46
46
  owner: string, vaultId: bigint,
47
47
  btcTxId: string, recipient: string, executionHash: string, amounts: bigint[],
48
- caller: string, frontingAddress: string, withdrawCount: number
48
+ caller: string, frontingAddress: string, withdrawCount: number,
49
+ contractVersion?: string
49
50
  ) {
50
- super(owner, vaultId);
51
+ super(owner, vaultId, contractVersion);
51
52
  this.btcTxId = btcTxId;
52
53
  this.recipient = recipient;
53
54
  this.executionHash = executionHash;
@@ -21,8 +21,8 @@ export class SpvVaultCloseEvent extends SpvVaultEvent<SpvVaultEventType.CLOSE> {
21
21
  */
22
22
  error: string;
23
23
 
24
- constructor(owner: string, vaultId: bigint, btcTxId: string, error: string) {
25
- super(owner, vaultId);
24
+ constructor(owner: string, vaultId: bigint, btcTxId: string, error: string, contractVersion?: string) {
25
+ super(owner, vaultId, contractVersion);
26
26
  this.btcTxId = btcTxId;
27
27
  this.error = error;
28
28
  }
@@ -21,8 +21,8 @@ export class SpvVaultDepositEvent extends SpvVaultEvent<SpvVaultEventType.DEPOSI
21
21
  */
22
22
  depositCount: number;
23
23
 
24
- constructor(owner: string, vaultId: bigint, amounts: bigint[], depositCount: number) {
25
- super(owner, vaultId);
24
+ constructor(owner: string, vaultId: bigint, amounts: bigint[], depositCount: number, contractVersion?: string) {
25
+ super(owner, vaultId, contractVersion);
26
26
  this.amounts = amounts;
27
27
  this.depositCount = depositCount;
28
28
  }
@@ -31,8 +31,8 @@ export abstract class SpvVaultEvent<C extends SpvVaultEventType = SpvVaultEventT
31
31
  */
32
32
  vaultId: bigint;
33
33
 
34
- constructor(owner: string, vaultId: bigint) {
35
- super();
34
+ constructor(owner: string, vaultId: bigint, contractVersion?: string) {
35
+ super(contractVersion);
36
36
  this.owner = owner;
37
37
  this.vaultId = vaultId;
38
38
  }
@@ -36,9 +36,9 @@ export class SpvVaultFrontEvent extends SpvVaultEvent<SpvVaultEventType.FRONT> {
36
36
  constructor(
37
37
  owner: string, vaultId: bigint,
38
38
  btcTxId: string, recipient: string, executionHash: string, amounts: bigint[],
39
- frontingAddress: string
39
+ frontingAddress: string, contractVersion?: string
40
40
  ) {
41
- super(owner, vaultId);
41
+ super(owner, vaultId, contractVersion);
42
42
  this.btcTxId = btcTxId;
43
43
  this.recipient = recipient;
44
44
  this.executionHash = executionHash;
@@ -19,8 +19,8 @@ export class SpvVaultOpenEvent extends SpvVaultEvent<SpvVaultEventType.OPEN> {
19
19
  */
20
20
  vout: number;
21
21
 
22
- constructor(owner: string, vaultId: bigint, btcTxId: string, vout: number) {
23
- super(owner, vaultId);
22
+ constructor(owner: string, vaultId: bigint, btcTxId: string, vout: number, contractVersion?: string) {
23
+ super(owner, vaultId, contractVersion);
24
24
  this.btcTxId = btcTxId;
25
25
  this.vout = vout;
26
26
  }
@@ -14,8 +14,8 @@ export class ClaimEvent<T extends SwapData> extends SwapEvent<T, SwapEventType.C
14
14
  */
15
15
  result: string;
16
16
 
17
- constructor(escrowHash: string, result: string) {
18
- super(escrowHash);
17
+ constructor(escrowHash: string, result: string, contractVersion?: string) {
18
+ super(escrowHash, contractVersion);
19
19
  this.result = result;
20
20
  }
21
21
 
@@ -19,8 +19,8 @@ export class InitializeEvent<T extends SwapData> extends SwapEvent<T, SwapEventT
19
19
  */
20
20
  swapData: () => Promise<T | null>;
21
21
 
22
- constructor(escrowHash: string, swapType: ChainSwapType, swapData: () => Promise<T | null>) {
23
- super(escrowHash);
22
+ constructor(escrowHash: string, swapType: ChainSwapType, swapData: () => Promise<T | null>, contractVersion?: string) {
23
+ super(escrowHash, contractVersion);
24
24
  this.swapType = swapType;
25
25
  this.swapData = swapData;
26
26
  }
@@ -25,8 +25,8 @@ export abstract class SwapEvent<T extends SwapData, C extends SwapEventType = Sw
25
25
  */
26
26
  escrowHash: string;
27
27
 
28
- constructor(escrowHash: string) {
29
- super();
28
+ constructor(escrowHash: string, contractVersion?: string) {
29
+ super(contractVersion);
30
30
  this.escrowHash = escrowHash;
31
31
  }
32
32