@stellar/typescript-wallet-sdk 1.2.1 → 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 +6563 -2344
- package/lib/bundle.js.map +1 -1
- package/lib/bundle_browser.js +6005 -1833
- 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 +21 -3
- 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 +41 -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 +39 -0
- package/lib/walletSdk/Horizon/Transaction/SponsoringBuilder.d.ts +29 -1
- package/lib/walletSdk/Horizon/Transaction/TransactionBuilder.d.ts +81 -13
- package/lib/walletSdk/Horizon/index.d.ts +2 -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 +11 -1
- package/lib/walletSdk/Types/horizon.d.ts +6 -5
- package/lib/walletSdk/Types/index.d.ts +8 -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/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 +41 -4
- 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 +100 -3
- package/src/walletSdk/Horizon/AccountService.ts +33 -21
- package/src/walletSdk/Horizon/Stellar.ts +89 -6
- 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 +9 -3
- 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/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 +43 -23
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { Memo,
|
|
1
|
+
import { Memo, Horizon, Transaction } from "stellar-sdk";
|
|
2
2
|
import { AccountKeypair } from "../Horizon/Account";
|
|
3
|
-
import { TransactionBuilder } from "
|
|
3
|
+
import { SponsoringBuilder, TransactionBuilder } from "walletSdk/Horizon";
|
|
4
4
|
import { StellarAssetId } from "../Asset";
|
|
5
5
|
export declare enum NETWORK_URLS {
|
|
6
6
|
PUBLIC = "https://horizon.stellar.org",
|
|
@@ -10,7 +10,7 @@ export type TransactionParams = {
|
|
|
10
10
|
sourceAddress: AccountKeypair;
|
|
11
11
|
baseFee?: number;
|
|
12
12
|
memo?: Memo;
|
|
13
|
-
timebounds?: Server.Timebounds | number;
|
|
13
|
+
timebounds?: Horizon.Server.Timebounds | number;
|
|
14
14
|
};
|
|
15
15
|
export type FeeBumpTransactionParams = {
|
|
16
16
|
feeAddress: AccountKeypair;
|
|
@@ -21,8 +21,8 @@ export type SubmitWithFeeIncreaseParams = {
|
|
|
21
21
|
sourceAddress: AccountKeypair;
|
|
22
22
|
timeout: number;
|
|
23
23
|
baseFeeIncrease: number;
|
|
24
|
-
buildingFunction: (
|
|
25
|
-
signerFunction?: (
|
|
24
|
+
buildingFunction: (builder: TransactionBuilder) => TransactionBuilder;
|
|
25
|
+
signerFunction?: (transaction: Transaction) => Transaction;
|
|
26
26
|
baseFee?: number;
|
|
27
27
|
memo?: Memo;
|
|
28
28
|
maxFee?: number;
|
|
@@ -42,3 +42,4 @@ export type PathPayParams = {
|
|
|
42
42
|
destMin?: string;
|
|
43
43
|
sendMax?: string;
|
|
44
44
|
};
|
|
45
|
+
export type CommonBuilder = TransactionBuilder | SponsoringBuilder;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { RawAxiosRequestHeaders } from "axios";
|
|
2
|
-
import {
|
|
2
|
+
import { Networks } from "stellar-sdk";
|
|
3
3
|
import { ApplicationConfiguration, StellarConfiguration } from "walletSdk";
|
|
4
|
+
import { RecoveryServerMap } from "./recovery";
|
|
4
5
|
export type WalletParams = {
|
|
5
6
|
stellarConfiguration: StellarConfiguration;
|
|
6
7
|
applicationConfiguration?: ApplicationConfiguration;
|
|
@@ -10,8 +11,8 @@ export type WalletAnchor = {
|
|
|
10
11
|
homeDomain: string;
|
|
11
12
|
language?: string;
|
|
12
13
|
};
|
|
13
|
-
export type
|
|
14
|
-
servers:
|
|
14
|
+
export type WalletRecoveryServers = {
|
|
15
|
+
servers: RecoveryServerMap;
|
|
15
16
|
};
|
|
16
17
|
export type ConfigParams = {
|
|
17
18
|
stellarConfiguration: StellarConfiguration;
|
|
@@ -32,6 +33,10 @@ export type AxiosErrorData = {
|
|
|
32
33
|
export * from "./anchor";
|
|
33
34
|
export * from "./auth";
|
|
34
35
|
export * from "./horizon";
|
|
36
|
+
export * from "./recovery";
|
|
37
|
+
export * from "./sep6";
|
|
38
|
+
export * from "./sep12";
|
|
35
39
|
export * from "./sep24";
|
|
40
|
+
export * from "./sep38";
|
|
36
41
|
export * from "./utils";
|
|
37
42
|
export * from "./watcher";
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
import { Transaction } from "stellar-sdk";
|
|
2
|
+
import { WalletSigner } from "walletSdk/Auth";
|
|
3
|
+
import { AccountKeypair, PublicKeypair } from "walletSdk/Horizon";
|
|
4
|
+
import { AuthToken } from "./auth";
|
|
5
|
+
import { CommonBuilder } from "./horizon";
|
|
6
|
+
/**
|
|
7
|
+
* Configuration for recoverable wallet
|
|
8
|
+
* @param accountAddress Stellar address of the account that is registering
|
|
9
|
+
* @param deviceAddress Stellar address of the device that is added as a primary signer. It will
|
|
10
|
+
* replace the master key of [accountAddress]
|
|
11
|
+
* @param accountThreshold Low, medium, and high thresholds to set on the account
|
|
12
|
+
* @param accountIdentity A list of account identities to be registered with the recovery servers
|
|
13
|
+
* @param signerWeight Signer weight of the device and recovery keys to set
|
|
14
|
+
* @param sponsorAddress optional Stellar address of the account sponsoring this transaction
|
|
15
|
+
*/
|
|
16
|
+
export type RecoverableWalletConfig = {
|
|
17
|
+
accountAddress: AccountKeypair;
|
|
18
|
+
deviceAddress: AccountKeypair;
|
|
19
|
+
accountThreshold: AccountThreshold;
|
|
20
|
+
accountIdentity: RecoveryIdentityMap;
|
|
21
|
+
signerWeight: SignerWeight;
|
|
22
|
+
sponsorAddress?: AccountKeypair;
|
|
23
|
+
builderExtra?: (builder: CommonBuilder) => CommonBuilder;
|
|
24
|
+
};
|
|
25
|
+
export type RecoverableWallet = {
|
|
26
|
+
transaction: Transaction;
|
|
27
|
+
signers: string[];
|
|
28
|
+
};
|
|
29
|
+
export type AccountSigner = {
|
|
30
|
+
address: AccountKeypair;
|
|
31
|
+
weight: number;
|
|
32
|
+
};
|
|
33
|
+
/**
|
|
34
|
+
* Account weights threshold
|
|
35
|
+
* @param low Low threshold weight
|
|
36
|
+
* @param medium Medium threshold weight
|
|
37
|
+
* @param high High threshold weight
|
|
38
|
+
*/
|
|
39
|
+
export type AccountThreshold = {
|
|
40
|
+
low: number;
|
|
41
|
+
medium: number;
|
|
42
|
+
high: number;
|
|
43
|
+
};
|
|
44
|
+
export type SignerWeight = {
|
|
45
|
+
device: number;
|
|
46
|
+
recoveryServer: number;
|
|
47
|
+
};
|
|
48
|
+
/**
|
|
49
|
+
* Recovery server configuration
|
|
50
|
+
* @property {string} endpoint - Main endpoint (root domain) of SEP-30 recovery server. E.g. `https://testanchor.stellar.org`
|
|
51
|
+
* @property {string} authEndpoint - SEP-10 auth endpoint to be used. Should be in the format `<https://domain/auth>`. E.g. `https://testanchor.stellar.org/auth`
|
|
52
|
+
* @property {string} homeDomain - SEP-10 home domain. E.g. `testanchor.stellar.org`
|
|
53
|
+
* @property {WalletSigner} [walletSigner] - WalletSigner used to sign authentication
|
|
54
|
+
*/
|
|
55
|
+
export type RecoveryServer = {
|
|
56
|
+
endpoint: string;
|
|
57
|
+
authEndpoint: string;
|
|
58
|
+
homeDomain: string;
|
|
59
|
+
walletSigner?: WalletSigner;
|
|
60
|
+
clientDomain?: string;
|
|
61
|
+
};
|
|
62
|
+
export type RecoveryServerKey = string;
|
|
63
|
+
export type RecoveryServerSigning = {
|
|
64
|
+
signerAddress: string;
|
|
65
|
+
authToken: AuthToken;
|
|
66
|
+
};
|
|
67
|
+
export type RecoveryServerSigningMap = {
|
|
68
|
+
[key: RecoveryServerKey]: RecoveryServerSigning;
|
|
69
|
+
};
|
|
70
|
+
export type RecoveryServerMap = {
|
|
71
|
+
[key: RecoveryServerKey]: RecoveryServer;
|
|
72
|
+
};
|
|
73
|
+
export type RecoveryAuthMap = {
|
|
74
|
+
[key: RecoveryServerKey]: AuthToken;
|
|
75
|
+
};
|
|
76
|
+
/**
|
|
77
|
+
* The role of the identity. This value is not used by the server and is stored and echoed back in
|
|
78
|
+
* responses as a way for a client to know conceptually who each identity represents
|
|
79
|
+
*/
|
|
80
|
+
export declare enum RecoveryRole {
|
|
81
|
+
OWNER = "owner",
|
|
82
|
+
SENDER = "sender",
|
|
83
|
+
RECEIVER = "receiver"
|
|
84
|
+
}
|
|
85
|
+
export declare enum RecoveryType {
|
|
86
|
+
STELLAR_ADDRESS = "stellar_address",
|
|
87
|
+
PHONE_NUMBER = "phone_number",
|
|
88
|
+
EMAIL = "email"
|
|
89
|
+
}
|
|
90
|
+
export type RecoveryAccountAuthMethod = {
|
|
91
|
+
type: RecoveryType;
|
|
92
|
+
value: string;
|
|
93
|
+
};
|
|
94
|
+
export type RecoveryAccountIdentity = {
|
|
95
|
+
role: RecoveryRole;
|
|
96
|
+
authMethods: RecoveryAccountAuthMethod[];
|
|
97
|
+
};
|
|
98
|
+
export type RecoveryIdentityMap = {
|
|
99
|
+
[key: RecoveryServerKey]: RecoveryAccountIdentity[];
|
|
100
|
+
};
|
|
101
|
+
export type RecoveryAccountRole = {
|
|
102
|
+
role: RecoveryRole;
|
|
103
|
+
authenticated?: boolean;
|
|
104
|
+
};
|
|
105
|
+
export type RecoveryAccountSigner = {
|
|
106
|
+
key: string;
|
|
107
|
+
};
|
|
108
|
+
export type RecoveryAccount = {
|
|
109
|
+
address: string;
|
|
110
|
+
identities: RecoveryAccountRole[];
|
|
111
|
+
signers: RecoveryAccountSigner[];
|
|
112
|
+
};
|
|
113
|
+
export type RecoverableIdentity = {
|
|
114
|
+
role: string;
|
|
115
|
+
authenticated?: boolean;
|
|
116
|
+
};
|
|
117
|
+
export type RecoverableSigner = {
|
|
118
|
+
key: PublicKeypair;
|
|
119
|
+
addedAt?: Date;
|
|
120
|
+
};
|
|
121
|
+
export type RecoverableAccountInfo = {
|
|
122
|
+
address: PublicKeypair;
|
|
123
|
+
identities: RecoverableIdentity[];
|
|
124
|
+
signers: RecoverableSigner[];
|
|
125
|
+
};
|
|
126
|
+
export type RecoveryAccountInfoMap = {
|
|
127
|
+
[key: RecoveryServerKey]: RecoverableAccountInfo;
|
|
128
|
+
};
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
export type CustomerInfoMap = {
|
|
2
|
+
[key: string]: string;
|
|
3
|
+
};
|
|
4
|
+
export declare enum Sep12Status {
|
|
5
|
+
ACCEPTED = "ACCEPTED",
|
|
6
|
+
PROCESSING = "PROCESSING",
|
|
7
|
+
NEEDS_INFO = "NEEDS_INFO",
|
|
8
|
+
REJECTED = "REJECTED",
|
|
9
|
+
VERIFICATION_REQUIRED = "VERIFICATION_REQUIRED"
|
|
10
|
+
}
|
|
11
|
+
export declare enum Sep12Type {
|
|
12
|
+
string = "string",
|
|
13
|
+
binary = "binary",
|
|
14
|
+
number = "number",
|
|
15
|
+
date = "date"
|
|
16
|
+
}
|
|
17
|
+
export type Field = {
|
|
18
|
+
type: Sep12Type;
|
|
19
|
+
description: string;
|
|
20
|
+
choices?: Array<string>;
|
|
21
|
+
optional?: boolean;
|
|
22
|
+
};
|
|
23
|
+
export type ProvidedField = {
|
|
24
|
+
type: Sep12Type;
|
|
25
|
+
description: string;
|
|
26
|
+
choices?: Array<string>;
|
|
27
|
+
optional?: boolean;
|
|
28
|
+
status?: Sep12Status;
|
|
29
|
+
error?: string;
|
|
30
|
+
};
|
|
31
|
+
export type GetCustomerParams = {
|
|
32
|
+
id?: string;
|
|
33
|
+
type?: string;
|
|
34
|
+
memo?: string;
|
|
35
|
+
lang?: string;
|
|
36
|
+
};
|
|
37
|
+
export type GetCustomerResponse = {
|
|
38
|
+
id?: string;
|
|
39
|
+
status: Sep12Status;
|
|
40
|
+
fields?: {
|
|
41
|
+
[key: string]: Field;
|
|
42
|
+
};
|
|
43
|
+
provided_fields?: {
|
|
44
|
+
[key: string]: ProvidedField;
|
|
45
|
+
};
|
|
46
|
+
message?: string;
|
|
47
|
+
};
|
|
48
|
+
export type AddCustomerParams = {
|
|
49
|
+
sep9Info?: CustomerInfoMap;
|
|
50
|
+
sep9BinaryInfo?: CustomerInfoMap;
|
|
51
|
+
id?: string;
|
|
52
|
+
memo?: string;
|
|
53
|
+
type?: string;
|
|
54
|
+
};
|
|
55
|
+
export type AddCustomerResponse = {
|
|
56
|
+
id: string;
|
|
57
|
+
};
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import { AxiosInstance } from "axios";
|
|
2
|
+
import { Anchor } from "../Anchor";
|
|
3
|
+
import { AuthToken } from "./auth";
|
|
4
|
+
export interface Sep38Info {
|
|
5
|
+
assets: Array<Sep38AssetInfo>;
|
|
6
|
+
}
|
|
7
|
+
export interface Sep38AssetInfo {
|
|
8
|
+
asset: string;
|
|
9
|
+
sell_delivery_methods?: Array<Sep38DeliveryMethod>;
|
|
10
|
+
buy_delivery_methods?: Array<Sep38DeliveryMethod>;
|
|
11
|
+
country_codes?: Array<string>;
|
|
12
|
+
}
|
|
13
|
+
export interface Sep38DeliveryMethod {
|
|
14
|
+
name: string;
|
|
15
|
+
description: string;
|
|
16
|
+
}
|
|
17
|
+
export type Sep38Params = {
|
|
18
|
+
anchor: Anchor;
|
|
19
|
+
httpClient: AxiosInstance;
|
|
20
|
+
authToken?: AuthToken;
|
|
21
|
+
};
|
|
22
|
+
export interface Sep38PricesParams {
|
|
23
|
+
sellAsset: string;
|
|
24
|
+
sellAmount: string;
|
|
25
|
+
sellDeliveryMethod?: string;
|
|
26
|
+
buyDeliveryMethod?: string;
|
|
27
|
+
countryCode?: string;
|
|
28
|
+
}
|
|
29
|
+
export interface Sep38PricesResponse {
|
|
30
|
+
buy_assets: Array<Sep38BuyAsset>;
|
|
31
|
+
}
|
|
32
|
+
export interface Sep38BuyAsset {
|
|
33
|
+
asset: string;
|
|
34
|
+
price: string;
|
|
35
|
+
decimals: number;
|
|
36
|
+
}
|
|
37
|
+
export interface Sep38PriceParams {
|
|
38
|
+
sellAsset: string;
|
|
39
|
+
buyAsset: string;
|
|
40
|
+
sellAmount?: string;
|
|
41
|
+
buyAmount?: string;
|
|
42
|
+
context: Sep38PriceContext;
|
|
43
|
+
sellDeliveryMethod?: string;
|
|
44
|
+
buyDeliveryMethod?: string;
|
|
45
|
+
countryCode?: string;
|
|
46
|
+
}
|
|
47
|
+
export declare enum Sep38PriceContext {
|
|
48
|
+
SEP6 = "sep6",
|
|
49
|
+
SEP24 = "sep24",
|
|
50
|
+
SEP31 = "sep31"
|
|
51
|
+
}
|
|
52
|
+
export interface Sep38PriceResponse {
|
|
53
|
+
total_price: string;
|
|
54
|
+
price: string;
|
|
55
|
+
sell_amount: string;
|
|
56
|
+
buy_amount: string;
|
|
57
|
+
fee: {
|
|
58
|
+
total: string;
|
|
59
|
+
asset: string;
|
|
60
|
+
details?: Array<Sep38FeeDetails>;
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
export interface Sep38FeeDetails {
|
|
64
|
+
name: string;
|
|
65
|
+
description?: string;
|
|
66
|
+
amount: string;
|
|
67
|
+
}
|
|
68
|
+
export interface Sep38PostQuoteParams {
|
|
69
|
+
sell_asset: string;
|
|
70
|
+
buy_asset: string;
|
|
71
|
+
sell_amount: string;
|
|
72
|
+
buy_amount: string;
|
|
73
|
+
context: Sep38PriceContext;
|
|
74
|
+
expire_after?: string;
|
|
75
|
+
sell_delivery_method?: string;
|
|
76
|
+
buy_delivery_method?: string;
|
|
77
|
+
country_code?: string;
|
|
78
|
+
}
|
|
79
|
+
export interface Sep38PostQuoteResponse {
|
|
80
|
+
id: string;
|
|
81
|
+
expires_at: string;
|
|
82
|
+
total_price: string;
|
|
83
|
+
price: string;
|
|
84
|
+
sell_asset: string;
|
|
85
|
+
sell_amount: string;
|
|
86
|
+
buy_asset: string;
|
|
87
|
+
buy_amount: string;
|
|
88
|
+
fee: {
|
|
89
|
+
total: string;
|
|
90
|
+
asset: string;
|
|
91
|
+
details?: Array<Sep38FeeDetails>;
|
|
92
|
+
};
|
|
93
|
+
}
|
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
import { AxiosInstance } from "axios";
|
|
2
|
+
import { Anchor } from "../Anchor";
|
|
3
|
+
export interface Sep6EndpointInfo {
|
|
4
|
+
enabled: boolean;
|
|
5
|
+
authentication_required?: boolean;
|
|
6
|
+
description?: string;
|
|
7
|
+
}
|
|
8
|
+
export interface Sep6DepositInfo {
|
|
9
|
+
enabled: boolean;
|
|
10
|
+
authentication_required?: boolean;
|
|
11
|
+
fee_fixed?: number;
|
|
12
|
+
fee_percent?: number;
|
|
13
|
+
min_amount?: number;
|
|
14
|
+
max_amount?: number;
|
|
15
|
+
fields?: {
|
|
16
|
+
[key: string]: {
|
|
17
|
+
description: string;
|
|
18
|
+
optional?: boolean;
|
|
19
|
+
choices?: string[];
|
|
20
|
+
};
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
export interface Sep6WithdrawInfo {
|
|
24
|
+
enabled: boolean;
|
|
25
|
+
authentication_required?: boolean;
|
|
26
|
+
fee_fixed?: number;
|
|
27
|
+
fee_percent?: number;
|
|
28
|
+
min_amount?: number;
|
|
29
|
+
max_amount?: number;
|
|
30
|
+
types?: {
|
|
31
|
+
[key: string]: {
|
|
32
|
+
fields?: {
|
|
33
|
+
[key: string]: {
|
|
34
|
+
description: string;
|
|
35
|
+
optional?: boolean;
|
|
36
|
+
choices?: string[];
|
|
37
|
+
};
|
|
38
|
+
};
|
|
39
|
+
};
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
export interface Sep6Info {
|
|
43
|
+
deposit: {
|
|
44
|
+
[key: string]: Sep6DepositInfo;
|
|
45
|
+
};
|
|
46
|
+
"deposit-exchange": {
|
|
47
|
+
[key: string]: Sep6DepositInfo;
|
|
48
|
+
};
|
|
49
|
+
withdraw: {
|
|
50
|
+
[key: string]: Sep6WithdrawInfo;
|
|
51
|
+
};
|
|
52
|
+
"withdraw-exchange": {
|
|
53
|
+
[key: string]: Sep6WithdrawInfo;
|
|
54
|
+
};
|
|
55
|
+
fee: {
|
|
56
|
+
enabled: boolean;
|
|
57
|
+
description: string;
|
|
58
|
+
};
|
|
59
|
+
transactions: Sep6EndpointInfo;
|
|
60
|
+
transaction: Sep6EndpointInfo;
|
|
61
|
+
features: {
|
|
62
|
+
account_creation: boolean;
|
|
63
|
+
claimable_balances: boolean;
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
export type Sep6Params = {
|
|
67
|
+
anchor: Anchor;
|
|
68
|
+
httpClient: AxiosInstance;
|
|
69
|
+
};
|
|
70
|
+
export interface Sep6DepositParams {
|
|
71
|
+
asset_code: string;
|
|
72
|
+
account: string;
|
|
73
|
+
memo_type?: string;
|
|
74
|
+
memo?: string;
|
|
75
|
+
email_address?: string;
|
|
76
|
+
type?: string;
|
|
77
|
+
lang?: string;
|
|
78
|
+
on_change_callback?: string;
|
|
79
|
+
amount?: string;
|
|
80
|
+
country_code?: string;
|
|
81
|
+
claimable_balance_supported?: string;
|
|
82
|
+
customer_id?: string;
|
|
83
|
+
}
|
|
84
|
+
export interface Sep6WithdrawParams {
|
|
85
|
+
asset_code: string;
|
|
86
|
+
type: string;
|
|
87
|
+
dest?: string;
|
|
88
|
+
dest_extra?: string;
|
|
89
|
+
account?: string;
|
|
90
|
+
memo?: string;
|
|
91
|
+
lang?: string;
|
|
92
|
+
on_change_callback?: string;
|
|
93
|
+
amount?: string;
|
|
94
|
+
country_code?: string;
|
|
95
|
+
refund_memo?: string;
|
|
96
|
+
refund_memo_type?: string;
|
|
97
|
+
customer_id?: string;
|
|
98
|
+
}
|
|
99
|
+
export type Sep6DepositResponse = Sep6DepositSuccess | Sep6MissingKYC | Sep6Pending;
|
|
100
|
+
export interface Sep6DepositSuccess {
|
|
101
|
+
how?: string;
|
|
102
|
+
instructions?: {
|
|
103
|
+
[key: string]: {
|
|
104
|
+
value: string;
|
|
105
|
+
description: string;
|
|
106
|
+
};
|
|
107
|
+
};
|
|
108
|
+
id?: string;
|
|
109
|
+
eta?: number;
|
|
110
|
+
min_amoun?: number;
|
|
111
|
+
max_amount?: number;
|
|
112
|
+
fee_fixed?: number;
|
|
113
|
+
fee_percent?: number;
|
|
114
|
+
extra_info?: {
|
|
115
|
+
message?: string;
|
|
116
|
+
};
|
|
117
|
+
}
|
|
118
|
+
export interface Sep6MissingKYC {
|
|
119
|
+
type: string;
|
|
120
|
+
fields: Array<string>;
|
|
121
|
+
}
|
|
122
|
+
export interface Sep6Pending {
|
|
123
|
+
type: string;
|
|
124
|
+
status: string;
|
|
125
|
+
more_info_url?: string;
|
|
126
|
+
eta?: number;
|
|
127
|
+
}
|
|
128
|
+
export type Sep6WithdrawResponse = Sep6WithdrawSuccess | Sep6MissingKYC | Sep6Pending;
|
|
129
|
+
export interface Sep6WithdrawSuccess {
|
|
130
|
+
account_id?: string;
|
|
131
|
+
memo_type?: string;
|
|
132
|
+
memo?: string;
|
|
133
|
+
id?: string;
|
|
134
|
+
eta?: number;
|
|
135
|
+
min_amount?: number;
|
|
136
|
+
max_amount?: number;
|
|
137
|
+
fee_fixed?: number;
|
|
138
|
+
fee_percent?: number;
|
|
139
|
+
extra_info?: {
|
|
140
|
+
message?: string;
|
|
141
|
+
};
|
|
142
|
+
}
|
|
143
|
+
export interface Sep6ExchangeParams {
|
|
144
|
+
destination_asset: string;
|
|
145
|
+
source_asset: string;
|
|
146
|
+
amount: string;
|
|
147
|
+
account?: string;
|
|
148
|
+
quote_id?: string;
|
|
149
|
+
memo_type?: string;
|
|
150
|
+
memo?: string;
|
|
151
|
+
email_address?: string;
|
|
152
|
+
type?: string;
|
|
153
|
+
lang?: string;
|
|
154
|
+
on_change_callback?: string;
|
|
155
|
+
country_code?: string;
|
|
156
|
+
claimable_balance_supported?: string;
|
|
157
|
+
customer_id?: string;
|
|
158
|
+
refund_memo?: string;
|
|
159
|
+
refund_memo_type?: string;
|
|
160
|
+
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { AnchorTransaction } from "./anchor";
|
|
2
|
+
import { AuthToken } from "./auth";
|
|
2
3
|
export type WatchTransactionsParams = {
|
|
3
|
-
authToken:
|
|
4
|
+
authToken: AuthToken;
|
|
4
5
|
assetCode: string;
|
|
5
6
|
onMessage: (transaction: AnchorTransaction) => void;
|
|
6
7
|
onError: (error: AnchorTransaction | Error) => void;
|
|
@@ -12,7 +13,7 @@ export type WatchTransactionsParams = {
|
|
|
12
13
|
noOlderThan?: string;
|
|
13
14
|
};
|
|
14
15
|
export type WatchTransactionParams = {
|
|
15
|
-
authToken:
|
|
16
|
+
authToken: AuthToken;
|
|
16
17
|
assetCode: string;
|
|
17
18
|
id: string;
|
|
18
19
|
onMessage: (transaction: AnchorTransaction) => void;
|
|
@@ -28,3 +29,7 @@ export interface WatcherResponse {
|
|
|
28
29
|
refresh: WatcherRefreshFunction;
|
|
29
30
|
stop: WatcherStopFunction;
|
|
30
31
|
}
|
|
32
|
+
export declare enum WatcherSepType {
|
|
33
|
+
SEP6 = "SEP6",
|
|
34
|
+
SEP24 = "SEP24"
|
|
35
|
+
}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { StellarToml } from "stellar-sdk";
|
|
2
2
|
import { TomlInfo } from "../Types";
|
|
3
|
-
export declare const parseToml: (toml:
|
|
3
|
+
export declare const parseToml: (toml: StellarToml.Api.StellarToml) => TomlInfo;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { AxiosInstance } from "axios";
|
|
2
|
+
import { AuthToken } from "../Types";
|
|
3
|
+
export declare const _getTransactionsForAsset: <T>(authToken: AuthToken, params: {
|
|
4
|
+
[key: string]: string | number;
|
|
5
|
+
}, endpoint: string, client: AxiosInstance) => Promise<T[]>;
|
|
6
|
+
export declare const _getTransactionBy: <T>(authToken: AuthToken, params: {
|
|
7
|
+
[key: string]: string | number;
|
|
8
|
+
}, endpoint: string, client: AxiosInstance) => Promise<T>;
|
|
@@ -1,25 +1,50 @@
|
|
|
1
1
|
import { Anchor } from "../Anchor";
|
|
2
|
-
import { WatchTransactionParams, WatchTransactionsParams, WatcherResponse } from "../Types";
|
|
2
|
+
import { WatchTransactionParams, WatchTransactionsParams, WatcherResponse, WatcherSepType } from "../Types";
|
|
3
|
+
/**
|
|
4
|
+
* Used for watching transaction from an Anchor as part of sep-24.
|
|
5
|
+
* Do not create this object directly, use the Anchor class.
|
|
6
|
+
* @class
|
|
7
|
+
*/
|
|
3
8
|
export declare class Watcher {
|
|
4
9
|
private anchor;
|
|
10
|
+
private sepType;
|
|
5
11
|
private _oneTransactionWatcher;
|
|
6
12
|
private _allTransactionsWatcher?;
|
|
7
13
|
private _watchOneTransactionRegistry;
|
|
8
14
|
private _watchAllTransactionsRegistry;
|
|
9
15
|
private _transactionsRegistry;
|
|
10
16
|
private _transactionsIgnoredRegistry;
|
|
11
|
-
|
|
17
|
+
/**
|
|
18
|
+
* Creates a new instance of the Watcher class.
|
|
19
|
+
*
|
|
20
|
+
* @param {Anchor} anchor - The Anchor to watch from.
|
|
21
|
+
* @param {WatcherSepType} sepType - The Sep type the anchor being polled is using
|
|
22
|
+
* (ie. Sep-6 or Sep-24).
|
|
23
|
+
*/
|
|
24
|
+
constructor(anchor: Anchor, sepType: WatcherSepType);
|
|
12
25
|
/**
|
|
13
26
|
* Watch all transactions returned from a transfer server. When new or
|
|
14
27
|
* updated transactions come in, run an `onMessage` callback.
|
|
15
28
|
*
|
|
16
29
|
* On initial load, it'll return ALL pending transactions via onMessage.
|
|
17
30
|
* Subsequent messages will be any one of these events:
|
|
18
|
-
*
|
|
19
|
-
*
|
|
31
|
+
* - Any new transaction appears
|
|
32
|
+
* - Any of the initial pending transactions change any state
|
|
20
33
|
*
|
|
21
34
|
* You may also provide an array of transaction ids, `watchlist`, and this
|
|
22
35
|
* watcher will always react to transactions whose ids are in the watchlist.
|
|
36
|
+
* @param {WatchTransactionsParams} params - The Watch Transactions params.
|
|
37
|
+
* @param {AuthToken} params.authToken - The authentication token used for authenticating with the anchor.
|
|
38
|
+
* @param {string} params.assetCode - The asset code to filter transactions by.
|
|
39
|
+
* @param {Function} params.onMessage - A callback function to handle incoming transaction messages.
|
|
40
|
+
* @param {Function} params.onError - A callback function to handle errors during transaction streaming.
|
|
41
|
+
* @param {Array<string>} [params.watchlist=[]] - An optional array of specific transaction IDs to watch.
|
|
42
|
+
* @param {number} [params.timeout=5000] - The timeout duration for the streaming connection (in milliseconds).
|
|
43
|
+
* @param {boolean} [params.isRetry=false] - Indicates whether this is a retry attempt (optional).
|
|
44
|
+
* @param {string} [params.lang=this.anchor.language] - The desired language (localization) for transaction messages.
|
|
45
|
+
* @param {string} params.kind - The kind of transaction to filter by.
|
|
46
|
+
* @param {string} [params.noOlderThan] - A date and time specifying that transactions older than this value should not be included.
|
|
47
|
+
* @returns {WatcherResponse} An object holding the refresh and stop functions for the watcher.
|
|
23
48
|
*/
|
|
24
49
|
watchAllTransactions({ authToken, assetCode, onMessage, onError, watchlist, timeout, isRetry, lang, kind, noOlderThan, }: WatchTransactionsParams): WatcherResponse;
|
|
25
50
|
/**
|
|
@@ -28,6 +53,18 @@ export declare class Watcher {
|
|
|
28
53
|
* * onSuccess - When the transaction comes back as completed / refunded / expired.
|
|
29
54
|
* * onError - When there's a runtime error, or the transaction comes back as
|
|
30
55
|
* no_market / too_small / too_large / error.
|
|
56
|
+
* @param {WatchTransactionParams} params - The Watch Transaction params.
|
|
57
|
+
* @param {AuthToken} params.authToken - The authentication token used for authenticating with th anchor.
|
|
58
|
+
* @param {string} params.assetCode - The asset code to filter transactions by.
|
|
59
|
+
* @param {string} params.id - The id of the transaction to watch.
|
|
60
|
+
* @param {Function} params.onMessage - A callback function to handle incoming transaction messages.
|
|
61
|
+
* @param {Function} params.onSuccess - If a transaction status is in a end state (eg. completed, refunded, expired) then this callback is called.
|
|
62
|
+
* @param {Function} params.onError - A callback function to handle errors during transaction streaming.
|
|
63
|
+
* @param {number} [params.timeout=5000] - The timeout duration for the streaming connection (in milliseconds).
|
|
64
|
+
* @param {boolean} [params.isRetry=false] - Indicates whether this is a retry attempt (optional).
|
|
65
|
+
* @param {string} [params.lang=this.anchor.language] - The desired language (localization) for transaction messages.
|
|
66
|
+
* @returns {WatcherResponse} An object holding the refresh and stop functions for the watcher.
|
|
31
67
|
*/
|
|
32
68
|
watchOneTransaction({ authToken, assetCode, id, onMessage, onSuccess, onError, timeout, isRetry, lang, }: WatchTransactionParams): WatcherResponse;
|
|
33
69
|
}
|
|
70
|
+
export * from "./getTransactions";
|
package/lib/walletSdk/index.d.ts
CHANGED
|
@@ -1,19 +1,56 @@
|
|
|
1
1
|
import { AxiosInstance } from "axios";
|
|
2
|
-
import { Networks,
|
|
2
|
+
import { Networks, Horizon } from "stellar-sdk";
|
|
3
3
|
import { Anchor } from "./Anchor";
|
|
4
4
|
import { WalletSigner } from "./Auth";
|
|
5
5
|
import { Stellar } from "./Horizon";
|
|
6
6
|
import { Recovery } from "./Recovery";
|
|
7
|
-
import { ConfigParams, StellarConfigurationParams, WalletAnchor, WalletParams,
|
|
7
|
+
import { ConfigParams, StellarConfigurationParams, WalletAnchor, WalletParams, WalletRecoveryServers } from "./Types";
|
|
8
|
+
/**
|
|
9
|
+
* The Wallet SDK main entry point class. From these class methods you can create a
|
|
10
|
+
* wallet on the Stellar network.
|
|
11
|
+
* @class
|
|
12
|
+
*/
|
|
8
13
|
export declare class Wallet {
|
|
9
14
|
private cfg;
|
|
10
15
|
private language;
|
|
16
|
+
/**
|
|
17
|
+
* Creates a Wallet instance configured to the test network.
|
|
18
|
+
* @returns {Wallet} A Wallet instance configured to the test network.
|
|
19
|
+
*/
|
|
11
20
|
static TestNet: () => Wallet;
|
|
21
|
+
/**
|
|
22
|
+
* Creates a Wallet instance configured to the public network.
|
|
23
|
+
* @returns {Wallet} A Wallet instance configured to the public network.
|
|
24
|
+
*/
|
|
12
25
|
static MainNet: () => Wallet;
|
|
26
|
+
/**
|
|
27
|
+
* Creates a new Wallet instance.
|
|
28
|
+
* @param {WalletParams} params - The Wallet params.
|
|
29
|
+
* @param {StellarConfiguration} params.stellarConfiguration - The Stellar configuration.
|
|
30
|
+
* @param {ApplicationConfiguration} params.applicationConfiguration - The Application configuration.
|
|
31
|
+
* @param {string} [params.language] - The default langauge to use.
|
|
32
|
+
*/
|
|
13
33
|
constructor({ stellarConfiguration, applicationConfiguration, language, }: WalletParams);
|
|
34
|
+
/**
|
|
35
|
+
* Create an Anchor instance for interacting with an Anchor.
|
|
36
|
+
* @param {WalletAnchor} params - The anchor params.
|
|
37
|
+
* @param {string} params.homeDomain - The home domain of the anchor. This domain will be used for
|
|
38
|
+
* things like getting the toml info.
|
|
39
|
+
* @param {string} [params.language=this.language] - The language setting for the Anchor.
|
|
40
|
+
* @returns {Anchor} An Anchor instance.
|
|
41
|
+
*/
|
|
14
42
|
anchor({ homeDomain, language }: WalletAnchor): Anchor;
|
|
43
|
+
/**
|
|
44
|
+
* Create a Stellar instance for interacting with the Stellar network.
|
|
45
|
+
* @returns {Stellar} A Stellar instance.
|
|
46
|
+
*/
|
|
15
47
|
stellar(): Stellar;
|
|
16
|
-
|
|
48
|
+
/**
|
|
49
|
+
* Create a Recovery instance for account recovery using SEP-30.
|
|
50
|
+
* @param {WalletRecoveryServers} servers - A map of recovery servers.
|
|
51
|
+
* @returns {Recovery} A Recovery instance.
|
|
52
|
+
*/
|
|
53
|
+
recovery({ servers }: WalletRecoveryServers): Recovery;
|
|
17
54
|
}
|
|
18
55
|
export declare class Config {
|
|
19
56
|
stellar: StellarConfiguration;
|
|
@@ -21,7 +58,7 @@ export declare class Config {
|
|
|
21
58
|
constructor({ stellarConfiguration, applicationConfiguration, }: ConfigParams);
|
|
22
59
|
}
|
|
23
60
|
export declare class StellarConfiguration {
|
|
24
|
-
server: Server;
|
|
61
|
+
server: Horizon.Server;
|
|
25
62
|
network: Networks;
|
|
26
63
|
horizonUrl: string;
|
|
27
64
|
baseFee: number;
|