@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.
- package/.eslintrc.js +76 -0
- package/.github/workflows/integrationTest.yml +19 -0
- package/.github/workflows/runTests.yml +14 -0
- package/.husky/pre-commit +1 -0
- package/README.md +19 -12
- package/examples/sep24/.env.example +4 -0
- package/examples/sep24/README.md +17 -0
- package/examples/sep24/sep24.ts +69 -14
- package/examples/tsconfig.json +10 -0
- package/jest.config.js +1 -0
- package/jest.integration.config.js +9 -0
- package/lib/bundle.js +6929 -2377
- package/lib/bundle.js.map +1 -1
- package/lib/bundle_browser.js +6915 -2410
- package/lib/bundle_browser.js.map +1 -1
- package/lib/index.d.ts +1 -1
- package/lib/walletSdk/Anchor/Sep24.d.ts +65 -22
- package/lib/walletSdk/Anchor/Sep38.d.ts +56 -0
- package/lib/walletSdk/Anchor/Sep6.d.ts +127 -0
- package/lib/walletSdk/Anchor/index.d.ts +91 -1
- package/lib/walletSdk/Asset/index.d.ts +11 -1
- package/lib/walletSdk/Auth/WalletSigner.d.ts +41 -1
- package/lib/walletSdk/Auth/index.d.ts +21 -0
- package/lib/walletSdk/Customer/index.d.ts +70 -0
- package/lib/walletSdk/Exceptions/index.d.ts +45 -2
- package/lib/walletSdk/Horizon/AccountService.d.ts +30 -20
- package/lib/walletSdk/Horizon/Stellar.d.ts +79 -2
- package/lib/walletSdk/Horizon/Transaction/CommonTransactionBuilder.d.ts +57 -0
- package/lib/walletSdk/Horizon/Transaction/SponsoringBuilder.d.ts +38 -0
- package/lib/walletSdk/Horizon/Transaction/TransactionBuilder.d.ts +112 -11
- package/lib/walletSdk/Horizon/index.d.ts +3 -1
- package/lib/walletSdk/Recovery/AccountRecover.d.ts +58 -0
- package/lib/walletSdk/Recovery/index.d.ts +69 -7
- package/lib/walletSdk/Types/anchor.d.ts +17 -2
- package/lib/walletSdk/Types/auth.d.ts +14 -1
- package/lib/walletSdk/Types/horizon.d.ts +17 -6
- package/lib/walletSdk/Types/index.d.ts +15 -3
- package/lib/walletSdk/Types/recovery.d.ts +128 -0
- package/lib/walletSdk/Types/sep12.d.ts +57 -0
- package/lib/walletSdk/Types/sep38.d.ts +93 -0
- package/lib/walletSdk/Types/sep6.d.ts +160 -0
- package/lib/walletSdk/Types/watcher.d.ts +7 -2
- package/lib/walletSdk/Utils/extractAxiosErrorData.d.ts +2 -0
- package/lib/walletSdk/Utils/index.d.ts +1 -0
- package/lib/walletSdk/Utils/toml.d.ts +2 -2
- package/lib/walletSdk/Watcher/getTransactions.d.ts +8 -0
- package/lib/walletSdk/Watcher/index.d.ts +41 -4
- package/lib/walletSdk/index.d.ts +43 -5
- package/package.json +17 -4
- package/src/index.ts +2 -0
- package/src/walletSdk/Anchor/Sep24.ts +93 -86
- package/src/walletSdk/Anchor/Sep38.ts +180 -0
- package/src/walletSdk/Anchor/Sep6.ts +291 -0
- package/src/walletSdk/Anchor/index.ts +138 -5
- package/src/walletSdk/Asset/index.ts +21 -4
- package/src/walletSdk/Auth/WalletSigner.ts +23 -5
- package/src/walletSdk/Auth/index.ts +24 -5
- package/src/walletSdk/Customer/index.ts +174 -0
- package/src/walletSdk/Exceptions/index.ts +115 -4
- package/src/walletSdk/Horizon/AccountService.ts +33 -21
- package/src/walletSdk/Horizon/Stellar.ts +89 -5
- package/src/walletSdk/Horizon/Transaction/CommonTransactionBuilder.ts +43 -4
- package/src/walletSdk/Horizon/Transaction/SponsoringBuilder.ts +30 -7
- package/src/walletSdk/Horizon/Transaction/TransactionBuilder.ts +88 -15
- package/src/walletSdk/Horizon/index.ts +2 -1
- package/src/walletSdk/Recovery/AccountRecover.ts +255 -0
- package/src/walletSdk/Recovery/index.ts +314 -13
- package/src/walletSdk/Types/anchor.ts +23 -2
- package/src/walletSdk/Types/auth.ts +36 -2
- package/src/walletSdk/Types/horizon.ts +7 -5
- package/src/walletSdk/Types/index.ts +17 -4
- package/src/walletSdk/Types/recovery.ts +152 -0
- package/src/walletSdk/Types/sep12.ts +61 -0
- package/src/walletSdk/Types/sep38.ts +106 -0
- package/src/walletSdk/Types/sep6.ts +168 -0
- package/src/walletSdk/Types/watcher.ts +8 -2
- package/src/walletSdk/Utils/camelToSnakeCase.ts +1 -0
- package/src/walletSdk/Utils/extractAxiosErrorData.ts +28 -0
- package/src/walletSdk/Utils/index.ts +1 -0
- package/src/walletSdk/Utils/toml.ts +2 -2
- package/src/walletSdk/Watcher/getTransactions.ts +65 -0
- package/src/walletSdk/Watcher/index.ts +70 -9
- package/src/walletSdk/index.ts +45 -8
- package/test/README.md +18 -0
- package/test/accountService.test.ts +21 -3
- package/test/customer.test.ts +82 -0
- package/test/docker/docker-compose.yml +97 -0
- package/test/integration.test.ts +166 -0
- package/test/recovery.test.ts +107 -0
- package/test/sep38.test.ts +71 -0
- package/test/sep6.test.ts +240 -0
- package/test/stellar.test.ts +57 -12
- package/test/transaction.test.ts +8 -10
- package/test/tsconfig.json +10 -0
- package/test/utils/index.ts +12 -0
- package/test/wallet.test.ts +60 -21
package/lib/index.d.ts
CHANGED
|
@@ -11,7 +11,7 @@ export { Anchor } from "./walletSdk/Anchor";
|
|
|
11
11
|
export { Sep24 } from "./walletSdk/Anchor/Sep24";
|
|
12
12
|
export { IssuedAssetId, NativeAssetId, FiatAssetId } from "./walletSdk/Asset";
|
|
13
13
|
export { Sep10, WalletSigner, DefaultSigner } from "./walletSdk/Auth";
|
|
14
|
-
export { PublicKeypair, SigningKeypair, AccountService, Stellar, TransactionBuilder, } from "./walletSdk/Horizon";
|
|
14
|
+
export { AccountKeypair, PublicKeypair, SigningKeypair, AccountService, Stellar, CommonTransactionBuilder, TransactionBuilder, SponsoringBuilder, } from "./walletSdk/Horizon";
|
|
15
15
|
export { Recovery } from "./walletSdk/Recovery";
|
|
16
16
|
export { Watcher } from "./walletSdk/Watcher";
|
|
17
17
|
/**
|
|
@@ -6,42 +6,85 @@ type Sep24Params = {
|
|
|
6
6
|
anchor: Anchor;
|
|
7
7
|
httpClient: AxiosInstance;
|
|
8
8
|
};
|
|
9
|
+
/**
|
|
10
|
+
* Interactive flow for deposit and withdrawal using SEP-24.
|
|
11
|
+
* @see {@link https://github.com/stellar/stellar-protocol/blob/master/ecosystem/sep-0024.md}
|
|
12
|
+
* Do not create this object directly, use the Anchor class.
|
|
13
|
+
* @class
|
|
14
|
+
*/
|
|
9
15
|
export declare class Sep24 {
|
|
10
16
|
private anchor;
|
|
11
17
|
private httpClient;
|
|
18
|
+
/**
|
|
19
|
+
* Creates a new instance of the Sep24 class.
|
|
20
|
+
* @constructor
|
|
21
|
+
* @param {Sep24Params} params - Parameters to initialize the Sep24 instance.
|
|
22
|
+
*/
|
|
12
23
|
constructor(params: Sep24Params);
|
|
24
|
+
/**
|
|
25
|
+
* Initiates a deposit request.
|
|
26
|
+
* @param {Sep24PostParams} params - The SEP-24 Post params.
|
|
27
|
+
* @param {string} params.assetCode - The asset to deposit.
|
|
28
|
+
* @param {AuthToken} params.authToken - Authentication token for the request.
|
|
29
|
+
* @param {string} [params.lang] - The language for the request (defaults to the Anchor's language).
|
|
30
|
+
* @param {ExtraFields} [params.extraFields] - Additional fields for the request.
|
|
31
|
+
* @param {Memo} [params.destinationMemo] - Memo information for the destination account.
|
|
32
|
+
* @param {string} [params.destinationAccount] - The destination account for the deposit.
|
|
33
|
+
* @returns {Promise<Sep24PostResponse>} The Sep24 response.
|
|
34
|
+
* @throws {AssetNotSupportedError} If the asset is not supported for deposit.
|
|
35
|
+
*/
|
|
13
36
|
deposit({ assetCode, authToken, lang, extraFields, destinationMemo, destinationAccount, }: Sep24PostParams): Promise<Sep24PostResponse>;
|
|
37
|
+
/**
|
|
38
|
+
* Initiates a withdrawal request.
|
|
39
|
+
* @param {Sep24PostParams} params - The SEP-24 Post params.
|
|
40
|
+
* @param {string} params.assetCode - The asset to withdraw.
|
|
41
|
+
* @param {AuthToken} params.authToken - Authentication token for the request.
|
|
42
|
+
* @param {string} [params.lang] - The language for the request (defaults to the Anchor's language).
|
|
43
|
+
* @param {ExtraFields} [params.extraFields] - Additional fields for the request.
|
|
44
|
+
* @param {string} [params.withdrawalAccount] - The withdrawal account.
|
|
45
|
+
* @returns {Promise<Sep24PostResponse>} The Sep24 response.
|
|
46
|
+
* @throws {AssetNotSupportedError} If the asset is not supported for withdrawal.
|
|
47
|
+
*/
|
|
14
48
|
withdraw({ assetCode, authToken, lang, extraFields, withdrawalAccount, }: Sep24PostParams): Promise<Sep24PostResponse>;
|
|
15
49
|
private flow;
|
|
50
|
+
/**
|
|
51
|
+
* Retrieves information about the Anchor.
|
|
52
|
+
* @returns {Promise<AnchorServiceInfo>} An object containing information about the Anchor.
|
|
53
|
+
* @throws {ServerRequestFailedError} If the server request to fetch information fails.
|
|
54
|
+
*/
|
|
16
55
|
getServicesInfo(): Promise<AnchorServiceInfo>;
|
|
56
|
+
/**
|
|
57
|
+
* Creates a new instance of the Watcher class, to watch sep24 transactions.
|
|
58
|
+
* @returns {Watcher} A new Watcher instance.
|
|
59
|
+
*/
|
|
17
60
|
watcher(): Watcher;
|
|
18
61
|
/**
|
|
19
|
-
* Get single transaction's current status and details
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
* @param
|
|
23
|
-
* @param
|
|
24
|
-
* @param
|
|
25
|
-
* @param
|
|
26
|
-
* @
|
|
27
|
-
* @throws
|
|
28
|
-
* @throws
|
|
29
|
-
* @throws
|
|
62
|
+
* Get single transaction's current status and details from the anchor.
|
|
63
|
+
* @param {GetTransactionParams} params - The Get Transactions params.
|
|
64
|
+
* @param {AuthToken} params.authToken - The authentication token for the account authenticated with the anchor.
|
|
65
|
+
* @param {string} [params.id] - The transaction ID.
|
|
66
|
+
* @param {string} [params.stellarTransactionId] - The Stellar transaction ID.
|
|
67
|
+
* @param {string} [params.externalTransactionId] - The external transaction ID.
|
|
68
|
+
* @param {string} [params.lang] - The language setting.
|
|
69
|
+
* @returns {Promise<AnchorTransaction>} The transaction object.
|
|
70
|
+
* @throws {MissingTransactionIdError} If none of the ID parameters is provided.
|
|
71
|
+
* @throws {InvalidTransactionResponseError} If the anchor returns an invalid transaction response.
|
|
72
|
+
* @throws {ServerRequestFailedError} If the server request fails.
|
|
30
73
|
*/
|
|
31
74
|
getTransactionBy({ authToken, id, stellarTransactionId, externalTransactionId, lang, }: GetTransactionParams): Promise<AnchorTransaction>;
|
|
32
75
|
/**
|
|
33
76
|
* Get account's transactions specified by asset and other params.
|
|
34
|
-
*
|
|
35
|
-
* @param authToken
|
|
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
|
-
* @
|
|
43
|
-
* @throws
|
|
44
|
-
* @throws
|
|
77
|
+
* @param {GetTransactionParams} params - The Get Transactions params.
|
|
78
|
+
* @param {AuthToken} params.authToken - The authentication token for the account authenticated with the anchor.
|
|
79
|
+
* @param {string} params.assetCode - The target asset to query for.
|
|
80
|
+
* @param {string} [params.noOlderThan] - The response should contain transactions starting on or after this date & time.
|
|
81
|
+
* @param {string} [params.limit] - The response should contain at most 'limit' transactions.
|
|
82
|
+
* @param {string} [params.kind] - The kind of transaction that is desired. E.g.: 'deposit', 'withdrawal'.
|
|
83
|
+
* @param {string} [params.pagingId] - The response should contain transactions starting prior to this ID (exclusive).
|
|
84
|
+
* @param {string} [params.lang] - The desired language (localization), it can also accept locale in the format 'en-US'.
|
|
85
|
+
* @returns {Promise<AnchorTransaction[]>} A list of transactions as requested by the client, sorted in time-descending order.
|
|
86
|
+
* @throws {InvalidTransactionsResponseError} Anchor returns an invalid response.
|
|
87
|
+
* @throws {ServerRequestFailedError} If server request fails.
|
|
45
88
|
*/
|
|
46
89
|
getTransactionsForAsset({ authToken, assetCode, noOlderThan, limit, kind, pagingId, lang, }: GetTransactionsParams): Promise<AnchorTransaction[]>;
|
|
47
90
|
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { Sep38Info, Sep38Params, Sep38PricesParams, Sep38PriceParams, Sep38PricesResponse, Sep38PriceResponse, Sep38PostQuoteParams, Sep38PostQuoteResponse } from "../Types";
|
|
2
|
+
/**
|
|
3
|
+
* Quote service using SEP-38. It can be used for getting price quotes from an anchor
|
|
4
|
+
* for exchanging assets.
|
|
5
|
+
* @see {@link https://github.com/stellar/stellar-protocol/blob/master/ecosystem/sep-0038.md}
|
|
6
|
+
* Do not create this object directly, use the Anchor class.
|
|
7
|
+
* @class
|
|
8
|
+
*/
|
|
9
|
+
export declare class Sep38 {
|
|
10
|
+
private anchor;
|
|
11
|
+
private httpClient;
|
|
12
|
+
private authToken;
|
|
13
|
+
private headers;
|
|
14
|
+
private sep38Info;
|
|
15
|
+
/**
|
|
16
|
+
* Creates a new instance of the Sep38 class.
|
|
17
|
+
* @constructor
|
|
18
|
+
* @param {Sep38Params} params - Parameters to initialize the Sep38 instance.
|
|
19
|
+
*/
|
|
20
|
+
constructor(params: Sep38Params);
|
|
21
|
+
/**
|
|
22
|
+
* Get SEP-38 anchor information.
|
|
23
|
+
* If `shouldRefresh` is set to `true`, it fetches fresh values; otherwise, it returns cached values if available.
|
|
24
|
+
* @param {boolean} [shouldRefresh=false] - Flag to force a refresh of TOML values.
|
|
25
|
+
* @returns {Promise<Sep38Info>} - SEP-38 information about the anchor.
|
|
26
|
+
*/
|
|
27
|
+
info(shouldRefresh?: boolean): Promise<Sep38Info>;
|
|
28
|
+
/**
|
|
29
|
+
* Get indicative prices of off-chain assets in exchange for a Stellar asset, or vice versa,
|
|
30
|
+
* from an anchor using Sep-38.
|
|
31
|
+
* @param {Sep38PricesParams} params - The parameters for the GET prices request.
|
|
32
|
+
* if the anchor does not require it.
|
|
33
|
+
* @returns {Promise<Sep38PricesResponse>} - SEP-38 /prices response.
|
|
34
|
+
*/
|
|
35
|
+
prices(params: Sep38PricesParams): Promise<Sep38PricesResponse>;
|
|
36
|
+
/**
|
|
37
|
+
* Get an indicative price for an an asset pair from and anchor using SEP-38.
|
|
38
|
+
* @param {Sep38PriceParams} params - The parameters for the GET price request.
|
|
39
|
+
* if the anchor does not require it.
|
|
40
|
+
* @throws {Sep38PriceOnlyOneAmountError} Must give only sellAmount or buyAmount, and not both.
|
|
41
|
+
* @returns {Promise<Sep38PriceResponse>} - SEP-38 /price response.
|
|
42
|
+
*/
|
|
43
|
+
price(params: Sep38PriceParams): Promise<Sep38PriceResponse>;
|
|
44
|
+
/**
|
|
45
|
+
* Request a firm quote from the anchor.
|
|
46
|
+
* @param {Sep38PostQuoteParams} params - The parameters for the quote request.
|
|
47
|
+
* @returns {Promise<Sep38PostQuoteResponse>} - SEP-38 quote response.
|
|
48
|
+
*/
|
|
49
|
+
requestQuote(params: Sep38PostQuoteParams): Promise<Sep38PostQuoteResponse>;
|
|
50
|
+
/**
|
|
51
|
+
* Get a previously-provided quote from the anchor.
|
|
52
|
+
* @param {string} quoteId - The id of the quote to fetch.
|
|
53
|
+
* @returns {Promise<Sep38PostQuoteResponse>} - SEP-38 quote response.
|
|
54
|
+
*/
|
|
55
|
+
getQuote(quoteId: string): Promise<Sep38PostQuoteResponse>;
|
|
56
|
+
}
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
import { Sep6Info, Sep6Params, Sep6DepositParams, Sep6WithdrawParams, Sep6DepositResponse, Sep6WithdrawResponse, Sep6ExchangeParams, Sep6Transaction, GetTransactionParams, GetTransactionsParams, AuthToken } from "../Types";
|
|
2
|
+
import { Watcher } from "../Watcher";
|
|
3
|
+
/**
|
|
4
|
+
* Flow for creating deposits and withdrawals with an anchor using SEP-6.
|
|
5
|
+
* For an interactive flow use Sep24 instead.
|
|
6
|
+
* @see {@link https://github.com/stellar/stellar-protocol/blob/master/ecosystem/sep-0006.md}
|
|
7
|
+
* Do not create this object directly, use the Anchor class.
|
|
8
|
+
* @class
|
|
9
|
+
*/
|
|
10
|
+
export declare class Sep6 {
|
|
11
|
+
private anchor;
|
|
12
|
+
private httpClient;
|
|
13
|
+
private anchorInfo;
|
|
14
|
+
/**
|
|
15
|
+
* Creates a new instance of the Sep6 class.
|
|
16
|
+
* @constructor
|
|
17
|
+
* @param {Sep6Params} params - Parameters to initialize the Sep6 instance.
|
|
18
|
+
*/
|
|
19
|
+
constructor(params: Sep6Params);
|
|
20
|
+
/**
|
|
21
|
+
* Get SEP-6 anchor information.
|
|
22
|
+
* If `shouldRefresh` is set to `true`, it fetches fresh values; otherwise, it returns cached values if available.
|
|
23
|
+
* @param {boolean} [shouldRefresh=false] - Flag to force a refresh of TOML values.
|
|
24
|
+
* @returns {Promise<Sep6Info>} - SEP-6 information about the anchor.
|
|
25
|
+
*/
|
|
26
|
+
info(shouldRefresh?: boolean): Promise<Sep6Info>;
|
|
27
|
+
/**
|
|
28
|
+
* Deposits funds using the SEP-6 protocol. Next steps by
|
|
29
|
+
* the anchor are given in the response.
|
|
30
|
+
*
|
|
31
|
+
* @param {object} options - The options for the deposit.
|
|
32
|
+
* @param {AuthToken} options.authToken - The authentication token.
|
|
33
|
+
* @param {Sep6DepositParams} options.params - The parameters for the deposit request.
|
|
34
|
+
*
|
|
35
|
+
* @returns {Promise<Sep6DepositResponse>} Sep6 deposit response, containing next steps if needed
|
|
36
|
+
* to complete the deposit.
|
|
37
|
+
*
|
|
38
|
+
* @throws {Error} If an unexpected error occurs during the deposit operation.
|
|
39
|
+
*/
|
|
40
|
+
deposit({ authToken, params, }: {
|
|
41
|
+
authToken: AuthToken;
|
|
42
|
+
params: Sep6DepositParams;
|
|
43
|
+
}): Promise<Sep6DepositResponse>;
|
|
44
|
+
/**
|
|
45
|
+
* Initiates a withdrawal using SEP-6.
|
|
46
|
+
*
|
|
47
|
+
* @param {object} options - The options for the withdrawal operation.
|
|
48
|
+
* @param {AuthToken} options.authToken - The authentication token.
|
|
49
|
+
* @param {Sep6WithdrawParams} options.params - The parameters for the withdrawal request.
|
|
50
|
+
*
|
|
51
|
+
* @returns {Promise<Sep6WithdrawResponse>} Sep6 withdraw response.
|
|
52
|
+
*/
|
|
53
|
+
withdraw({ authToken, params, }: {
|
|
54
|
+
authToken: AuthToken;
|
|
55
|
+
params: Sep6WithdrawParams;
|
|
56
|
+
}): Promise<Sep6WithdrawResponse>;
|
|
57
|
+
/**
|
|
58
|
+
* Similar to the SEP-6 deposit function, but for non-equivalent assets
|
|
59
|
+
* that require an exchange.
|
|
60
|
+
*
|
|
61
|
+
* @param {object} options - The options for the deposit exchange.
|
|
62
|
+
* @param {AuthToken} options.authToken - The authentication token.
|
|
63
|
+
* @param {Sep6ExchangeParams} options.params - The parameters for the deposit request.
|
|
64
|
+
*
|
|
65
|
+
* @returns {Promise<Sep6DepositResponse>} Sep6 deposit response, containing next steps if needed
|
|
66
|
+
* to complete the deposit.
|
|
67
|
+
*
|
|
68
|
+
* @throws {Error} If an unexpected error occurs during the deposit operation.
|
|
69
|
+
*/
|
|
70
|
+
depositExchange({ authToken, params, }: {
|
|
71
|
+
authToken: AuthToken;
|
|
72
|
+
params: Sep6ExchangeParams;
|
|
73
|
+
}): Promise<Sep6DepositResponse>;
|
|
74
|
+
/**
|
|
75
|
+
* Similar to the SEP-6 withdraw function, but for non-equivalent assets
|
|
76
|
+
* that require an exchange.
|
|
77
|
+
*
|
|
78
|
+
* @param {object} options - The options for the deposit exchange.
|
|
79
|
+
* @param {AuthToken} options.authToken - The authentication token.
|
|
80
|
+
* @param {Sep6ExchangeParams} options.params - The parameters for the deposit request.
|
|
81
|
+
*
|
|
82
|
+
* @returns {Promise<Sep6WithdrawResponse>} Sep6 withdraw response, containing next steps if needed
|
|
83
|
+
* to complete the withdrawal.
|
|
84
|
+
*
|
|
85
|
+
* @throws {Error} If an unexpected error occurs during the deposit operation.
|
|
86
|
+
*/
|
|
87
|
+
withdrawExchange({ authToken, params, }: {
|
|
88
|
+
authToken: AuthToken;
|
|
89
|
+
params: Sep6ExchangeParams;
|
|
90
|
+
}): Promise<Sep6WithdrawResponse>;
|
|
91
|
+
private flow;
|
|
92
|
+
/**
|
|
93
|
+
* Creates a new instance of the Watcher class, to watch sep6 transactions.
|
|
94
|
+
* @returns {Watcher} A new Watcher instance.
|
|
95
|
+
*/
|
|
96
|
+
watcher(): Watcher;
|
|
97
|
+
/**
|
|
98
|
+
* Get account's sep6 transactions specified by asset and other params.
|
|
99
|
+
* @param {GetTransactionsParams} params - The Get Transactions params.
|
|
100
|
+
* @param {AuthToken} params.authToken - The authentication token for the account authenticated with the anchor.
|
|
101
|
+
* @param {string} params.assetCode - The target asset to query for.
|
|
102
|
+
* @param {string} [params.noOlderThan] - The response should contain transactions starting on or after this date & time.
|
|
103
|
+
* @param {string} [params.limit] - The response should contain at most 'limit' transactions.
|
|
104
|
+
* @param {string} [params.kind] - The kind of transaction that is desired. E.g.: 'deposit', 'withdrawal', 'depo
|
|
105
|
+
* -exchange', 'withdrawal-exchange'.
|
|
106
|
+
* @param {string} [params.pagingId] - The response should contain transactions starting prior to this ID (exclusive).
|
|
107
|
+
* @param {string} [params.lang] - The desired language (localization), it can also accept locale in the format 'en-US'.
|
|
108
|
+
* @returns {Promise<Sep6Transaction[]>} A list of transactions as requested by the client, sorted in time-descending order.
|
|
109
|
+
* @throws {InvalidTransactionsResponseError} Anchor returns an invalid response.
|
|
110
|
+
* @throws {ServerRequestFailedError} If server request fails.
|
|
111
|
+
*/
|
|
112
|
+
getTransactionsForAsset({ authToken, assetCode, noOlderThan, limit, kind, pagingId, lang, }: GetTransactionsParams): Promise<Sep6Transaction[]>;
|
|
113
|
+
/**
|
|
114
|
+
* Get single sep6 transaction's current status and details from the anchor.
|
|
115
|
+
* @param {GetTransactionParams} params - The Get Transactions params.
|
|
116
|
+
* @param {AuthToken} params.authToken - The authentication token for the account authenticated with the anchor.
|
|
117
|
+
* @param {string} [params.id] - The transaction ID.
|
|
118
|
+
* @param {string} [params.stellarTransactionId] - The Stellar transaction ID.
|
|
119
|
+
* @param {string} [params.externalTransactionId] - The external transaction ID.
|
|
120
|
+
* @param {string} [params.lang] - The language setting.
|
|
121
|
+
* @returns {Promise<Sep6Transaction>} The transaction object.
|
|
122
|
+
* @throws {MissingTransactionIdError} If none of the ID parameters is provided.
|
|
123
|
+
* @throws {InvalidTransactionResponseError} If the anchor returns an invalid transaction response.
|
|
124
|
+
* @throws {ServerRequestFailedError} If the server request fails.
|
|
125
|
+
*/
|
|
126
|
+
getTransactionBy({ authToken, id, stellarTransactionId, externalTransactionId, lang, }: GetTransactionParams): Promise<Sep6Transaction>;
|
|
127
|
+
}
|
|
@@ -1,24 +1,114 @@
|
|
|
1
1
|
import { AxiosInstance } from "axios";
|
|
2
2
|
import { Config } from "walletSdk";
|
|
3
3
|
import { Sep10 } from "../Auth";
|
|
4
|
+
import { Sep12 } from "../Customer";
|
|
5
|
+
import { Sep6 } from "./Sep6";
|
|
4
6
|
import { Sep24 } from "./Sep24";
|
|
5
|
-
import {
|
|
7
|
+
import { Sep38 } from "./Sep38";
|
|
8
|
+
import { AnchorServiceInfo, TomlInfo, AuthToken } from "../Types";
|
|
6
9
|
type AnchorParams = {
|
|
7
10
|
cfg: Config;
|
|
8
11
|
homeDomain: string;
|
|
9
12
|
httpClient: AxiosInstance;
|
|
10
13
|
language: string;
|
|
11
14
|
};
|
|
15
|
+
export type Transfer = Sep6;
|
|
16
|
+
export type Auth = Sep10;
|
|
17
|
+
export type Customer = Sep12;
|
|
18
|
+
export type Interactive = Sep24;
|
|
19
|
+
export type Quote = Sep38;
|
|
20
|
+
/**
|
|
21
|
+
* Build on/off ramps with anchors.
|
|
22
|
+
* Do not create this object directly, use the Wallet class.
|
|
23
|
+
* @class
|
|
24
|
+
*/
|
|
12
25
|
export declare class Anchor {
|
|
13
26
|
language: string;
|
|
14
27
|
private cfg;
|
|
15
28
|
private homeDomain;
|
|
16
29
|
private httpClient;
|
|
17
30
|
private toml;
|
|
31
|
+
/**
|
|
32
|
+
* Creates a new Anchor instance.
|
|
33
|
+
* @constructor
|
|
34
|
+
* @param {AnchorParams} params - The parameters to initialize the Anchor.
|
|
35
|
+
*/
|
|
18
36
|
constructor(params: AnchorParams);
|
|
37
|
+
/**
|
|
38
|
+
* Get anchor information from a TOML file.
|
|
39
|
+
* If `shouldRefresh` is set to `true`, it fetches fresh TOML values; otherwise, it returns cached values if available.
|
|
40
|
+
* @param {boolean} [shouldRefresh=false] - Flag to force a refresh of TOML values.
|
|
41
|
+
* @returns {Promise<TomlInfo>} - TOML information about the anchor.
|
|
42
|
+
*/
|
|
19
43
|
sep1(shouldRefresh?: boolean): Promise<TomlInfo>;
|
|
44
|
+
/**
|
|
45
|
+
* Retrieves and returns TOML information using the `sep1` method.
|
|
46
|
+
* @param {boolean} [shouldRefresh=false] - Flag to force a refresh of TOML values.
|
|
47
|
+
* @returns {Promise<TomlInfo>} - TOML information.
|
|
48
|
+
*/
|
|
49
|
+
getInfo(shouldRefresh?: boolean): Promise<TomlInfo>;
|
|
50
|
+
/**
|
|
51
|
+
* Creates new transfer flow for given anchor. It can be used for withdrawal or deposit.
|
|
52
|
+
* @returns {Sep6} - flow service.
|
|
53
|
+
*/
|
|
54
|
+
sep6(): Sep6;
|
|
55
|
+
/**
|
|
56
|
+
* Creates new transfer flow using the `sep6` method.
|
|
57
|
+
* @returns {Transfer} - transfer flow service.
|
|
58
|
+
*/
|
|
59
|
+
transfer(): Transfer;
|
|
60
|
+
/**
|
|
61
|
+
* Create new auth object to authenticate account with the anchor using SEP-10.
|
|
62
|
+
* @returns {Promise<Sep10>} - The SEP-10 authentication manager.
|
|
63
|
+
*/
|
|
20
64
|
sep10(): Promise<Sep10>;
|
|
65
|
+
/**
|
|
66
|
+
* Create new auth object to authenticate with using the `sep10` method.
|
|
67
|
+
* @returns {Promise<Auth>} - The SEP-10 authentication manager.
|
|
68
|
+
*/
|
|
69
|
+
auth(): Promise<Auth>;
|
|
70
|
+
/**
|
|
71
|
+
* Create new customer object to handle customer records with the anchor using SEP-12.
|
|
72
|
+
* @param {AuthToken} authToken - The authentication token.
|
|
73
|
+
* @returns {Promise<Sep12>} - A Sep12 customer instance.
|
|
74
|
+
* @throws {KYCServerNotFoundError} - If the KYC server information is not available.
|
|
75
|
+
*/
|
|
76
|
+
sep12(authToken: AuthToken): Promise<Sep12>;
|
|
77
|
+
/**
|
|
78
|
+
* Create new customer object to handle customer records using the `sep12` method.
|
|
79
|
+
* @param {AuthToken} authToken - The authentication token.
|
|
80
|
+
* @returns {Promise<Customer>} - A Customer instance.
|
|
81
|
+
*/
|
|
82
|
+
customer(authToken: AuthToken): Promise<Customer>;
|
|
83
|
+
/**
|
|
84
|
+
* Creates new interactive flow for given anchor. It can be used for withdrawal or deposit.
|
|
85
|
+
* @returns {Sep24} - interactive flow service.
|
|
86
|
+
*/
|
|
21
87
|
sep24(): Sep24;
|
|
88
|
+
/**
|
|
89
|
+
* Creates new interactive flow using the `sep24` method.
|
|
90
|
+
* @returns {Interactive} - interactive flow service
|
|
91
|
+
*/
|
|
92
|
+
interactive(): Interactive;
|
|
93
|
+
/**
|
|
94
|
+
* Creates a new quote service. It can be used for getting price quotes from an anchor
|
|
95
|
+
* for exchanging assets.
|
|
96
|
+
* @param {AuthToken} [authToken] - The authentication token.
|
|
97
|
+
* @returns {Sep38} - quote service.
|
|
98
|
+
*/
|
|
99
|
+
sep38(authToken?: AuthToken): Sep38;
|
|
100
|
+
/**
|
|
101
|
+
* Creates a new quote service using the `sep38` method.
|
|
102
|
+
* @param {AuthToken} [authToken] - The authentication token.
|
|
103
|
+
* @returns {Quote} - quote service.
|
|
104
|
+
*/
|
|
105
|
+
quote(authToken?: AuthToken): Quote;
|
|
106
|
+
/**
|
|
107
|
+
* Get information about an Anchor.
|
|
108
|
+
* @param {string} [lang=this.language] - The language in which to retrieve information.
|
|
109
|
+
* @returns {Promise<AnchorServiceInfo>} An object containing information about the Anchor.
|
|
110
|
+
* @throws {ServerRequestFailedError} If the http request fails.
|
|
111
|
+
*/
|
|
22
112
|
getServicesInfo(lang?: string): Promise<AnchorServiceInfo>;
|
|
23
113
|
}
|
|
24
114
|
export {};
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { Asset as StellarAsset } from "stellar-sdk";
|
|
1
2
|
declare class AssetId {
|
|
2
3
|
id: string;
|
|
3
4
|
scheme: string;
|
|
@@ -8,12 +9,13 @@ export declare class StellarAssetId extends AssetId {
|
|
|
8
9
|
code: string;
|
|
9
10
|
issuer: string;
|
|
10
11
|
scheme: string;
|
|
11
|
-
toAsset():
|
|
12
|
+
toAsset(): StellarAsset;
|
|
12
13
|
}
|
|
13
14
|
export declare class IssuedAssetId extends StellarAssetId {
|
|
14
15
|
constructor(code: string, issuer: string);
|
|
15
16
|
toString(): string;
|
|
16
17
|
}
|
|
18
|
+
export type XLM = NativeAssetId;
|
|
17
19
|
export declare class NativeAssetId extends StellarAssetId {
|
|
18
20
|
id: string;
|
|
19
21
|
code: string;
|
|
@@ -24,4 +26,12 @@ export declare class FiatAssetId extends AssetId {
|
|
|
24
26
|
constructor(code: string);
|
|
25
27
|
toString(): string;
|
|
26
28
|
}
|
|
29
|
+
export declare const Assets: {
|
|
30
|
+
Main: {
|
|
31
|
+
USDC: IssuedAssetId;
|
|
32
|
+
};
|
|
33
|
+
Test: {
|
|
34
|
+
USDC: IssuedAssetId;
|
|
35
|
+
};
|
|
36
|
+
};
|
|
27
37
|
export {};
|
|
@@ -1,7 +1,47 @@
|
|
|
1
1
|
import { Transaction } from "stellar-sdk";
|
|
2
|
-
import { SignWithClientAccountParams, SignWithDomainAccountParams } from "../Types";
|
|
2
|
+
import { SignWithClientAccountParams, SignWithDomainAccountParams, HttpHeaders } from "../Types";
|
|
3
|
+
/**
|
|
4
|
+
* A Wallet Signer for signing Stellar transactions.
|
|
5
|
+
*/
|
|
3
6
|
export interface WalletSigner {
|
|
7
|
+
/**
|
|
8
|
+
* Sign a transaction with a client keypair.
|
|
9
|
+
* @param {Transaction} params.transaction - The transaction to sign.
|
|
10
|
+
* @param {AccountKeypair} params.accountKp - The keypair to sign with.
|
|
11
|
+
* @returns {Transaction} The signed transaction.
|
|
12
|
+
*/
|
|
4
13
|
signWithClientAccount({ transaction, accountKp, }: SignWithClientAccountParams): Transaction;
|
|
14
|
+
/**
|
|
15
|
+
* Sign a transaction using the domain account's keypair. This method is async in the
|
|
16
|
+
* case of signing with a different server.
|
|
17
|
+
* @param {XdrEncodedTransaction} params.transactionXDR - The XDR representation of the transaction to sign.
|
|
18
|
+
* @param {NetworkPassphrase} params.networkPassphrase - The network passphrase for the Stellar network.
|
|
19
|
+
* @param {AccountKeypair} params.accountKp - The keypair of the domain account.
|
|
20
|
+
* @returns {Promise<Transaction>} The signed transaction.
|
|
21
|
+
*/
|
|
5
22
|
signWithDomainAccount({ transactionXDR, networkPassphrase, accountKp, }: SignWithDomainAccountParams): Promise<Transaction>;
|
|
6
23
|
}
|
|
24
|
+
/**
|
|
25
|
+
* A Default signer used if no signer is given.
|
|
26
|
+
*/
|
|
7
27
|
export declare const DefaultSigner: WalletSigner;
|
|
28
|
+
/**
|
|
29
|
+
* A Domain Signer used for signing Stellar transactions with a domain server.
|
|
30
|
+
* @class
|
|
31
|
+
* @implements {WalletSigner}
|
|
32
|
+
*/
|
|
33
|
+
export declare class DomainSigner implements WalletSigner {
|
|
34
|
+
private url;
|
|
35
|
+
private client;
|
|
36
|
+
private headers;
|
|
37
|
+
/**
|
|
38
|
+
* Create a new instance of the DomainSigner class.
|
|
39
|
+
* @constructor
|
|
40
|
+
* @param {string} url - The URL of the domain server.
|
|
41
|
+
* @param {HttpHeaders} headers - The HTTP headers for requests to the domain server.
|
|
42
|
+
* These headers can be used for authentication purposes.
|
|
43
|
+
*/
|
|
44
|
+
constructor(url: string, headers: HttpHeaders);
|
|
45
|
+
signWithClientAccount({ transaction, accountKp, }: SignWithClientAccountParams): Transaction;
|
|
46
|
+
signWithDomainAccount({ transactionXDR, networkPassphrase, accountKp, }: SignWithDomainAccountParams): Promise<Transaction>;
|
|
47
|
+
}
|
|
@@ -8,12 +8,33 @@ type Sep10Params = {
|
|
|
8
8
|
homeDomain: string;
|
|
9
9
|
httpClient: AxiosInstance;
|
|
10
10
|
};
|
|
11
|
+
/**
|
|
12
|
+
* Sep-10 used for authentication to an external server.
|
|
13
|
+
* @see {@link https://github.com/stellar/stellar-protocol/blob/master/ecosystem/sep-0010.md}
|
|
14
|
+
* Do not create this object directly, use the Anchor class.
|
|
15
|
+
* @class
|
|
16
|
+
*/
|
|
11
17
|
export declare class Sep10 {
|
|
12
18
|
private cfg;
|
|
13
19
|
private webAuthEndpoint;
|
|
14
20
|
private homeDomain;
|
|
15
21
|
private httpClient;
|
|
22
|
+
/**
|
|
23
|
+
* Creates a new instance of the Sep10 class.
|
|
24
|
+
*
|
|
25
|
+
* @constructor
|
|
26
|
+
* @param {Sep10Params} params - Parameters to initialize the Sep10 instance.
|
|
27
|
+
*/
|
|
16
28
|
constructor(params: Sep10Params);
|
|
29
|
+
/**
|
|
30
|
+
* Initiates the authentication process using SEP-10.
|
|
31
|
+
* @param {AuthenticateParams} params - The Authentication params.
|
|
32
|
+
* @param {AccountKeypair} params.accountKp - Keypair for the Stellar account being authenticated.
|
|
33
|
+
* @param {WalletSigner} [params.walletSigner] - Signer for signing transactions (defaults to the configuration default signer).
|
|
34
|
+
* @param {string} [params.memoId] - Memo ID to distinguish the account.
|
|
35
|
+
* @param {string} [params.clientDomain] - Domain hosting stellar.toml file containing `SIGNING_KEY`.
|
|
36
|
+
* @returns {Promise<AuthToken>} The authentication token.
|
|
37
|
+
*/
|
|
17
38
|
authenticate({ accountKp, walletSigner, memoId, clientDomain, }: AuthenticateParams): Promise<AuthToken>;
|
|
18
39
|
private challenge;
|
|
19
40
|
private sign;
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { AxiosInstance } from "axios";
|
|
2
|
+
import { GetCustomerParams, GetCustomerResponse, AddCustomerResponse, AddCustomerParams, AuthToken } from "../Types";
|
|
3
|
+
/**
|
|
4
|
+
* KYC management with Sep-12.
|
|
5
|
+
* @see {@link https://github.com/stellar/stellar-protocol/blob/master/ecosystem/sep-0012.md}
|
|
6
|
+
* Do not create this object directly, use the Anchor class.
|
|
7
|
+
* @class
|
|
8
|
+
*/
|
|
9
|
+
export declare class Sep12 {
|
|
10
|
+
private authToken;
|
|
11
|
+
private baseUrl;
|
|
12
|
+
private httpClient;
|
|
13
|
+
private headers;
|
|
14
|
+
/**
|
|
15
|
+
* Creates a new instance of the Sep12 class.
|
|
16
|
+
* @constructor
|
|
17
|
+
* @param {AuthToken} authToken - The authentication token for authenticating with the server.
|
|
18
|
+
* @param {string} baseUrl - The KYC url.
|
|
19
|
+
* @param {AxiosInstance} httpClient - An Axios instance for making HTTP requests.
|
|
20
|
+
*/
|
|
21
|
+
constructor(authToken: AuthToken, baseUrl: string, httpClient: AxiosInstance);
|
|
22
|
+
/**
|
|
23
|
+
* Retrieve customer information. All arguments are optional, but at least one
|
|
24
|
+
* must be given. For more information:
|
|
25
|
+
* @see {@link https://github.com/stellar/stellar-protocol/blob/master/ecosystem/sep-0012.md#request}
|
|
26
|
+
* @param {object} params - The parameters for retrieving customer information.
|
|
27
|
+
* @param {string} [params.id] - The id of the customer .
|
|
28
|
+
* @param {string} [params.type] - The type of action the customer is being KYCd for.
|
|
29
|
+
* @see {@link https://github.com/stellar/stellar-protocol/blob/master/ecosystem/sep-0012.md#type-specification}
|
|
30
|
+
* @param {string} [params.memo] - A memo associated with the customer.
|
|
31
|
+
* @param {string} [params.lang] - The desired language. Defaults to "en".
|
|
32
|
+
* @returns {Promise<GetCustomerResponse>} The customer information.
|
|
33
|
+
* @throws {CustomerNotFoundError} If the customer is not found.
|
|
34
|
+
*/
|
|
35
|
+
getCustomer(params: GetCustomerParams): Promise<GetCustomerResponse>;
|
|
36
|
+
/**
|
|
37
|
+
* Add a new customer. Customer info is given in sep9Info param. If it
|
|
38
|
+
* is binary type (eg. Buffer of an image) include it in sep9BinaryInfo.
|
|
39
|
+
* @param {AddCustomerParams} params - The parameters for adding a customer.
|
|
40
|
+
* @param {CustomerInfoMap} [params.sep9Info] - Customer information. What fields you should
|
|
41
|
+
* give is indicated by the anchor.
|
|
42
|
+
* @param {CustomerInfoMap} [params.sep9BinaryInfo] - Customer information that is in binary
|
|
43
|
+
* format (eg. Buffer of an image).
|
|
44
|
+
* @param {string} [params.type] - The type of the customer.
|
|
45
|
+
* @param {string} [params.memo] - A memo associated with the customer.
|
|
46
|
+
* @returns {Promise<AddCustomerResponse>} Add customer response.
|
|
47
|
+
*/
|
|
48
|
+
add({ sep9Info, sep9BinaryInfo, type, memo, }: AddCustomerParams): Promise<AddCustomerResponse>;
|
|
49
|
+
/**
|
|
50
|
+
* Updates an existing customer. Customer info is given in sep9Info param. If it
|
|
51
|
+
* is binary type (eg. Buffer of an image) include it in sep9BinaryInfo.
|
|
52
|
+
* @param {AddCustomerParams} params - The parameters for adding a customer.
|
|
53
|
+
* @param {CustomerInfoMap} [params.sep9Info] - Customer information. What fields you should
|
|
54
|
+
* give is indicated by the anchor.
|
|
55
|
+
* @param {CustomerInfoMap} [params.sep9BinaryInfo] - Customer information that is in binary
|
|
56
|
+
* format (eg. Buffer of an image).
|
|
57
|
+
* @param {string} [params.id] - The id of the customer.
|
|
58
|
+
* @param {string} [params.type] - The type of the customer.
|
|
59
|
+
* @param {string} [params.memo] - A memo associated with the customer.
|
|
60
|
+
* @returns {Promise<AddCustomerResponse>} Add customer response.
|
|
61
|
+
* @throws {Sep9InfoRequiredError} If no SEP-9 info is given.
|
|
62
|
+
*/
|
|
63
|
+
update({ sep9Info, sep9BinaryInfo, id, type, memo, }: AddCustomerParams): Promise<AddCustomerResponse>;
|
|
64
|
+
/**
|
|
65
|
+
* Deletes a customer.
|
|
66
|
+
* @param {string} accountAddress - The account address of the customer to delete.
|
|
67
|
+
* @param {string} [memo] - An optional memo for customer identification.
|
|
68
|
+
*/
|
|
69
|
+
delete(accountAddress?: string, memo?: string): Promise<void>;
|
|
70
|
+
}
|