@stellar/typescript-wallet-sdk 1.3.0 → 1.4.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/babel.config.js +5 -1
- package/examples/sep24/sep24.ts +6 -1
- package/jest.integration.config.js +1 -1
- package/lib/bundle.js +35919 -35080
- package/lib/bundle.js.map +1 -1
- package/lib/bundle_browser.js +29734 -67834
- package/lib/bundle_browser.js.map +1 -1
- package/lib/index.d.ts +6 -1
- package/lib/walletSdk/Anchor/index.d.ts +2 -0
- package/lib/walletSdk/Asset/index.d.ts +1 -1
- package/lib/walletSdk/Auth/WalletSigner.d.ts +1 -1
- package/lib/walletSdk/Exceptions/index.d.ts +16 -1
- package/lib/walletSdk/Horizon/Account.d.ts +1 -1
- package/lib/walletSdk/Horizon/AccountService.d.ts +1 -1
- package/lib/walletSdk/Horizon/Stellar.d.ts +1 -1
- package/lib/walletSdk/Horizon/Transaction/CommonTransactionBuilder.d.ts +1 -1
- package/lib/walletSdk/Horizon/Transaction/SponsoringBuilder.d.ts +1 -1
- package/lib/walletSdk/Horizon/Transaction/TransactionBuilder.d.ts +1 -1
- package/lib/walletSdk/Recovery/AccountRecover.d.ts +1 -1
- package/lib/walletSdk/Recovery/index.d.ts +1 -1
- package/lib/walletSdk/Server/index.d.ts +21 -0
- package/lib/walletSdk/Types/anchor.d.ts +1 -1
- package/lib/walletSdk/Types/auth.d.ts +12 -2
- package/lib/walletSdk/Types/horizon.d.ts +1 -1
- package/lib/walletSdk/Types/index.d.ts +2 -1
- package/lib/walletSdk/Types/recovery.d.ts +1 -1
- package/lib/walletSdk/Types/sep24.d.ts +1 -1
- package/lib/walletSdk/Utils/toml.d.ts +1 -1
- package/lib/walletSdk/index.d.ts +4 -2
- package/package.json +8 -11
- package/src/index.ts +7 -1
- package/src/walletSdk/Anchor/index.ts +9 -5
- package/src/walletSdk/Asset/index.ts +1 -1
- package/src/walletSdk/Auth/WalletSigner.ts +1 -1
- package/src/walletSdk/Auth/index.ts +3 -3
- package/src/walletSdk/Exceptions/index.ts +36 -1
- package/src/walletSdk/Horizon/Account.ts +1 -1
- package/src/walletSdk/Horizon/AccountService.ts +1 -1
- package/src/walletSdk/Horizon/Stellar.ts +1 -1
- package/src/walletSdk/Horizon/Transaction/CommonTransactionBuilder.ts +5 -5
- package/src/walletSdk/Horizon/Transaction/SponsoringBuilder.ts +4 -4
- package/src/walletSdk/Horizon/Transaction/TransactionBuilder.ts +8 -9
- package/src/walletSdk/Recovery/AccountRecover.ts +1 -1
- package/src/walletSdk/Recovery/index.ts +1 -1
- package/src/walletSdk/Server/index.ts +95 -0
- package/src/walletSdk/Types/anchor.ts +1 -1
- package/src/walletSdk/Types/auth.ts +14 -2
- package/src/walletSdk/Types/horizon.ts +1 -1
- package/src/walletSdk/Types/index.ts +2 -1
- package/src/walletSdk/Types/recovery.ts +1 -1
- package/src/walletSdk/Types/sep24.ts +1 -1
- package/src/walletSdk/Utils/toml.ts +1 -1
- package/src/walletSdk/index.ts +14 -2
- package/test/account.test.ts +1 -1
- package/test/accountService.test.ts +13 -41
- package/test/integration/anchorplatform.test.ts +145 -0
- package/test/{integration.test.ts → integration/recovery.test.ts} +2 -2
- package/test/recovery.test.ts +1 -1
- package/test/sep6.test.ts +1 -1
- package/test/server.test.ts +71 -0
- package/test/stellar.test.ts +1 -1
- package/test/transaction.test.ts +1 -1
- package/test/wallet.test.ts +1 -1
- package/webpack.config.js +48 -32
- package/.eslintrc.js +0 -76
- package/.github/workflows/integrationTest.yml +0 -19
- package/.github/workflows/runTests.yml +0 -14
- package/.husky/pre-commit +0 -5
- package/LICENSE +0 -204
- package/README.md +0 -51
- package/docs/WalletGuide.md +0 -5
- package/jest.config.js +0 -9
- package/prettier.config.js +0 -1
package/lib/index.d.ts
CHANGED
|
@@ -24,8 +24,13 @@ export { Utils };
|
|
|
24
24
|
*/
|
|
25
25
|
import * as Exceptions from "./walletSdk/Exceptions";
|
|
26
26
|
export { Exceptions };
|
|
27
|
+
/**
|
|
28
|
+
* Server
|
|
29
|
+
*/
|
|
30
|
+
import * as Server from "./walletSdk/Server";
|
|
31
|
+
export { Server };
|
|
27
32
|
import * as walletSdk from "./walletSdk";
|
|
28
|
-
import { Keypair } from "stellar-sdk";
|
|
33
|
+
import { Keypair } from "@stellar/stellar-sdk";
|
|
29
34
|
export { walletSdk, Keypair };
|
|
30
35
|
declare const _default: {
|
|
31
36
|
walletSdk: typeof walletSdk;
|
|
@@ -9,6 +9,7 @@ import { AnchorServiceInfo, TomlInfo, AuthToken } from "../Types";
|
|
|
9
9
|
type AnchorParams = {
|
|
10
10
|
cfg: Config;
|
|
11
11
|
homeDomain: string;
|
|
12
|
+
allowHttp?: boolean;
|
|
12
13
|
httpClient: AxiosInstance;
|
|
13
14
|
language: string;
|
|
14
15
|
};
|
|
@@ -26,6 +27,7 @@ export declare class Anchor {
|
|
|
26
27
|
language: string;
|
|
27
28
|
private cfg;
|
|
28
29
|
private homeDomain;
|
|
30
|
+
private allowHttp;
|
|
29
31
|
private httpClient;
|
|
30
32
|
private toml;
|
|
31
33
|
/**
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Networks, Horizon } from "stellar-sdk";
|
|
1
|
+
import { Networks, Horizon } from "@stellar/stellar-sdk";
|
|
2
2
|
import { AnchorTransaction, FLOW_TYPE, AxiosErrorData, GetCustomerParams } from "../Types";
|
|
3
3
|
export declare class ServerRequestFailedError extends Error {
|
|
4
4
|
data: AxiosErrorData;
|
|
@@ -100,3 +100,18 @@ export declare class NoAccountAndNoSponsorError extends Error {
|
|
|
100
100
|
export declare class Sep38PriceOnlyOneAmountError extends Error {
|
|
101
101
|
constructor();
|
|
102
102
|
}
|
|
103
|
+
export declare class ChallengeTxnIncorrectSequenceError extends Error {
|
|
104
|
+
constructor();
|
|
105
|
+
}
|
|
106
|
+
export declare class ChallengeTxnInvalidSignatureError extends Error {
|
|
107
|
+
constructor();
|
|
108
|
+
}
|
|
109
|
+
export declare class AllowHttpOnNonTestnetError extends Error {
|
|
110
|
+
constructor();
|
|
111
|
+
}
|
|
112
|
+
export declare class UnknownAnchorTransactionError extends Error {
|
|
113
|
+
constructor();
|
|
114
|
+
}
|
|
115
|
+
export declare class InvalidJsonError extends Error {
|
|
116
|
+
constructor();
|
|
117
|
+
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Horizon, Transaction, FeeBumpTransaction } from "stellar-sdk";
|
|
1
|
+
import { Horizon, Transaction, FeeBumpTransaction } from "@stellar/stellar-sdk";
|
|
2
2
|
import { Config } from "walletSdk";
|
|
3
3
|
import { AccountService } from "./AccountService";
|
|
4
4
|
import { TransactionBuilder } from "./Transaction/TransactionBuilder";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Account as StellarAccount, Transaction, Horizon, Memo, xdr } from "stellar-sdk";
|
|
1
|
+
import { Account as StellarAccount, Transaction, Horizon, Memo, xdr } from "@stellar/stellar-sdk";
|
|
2
2
|
import { Config } from "walletSdk";
|
|
3
3
|
import { AccountKeypair } from "../Account";
|
|
4
4
|
import { StellarAssetId } from "../../Asset";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { AxiosInstance } from "axios";
|
|
2
|
-
import { Transaction } from "stellar-sdk";
|
|
2
|
+
import { Transaction } from "@stellar/stellar-sdk";
|
|
3
3
|
import { RecoveryServer, RecoveryServerKey, RecoveryServerMap, RecoveryServerSigningMap } from "walletSdk/Types";
|
|
4
4
|
import { AccountKeypair, Stellar } from "../Horizon";
|
|
5
5
|
/**
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { AxiosInstance } from "axios";
|
|
2
|
-
import { Transaction } from "stellar-sdk";
|
|
2
|
+
import { Transaction } from "@stellar/stellar-sdk";
|
|
3
3
|
import { Config } from "walletSdk";
|
|
4
4
|
import { AccountSigner, AccountThreshold, CommonBuilder, RecoverableWallet, RecoverableWalletConfig, RecoveryAccountInfoMap, RecoveryAuthMap, RecoveryServerKey, RecoveryServerMap } from "walletSdk/Types";
|
|
5
5
|
import { AccountRecover } from "./AccountRecover";
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Code in the Server module is written to be used by server side
|
|
3
|
+
* applications.
|
|
4
|
+
*/
|
|
5
|
+
import { SignChallengeTxnParams, SignChallengeTxnResponse, AnchorTransaction } from "../Types";
|
|
6
|
+
/**
|
|
7
|
+
* Helper method for signing a SEP-10 challenge transaction if valid.
|
|
8
|
+
* @param {SignChallengeTxnParams} params - The Authentication params.
|
|
9
|
+
* @param {AccountKeypair} params.accountKp - Keypair for the Stellar account signing the transaction.
|
|
10
|
+
* @param {string} [params.challengeTx] - The challenge transaction given by an anchor for authentication.
|
|
11
|
+
* @param {string} [params.networkPassphrase] - The network passphrase for the network authenticating on.
|
|
12
|
+
* @param {string} [params.anchorDomain] - Domain hosting stellar.toml file containing `SIGNING_KEY`.
|
|
13
|
+
* @returns {Promise<SignChallengeTxnResponse>} The signed transaction.
|
|
14
|
+
*/
|
|
15
|
+
export declare const signChallengeTransaction: ({ accountKp, challengeTx, networkPassphrase, anchorDomain, }: SignChallengeTxnParams) => Promise<SignChallengeTxnResponse>;
|
|
16
|
+
/**
|
|
17
|
+
* Helper method for parsing a JSON string into an AnchorTransaction.
|
|
18
|
+
* @param {string} transaction - The json string of an anchor transaction.
|
|
19
|
+
* @returns {AnchorTransaction} The transaction object.
|
|
20
|
+
*/
|
|
21
|
+
export declare const parseAnchorTransaction: (transaction: string) => AnchorTransaction;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { Transaction } from "stellar-sdk";
|
|
1
|
+
import { Transaction } from "@stellar/stellar-sdk";
|
|
2
2
|
import { WalletSigner } from "../Auth/WalletSigner";
|
|
3
|
-
import { AccountKeypair } from "../Horizon/Account";
|
|
3
|
+
import { AccountKeypair, SigningKeypair } from "../Horizon/Account";
|
|
4
4
|
export type AuthenticateParams = {
|
|
5
5
|
accountKp: AccountKeypair;
|
|
6
6
|
walletSigner?: WalletSigner;
|
|
@@ -46,3 +46,13 @@ export type SignWithDomainAccountParams = {
|
|
|
46
46
|
export type HttpHeaders = {
|
|
47
47
|
[key: string]: string;
|
|
48
48
|
};
|
|
49
|
+
export type SignChallengeTxnParams = {
|
|
50
|
+
accountKp: SigningKeypair;
|
|
51
|
+
challengeTx: string;
|
|
52
|
+
networkPassphrase: string;
|
|
53
|
+
anchorDomain: string;
|
|
54
|
+
};
|
|
55
|
+
export type SignChallengeTxnResponse = {
|
|
56
|
+
transaction: XdrEncodedTransaction;
|
|
57
|
+
networkPassphrase: NetworkPassphrase;
|
|
58
|
+
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Memo, Horizon, Transaction } from "stellar-sdk";
|
|
1
|
+
import { Memo, Horizon, Transaction } from "@stellar/stellar-sdk";
|
|
2
2
|
import { AccountKeypair } from "../Horizon/Account";
|
|
3
3
|
import { SponsoringBuilder, TransactionBuilder } from "walletSdk/Horizon";
|
|
4
4
|
import { StellarAssetId } from "../Asset";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { RawAxiosRequestHeaders } from "axios";
|
|
2
|
-
import { Networks } from "stellar-sdk";
|
|
2
|
+
import { Networks } from "@stellar/stellar-sdk";
|
|
3
3
|
import { ApplicationConfiguration, StellarConfiguration } from "walletSdk";
|
|
4
4
|
import { RecoveryServerMap } from "./recovery";
|
|
5
5
|
export type WalletParams = {
|
|
@@ -9,6 +9,7 @@ export type WalletParams = {
|
|
|
9
9
|
};
|
|
10
10
|
export type WalletAnchor = {
|
|
11
11
|
homeDomain: string;
|
|
12
|
+
allowHttp?: boolean;
|
|
12
13
|
language?: string;
|
|
13
14
|
};
|
|
14
15
|
export type WalletRecoveryServers = {
|
package/lib/walletSdk/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { AxiosInstance } from "axios";
|
|
2
|
-
import { Networks, Horizon } from "stellar-sdk";
|
|
2
|
+
import { Networks, Horizon } from "@stellar/stellar-sdk";
|
|
3
3
|
import { Anchor } from "./Anchor";
|
|
4
4
|
import { WalletSigner } from "./Auth";
|
|
5
5
|
import { Stellar } from "./Horizon";
|
|
@@ -36,10 +36,12 @@ export declare class Wallet {
|
|
|
36
36
|
* @param {WalletAnchor} params - The anchor params.
|
|
37
37
|
* @param {string} params.homeDomain - The home domain of the anchor. This domain will be used for
|
|
38
38
|
* things like getting the toml info.
|
|
39
|
+
* @param {allowHttp} [params.allowHttp] - Flag to allow http protocol for the home domain.
|
|
40
|
+
* Defaults to false, and can only be set to true on Testnet.
|
|
39
41
|
* @param {string} [params.language=this.language] - The language setting for the Anchor.
|
|
40
42
|
* @returns {Anchor} An Anchor instance.
|
|
41
43
|
*/
|
|
42
|
-
anchor({ homeDomain, language }: WalletAnchor): Anchor;
|
|
44
|
+
anchor({ homeDomain, allowHttp, language, }: WalletAnchor): Anchor;
|
|
43
45
|
/**
|
|
44
46
|
* Create a Stellar instance for interacting with the Stellar network.
|
|
45
47
|
* @returns {Stellar} A Stellar instance.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stellar/typescript-wallet-sdk",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.4.0",
|
|
4
4
|
"engines": {
|
|
5
5
|
"node": ">=18"
|
|
6
6
|
},
|
|
@@ -11,6 +11,7 @@
|
|
|
11
11
|
"private": false,
|
|
12
12
|
"devDependencies": {
|
|
13
13
|
"@babel/preset-env": "^7.20.2",
|
|
14
|
+
"@babel/preset-typescript": "^7.23.3",
|
|
14
15
|
"@stellar/prettier-config": "^1.0.1",
|
|
15
16
|
"@stellar/tsconfig": "^1.0.2",
|
|
16
17
|
"@types/jest": "^29.4.0",
|
|
@@ -30,6 +31,7 @@
|
|
|
30
31
|
"npm-run-all": "^4.1.5",
|
|
31
32
|
"prettier": "^2.0.5",
|
|
32
33
|
"pretty-quick": "^2.0.1",
|
|
34
|
+
"process": "^0.11.10",
|
|
33
35
|
"sinon": "^15.1.0",
|
|
34
36
|
"stream-browserify": "^3.0.0",
|
|
35
37
|
"ts-jest": "^29.0.5",
|
|
@@ -41,31 +43,26 @@
|
|
|
41
43
|
"webpack-cli": "^5.1.1"
|
|
42
44
|
},
|
|
43
45
|
"dependencies": {
|
|
46
|
+
"@stellar/stellar-sdk": "^11.1.0",
|
|
44
47
|
"axios": "^1.4.0",
|
|
45
48
|
"https-browserify": "^1.0.0",
|
|
46
49
|
"jws": "^4.0.0",
|
|
47
50
|
"lodash": "^4.17.21",
|
|
48
51
|
"query-string": "^7.1.3",
|
|
49
|
-
"stellar-sdk": "^11.0.0-beta.6",
|
|
50
52
|
"stream-http": "^3.2.0",
|
|
51
53
|
"url": "^0.11.0",
|
|
52
54
|
"util": "^0.12.5",
|
|
53
|
-
"utility-types": "^3.10.0"
|
|
55
|
+
"utility-types": "^3.10.0",
|
|
56
|
+
"vm-browserify": "^1.1.2"
|
|
54
57
|
},
|
|
55
58
|
"scripts": {
|
|
56
|
-
"lint": "eslint . --ext .ts",
|
|
57
|
-
"prepare": "husky install",
|
|
58
59
|
"test": "jest --watchAll",
|
|
59
60
|
"test:ci": "jest --ci",
|
|
60
|
-
"test:
|
|
61
|
+
"test:recovery:ci": "jest --config jest.integration.config.js recovery.test.ts --ci",
|
|
62
|
+
"test:anchorplatform:ci": "yarn jest --config jest.integration.config.js anchorplatform.test.ts --ci",
|
|
61
63
|
"build:web": "webpack --config webpack.config.js",
|
|
62
64
|
"build:node": "webpack --env NODE=true --config webpack.config.js",
|
|
63
65
|
"build": "run-p build:web build:node",
|
|
64
66
|
"example:sep24": "ts-node examples/sep24/sep24.ts"
|
|
65
|
-
},
|
|
66
|
-
"lint-staged": {
|
|
67
|
-
"**/*.ts": [
|
|
68
|
-
"eslint --fix --max-warnings 0"
|
|
69
|
-
]
|
|
70
67
|
}
|
|
71
68
|
}
|
package/src/index.ts
CHANGED
|
@@ -42,8 +42,14 @@ export { Utils };
|
|
|
42
42
|
import * as Exceptions from "./walletSdk/Exceptions";
|
|
43
43
|
export { Exceptions };
|
|
44
44
|
|
|
45
|
+
/**
|
|
46
|
+
* Server
|
|
47
|
+
*/
|
|
48
|
+
import * as Server from "./walletSdk/Server";
|
|
49
|
+
export { Server };
|
|
50
|
+
|
|
45
51
|
import * as walletSdk from "./walletSdk";
|
|
46
|
-
import { Keypair } from "stellar-sdk";
|
|
52
|
+
import { Keypair } from "@stellar/stellar-sdk";
|
|
47
53
|
// TODO - figure out why Keypair used in parent codebase throws error
|
|
48
54
|
export { walletSdk, Keypair };
|
|
49
55
|
export default { walletSdk };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { AxiosInstance } from "axios";
|
|
2
|
-
import { StellarToml } from "stellar-sdk";
|
|
2
|
+
import { StellarToml } from "@stellar/stellar-sdk";
|
|
3
3
|
|
|
4
4
|
import { Config } from "walletSdk";
|
|
5
5
|
import { Sep10 } from "../Auth";
|
|
@@ -19,6 +19,7 @@ import { parseToml } from "../Utils";
|
|
|
19
19
|
type AnchorParams = {
|
|
20
20
|
cfg: Config;
|
|
21
21
|
homeDomain: string;
|
|
22
|
+
allowHttp?: boolean;
|
|
22
23
|
httpClient: AxiosInstance;
|
|
23
24
|
language: string;
|
|
24
25
|
};
|
|
@@ -43,6 +44,7 @@ export class Anchor {
|
|
|
43
44
|
|
|
44
45
|
private cfg: Config;
|
|
45
46
|
private homeDomain: string;
|
|
47
|
+
private allowHttp: boolean;
|
|
46
48
|
private httpClient: AxiosInstance;
|
|
47
49
|
private toml: TomlInfo;
|
|
48
50
|
|
|
@@ -52,10 +54,10 @@ export class Anchor {
|
|
|
52
54
|
* @param {AnchorParams} params - The parameters to initialize the Anchor.
|
|
53
55
|
*/
|
|
54
56
|
constructor(params: AnchorParams) {
|
|
55
|
-
const { cfg, homeDomain, httpClient, language } = params;
|
|
56
|
-
|
|
57
|
+
const { cfg, homeDomain, httpClient, language, allowHttp = false } = params;
|
|
57
58
|
this.cfg = cfg;
|
|
58
59
|
this.homeDomain = homeDomain;
|
|
60
|
+
this.allowHttp = allowHttp;
|
|
59
61
|
this.httpClient = httpClient;
|
|
60
62
|
this.language = language;
|
|
61
63
|
}
|
|
@@ -72,8 +74,10 @@ export class Anchor {
|
|
|
72
74
|
return this.toml;
|
|
73
75
|
}
|
|
74
76
|
|
|
75
|
-
|
|
76
|
-
|
|
77
|
+
const stellarToml = await StellarToml.Resolver.resolve(this.homeDomain, {
|
|
78
|
+
allowHttp: this.allowHttp,
|
|
79
|
+
});
|
|
80
|
+
|
|
77
81
|
const parsedToml = parseToml(stellarToml);
|
|
78
82
|
this.toml = parsedToml;
|
|
79
83
|
return parsedToml;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { AxiosInstance } from "axios";
|
|
2
|
-
import
|
|
2
|
+
import { TransactionBuilder, Transaction } from "@stellar/stellar-sdk";
|
|
3
3
|
import { decode } from "jws";
|
|
4
4
|
|
|
5
5
|
import { Config } from "walletSdk";
|
|
@@ -118,10 +118,10 @@ export class Sep10 {
|
|
|
118
118
|
challengeResponse,
|
|
119
119
|
walletSigner,
|
|
120
120
|
}: SignParams): Promise<Transaction> {
|
|
121
|
-
let transaction: Transaction =
|
|
121
|
+
let transaction: Transaction = TransactionBuilder.fromXDR(
|
|
122
122
|
challengeResponse.transaction,
|
|
123
123
|
challengeResponse.network_passphrase,
|
|
124
|
-
);
|
|
124
|
+
) as Transaction;
|
|
125
125
|
|
|
126
126
|
// check if verifying client domain as well
|
|
127
127
|
for (const op of transaction.operations) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Networks, Horizon } from "stellar-sdk";
|
|
1
|
+
import { Networks, Horizon } from "@stellar/stellar-sdk";
|
|
2
2
|
import axios from "axios";
|
|
3
3
|
import {
|
|
4
4
|
AnchorTransaction,
|
|
@@ -270,3 +270,38 @@ export class Sep38PriceOnlyOneAmountError extends Error {
|
|
|
270
270
|
Object.setPrototypeOf(this, Sep38PriceOnlyOneAmountError.prototype);
|
|
271
271
|
}
|
|
272
272
|
}
|
|
273
|
+
|
|
274
|
+
export class ChallengeTxnIncorrectSequenceError extends Error {
|
|
275
|
+
constructor() {
|
|
276
|
+
super("Challenge transaction sequence number must be 0");
|
|
277
|
+
Object.setPrototypeOf(this, ChallengeTxnIncorrectSequenceError.prototype);
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
export class ChallengeTxnInvalidSignatureError extends Error {
|
|
282
|
+
constructor() {
|
|
283
|
+
super("Invalid signature for challenge transaction");
|
|
284
|
+
Object.setPrototypeOf(this, ChallengeTxnInvalidSignatureError.prototype);
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
export class AllowHttpOnNonTestnetError extends Error {
|
|
289
|
+
constructor() {
|
|
290
|
+
super("Can only allow Http on Testnet");
|
|
291
|
+
Object.setPrototypeOf(this, AllowHttpOnNonTestnetError.prototype);
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
export class UnknownAnchorTransactionError extends Error {
|
|
296
|
+
constructor() {
|
|
297
|
+
super("Unknown AnchorTransaction type parse failed");
|
|
298
|
+
Object.setPrototypeOf(this, UnknownAnchorTransactionError.prototype);
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
export class InvalidJsonError extends Error {
|
|
303
|
+
constructor() {
|
|
304
|
+
super("Invalid Json given");
|
|
305
|
+
Object.setPrototypeOf(this, InvalidJsonError.prototype);
|
|
306
|
+
}
|
|
307
|
+
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { Operation, xdr } from "@stellar/stellar-sdk";
|
|
2
2
|
import { IssuedAssetId } from "../../Asset";
|
|
3
3
|
import { AccountKeypair } from "../Account";
|
|
4
4
|
|
|
@@ -19,7 +19,7 @@ export abstract class CommonTransactionBuilder<T> {
|
|
|
19
19
|
*/
|
|
20
20
|
addAssetSupport(asset: IssuedAssetId, trustLimit?: string): T {
|
|
21
21
|
this.operations.push(
|
|
22
|
-
|
|
22
|
+
Operation.changeTrust({
|
|
23
23
|
asset: asset.toAsset(),
|
|
24
24
|
limit: trustLimit,
|
|
25
25
|
source: this.sourceAddress,
|
|
@@ -46,7 +46,7 @@ export abstract class CommonTransactionBuilder<T> {
|
|
|
46
46
|
*/
|
|
47
47
|
addAccountSigner(signerAddress: AccountKeypair, signerWeight: number): T {
|
|
48
48
|
this.operations.push(
|
|
49
|
-
|
|
49
|
+
Operation.setOptions({
|
|
50
50
|
source: this.sourceAddress,
|
|
51
51
|
signer: {
|
|
52
52
|
ed25519PublicKey: signerAddress.publicKey,
|
|
@@ -75,7 +75,7 @@ export abstract class CommonTransactionBuilder<T> {
|
|
|
75
75
|
*/
|
|
76
76
|
lockAccountMasterKey(): T {
|
|
77
77
|
this.operations.push(
|
|
78
|
-
|
|
78
|
+
Operation.setOptions({
|
|
79
79
|
source: this.sourceAddress,
|
|
80
80
|
masterWeight: 0,
|
|
81
81
|
}),
|
|
@@ -102,7 +102,7 @@ export abstract class CommonTransactionBuilder<T> {
|
|
|
102
102
|
high?: number;
|
|
103
103
|
}): T {
|
|
104
104
|
this.operations.push(
|
|
105
|
-
|
|
105
|
+
Operation.setOptions({
|
|
106
106
|
source: this.sourceAddress,
|
|
107
107
|
lowThreshold: low,
|
|
108
108
|
medThreshold: medium,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { Operation, xdr } from "@stellar/stellar-sdk";
|
|
2
2
|
|
|
3
3
|
import { CommonTransactionBuilder } from "./CommonTransactionBuilder";
|
|
4
4
|
import { AccountKeypair } from "../Account";
|
|
@@ -45,7 +45,7 @@ export class SponsoringBuilder extends CommonTransactionBuilder<SponsoringBuilde
|
|
|
45
45
|
startingBalance: number = 0,
|
|
46
46
|
): SponsoringBuilder {
|
|
47
47
|
this.operations.push(
|
|
48
|
-
|
|
48
|
+
Operation.createAccount({
|
|
49
49
|
destination: newAccount.publicKey,
|
|
50
50
|
startingBalance: startingBalance.toString(),
|
|
51
51
|
source: this.sponsorAccount.publicKey,
|
|
@@ -60,7 +60,7 @@ export class SponsoringBuilder extends CommonTransactionBuilder<SponsoringBuilde
|
|
|
60
60
|
*/
|
|
61
61
|
startSponsoring() {
|
|
62
62
|
this.operations.push(
|
|
63
|
-
|
|
63
|
+
Operation.beginSponsoringFutureReserves({
|
|
64
64
|
sponsoredId: this.sourceAddress,
|
|
65
65
|
source: this.sponsorAccount.publicKey,
|
|
66
66
|
}),
|
|
@@ -73,7 +73,7 @@ export class SponsoringBuilder extends CommonTransactionBuilder<SponsoringBuilde
|
|
|
73
73
|
*/
|
|
74
74
|
stopSponsoring() {
|
|
75
75
|
this.operations.push(
|
|
76
|
-
|
|
76
|
+
Operation.endSponsoringFutureReserves({
|
|
77
77
|
source: this.sourceAddress,
|
|
78
78
|
}),
|
|
79
79
|
);
|
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
import
|
|
1
|
+
import {
|
|
2
|
+
Operation,
|
|
2
3
|
TransactionBuilder as StellarTransactionBuilder,
|
|
3
4
|
Account as StellarAccount,
|
|
4
5
|
Transaction,
|
|
5
6
|
Horizon,
|
|
6
7
|
Memo,
|
|
7
8
|
xdr,
|
|
8
|
-
} from "stellar-sdk";
|
|
9
|
+
} from "@stellar/stellar-sdk";
|
|
9
10
|
|
|
10
11
|
import { Config } from "walletSdk";
|
|
11
12
|
import { AccountKeypair } from "../Account";
|
|
@@ -101,7 +102,7 @@ export class TransactionBuilder extends CommonTransactionBuilder<TransactionBuil
|
|
|
101
102
|
}
|
|
102
103
|
|
|
103
104
|
this.operations.push(
|
|
104
|
-
|
|
105
|
+
Operation.createAccount({
|
|
105
106
|
destination: newAccount.publicKey,
|
|
106
107
|
startingBalance: startingBalance.toString(),
|
|
107
108
|
source: this.sourceAddress,
|
|
@@ -123,7 +124,7 @@ export class TransactionBuilder extends CommonTransactionBuilder<TransactionBuil
|
|
|
123
124
|
amount: string,
|
|
124
125
|
): TransactionBuilder {
|
|
125
126
|
this.operations.push(
|
|
126
|
-
|
|
127
|
+
Operation.payment({
|
|
127
128
|
destination: destinationAddress,
|
|
128
129
|
asset: assetId.toAsset(),
|
|
129
130
|
amount,
|
|
@@ -167,7 +168,7 @@ export class TransactionBuilder extends CommonTransactionBuilder<TransactionBuil
|
|
|
167
168
|
}
|
|
168
169
|
if (sendAmount) {
|
|
169
170
|
this.operations.push(
|
|
170
|
-
|
|
171
|
+
Operation.pathPaymentStrictSend({
|
|
171
172
|
destination: destinationAddress,
|
|
172
173
|
sendAsset: sendAsset.toAsset(),
|
|
173
174
|
sendAmount,
|
|
@@ -177,7 +178,7 @@ export class TransactionBuilder extends CommonTransactionBuilder<TransactionBuil
|
|
|
177
178
|
);
|
|
178
179
|
} else {
|
|
179
180
|
this.operations.push(
|
|
180
|
-
|
|
181
|
+
Operation.pathPaymentStrictReceive({
|
|
181
182
|
destination: destinationAddress,
|
|
182
183
|
sendAsset: sendAsset.toAsset(),
|
|
183
184
|
destAmount,
|
|
@@ -289,9 +290,7 @@ export class TransactionBuilder extends CommonTransactionBuilder<TransactionBuil
|
|
|
289
290
|
* @returns {TransactionBuilder} The TransactionBuilder instance.
|
|
290
291
|
*/
|
|
291
292
|
accountMerge(destination: string, source?: string): TransactionBuilder {
|
|
292
|
-
this.operations.push(
|
|
293
|
-
StellarSdk.Operation.accountMerge({ destination, source }),
|
|
294
|
-
);
|
|
293
|
+
this.operations.push(Operation.accountMerge({ destination, source }));
|
|
295
294
|
return this;
|
|
296
295
|
}
|
|
297
296
|
|