@stellar/typescript-wallet-sdk 1.0.0-alpha.2 → 1.1.0-alpha.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.
- package/lib/bundle.js +1541 -80
- package/lib/bundle.js.map +1 -1
- package/lib/walletSdk/Watcher/Types.d.ts +65 -0
- package/lib/walletSdk/Watcher/index.d.ts +54 -0
- package/lib/walletSdk/anchor/Types.d.ts +76 -0
- package/lib/walletSdk/anchor/index.d.ts +78 -7
- package/lib/walletSdk/auth/WalletSigner.d.ts +3 -0
- package/lib/walletSdk/auth/index.d.ts +8 -5
- package/lib/walletSdk/exception/index.d.ts +9 -0
- package/lib/walletSdk/horizon/Account.d.ts +20 -0
- package/lib/walletSdk/horizon/AccountService.d.ts +8 -0
- package/lib/walletSdk/horizon/Stellar.d.ts +5 -1
- package/lib/walletSdk/index.d.ts +12 -13
- package/lib/walletSdk/interactive/index.d.ts +16 -5
- package/lib/walletSdk/util/camelToSnakeCase.d.ts +2 -0
- package/lib/walletSdk/util/sleep.d.ts +1 -0
- package/package.json +12 -6
- package/src/walletSdk/Anchor/Types.ts +79 -0
- package/src/walletSdk/Anchor/index.ts +224 -24
- package/src/walletSdk/Auth/WalletSigner.ts +18 -3
- package/src/walletSdk/Auth/index.ts +41 -15
- package/src/walletSdk/Watcher/Types.ts +81 -0
- package/src/walletSdk/Watcher/index.ts +355 -0
- package/src/walletSdk/exception/index.ts +23 -2
- package/src/walletSdk/horizon/Account.ts +52 -0
- package/src/walletSdk/horizon/AccountService.ts +19 -0
- package/src/walletSdk/horizon/Stellar.ts +10 -2
- package/src/walletSdk/index.ts +41 -28
- package/src/walletSdk/interactive/index.ts +32 -43
- package/src/walletSdk/util/camelToSnakeCase.ts +13 -0
- package/test/account.test.ts +36 -0
- package/test/fixtures/TransactionsResponse.ts +230 -0
- package/test/wallet.test.ts +1722 -0
- package/test/index.test.ts +0 -73
|
@@ -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,54 @@
|
|
|
1
|
+
import { Anchor } from "walletSdk/Anchor";
|
|
2
|
+
import { 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(params: {
|
|
25
|
+
authToken: string;
|
|
26
|
+
assetCode: string;
|
|
27
|
+
onMessage: (transaction: any) => void;
|
|
28
|
+
onError: (error: any) => void;
|
|
29
|
+
watchlist?: string[];
|
|
30
|
+
timeout?: number;
|
|
31
|
+
isRetry?: boolean;
|
|
32
|
+
noOlderThan?: string;
|
|
33
|
+
kind?: string;
|
|
34
|
+
lang?: string;
|
|
35
|
+
}): WatcherResponse;
|
|
36
|
+
/**
|
|
37
|
+
* Watch a transaction until it stops pending. Takes three callbacks:
|
|
38
|
+
* * onMessage - When the transaction comes back as pending_ or incomplete.
|
|
39
|
+
* * onSuccess - When the transaction comes back as completed / refunded / expired.
|
|
40
|
+
* * onError - When there's a runtime error, or the transaction comes back as
|
|
41
|
+
* no_market / too_small / too_large / error.
|
|
42
|
+
*/
|
|
43
|
+
watchOneTransaction(params: {
|
|
44
|
+
authToken: string;
|
|
45
|
+
assetCode: string;
|
|
46
|
+
id: string;
|
|
47
|
+
onMessage: (transaction: any) => void;
|
|
48
|
+
onSuccess: (transaction: any) => void;
|
|
49
|
+
onError: (error: any) => void;
|
|
50
|
+
timeout?: number;
|
|
51
|
+
isRetry?: boolean;
|
|
52
|
+
lang?: string;
|
|
53
|
+
}): WatcherResponse;
|
|
54
|
+
}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { MemoType } from "stellar-sdk";
|
|
2
|
+
import { Optional } from "utility-types";
|
|
3
|
+
import { TransactionStatus } from "../Watcher/Types";
|
|
4
|
+
export interface AnchorServiceInfo {
|
|
5
|
+
deposit: {
|
|
6
|
+
[key: string]: AnchorServiceAsset;
|
|
7
|
+
};
|
|
8
|
+
withdraw: {
|
|
9
|
+
[key: string]: AnchorServiceAsset;
|
|
10
|
+
};
|
|
11
|
+
fee: {
|
|
12
|
+
enabled: boolean;
|
|
13
|
+
};
|
|
14
|
+
features: {
|
|
15
|
+
account_creation: boolean;
|
|
16
|
+
claimable_balances: boolean;
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
interface BaseTransaction {
|
|
20
|
+
id: string;
|
|
21
|
+
kind: string;
|
|
22
|
+
status: TransactionStatus;
|
|
23
|
+
more_info_url: string;
|
|
24
|
+
started_at: string;
|
|
25
|
+
message?: string;
|
|
26
|
+
}
|
|
27
|
+
interface ProcessingAnchorTransaction extends BaseTransaction {
|
|
28
|
+
status_eta?: number;
|
|
29
|
+
kyc_verified?: boolean;
|
|
30
|
+
amount_in_asset?: string;
|
|
31
|
+
amount_in: string;
|
|
32
|
+
amount_out_asset?: string;
|
|
33
|
+
amount_out: string;
|
|
34
|
+
amount_fee_asset?: string;
|
|
35
|
+
amount_fee: string;
|
|
36
|
+
completed_at?: string;
|
|
37
|
+
stellar_transaction_id?: string;
|
|
38
|
+
external_transaction_id?: string;
|
|
39
|
+
refunds?: Refunds;
|
|
40
|
+
}
|
|
41
|
+
export interface DepositTransaction extends ProcessingAnchorTransaction {
|
|
42
|
+
from?: string;
|
|
43
|
+
to?: string;
|
|
44
|
+
deposit_memo?: string;
|
|
45
|
+
deposit_memo_type?: MemoType;
|
|
46
|
+
claimable_balance_id?: string;
|
|
47
|
+
}
|
|
48
|
+
export interface WithdrawTransaction extends ProcessingAnchorTransaction {
|
|
49
|
+
from: string;
|
|
50
|
+
to?: string;
|
|
51
|
+
withdraw_memo?: string;
|
|
52
|
+
withdraw_memo_type: MemoType;
|
|
53
|
+
withdraw_anchor_account: string;
|
|
54
|
+
}
|
|
55
|
+
interface ErrorTransaction extends Optional<DepositTransaction & WithdrawTransaction> {
|
|
56
|
+
}
|
|
57
|
+
export type AnchorTransaction = DepositTransaction | WithdrawTransaction | ErrorTransaction;
|
|
58
|
+
interface Payment {
|
|
59
|
+
id: string;
|
|
60
|
+
id_type: string;
|
|
61
|
+
amount: string;
|
|
62
|
+
fee: string;
|
|
63
|
+
}
|
|
64
|
+
interface Refunds {
|
|
65
|
+
amount_refunded: string;
|
|
66
|
+
amount_fee: string;
|
|
67
|
+
payments: Payment[];
|
|
68
|
+
}
|
|
69
|
+
interface AnchorServiceAsset {
|
|
70
|
+
enabled: boolean;
|
|
71
|
+
min_amount: number;
|
|
72
|
+
max_amount: number;
|
|
73
|
+
fee_fixed: number;
|
|
74
|
+
fee_percent: number;
|
|
75
|
+
}
|
|
76
|
+
export {};
|
|
@@ -1,16 +1,87 @@
|
|
|
1
|
+
import { AxiosInstance } from "axios";
|
|
1
2
|
import { Auth } from "../Auth";
|
|
2
3
|
import { Interactive } from "../interactive";
|
|
3
4
|
import { TomlInfo } from "../toml";
|
|
5
|
+
import { Watcher } from "../Watcher";
|
|
6
|
+
import { Config } from "walletSdk";
|
|
7
|
+
import { AnchorTransaction, AnchorServiceInfo } from "./Types";
|
|
8
|
+
type GetTransactionsParams = {
|
|
9
|
+
authToken: string;
|
|
10
|
+
assetCode: string;
|
|
11
|
+
noOlderThan?: string;
|
|
12
|
+
limit?: number;
|
|
13
|
+
kind?: string;
|
|
14
|
+
pagingId?: string;
|
|
15
|
+
lang?: string;
|
|
16
|
+
};
|
|
4
17
|
export declare class Anchor {
|
|
18
|
+
language: string;
|
|
19
|
+
private cfg;
|
|
5
20
|
private homeDomain;
|
|
6
21
|
private httpClient;
|
|
7
|
-
private
|
|
8
|
-
constructor(cfg
|
|
9
|
-
|
|
22
|
+
private toml;
|
|
23
|
+
constructor({ cfg, homeDomain, httpClient, language, }: {
|
|
24
|
+
cfg: Config;
|
|
25
|
+
homeDomain: string;
|
|
26
|
+
httpClient: AxiosInstance;
|
|
27
|
+
language: string;
|
|
28
|
+
});
|
|
29
|
+
getInfo(shouldRefresh?: boolean): Promise<TomlInfo>;
|
|
10
30
|
auth(): Promise<Auth>;
|
|
11
31
|
interactive(): Interactive;
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
32
|
+
watcher(): Watcher;
|
|
33
|
+
getServicesInfo(lang?: string): Promise<AnchorServiceInfo>;
|
|
34
|
+
/**
|
|
35
|
+
* Get single transaction's current status and details. One of the [id], [stellarTransactionId],
|
|
36
|
+
* [externalTransactionId] must be provided.
|
|
37
|
+
*
|
|
38
|
+
* @param authToken auth token of the account authenticated with the anchor
|
|
39
|
+
* @param id transaction ID
|
|
40
|
+
* @param stellarTransactionId stellar transaction ID
|
|
41
|
+
* @param externalTransactionId external transaction ID
|
|
42
|
+
* @return transaction object
|
|
43
|
+
* @throws [MissingTransactionIdError] if none of the id params is provided
|
|
44
|
+
* @throws [InvalidTransactionResponseError] if Anchor returns an invalid transaction
|
|
45
|
+
* @throws [ServerRequestFailedError] if server request fails
|
|
46
|
+
*/
|
|
47
|
+
getTransactionBy({ authToken, id, stellarTransactionId, externalTransactionId, lang, }: {
|
|
48
|
+
authToken: string;
|
|
49
|
+
id?: string;
|
|
50
|
+
stellarTransactionId?: string;
|
|
51
|
+
externalTransactionId?: string;
|
|
52
|
+
lang?: string;
|
|
53
|
+
}): Promise<AnchorTransaction>;
|
|
54
|
+
/**
|
|
55
|
+
* Get account's transactions specified by asset and other params.
|
|
56
|
+
*
|
|
57
|
+
* @param authToken auth token of the account authenticated with the anchor
|
|
58
|
+
* @param assetCode target asset to query for
|
|
59
|
+
* @param noOlderThan response should contain transactions starting on or after this date & time
|
|
60
|
+
* @param limit response should contain at most 'limit' transactions
|
|
61
|
+
* @param kind kind of transaction that is desired. E.g.: 'deposit', 'withdrawal'
|
|
62
|
+
* @param pagingId response should contain transactions starting prior to this ID (exclusive)
|
|
63
|
+
* @param lang desired language (localization), it can also accept locale in the format 'en-US'
|
|
64
|
+
* @return list of transactions as requested by the client, sorted in time-descending order
|
|
65
|
+
* @throws [InvalidTransactionsResponseError] if Anchor returns an invalid response
|
|
66
|
+
* @throws [ServerRequestFailedError] if server request fails
|
|
67
|
+
*/
|
|
68
|
+
getTransactionsForAsset(params: GetTransactionsParams): Promise<AnchorTransaction[]>;
|
|
69
|
+
/**
|
|
70
|
+
* Get all successfully finished (either completed or refunded) account transactions for specified
|
|
71
|
+
* asset. Optional field implementation depends on anchor.
|
|
72
|
+
*
|
|
73
|
+
* @param authToken auth token of the account authenticated with the anchor
|
|
74
|
+
* @param assetCode target asset to query for
|
|
75
|
+
* @param noOlderThan response should contain transactions starting on or after this date & time
|
|
76
|
+
* @param limit response should contain at most 'limit' transactions
|
|
77
|
+
* @param kind kind of transaction that is desired. E.g.: 'deposit', 'withdrawal'
|
|
78
|
+
* @param pagingId response should contain transactions starting prior to this ID (exclusive)
|
|
79
|
+
* @param lang desired language (localization), it can also accept locale in the format 'en-US'
|
|
80
|
+
* @return list of filtered transactions that achieved a final state (completed or refunded)
|
|
81
|
+
* @throws [AssetNotSupportedError] if asset is not supported by the anchor
|
|
82
|
+
* @throws [InvalidTransactionsResponseError] if Anchor returns an invalid response
|
|
83
|
+
* @throws [ServerRequestFailedError] if server request fails
|
|
84
|
+
*/
|
|
85
|
+
getHistory(params: GetTransactionsParams): Promise<AnchorTransaction[]>;
|
|
16
86
|
}
|
|
87
|
+
export {};
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
import { Keypair, Transaction } from "stellar-sdk";
|
|
1
2
|
export interface WalletSigner {
|
|
3
|
+
signWithClientAccount(txn: Transaction, account: Keypair): Transaction;
|
|
4
|
+
signWithDomainAccount(transactionXDR: string, networkPassPhrase: string, account: Keypair): Transaction;
|
|
2
5
|
}
|
|
3
6
|
export declare const DefaultSigner: WalletSigner;
|
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
import { Keypair } from "stellar-sdk";
|
|
2
|
+
import { WalletSigner } from "./WalletSigner";
|
|
2
3
|
export declare class Auth {
|
|
4
|
+
private cfg;
|
|
3
5
|
private webAuthEndpoint;
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
6
|
+
private httpClient;
|
|
7
|
+
constructor(cfg: any, webAuthEndpoint: any, httpClient: any);
|
|
8
|
+
authenticate(accountKp: Keypair, walletSigner?: WalletSigner, memoId?: string, clientDomain?: string): Promise<any>;
|
|
9
|
+
private challenge;
|
|
10
|
+
private sign;
|
|
11
|
+
private getToken;
|
|
9
12
|
}
|
|
@@ -10,3 +10,12 @@ export declare class InvalidMemoError extends Error {
|
|
|
10
10
|
export declare class ClientDomainWithMemoError extends Error {
|
|
11
11
|
constructor();
|
|
12
12
|
}
|
|
13
|
+
export declare class MissingTransactionIdError extends Error {
|
|
14
|
+
constructor();
|
|
15
|
+
}
|
|
16
|
+
export declare class InvalidTransactionResponseError extends Error {
|
|
17
|
+
constructor(transactionResponse: any);
|
|
18
|
+
}
|
|
19
|
+
export declare class InvalidTransactionsResponseError extends Error {
|
|
20
|
+
constructor(transactionsResponse: any);
|
|
21
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { Keypair, Transaction, FeeBumpTransaction } from "stellar-sdk";
|
|
2
|
+
declare class AccountKeypair {
|
|
3
|
+
keypair: Keypair;
|
|
4
|
+
constructor(keypair: Keypair);
|
|
5
|
+
get publicKey(): string;
|
|
6
|
+
toString(): string;
|
|
7
|
+
}
|
|
8
|
+
export declare class PublicKeypair extends AccountKeypair {
|
|
9
|
+
keypair: Keypair;
|
|
10
|
+
constructor(keypair: Keypair);
|
|
11
|
+
static fromPublicKey: (str: string) => PublicKeypair;
|
|
12
|
+
}
|
|
13
|
+
export declare class SigningKeypair extends AccountKeypair {
|
|
14
|
+
keypair: Keypair;
|
|
15
|
+
constructor(keypair: Keypair);
|
|
16
|
+
static fromSecret: (secret: string) => SigningKeypair;
|
|
17
|
+
get secretKey(): string;
|
|
18
|
+
sign(transaction: Transaction | FeeBumpTransaction): Transaction | FeeBumpTransaction;
|
|
19
|
+
}
|
|
20
|
+
export {};
|
package/lib/walletSdk/index.d.ts
CHANGED
|
@@ -1,24 +1,24 @@
|
|
|
1
1
|
import { Networks, Server } from "stellar-sdk";
|
|
2
|
+
import { AxiosInstance, AxiosRequestConfig } from "axios";
|
|
2
3
|
import { Anchor } from "./Anchor";
|
|
3
4
|
import { WalletSigner } from "./Auth/WalletSigner";
|
|
4
5
|
import { Stellar } from "./horizon/Stellar";
|
|
5
6
|
import { Recovery } from "./recovery/Recovery";
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
declare class HttpClient {
|
|
7
|
+
export declare class Config {
|
|
8
|
+
app: ApplicationConfiguration;
|
|
9
|
+
stellar: StellarConfiguration;
|
|
10
|
+
constructor(stellarCfg: any, appCfg: any);
|
|
11
11
|
}
|
|
12
12
|
export declare class Wallet {
|
|
13
13
|
private cfg;
|
|
14
|
-
private
|
|
14
|
+
private language;
|
|
15
15
|
static TestNet: () => Wallet;
|
|
16
16
|
static MainNet: () => Wallet;
|
|
17
|
-
constructor(stellarConfiguration: StellarConfiguration, applicationConfiguration?: ApplicationConfiguration);
|
|
18
|
-
anchor(homeDomain: string, httpClientConfig?:
|
|
17
|
+
constructor(stellarConfiguration: StellarConfiguration, applicationConfiguration?: ApplicationConfiguration, language?: string);
|
|
18
|
+
anchor(homeDomain: string, httpClientConfig?: AxiosRequestConfig, language?: string): Anchor;
|
|
19
19
|
stellar(): Stellar;
|
|
20
|
-
recover(servers: any, httpClientConfig
|
|
21
|
-
getClient(httpClientConfig?:
|
|
20
|
+
recover(servers: any, httpClientConfig?: AxiosRequestConfig): Recovery;
|
|
21
|
+
getClient(httpClientConfig?: AxiosRequestConfig): AxiosInstance;
|
|
22
22
|
}
|
|
23
23
|
export declare class StellarConfiguration {
|
|
24
24
|
server: Server;
|
|
@@ -31,7 +31,6 @@ export declare class StellarConfiguration {
|
|
|
31
31
|
}
|
|
32
32
|
export declare class ApplicationConfiguration {
|
|
33
33
|
defaultSigner: WalletSigner;
|
|
34
|
-
defaultClient:
|
|
35
|
-
constructor(defaultSigner?: WalletSigner
|
|
34
|
+
defaultClient: AxiosInstance;
|
|
35
|
+
constructor(defaultSigner?: WalletSigner);
|
|
36
36
|
}
|
|
37
|
-
export {};
|
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
type ExtraFields = {
|
|
2
|
-
[
|
|
2
|
+
[api_key: string]: string;
|
|
3
|
+
};
|
|
4
|
+
type InteractiveParams = {
|
|
5
|
+
accountAddress: string;
|
|
6
|
+
assetCode: string;
|
|
7
|
+
authToken: string;
|
|
8
|
+
lang?: string;
|
|
9
|
+
extraFields?: ExtraFields;
|
|
10
|
+
fundsAccountAddress?: string;
|
|
3
11
|
};
|
|
4
12
|
export declare enum FLOW_TYPE {
|
|
5
13
|
DEPOSIT = "deposit",
|
|
@@ -8,9 +16,12 @@ export declare enum FLOW_TYPE {
|
|
|
8
16
|
export declare class Interactive {
|
|
9
17
|
private homeDomain;
|
|
10
18
|
private anchor;
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
19
|
+
private httpClient;
|
|
20
|
+
constructor(homeDomain: any, anchor: any, httpClient: any);
|
|
21
|
+
deposit(params: InteractiveParams): Promise<any>;
|
|
22
|
+
withdraw(params: InteractiveParams): Promise<any>;
|
|
23
|
+
flow(params: InteractiveParams & {
|
|
24
|
+
type: FLOW_TYPE;
|
|
25
|
+
}): Promise<any>;
|
|
15
26
|
}
|
|
16
27
|
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function sleep(delay: number): Promise<void>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stellar/typescript-wallet-sdk",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.1.0-alpha.1",
|
|
4
4
|
"engines": {
|
|
5
5
|
"node": ">=18"
|
|
6
6
|
},
|
|
@@ -14,23 +14,29 @@
|
|
|
14
14
|
"@stellar/prettier-config": "^1.0.1",
|
|
15
15
|
"@stellar/tsconfig": "^1.0.2",
|
|
16
16
|
"@types/jest": "^29.4.0",
|
|
17
|
+
"@types/lodash": "^4.14.194",
|
|
18
|
+
"@types/sinon": "^10.0.15",
|
|
17
19
|
"babel-jest": "^29.4.1",
|
|
18
20
|
"eslint": "^8.33.0",
|
|
19
21
|
"jest": "^29.4.1",
|
|
22
|
+
"sinon": "^15.1.0",
|
|
20
23
|
"ts-jest": "^29.0.5",
|
|
24
|
+
"ts-loader": "^9.4.2",
|
|
21
25
|
"tslib": "^2.5.0",
|
|
22
|
-
"typescript": "^5.0.4"
|
|
26
|
+
"typescript": "^5.0.4",
|
|
27
|
+
"webpack": "^5.83.1",
|
|
28
|
+
"webpack-cli": "^5.1.1"
|
|
23
29
|
},
|
|
24
30
|
"dependencies": {
|
|
25
|
-
"axios": "^1.
|
|
31
|
+
"axios": "^1.4.0",
|
|
26
32
|
"https-browserify": "^1.0.0",
|
|
33
|
+
"lodash": "^4.17.21",
|
|
34
|
+
"query-string": "^7.1.3",
|
|
27
35
|
"stellar-sdk": "^10.4.1",
|
|
28
36
|
"stream-http": "^3.2.0",
|
|
29
|
-
"ts-loader": "^9.4.2",
|
|
30
37
|
"url": "^0.11.0",
|
|
31
38
|
"util": "^0.12.5",
|
|
32
|
-
"
|
|
33
|
-
"webpack-cli": "^5.1.1"
|
|
39
|
+
"utility-types": "^3.10.0"
|
|
34
40
|
},
|
|
35
41
|
"scripts": {
|
|
36
42
|
"prepare": "yarn build",
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { MemoType } from "stellar-sdk";
|
|
2
|
+
import { Optional } from "utility-types";
|
|
3
|
+
import { TransactionStatus } from "../Watcher/Types";
|
|
4
|
+
|
|
5
|
+
export interface AnchorServiceInfo {
|
|
6
|
+
deposit: { [key: string]: AnchorServiceAsset };
|
|
7
|
+
withdraw: { [key: string]: AnchorServiceAsset };
|
|
8
|
+
fee: { enabled: boolean };
|
|
9
|
+
features: { account_creation: boolean; claimable_balances: boolean };
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
interface BaseTransaction {
|
|
13
|
+
id: string;
|
|
14
|
+
kind: string;
|
|
15
|
+
status: TransactionStatus;
|
|
16
|
+
more_info_url: string;
|
|
17
|
+
started_at: string;
|
|
18
|
+
message?: string;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
interface ProcessingAnchorTransaction extends BaseTransaction {
|
|
22
|
+
status_eta?: number;
|
|
23
|
+
kyc_verified?: boolean;
|
|
24
|
+
amount_in_asset?: string;
|
|
25
|
+
amount_in: string;
|
|
26
|
+
amount_out_asset?: string;
|
|
27
|
+
amount_out: string;
|
|
28
|
+
amount_fee_asset?: string;
|
|
29
|
+
amount_fee: string;
|
|
30
|
+
completed_at?: string;
|
|
31
|
+
stellar_transaction_id?: string;
|
|
32
|
+
external_transaction_id?: string;
|
|
33
|
+
refunds?: Refunds;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export interface DepositTransaction extends ProcessingAnchorTransaction {
|
|
37
|
+
from?: string;
|
|
38
|
+
to?: string;
|
|
39
|
+
deposit_memo?: string;
|
|
40
|
+
deposit_memo_type?: MemoType;
|
|
41
|
+
claimable_balance_id?: string;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export interface WithdrawTransaction extends ProcessingAnchorTransaction {
|
|
45
|
+
from: string;
|
|
46
|
+
to?: string;
|
|
47
|
+
withdraw_memo?: string;
|
|
48
|
+
withdraw_memo_type: MemoType;
|
|
49
|
+
withdraw_anchor_account: string;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
interface ErrorTransaction
|
|
53
|
+
extends Optional<DepositTransaction & WithdrawTransaction> {}
|
|
54
|
+
|
|
55
|
+
export type AnchorTransaction =
|
|
56
|
+
| DepositTransaction
|
|
57
|
+
| WithdrawTransaction
|
|
58
|
+
| ErrorTransaction;
|
|
59
|
+
|
|
60
|
+
interface Payment {
|
|
61
|
+
id: string;
|
|
62
|
+
id_type: string;
|
|
63
|
+
amount: string;
|
|
64
|
+
fee: string;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
interface Refunds {
|
|
68
|
+
amount_refunded: string;
|
|
69
|
+
amount_fee: string;
|
|
70
|
+
payments: Payment[];
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
interface AnchorServiceAsset {
|
|
74
|
+
enabled: boolean;
|
|
75
|
+
min_amount: number;
|
|
76
|
+
max_amount: number;
|
|
77
|
+
fee_fixed: number;
|
|
78
|
+
fee_percent: number;
|
|
79
|
+
}
|