@stellar/typescript-wallet-sdk 1.2.0 → 1.3.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 (96) hide show
  1. package/.eslintrc.js +76 -0
  2. package/.github/workflows/integrationTest.yml +19 -0
  3. package/.github/workflows/runTests.yml +14 -0
  4. package/.husky/pre-commit +1 -0
  5. package/README.md +19 -12
  6. package/examples/sep24/.env.example +4 -0
  7. package/examples/sep24/README.md +17 -0
  8. package/examples/sep24/sep24.ts +69 -14
  9. package/examples/tsconfig.json +10 -0
  10. package/jest.config.js +1 -0
  11. package/jest.integration.config.js +9 -0
  12. package/lib/bundle.js +6929 -2377
  13. package/lib/bundle.js.map +1 -1
  14. package/lib/bundle_browser.js +6915 -2410
  15. package/lib/bundle_browser.js.map +1 -1
  16. package/lib/index.d.ts +1 -1
  17. package/lib/walletSdk/Anchor/Sep24.d.ts +65 -22
  18. package/lib/walletSdk/Anchor/Sep38.d.ts +56 -0
  19. package/lib/walletSdk/Anchor/Sep6.d.ts +127 -0
  20. package/lib/walletSdk/Anchor/index.d.ts +91 -1
  21. package/lib/walletSdk/Asset/index.d.ts +11 -1
  22. package/lib/walletSdk/Auth/WalletSigner.d.ts +41 -1
  23. package/lib/walletSdk/Auth/index.d.ts +21 -0
  24. package/lib/walletSdk/Customer/index.d.ts +70 -0
  25. package/lib/walletSdk/Exceptions/index.d.ts +45 -2
  26. package/lib/walletSdk/Horizon/AccountService.d.ts +30 -20
  27. package/lib/walletSdk/Horizon/Stellar.d.ts +79 -2
  28. package/lib/walletSdk/Horizon/Transaction/CommonTransactionBuilder.d.ts +57 -0
  29. package/lib/walletSdk/Horizon/Transaction/SponsoringBuilder.d.ts +38 -0
  30. package/lib/walletSdk/Horizon/Transaction/TransactionBuilder.d.ts +112 -11
  31. package/lib/walletSdk/Horizon/index.d.ts +3 -1
  32. package/lib/walletSdk/Recovery/AccountRecover.d.ts +58 -0
  33. package/lib/walletSdk/Recovery/index.d.ts +69 -7
  34. package/lib/walletSdk/Types/anchor.d.ts +17 -2
  35. package/lib/walletSdk/Types/auth.d.ts +14 -1
  36. package/lib/walletSdk/Types/horizon.d.ts +17 -6
  37. package/lib/walletSdk/Types/index.d.ts +15 -3
  38. package/lib/walletSdk/Types/recovery.d.ts +128 -0
  39. package/lib/walletSdk/Types/sep12.d.ts +57 -0
  40. package/lib/walletSdk/Types/sep38.d.ts +93 -0
  41. package/lib/walletSdk/Types/sep6.d.ts +160 -0
  42. package/lib/walletSdk/Types/watcher.d.ts +7 -2
  43. package/lib/walletSdk/Utils/extractAxiosErrorData.d.ts +2 -0
  44. package/lib/walletSdk/Utils/index.d.ts +1 -0
  45. package/lib/walletSdk/Utils/toml.d.ts +2 -2
  46. package/lib/walletSdk/Watcher/getTransactions.d.ts +8 -0
  47. package/lib/walletSdk/Watcher/index.d.ts +41 -4
  48. package/lib/walletSdk/index.d.ts +43 -5
  49. package/package.json +17 -4
  50. package/src/index.ts +2 -0
  51. package/src/walletSdk/Anchor/Sep24.ts +93 -86
  52. package/src/walletSdk/Anchor/Sep38.ts +180 -0
  53. package/src/walletSdk/Anchor/Sep6.ts +291 -0
  54. package/src/walletSdk/Anchor/index.ts +138 -5
  55. package/src/walletSdk/Asset/index.ts +21 -4
  56. package/src/walletSdk/Auth/WalletSigner.ts +23 -5
  57. package/src/walletSdk/Auth/index.ts +24 -5
  58. package/src/walletSdk/Customer/index.ts +174 -0
  59. package/src/walletSdk/Exceptions/index.ts +115 -4
  60. package/src/walletSdk/Horizon/AccountService.ts +33 -21
  61. package/src/walletSdk/Horizon/Stellar.ts +89 -5
  62. package/src/walletSdk/Horizon/Transaction/CommonTransactionBuilder.ts +43 -4
  63. package/src/walletSdk/Horizon/Transaction/SponsoringBuilder.ts +30 -7
  64. package/src/walletSdk/Horizon/Transaction/TransactionBuilder.ts +88 -15
  65. package/src/walletSdk/Horizon/index.ts +2 -1
  66. package/src/walletSdk/Recovery/AccountRecover.ts +255 -0
  67. package/src/walletSdk/Recovery/index.ts +314 -13
  68. package/src/walletSdk/Types/anchor.ts +23 -2
  69. package/src/walletSdk/Types/auth.ts +36 -2
  70. package/src/walletSdk/Types/horizon.ts +7 -5
  71. package/src/walletSdk/Types/index.ts +17 -4
  72. package/src/walletSdk/Types/recovery.ts +152 -0
  73. package/src/walletSdk/Types/sep12.ts +61 -0
  74. package/src/walletSdk/Types/sep38.ts +106 -0
  75. package/src/walletSdk/Types/sep6.ts +168 -0
  76. package/src/walletSdk/Types/watcher.ts +8 -2
  77. package/src/walletSdk/Utils/camelToSnakeCase.ts +1 -0
  78. package/src/walletSdk/Utils/extractAxiosErrorData.ts +28 -0
  79. package/src/walletSdk/Utils/index.ts +1 -0
  80. package/src/walletSdk/Utils/toml.ts +2 -2
  81. package/src/walletSdk/Watcher/getTransactions.ts +65 -0
  82. package/src/walletSdk/Watcher/index.ts +70 -9
  83. package/src/walletSdk/index.ts +45 -8
  84. package/test/README.md +18 -0
  85. package/test/accountService.test.ts +21 -3
  86. package/test/customer.test.ts +82 -0
  87. package/test/docker/docker-compose.yml +97 -0
  88. package/test/integration.test.ts +166 -0
  89. package/test/recovery.test.ts +107 -0
  90. package/test/sep38.test.ts +71 -0
  91. package/test/sep6.test.ts +240 -0
  92. package/test/stellar.test.ts +57 -12
  93. package/test/transaction.test.ts +8 -10
  94. package/test/tsconfig.json +10 -0
  95. package/test/utils/index.ts +12 -0
  96. package/test/wallet.test.ts +60 -21
@@ -0,0 +1,61 @@
1
+ export type CustomerInfoMap = {
2
+ [key: string]: string;
3
+ };
4
+
5
+ export enum Sep12Status {
6
+ ACCEPTED = "ACCEPTED",
7
+ PROCESSING = "PROCESSING",
8
+ NEEDS_INFO = "NEEDS_INFO",
9
+ REJECTED = "REJECTED",
10
+ VERIFICATION_REQUIRED = "VERIFICATION_REQUIRED",
11
+ }
12
+
13
+ export enum Sep12Type {
14
+ string = "string",
15
+ binary = "binary",
16
+ number = "number",
17
+ date = "date",
18
+ }
19
+
20
+ export type Field = {
21
+ type: Sep12Type;
22
+ description: string;
23
+ choices?: Array<string>;
24
+ optional?: boolean;
25
+ };
26
+
27
+ export type ProvidedField = {
28
+ type: Sep12Type;
29
+ description: string;
30
+ choices?: Array<string>;
31
+ optional?: boolean;
32
+ status?: Sep12Status;
33
+ error?: string;
34
+ };
35
+
36
+ export type GetCustomerParams = {
37
+ id?: string;
38
+ type?: string;
39
+ memo?: string;
40
+ lang?: string;
41
+ };
42
+
43
+ export type GetCustomerResponse = {
44
+ id?: string;
45
+ status: Sep12Status;
46
+ fields?: { [key: string]: Field };
47
+ provided_fields?: { [key: string]: ProvidedField };
48
+ message?: string;
49
+ };
50
+
51
+ export type AddCustomerParams = {
52
+ sep9Info?: CustomerInfoMap;
53
+ sep9BinaryInfo?: CustomerInfoMap;
54
+ id?: string;
55
+ memo?: string;
56
+ type?: string;
57
+ };
58
+
59
+ export type AddCustomerResponse = {
60
+ id: string;
61
+ };
@@ -0,0 +1,106 @@
1
+ import { AxiosInstance } from "axios";
2
+ import { Anchor } from "../Anchor";
3
+ import { AuthToken } from "./auth";
4
+
5
+ export interface Sep38Info {
6
+ assets: Array<Sep38AssetInfo>;
7
+ }
8
+
9
+ export interface Sep38AssetInfo {
10
+ asset: string;
11
+ sell_delivery_methods?: Array<Sep38DeliveryMethod>;
12
+ buy_delivery_methods?: Array<Sep38DeliveryMethod>;
13
+ country_codes?: Array<string>;
14
+ }
15
+
16
+ export interface Sep38DeliveryMethod {
17
+ name: string;
18
+ description: string;
19
+ }
20
+
21
+ export type Sep38Params = {
22
+ anchor: Anchor;
23
+ httpClient: AxiosInstance;
24
+ authToken?: AuthToken;
25
+ };
26
+
27
+ export interface Sep38PricesParams {
28
+ sellAsset: string;
29
+ sellAmount: string;
30
+ sellDeliveryMethod?: string;
31
+ buyDeliveryMethod?: string;
32
+ countryCode?: string;
33
+ }
34
+
35
+ export interface Sep38PricesResponse {
36
+ buy_assets: Array<Sep38BuyAsset>;
37
+ }
38
+
39
+ export interface Sep38BuyAsset {
40
+ asset: string;
41
+ price: string;
42
+ decimals: number;
43
+ }
44
+
45
+ export interface Sep38PriceParams {
46
+ sellAsset: string;
47
+ buyAsset: string;
48
+ sellAmount?: string;
49
+ buyAmount?: string;
50
+ context: Sep38PriceContext;
51
+ sellDeliveryMethod?: string;
52
+ buyDeliveryMethod?: string;
53
+ countryCode?: string;
54
+ }
55
+
56
+ export enum Sep38PriceContext {
57
+ SEP6 = "sep6",
58
+ SEP24 = "sep24",
59
+ SEP31 = "sep31",
60
+ }
61
+
62
+ export interface Sep38PriceResponse {
63
+ total_price: string;
64
+ price: string;
65
+ sell_amount: string;
66
+ buy_amount: string;
67
+ fee: {
68
+ total: string;
69
+ asset: string;
70
+ details?: Array<Sep38FeeDetails>;
71
+ };
72
+ }
73
+
74
+ export interface Sep38FeeDetails {
75
+ name: string;
76
+ description?: string;
77
+ amount: string;
78
+ }
79
+
80
+ export interface Sep38PostQuoteParams {
81
+ sell_asset: string;
82
+ buy_asset: string;
83
+ sell_amount: string;
84
+ buy_amount: string;
85
+ context: Sep38PriceContext;
86
+ expire_after?: string;
87
+ sell_delivery_method?: string;
88
+ buy_delivery_method?: string;
89
+ country_code?: string;
90
+ }
91
+
92
+ export interface Sep38PostQuoteResponse {
93
+ id: string;
94
+ expires_at: string;
95
+ total_price: string;
96
+ price: string;
97
+ sell_asset: string;
98
+ sell_amount: string;
99
+ buy_asset: string;
100
+ buy_amount: string;
101
+ fee: {
102
+ total: string;
103
+ asset: string;
104
+ details?: Array<Sep38FeeDetails>;
105
+ };
106
+ }
@@ -0,0 +1,168 @@
1
+ import { AxiosInstance } from "axios";
2
+ import { Anchor } from "../Anchor";
3
+
4
+ export interface Sep6EndpointInfo {
5
+ enabled: boolean;
6
+ authentication_required?: boolean;
7
+ description?: string;
8
+ }
9
+
10
+ export interface Sep6DepositInfo {
11
+ enabled: boolean;
12
+ authentication_required?: boolean;
13
+ fee_fixed?: number;
14
+ fee_percent?: number;
15
+ min_amount?: number;
16
+ max_amount?: number;
17
+ fields?: {
18
+ [key: string]: {
19
+ description: string;
20
+ optional?: boolean;
21
+ choices?: string[];
22
+ };
23
+ };
24
+ }
25
+
26
+ export interface Sep6WithdrawInfo {
27
+ enabled: boolean;
28
+ authentication_required?: boolean;
29
+ fee_fixed?: number;
30
+ fee_percent?: number;
31
+ min_amount?: number;
32
+ max_amount?: number;
33
+ types?: {
34
+ [key: string]: {
35
+ fields?: {
36
+ [key: string]: {
37
+ description: string;
38
+ optional?: boolean;
39
+ choices?: string[];
40
+ };
41
+ };
42
+ };
43
+ };
44
+ }
45
+
46
+ export interface Sep6Info {
47
+ deposit: { [key: string]: Sep6DepositInfo };
48
+ "deposit-exchange": { [key: string]: Sep6DepositInfo };
49
+ withdraw: { [key: string]: Sep6WithdrawInfo };
50
+ "withdraw-exchange": { [key: string]: Sep6WithdrawInfo };
51
+ fee: {
52
+ enabled: boolean;
53
+ description: string;
54
+ };
55
+ transactions: Sep6EndpointInfo;
56
+ transaction: Sep6EndpointInfo;
57
+ features: {
58
+ account_creation: boolean;
59
+ claimable_balances: boolean;
60
+ };
61
+ }
62
+
63
+ export type Sep6Params = {
64
+ anchor: Anchor;
65
+ httpClient: AxiosInstance;
66
+ };
67
+
68
+ export interface Sep6DepositParams {
69
+ asset_code: string;
70
+ account: string;
71
+ memo_type?: string;
72
+ memo?: string;
73
+ email_address?: string;
74
+ type?: string;
75
+ lang?: string;
76
+ on_change_callback?: string;
77
+ amount?: string;
78
+ country_code?: string;
79
+ claimable_balance_supported?: string;
80
+ customer_id?: string;
81
+ }
82
+
83
+ export interface Sep6WithdrawParams {
84
+ asset_code: string;
85
+ type: string;
86
+ dest?: string;
87
+ dest_extra?: string;
88
+ account?: string;
89
+ memo?: string;
90
+ lang?: string;
91
+ on_change_callback?: string;
92
+ amount?: string;
93
+ country_code?: string;
94
+ refund_memo?: string;
95
+ refund_memo_type?: string;
96
+ customer_id?: string;
97
+ }
98
+
99
+ export type Sep6DepositResponse =
100
+ | Sep6DepositSuccess
101
+ | Sep6MissingKYC
102
+ | Sep6Pending;
103
+
104
+ export interface Sep6DepositSuccess {
105
+ how?: string;
106
+ instructions?: {
107
+ [key: string]: {
108
+ value: string;
109
+ description: string;
110
+ };
111
+ };
112
+ id?: string;
113
+ eta?: number;
114
+ min_amoun?: number;
115
+ max_amount?: number;
116
+ fee_fixed?: number;
117
+ fee_percent?: number;
118
+ extra_info?: { message?: string };
119
+ }
120
+
121
+ export interface Sep6MissingKYC {
122
+ type: string;
123
+ fields: Array<string>;
124
+ }
125
+
126
+ export interface Sep6Pending {
127
+ type: string;
128
+ status: string;
129
+ more_info_url?: string;
130
+ eta?: number;
131
+ }
132
+
133
+ export type Sep6WithdrawResponse =
134
+ | Sep6WithdrawSuccess
135
+ | Sep6MissingKYC
136
+ | Sep6Pending;
137
+
138
+ export interface Sep6WithdrawSuccess {
139
+ account_id?: string;
140
+ memo_type?: string;
141
+ memo?: string;
142
+ id?: string;
143
+ eta?: number;
144
+ min_amount?: number;
145
+ max_amount?: number;
146
+ fee_fixed?: number;
147
+ fee_percent?: number;
148
+ extra_info?: { message?: string };
149
+ }
150
+
151
+ export interface Sep6ExchangeParams {
152
+ destination_asset: string;
153
+ source_asset: string;
154
+ amount: string;
155
+ account?: string;
156
+ quote_id?: string;
157
+ memo_type?: string;
158
+ memo?: string;
159
+ email_address?: string;
160
+ type?: string;
161
+ lang?: string;
162
+ on_change_callback?: string;
163
+ country_code?: string;
164
+ claimable_balance_supported?: string;
165
+ customer_id?: string;
166
+ refund_memo?: string;
167
+ refund_memo_type?: string;
168
+ }
@@ -1,7 +1,8 @@
1
1
  import { AnchorTransaction } from "./anchor";
2
+ import { AuthToken } from "./auth";
2
3
 
3
4
  export type WatchTransactionsParams = {
4
- authToken: string;
5
+ authToken: AuthToken;
5
6
  assetCode: string;
6
7
  onMessage: (transaction: AnchorTransaction) => void;
7
8
  onError: (error: AnchorTransaction | Error) => void;
@@ -14,7 +15,7 @@ export type WatchTransactionsParams = {
14
15
  };
15
16
 
16
17
  export type WatchTransactionParams = {
17
- authToken: string;
18
+ authToken: AuthToken;
18
19
  assetCode: string;
19
20
  id: string;
20
21
  onMessage: (transaction: AnchorTransaction) => void;
@@ -32,3 +33,8 @@ export interface WatcherResponse {
32
33
  refresh: WatcherRefreshFunction;
33
34
  stop: WatcherStopFunction;
34
35
  }
36
+
37
+ export enum WatcherSepType {
38
+ SEP6 = "SEP6",
39
+ SEP24 = "SEP24",
40
+ }
@@ -4,6 +4,7 @@ export const camelToSnakeCaseKey = (key: string): string =>
4
4
  (upperCaseLetter) => `_${upperCaseLetter.toLowerCase()}`,
5
5
  );
6
6
 
7
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
7
8
  export const camelToSnakeCaseObject = (obj: any): any => {
8
9
  const snakeCasedObj = {};
9
10
  for (const key in obj) {
@@ -0,0 +1,28 @@
1
+ import axios from "axios";
2
+ import { AxiosErrorData } from "../Types";
3
+
4
+ // Based on https://axios-http.com/docs/handling_errors
5
+
6
+ export const extractAxiosErrorData = (error: Error): AxiosErrorData => {
7
+ if (!axios.isAxiosError(error)) {
8
+ return { responseData: JSON.stringify(error) };
9
+ }
10
+ if (error.response) {
11
+ return {
12
+ status: error.response.status,
13
+ statusText: error.response.statusText,
14
+ responseData: error.response.data,
15
+ headers: error.response.headers,
16
+ };
17
+ } else if (error.request) {
18
+ // The request was made but no response was received
19
+ return {
20
+ statusText: `No response received from request: ${JSON.stringify(
21
+ error.request,
22
+ )}`,
23
+ };
24
+ } else {
25
+ // Something happened in setting up the request that triggered an Error
26
+ return { statusText: `Failed request with error: ${error.message}` };
27
+ }
28
+ };
@@ -1,3 +1,4 @@
1
1
  export * from "./camelToSnakeCase";
2
2
  export * from "./toml";
3
3
  export * from "./url";
4
+ export * from "./extractAxiosErrorData";
@@ -1,8 +1,8 @@
1
- import { StellarTomlResolver } from "stellar-sdk";
1
+ import { StellarToml } from "stellar-sdk";
2
2
 
3
3
  import { TomlInfo } from "../Types";
4
4
 
5
- export const parseToml = (toml: StellarTomlResolver.StellarToml): TomlInfo => {
5
+ export const parseToml = (toml: StellarToml.Api.StellarToml): TomlInfo => {
6
6
  const tomlDocumentation = toml["DOCUMENTATION"];
7
7
  const documentation = {
8
8
  orgName: tomlDocumentation["ORG_NAME"],
@@ -0,0 +1,65 @@
1
+ import { AxiosInstance } from "axios";
2
+ import queryString from "query-string";
3
+
4
+ import { AuthToken } from "../Types";
5
+ import {
6
+ ServerRequestFailedError,
7
+ InvalidTransactionsResponseError,
8
+ InvalidTransactionResponseError,
9
+ } from "../Exceptions";
10
+
11
+ export const _getTransactionsForAsset = async <T>(
12
+ authToken: AuthToken,
13
+ params: { [key: string]: string | number },
14
+ endpoint: string,
15
+ client: AxiosInstance,
16
+ ): Promise<T[]> => {
17
+ try {
18
+ const resp = await client.get(
19
+ `${endpoint}/transactions?${queryString.stringify(params)}`,
20
+ {
21
+ headers: {
22
+ Authorization: `Bearer ${authToken.token}`,
23
+ },
24
+ },
25
+ );
26
+
27
+ const transactions: T[] = resp.data.transactions;
28
+
29
+ if (!transactions || !Array.isArray(transactions)) {
30
+ throw new InvalidTransactionsResponseError(transactions);
31
+ }
32
+
33
+ return transactions;
34
+ } catch (e) {
35
+ throw new ServerRequestFailedError(e);
36
+ }
37
+ };
38
+
39
+ export const _getTransactionBy = async <T>(
40
+ authToken: AuthToken,
41
+ params: { [key: string]: string | number },
42
+ endpoint: string,
43
+ client: AxiosInstance,
44
+ ): Promise<T> => {
45
+ try {
46
+ const resp = await client.get(
47
+ `${endpoint}/transaction?${queryString.stringify(params)}`,
48
+ {
49
+ headers: {
50
+ Authorization: `Bearer ${authToken.token}`,
51
+ },
52
+ },
53
+ );
54
+
55
+ const transaction: T = resp.data.transaction;
56
+
57
+ if (!transaction || Object.keys(transaction).length === 0) {
58
+ throw new InvalidTransactionResponseError(transaction);
59
+ }
60
+
61
+ return transaction;
62
+ } catch (e) {
63
+ throw new ServerRequestFailedError(e);
64
+ }
65
+ };
@@ -5,6 +5,7 @@ import {
5
5
  WatchTransactionParams,
6
6
  WatchTransactionsParams,
7
7
  WatcherResponse,
8
+ WatcherSepType,
8
9
  } from "../Types";
9
10
 
10
11
  interface WatchRegistryAsset {
@@ -20,16 +21,21 @@ interface WatchAllTransactionsRegistry {
20
21
  }
21
22
 
22
23
  interface TransactionsRegistryAsset {
23
- [id: string]: any; // TOOD - replace with Transaction type
24
+ [id: string]: AnchorTransaction;
24
25
  }
25
26
 
26
27
  interface TransactionsRegistry {
27
28
  [assetCode: string]: TransactionsRegistryAsset;
28
29
  }
29
30
 
30
- // Do not create this object directly, use the Anchor class.
31
+ /**
32
+ * Used for watching transaction from an Anchor as part of sep-24.
33
+ * Do not create this object directly, use the Anchor class.
34
+ * @class
35
+ */
31
36
  export class Watcher {
32
37
  private anchor: Anchor;
38
+ private sepType: WatcherSepType;
33
39
 
34
40
  private _oneTransactionWatcher: {
35
41
  [assetCode: string]: {
@@ -42,8 +48,16 @@ export class Watcher {
42
48
  private _transactionsRegistry: TransactionsRegistry;
43
49
  private _transactionsIgnoredRegistry: TransactionsRegistry;
44
50
 
45
- constructor(anchor: Anchor) {
51
+ /**
52
+ * Creates a new instance of the Watcher class.
53
+ *
54
+ * @param {Anchor} anchor - The Anchor to watch from.
55
+ * @param {WatcherSepType} sepType - The Sep type the anchor being polled is using
56
+ * (ie. Sep-6 or Sep-24).
57
+ */
58
+ constructor(anchor: Anchor, sepType: WatcherSepType) {
46
59
  this.anchor = anchor;
60
+ this.sepType = sepType;
47
61
 
48
62
  this._oneTransactionWatcher = {};
49
63
  this._allTransactionsWatcher = undefined;
@@ -59,11 +73,23 @@ export class Watcher {
59
73
  *
60
74
  * On initial load, it'll return ALL pending transactions via onMessage.
61
75
  * Subsequent messages will be any one of these events:
62
- * - Any new transaction appears
63
- * - Any of the initial pending transactions change any state
76
+ * - Any new transaction appears
77
+ * - Any of the initial pending transactions change any state
64
78
  *
65
79
  * You may also provide an array of transaction ids, `watchlist`, and this
66
80
  * watcher will always react to transactions whose ids are in the watchlist.
81
+ * @param {WatchTransactionsParams} params - The Watch Transactions params.
82
+ * @param {AuthToken} params.authToken - The authentication token used for authenticating with the anchor.
83
+ * @param {string} params.assetCode - The asset code to filter transactions by.
84
+ * @param {Function} params.onMessage - A callback function to handle incoming transaction messages.
85
+ * @param {Function} params.onError - A callback function to handle errors during transaction streaming.
86
+ * @param {Array<string>} [params.watchlist=[]] - An optional array of specific transaction IDs to watch.
87
+ * @param {number} [params.timeout=5000] - The timeout duration for the streaming connection (in milliseconds).
88
+ * @param {boolean} [params.isRetry=false] - Indicates whether this is a retry attempt (optional).
89
+ * @param {string} [params.lang=this.anchor.language] - The desired language (localization) for transaction messages.
90
+ * @param {string} params.kind - The kind of transaction to filter by.
91
+ * @param {string} [params.noOlderThan] - A date and time specifying that transactions older than this value should not be included.
92
+ * @returns {WatcherResponse} An object holding the refresh and stop functions for the watcher.
67
93
  */
68
94
  watchAllTransactions({
69
95
  authToken,
@@ -110,8 +136,19 @@ export class Watcher {
110
136
  this._watchAllTransactionsRegistry[assetCode] = true;
111
137
  }
112
138
 
113
- this.anchor
114
- .sep24()
139
+ let sepObj;
140
+ switch (this.sepType) {
141
+ case WatcherSepType.SEP6:
142
+ sepObj = this.anchor.sep6();
143
+ break;
144
+ case WatcherSepType.SEP24:
145
+ sepObj = this.anchor.sep24();
146
+ break;
147
+ default:
148
+ break;
149
+ }
150
+
151
+ sepObj
115
152
  .getTransactionsForAsset({
116
153
  authToken,
117
154
  assetCode,
@@ -240,6 +277,17 @@ export class Watcher {
240
277
  * * onSuccess - When the transaction comes back as completed / refunded / expired.
241
278
  * * onError - When there's a runtime error, or the transaction comes back as
242
279
  * no_market / too_small / too_large / error.
280
+ * @param {WatchTransactionParams} params - The Watch Transaction params.
281
+ * @param {AuthToken} params.authToken - The authentication token used for authenticating with th anchor.
282
+ * @param {string} params.assetCode - The asset code to filter transactions by.
283
+ * @param {string} params.id - The id of the transaction to watch.
284
+ * @param {Function} params.onMessage - A callback function to handle incoming transaction messages.
285
+ * @param {Function} params.onSuccess - If a transaction status is in a end state (eg. completed, refunded, expired) then this callback is called.
286
+ * @param {Function} params.onError - A callback function to handle errors during transaction streaming.
287
+ * @param {number} [params.timeout=5000] - The timeout duration for the streaming connection (in milliseconds).
288
+ * @param {boolean} [params.isRetry=false] - Indicates whether this is a retry attempt (optional).
289
+ * @param {string} [params.lang=this.anchor.language] - The desired language (localization) for transaction messages.
290
+ * @returns {WatcherResponse} An object holding the refresh and stop functions for the watcher.
243
291
  */
244
292
  watchOneTransaction({
245
293
  authToken,
@@ -281,9 +329,20 @@ export class Watcher {
281
329
  };
282
330
  }
283
331
 
332
+ let sepObj;
333
+ switch (this.sepType) {
334
+ case WatcherSepType.SEP6:
335
+ sepObj = this.anchor.sep6();
336
+ break;
337
+ case WatcherSepType.SEP24:
338
+ sepObj = this.anchor.sep24();
339
+ break;
340
+ default:
341
+ break;
342
+ }
343
+
284
344
  // do this all asynchronously (since this func needs to return a cancel fun)
285
- this.anchor
286
- .sep24()
345
+ sepObj
287
346
  .getTransactionBy({ authToken, id, lang })
288
347
  .then((transaction: AnchorTransaction) => {
289
348
  // make sure we're still watching
@@ -363,3 +422,5 @@ export class Watcher {
363
422
  };
364
423
  }
365
424
  }
425
+
426
+ export * from "./getTransactions";