@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
@@ -1,5 +1,6 @@
1
1
  import { MemoType } from "stellar-sdk";
2
2
  import { Optional } from "utility-types";
3
+ import { AuthToken } from "./auth";
3
4
  export interface AnchorServiceInfo {
4
5
  deposit: AssetInfoMap;
5
6
  withdraw: AssetInfoMap;
@@ -37,6 +38,7 @@ export interface ProcessingAnchorTransaction extends BaseTransaction {
37
38
  amount_out_asset?: string;
38
39
  amount_out: string;
39
40
  amount_fee_asset?: string;
41
+ quote_id?: string;
40
42
  amount_fee: string;
41
43
  completed_at?: string;
42
44
  stellar_transaction_id?: string;
@@ -57,6 +59,19 @@ export interface WithdrawTransaction extends ProcessingAnchorTransaction {
57
59
  withdraw_memo_type: MemoType;
58
60
  withdraw_anchor_account: string;
59
61
  }
62
+ export type Sep6Transaction = DepositTransaction & WithdrawTransaction & {
63
+ from?: string;
64
+ external_extra?: string;
65
+ external_extra_text?: string;
66
+ required_info_message?: string;
67
+ required_info_updates?: any;
68
+ required_customer_info_message?: string;
69
+ required_customer_info_updates?: any;
70
+ instructions?: {
71
+ value: string;
72
+ description: string;
73
+ };
74
+ };
60
75
  export interface ErrorTransaction extends Optional<DepositTransaction & WithdrawTransaction> {
61
76
  }
62
77
  export type AnchorTransaction = DepositTransaction | WithdrawTransaction | ErrorTransaction;
@@ -72,14 +87,14 @@ export interface Payment {
72
87
  fee: string;
73
88
  }
74
89
  export type GetTransactionParams = {
75
- authToken: string;
90
+ authToken: AuthToken;
76
91
  id?: string;
77
92
  stellarTransactionId?: string;
78
93
  externalTransactionId?: string;
79
94
  lang?: string;
80
95
  };
81
96
  export type GetTransactionsParams = {
82
- authToken: string;
97
+ authToken: AuthToken;
83
98
  assetCode: string;
84
99
  noOlderThan?: string;
85
100
  limit?: number;
@@ -7,7 +7,17 @@ export type AuthenticateParams = {
7
7
  memoId?: string;
8
8
  clientDomain?: string;
9
9
  };
10
- export type AuthToken = string;
10
+ export declare class AuthToken {
11
+ token: string;
12
+ issuer: string;
13
+ issuedAt: string;
14
+ expiresAt: string;
15
+ clientDomain: string;
16
+ private principalAccount;
17
+ get account(): string;
18
+ get memo(): string;
19
+ static from: (str: string) => AuthToken;
20
+ }
11
21
  export type ChallengeParams = {
12
22
  accountKp: AccountKeypair;
13
23
  memoId?: string;
@@ -33,3 +43,6 @@ export type SignWithDomainAccountParams = {
33
43
  networkPassphrase: NetworkPassphrase;
34
44
  accountKp: AccountKeypair;
35
45
  };
46
+ export type HttpHeaders = {
47
+ [key: string]: string;
48
+ };
@@ -1,15 +1,16 @@
1
- import { Memo, Server, Transaction } from "stellar-sdk";
1
+ import { Memo, Horizon, Transaction } from "stellar-sdk";
2
2
  import { AccountKeypair } from "../Horizon/Account";
3
- import { TransactionBuilder } from "../Horizon/Transaction/TransactionBuilder";
3
+ import { SponsoringBuilder, TransactionBuilder } from "walletSdk/Horizon";
4
+ import { StellarAssetId } from "../Asset";
4
5
  export declare enum NETWORK_URLS {
5
6
  PUBLIC = "https://horizon.stellar.org",
6
7
  TESTNET = "https://horizon-testnet.stellar.org"
7
8
  }
8
9
  export type TransactionParams = {
9
10
  sourceAddress: AccountKeypair;
10
- baseFee: number;
11
+ baseFee?: number;
11
12
  memo?: Memo;
12
- timebounds?: Server.Timebounds | number;
13
+ timebounds?: Horizon.Server.Timebounds | number;
13
14
  };
14
15
  export type FeeBumpTransactionParams = {
15
16
  feeAddress: AccountKeypair;
@@ -20,8 +21,8 @@ export type SubmitWithFeeIncreaseParams = {
20
21
  sourceAddress: AccountKeypair;
21
22
  timeout: number;
22
23
  baseFeeIncrease: number;
23
- buildingFunction: (TransactionBuilder: any) => TransactionBuilder;
24
- signerFunction?: (Transaction: any) => Transaction;
24
+ buildingFunction: (builder: TransactionBuilder) => TransactionBuilder;
25
+ signerFunction?: (transaction: Transaction) => Transaction;
25
26
  baseFee?: number;
26
27
  memo?: Memo;
27
28
  maxFee?: number;
@@ -32,3 +33,13 @@ export declare enum HORIZON_ORDER {
32
33
  ASC = "asc",
33
34
  DESC = "desc"
34
35
  }
36
+ export type PathPayParams = {
37
+ destinationAddress: string;
38
+ sendAsset: StellarAssetId;
39
+ destAsset: StellarAssetId;
40
+ sendAmount?: string;
41
+ destAmount?: string;
42
+ destMin?: string;
43
+ sendMax?: string;
44
+ };
45
+ export type CommonBuilder = TransactionBuilder | SponsoringBuilder;
@@ -1,5 +1,7 @@
1
- import { Server, Networks } from "stellar-sdk";
1
+ import { RawAxiosRequestHeaders } from "axios";
2
+ import { Networks } from "stellar-sdk";
2
3
  import { ApplicationConfiguration, StellarConfiguration } from "walletSdk";
4
+ import { RecoveryServerMap } from "./recovery";
3
5
  export type WalletParams = {
4
6
  stellarConfiguration: StellarConfiguration;
5
7
  applicationConfiguration?: ApplicationConfiguration;
@@ -9,8 +11,8 @@ export type WalletAnchor = {
9
11
  homeDomain: string;
10
12
  language?: string;
11
13
  };
12
- export type WalletRecovery = {
13
- servers: Server[];
14
+ export type WalletRecoveryServers = {
15
+ servers: RecoveryServerMap;
14
16
  };
15
17
  export type ConfigParams = {
16
18
  stellarConfiguration: StellarConfiguration;
@@ -22,9 +24,19 @@ export type StellarConfigurationParams = {
22
24
  baseFee?: number;
23
25
  defaultTimeout?: number;
24
26
  };
27
+ export type AxiosErrorData = {
28
+ status?: number;
29
+ statusText?: string;
30
+ responseData?: any;
31
+ headers?: RawAxiosRequestHeaders;
32
+ };
25
33
  export * from "./anchor";
26
34
  export * from "./auth";
27
35
  export * from "./horizon";
36
+ export * from "./recovery";
37
+ export * from "./sep6";
38
+ export * from "./sep12";
28
39
  export * from "./sep24";
40
+ export * from "./sep38";
29
41
  export * from "./utils";
30
42
  export * from "./watcher";
@@ -0,0 +1,128 @@
1
+ import { Transaction } from "stellar-sdk";
2
+ import { WalletSigner } from "walletSdk/Auth";
3
+ import { AccountKeypair, PublicKeypair } from "walletSdk/Horizon";
4
+ import { AuthToken } from "./auth";
5
+ import { CommonBuilder } from "./horizon";
6
+ /**
7
+ * Configuration for recoverable wallet
8
+ * @param accountAddress Stellar address of the account that is registering
9
+ * @param deviceAddress Stellar address of the device that is added as a primary signer. It will
10
+ * replace the master key of [accountAddress]
11
+ * @param accountThreshold Low, medium, and high thresholds to set on the account
12
+ * @param accountIdentity A list of account identities to be registered with the recovery servers
13
+ * @param signerWeight Signer weight of the device and recovery keys to set
14
+ * @param sponsorAddress optional Stellar address of the account sponsoring this transaction
15
+ */
16
+ export type RecoverableWalletConfig = {
17
+ accountAddress: AccountKeypair;
18
+ deviceAddress: AccountKeypair;
19
+ accountThreshold: AccountThreshold;
20
+ accountIdentity: RecoveryIdentityMap;
21
+ signerWeight: SignerWeight;
22
+ sponsorAddress?: AccountKeypair;
23
+ builderExtra?: (builder: CommonBuilder) => CommonBuilder;
24
+ };
25
+ export type RecoverableWallet = {
26
+ transaction: Transaction;
27
+ signers: string[];
28
+ };
29
+ export type AccountSigner = {
30
+ address: AccountKeypair;
31
+ weight: number;
32
+ };
33
+ /**
34
+ * Account weights threshold
35
+ * @param low Low threshold weight
36
+ * @param medium Medium threshold weight
37
+ * @param high High threshold weight
38
+ */
39
+ export type AccountThreshold = {
40
+ low: number;
41
+ medium: number;
42
+ high: number;
43
+ };
44
+ export type SignerWeight = {
45
+ device: number;
46
+ recoveryServer: number;
47
+ };
48
+ /**
49
+ * Recovery server configuration
50
+ * @property {string} endpoint - Main endpoint (root domain) of SEP-30 recovery server. E.g. `https://testanchor.stellar.org`
51
+ * @property {string} authEndpoint - SEP-10 auth endpoint to be used. Should be in the format `<https://domain/auth>`. E.g. `https://testanchor.stellar.org/auth`
52
+ * @property {string} homeDomain - SEP-10 home domain. E.g. `testanchor.stellar.org`
53
+ * @property {WalletSigner} [walletSigner] - WalletSigner used to sign authentication
54
+ */
55
+ export type RecoveryServer = {
56
+ endpoint: string;
57
+ authEndpoint: string;
58
+ homeDomain: string;
59
+ walletSigner?: WalletSigner;
60
+ clientDomain?: string;
61
+ };
62
+ export type RecoveryServerKey = string;
63
+ export type RecoveryServerSigning = {
64
+ signerAddress: string;
65
+ authToken: AuthToken;
66
+ };
67
+ export type RecoveryServerSigningMap = {
68
+ [key: RecoveryServerKey]: RecoveryServerSigning;
69
+ };
70
+ export type RecoveryServerMap = {
71
+ [key: RecoveryServerKey]: RecoveryServer;
72
+ };
73
+ export type RecoveryAuthMap = {
74
+ [key: RecoveryServerKey]: AuthToken;
75
+ };
76
+ /**
77
+ * The role of the identity. This value is not used by the server and is stored and echoed back in
78
+ * responses as a way for a client to know conceptually who each identity represents
79
+ */
80
+ export declare enum RecoveryRole {
81
+ OWNER = "owner",
82
+ SENDER = "sender",
83
+ RECEIVER = "receiver"
84
+ }
85
+ export declare enum RecoveryType {
86
+ STELLAR_ADDRESS = "stellar_address",
87
+ PHONE_NUMBER = "phone_number",
88
+ EMAIL = "email"
89
+ }
90
+ export type RecoveryAccountAuthMethod = {
91
+ type: RecoveryType;
92
+ value: string;
93
+ };
94
+ export type RecoveryAccountIdentity = {
95
+ role: RecoveryRole;
96
+ authMethods: RecoveryAccountAuthMethod[];
97
+ };
98
+ export type RecoveryIdentityMap = {
99
+ [key: RecoveryServerKey]: RecoveryAccountIdentity[];
100
+ };
101
+ export type RecoveryAccountRole = {
102
+ role: RecoveryRole;
103
+ authenticated?: boolean;
104
+ };
105
+ export type RecoveryAccountSigner = {
106
+ key: string;
107
+ };
108
+ export type RecoveryAccount = {
109
+ address: string;
110
+ identities: RecoveryAccountRole[];
111
+ signers: RecoveryAccountSigner[];
112
+ };
113
+ export type RecoverableIdentity = {
114
+ role: string;
115
+ authenticated?: boolean;
116
+ };
117
+ export type RecoverableSigner = {
118
+ key: PublicKeypair;
119
+ addedAt?: Date;
120
+ };
121
+ export type RecoverableAccountInfo = {
122
+ address: PublicKeypair;
123
+ identities: RecoverableIdentity[];
124
+ signers: RecoverableSigner[];
125
+ };
126
+ export type RecoveryAccountInfoMap = {
127
+ [key: RecoveryServerKey]: RecoverableAccountInfo;
128
+ };
@@ -0,0 +1,57 @@
1
+ export type CustomerInfoMap = {
2
+ [key: string]: string;
3
+ };
4
+ export declare enum Sep12Status {
5
+ ACCEPTED = "ACCEPTED",
6
+ PROCESSING = "PROCESSING",
7
+ NEEDS_INFO = "NEEDS_INFO",
8
+ REJECTED = "REJECTED",
9
+ VERIFICATION_REQUIRED = "VERIFICATION_REQUIRED"
10
+ }
11
+ export declare enum Sep12Type {
12
+ string = "string",
13
+ binary = "binary",
14
+ number = "number",
15
+ date = "date"
16
+ }
17
+ export type Field = {
18
+ type: Sep12Type;
19
+ description: string;
20
+ choices?: Array<string>;
21
+ optional?: boolean;
22
+ };
23
+ export type ProvidedField = {
24
+ type: Sep12Type;
25
+ description: string;
26
+ choices?: Array<string>;
27
+ optional?: boolean;
28
+ status?: Sep12Status;
29
+ error?: string;
30
+ };
31
+ export type GetCustomerParams = {
32
+ id?: string;
33
+ type?: string;
34
+ memo?: string;
35
+ lang?: string;
36
+ };
37
+ export type GetCustomerResponse = {
38
+ id?: string;
39
+ status: Sep12Status;
40
+ fields?: {
41
+ [key: string]: Field;
42
+ };
43
+ provided_fields?: {
44
+ [key: string]: ProvidedField;
45
+ };
46
+ message?: string;
47
+ };
48
+ export type AddCustomerParams = {
49
+ sep9Info?: CustomerInfoMap;
50
+ sep9BinaryInfo?: CustomerInfoMap;
51
+ id?: string;
52
+ memo?: string;
53
+ type?: string;
54
+ };
55
+ export type AddCustomerResponse = {
56
+ id: string;
57
+ };
@@ -0,0 +1,93 @@
1
+ import { AxiosInstance } from "axios";
2
+ import { Anchor } from "../Anchor";
3
+ import { AuthToken } from "./auth";
4
+ export interface Sep38Info {
5
+ assets: Array<Sep38AssetInfo>;
6
+ }
7
+ export interface Sep38AssetInfo {
8
+ asset: string;
9
+ sell_delivery_methods?: Array<Sep38DeliveryMethod>;
10
+ buy_delivery_methods?: Array<Sep38DeliveryMethod>;
11
+ country_codes?: Array<string>;
12
+ }
13
+ export interface Sep38DeliveryMethod {
14
+ name: string;
15
+ description: string;
16
+ }
17
+ export type Sep38Params = {
18
+ anchor: Anchor;
19
+ httpClient: AxiosInstance;
20
+ authToken?: AuthToken;
21
+ };
22
+ export interface Sep38PricesParams {
23
+ sellAsset: string;
24
+ sellAmount: string;
25
+ sellDeliveryMethod?: string;
26
+ buyDeliveryMethod?: string;
27
+ countryCode?: string;
28
+ }
29
+ export interface Sep38PricesResponse {
30
+ buy_assets: Array<Sep38BuyAsset>;
31
+ }
32
+ export interface Sep38BuyAsset {
33
+ asset: string;
34
+ price: string;
35
+ decimals: number;
36
+ }
37
+ export interface Sep38PriceParams {
38
+ sellAsset: string;
39
+ buyAsset: string;
40
+ sellAmount?: string;
41
+ buyAmount?: string;
42
+ context: Sep38PriceContext;
43
+ sellDeliveryMethod?: string;
44
+ buyDeliveryMethod?: string;
45
+ countryCode?: string;
46
+ }
47
+ export declare enum Sep38PriceContext {
48
+ SEP6 = "sep6",
49
+ SEP24 = "sep24",
50
+ SEP31 = "sep31"
51
+ }
52
+ export interface Sep38PriceResponse {
53
+ total_price: string;
54
+ price: string;
55
+ sell_amount: string;
56
+ buy_amount: string;
57
+ fee: {
58
+ total: string;
59
+ asset: string;
60
+ details?: Array<Sep38FeeDetails>;
61
+ };
62
+ }
63
+ export interface Sep38FeeDetails {
64
+ name: string;
65
+ description?: string;
66
+ amount: string;
67
+ }
68
+ export interface Sep38PostQuoteParams {
69
+ sell_asset: string;
70
+ buy_asset: string;
71
+ sell_amount: string;
72
+ buy_amount: string;
73
+ context: Sep38PriceContext;
74
+ expire_after?: string;
75
+ sell_delivery_method?: string;
76
+ buy_delivery_method?: string;
77
+ country_code?: string;
78
+ }
79
+ export interface Sep38PostQuoteResponse {
80
+ id: string;
81
+ expires_at: string;
82
+ total_price: string;
83
+ price: string;
84
+ sell_asset: string;
85
+ sell_amount: string;
86
+ buy_asset: string;
87
+ buy_amount: string;
88
+ fee: {
89
+ total: string;
90
+ asset: string;
91
+ details?: Array<Sep38FeeDetails>;
92
+ };
93
+ }
@@ -0,0 +1,160 @@
1
+ import { AxiosInstance } from "axios";
2
+ import { Anchor } from "../Anchor";
3
+ export interface Sep6EndpointInfo {
4
+ enabled: boolean;
5
+ authentication_required?: boolean;
6
+ description?: string;
7
+ }
8
+ export interface Sep6DepositInfo {
9
+ enabled: boolean;
10
+ authentication_required?: boolean;
11
+ fee_fixed?: number;
12
+ fee_percent?: number;
13
+ min_amount?: number;
14
+ max_amount?: number;
15
+ fields?: {
16
+ [key: string]: {
17
+ description: string;
18
+ optional?: boolean;
19
+ choices?: string[];
20
+ };
21
+ };
22
+ }
23
+ export interface Sep6WithdrawInfo {
24
+ enabled: boolean;
25
+ authentication_required?: boolean;
26
+ fee_fixed?: number;
27
+ fee_percent?: number;
28
+ min_amount?: number;
29
+ max_amount?: number;
30
+ types?: {
31
+ [key: string]: {
32
+ fields?: {
33
+ [key: string]: {
34
+ description: string;
35
+ optional?: boolean;
36
+ choices?: string[];
37
+ };
38
+ };
39
+ };
40
+ };
41
+ }
42
+ export interface Sep6Info {
43
+ deposit: {
44
+ [key: string]: Sep6DepositInfo;
45
+ };
46
+ "deposit-exchange": {
47
+ [key: string]: Sep6DepositInfo;
48
+ };
49
+ withdraw: {
50
+ [key: string]: Sep6WithdrawInfo;
51
+ };
52
+ "withdraw-exchange": {
53
+ [key: string]: Sep6WithdrawInfo;
54
+ };
55
+ fee: {
56
+ enabled: boolean;
57
+ description: string;
58
+ };
59
+ transactions: Sep6EndpointInfo;
60
+ transaction: Sep6EndpointInfo;
61
+ features: {
62
+ account_creation: boolean;
63
+ claimable_balances: boolean;
64
+ };
65
+ }
66
+ export type Sep6Params = {
67
+ anchor: Anchor;
68
+ httpClient: AxiosInstance;
69
+ };
70
+ export interface Sep6DepositParams {
71
+ asset_code: string;
72
+ account: string;
73
+ memo_type?: string;
74
+ memo?: string;
75
+ email_address?: string;
76
+ type?: string;
77
+ lang?: string;
78
+ on_change_callback?: string;
79
+ amount?: string;
80
+ country_code?: string;
81
+ claimable_balance_supported?: string;
82
+ customer_id?: string;
83
+ }
84
+ export interface Sep6WithdrawParams {
85
+ asset_code: string;
86
+ type: string;
87
+ dest?: string;
88
+ dest_extra?: string;
89
+ account?: string;
90
+ memo?: string;
91
+ lang?: string;
92
+ on_change_callback?: string;
93
+ amount?: string;
94
+ country_code?: string;
95
+ refund_memo?: string;
96
+ refund_memo_type?: string;
97
+ customer_id?: string;
98
+ }
99
+ export type Sep6DepositResponse = Sep6DepositSuccess | Sep6MissingKYC | Sep6Pending;
100
+ export interface Sep6DepositSuccess {
101
+ how?: string;
102
+ instructions?: {
103
+ [key: string]: {
104
+ value: string;
105
+ description: string;
106
+ };
107
+ };
108
+ id?: string;
109
+ eta?: number;
110
+ min_amoun?: number;
111
+ max_amount?: number;
112
+ fee_fixed?: number;
113
+ fee_percent?: number;
114
+ extra_info?: {
115
+ message?: string;
116
+ };
117
+ }
118
+ export interface Sep6MissingKYC {
119
+ type: string;
120
+ fields: Array<string>;
121
+ }
122
+ export interface Sep6Pending {
123
+ type: string;
124
+ status: string;
125
+ more_info_url?: string;
126
+ eta?: number;
127
+ }
128
+ export type Sep6WithdrawResponse = Sep6WithdrawSuccess | Sep6MissingKYC | Sep6Pending;
129
+ export interface Sep6WithdrawSuccess {
130
+ account_id?: string;
131
+ memo_type?: string;
132
+ memo?: string;
133
+ id?: string;
134
+ eta?: number;
135
+ min_amount?: number;
136
+ max_amount?: number;
137
+ fee_fixed?: number;
138
+ fee_percent?: number;
139
+ extra_info?: {
140
+ message?: string;
141
+ };
142
+ }
143
+ export interface Sep6ExchangeParams {
144
+ destination_asset: string;
145
+ source_asset: string;
146
+ amount: string;
147
+ account?: string;
148
+ quote_id?: string;
149
+ memo_type?: string;
150
+ memo?: string;
151
+ email_address?: string;
152
+ type?: string;
153
+ lang?: string;
154
+ on_change_callback?: string;
155
+ country_code?: string;
156
+ claimable_balance_supported?: string;
157
+ customer_id?: string;
158
+ refund_memo?: string;
159
+ refund_memo_type?: string;
160
+ }
@@ -1,6 +1,7 @@
1
1
  import { AnchorTransaction } from "./anchor";
2
+ import { AuthToken } from "./auth";
2
3
  export type WatchTransactionsParams = {
3
- authToken: string;
4
+ authToken: AuthToken;
4
5
  assetCode: string;
5
6
  onMessage: (transaction: AnchorTransaction) => void;
6
7
  onError: (error: AnchorTransaction | Error) => void;
@@ -12,7 +13,7 @@ export type WatchTransactionsParams = {
12
13
  noOlderThan?: string;
13
14
  };
14
15
  export type WatchTransactionParams = {
15
- authToken: string;
16
+ authToken: AuthToken;
16
17
  assetCode: string;
17
18
  id: string;
18
19
  onMessage: (transaction: AnchorTransaction) => void;
@@ -28,3 +29,7 @@ export interface WatcherResponse {
28
29
  refresh: WatcherRefreshFunction;
29
30
  stop: WatcherStopFunction;
30
31
  }
32
+ export declare enum WatcherSepType {
33
+ SEP6 = "SEP6",
34
+ SEP24 = "SEP24"
35
+ }
@@ -0,0 +1,2 @@
1
+ import { AxiosErrorData } from "../Types";
2
+ export declare const extractAxiosErrorData: (error: Error) => AxiosErrorData;
@@ -1,3 +1,4 @@
1
1
  export * from "./camelToSnakeCase";
2
2
  export * from "./toml";
3
3
  export * from "./url";
4
+ export * from "./extractAxiosErrorData";
@@ -1,3 +1,3 @@
1
- import { StellarTomlResolver } from "stellar-sdk";
1
+ import { StellarToml } from "stellar-sdk";
2
2
  import { TomlInfo } from "../Types";
3
- export declare const parseToml: (toml: StellarTomlResolver.StellarToml) => TomlInfo;
3
+ export declare const parseToml: (toml: StellarToml.Api.StellarToml) => TomlInfo;
@@ -0,0 +1,8 @@
1
+ import { AxiosInstance } from "axios";
2
+ import { AuthToken } from "../Types";
3
+ export declare const _getTransactionsForAsset: <T>(authToken: AuthToken, params: {
4
+ [key: string]: string | number;
5
+ }, endpoint: string, client: AxiosInstance) => Promise<T[]>;
6
+ export declare const _getTransactionBy: <T>(authToken: AuthToken, params: {
7
+ [key: string]: string | number;
8
+ }, endpoint: string, client: AxiosInstance) => Promise<T>;