@stellar/typescript-wallet-sdk 1.1.0-alpha.2 → 1.1.1

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 (90) hide show
  1. package/.husky/pre-commit +4 -0
  2. package/docs/WalletGuide.md +5 -0
  3. package/lib/bundle.js +15519 -18948
  4. package/lib/bundle.js.map +1 -1
  5. package/lib/bundle_browser.js +89069 -0
  6. package/lib/bundle_browser.js.map +1 -0
  7. package/lib/index.d.ts +26 -7
  8. package/lib/walletSdk/Anchor/Sep24.d.ts +48 -0
  9. package/lib/walletSdk/Anchor/index.d.ts +24 -0
  10. package/lib/walletSdk/Asset/index.d.ts +27 -0
  11. package/lib/walletSdk/Auth/WalletSigner.d.ts +7 -0
  12. package/lib/walletSdk/Auth/index.d.ts +21 -0
  13. package/lib/walletSdk/Exceptions/index.d.ts +56 -0
  14. package/lib/walletSdk/{horizon → Horizon}/Account.d.ts +3 -6
  15. package/lib/walletSdk/Horizon/AccountService.d.ts +53 -0
  16. package/lib/walletSdk/Horizon/Stellar.d.ts +16 -0
  17. package/lib/walletSdk/Horizon/Transaction/TransactionBuilder.d.ts +20 -0
  18. package/lib/walletSdk/Horizon/index.d.ts +4 -0
  19. package/lib/walletSdk/Recovery/index.d.ts +18 -0
  20. package/lib/walletSdk/{Watcher/Types.d.ts → Types/anchor.d.ts} +89 -6
  21. package/lib/walletSdk/Types/auth.d.ts +35 -0
  22. package/lib/walletSdk/Types/horizon.d.ts +34 -0
  23. package/lib/walletSdk/Types/index.d.ts +30 -0
  24. package/lib/walletSdk/Types/sep24.d.ts +30 -0
  25. package/lib/walletSdk/{toml/index.d.ts → Types/utils.d.ts} +4 -5
  26. package/lib/walletSdk/Types/watcher.d.ts +30 -0
  27. package/lib/walletSdk/{util → Utils}/camelToSnakeCase.d.ts +1 -1
  28. package/lib/walletSdk/Utils/getResultCode.d.ts +1 -0
  29. package/lib/walletSdk/Utils/index.d.ts +3 -0
  30. package/lib/walletSdk/Utils/toml.d.ts +3 -0
  31. package/lib/walletSdk/Utils/url.d.ts +1 -0
  32. package/lib/walletSdk/Watcher/index.d.ts +21 -42
  33. package/lib/walletSdk/index.d.ts +17 -15
  34. package/package.json +12 -2
  35. package/prettier.config.js +1 -0
  36. package/src/index.ts +39 -17
  37. package/src/walletSdk/Anchor/Sep24.ts +267 -0
  38. package/src/walletSdk/Anchor/index.ts +32 -201
  39. package/src/walletSdk/Asset/index.ts +58 -0
  40. package/src/walletSdk/Auth/WalletSigner.ts +23 -12
  41. package/src/walletSdk/Auth/index.ts +96 -49
  42. package/src/walletSdk/Exceptions/index.ts +148 -0
  43. package/src/walletSdk/{horizon → Horizon}/Account.ts +7 -9
  44. package/src/walletSdk/Horizon/AccountService.ts +96 -0
  45. package/src/walletSdk/Horizon/Stellar.ts +164 -0
  46. package/src/walletSdk/Horizon/Transaction/TransactionBuilder.ts +140 -0
  47. package/src/walletSdk/Horizon/index.ts +4 -0
  48. package/src/walletSdk/Recovery/index.ts +32 -0
  49. package/src/walletSdk/{Watcher/Types.ts → Types/anchor.ts} +114 -21
  50. package/src/walletSdk/Types/auth.ts +43 -0
  51. package/src/walletSdk/Types/horizon.ts +40 -0
  52. package/src/walletSdk/Types/index.ts +39 -0
  53. package/src/walletSdk/Types/sep24.ts +41 -0
  54. package/src/walletSdk/Types/utils.ts +77 -0
  55. package/src/walletSdk/Types/watcher.ts +34 -0
  56. package/src/walletSdk/Utils/camelToSnakeCase.ts +16 -0
  57. package/src/walletSdk/Utils/getResultCode.ts +5 -0
  58. package/src/walletSdk/Utils/index.ts +3 -0
  59. package/src/walletSdk/Utils/toml.ts +103 -0
  60. package/src/walletSdk/{util → Utils}/url.ts +1 -1
  61. package/src/walletSdk/Watcher/index.ts +137 -128
  62. package/src/walletSdk/index.ts +72 -55
  63. package/test/account.test.ts +19 -15
  64. package/test/accountService.test.ts +109 -0
  65. package/test/fixtures/TransactionsResponse.ts +144 -127
  66. package/test/stellar.test.ts +247 -0
  67. package/test/wallet.test.ts +196 -214
  68. package/tsconfig.json +3 -7
  69. package/webpack.config.js +7 -4
  70. package/lib/walletSdk/anchor/Types.d.ts +0 -75
  71. package/lib/walletSdk/anchor/index.d.ts +0 -87
  72. package/lib/walletSdk/auth/WalletSigner.d.ts +0 -6
  73. package/lib/walletSdk/auth/index.d.ts +0 -12
  74. package/lib/walletSdk/exception/index.d.ts +0 -21
  75. package/lib/walletSdk/horizon/AccountService.d.ts +0 -8
  76. package/lib/walletSdk/horizon/Stellar.d.ts +0 -7
  77. package/lib/walletSdk/horizon/constants.d.ts +0 -4
  78. package/lib/walletSdk/interactive/index.d.ts +0 -38
  79. package/lib/walletSdk/recovery/Recovery.d.ts +0 -3
  80. package/lib/walletSdk/util/sleep.d.ts +0 -1
  81. package/lib/walletSdk/util/url.d.ts +0 -1
  82. package/src/walletSdk/Anchor/Types.ts +0 -83
  83. package/src/walletSdk/exception/index.ts +0 -48
  84. package/src/walletSdk/horizon/AccountService.ts +0 -19
  85. package/src/walletSdk/horizon/Stellar.ts +0 -14
  86. package/src/walletSdk/horizon/constants.ts +0 -4
  87. package/src/walletSdk/interactive/index.ts +0 -105
  88. package/src/walletSdk/recovery/Recovery.ts +0 -6
  89. package/src/walletSdk/toml/index.ts +0 -179
  90. package/src/walletSdk/util/camelToSnakeCase.ts +0 -13
package/lib/index.d.ts CHANGED
@@ -1,12 +1,31 @@
1
- import * as walletSdk from "./walletSdk";
2
- import { Keypair } from "stellar-sdk";
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";
3
10
  export { Anchor } from "./walletSdk/Anchor";
4
- export * as AnchorTypes from "./walletSdk/Anchor/Types";
5
- export * as Exception from "./walletSdk/exception";
6
- export { Interactive, InteractiveResponse, InteractiveResponseType } from "./walletSdk/interactive";
7
- export { TomlInfo, parseToml } from "./walletSdk/toml";
11
+ export { Sep24 } from "./walletSdk/Anchor/Sep24";
12
+ export { IssuedAssetId, NativeAssetId, FiatAssetId } from "./walletSdk/Asset";
13
+ export { Sep10, WalletSigner, DefaultSigner } from "./walletSdk/Auth";
14
+ export { PublicKeypair, SigningKeypair, AccountService, Stellar, TransactionBuilder, } from "./walletSdk/Horizon";
15
+ export { Recovery } from "./walletSdk/Recovery";
8
16
  export { Watcher } from "./walletSdk/Watcher";
9
- export * as WatcherTypes from "./walletSdk/Watcher/Types";
17
+ /**
18
+ * Utils
19
+ */
20
+ import * as Utils from "./walletSdk/Utils";
21
+ export { Utils };
22
+ /**
23
+ * Exceptions
24
+ */
25
+ import * as Exceptions from "./walletSdk/Exceptions";
26
+ export { Exceptions };
27
+ import * as walletSdk from "./walletSdk";
28
+ import { Keypair } from "stellar-sdk";
10
29
  export { walletSdk, Keypair };
11
30
  declare const _default: {
12
31
  walletSdk: typeof walletSdk;
@@ -0,0 +1,48 @@
1
+ import { AxiosInstance } from "axios";
2
+ import { Anchor } from "../Anchor";
3
+ import { Sep24PostParams, Sep24PostResponse, AnchorTransaction, GetTransactionParams, GetTransactionsParams, AnchorServiceInfo } from "../Types";
4
+ import { Watcher } from "../Watcher";
5
+ type Sep24Params = {
6
+ anchor: Anchor;
7
+ httpClient: AxiosInstance;
8
+ };
9
+ export declare class Sep24 {
10
+ private anchor;
11
+ private httpClient;
12
+ constructor(params: Sep24Params);
13
+ deposit({ assetCode, authToken, lang, extraFields, destinationMemo, destinationAccount, }: Sep24PostParams): Promise<Sep24PostResponse>;
14
+ withdraw({ assetCode, authToken, lang, extraFields, withdrawalAccount, }: Sep24PostParams): Promise<Sep24PostResponse>;
15
+ private flow;
16
+ getServicesInfo(): Promise<AnchorServiceInfo>;
17
+ watcher(): Watcher;
18
+ /**
19
+ * Get single transaction's current status and details. One of the [id], [stellarTransactionId],
20
+ * [externalTransactionId] must be provided.
21
+ *
22
+ * @param authToken auth token of the account authenticated with the anchor
23
+ * @param id transaction ID
24
+ * @param stellarTransactionId stellar transaction ID
25
+ * @param externalTransactionId external transaction ID
26
+ * @return transaction object
27
+ * @throws [MissingTransactionIdError] if none of the id params is provided
28
+ * @throws [InvalidTransactionResponseError] if Anchor returns an invalid transaction
29
+ * @throws [ServerRequestFailedError] if server request fails
30
+ */
31
+ getTransactionBy({ authToken, id, stellarTransactionId, externalTransactionId, lang, }: GetTransactionParams): Promise<AnchorTransaction>;
32
+ /**
33
+ * Get account's transactions specified by asset and other params.
34
+ *
35
+ * @param authToken auth token of the account authenticated with the anchor
36
+ * @param assetCode target asset to query for
37
+ * @param noOlderThan response should contain transactions starting on or after this date & time
38
+ * @param limit response should contain at most 'limit' transactions
39
+ * @param kind kind of transaction that is desired. E.g.: 'deposit', 'withdrawal'
40
+ * @param pagingId response should contain transactions starting prior to this ID (exclusive)
41
+ * @param lang desired language (localization), it can also accept locale in the format 'en-US'
42
+ * @return list of transactions as requested by the client, sorted in time-descending order
43
+ * @throws [InvalidTransactionsResponseError] if Anchor returns an invalid response
44
+ * @throws [ServerRequestFailedError] if server request fails
45
+ */
46
+ getTransactionsForAsset({ authToken, assetCode, noOlderThan, limit, kind, pagingId, lang, }: GetTransactionsParams): Promise<AnchorTransaction[]>;
47
+ }
48
+ export {};
@@ -0,0 +1,24 @@
1
+ import { AxiosInstance } from "axios";
2
+ import { Config } from "walletSdk";
3
+ import { Sep10 } from "../Auth";
4
+ import { Sep24 } from "./Sep24";
5
+ import { AnchorServiceInfo, TomlInfo } from "../Types";
6
+ type AnchorParams = {
7
+ cfg: Config;
8
+ homeDomain: string;
9
+ httpClient: AxiosInstance;
10
+ language: string;
11
+ };
12
+ export declare class Anchor {
13
+ language: string;
14
+ private cfg;
15
+ private homeDomain;
16
+ private httpClient;
17
+ private toml;
18
+ constructor(params: AnchorParams);
19
+ sep1(shouldRefresh?: boolean): Promise<TomlInfo>;
20
+ sep10(): Promise<Sep10>;
21
+ sep24(): Sep24;
22
+ getServicesInfo(lang?: string): Promise<AnchorServiceInfo>;
23
+ }
24
+ export {};
@@ -0,0 +1,27 @@
1
+ declare class AssetId {
2
+ id: string;
3
+ scheme: string;
4
+ get sep38(): string;
5
+ }
6
+ export declare class StellarAssetId extends AssetId {
7
+ id: string;
8
+ code: string;
9
+ issuer: string;
10
+ scheme: string;
11
+ toAsset(): any;
12
+ }
13
+ export declare class IssuedAssetId extends StellarAssetId {
14
+ constructor(code: string, issuer: string);
15
+ toString(): string;
16
+ }
17
+ export declare class NativeAssetId extends StellarAssetId {
18
+ id: string;
19
+ code: string;
20
+ }
21
+ export declare class FiatAssetId extends AssetId {
22
+ id: string;
23
+ scheme: string;
24
+ constructor(code: string);
25
+ toString(): string;
26
+ }
27
+ export {};
@@ -0,0 +1,7 @@
1
+ import { Transaction } from "stellar-sdk";
2
+ import { SignWithClientAccountParams, SignWithDomainAccountParams } from "../Types";
3
+ export interface WalletSigner {
4
+ signWithClientAccount({ transaction, accountKp, }: SignWithClientAccountParams): Transaction;
5
+ signWithDomainAccount({ transactionXDR, networkPassphrase, accountKp, }: SignWithDomainAccountParams): Promise<Transaction>;
6
+ }
7
+ export declare const DefaultSigner: WalletSigner;
@@ -0,0 +1,21 @@
1
+ import { AxiosInstance } from "axios";
2
+ import { Config } from "walletSdk";
3
+ import { AuthenticateParams, AuthToken } from "../Types";
4
+ export { WalletSigner, DefaultSigner } from "./WalletSigner";
5
+ type Sep10Params = {
6
+ cfg: Config;
7
+ webAuthEndpoint: string;
8
+ homeDomain: string;
9
+ httpClient: AxiosInstance;
10
+ };
11
+ export declare class Sep10 {
12
+ private cfg;
13
+ private webAuthEndpoint;
14
+ private homeDomain;
15
+ private httpClient;
16
+ constructor(params: Sep10Params);
17
+ authenticate({ accountKp, walletSigner, memoId, clientDomain, }: AuthenticateParams): Promise<AuthToken>;
18
+ private challenge;
19
+ private sign;
20
+ private getToken;
21
+ }
@@ -0,0 +1,56 @@
1
+ import { Networks, Horizon } from "stellar-sdk";
2
+ import { AnchorTransaction, FLOW_TYPE } from "../Types";
3
+ export declare class ServerRequestFailedError extends Error {
4
+ constructor(e: Error);
5
+ }
6
+ export declare class AssetNotSupportedError extends Error {
7
+ constructor(type: FLOW_TYPE, assetCode: string);
8
+ }
9
+ export declare class InvalidMemoError extends Error {
10
+ constructor();
11
+ }
12
+ export declare class ClientDomainWithMemoError extends Error {
13
+ constructor();
14
+ }
15
+ export declare class MissingTransactionIdError extends Error {
16
+ constructor();
17
+ }
18
+ export declare class InvalidTransactionResponseError extends Error {
19
+ constructor(transactionResponse: AnchorTransaction);
20
+ }
21
+ export declare class InvalidTransactionsResponseError extends Error {
22
+ constructor(transactionsResponse: AnchorTransaction[]);
23
+ }
24
+ export declare class AccountDoesNotExistError extends Error {
25
+ constructor(network: Networks);
26
+ }
27
+ export declare class TransactionSubmitFailedError extends Error {
28
+ constructor(response: Horizon.SubmitTransactionResponse);
29
+ }
30
+ export declare class InsufficientStartingBalanceError extends Error {
31
+ constructor();
32
+ }
33
+ export declare class MissingTokenError extends Error {
34
+ constructor();
35
+ }
36
+ export declare class InvalidTokenError extends Error {
37
+ constructor();
38
+ }
39
+ export declare class ExpiredTokenError extends Error {
40
+ constructor(expiresAt: number);
41
+ }
42
+ export declare class TransactionSubmitWithFeeIncreaseFailedError extends Error {
43
+ constructor(maxFee: number, e: Error);
44
+ }
45
+ export declare class SignerRequiredError extends Error {
46
+ constructor();
47
+ }
48
+ export declare class OperationsLimitExceededError extends Error {
49
+ constructor(maxLimit: number);
50
+ }
51
+ export declare class WithdrawalTxNotPendingUserTransferStartError extends Error {
52
+ constructor(status: string);
53
+ }
54
+ export declare class WithdrawalTxMissingMemoError extends Error {
55
+ constructor();
56
+ }
@@ -1,20 +1,17 @@
1
1
  import { Keypair, Transaction, FeeBumpTransaction } from "stellar-sdk";
2
- declare class AccountKeypair {
2
+ export declare class AccountKeypair {
3
3
  keypair: Keypair;
4
4
  constructor(keypair: Keypair);
5
5
  get publicKey(): string;
6
6
  toString(): string;
7
7
  }
8
8
  export declare class PublicKeypair extends AccountKeypair {
9
- keypair: Keypair;
10
9
  constructor(keypair: Keypair);
11
- static fromPublicKey: (str: string) => PublicKeypair;
10
+ static fromPublicKey: (publicKey: string) => PublicKeypair;
12
11
  }
13
12
  export declare class SigningKeypair extends AccountKeypair {
14
- keypair: Keypair;
15
13
  constructor(keypair: Keypair);
16
- static fromSecret: (secret: string) => SigningKeypair;
14
+ static fromSecret: (secretKey: string) => SigningKeypair;
17
15
  get secretKey(): string;
18
16
  sign(transaction: Transaction | FeeBumpTransaction): Transaction | FeeBumpTransaction;
19
17
  }
20
- export {};
@@ -0,0 +1,53 @@
1
+ /// <reference types="node" />
2
+ import { Server, ServerApi } from "stellar-sdk";
3
+ import { Config } from "walletSdk";
4
+ import { SigningKeypair } from "./Account";
5
+ import { HORIZON_ORDER } from "../Types";
6
+ export declare class AccountService {
7
+ private server;
8
+ private network;
9
+ constructor(cfg: Config);
10
+ /**
11
+ * Generate new account keypair (public and secret key). This key pair can be
12
+ * used to create a Stellar account.
13
+ *
14
+ * @return public key and secret key
15
+ */
16
+ createKeypair(): SigningKeypair;
17
+ /**
18
+ * Generate new account keypair (public and secret key) from random bytes. This key pair can be
19
+ * used to create a Stellar account.
20
+ *
21
+ * @return public key and secret key
22
+ */
23
+ createKeypairFromRandom(randomBytes: Buffer): SigningKeypair;
24
+ /**
25
+ * Get account information from the Stellar network.
26
+ *
27
+ * @param accountAddress Stellar address of the account
28
+ * @param serverInstance optional Horizon server instance when default doesn't work
29
+ * @return account information
30
+ */
31
+ getInfo({ accountAddress, serverInstance, }: {
32
+ accountAddress: string;
33
+ serverInstance?: Server;
34
+ }): Promise<ServerApi.AccountRecord>;
35
+ /**
36
+ * Get account operations for the specified Stellar address.
37
+ *
38
+ * @param accountAddress Stellar address of the account
39
+ * @param limit optional how many operations to fetch, maximum is 200, default is 10
40
+ * @param order optional data order, ascending or descending, defaults to descending
41
+ * @param cursor optional cursor to specify a starting point
42
+ * @param includeFailed optional flag to include failed operations, defaults to false
43
+ * @return a list of operations
44
+ * @throws [OperationsLimitExceededException] when maximum limit of 200 is exceeded
45
+ */
46
+ getHistory({ accountAddress, limit, order, cursor, includeFailed, }: {
47
+ accountAddress: string;
48
+ limit?: number;
49
+ order?: HORIZON_ORDER;
50
+ cursor?: string;
51
+ includeFailed?: boolean;
52
+ }): Promise<ServerApi.CollectionPage<ServerApi.OperationRecord>>;
53
+ }
@@ -0,0 +1,16 @@
1
+ import { Server, Transaction, FeeBumpTransaction } from "stellar-sdk";
2
+ import { Config } from "walletSdk";
3
+ import { AccountService } from "./AccountService";
4
+ import { TransactionBuilder } from "./Transaction/TransactionBuilder";
5
+ import { TransactionParams, SubmitWithFeeIncreaseParams, FeeBumpTransactionParams } from "../Types";
6
+ export declare class Stellar {
7
+ private cfg;
8
+ server: Server;
9
+ constructor(cfg: Config);
10
+ account(): AccountService;
11
+ transaction({ sourceAddress, baseFee, memo, timebounds, }: TransactionParams): Promise<TransactionBuilder>;
12
+ makeFeeBump({ feeAddress, transaction, baseFee, }: FeeBumpTransactionParams): FeeBumpTransaction;
13
+ submitTransaction(signedTransaction: Transaction | FeeBumpTransaction): Promise<boolean>;
14
+ submitWithFeeIncrease({ sourceAddress, timeout, baseFeeIncrease, buildingFunction, signerFunction, baseFee, memo, maxFee, }: SubmitWithFeeIncreaseParams): Promise<Transaction>;
15
+ decodeTransaction(xdr: string): Transaction | FeeBumpTransaction;
16
+ }
@@ -0,0 +1,20 @@
1
+ import { Account as StellarAccount, Transaction, Server, Memo, xdr } from "stellar-sdk";
2
+ import { Config } from "walletSdk";
3
+ import { AccountKeypair } from "../Account";
4
+ import { IssuedAssetId, StellarAssetId } from "../../Asset";
5
+ import { WithdrawTransaction } from "../../Types";
6
+ export declare class TransactionBuilder {
7
+ private network;
8
+ private operations;
9
+ private builder;
10
+ sourceAccount: string;
11
+ constructor(cfg: Config, sourceAccount: StellarAccount, baseFee?: number, memo?: Memo, timebounds?: Server.Timebounds);
12
+ createAccount(newAccount: AccountKeypair, startingBalance?: number): TransactionBuilder;
13
+ transfer(destinationAddress: string, assetId: StellarAssetId, amount: string): TransactionBuilder;
14
+ addOperation(op: xdr.Operation): TransactionBuilder;
15
+ setMemo(memo: Memo): TransactionBuilder;
16
+ addAssetSupport(asset: IssuedAssetId, trustLimit?: string): TransactionBuilder;
17
+ removeAssetSupport(asset: IssuedAssetId): TransactionBuilder;
18
+ build(): Transaction;
19
+ transferWithdrawalTransaction(transaction: WithdrawTransaction, assetId: StellarAssetId): TransactionBuilder;
20
+ }
@@ -0,0 +1,4 @@
1
+ export { PublicKeypair, SigningKeypair } from "./Account";
2
+ export { AccountService } from "./AccountService";
3
+ export { Stellar } from "./Stellar";
4
+ export { TransactionBuilder } from "./Transaction/TransactionBuilder";
@@ -0,0 +1,18 @@
1
+ import { AxiosInstance } from "axios";
2
+ import { Server } from "stellar-sdk";
3
+ import { Config } from "walletSdk";
4
+ import { Stellar } from "../Horizon";
5
+ type RecoveryParams = {
6
+ cfg: Config;
7
+ stellar: Stellar;
8
+ httpClient: AxiosInstance;
9
+ servers: Server[];
10
+ };
11
+ export declare class Recovery {
12
+ private cfg;
13
+ private stellar;
14
+ private httpClient;
15
+ private servers;
16
+ constructor(params: RecoveryParams);
17
+ }
18
+ export {};
@@ -1,3 +1,92 @@
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
+ };
1
90
  export declare enum TransactionStatus {
2
91
  /**
3
92
  * There is not yet enough information for this transaction to be initiated. Perhaps the user has
@@ -57,9 +146,3 @@ export declare enum TransactionStatus {
57
146
  /** Catch-all for any error not enumerated above. */
58
147
  error = "error"
59
148
  }
60
- export type WatcherRefreshFunction = () => void;
61
- export type WatcherStopFunction = () => void;
62
- export interface WatcherResponse {
63
- refresh: WatcherRefreshFunction;
64
- stop: WatcherStopFunction;
65
- }
@@ -0,0 +1,35 @@
1
+ import { Transaction } from "stellar-sdk";
2
+ import { WalletSigner } from "../Auth/WalletSigner";
3
+ import { AccountKeypair } from "../Horizon/Account";
4
+ export type AuthenticateParams = {
5
+ accountKp: AccountKeypair;
6
+ walletSigner?: WalletSigner;
7
+ memoId?: string;
8
+ clientDomain?: string;
9
+ };
10
+ export type AuthToken = string;
11
+ export type ChallengeParams = {
12
+ accountKp: AccountKeypair;
13
+ memoId?: string;
14
+ clientDomain?: string;
15
+ };
16
+ export type XdrEncodedTransaction = string;
17
+ export type NetworkPassphrase = string;
18
+ export type ChallengeResponse = {
19
+ transaction: XdrEncodedTransaction;
20
+ network_passphrase: NetworkPassphrase;
21
+ };
22
+ export type SignParams = {
23
+ accountKp: AccountKeypair;
24
+ challengeResponse: ChallengeResponse;
25
+ walletSigner: WalletSigner;
26
+ };
27
+ export type SignWithClientAccountParams = {
28
+ transaction: Transaction;
29
+ accountKp: AccountKeypair;
30
+ };
31
+ export type SignWithDomainAccountParams = {
32
+ transactionXDR: XdrEncodedTransaction;
33
+ networkPassphrase: NetworkPassphrase;
34
+ accountKp: AccountKeypair;
35
+ };
@@ -0,0 +1,34 @@
1
+ import { Memo, Server, Transaction } from "stellar-sdk";
2
+ import { AccountKeypair } from "../Horizon/Account";
3
+ import { TransactionBuilder } from "../Horizon/Transaction/TransactionBuilder";
4
+ export declare enum NETWORK_URLS {
5
+ PUBLIC = "https://horizon.stellar.org",
6
+ TESTNET = "https://horizon-testnet.stellar.org"
7
+ }
8
+ export type TransactionParams = {
9
+ sourceAddress: AccountKeypair;
10
+ baseFee: number;
11
+ memo?: Memo;
12
+ timebounds?: Server.Timebounds | number;
13
+ };
14
+ export type FeeBumpTransactionParams = {
15
+ feeAddress: AccountKeypair;
16
+ transaction: Transaction;
17
+ baseFee?: number;
18
+ };
19
+ export type SubmitWithFeeIncreaseParams = {
20
+ sourceAddress: AccountKeypair;
21
+ timeout: number;
22
+ baseFeeIncrease: number;
23
+ buildingFunction: (TransactionBuilder: any) => TransactionBuilder;
24
+ signerFunction?: (Transaction: any) => Transaction;
25
+ baseFee?: number;
26
+ memo?: Memo;
27
+ maxFee?: number;
28
+ };
29
+ export declare const HORIZON_LIMIT_MAX = 200;
30
+ export declare const HORIZON_LIMIT_DEFAULT = 10;
31
+ export declare enum HORIZON_ORDER {
32
+ ASC = "asc",
33
+ DESC = "desc"
34
+ }
@@ -0,0 +1,30 @@
1
+ import { Server, Networks } from "stellar-sdk";
2
+ import { ApplicationConfiguration, StellarConfiguration } from "walletSdk";
3
+ export type WalletParams = {
4
+ stellarConfiguration: StellarConfiguration;
5
+ applicationConfiguration?: ApplicationConfiguration;
6
+ language?: string;
7
+ };
8
+ export type WalletAnchor = {
9
+ homeDomain: string;
10
+ language?: string;
11
+ };
12
+ export type WalletRecovery = {
13
+ servers: Server[];
14
+ };
15
+ export type ConfigParams = {
16
+ stellarConfiguration: StellarConfiguration;
17
+ applicationConfiguration?: ApplicationConfiguration;
18
+ };
19
+ export type StellarConfigurationParams = {
20
+ network: Networks;
21
+ horizonUrl: string;
22
+ baseFee?: number;
23
+ defaultTimeout?: number;
24
+ };
25
+ export * from "./anchor";
26
+ export * from "./auth";
27
+ export * from "./horizon";
28
+ export * from "./sep24";
29
+ export * from "./utils";
30
+ export * from "./watcher";
@@ -0,0 +1,30 @@
1
+ import { Memo } from "stellar-sdk";
2
+ import { AuthToken } from "./auth";
3
+ export declare enum FLOW_TYPE {
4
+ DEPOSIT = "deposit",
5
+ WITHDRAW = "withdraw"
6
+ }
7
+ export type ExtraFields = {
8
+ [api_key: string]: string;
9
+ };
10
+ export type Sep24PostParams = {
11
+ authToken: AuthToken;
12
+ assetCode: string;
13
+ lang?: string;
14
+ extraFields?: ExtraFields;
15
+ destinationMemo?: Memo;
16
+ destinationAccount?: string;
17
+ withdrawalAccount?: string;
18
+ account?: string;
19
+ };
20
+ export declare enum Sep24ResponseType {
21
+ authentication_required = "authentication_required",
22
+ interactive_customer_info_needed = "interactive_customer_info_needed",
23
+ error = "error"
24
+ }
25
+ export interface Sep24PostResponse {
26
+ type: Sep24ResponseType.authentication_required | Sep24ResponseType.interactive_customer_info_needed | Sep24ResponseType.error;
27
+ id?: string;
28
+ url?: string;
29
+ error?: string;
30
+ }
@@ -47,13 +47,13 @@ export type TomlInfo = {
47
47
  codeTemplate: string;
48
48
  issuer: string;
49
49
  status: string;
50
- displayDecimals: string;
50
+ displayDecimals: number;
51
51
  name: string;
52
52
  desc: string;
53
53
  conditions: string;
54
54
  image: string;
55
- fixedNumber: string;
56
- maxNumber: string;
55
+ fixedNumber: number;
56
+ maxNumber: number;
57
57
  isUnlimited: boolean;
58
58
  isAssetAnchored: boolean;
59
59
  anchorAssetType: string;
@@ -63,7 +63,7 @@ export type TomlInfo = {
63
63
  collateralAddresses: Array<string>;
64
64
  collateralAddressMessages: Array<string>;
65
65
  collateralAddressSignatures: Array<string>;
66
- regulated: string;
66
+ regulated: boolean;
67
67
  approvalServer: string;
68
68
  approvalCriteria: string;
69
69
  }>;
@@ -75,4 +75,3 @@ export type TomlInfo = {
75
75
  history: string;
76
76
  }>;
77
77
  };
78
- export declare const parseToml: (toml: any) => TomlInfo;
@@ -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
+ }
@@ -1,2 +1,2 @@
1
1
  export declare const camelToSnakeCaseKey: (key: string) => string;
2
- export declare const camelToSnakeCaseObject: (obj: any) => {};
2
+ export declare const camelToSnakeCaseObject: (obj: any) => any;