@stellar/typescript-wallet-sdk 1.0.0-alpha.2 → 1.0.0-beta.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 (67) hide show
  1. package/lib/bundle.js +1979 -259
  2. package/lib/bundle.js.map +1 -1
  3. package/lib/index.d.ts +25 -0
  4. package/lib/walletSdk/Exceptions/index.d.ts +22 -0
  5. package/lib/walletSdk/Types/anchor.d.ts +148 -0
  6. package/lib/walletSdk/Types/auth.d.ts +34 -0
  7. package/lib/walletSdk/Types/horizon.d.ts +4 -0
  8. package/lib/walletSdk/Types/index.d.ts +32 -0
  9. package/lib/walletSdk/Types/interactive.d.ts +27 -0
  10. package/lib/walletSdk/Types/utils.d.ts +77 -0
  11. package/lib/walletSdk/Types/watcher.d.ts +30 -0
  12. package/lib/walletSdk/Utils/camelToSnakeCase.d.ts +2 -0
  13. package/lib/walletSdk/Utils/index.d.ts +3 -0
  14. package/lib/walletSdk/Utils/toml.d.ts +3 -0
  15. package/lib/walletSdk/Utils/url.d.ts +1 -0
  16. package/lib/walletSdk/Watcher/Types.d.ts +65 -0
  17. package/lib/walletSdk/Watcher/index.d.ts +33 -0
  18. package/lib/walletSdk/anchor/Types.d.ts +75 -0
  19. package/lib/walletSdk/anchor/index.d.ts +65 -9
  20. package/lib/walletSdk/auth/WalletSigner.d.ts +4 -0
  21. package/lib/walletSdk/auth/index.d.ts +18 -6
  22. package/lib/walletSdk/exception/index.d.ts +9 -0
  23. package/lib/walletSdk/horizon/Account.d.ts +18 -0
  24. package/lib/walletSdk/horizon/AccountService.d.ts +8 -0
  25. package/lib/walletSdk/horizon/Stellar.d.ts +5 -1
  26. package/lib/walletSdk/horizon/index.d.ts +3 -0
  27. package/lib/walletSdk/index.d.ts +18 -18
  28. package/lib/walletSdk/interactive/index.d.ts +11 -11
  29. package/lib/walletSdk/recovery/index.d.ts +18 -0
  30. package/lib/walletSdk/util/camelToSnakeCase.d.ts +2 -0
  31. package/lib/walletSdk/util/sleep.d.ts +1 -0
  32. package/package.json +12 -6
  33. package/src/index.ts +39 -1
  34. package/src/walletSdk/Anchor/index.ts +252 -27
  35. package/src/walletSdk/Auth/WalletSigner.ts +27 -3
  36. package/src/walletSdk/Auth/index.ts +87 -32
  37. package/src/walletSdk/Exceptions/index.ts +51 -0
  38. package/src/walletSdk/Horizon/Account.ts +50 -0
  39. package/src/walletSdk/Horizon/AccountService.ts +19 -0
  40. package/src/walletSdk/Horizon/Stellar.ts +15 -0
  41. package/src/walletSdk/Horizon/index.ts +3 -0
  42. package/src/walletSdk/Interactive/index.ts +126 -0
  43. package/src/walletSdk/Recovery/index.ts +37 -0
  44. package/src/walletSdk/Types/anchor.ts +174 -0
  45. package/src/walletSdk/Types/auth.ts +42 -0
  46. package/src/walletSdk/{horizon/constants.ts → Types/horizon.ts} +1 -1
  47. package/src/walletSdk/Types/index.ts +40 -0
  48. package/src/walletSdk/Types/interactive.ts +36 -0
  49. package/src/walletSdk/Types/utils.ts +77 -0
  50. package/src/walletSdk/Types/watcher.ts +34 -0
  51. package/src/walletSdk/Utils/camelToSnakeCase.ts +13 -0
  52. package/src/walletSdk/Utils/index.ts +3 -0
  53. package/src/walletSdk/Utils/toml.ts +103 -0
  54. package/src/walletSdk/{util → Utils}/url.ts +1 -1
  55. package/src/walletSdk/Watcher/index.ts +367 -0
  56. package/src/walletSdk/index.ts +103 -58
  57. package/test/account.test.ts +30 -0
  58. package/test/fixtures/TransactionsResponse.ts +230 -0
  59. package/test/wallet.test.ts +1719 -0
  60. package/src/walletSdk/exception/index.ts +0 -27
  61. package/src/walletSdk/horizon/Account.ts +0 -0
  62. package/src/walletSdk/horizon/AccountService.ts +0 -0
  63. package/src/walletSdk/horizon/Stellar.ts +0 -6
  64. package/src/walletSdk/interactive/index.ts +0 -103
  65. package/src/walletSdk/recovery/Recovery.ts +0 -6
  66. package/src/walletSdk/toml/index.ts +0 -179
  67. package/test/index.test.ts +0 -73
package/lib/index.d.ts CHANGED
@@ -1,3 +1,28 @@
1
+ /**
2
+ * Types
3
+ */
4
+ import * as Types from "./walletSdk/Types";
5
+ export { Types };
6
+ /**
7
+ * Classes
8
+ */
9
+ export { Wallet, Config, StellarConfiguration, ApplicationConfiguration } from "./walletSdk";
10
+ export { Anchor } from "./walletSdk/Anchor";
11
+ export { Auth, WalletSigner, DefaultSigner } from "./walletSdk/Auth";
12
+ export { PublicKeypair, SigningKeypair, AccountService, Stellar } from "./walletSdk/Horizon";
13
+ export { Interactive } from "./walletSdk/Interactive";
14
+ export { Recovery } from "./walletSdk/Recovery";
15
+ export { Watcher } from "./walletSdk/Watcher";
16
+ /**
17
+ * Utils
18
+ */
19
+ import * as Utils from "./walletSdk/Utils";
20
+ export { Utils };
21
+ /**
22
+ * Exceptions
23
+ */
24
+ import * as Exceptions from "./walletSdk/Exceptions";
25
+ export { Exceptions };
1
26
  import * as walletSdk from "./walletSdk";
2
27
  import { Keypair } from "stellar-sdk";
3
28
  export { walletSdk, Keypair };
@@ -0,0 +1,22 @@
1
+ import { AnchorTransaction, FLOW_TYPE } from "../Types";
2
+ export declare class ServerRequestFailedError extends Error {
3
+ constructor(e: Error);
4
+ }
5
+ export declare class AssetNotSupportedError extends Error {
6
+ constructor(type: FLOW_TYPE, assetCode: string);
7
+ }
8
+ export declare class InvalidMemoError extends Error {
9
+ constructor();
10
+ }
11
+ export declare class ClientDomainWithMemoError extends Error {
12
+ constructor();
13
+ }
14
+ export declare class MissingTransactionIdError extends Error {
15
+ constructor();
16
+ }
17
+ export declare class InvalidTransactionResponseError extends Error {
18
+ constructor(transactionResponse: AnchorTransaction);
19
+ }
20
+ export declare class InvalidTransactionsResponseError extends Error {
21
+ constructor(transactionsResponse: AnchorTransaction[]);
22
+ }
@@ -0,0 +1,148 @@
1
+ import { MemoType } from "stellar-sdk";
2
+ import { Optional } from "utility-types";
3
+ export interface AnchorServiceInfo {
4
+ deposit: AssetInfoMap;
5
+ withdraw: AssetInfoMap;
6
+ fee: {
7
+ enabled: boolean;
8
+ };
9
+ features: {
10
+ account_creation: boolean;
11
+ claimable_balances: boolean;
12
+ };
13
+ }
14
+ export interface AssetInfoMap {
15
+ [asset_code: string]: AnchorServiceAsset;
16
+ }
17
+ export interface AnchorServiceAsset {
18
+ enabled: boolean;
19
+ min_amount: number;
20
+ max_amount: number;
21
+ fee_fixed: number;
22
+ fee_percent: number;
23
+ }
24
+ export interface BaseTransaction {
25
+ id: string;
26
+ kind: string;
27
+ status: TransactionStatus;
28
+ more_info_url: string;
29
+ started_at: string;
30
+ message?: string;
31
+ }
32
+ export interface ProcessingAnchorTransaction extends BaseTransaction {
33
+ status_eta?: number;
34
+ kyc_verified?: boolean;
35
+ amount_in_asset?: string;
36
+ amount_in: string;
37
+ amount_out_asset?: string;
38
+ amount_out: string;
39
+ amount_fee_asset?: string;
40
+ amount_fee: string;
41
+ completed_at?: string;
42
+ stellar_transaction_id?: string;
43
+ external_transaction_id?: string;
44
+ refunds?: Refunds;
45
+ }
46
+ export interface DepositTransaction extends ProcessingAnchorTransaction {
47
+ from?: string;
48
+ to?: string;
49
+ deposit_memo?: string;
50
+ deposit_memo_type?: MemoType;
51
+ claimable_balance_id?: string;
52
+ }
53
+ export interface WithdrawTransaction extends ProcessingAnchorTransaction {
54
+ from: string;
55
+ to?: string;
56
+ withdraw_memo?: string;
57
+ withdraw_memo_type: MemoType;
58
+ withdraw_anchor_account: string;
59
+ }
60
+ export interface ErrorTransaction extends Optional<DepositTransaction & WithdrawTransaction> {
61
+ }
62
+ export type AnchorTransaction = DepositTransaction | WithdrawTransaction | ErrorTransaction;
63
+ export interface Refunds {
64
+ amount_refunded: string;
65
+ amount_fee: string;
66
+ payments: Payment[];
67
+ }
68
+ export interface Payment {
69
+ id: string;
70
+ id_type: string;
71
+ amount: string;
72
+ fee: string;
73
+ }
74
+ export type GetTransactionParams = {
75
+ authToken: string;
76
+ id?: string;
77
+ stellarTransactionId?: string;
78
+ externalTransactionId?: string;
79
+ lang?: string;
80
+ };
81
+ export type GetTransactionsParams = {
82
+ authToken: string;
83
+ assetCode: string;
84
+ noOlderThan?: string;
85
+ limit?: number;
86
+ kind?: string;
87
+ pagingId?: string;
88
+ lang?: string;
89
+ };
90
+ export declare enum TransactionStatus {
91
+ /**
92
+ * There is not yet enough information for this transaction to be initiated. Perhaps the user has
93
+ * not yet entered necessary info in an interactive flow
94
+ */
95
+ incomplete = "incomplete",
96
+ /**
97
+ * The user has not yet initiated their transfer to the anchor. This is the next necessary step in
98
+ * any deposit or withdrawal flow after transitioning from `incomplete`
99
+ */
100
+ pending_user_transfer_start = "pending_user_transfer_start",
101
+ /**
102
+ * The Stellar payment has been successfully received by the anchor and the off-chain funds are
103
+ * available for the customer to pick up. Only used for withdrawal transactions.
104
+ */
105
+ pending_user_transfer_complete = "pending_user_transfer_complete",
106
+ /**
107
+ * Pending External deposit/withdrawal has been submitted to external network, but is not yet
108
+ * confirmed. This is the status when waiting on Bitcoin or other external crypto network to
109
+ * complete a transaction, or when waiting on a bank transfer.
110
+ */
111
+ pending_external = "pending_external",
112
+ /**
113
+ * Deposit/withdrawal is being processed internally by anchor. This can also be used when the
114
+ * anchor must verify KYC information prior to deposit/withdrawal.
115
+ */
116
+ pending_anchor = "pending_anchor",
117
+ /**
118
+ * Deposit/withdrawal operation has been submitted to Stellar network, but is not yet confirmed.
119
+ */
120
+ pending_stellar = "pending_stellar",
121
+ /** The user must add a trustline for the asset for the deposit to complete. */
122
+ pending_trust = "pending_trust",
123
+ /**
124
+ * The user must take additional action before the deposit / withdrawal can complete, for example
125
+ * an email or 2fa confirmation of a withdrawal.
126
+ */
127
+ pending_user = "pending_user",
128
+ /** Deposit/withdrawal fully completed */
129
+ completed = "completed",
130
+ /** The deposit/withdrawal is fully refunded */
131
+ refunded = "refunded",
132
+ /**
133
+ * Funds were never received by the anchor and the transaction is considered abandoned by the
134
+ * user. Anchors are responsible for determining when transactions are considered expired.
135
+ */
136
+ expired = "expired",
137
+ /**
138
+ * Could not complete deposit because no satisfactory asset/XLM market was available to create the
139
+ * account
140
+ */
141
+ no_market = "no_market",
142
+ /** Deposit/withdrawal size less than min_amount. */
143
+ too_small = "too_small",
144
+ /** Deposit/withdrawal size exceeded max_amount. */
145
+ too_large = "too_large",
146
+ /** Catch-all for any error not enumerated above. */
147
+ error = "error"
148
+ }
@@ -0,0 +1,34 @@
1
+ import { Keypair, Transaction } from "stellar-sdk";
2
+ import { WalletSigner } from "../Auth/WalletSigner";
3
+ export type AuthenticateParams = {
4
+ accountKp: Keypair;
5
+ walletSigner?: WalletSigner;
6
+ memoId?: string;
7
+ clientDomain?: string;
8
+ };
9
+ export type AuthToken = string;
10
+ export type ChallengeParams = {
11
+ accountKp: Keypair;
12
+ memoId?: string;
13
+ clientDomain?: string;
14
+ };
15
+ export type XdrEncodedTransaction = string;
16
+ export type NetworkPassphrase = string;
17
+ export type ChallengeResponse = {
18
+ transaction: XdrEncodedTransaction;
19
+ network_passphrase: NetworkPassphrase;
20
+ };
21
+ export type SignParams = {
22
+ accountKp: Keypair;
23
+ challengeResponse: ChallengeResponse;
24
+ walletSigner: WalletSigner;
25
+ };
26
+ export type SignWithClientAccountParams = {
27
+ transaction: Transaction;
28
+ accountKp: Keypair;
29
+ };
30
+ export type SignWithDomainAccountParams = {
31
+ transactionXDR: XdrEncodedTransaction;
32
+ networkPassphrase: NetworkPassphrase;
33
+ accountKp: Keypair;
34
+ };
@@ -0,0 +1,4 @@
1
+ export declare enum NETWORK_URLS {
2
+ PUBLIC = "https://horizon.stellar.org",
3
+ TESTNET = "https://horizon-testnet.stellar.org"
4
+ }
@@ -0,0 +1,32 @@
1
+ import { AxiosRequestConfig } from "axios";
2
+ import { Server, Networks } from "stellar-sdk";
3
+ import { ApplicationConfiguration, StellarConfiguration } from "walletSdk";
4
+ export type WalletParams = {
5
+ stellarConfiguration: StellarConfiguration;
6
+ applicationConfiguration?: ApplicationConfiguration;
7
+ language?: string;
8
+ };
9
+ export type WalletAnchor = {
10
+ homeDomain: string;
11
+ httpClientConfig?: AxiosRequestConfig;
12
+ language?: string;
13
+ };
14
+ export type WalletRecovery = {
15
+ servers: Server[];
16
+ httpClientConfig?: AxiosRequestConfig;
17
+ };
18
+ export type ConfigParams = {
19
+ stellarConfiguration: StellarConfiguration;
20
+ applicationConfiguration?: ApplicationConfiguration;
21
+ };
22
+ export type StellarConfigurationParams = {
23
+ network: Networks;
24
+ horizonUrl: string;
25
+ baseFee?: number;
26
+ };
27
+ export * from "./anchor";
28
+ export * from "./auth";
29
+ export * from "./horizon";
30
+ export * from "./interactive";
31
+ export * from "./utils";
32
+ export * from "./watcher";
@@ -0,0 +1,27 @@
1
+ import { AuthToken } from "./auth";
2
+ export declare enum FLOW_TYPE {
3
+ DEPOSIT = "deposit",
4
+ WITHDRAW = "withdraw"
5
+ }
6
+ export type ExtraFields = {
7
+ [api_key: string]: string;
8
+ };
9
+ export type InteractivePostParams = {
10
+ authToken: AuthToken;
11
+ accountAddress: string;
12
+ assetCode: string;
13
+ lang?: string;
14
+ extraFields?: ExtraFields;
15
+ fundsAccountAddress?: string;
16
+ };
17
+ export declare enum InteractiveResponseType {
18
+ authentication_required = "authentication_required",
19
+ interactive_customer_info_needed = "interactive_customer_info_needed",
20
+ error = "error"
21
+ }
22
+ export interface InteractivePostResponse {
23
+ type: InteractiveResponseType.authentication_required | InteractiveResponseType.interactive_customer_info_needed | InteractiveResponseType.error;
24
+ id?: string;
25
+ url?: string;
26
+ error?: string;
27
+ }
@@ -0,0 +1,77 @@
1
+ export type TomlInfo = {
2
+ version: string;
3
+ networkPassphrase: string;
4
+ federationServer: string;
5
+ authServer: string;
6
+ transferServer: string;
7
+ transferServerSep24: string;
8
+ kycServer: string;
9
+ webAuthEndpoint: string;
10
+ signingKey: string;
11
+ horizonUrl: string;
12
+ accounts: Array<string>;
13
+ uriRequestSigningKey: string;
14
+ directPaymentServer: string;
15
+ anchorQuoteServer: string;
16
+ documentation: {
17
+ orgName: string;
18
+ orgDba: string;
19
+ orgUrl: string;
20
+ orgLogo: string;
21
+ orgDescription: string;
22
+ orgPhysicalAddress: string;
23
+ orgPhysicalAddressAttestation: string;
24
+ orgPhoneNumber: string;
25
+ orgPhoneNumberAttestation: string;
26
+ orgKeybase: string;
27
+ orgTwitter: string;
28
+ orgGithub: string;
29
+ orgOfficialEmail: string;
30
+ orgSupportEmail: string;
31
+ orgLicensingAuthority: string;
32
+ orgLicenseType: string;
33
+ orgLicenseNumber: string;
34
+ };
35
+ principals: Array<{
36
+ name: string;
37
+ email: string;
38
+ keybase: string;
39
+ telegram: string;
40
+ twitter: string;
41
+ github: string;
42
+ idPhotoHash: string;
43
+ verificationPhotoHash: string;
44
+ }>;
45
+ currencies: Array<{
46
+ code: string;
47
+ codeTemplate: string;
48
+ issuer: string;
49
+ status: string;
50
+ displayDecimals: number;
51
+ name: string;
52
+ desc: string;
53
+ conditions: string;
54
+ image: string;
55
+ fixedNumber: number;
56
+ maxNumber: number;
57
+ isUnlimited: boolean;
58
+ isAssetAnchored: boolean;
59
+ anchorAssetType: string;
60
+ anchorAsset: string;
61
+ attestationOfReserve: string;
62
+ redemptionInstructions: string;
63
+ collateralAddresses: Array<string>;
64
+ collateralAddressMessages: Array<string>;
65
+ collateralAddressSignatures: Array<string>;
66
+ regulated: boolean;
67
+ approvalServer: string;
68
+ approvalCriteria: string;
69
+ }>;
70
+ validators: Array<{
71
+ alias: string;
72
+ displayName: string;
73
+ publicKey: string;
74
+ host: string;
75
+ history: string;
76
+ }>;
77
+ };
@@ -0,0 +1,30 @@
1
+ import { AnchorTransaction } from "./anchor";
2
+ export type WatchTransactionsParams = {
3
+ authToken: string;
4
+ assetCode: string;
5
+ onMessage: (transaction: AnchorTransaction) => void;
6
+ onError: (error: AnchorTransaction | Error) => void;
7
+ watchlist?: string[];
8
+ timeout?: number;
9
+ isRetry?: boolean;
10
+ lang?: string;
11
+ kind?: string;
12
+ noOlderThan?: string;
13
+ };
14
+ export type WatchTransactionParams = {
15
+ authToken: string;
16
+ assetCode: string;
17
+ id: string;
18
+ onMessage: (transaction: AnchorTransaction) => void;
19
+ onSuccess: (transaction: AnchorTransaction) => void;
20
+ onError: (error: AnchorTransaction | Error) => void;
21
+ timeout?: number;
22
+ isRetry?: boolean;
23
+ lang?: string;
24
+ };
25
+ export type WatcherRefreshFunction = () => void;
26
+ export type WatcherStopFunction = () => void;
27
+ export interface WatcherResponse {
28
+ refresh: WatcherRefreshFunction;
29
+ stop: WatcherStopFunction;
30
+ }
@@ -0,0 +1,2 @@
1
+ export declare const camelToSnakeCaseKey: (key: string) => string;
2
+ export declare const camelToSnakeCaseObject: (obj: any) => any;
@@ -0,0 +1,3 @@
1
+ export * from "./camelToSnakeCase";
2
+ export * from "./toml";
3
+ export * from "./url";
@@ -0,0 +1,3 @@
1
+ import { StellarTomlResolver } from "stellar-sdk";
2
+ import { TomlInfo } from "../Types";
3
+ export declare const parseToml: (toml: StellarTomlResolver.StellarToml) => TomlInfo;
@@ -0,0 +1 @@
1
+ export declare const getUrlDomain: (url: string) => any;
@@ -0,0 +1,65 @@
1
+ export declare enum TransactionStatus {
2
+ /**
3
+ * There is not yet enough information for this transaction to be initiated. Perhaps the user has
4
+ * not yet entered necessary info in an interactive flow
5
+ */
6
+ incomplete = "incomplete",
7
+ /**
8
+ * The user has not yet initiated their transfer to the anchor. This is the next necessary step in
9
+ * any deposit or withdrawal flow after transitioning from `incomplete`
10
+ */
11
+ pending_user_transfer_start = "pending_user_transfer_start",
12
+ /**
13
+ * The Stellar payment has been successfully received by the anchor and the off-chain funds are
14
+ * available for the customer to pick up. Only used for withdrawal transactions.
15
+ */
16
+ pending_user_transfer_complete = "pending_user_transfer_complete",
17
+ /**
18
+ * Pending External deposit/withdrawal has been submitted to external network, but is not yet
19
+ * confirmed. This is the status when waiting on Bitcoin or other external crypto network to
20
+ * complete a transaction, or when waiting on a bank transfer.
21
+ */
22
+ pending_external = "pending_external",
23
+ /**
24
+ * Deposit/withdrawal is being processed internally by anchor. This can also be used when the
25
+ * anchor must verify KYC information prior to deposit/withdrawal.
26
+ */
27
+ pending_anchor = "pending_anchor",
28
+ /**
29
+ * Deposit/withdrawal operation has been submitted to Stellar network, but is not yet confirmed.
30
+ */
31
+ pending_stellar = "pending_stellar",
32
+ /** The user must add a trustline for the asset for the deposit to complete. */
33
+ pending_trust = "pending_trust",
34
+ /**
35
+ * The user must take additional action before the deposit / withdrawal can complete, for example
36
+ * an email or 2fa confirmation of a withdrawal.
37
+ */
38
+ pending_user = "pending_user",
39
+ /** Deposit/withdrawal fully completed */
40
+ completed = "completed",
41
+ /** The deposit/withdrawal is fully refunded */
42
+ refunded = "refunded",
43
+ /**
44
+ * Funds were never received by the anchor and the transaction is considered abandoned by the
45
+ * user. Anchors are responsible for determining when transactions are considered expired.
46
+ */
47
+ expired = "expired",
48
+ /**
49
+ * Could not complete deposit because no satisfactory asset/XLM market was available to create the
50
+ * account
51
+ */
52
+ no_market = "no_market",
53
+ /** Deposit/withdrawal size less than min_amount. */
54
+ too_small = "too_small",
55
+ /** Deposit/withdrawal size exceeded max_amount. */
56
+ too_large = "too_large",
57
+ /** Catch-all for any error not enumerated above. */
58
+ error = "error"
59
+ }
60
+ export type WatcherRefreshFunction = () => void;
61
+ export type WatcherStopFunction = () => void;
62
+ export interface WatcherResponse {
63
+ refresh: WatcherRefreshFunction;
64
+ stop: WatcherStopFunction;
65
+ }
@@ -0,0 +1,33 @@
1
+ import { Anchor } from "../Anchor";
2
+ import { WatchTransactionParams, WatchTransactionsParams, WatcherResponse } from "../Types";
3
+ export declare class Watcher {
4
+ private anchor;
5
+ private _oneTransactionWatcher;
6
+ private _allTransactionsWatcher?;
7
+ private _watchOneTransactionRegistry;
8
+ private _watchAllTransactionsRegistry;
9
+ private _transactionsRegistry;
10
+ private _transactionsIgnoredRegistry;
11
+ constructor(anchor: Anchor);
12
+ /**
13
+ * Watch all transactions returned from a transfer server. When new or
14
+ * updated transactions come in, run an `onMessage` callback.
15
+ *
16
+ * On initial load, it'll return ALL pending transactions via onMessage.
17
+ * Subsequent messages will be any one of these events:
18
+ * - Any new transaction appears
19
+ * - Any of the initial pending transactions change any state
20
+ *
21
+ * You may also provide an array of transaction ids, `watchlist`, and this
22
+ * watcher will always react to transactions whose ids are in the watchlist.
23
+ */
24
+ watchAllTransactions({ authToken, assetCode, onMessage, onError, watchlist, timeout, isRetry, lang, kind, noOlderThan, }: WatchTransactionsParams): WatcherResponse;
25
+ /**
26
+ * Watch a transaction until it stops pending. Takes three callbacks:
27
+ * * onMessage - When the transaction comes back as pending_ or incomplete.
28
+ * * onSuccess - When the transaction comes back as completed / refunded / expired.
29
+ * * onError - When there's a runtime error, or the transaction comes back as
30
+ * no_market / too_small / too_large / error.
31
+ */
32
+ watchOneTransaction({ authToken, assetCode, id, onMessage, onSuccess, onError, timeout, isRetry, lang, }: WatchTransactionParams): WatcherResponse;
33
+ }
@@ -0,0 +1,75 @@
1
+ import { MemoType } from "stellar-sdk";
2
+ import { Optional } from "utility-types";
3
+ import { TransactionStatus } from "../Watcher/Types";
4
+ export interface AssetInfoMap {
5
+ [asset_code: string]: AnchorServiceAsset;
6
+ }
7
+ export interface AnchorServiceInfo {
8
+ deposit: AssetInfoMap;
9
+ withdraw: AssetInfoMap;
10
+ fee: {
11
+ enabled: boolean;
12
+ };
13
+ features: {
14
+ account_creation: boolean;
15
+ claimable_balances: boolean;
16
+ };
17
+ }
18
+ interface BaseTransaction {
19
+ id: string;
20
+ kind: string;
21
+ status: TransactionStatus;
22
+ more_info_url: string;
23
+ started_at: string;
24
+ message?: string;
25
+ }
26
+ interface ProcessingAnchorTransaction extends BaseTransaction {
27
+ status_eta?: number;
28
+ kyc_verified?: boolean;
29
+ amount_in_asset?: string;
30
+ amount_in: string;
31
+ amount_out_asset?: string;
32
+ amount_out: string;
33
+ amount_fee_asset?: string;
34
+ amount_fee: string;
35
+ completed_at?: string;
36
+ stellar_transaction_id?: string;
37
+ external_transaction_id?: string;
38
+ refunds?: Refunds;
39
+ }
40
+ export interface DepositTransaction extends ProcessingAnchorTransaction {
41
+ from?: string;
42
+ to?: string;
43
+ deposit_memo?: string;
44
+ deposit_memo_type?: MemoType;
45
+ claimable_balance_id?: string;
46
+ }
47
+ export interface WithdrawTransaction extends ProcessingAnchorTransaction {
48
+ from: string;
49
+ to?: string;
50
+ withdraw_memo?: string;
51
+ withdraw_memo_type: MemoType;
52
+ withdraw_anchor_account: string;
53
+ }
54
+ interface ErrorTransaction extends Optional<DepositTransaction & WithdrawTransaction> {
55
+ }
56
+ export type AnchorTransaction = DepositTransaction | WithdrawTransaction | ErrorTransaction;
57
+ interface Payment {
58
+ id: string;
59
+ id_type: string;
60
+ amount: string;
61
+ fee: string;
62
+ }
63
+ interface Refunds {
64
+ amount_refunded: string;
65
+ amount_fee: string;
66
+ payments: Payment[];
67
+ }
68
+ export interface AnchorServiceAsset {
69
+ enabled: boolean;
70
+ min_amount: number;
71
+ max_amount: number;
72
+ fee_fixed: number;
73
+ fee_percent: number;
74
+ }
75
+ export {};