@ledgerhq/live-common 25.0.0-next.0 → 25.0.0-next.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/__tests__/accounts/importAccounts.js +1 -1
- package/lib/__tests__/test-helpers/setup.js +1 -1
- package/lib/account/helpers.d.ts +5 -1
- package/lib/account/helpers.d.ts.map +1 -1
- package/lib/account/helpers.js +28 -1
- package/lib/account/helpers.js.map +1 -1
- package/lib/apps/filtering.test.js +1 -1
- package/lib/bot/specs.d.ts +1 -0
- package/lib/bot/specs.d.ts.map +1 -1
- package/lib/bot/specs.js +6 -1
- package/lib/bot/specs.js.map +1 -1
- package/lib/countervalues/api/api.d.ts.map +1 -1
- package/lib/countervalues/api/api.js +25 -13
- package/lib/countervalues/api/api.js.map +1 -1
- package/lib/countervalues/logic.d.ts.map +1 -1
- package/lib/countervalues/logic.integration.test.d.ts +1 -1
- package/lib/countervalues/logic.integration.test.d.ts.map +1 -1
- package/lib/countervalues/logic.integration.test.js +78 -2
- package/lib/countervalues/logic.integration.test.js.map +1 -1
- package/lib/countervalues/logic.js +5 -1
- package/lib/countervalues/logic.js.map +1 -1
- package/lib/countervalues/modules/index.d.ts +1 -1
- package/lib/countervalues/modules/index.d.ts.map +1 -1
- package/lib/countervalues/modules/index.js +3 -1
- package/lib/countervalues/modules/index.js.map +1 -1
- package/lib/countervalues/types.d.ts +1 -0
- package/lib/countervalues/types.d.ts.map +1 -1
- package/lib/currencies/helpers.d.ts +9 -0
- package/lib/currencies/helpers.d.ts.map +1 -0
- package/lib/currencies/helpers.js +78 -0
- package/lib/currencies/helpers.js.map +1 -0
- package/lib/currencies/helpers.test.d.ts +2 -0
- package/lib/currencies/helpers.test.d.ts.map +1 -0
- package/lib/currencies/helpers.test.js +20 -0
- package/lib/currencies/helpers.test.js.map +1 -0
- package/lib/currencies/index.d.ts +1 -0
- package/lib/currencies/index.d.ts.map +1 -1
- package/lib/currencies/index.js +1 -0
- package/lib/currencies/index.js.map +1 -1
- package/lib/currencies/react.d.ts +4 -0
- package/lib/currencies/react.d.ts.map +1 -0
- package/lib/currencies/react.js +16 -0
- package/lib/currencies/react.js.map +1 -0
- package/lib/env.d.ts +10 -5
- package/lib/env.d.ts.map +1 -1
- package/lib/env.js +5 -0
- package/lib/env.js.map +1 -1
- package/lib/env.react.d.ts +1 -1
- package/lib/env.react.d.ts.map +1 -1
- package/lib/errors.d.ts +1 -2
- package/lib/errors.d.ts.map +1 -1
- package/lib/errors.js +3 -4
- package/lib/errors.js.map +1 -1
- package/lib/families/solana/api/chain/instruction/token/types.d.ts +3 -3
- package/lib/families/stellar/api/horizon.d.ts +29 -7
- package/lib/families/stellar/api/horizon.d.ts.map +1 -1
- package/lib/families/stellar/api/horizon.js +114 -58
- package/lib/families/stellar/api/horizon.js.map +1 -1
- package/lib/families/stellar/api/index.d.ts +1 -1
- package/lib/families/stellar/api/index.d.ts.map +1 -1
- package/lib/families/stellar/api/index.js +5 -1
- package/lib/families/stellar/api/index.js.map +1 -1
- package/lib/families/stellar/bridge/mock.d.ts.map +1 -1
- package/lib/families/stellar/bridge/mock.js +4 -1
- package/lib/families/stellar/bridge/mock.js.map +1 -1
- package/lib/families/stellar/bridge.integration.test.js +12 -4
- package/lib/families/stellar/bridge.integration.test.js.map +1 -1
- package/lib/families/stellar/cli-transaction.d.ts +3 -1
- package/lib/families/stellar/cli-transaction.d.ts.map +1 -1
- package/lib/families/stellar/cli-transaction.js +48 -2
- package/lib/families/stellar/cli-transaction.js.map +1 -1
- package/lib/families/stellar/deviceTransactionConfig.d.ts +7 -1
- package/lib/families/stellar/deviceTransactionConfig.d.ts.map +1 -1
- package/lib/families/stellar/deviceTransactionConfig.js +12 -1
- package/lib/families/stellar/deviceTransactionConfig.js.map +1 -1
- package/lib/families/stellar/errors.d.ts +12 -0
- package/lib/families/stellar/errors.d.ts.map +1 -0
- package/lib/families/stellar/errors.js +16 -0
- package/lib/families/stellar/errors.js.map +1 -0
- package/lib/families/stellar/js-buildTransaction.d.ts.map +1 -1
- package/lib/families/stellar/js-buildTransaction.js +34 -16
- package/lib/families/stellar/js-buildTransaction.js.map +1 -1
- package/lib/families/stellar/js-createTransaction.d.ts.map +1 -1
- package/lib/families/stellar/js-createTransaction.js +4 -1
- package/lib/families/stellar/js-createTransaction.js.map +1 -1
- package/lib/families/stellar/js-estimateMaxSpendable.js +2 -1
- package/lib/families/stellar/js-estimateMaxSpendable.js.map +1 -1
- package/lib/families/stellar/js-getTransactionStatus.d.ts.map +1 -1
- package/lib/families/stellar/js-getTransactionStatus.js +127 -57
- package/lib/families/stellar/js-getTransactionStatus.js.map +1 -1
- package/lib/families/stellar/js-prepareTransaction.d.ts.map +1 -1
- package/lib/families/stellar/js-prepareTransaction.js +25 -7
- package/lib/families/stellar/js-prepareTransaction.js.map +1 -1
- package/lib/families/stellar/js-signOperation.d.ts.map +1 -1
- package/lib/families/stellar/js-signOperation.js +33 -6
- package/lib/families/stellar/js-signOperation.js.map +1 -1
- package/lib/families/stellar/js-synchronization.d.ts +1 -1
- package/lib/families/stellar/js-synchronization.d.ts.map +1 -1
- package/lib/families/stellar/js-synchronization.js +42 -16
- package/lib/families/stellar/js-synchronization.js.map +1 -1
- package/lib/families/stellar/logic.d.ts +21 -14
- package/lib/families/stellar/logic.d.ts.map +1 -1
- package/lib/families/stellar/logic.js +158 -57
- package/lib/families/stellar/logic.js.map +1 -1
- package/lib/families/stellar/specs.d.ts.map +1 -1
- package/lib/families/stellar/specs.js +182 -7
- package/lib/families/stellar/specs.js.map +1 -1
- package/lib/families/stellar/speculos-deviceActions.d.ts.map +1 -1
- package/lib/families/stellar/speculos-deviceActions.js +60 -28
- package/lib/families/stellar/speculos-deviceActions.js.map +1 -1
- package/lib/families/stellar/tokens.d.ts +11 -0
- package/lib/families/stellar/tokens.d.ts.map +1 -0
- package/lib/families/stellar/tokens.js +82 -0
- package/lib/families/stellar/tokens.js.map +1 -0
- package/lib/families/stellar/transaction.d.ts +2 -2
- package/lib/families/stellar/transaction.d.ts.map +1 -1
- package/lib/families/stellar/transaction.js +32 -6
- package/lib/families/stellar/transaction.js.map +1 -1
- package/lib/families/stellar/types.d.ts +45 -0
- package/lib/families/stellar/types.d.ts.map +1 -1
- package/lib/families/stellar/types.js +7 -1
- package/lib/families/stellar/types.js.map +1 -1
- package/lib/generated/cli-transaction.d.ts +1 -0
- package/lib/generated/cli-transaction.d.ts.map +1 -1
- package/lib/generated/transaction.d.ts +1 -1
- package/lib/platform/PlatformAppProvider/api/api.mock.js +11 -11
- package/lib/platform/PlatformAppProvider/api/api.mock.js.map +1 -1
- package/lib/platform/PlatformAppProvider/helpers.d.ts +0 -7
- package/lib/platform/PlatformAppProvider/helpers.d.ts.map +1 -1
- package/lib/platform/PlatformAppProvider/helpers.js +1 -29
- package/lib/platform/PlatformAppProvider/helpers.js.map +1 -1
- package/lib/platform/converters.d.ts +4 -4
- package/lib/platform/converters.d.ts.map +1 -1
- package/lib/platform/converters.js +40 -2
- package/lib/platform/converters.js.map +1 -1
- package/lib/platform/filters.d.ts +18 -0
- package/lib/platform/filters.d.ts.map +1 -0
- package/lib/platform/filters.js +63 -0
- package/lib/platform/filters.js.map +1 -0
- package/lib/platform/helpers.d.ts +7 -0
- package/lib/platform/helpers.d.ts.map +1 -0
- package/lib/platform/helpers.js +22 -0
- package/lib/platform/helpers.js.map +1 -0
- package/lib/platform/logic.d.ts +1 -5
- package/lib/platform/logic.d.ts.map +1 -1
- package/lib/platform/logic.js +1 -18
- package/lib/platform/logic.js.map +1 -1
- package/lib/platform/providers/RemoteLiveAppProvider/api/mock.json +87 -246
- package/lib/platform/react.d.ts +11 -0
- package/lib/platform/react.d.ts.map +1 -0
- package/lib/platform/react.js +61 -0
- package/lib/platform/react.js.map +1 -0
- package/lib/platform/types.d.ts +8 -2
- package/lib/platform/types.d.ts.map +1 -1
- package/lib/platform/types.js +15 -0
- package/lib/platform/types.js.map +1 -1
- package/lib/platform/version.test.js +1 -1
- package/lib/walletconnect/walletconnect.test.js +0 -2
- package/lib/walletconnect/walletconnect.test.js.map +1 -1
- package/package.json +5 -4
- package/src/__tests__/accounts/importAccounts.ts +1 -1
- package/src/__tests__/test-helpers/setup.ts +1 -1
- package/src/account/helpers.ts +51 -0
- package/src/apps/filtering.test.ts +1 -1
- package/src/bot/specs.ts +7 -1
- package/src/countervalues/api/api.ts +25 -8
- package/src/countervalues/logic.integration.test.ts +71 -1
- package/src/countervalues/logic.ts +3 -1
- package/src/countervalues/modules/index.ts +3 -1
- package/src/countervalues/types.ts +2 -0
- package/src/currencies/__snapshots__/sortByMarketcap.test.ts.snap +1 -0
- package/src/currencies/helpers.test.ts +21 -0
- package/src/currencies/helpers.ts +69 -0
- package/src/currencies/index.ts +1 -0
- package/src/currencies/react.ts +16 -0
- package/src/env.ts +5 -0
- package/src/errors.ts +1 -6
- package/src/families/stellar/__snapshots__/bridge.integration.test.ts.snap +765 -339
- package/src/families/stellar/api/horizon.ts +115 -33
- package/src/families/stellar/api/index.ts +4 -0
- package/src/families/stellar/bridge/mock.ts +3 -0
- package/src/families/stellar/bridge.integration.test.ts +10 -2
- package/src/families/stellar/cli-transaction.ts +75 -2
- package/src/families/stellar/deviceTransactionConfig.ts +22 -0
- package/src/families/stellar/errors.ts +34 -0
- package/src/families/stellar/js-buildTransaction.ts +56 -16
- package/src/families/stellar/js-createTransaction.ts +3 -0
- package/src/families/stellar/js-estimateMaxSpendable.ts +1 -1
- package/src/families/stellar/js-getTransactionStatus.ts +152 -60
- package/src/families/stellar/js-prepareTransaction.ts +4 -3
- package/src/families/stellar/js-signOperation.ts +37 -6
- package/src/families/stellar/js-synchronization.ts +53 -11
- package/src/families/stellar/logic.ts +198 -62
- package/src/families/stellar/specs.ts +227 -8
- package/src/families/stellar/speculos-deviceActions.ts +66 -22
- package/src/families/stellar/tokens.ts +118 -0
- package/src/families/stellar/transaction.ts +31 -3
- package/src/families/stellar/types.ts +52 -0
- package/src/platform/PlatformAppProvider/api/api.mock.ts +11 -11
- package/src/platform/PlatformAppProvider/helpers.ts +0 -48
- package/src/platform/converters.ts +60 -6
- package/src/platform/filters.ts +102 -0
- package/src/platform/helpers.ts +33 -0
- package/src/platform/logic.ts +1 -20
- package/src/platform/providers/RemoteLiveAppProvider/api/mock.json +87 -246
- package/src/platform/react.ts +93 -0
- package/src/platform/types.ts +23 -1
- package/src/platform/version.test.ts +1 -1
- package/src/walletconnect/walletconnect.test.ts +0 -3
|
@@ -1,14 +1,16 @@
|
|
|
1
|
-
import type { Transaction, AccountLike } from "../../types";
|
|
1
|
+
import type { Transaction, AccountLike, Account, AccountLikeArray } from "../../types";
|
|
2
2
|
declare function inferTransactions(transactions: Array<{
|
|
3
3
|
account: AccountLike;
|
|
4
4
|
transaction: Transaction;
|
|
5
5
|
}>, opts: Record<string, any>): Transaction[];
|
|
6
|
+
declare function inferAccounts(account: Account, opts: Record<string, any>): AccountLikeArray;
|
|
6
7
|
declare const _default: {
|
|
7
8
|
options: {
|
|
8
9
|
name: string;
|
|
9
10
|
type: StringConstructor;
|
|
10
11
|
desc: string;
|
|
11
12
|
}[];
|
|
13
|
+
inferAccounts: typeof inferAccounts;
|
|
12
14
|
inferTransactions: typeof inferTransactions;
|
|
13
15
|
};
|
|
14
16
|
export default _default;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli-transaction.d.ts","sourceRoot":"","sources":["../../../src/families/stellar/cli-transaction.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"cli-transaction.d.ts","sourceRoot":"","sources":["../../../src/families/stellar/cli-transaction.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,WAAW,EACX,WAAW,EACX,OAAO,EACP,gBAAgB,EACjB,MAAM,aAAa,CAAC;AAoCrB,iBAAS,iBAAiB,CACxB,YAAY,EAAE,KAAK,CAAC;IAClB,OAAO,EAAE,WAAW,CAAC;IACrB,WAAW,EAAE,WAAW,CAAC;CAC1B,CAAC,EACF,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GACxB,WAAW,EAAE,CAcf;AAED,iBAAS,aAAa,CACpB,OAAO,EAAE,OAAO,EAChB,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GACxB,gBAAgB,CAuClB;;;;;;;;;;AAED,wBAIE"}
|
|
@@ -15,6 +15,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
15
15
|
};
|
|
16
16
|
exports.__esModule = true;
|
|
17
17
|
var invariant_1 = __importDefault(require("invariant"));
|
|
18
|
+
var account_1 = require("../../account");
|
|
19
|
+
var tokens_1 = require("./tokens");
|
|
18
20
|
var options = [
|
|
19
21
|
{
|
|
20
22
|
name: "fee",
|
|
@@ -31,16 +33,60 @@ var options = [
|
|
|
31
33
|
type: String,
|
|
32
34
|
desc: "stellar memo value"
|
|
33
35
|
},
|
|
36
|
+
{
|
|
37
|
+
name: "mode",
|
|
38
|
+
type: String,
|
|
39
|
+
desc: "change operation type"
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
name: "assetIssuer",
|
|
43
|
+
type: String,
|
|
44
|
+
desc: "Asset issuer"
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
name: "assetCode",
|
|
48
|
+
type: String,
|
|
49
|
+
desc: "Same as token"
|
|
50
|
+
},
|
|
34
51
|
];
|
|
35
52
|
function inferTransactions(transactions, opts) {
|
|
36
53
|
return transactions.map(function (_a) {
|
|
37
|
-
var
|
|
54
|
+
var _b;
|
|
55
|
+
var transaction = _a.transaction, account = _a.account;
|
|
38
56
|
(0, invariant_1["default"])(transaction.family === "stellar", "stellar family");
|
|
39
|
-
return __assign(__assign({}, transaction), { memoType: opts.memoType, memoValue: opts.memoValue });
|
|
57
|
+
return __assign(__assign({}, transaction), { subAccountId: account.type === "TokenAccount" ? account.id : null, memoType: opts.memoType, memoValue: opts.memoValue, mode: (_b = opts.mode) !== null && _b !== void 0 ? _b : "send", assetCode: opts.token, assetIssuer: opts.assetIssuer });
|
|
40
58
|
});
|
|
41
59
|
}
|
|
60
|
+
function inferAccounts(account, opts) {
|
|
61
|
+
var _a;
|
|
62
|
+
(0, invariant_1["default"])(account.currency.family === "stellar", "stellar family");
|
|
63
|
+
if (opts.subAccountId) {
|
|
64
|
+
var assetSubAccount = (_a = account.subAccounts) === null || _a === void 0 ? void 0 : _a.find(function (a) { return a.id === opts.subAccountId; });
|
|
65
|
+
if (!assetSubAccount) {
|
|
66
|
+
throw new Error("".concat(opts.subAccountId, " asset not found"));
|
|
67
|
+
}
|
|
68
|
+
return [assetSubAccount];
|
|
69
|
+
}
|
|
70
|
+
if (opts.assetCode) {
|
|
71
|
+
var subAccounts = account.subAccounts || [];
|
|
72
|
+
var subAccount = subAccounts.find(function (sa) {
|
|
73
|
+
var currency = (0, account_1.getAccountCurrency)(sa);
|
|
74
|
+
return (opts.assetCode.toLowerCase() === currency.ticker.toLowerCase() ||
|
|
75
|
+
opts.assetCode.toLowerCase() === (0, tokens_1.getAssetIdFromTokenId)(currency.id));
|
|
76
|
+
});
|
|
77
|
+
if (!subAccount) {
|
|
78
|
+
throw new Error("token account '" +
|
|
79
|
+
opts.assetCode +
|
|
80
|
+
"' not found. Available: " +
|
|
81
|
+
subAccounts.map(function (t) { return (0, account_1.getAccountCurrency)(t).ticker; }).join(", "));
|
|
82
|
+
}
|
|
83
|
+
return [subAccount];
|
|
84
|
+
}
|
|
85
|
+
return [account];
|
|
86
|
+
}
|
|
42
87
|
exports["default"] = {
|
|
43
88
|
options: options,
|
|
89
|
+
inferAccounts: inferAccounts,
|
|
44
90
|
inferTransactions: inferTransactions
|
|
45
91
|
};
|
|
46
92
|
//# sourceMappingURL=cli-transaction.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli-transaction.js","sourceRoot":"","sources":["../../../src/families/stellar/cli-transaction.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,wDAAkC;
|
|
1
|
+
{"version":3,"file":"cli-transaction.js","sour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,CAAC,UAAU,CAAC,CAAC;KACrB;IAED,OAAO,CAAC,OAAO,CAAC,CAAC;AACnB,CAAC;AAED,qBAAe;IACb,OAAO,SAAA;IACP,aAAa,eAAA;IACb,iBAAiB,mBAAA;CAClB,CAAC"}
|
|
@@ -7,8 +7,14 @@ export declare type ExtraDeviceTransactionField = {
|
|
|
7
7
|
} | {
|
|
8
8
|
type: "stellar.network";
|
|
9
9
|
label: string;
|
|
10
|
+
} | {
|
|
11
|
+
type: "stellar.assetCode";
|
|
12
|
+
label: string;
|
|
13
|
+
} | {
|
|
14
|
+
type: "stellar.assetIssuer";
|
|
15
|
+
label: string;
|
|
10
16
|
};
|
|
11
|
-
declare function getDeviceTransactionConfig({ status: { amount, estimatedFees }, }: {
|
|
17
|
+
declare function getDeviceTransactionConfig({ status: { amount, estimatedFees }, transaction, }: {
|
|
12
18
|
account: AccountLike;
|
|
13
19
|
parentAccount: Account | null | undefined;
|
|
14
20
|
transaction: Transaction;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"deviceTransactionConfig.d.ts","sourceRoot":"","sources":["../../../src/families/stellar/deviceTransactionConfig.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAC3E,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAC3C,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,mBAAmB,CAAC;AAEhE,oBAAY,2BAA2B,GACnC;IACE,IAAI,EAAE,cAAc,CAAC;IACrB,KAAK,EAAE,MAAM,CAAC;CACf,GACD;IACE,IAAI,EAAE,iBAAiB,CAAC;IACxB,KAAK,EAAE,MAAM,CAAC;CACf,CAAC;AAEN,iBAAS,0BAA0B,CAAC,EAClC,MAAM,EAAE,EAAE,MAAM,EAAE,aAAa,EAAE,
|
|
1
|
+
{"version":3,"file":"deviceTransactionConfig.d.ts","sourceRoot":"","sources":["../../../src/families/stellar/deviceTransactionConfig.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAC3E,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAC3C,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,mBAAmB,CAAC;AAEhE,oBAAY,2BAA2B,GACnC;IACE,IAAI,EAAE,cAAc,CAAC;IACrB,KAAK,EAAE,MAAM,CAAC;CACf,GACD;IACE,IAAI,EAAE,iBAAiB,CAAC;IACxB,KAAK,EAAE,MAAM,CAAC;CACf,GACD;IACE,IAAI,EAAE,mBAAmB,CAAC;IAC1B,KAAK,EAAE,MAAM,CAAC;CACf,GACD;IACE,IAAI,EAAE,qBAAqB,CAAC;IAC5B,KAAK,EAAE,MAAM,CAAC;CACf,CAAC;AAEN,iBAAS,0BAA0B,CAAC,EAClC,MAAM,EAAE,EAAE,MAAM,EAAE,aAAa,EAAE,EACjC,WAAW,GACZ,EAAE;IACD,OAAO,EAAE,WAAW,CAAC;IACrB,aAAa,EAAE,OAAO,GAAG,IAAI,GAAG,SAAS,CAAC;IAC1C,WAAW,EAAE,WAAW,CAAC;IACzB,MAAM,EAAE,iBAAiB,CAAC;CAC3B,GAAG,KAAK,CAAC,sBAAsB,GAAG,2BAA2B,CAAC,CA0C9D;AAED,eAAe,0BAA0B,CAAC"}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
exports.__esModule = true;
|
|
3
3
|
function getDeviceTransactionConfig(_a) {
|
|
4
|
-
var _b = _a.status, amount = _b.amount, estimatedFees = _b.estimatedFees;
|
|
4
|
+
var _b = _a.status, amount = _b.amount, estimatedFees = _b.estimatedFees, transaction = _a.transaction;
|
|
5
|
+
var assetCode = transaction.assetCode, assetIssuer = transaction.assetIssuer;
|
|
5
6
|
var fields = [
|
|
6
7
|
{
|
|
7
8
|
type: "stellar.network",
|
|
@@ -14,6 +15,16 @@ function getDeviceTransactionConfig(_a) {
|
|
|
14
15
|
label: "Amount"
|
|
15
16
|
});
|
|
16
17
|
}
|
|
18
|
+
if (assetCode && assetIssuer) {
|
|
19
|
+
fields.push({
|
|
20
|
+
type: "stellar.assetCode",
|
|
21
|
+
label: "Asset"
|
|
22
|
+
});
|
|
23
|
+
fields.push({
|
|
24
|
+
type: "stellar.assetIssuer",
|
|
25
|
+
label: "Asset issuer"
|
|
26
|
+
});
|
|
27
|
+
}
|
|
17
28
|
fields.push({
|
|
18
29
|
type: "stellar.memo",
|
|
19
30
|
label: "Memo"
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"deviceTransactionConfig.js","sourceRoot":"","sources":["../../../src/families/stellar/deviceTransactionConfig.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"deviceTransactionConfig.js","sourceRoot":"","sources":["../../../src/families/stellar/deviceTransactionConfig.ts"],"names":[],"mappings":";;AAsBA,SAAS,0BAA0B,CAAC,EAQnC;QAPC,cAAiC,EAAvB,MAAM,YAAA,EAAE,aAAa,mBAAA,EAC/B,WAAW,iBAAA;IAOH,IAAA,SAAS,GAAkB,WAAW,UAA7B,EAAE,WAAW,GAAK,WAAW,YAAhB,CAAiB;IAE/C,IAAM,MAAM,GAAgE;QAC1E;YACE,IAAI,EAAE,iBAAiB;YACvB,KAAK,EAAE,SAAS;SACjB;KACF,CAAC;IAEF,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE,EAAE;QACpB,MAAM,CAAC,IAAI,CAAC;YACV,IAAI,EAAE,QAAQ;YACd,KAAK,EAAE,QAAQ;SAChB,CAAC,CAAC;KACJ;IAED,IAAI,SAAS,IAAI,WAAW,EAAE;QAC5B,MAAM,CAAC,IAAI,CAAC;YACV,IAAI,EAAE,mBAAmB;YACzB,KAAK,EAAE,OAAO;SACf,CAAC,CAAC;QACH,MAAM,CAAC,IAAI,CAAC;YACV,IAAI,EAAE,qBAAqB;YAC3B,KAAK,EAAE,cAAc;SACtB,CAAC,CAAC;KACJ;IAED,MAAM,CAAC,IAAI,CAAC;QACV,IAAI,EAAE,cAAc;QACpB,KAAK,EAAE,MAAM;KACd,CAAC,CAAC;IAEH,6CAA6C;IAC7C,IAAI,aAAa,IAAI,CAAC,aAAa,CAAC,MAAM,EAAE,EAAE;QAC5C,MAAM,CAAC,IAAI,CAAC;YACV,IAAI,EAAE,MAAM;YACZ,KAAK,EAAE,MAAM;SACd,CAAC,CAAC;KACJ;IAED,OAAO,MAAM,CAAC;AAChB,CAAC;AAED,qBAAe,0BAA0B,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export declare const StellarMemoRecommended: import("@ledgerhq/errors/lib/helpers").CustomErrorFunc;
|
|
2
|
+
export declare const StellarWrongMemoFormat: import("@ledgerhq/errors/lib/helpers").CustomErrorFunc;
|
|
3
|
+
export declare const StellarAssetRequired: import("@ledgerhq/errors/lib/helpers").CustomErrorFunc;
|
|
4
|
+
export declare const StellarAssetNotAccepted: import("@ledgerhq/errors/lib/helpers").CustomErrorFunc;
|
|
5
|
+
export declare const StellarAssetNotFound: import("@ledgerhq/errors/lib/helpers").CustomErrorFunc;
|
|
6
|
+
export declare const StellarNotEnoughNativeBalance: import("@ledgerhq/errors/lib/helpers").CustomErrorFunc;
|
|
7
|
+
export declare const StellarFeeSmallerThanRecommended: import("@ledgerhq/errors/lib/helpers").CustomErrorFunc;
|
|
8
|
+
export declare const StellarFeeSmallerThanBase: import("@ledgerhq/errors/lib/helpers").CustomErrorFunc;
|
|
9
|
+
export declare const StellarNotEnoughNativeBalanceToAddTrustline: import("@ledgerhq/errors/lib/helpers").CustomErrorFunc;
|
|
10
|
+
export declare const StellarMuxedAccountNotExist: import("@ledgerhq/errors/lib/helpers").CustomErrorFunc;
|
|
11
|
+
export declare const StellarSourceHasMultiSign: import("@ledgerhq/errors/lib/helpers").CustomErrorFunc;
|
|
12
|
+
//# sourceMappingURL=errors.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../../src/families/stellar/errors.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,sBAAsB,wDAElC,CAAC;AACF,eAAO,MAAM,sBAAsB,wDAElC,CAAC;AACF,eAAO,MAAM,oBAAoB,wDAEhC,CAAC;AACF,eAAO,MAAM,uBAAuB,wDAEnC,CAAC;AACF,eAAO,MAAM,oBAAoB,wDAEhC,CAAC;AACF,eAAO,MAAM,6BAA6B,wDAEzC,CAAC;AACF,eAAO,MAAM,gCAAgC,wDAE5C,CAAC;AACF,eAAO,MAAM,yBAAyB,wDAErC,CAAC;AACF,eAAO,MAAM,2CAA2C,wDACe,CAAC;AACxE,eAAO,MAAM,2BAA2B,wDAEvC,CAAC;AACF,eAAO,MAAM,yBAAyB,wDAErC,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
exports.__esModule = true;
|
|
3
|
+
exports.StellarSourceHasMultiSign = exports.StellarMuxedAccountNotExist = exports.StellarNotEnoughNativeBalanceToAddTrustline = exports.StellarFeeSmallerThanBase = exports.StellarFeeSmallerThanRecommended = exports.StellarNotEnoughNativeBalance = exports.StellarAssetNotFound = exports.StellarAssetNotAccepted = exports.StellarAssetRequired = exports.StellarWrongMemoFormat = exports.StellarMemoRecommended = void 0;
|
|
4
|
+
var errors_1 = require("@ledgerhq/errors");
|
|
5
|
+
exports.StellarMemoRecommended = (0, errors_1.createCustomErrorClass)("StellarMemoRecommended");
|
|
6
|
+
exports.StellarWrongMemoFormat = (0, errors_1.createCustomErrorClass)("StellarWrongMemoFormat");
|
|
7
|
+
exports.StellarAssetRequired = (0, errors_1.createCustomErrorClass)("StellarAssetRequired");
|
|
8
|
+
exports.StellarAssetNotAccepted = (0, errors_1.createCustomErrorClass)("StellarAssetNotAccepted");
|
|
9
|
+
exports.StellarAssetNotFound = (0, errors_1.createCustomErrorClass)("StellarAssetNotFound");
|
|
10
|
+
exports.StellarNotEnoughNativeBalance = (0, errors_1.createCustomErrorClass)("StellarNotEnoughNativeBalance");
|
|
11
|
+
exports.StellarFeeSmallerThanRecommended = (0, errors_1.createCustomErrorClass)("StellarFeeSmallerThanRecommended");
|
|
12
|
+
exports.StellarFeeSmallerThanBase = (0, errors_1.createCustomErrorClass)("StellarFeeSmallerThanBase");
|
|
13
|
+
exports.StellarNotEnoughNativeBalanceToAddTrustline = (0, errors_1.createCustomErrorClass)("StellarNotEnoughNativeBalanceToAddTrustline");
|
|
14
|
+
exports.StellarMuxedAccountNotExist = (0, errors_1.createCustomErrorClass)("StellarMuxedAccountNotExist");
|
|
15
|
+
exports.StellarSourceHasMultiSign = (0, errors_1.createCustomErrorClass)("StellarSourceHasMultiSign");
|
|
16
|
+
//# sourceMappingURL=errors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../../../src/families/stellar/errors.ts"],"names":[],"mappings":";;;AAAA,2CAA0D;AAE7C,QAAA,sBAAsB,GAAG,IAAA,+BAAsB,EAC1D,wBAAwB,CACzB,CAAC;AACW,QAAA,sBAAsB,GAAG,IAAA,+BAAsB,EAC1D,wBAAwB,CACzB,CAAC;AACW,QAAA,oBAAoB,GAAG,IAAA,+BAAsB,EACxD,sBAAsB,CACvB,CAAC;AACW,QAAA,uBAAuB,GAAG,IAAA,+BAAsB,EAC3D,yBAAyB,CAC1B,CAAC;AACW,QAAA,oBAAoB,GAAG,IAAA,+BAAsB,EACxD,sBAAsB,CACvB,CAAC;AACW,QAAA,6BAA6B,GAAG,IAAA,+BAAsB,EACjE,+BAA+B,CAChC,CAAC;AACW,QAAA,gCAAgC,GAAG,IAAA,+BAAsB,EACpE,kCAAkC,CACnC,CAAC;AACW,QAAA,yBAAyB,GAAG,IAAA,+BAAsB,EAC7D,2BAA2B,CAC5B,CAAC;AACW,QAAA,2CAA2C,GACtD,IAAA,+BAAsB,EAAC,6CAA6C,CAAC,CAAC;AAC3D,QAAA,2BAA2B,GAAG,IAAA,+BAAsB,EAC/D,6BAA6B,CAC9B,CAAC;AACW,QAAA,yBAAyB,GAAG,IAAA,+BAAsB,EAC7D,2BAA2B,CAC5B,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"js-buildTransaction.d.ts","sourceRoot":"","sources":["../../../src/families/stellar/js-buildTransaction.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"js-buildTransaction.d.ts","sourceRoot":"","sources":["../../../src/families/stellar/js-buildTransaction.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAC3C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAc3C;;;GAGG;AACH,eAAO,MAAM,gBAAgB,YAClB,OAAO,eACH,WAAW,KACvB,QAAQ,GAAG,CA4Fb,CAAC;AACF,eAAe,gBAAgB,CAAC"}
|
|
@@ -41,48 +41,66 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
41
41
|
exports.__esModule = true;
|
|
42
42
|
exports.buildTransaction = void 0;
|
|
43
43
|
var invariant_1 = __importDefault(require("invariant"));
|
|
44
|
-
var bignumber_js_1 = require("bignumber.js");
|
|
45
44
|
var stellar_sdk_1 = __importDefault(require("stellar-sdk"));
|
|
46
45
|
var errors_1 = require("@ledgerhq/errors");
|
|
47
46
|
var api_1 = require("./api");
|
|
48
47
|
var logic_1 = require("./logic");
|
|
48
|
+
var errors_2 = require("../../errors");
|
|
49
49
|
/**
|
|
50
50
|
* @param {Account} a
|
|
51
51
|
* @param {Transaction} t
|
|
52
52
|
*/
|
|
53
53
|
var buildTransaction = function (account, transaction) { return __awaiter(void 0, void 0, void 0, function () {
|
|
54
|
-
var recipient,
|
|
54
|
+
var recipient, networkInfo, fees, memoType, memoValue, mode, assetCode, assetIssuer, source, transactionBuilder, operation, amount, recipientAccount, memo, built;
|
|
55
55
|
return __generator(this, function (_a) {
|
|
56
56
|
switch (_a.label) {
|
|
57
57
|
case 0:
|
|
58
|
-
recipient = transaction.recipient,
|
|
58
|
+
recipient = transaction.recipient, networkInfo = transaction.networkInfo, fees = transaction.fees, memoType = transaction.memoType, memoValue = transaction.memoValue, mode = transaction.mode, assetCode = transaction.assetCode, assetIssuer = transaction.assetIssuer;
|
|
59
59
|
if (!fees) {
|
|
60
60
|
throw new errors_1.FeeNotLoaded();
|
|
61
61
|
}
|
|
62
|
-
(0, invariant_1["default"])(networkInfo && networkInfo.family === "stellar", "stellar family");
|
|
63
|
-
amount = new bignumber_js_1.BigNumber(0);
|
|
64
|
-
amount =
|
|
65
|
-
useAllAmount && networkInfo
|
|
66
|
-
? account.balance.minus(networkInfo.baseReserve).minus(fees)
|
|
67
|
-
: transaction.amount;
|
|
68
|
-
if (!amount)
|
|
69
|
-
throw new errors_1.AmountRequired();
|
|
70
62
|
return [4 /*yield*/, (0, api_1.loadAccount)(account.freshAddress)];
|
|
71
63
|
case 1:
|
|
72
64
|
source = _a.sent();
|
|
73
|
-
if (!source)
|
|
65
|
+
if (!source) {
|
|
74
66
|
throw new errors_1.NetworkDown();
|
|
67
|
+
}
|
|
68
|
+
(0, invariant_1["default"])(networkInfo && networkInfo.family === "stellar", "stellar family");
|
|
75
69
|
transactionBuilder = (0, api_1.buildTransactionBuilder)(source, fees);
|
|
76
70
|
operation = null;
|
|
77
|
-
return [
|
|
71
|
+
if (!(mode === "changeTrust")) return [3 /*break*/, 2];
|
|
72
|
+
if (!assetCode || !assetIssuer) {
|
|
73
|
+
throw new errors_2.StellarAssetRequired("");
|
|
74
|
+
}
|
|
75
|
+
operation = (0, api_1.buildChangeTrustOperation)(assetCode, assetIssuer);
|
|
76
|
+
return [3 /*break*/, 4];
|
|
78
77
|
case 2:
|
|
79
|
-
|
|
80
|
-
if (
|
|
81
|
-
|
|
78
|
+
amount = (0, logic_1.getAmountValue)(account, transaction, fees);
|
|
79
|
+
if (!amount) {
|
|
80
|
+
throw new errors_1.AmountRequired();
|
|
81
|
+
}
|
|
82
|
+
return [4 /*yield*/, (0, logic_1.getRecipientAccount)({
|
|
83
|
+
account: account,
|
|
84
|
+
recipient: transaction.recipient
|
|
85
|
+
})];
|
|
86
|
+
case 3:
|
|
87
|
+
recipientAccount = _a.sent();
|
|
88
|
+
if (recipientAccount === null || recipientAccount === void 0 ? void 0 : recipientAccount.id) {
|
|
89
|
+
operation = (0, api_1.buildPaymentOperation)({
|
|
90
|
+
destination: recipient,
|
|
91
|
+
amount: amount,
|
|
92
|
+
assetCode: assetCode,
|
|
93
|
+
assetIssuer: assetIssuer
|
|
94
|
+
});
|
|
82
95
|
}
|
|
83
96
|
else {
|
|
97
|
+
if (recipientAccount === null || recipientAccount === void 0 ? void 0 : recipientAccount.isMuxedAccount) {
|
|
98
|
+
throw new errors_2.StellarMuxedAccountNotExist("");
|
|
99
|
+
}
|
|
84
100
|
operation = (0, api_1.buildCreateAccountOperation)(recipient, amount);
|
|
85
101
|
}
|
|
102
|
+
_a.label = 4;
|
|
103
|
+
case 4:
|
|
86
104
|
transactionBuilder.addOperation(operation);
|
|
87
105
|
memo = null;
|
|
88
106
|
if (memoType && memoValue) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"js-buildTransaction.js","sourceRoot":"","sources":["../../../src/families/stellar/js-buildTransaction.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,wDAAkC;AAClC,
|
|
1
|
+
{"version":3,"file":"js-buildTransaction.js","sourceRoot":"","sources":["../../../src/families/stellar/js-buildTransaction.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,wDAAkC;AAClC,4DAAqC;AACrC,2CAA6E;AAG7E,6BAMe;AACf,iCAA8D;AAC9D,uCAGsB;AAEtB;;;GAGG;AACI,IAAM,gBAAgB,GAAG,UAC9B,OAAgB,EAChB,WAAwB;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FW,QAAA,gBAAgB,oBA+F3B;AACF,qBAAe,wBAAgB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"js-createTransaction.d.ts","sourceRoot":"","sources":["../../../src/families/stellar/js-createTransaction.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAE3C;;;;GAIG;AACH,QAAA,MAAM,iBAAiB,QAAO,
|
|
1
|
+
{"version":3,"file":"js-createTransaction.d.ts","sourceRoot":"","sources":["../../../src/families/stellar/js-createTransaction.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAE3C;;;;GAIG;AACH,QAAA,MAAM,iBAAiB,QAAO,WAa5B,CAAC;AAEH,eAAe,iBAAiB,CAAC"}
|
|
@@ -15,7 +15,10 @@ var createTransaction = function () { return ({
|
|
|
15
15
|
recipient: "",
|
|
16
16
|
memoValue: null,
|
|
17
17
|
memoType: null,
|
|
18
|
-
useAllAmount: false
|
|
18
|
+
useAllAmount: false,
|
|
19
|
+
mode: "send",
|
|
20
|
+
assetCode: "",
|
|
21
|
+
assetIssuer: ""
|
|
19
22
|
}); };
|
|
20
23
|
exports["default"] = createTransaction;
|
|
21
24
|
//# sourceMappingURL=js-createTransaction.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"js-createTransaction.js","sourceRoot":"","sources":["../../../src/families/stellar/js-createTransaction.ts"],"names":[],"mappings":";;AAAA,6CAAyC;AAGzC;;;;GAIG;AACH,IAAM,iBAAiB,GAAG,cAAmB,OAAA,CAAC;IAC5C,MAAM,EAAE,SAAS;IACjB,MAAM,EAAE,IAAI,wBAAS,CAAC,CAAC,CAAC;IACxB,WAAW,EAAE,IAAI;IACjB,WAAW,EAAE,IAAI;IACjB,IAAI,EAAE,IAAI;IACV,SAAS,EAAE,EAAE;IACb,SAAS,EAAE,IAAI;IACf,QAAQ,EAAE,IAAI;IACd,YAAY,EAAE,KAAK;
|
|
1
|
+
{"version":3,"file":"js-createTransaction.js","sourceRoot":"","sources":["../../../src/families/stellar/js-createTransaction.ts"],"names":[],"mappings":";;AAAA,6CAAyC;AAGzC;;;;GAIG;AACH,IAAM,iBAAiB,GAAG,cAAmB,OAAA,CAAC;IAC5C,MAAM,EAAE,SAAS;IACjB,MAAM,EAAE,IAAI,wBAAS,CAAC,CAAC,CAAC;IACxB,WAAW,EAAE,IAAI;IACjB,WAAW,EAAE,IAAI;IACjB,IAAI,EAAE,IAAI;IACV,SAAS,EAAE,EAAE;IACb,SAAS,EAAE,IAAI;IACf,QAAQ,EAAE,IAAI;IACd,YAAY,EAAE,KAAK;IACnB,IAAI,EAAE,MAAM;IACZ,SAAS,EAAE,EAAE;IACb,WAAW,EAAE,EAAE;CAChB,CAAC,EAb2C,CAa3C,CAAC;AAEH,qBAAe,iBAAiB,CAAC"}
|
|
@@ -54,6 +54,7 @@ var account_1 = require("../../account");
|
|
|
54
54
|
var js_createTransaction_1 = __importDefault(require("./js-createTransaction"));
|
|
55
55
|
var js_prepareTransaction_1 = __importDefault(require("./js-prepareTransaction"));
|
|
56
56
|
var js_getTransactionStatus_1 = __importDefault(require("./js-getTransactionStatus"));
|
|
57
|
+
var bignumber_js_1 = __importDefault(require("bignumber.js"));
|
|
57
58
|
var notCreatedStellarMockAddress = "GAW46JE3SHIAYLNNNQCAZFQ437WB5ZH7LDRDWR5LVDWHCTHCKYB6RCCH";
|
|
58
59
|
var estimateMaxSpendable = function (_a) {
|
|
59
60
|
var account = _a.account, parentAccount = _a.parentAccount, transaction = _a.transaction;
|
|
@@ -71,7 +72,7 @@ var estimateMaxSpendable = function (_a) {
|
|
|
71
72
|
return [4 /*yield*/, (0, js_getTransactionStatus_1["default"])(mainAccount, t)];
|
|
72
73
|
case 2:
|
|
73
74
|
s = _b.sent();
|
|
74
|
-
return [2 /*return*/, s.amount];
|
|
75
|
+
return [2 /*return*/, s.amount.gte(0) ? s.amount : new bignumber_js_1["default"](0)];
|
|
75
76
|
}
|
|
76
77
|
});
|
|
77
78
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"js-estimateMaxSpendable.js","sourceRoot":"","sources":["../../../src/families/stellar/js-estimateMaxSpendable.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,yCAA+C;AAC/C,gFAAuD;AACvD,kFAAyD;AACzD,sFAA6D;
|
|
1
|
+
{"version":3,"file":"js-estimateMaxSpendable.js","sourceRoot":"","sources":["../../../src/families/stellar/js-estimateMaxSpendable.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,yCAA+C;AAC/C,gFAAuD;AACvD,kFAAyD;AACzD,sFAA6D;AAG7D,8DAAqC;AAErC,IAAM,4BAA4B,GAChC,0DAA0D,CAAC;AAE7D,IAAM,oBAAoB,GAAG,UAAO,EAQnC;QAPC,OAAO,aAAA,EACP,aAAa,mBAAA,EACb,WAAW,iBAAA;;;;;;oBAML,WAAW,GAAG,IAAA,wBAAc,EAAC,OAAO,EAAE,aAAa,CAAC,CAAC;oBACjD,qBAAM,IAAA,kCAAkB,EAAC,WAAW,iCACzC,IAAA,iCAAiB,GAAE,GACnB,WAAW,KACd,SAAS,EAAE,CAAA,WAAW,aAAX,WAAW,uBAAX,WAAW,CAAE,SAAS,KAAI,4BAA4B;4BACjE,mBAAmB;4BACnB,YAAY,EAAE,IAAI,IAClB,EAAA;;oBANI,CAAC,GAAG,SAMR;oBACQ,qBAAM,IAAA,oCAAoB,EAAC,WAAW,EAAE,CAAC,CAAC,EAAA;;oBAA9C,CAAC,GAAG,SAA0C;oBACpD,sBAAO,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,yBAAS,CAAC,CAAC,CAAC,EAAC;;;;CACtD,CAAC;AAEF,qBAAe,oBAAoB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"js-getTransactionStatus.d.ts","sourceRoot":"","sources":["../../../src/families/stellar/js-getTransactionStatus.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"js-getTransactionStatus.d.ts","sourceRoot":"","sources":["../../../src/families/stellar/js-getTransactionStatus.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AA0BzC,OAAO,KAAK,EAAE,OAAO,EAAgB,MAAM,aAAa,CAAC;AACzD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAS3C,QAAA,MAAM,oBAAoB,MACrB,OAAO,KACP,WAAW;YAEN,OAAO,MAAM,EAAE,KAAK,CAAC;cACnB,OAAO,MAAM,EAAE,KAAK,CAAC;mBAChB,SAAS;YAChB,SAAS;gBACL,SAAS;EAgLtB,CAAC;AAEF,eAAe,oBAAoB,CAAC"}
|
|
@@ -39,86 +39,156 @@ exports.__esModule = true;
|
|
|
39
39
|
var bignumber_js_1 = require("bignumber.js");
|
|
40
40
|
var errors_1 = require("@ledgerhq/errors");
|
|
41
41
|
var errors_2 = require("../../errors");
|
|
42
|
+
var account_1 = require("../../account");
|
|
42
43
|
var currencies_1 = require("../../currencies");
|
|
43
44
|
var logic_1 = require("./logic");
|
|
45
|
+
var api_1 = require("./api");
|
|
44
46
|
var getTransactionStatus = function (a, t) { return __awaiter(void 0, void 0, void 0, function () {
|
|
45
|
-
var errors, warnings, useAllAmount, estimatedFees, baseReserve, amount, totalSpent,
|
|
46
|
-
|
|
47
|
-
|
|
47
|
+
var errors, warnings, useAllAmount, destinationNotExistMessage, estimatedFees, baseReserve, isAssetPayment, nativeBalance, nativeAmountAvailable, amount, maxAmount, totalSpent, recipientAccount, asset, assetBalance;
|
|
48
|
+
var _a, _b;
|
|
49
|
+
return __generator(this, function (_c) {
|
|
50
|
+
switch (_c.label) {
|
|
48
51
|
case 0:
|
|
49
52
|
errors = {};
|
|
50
53
|
warnings = {};
|
|
51
54
|
useAllAmount = !!t.useAllAmount;
|
|
55
|
+
destinationNotExistMessage = new errors_1.NotEnoughBalanceBecauseDestinationNotCreated("", {
|
|
56
|
+
minimalAmount: "".concat(api_1.MIN_BALANCE, " XLM")
|
|
57
|
+
});
|
|
52
58
|
if (a.pendingOperations.length > 0) {
|
|
53
59
|
throw new errors_2.AccountAwaitingSendPendingOperations();
|
|
54
60
|
}
|
|
55
|
-
if (!t.recipient) {
|
|
56
|
-
errors.recipient = new errors_1.RecipientRequired("");
|
|
57
|
-
}
|
|
58
|
-
else if (a.freshAddress === t.recipient) {
|
|
59
|
-
errors.recipient = new errors_1.InvalidAddressBecauseDestinationIsAlsoSource();
|
|
60
|
-
}
|
|
61
|
-
else if (!(0, logic_1.isAddressValid)(t.recipient)) {
|
|
62
|
-
errors.recipient = new errors_1.InvalidAddress("");
|
|
63
|
-
}
|
|
64
|
-
return [4 /*yield*/, (0, logic_1.isAccountMultiSign)(a)];
|
|
65
|
-
case 1:
|
|
66
|
-
if (_b.sent()) {
|
|
67
|
-
errors.recipient = new errors_2.SourceHasMultiSign("", {
|
|
68
|
-
currencyName: a.currency.name
|
|
69
|
-
});
|
|
70
|
-
}
|
|
71
61
|
if (!t.fees || !t.baseReserve) {
|
|
72
62
|
errors.fees = new errors_1.FeeNotLoaded();
|
|
73
63
|
}
|
|
74
64
|
estimatedFees = !t.fees ? new bignumber_js_1.BigNumber(0) : t.fees;
|
|
75
65
|
baseReserve = !t.baseReserve ? new bignumber_js_1.BigNumber(0) : t.baseReserve;
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
66
|
+
isAssetPayment = t.subAccountId && t.assetCode && t.assetIssuer;
|
|
67
|
+
nativeBalance = a.balance;
|
|
68
|
+
nativeAmountAvailable = a.spendableBalance.minus(estimatedFees);
|
|
69
|
+
amount = new bignumber_js_1.BigNumber(0);
|
|
70
|
+
maxAmount = new bignumber_js_1.BigNumber(0);
|
|
71
|
+
totalSpent = new bignumber_js_1.BigNumber(0);
|
|
72
|
+
// Enough native balance to cover transaction (with required reserve + fees)
|
|
73
|
+
if (!errors.amount && nativeAmountAvailable.lt(0)) {
|
|
74
|
+
errors.amount = new errors_2.StellarNotEnoughNativeBalance();
|
|
75
|
+
}
|
|
76
|
+
// Entered fee is smaller than base fee
|
|
77
|
+
if (estimatedFees.lt(((_a = t.networkInfo) === null || _a === void 0 ? void 0 : _a.baseFee) || 0)) {
|
|
78
|
+
errors.transaction = new errors_2.StellarFeeSmallerThanBase();
|
|
79
|
+
// Entered fee is smaller than recommended
|
|
89
80
|
}
|
|
90
|
-
if (
|
|
91
|
-
|
|
92
|
-
errors.amount = new errors_1.NotEnoughBalance();
|
|
81
|
+
else if (estimatedFees.lt(((_b = t.networkInfo) === null || _b === void 0 ? void 0 : _b.fees) || 0)) {
|
|
82
|
+
warnings.transaction = new errors_2.StellarFeeSmallerThanRecommended();
|
|
93
83
|
}
|
|
94
|
-
if (!
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
amount = new bignumber_js_1.BigNumber(0);
|
|
84
|
+
if (!(t.mode === "changeTrust")) return [3 /*break*/, 1];
|
|
85
|
+
// Check asset provided
|
|
86
|
+
if (!t.assetCode || !t.assetIssuer) {
|
|
87
|
+
// This is unlikely
|
|
88
|
+
errors.transaction = new errors_2.StellarAssetRequired("");
|
|
100
89
|
}
|
|
101
|
-
|
|
102
|
-
|
|
90
|
+
// Has enough native balance to add new trustline
|
|
91
|
+
if (nativeAmountAvailable.minus(api_1.BASE_RESERVE).lt(0)) {
|
|
92
|
+
errors.amount = new errors_2.StellarNotEnoughNativeBalanceToAddTrustline();
|
|
103
93
|
}
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
94
|
+
return [3 /*break*/, 3];
|
|
95
|
+
case 1:
|
|
96
|
+
// Payment
|
|
97
|
+
// Check recipient address
|
|
98
|
+
if (!t.recipient) {
|
|
99
|
+
errors.recipient = new errors_1.RecipientRequired("");
|
|
100
|
+
}
|
|
101
|
+
else if (!(0, logic_1.isAddressValid)(t.recipient)) {
|
|
102
|
+
errors.recipient = new errors_1.InvalidAddress("");
|
|
103
|
+
}
|
|
104
|
+
else if (a.freshAddress === t.recipient) {
|
|
105
|
+
errors.recipient = new errors_1.InvalidAddressBecauseDestinationIsAlsoSource();
|
|
106
|
+
}
|
|
107
|
+
return [4 /*yield*/, (0, logic_1.getRecipientAccount)({
|
|
109
108
|
account: a,
|
|
110
109
|
recipient: t.recipient
|
|
111
110
|
})];
|
|
112
111
|
case 2:
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
112
|
+
recipientAccount = _c.sent();
|
|
113
|
+
// Check recipient account
|
|
114
|
+
if (!(recipientAccount === null || recipientAccount === void 0 ? void 0 : recipientAccount.id) && !errors.recipient && !warnings.recipient) {
|
|
115
|
+
if (recipientAccount === null || recipientAccount === void 0 ? void 0 : recipientAccount.isMuxedAccount) {
|
|
116
|
+
errors.recipient = new errors_2.StellarMuxedAccountNotExist();
|
|
117
|
+
}
|
|
118
|
+
else {
|
|
119
|
+
if (isAssetPayment) {
|
|
120
|
+
errors.recipient = destinationNotExistMessage;
|
|
121
|
+
}
|
|
122
|
+
else {
|
|
123
|
+
warnings.recipient = destinationNotExistMessage;
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
// Asset payment
|
|
128
|
+
if (isAssetPayment) {
|
|
129
|
+
asset = (0, account_1.findSubAccountById)(a, t.subAccountId || "");
|
|
130
|
+
if (asset === null) {
|
|
131
|
+
// This is unlikely
|
|
132
|
+
throw new errors_2.StellarAssetNotFound();
|
|
133
|
+
}
|
|
134
|
+
// Check recipient account accepts asset
|
|
135
|
+
if ((recipientAccount === null || recipientAccount === void 0 ? void 0 : recipientAccount.id) &&
|
|
136
|
+
!errors.recipient &&
|
|
137
|
+
!warnings.recipient &&
|
|
138
|
+
!recipientAccount.assetIds.includes("".concat(t.assetCode, ":").concat(t.assetIssuer))) {
|
|
139
|
+
errors.recipient = new errors_2.StellarAssetNotAccepted("", {
|
|
140
|
+
assetCode: t.assetCode
|
|
141
|
+
});
|
|
142
|
+
}
|
|
143
|
+
assetBalance = (asset === null || asset === void 0 ? void 0 : asset.balance) || new bignumber_js_1.BigNumber(0);
|
|
144
|
+
maxAmount = (asset === null || asset === void 0 ? void 0 : asset.spendableBalance) || assetBalance;
|
|
145
|
+
amount = useAllAmount ? maxAmount : t.amount;
|
|
146
|
+
totalSpent = amount;
|
|
147
|
+
if (!errors.amount && amount.gt(assetBalance)) {
|
|
148
|
+
errors.amount = new errors_1.NotEnoughBalance();
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
else {
|
|
152
|
+
// Native payment
|
|
153
|
+
maxAmount = nativeAmountAvailable;
|
|
154
|
+
amount = useAllAmount ? maxAmount : t.amount || 0;
|
|
155
|
+
if (amount.gt(maxAmount)) {
|
|
156
|
+
errors.amount = new errors_1.NotEnoughBalance();
|
|
157
|
+
}
|
|
158
|
+
totalSpent = useAllAmount
|
|
159
|
+
? nativeAmountAvailable
|
|
160
|
+
: t.amount.plus(estimatedFees);
|
|
161
|
+
// Need to send at least 1 XLM to create an account
|
|
162
|
+
if (!errors.recipient &&
|
|
163
|
+
!(recipientAccount === null || recipientAccount === void 0 ? void 0 : recipientAccount.id) &&
|
|
164
|
+
!errors.amount &&
|
|
165
|
+
amount.lt(10000000)) {
|
|
166
|
+
errors.amount = destinationNotExistMessage;
|
|
167
|
+
}
|
|
168
|
+
if (totalSpent.gt(nativeBalance.minus(baseReserve))) {
|
|
169
|
+
errors.amount = new errors_1.NotEnoughSpendableBalance(undefined, {
|
|
170
|
+
minimumAmount: (0, currencies_1.formatCurrencyUnit)(a.currency.units[0], baseReserve, {
|
|
171
|
+
disableRounding: true,
|
|
172
|
+
showCode: true
|
|
173
|
+
})
|
|
174
|
+
});
|
|
175
|
+
}
|
|
176
|
+
if (!errors.recipient &&
|
|
177
|
+
!errors.amount &&
|
|
178
|
+
(amount.lt(0) || totalSpent.gt(nativeBalance))) {
|
|
179
|
+
errors.amount = new errors_1.NotEnoughBalance();
|
|
180
|
+
totalSpent = new bignumber_js_1.BigNumber(0);
|
|
181
|
+
amount = new bignumber_js_1.BigNumber(0);
|
|
182
|
+
}
|
|
183
|
+
if (!errors.amount && amount.eq(0)) {
|
|
184
|
+
errors.amount = new errors_1.AmountRequired();
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
_c.label = 3;
|
|
188
|
+
case 3: return [4 /*yield*/, (0, logic_1.isAccountMultiSign)(a)];
|
|
189
|
+
case 4:
|
|
190
|
+
if (_c.sent()) {
|
|
191
|
+
errors.recipient = new errors_2.StellarSourceHasMultiSign();
|
|
122
192
|
}
|
|
123
193
|
if (t.memoType && t.memoValue && !(0, logic_1.isMemoValid)(t.memoType, t.memoValue)) {
|
|
124
194
|
errors.transaction = new errors_2.StellarWrongMemoFormat();
|