@atomiqlabs/chain-solana 10.0.0-dev.3 → 11.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.
Files changed (114) hide show
  1. package/LICENSE +201 -201
  2. package/dist/index.d.ts +29 -29
  3. package/dist/index.js +45 -45
  4. package/dist/solana/SolanaChainType.d.ts +10 -10
  5. package/dist/solana/SolanaChainType.js +2 -2
  6. package/dist/solana/SolanaChains.d.ts +20 -20
  7. package/dist/solana/SolanaChains.js +25 -25
  8. package/dist/solana/SolanaInitializer.d.ts +18 -18
  9. package/dist/solana/SolanaInitializer.js +63 -63
  10. package/dist/solana/btcrelay/SolanaBtcRelay.d.ts +228 -228
  11. package/dist/solana/btcrelay/SolanaBtcRelay.js +441 -441
  12. package/dist/solana/btcrelay/headers/SolanaBtcHeader.d.ts +29 -29
  13. package/dist/solana/btcrelay/headers/SolanaBtcHeader.js +34 -34
  14. package/dist/solana/btcrelay/headers/SolanaBtcStoredHeader.d.ts +46 -46
  15. package/dist/solana/btcrelay/headers/SolanaBtcStoredHeader.js +78 -78
  16. package/dist/solana/btcrelay/program/programIdl.json +671 -671
  17. package/dist/solana/chain/SolanaAction.d.ts +26 -26
  18. package/dist/solana/chain/SolanaAction.js +86 -86
  19. package/dist/solana/chain/SolanaChainInterface.d.ts +58 -58
  20. package/dist/solana/chain/SolanaChainInterface.js +112 -112
  21. package/dist/solana/chain/SolanaModule.d.ts +14 -14
  22. package/dist/solana/chain/SolanaModule.js +13 -13
  23. package/dist/solana/chain/modules/SolanaAddresses.d.ts +8 -8
  24. package/dist/solana/chain/modules/SolanaAddresses.js +22 -22
  25. package/dist/solana/chain/modules/SolanaBlocks.d.ts +28 -28
  26. package/dist/solana/chain/modules/SolanaBlocks.js +72 -72
  27. package/dist/solana/chain/modules/SolanaEvents.d.ts +25 -25
  28. package/dist/solana/chain/modules/SolanaEvents.js +58 -58
  29. package/dist/solana/chain/modules/SolanaFees.d.ts +121 -121
  30. package/dist/solana/chain/modules/SolanaFees.js +379 -379
  31. package/dist/solana/chain/modules/SolanaSignatures.d.ts +23 -23
  32. package/dist/solana/chain/modules/SolanaSignatures.js +39 -39
  33. package/dist/solana/chain/modules/SolanaSlots.d.ts +31 -31
  34. package/dist/solana/chain/modules/SolanaSlots.js +68 -68
  35. package/dist/solana/chain/modules/SolanaTokens.d.ts +136 -136
  36. package/dist/solana/chain/modules/SolanaTokens.js +248 -248
  37. package/dist/solana/chain/modules/SolanaTransactions.d.ts +124 -124
  38. package/dist/solana/chain/modules/SolanaTransactions.js +332 -332
  39. package/dist/solana/events/SolanaChainEvents.d.ts +88 -88
  40. package/dist/solana/events/SolanaChainEvents.js +256 -256
  41. package/dist/solana/events/SolanaChainEventsBrowser.d.ts +85 -85
  42. package/dist/solana/events/SolanaChainEventsBrowser.js +194 -194
  43. package/dist/solana/program/SolanaProgramBase.d.ts +40 -40
  44. package/dist/solana/program/SolanaProgramBase.js +43 -43
  45. package/dist/solana/program/SolanaProgramModule.d.ts +8 -8
  46. package/dist/solana/program/SolanaProgramModule.js +11 -11
  47. package/dist/solana/program/modules/SolanaProgramEvents.d.ts +59 -59
  48. package/dist/solana/program/modules/SolanaProgramEvents.js +103 -103
  49. package/dist/solana/swaps/SolanaSwapData.d.ts +59 -59
  50. package/dist/solana/swaps/SolanaSwapData.js +267 -267
  51. package/dist/solana/swaps/SolanaSwapModule.d.ts +10 -10
  52. package/dist/solana/swaps/SolanaSwapModule.js +11 -11
  53. package/dist/solana/swaps/SolanaSwapProgram.d.ts +202 -202
  54. package/dist/solana/swaps/SolanaSwapProgram.js +470 -463
  55. package/dist/solana/swaps/SwapTypeEnum.d.ts +11 -11
  56. package/dist/solana/swaps/SwapTypeEnum.js +42 -42
  57. package/dist/solana/swaps/modules/SolanaDataAccount.d.ts +94 -94
  58. package/dist/solana/swaps/modules/SolanaDataAccount.js +231 -231
  59. package/dist/solana/swaps/modules/SolanaLpVault.d.ts +71 -71
  60. package/dist/solana/swaps/modules/SolanaLpVault.js +173 -173
  61. package/dist/solana/swaps/modules/SwapClaim.d.ts +129 -129
  62. package/dist/solana/swaps/modules/SwapClaim.js +291 -291
  63. package/dist/solana/swaps/modules/SwapInit.d.ts +217 -217
  64. package/dist/solana/swaps/modules/SwapInit.js +519 -519
  65. package/dist/solana/swaps/modules/SwapRefund.d.ts +82 -82
  66. package/dist/solana/swaps/modules/SwapRefund.js +252 -252
  67. package/dist/solana/swaps/programIdl.json +945 -945
  68. package/dist/solana/swaps/programTypes.d.ts +943 -943
  69. package/dist/solana/swaps/programTypes.js +945 -945
  70. package/dist/solana/wallet/SolanaKeypairWallet.d.ts +9 -9
  71. package/dist/solana/wallet/SolanaKeypairWallet.js +33 -33
  72. package/dist/solana/wallet/SolanaSigner.d.ts +10 -10
  73. package/dist/solana/wallet/SolanaSigner.js +16 -16
  74. package/dist/utils/Utils.d.ts +53 -53
  75. package/dist/utils/Utils.js +170 -170
  76. package/package.json +41 -41
  77. package/src/index.ts +36 -36
  78. package/src/solana/SolanaChainType.ts +25 -25
  79. package/src/solana/SolanaChains.ts +23 -23
  80. package/src/solana/SolanaInitializer.ts +102 -102
  81. package/src/solana/btcrelay/SolanaBtcRelay.ts +589 -588
  82. package/src/solana/btcrelay/headers/SolanaBtcHeader.ts +57 -57
  83. package/src/solana/btcrelay/headers/SolanaBtcStoredHeader.ts +102 -102
  84. package/src/solana/btcrelay/program/programIdl.json +670 -670
  85. package/src/solana/chain/SolanaAction.ts +108 -108
  86. package/src/solana/chain/SolanaChainInterface.ts +174 -174
  87. package/src/solana/chain/SolanaModule.ts +20 -20
  88. package/src/solana/chain/modules/SolanaAddresses.ts +20 -20
  89. package/src/solana/chain/modules/SolanaBlocks.ts +78 -78
  90. package/src/solana/chain/modules/SolanaEvents.ts +56 -56
  91. package/src/solana/chain/modules/SolanaFees.ts +450 -450
  92. package/src/solana/chain/modules/SolanaSignatures.ts +39 -39
  93. package/src/solana/chain/modules/SolanaSlots.ts +82 -82
  94. package/src/solana/chain/modules/SolanaTokens.ts +307 -307
  95. package/src/solana/chain/modules/SolanaTransactions.ts +370 -370
  96. package/src/solana/events/SolanaChainEvents.ts +299 -299
  97. package/src/solana/events/SolanaChainEventsBrowser.ts +256 -256
  98. package/src/solana/program/SolanaProgramBase.ts +79 -79
  99. package/src/solana/program/SolanaProgramModule.ts +15 -15
  100. package/src/solana/program/modules/SolanaProgramEvents.ts +140 -140
  101. package/src/solana/swaps/SolanaSwapData.ts +379 -379
  102. package/src/solana/swaps/SolanaSwapModule.ts +16 -16
  103. package/src/solana/swaps/SolanaSwapProgram.ts +697 -692
  104. package/src/solana/swaps/SwapTypeEnum.ts +29 -29
  105. package/src/solana/swaps/modules/SolanaDataAccount.ts +307 -307
  106. package/src/solana/swaps/modules/SolanaLpVault.ts +215 -215
  107. package/src/solana/swaps/modules/SwapClaim.ts +389 -389
  108. package/src/solana/swaps/modules/SwapInit.ts +663 -663
  109. package/src/solana/swaps/modules/SwapRefund.ts +312 -312
  110. package/src/solana/swaps/programIdl.json +944 -944
  111. package/src/solana/swaps/programTypes.ts +1885 -1885
  112. package/src/solana/wallet/SolanaKeypairWallet.ts +36 -36
  113. package/src/solana/wallet/SolanaSigner.ts +23 -23
  114. package/src/utils/Utils.ts +180 -180
@@ -1,11 +1,11 @@
1
- export declare class SwapTypeEnum {
2
- static toChainSwapType(data: any): number;
3
- static toNumber(data: any): number;
4
- static fromNumber(kind: 0 | 1 | 2 | 3): {
5
- htlc?: never;
6
- chain?: never;
7
- chainNonced?: never;
8
- } & {
9
- chainTxhash: Record<string, never>;
10
- };
11
- }
1
+ export declare class SwapTypeEnum {
2
+ static toChainSwapType(data: any): number;
3
+ static toNumber(data: any): number;
4
+ static fromNumber(kind: 0 | 1 | 2 | 3): {
5
+ htlc?: never;
6
+ chain?: never;
7
+ chainNonced?: never;
8
+ } & {
9
+ chainTxhash: Record<string, never>;
10
+ };
11
+ }
@@ -1,42 +1,42 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.SwapTypeEnum = void 0;
4
- const base_1 = require("@atomiqlabs/base");
5
- class SwapTypeEnum {
6
- static toChainSwapType(data) {
7
- const text = Object.keys(data)[0];
8
- if (text === "htlc")
9
- return base_1.ChainSwapType.HTLC;
10
- if (text === "chain")
11
- return base_1.ChainSwapType.CHAIN;
12
- if (text === "chainNonced")
13
- return base_1.ChainSwapType.CHAIN_NONCED;
14
- if (text === "chainTxhash")
15
- return base_1.ChainSwapType.CHAIN_TXID;
16
- return null;
17
- }
18
- static toNumber(data) {
19
- const text = Object.keys(data)[0];
20
- if (text === "htlc")
21
- return 0;
22
- if (text === "chain")
23
- return 1;
24
- if (text === "chainNonced")
25
- return 2;
26
- if (text === "chainTxhash")
27
- return 3;
28
- return null;
29
- }
30
- static fromNumber(kind) {
31
- if (kind === 0)
32
- return { htlc: null };
33
- if (kind === 1)
34
- return { chain: null };
35
- if (kind === 2)
36
- return { chainNonced: null };
37
- if (kind === 3)
38
- return { chainTxhash: null };
39
- }
40
- }
41
- exports.SwapTypeEnum = SwapTypeEnum;
42
- ;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SwapTypeEnum = void 0;
4
+ const base_1 = require("@atomiqlabs/base");
5
+ class SwapTypeEnum {
6
+ static toChainSwapType(data) {
7
+ const text = Object.keys(data)[0];
8
+ if (text === "htlc")
9
+ return base_1.ChainSwapType.HTLC;
10
+ if (text === "chain")
11
+ return base_1.ChainSwapType.CHAIN;
12
+ if (text === "chainNonced")
13
+ return base_1.ChainSwapType.CHAIN_NONCED;
14
+ if (text === "chainTxhash")
15
+ return base_1.ChainSwapType.CHAIN_TXID;
16
+ return null;
17
+ }
18
+ static toNumber(data) {
19
+ const text = Object.keys(data)[0];
20
+ if (text === "htlc")
21
+ return 0;
22
+ if (text === "chain")
23
+ return 1;
24
+ if (text === "chainNonced")
25
+ return 2;
26
+ if (text === "chainTxhash")
27
+ return 3;
28
+ return null;
29
+ }
30
+ static fromNumber(kind) {
31
+ if (kind === 0)
32
+ return { htlc: null };
33
+ if (kind === 1)
34
+ return { chain: null };
35
+ if (kind === 2)
36
+ return { chainNonced: null };
37
+ if (kind === 3)
38
+ return { chainTxhash: null };
39
+ }
40
+ }
41
+ exports.SwapTypeEnum = SwapTypeEnum;
42
+ ;
@@ -1,94 +1,94 @@
1
- /// <reference types="node" />
2
- import { SolanaSwapModule } from "../SolanaSwapModule";
3
- import { PublicKey, Signer } from "@solana/web3.js";
4
- import { IStorageManager, StorageObject } from "@atomiqlabs/base";
5
- import { SolanaSwapProgram } from "../SolanaSwapProgram";
6
- import { SolanaTx } from "../../chain/modules/SolanaTransactions";
7
- import { SolanaSigner } from "../../wallet/SolanaSigner";
8
- import { SolanaChainInterface } from "../../chain/SolanaChainInterface";
9
- export declare class StoredDataAccount implements StorageObject {
10
- accountKey: PublicKey;
11
- owner: PublicKey;
12
- constructor(accountKey: PublicKey, owner: PublicKey);
13
- constructor(data: any);
14
- serialize(): any;
15
- }
16
- export declare class SolanaDataAccount extends SolanaSwapModule {
17
- readonly SwapTxDataAlt: (reversedTxId: Buffer, signer: Signer) => import("@solana/web3.js").Keypair;
18
- readonly SwapTxDataAltBuffer: (reversedTxId: Buffer, secret: Buffer) => import("@solana/web3.js").Keypair;
19
- readonly storage: IStorageManager<StoredDataAccount>;
20
- private static readonly CUCosts;
21
- /**
22
- * Action for initialization of the data account
23
- *
24
- * @param signer
25
- * @param accountKey
26
- * @param dataLength
27
- * @private
28
- */
29
- private InitDataAccount;
30
- /**
31
- * Action for closing the specific data account
32
- *
33
- * @param signer
34
- * @param publicKey
35
- */
36
- private CloseDataAccount;
37
- /**
38
- * Action for writing data to a data account, writes up to sizeLimit starting from the offset position of the
39
- * provided writeData buffer
40
- *
41
- * @param signer
42
- * @param accountKey account public key to write to
43
- * @param writeData buffer holding the write data
44
- * @param offset data from buffer starting at offset are written
45
- * @param sizeLimit maximum amount of data to be written to the data account in this action
46
- * @private
47
- * @returns {Promise<{bytesWritten: number, action: SolanaAction}>} bytes written to the data account & action
48
- */
49
- private WriteData;
50
- constructor(chainInterface: SolanaChainInterface, program: SolanaSwapProgram, storage: IStorageManager<StoredDataAccount>);
51
- /**
52
- * Saves data account to the storage, the storage is required such that we are able to close the accounts later
53
- * manually in case the claim doesn't happen (expires due to fees, etc.)
54
- *
55
- * @param signer
56
- * @param publicKey
57
- * @private
58
- */
59
- private saveDataAccount;
60
- /**
61
- * Initializes the data account handler, loads the existing data accounts which should be checked and closed
62
- */
63
- init(): Promise<void>;
64
- /**
65
- * Removes data account from the list of accounts that should be checked for reclaiming the locked SOL, this should
66
- * be called after a batch of transactions claiming the swap was confirmed
67
- *
68
- * @param publicKey
69
- */
70
- removeDataAccount(publicKey: PublicKey): Promise<void>;
71
- getDataAccountsInfo(signer: PublicKey): Promise<{
72
- closePublicKeys: PublicKey[];
73
- count: number;
74
- totalValue: bigint;
75
- }>;
76
- /**
77
- * Sweeps all old data accounts, reclaiming the SOL locked in the PDAs
78
- */
79
- sweepDataAccounts(signer: SolanaSigner): Promise<{
80
- txIds: string[];
81
- count: number;
82
- totalValue: bigint;
83
- }>;
84
- /**
85
- * Adds the transactions writing (and also initializing if it doesn't exist) data to the data account
86
- *
87
- * @param signer
88
- * @param reversedTxId reversed btc tx id is used to derive the data account address
89
- * @param writeData full data to be written to the data account
90
- * @param txs solana transactions array, where txns for writing & initializing will be added
91
- * @param feeRate fee rate to use for the transactions
92
- */
93
- addTxsWriteData(signer: SolanaSigner | PublicKey, reversedTxId: Buffer, writeData: Buffer, txs: SolanaTx[], feeRate: string): Promise<PublicKey>;
94
- }
1
+ /// <reference types="node" />
2
+ import { SolanaSwapModule } from "../SolanaSwapModule";
3
+ import { PublicKey, Signer } from "@solana/web3.js";
4
+ import { IStorageManager, StorageObject } from "@atomiqlabs/base";
5
+ import { SolanaSwapProgram } from "../SolanaSwapProgram";
6
+ import { SolanaTx } from "../../chain/modules/SolanaTransactions";
7
+ import { SolanaSigner } from "../../wallet/SolanaSigner";
8
+ import { SolanaChainInterface } from "../../chain/SolanaChainInterface";
9
+ export declare class StoredDataAccount implements StorageObject {
10
+ accountKey: PublicKey;
11
+ owner: PublicKey;
12
+ constructor(accountKey: PublicKey, owner: PublicKey);
13
+ constructor(data: any);
14
+ serialize(): any;
15
+ }
16
+ export declare class SolanaDataAccount extends SolanaSwapModule {
17
+ readonly SwapTxDataAlt: (reversedTxId: Buffer, signer: Signer) => import("@solana/web3.js").Keypair;
18
+ readonly SwapTxDataAltBuffer: (reversedTxId: Buffer, secret: Buffer) => import("@solana/web3.js").Keypair;
19
+ readonly storage: IStorageManager<StoredDataAccount>;
20
+ private static readonly CUCosts;
21
+ /**
22
+ * Action for initialization of the data account
23
+ *
24
+ * @param signer
25
+ * @param accountKey
26
+ * @param dataLength
27
+ * @private
28
+ */
29
+ private InitDataAccount;
30
+ /**
31
+ * Action for closing the specific data account
32
+ *
33
+ * @param signer
34
+ * @param publicKey
35
+ */
36
+ private CloseDataAccount;
37
+ /**
38
+ * Action for writing data to a data account, writes up to sizeLimit starting from the offset position of the
39
+ * provided writeData buffer
40
+ *
41
+ * @param signer
42
+ * @param accountKey account public key to write to
43
+ * @param writeData buffer holding the write data
44
+ * @param offset data from buffer starting at offset are written
45
+ * @param sizeLimit maximum amount of data to be written to the data account in this action
46
+ * @private
47
+ * @returns {Promise<{bytesWritten: number, action: SolanaAction}>} bytes written to the data account & action
48
+ */
49
+ private WriteData;
50
+ constructor(chainInterface: SolanaChainInterface, program: SolanaSwapProgram, storage: IStorageManager<StoredDataAccount>);
51
+ /**
52
+ * Saves data account to the storage, the storage is required such that we are able to close the accounts later
53
+ * manually in case the claim doesn't happen (expires due to fees, etc.)
54
+ *
55
+ * @param signer
56
+ * @param publicKey
57
+ * @private
58
+ */
59
+ private saveDataAccount;
60
+ /**
61
+ * Initializes the data account handler, loads the existing data accounts which should be checked and closed
62
+ */
63
+ init(): Promise<void>;
64
+ /**
65
+ * Removes data account from the list of accounts that should be checked for reclaiming the locked SOL, this should
66
+ * be called after a batch of transactions claiming the swap was confirmed
67
+ *
68
+ * @param publicKey
69
+ */
70
+ removeDataAccount(publicKey: PublicKey): Promise<void>;
71
+ getDataAccountsInfo(signer: PublicKey): Promise<{
72
+ closePublicKeys: PublicKey[];
73
+ count: number;
74
+ totalValue: bigint;
75
+ }>;
76
+ /**
77
+ * Sweeps all old data accounts, reclaiming the SOL locked in the PDAs
78
+ */
79
+ sweepDataAccounts(signer: SolanaSigner): Promise<{
80
+ txIds: string[];
81
+ count: number;
82
+ totalValue: bigint;
83
+ }>;
84
+ /**
85
+ * Adds the transactions writing (and also initializing if it doesn't exist) data to the data account
86
+ *
87
+ * @param signer
88
+ * @param reversedTxId reversed btc tx id is used to derive the data account address
89
+ * @param writeData full data to be written to the data account
90
+ * @param txs solana transactions array, where txns for writing & initializing will be added
91
+ * @param feeRate fee rate to use for the transactions
92
+ */
93
+ addTxsWriteData(signer: SolanaSigner | PublicKey, reversedTxId: Buffer, writeData: Buffer, txs: SolanaTx[], feeRate: string): Promise<PublicKey>;
94
+ }