@ledgerhq/coin-hedera 1.10.1 → 1.10.2-nightly.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 +1 -0
- package/CHANGELOG.md +10 -0
- package/lib/api/mirror.d.ts +3 -20
- package/lib/api/mirror.d.ts.map +1 -1
- package/lib/api/mirror.js +32 -90
- package/lib/api/mirror.js.map +1 -1
- package/lib/api/mirror.test.js +59 -4
- package/lib/api/mirror.test.js.map +1 -1
- package/lib/api/network.d.ts +3 -3
- package/lib/api/network.d.ts.map +1 -1
- package/lib/api/network.js +46 -3
- package/lib/api/network.js.map +1 -1
- package/lib/api/types.d.ts +44 -0
- package/lib/api/types.d.ts.map +1 -0
- package/lib/api/types.js +3 -0
- package/lib/api/types.js.map +1 -0
- package/lib/api/utils.d.ts +8 -0
- package/lib/api/utils.d.ts.map +1 -0
- package/lib/api/utils.js +132 -0
- package/lib/api/utils.js.map +1 -0
- package/lib/bridge/broadcast.d.ts.map +1 -1
- package/lib/bridge/broadcast.js +2 -0
- package/lib/bridge/broadcast.js.map +1 -1
- package/lib/bridge/buildOptimisticOperation.d.ts +2 -2
- package/lib/bridge/buildOptimisticOperation.d.ts.map +1 -1
- package/lib/bridge/buildOptimisticOperation.integration.test.d.ts +2 -0
- package/lib/bridge/buildOptimisticOperation.integration.test.d.ts.map +1 -0
- package/lib/bridge/buildOptimisticOperation.integration.test.js +82 -0
- package/lib/bridge/buildOptimisticOperation.integration.test.js.map +1 -0
- package/lib/bridge/buildOptimisticOperation.js +87 -5
- package/lib/bridge/buildOptimisticOperation.js.map +1 -1
- package/lib/bridge/estimateMaxSpendable.d.ts.map +1 -1
- package/lib/bridge/estimateMaxSpendable.js +8 -2
- package/lib/bridge/estimateMaxSpendable.js.map +1 -1
- package/lib/bridge/getTransactionStatus.d.ts +3 -3
- package/lib/bridge/getTransactionStatus.d.ts.map +1 -1
- package/lib/bridge/getTransactionStatus.js +116 -23
- package/lib/bridge/getTransactionStatus.js.map +1 -1
- package/lib/bridge/getTransactionStatus.test.d.ts +2 -0
- package/lib/bridge/getTransactionStatus.test.d.ts.map +1 -0
- package/lib/bridge/getTransactionStatus.test.js +176 -0
- package/lib/bridge/getTransactionStatus.test.js.map +1 -0
- package/lib/bridge/index.d.ts +4 -4
- package/lib/bridge/index.d.ts.map +1 -1
- package/lib/bridge/index.js +9 -6
- package/lib/bridge/index.js.map +1 -1
- package/lib/bridge/js-estimateMaxSpendable.integration.test.js +28 -44
- package/lib/bridge/js-estimateMaxSpendable.integration.test.js.map +1 -1
- package/lib/bridge/js-transaction.test.js +10 -49
- package/lib/bridge/js-transaction.test.js.map +1 -1
- package/lib/bridge/prepareTransaction.d.ts +0 -1
- package/lib/bridge/prepareTransaction.d.ts.map +1 -1
- package/lib/bridge/prepareTransaction.js +0 -1
- package/lib/bridge/prepareTransaction.js.map +1 -1
- package/lib/bridge/serialization.d.ts +7 -0
- package/lib/bridge/serialization.d.ts.map +1 -0
- package/lib/bridge/serialization.js +36 -0
- package/lib/bridge/serialization.js.map +1 -0
- package/lib/bridge/serialization.test.d.ts +2 -0
- package/lib/bridge/serialization.test.d.ts.map +1 -0
- package/lib/bridge/serialization.test.js +27 -0
- package/lib/bridge/serialization.test.js.map +1 -0
- package/lib/bridge/synchronisation.d.ts +3 -3
- package/lib/bridge/synchronisation.d.ts.map +1 -1
- package/lib/bridge/synchronisation.js +37 -15
- package/lib/bridge/synchronisation.js.map +1 -1
- package/lib/bridge/transaction.test.js +18 -59
- package/lib/bridge/transaction.test.js.map +1 -1
- package/lib/bridge/utils.d.ts +22 -8
- package/lib/bridge/utils.d.ts.map +1 -1
- package/lib/bridge/utils.integration.test.js +415 -73
- package/lib/bridge/utils.integration.test.js.map +1 -1
- package/lib/bridge/utils.js +300 -15
- package/lib/bridge/utils.js.map +1 -1
- package/lib/constants.d.ts +32 -0
- package/lib/constants.d.ts.map +1 -0
- package/lib/constants.js +37 -0
- package/lib/constants.js.map +1 -0
- package/lib/deviceTransactionConfig.d.ts.map +1 -1
- package/lib/deviceTransactionConfig.js +17 -15
- package/lib/deviceTransactionConfig.js.map +1 -1
- package/lib/logic.d.ts +9 -3
- package/lib/logic.d.ts.map +1 -1
- package/lib/logic.js +31 -3
- package/lib/logic.js.map +1 -1
- package/lib/logic.test.js +103 -50
- package/lib/logic.test.js.map +1 -1
- package/lib/test/fixtures/account.fixture.d.ts +19 -0
- package/lib/test/fixtures/account.fixture.d.ts.map +1 -0
- package/lib/test/fixtures/account.fixture.js +116 -0
- package/lib/test/fixtures/account.fixture.js.map +1 -0
- package/lib/test/fixtures/currency.fixture.d.ts +5 -0
- package/lib/test/fixtures/currency.fixture.d.ts.map +1 -0
- package/lib/test/fixtures/currency.fixture.js +67 -0
- package/lib/test/fixtures/currency.fixture.js.map +1 -0
- package/lib/test/fixtures/mirror.fixture.d.ts +3 -0
- package/lib/test/fixtures/mirror.fixture.d.ts.map +1 -0
- package/lib/test/fixtures/mirror.fixture.js +17 -0
- package/lib/test/fixtures/mirror.fixture.js.map +1 -0
- package/lib/test/fixtures/operation.fixture.d.ts +3 -0
- package/lib/test/fixtures/operation.fixture.d.ts.map +1 -0
- package/lib/test/fixtures/operation.fixture.js +26 -0
- package/lib/test/fixtures/operation.fixture.js.map +1 -0
- package/lib/test/fixtures/transaction.fixture.d.ts +4 -0
- package/lib/test/fixtures/transaction.fixture.d.ts.map +1 -0
- package/lib/test/fixtures/transaction.fixture.js +28 -0
- package/lib/test/fixtures/transaction.fixture.js.map +1 -0
- package/lib/types/bridge.d.ts +25 -1
- package/lib/types/bridge.d.ts.map +1 -1
- package/lib-es/api/mirror.d.ts +3 -20
- package/lib-es/api/mirror.d.ts.map +1 -1
- package/lib-es/api/mirror.js +29 -88
- package/lib-es/api/mirror.js.map +1 -1
- package/lib-es/api/mirror.test.js +60 -5
- package/lib-es/api/mirror.test.js.map +1 -1
- package/lib-es/api/network.d.ts +3 -3
- package/lib-es/api/network.d.ts.map +1 -1
- package/lib-es/api/network.js +44 -4
- package/lib-es/api/network.js.map +1 -1
- package/lib-es/api/types.d.ts +44 -0
- package/lib-es/api/types.d.ts.map +1 -0
- package/lib-es/api/types.js +2 -0
- package/lib-es/api/types.js.map +1 -0
- package/lib-es/api/utils.d.ts +8 -0
- package/lib-es/api/utils.d.ts.map +1 -0
- package/lib-es/api/utils.js +124 -0
- package/lib-es/api/utils.js.map +1 -0
- package/lib-es/bridge/broadcast.d.ts.map +1 -1
- package/lib-es/bridge/broadcast.js +2 -0
- package/lib-es/bridge/broadcast.js.map +1 -1
- package/lib-es/bridge/buildOptimisticOperation.d.ts +2 -2
- package/lib-es/bridge/buildOptimisticOperation.d.ts.map +1 -1
- package/lib-es/bridge/buildOptimisticOperation.integration.test.d.ts +2 -0
- package/lib-es/bridge/buildOptimisticOperation.integration.test.d.ts.map +1 -0
- package/lib-es/bridge/buildOptimisticOperation.integration.test.js +77 -0
- package/lib-es/bridge/buildOptimisticOperation.integration.test.js.map +1 -0
- package/lib-es/bridge/buildOptimisticOperation.js +84 -5
- package/lib-es/bridge/buildOptimisticOperation.js.map +1 -1
- package/lib-es/bridge/estimateMaxSpendable.d.ts.map +1 -1
- package/lib-es/bridge/estimateMaxSpendable.js +8 -2
- package/lib-es/bridge/estimateMaxSpendable.js.map +1 -1
- package/lib-es/bridge/getTransactionStatus.d.ts +3 -3
- package/lib-es/bridge/getTransactionStatus.d.ts.map +1 -1
- package/lib-es/bridge/getTransactionStatus.js +114 -24
- package/lib-es/bridge/getTransactionStatus.js.map +1 -1
- package/lib-es/bridge/getTransactionStatus.test.d.ts +2 -0
- package/lib-es/bridge/getTransactionStatus.test.d.ts.map +1 -0
- package/lib-es/bridge/getTransactionStatus.test.js +148 -0
- package/lib-es/bridge/getTransactionStatus.test.js.map +1 -0
- package/lib-es/bridge/index.d.ts +4 -4
- package/lib-es/bridge/index.d.ts.map +1 -1
- package/lib-es/bridge/index.js +9 -6
- package/lib-es/bridge/index.js.map +1 -1
- package/lib-es/bridge/js-estimateMaxSpendable.integration.test.js +28 -44
- package/lib-es/bridge/js-estimateMaxSpendable.integration.test.js.map +1 -1
- package/lib-es/bridge/js-transaction.test.js +10 -49
- package/lib-es/bridge/js-transaction.test.js.map +1 -1
- package/lib-es/bridge/prepareTransaction.d.ts +0 -1
- package/lib-es/bridge/prepareTransaction.d.ts.map +1 -1
- package/lib-es/bridge/prepareTransaction.js +0 -1
- package/lib-es/bridge/prepareTransaction.js.map +1 -1
- package/lib-es/bridge/serialization.d.ts +7 -0
- package/lib-es/bridge/serialization.d.ts.map +1 -0
- package/lib-es/bridge/serialization.js +29 -0
- package/lib-es/bridge/serialization.js.map +1 -0
- package/lib-es/bridge/serialization.test.d.ts +2 -0
- package/lib-es/bridge/serialization.test.d.ts.map +1 -0
- package/lib-es/bridge/serialization.test.js +25 -0
- package/lib-es/bridge/serialization.test.js.map +1 -0
- package/lib-es/bridge/synchronisation.d.ts +3 -3
- package/lib-es/bridge/synchronisation.d.ts.map +1 -1
- package/lib-es/bridge/synchronisation.js +39 -17
- package/lib-es/bridge/synchronisation.js.map +1 -1
- package/lib-es/bridge/transaction.test.js +18 -59
- package/lib-es/bridge/transaction.test.js.map +1 -1
- package/lib-es/bridge/utils.d.ts +22 -8
- package/lib-es/bridge/utils.d.ts.map +1 -1
- package/lib-es/bridge/utils.integration.test.js +416 -74
- package/lib-es/bridge/utils.integration.test.js.map +1 -1
- package/lib-es/bridge/utils.js +295 -15
- package/lib-es/bridge/utils.js.map +1 -1
- package/lib-es/constants.d.ts +32 -0
- package/lib-es/constants.d.ts.map +1 -0
- package/lib-es/constants.js +34 -0
- package/lib-es/constants.js.map +1 -0
- package/lib-es/deviceTransactionConfig.d.ts.map +1 -1
- package/lib-es/deviceTransactionConfig.js +17 -15
- package/lib-es/deviceTransactionConfig.js.map +1 -1
- package/lib-es/logic.d.ts +9 -3
- package/lib-es/logic.d.ts.map +1 -1
- package/lib-es/logic.js +26 -3
- package/lib-es/logic.js.map +1 -1
- package/lib-es/logic.test.js +104 -51
- package/lib-es/logic.test.js.map +1 -1
- package/lib-es/test/fixtures/account.fixture.d.ts +19 -0
- package/lib-es/test/fixtures/account.fixture.d.ts.map +1 -0
- package/lib-es/test/fixtures/account.fixture.js +107 -0
- package/lib-es/test/fixtures/account.fixture.js.map +1 -0
- package/lib-es/test/fixtures/currency.fixture.d.ts +5 -0
- package/lib-es/test/fixtures/currency.fixture.d.ts.map +1 -0
- package/lib-es/test/fixtures/currency.fixture.js +58 -0
- package/lib-es/test/fixtures/currency.fixture.js.map +1 -0
- package/lib-es/test/fixtures/mirror.fixture.d.ts +3 -0
- package/lib-es/test/fixtures/mirror.fixture.d.ts.map +1 -0
- package/lib-es/test/fixtures/mirror.fixture.js +13 -0
- package/lib-es/test/fixtures/mirror.fixture.js.map +1 -0
- package/lib-es/test/fixtures/operation.fixture.d.ts +3 -0
- package/lib-es/test/fixtures/operation.fixture.d.ts.map +1 -0
- package/lib-es/test/fixtures/operation.fixture.js +19 -0
- package/lib-es/test/fixtures/operation.fixture.js.map +1 -0
- package/lib-es/test/fixtures/transaction.fixture.d.ts +4 -0
- package/lib-es/test/fixtures/transaction.fixture.d.ts.map +1 -0
- package/lib-es/test/fixtures/transaction.fixture.js +20 -0
- package/lib-es/test/fixtures/transaction.fixture.js.map +1 -0
- package/lib-es/types/bridge.d.ts +25 -1
- package/lib-es/types/bridge.d.ts.map +1 -1
- package/package.json +11 -9
- package/src/api/mirror.test.ts +79 -5
- package/src/api/mirror.ts +30 -111
- package/src/api/network.ts +71 -4
- package/src/api/types.ts +48 -0
- package/src/api/utils.ts +150 -0
- package/src/bridge/broadcast.ts +2 -0
- package/src/bridge/buildOptimisticOperation.integration.test.ts +88 -0
- package/src/bridge/buildOptimisticOperation.ts +118 -7
- package/src/bridge/estimateMaxSpendable.ts +8 -2
- package/src/bridge/getTransactionStatus.test.ts +200 -0
- package/src/bridge/getTransactionStatus.ts +166 -32
- package/src/bridge/index.ts +13 -10
- package/src/bridge/js-estimateMaxSpendable.integration.test.ts +37 -46
- package/src/bridge/js-transaction.test.ts +13 -54
- package/src/bridge/prepareTransaction.ts +1 -2
- package/src/bridge/serialization.test.ts +39 -0
- package/src/bridge/serialization.ts +43 -0
- package/src/bridge/synchronisation.ts +65 -27
- package/src/bridge/transaction.test.ts +22 -64
- package/src/bridge/utils.integration.test.ts +525 -76
- package/src/bridge/utils.ts +423 -24
- package/src/constants.ts +35 -0
- package/src/deviceTransactionConfig.ts +16 -15
- package/src/logic.test.ts +147 -57
- package/src/logic.ts +58 -7
- package/src/test/fixtures/account.fixture.ts +123 -0
- package/src/test/fixtures/currency.fixture.ts +66 -0
- package/src/test/fixtures/mirror.fixture.ts +14 -0
- package/src/test/fixtures/operation.fixture.ts +20 -0
- package/src/test/fixtures/transaction.fixture.ts +22 -0
- package/src/types/bridge.ts +33 -0
package/lib-es/bridge/index.js
CHANGED
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
import { getSerializedAddressParameters, makeScanAccounts, makeSync, updateTransaction, } from "@ledgerhq/coin-framework/bridge/jsHelpers";
|
|
2
|
-
import resolver from "../signer/index";
|
|
3
2
|
import getAddressWrapper from "@ledgerhq/coin-framework/bridge/getAddressWrapper";
|
|
4
|
-
import {
|
|
3
|
+
import { broadcast } from "./broadcast";
|
|
4
|
+
import { createTransaction } from "./createTransaction";
|
|
5
5
|
import { estimateMaxSpendable } from "./estimateMaxSpendable";
|
|
6
|
+
import { getTransactionStatus } from "./getTransactionStatus";
|
|
6
7
|
import { prepareTransaction } from "./prepareTransaction";
|
|
7
|
-
import { createTransaction } from "./createTransaction";
|
|
8
|
-
import { getAccountShape, buildIterateResult } from "./synchronisation";
|
|
9
|
-
import { buildSignOperation } from "./signOperation";
|
|
10
|
-
import { broadcast } from "./broadcast";
|
|
11
8
|
import { receive } from "./receive";
|
|
9
|
+
import { buildSignOperation } from "./signOperation";
|
|
10
|
+
import { getAccountShape, buildIterateResult } from "./synchronisation";
|
|
11
|
+
import { assignFromAccountRaw, assignToAccountRaw } from "./serialization";
|
|
12
|
+
import resolver from "../signer/index";
|
|
12
13
|
function buildCurrencyBridge(signerContext) {
|
|
13
14
|
const getAddress = resolver(signerContext);
|
|
14
15
|
const scanAccounts = makeScanAccounts({
|
|
@@ -32,6 +33,8 @@ function buildAccountBridge(signerContext) {
|
|
|
32
33
|
updateTransaction,
|
|
33
34
|
getTransactionStatus,
|
|
34
35
|
prepareTransaction,
|
|
36
|
+
assignToAccountRaw,
|
|
37
|
+
assignFromAccountRaw,
|
|
35
38
|
sync,
|
|
36
39
|
receive: receive(getAddressWrapper(getAddress)),
|
|
37
40
|
signOperation,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/bridge/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,8BAA8B,EAC9B,gBAAgB,EAChB,QAAQ,EACR,iBAAiB,GAClB,MAAM,2CAA2C,CAAC;AACnD,OAAO,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/bridge/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,8BAA8B,EAC9B,gBAAgB,EAChB,QAAQ,EACR,iBAAiB,GAClB,MAAM,2CAA2C,CAAC;AACnD,OAAO,iBAAiB,MAAM,mDAAmD,CAAC;AAGlF,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAC9D,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAC9D,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AACrD,OAAO,EAAE,eAAe,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CA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ils";
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
id: "",
|
|
8
|
-
seedIdentifier: "",
|
|
9
|
-
derivationMode: "",
|
|
10
|
-
index: 0,
|
|
11
|
-
freshAddress: "",
|
|
12
|
-
freshAddressPath: "",
|
|
13
|
-
used: false,
|
|
14
|
-
balance: new BigNumber(100000000),
|
|
15
|
-
spendableBalance: new BigNumber(0),
|
|
16
|
-
creationDate: new Date(),
|
|
17
|
-
blockHeight: 0,
|
|
18
|
-
currency: {
|
|
19
|
-
type: "CryptoCurrency",
|
|
20
|
-
id: "hedera",
|
|
21
|
-
managerAppName: "",
|
|
22
|
-
coinType: 0,
|
|
23
|
-
scheme: "",
|
|
24
|
-
color: "",
|
|
25
|
-
family: "",
|
|
26
|
-
explorerViews: [],
|
|
27
|
-
name: "",
|
|
28
|
-
ticker: "",
|
|
29
|
-
units: [],
|
|
30
|
-
},
|
|
31
|
-
operationsCount: 0,
|
|
32
|
-
operations: [],
|
|
33
|
-
pendingOperations: [],
|
|
34
|
-
lastSyncDate: new Date(),
|
|
35
|
-
balanceHistoryCache: {
|
|
36
|
-
HOUR: { latestDate: null, balances: [] },
|
|
37
|
-
DAY: { latestDate: null, balances: [] },
|
|
38
|
-
WEEK: { latestDate: null, balances: [] },
|
|
39
|
-
},
|
|
40
|
-
swapHistory: [],
|
|
41
|
-
};
|
|
4
|
+
import { getMockedAccount, getMockedTokenAccount } from "../test/fixtures/account.fixture";
|
|
5
|
+
import { getMockedTokenCurrency } from "../test/fixtures/currency.fixture";
|
|
6
|
+
import { HEDERA_OPERATION_TYPES } from "../constants";
|
|
42
7
|
describe("js-estimateMaxSpendable", () => {
|
|
43
8
|
let bridge;
|
|
44
|
-
let estimatedFees
|
|
9
|
+
let estimatedFees;
|
|
45
10
|
beforeAll(async () => {
|
|
46
11
|
const signer = jest.fn();
|
|
47
12
|
bridge = createBridges(signer);
|
|
48
|
-
|
|
13
|
+
const mockedAccount = getMockedAccount();
|
|
14
|
+
const crypto = await getEstimatedFees(mockedAccount, HEDERA_OPERATION_TYPES.CryptoTransfer);
|
|
15
|
+
estimatedFees = { crypto };
|
|
49
16
|
});
|
|
50
|
-
test("estimateMaxSpendable", async () => {
|
|
17
|
+
test("estimateMaxSpendable returns balance minus fee", async () => {
|
|
18
|
+
const mockedAccount = getMockedAccount();
|
|
51
19
|
const result = await bridge.accountBridge.estimateMaxSpendable({
|
|
52
|
-
account,
|
|
20
|
+
account: mockedAccount,
|
|
53
21
|
});
|
|
54
|
-
|
|
55
|
-
|
|
22
|
+
expect(result).toEqual(mockedAccount.balance.minus(estimatedFees.crypto));
|
|
23
|
+
});
|
|
24
|
+
test("estimateMaxSpendable returns 0 if balance < estimated fees", async () => {
|
|
25
|
+
const mockedAccount = getMockedAccount({ balance: estimatedFees.crypto.minus(1) });
|
|
26
|
+
const result = await bridge.accountBridge.estimateMaxSpendable({
|
|
27
|
+
account: mockedAccount,
|
|
28
|
+
});
|
|
29
|
+
expect(result).toEqual(new BigNumber(0));
|
|
30
|
+
});
|
|
31
|
+
test("estimateMaxSpendable returns token balance for token account", async () => {
|
|
32
|
+
const mockedTokenCurrency = getMockedTokenCurrency();
|
|
33
|
+
const mockedTokenAccount = getMockedTokenAccount(mockedTokenCurrency);
|
|
34
|
+
const mockedAccount = getMockedAccount({ subAccounts: [mockedTokenAccount] });
|
|
35
|
+
const result = await bridge.accountBridge.estimateMaxSpendable({
|
|
36
|
+
account: mockedTokenAccount,
|
|
37
|
+
parentAccount: mockedAccount,
|
|
38
|
+
});
|
|
39
|
+
expect(result).toEqual(mockedTokenAccount.balance);
|
|
56
40
|
});
|
|
57
41
|
});
|
|
58
42
|
//# sourceMappingURL=js-estimateMaxSpendable.integration.test.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"js-estimateMaxSpendable.integration.test.js","sourceRoot":"","sources":["../../src/bridge/js-estimateMaxSpendable.integration.test.ts"],"names":[],"mappings":"AAAA,OAAO,SAAS,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"js-estimateMaxSpendable.integration.test.js","sourceRoot":"","sources":["../../src/bridge/js-estimateMaxSpendable.integration.test.ts"],"names":[],"mappings":"AAAA,OAAO,SAAS,MAAM,cAAc,CAAC;AACrC,OAAO,EAAE,aAAa,EAAE,MAAM,GAAG,CAAC;AAClC,OAAO,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAC3C,OAAO,EAAE,gBAAgB,EAAE,qBAAqB,EAAE,MAAM,kCAAkC,CAAC;AAC3F,OAAO,EAAE,sBAAsB,EAAE,MAAM,mCAAmC,CAAC;AAC3E,OAAO,EAAE,sBAAsB,EAAE,MAAM,cAAc,CAAC;AAEtD,QAAQ,CAAC,yBAAyB,EAAE,GAAG,EAAE;IACvC,IAAI,MAAwC,CAAC;IAC7C,IAAI,aAA0C,CAAC;IAE/C,SAAS,CAAC,KAAK,IAAI,EAAE;QACnB,MAAM,MAAM,GAAG,IAAI,CAAC,EAAE,EAAE,CAAC;QACzB,MAAM,GAAG,aAAa,CAAC,MAAM,CAAC,CAAC;QAE/B,MAAM,aAAa,GAAG,gBAAgB,EAAE,CAAC;QACzC,MAAM,MAAM,GAAG,MAAM,gBAAgB,CAAC,aAAa,EAAE,sBAAsB,CAAC,cAAc,CAAC,CAAC;QAE5F,aAAa,GAAG,EAAE,MAAM,EAAE,CAAC;IAC7B,CAAC,CAAC,CAAC;IAEH,IAAI,CAAC,gDAAgD,EAAE,KAAK,IAAI,EAAE;QAChE,MAAM,aAAa,GAAG,gBAAgB,EAAE,CAAC;QAEzC,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC,aAAa,CAAC,oBAAoB,CAAC;YAC7D,OAAO,EAAE,aAAa;SACvB,CAAC,CAAC;QAEH,MAAM,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,aAAa,CAAC,OAAO,CAAC,KAAK,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC,CAAC;IAC5E,CAAC,CAAC,CAAC;IAEH,IAAI,CAAC,4DAA4D,EAAE,KAAK,IAAI,EAAE;QAC5E,MAAM,aAAa,GAAG,gBAAgB,CAAC,EAAE,OAAO,EAAE,aAAa,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;QAEnF,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC,aAAa,CAAC,oBAAoB,CAAC;YAC7D,OAAO,EAAE,aAAa;SACvB,CAAC,CAAC;QAEH,MAAM,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,IAAI,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC;IAC3C,CAAC,CAAC,CAAC;IAEH,IAAI,CAAC,8DAA8D,EAAE,KAAK,IAAI,EAAE;QAC9E,MAAM,mBAAmB,GAAG,sBAAsB,EAAE,CAAC;QACrD,MAAM,kBAAkB,GAAG,qBAAqB,CAAC,mBAAmB,CAAC,CAAC;QACtE,MAAM,aAAa,GAAG,gBAAgB,CAAC,EAAE,WAAW,EAAE,CAAC,kBAAkB,CAAC,EAAE,CAAC,CAAC;QAE9E,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC,aAAa,CAAC,oBAAoB,CAAC;YAC7D,OAAO,EAAE,kBAAkB;YAC3B,aAAa,EAAE,aAAa;SAC7B,CAAC,CAAC;QAEH,MAAM,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,kBAAkB,CAAC,OAAO,CAAC,CAAC;IACrD,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -1,58 +1,19 @@
|
|
|
1
1
|
import BigNumber from "bignumber.js";
|
|
2
2
|
import { updateTransaction } from "@ledgerhq/coin-framework/bridge/jsHelpers";
|
|
3
3
|
import { createBridges } from ".";
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
id: "",
|
|
7
|
-
seedIdentifier: "",
|
|
8
|
-
derivationMode: "",
|
|
9
|
-
index: 0,
|
|
10
|
-
freshAddress: "",
|
|
11
|
-
freshAddressPath: "",
|
|
12
|
-
used: false,
|
|
13
|
-
balance: new BigNumber(200000),
|
|
14
|
-
spendableBalance: new BigNumber(0),
|
|
15
|
-
creationDate: new Date(),
|
|
16
|
-
blockHeight: 0,
|
|
17
|
-
currency: {
|
|
18
|
-
type: "CryptoCurrency",
|
|
19
|
-
id: "hedera",
|
|
20
|
-
managerAppName: "",
|
|
21
|
-
coinType: 0,
|
|
22
|
-
scheme: "",
|
|
23
|
-
color: "",
|
|
24
|
-
family: "",
|
|
25
|
-
explorerViews: [],
|
|
26
|
-
name: "",
|
|
27
|
-
ticker: "",
|
|
28
|
-
units: [],
|
|
29
|
-
},
|
|
30
|
-
operationsCount: 0,
|
|
31
|
-
operations: [],
|
|
32
|
-
pendingOperations: [],
|
|
33
|
-
lastSyncDate: new Date(),
|
|
34
|
-
balanceHistoryCache: {
|
|
35
|
-
HOUR: { latestDate: null, balances: [] },
|
|
36
|
-
DAY: { latestDate: null, balances: [] },
|
|
37
|
-
WEEK: { latestDate: null, balances: [] },
|
|
38
|
-
},
|
|
39
|
-
swapHistory: [],
|
|
40
|
-
};
|
|
41
|
-
const transaction = {
|
|
42
|
-
family: "hedera",
|
|
43
|
-
amount: new BigNumber(0),
|
|
44
|
-
recipient: "",
|
|
45
|
-
useAllAmount: false,
|
|
46
|
-
};
|
|
4
|
+
import { getMockedAccount } from "../test/fixtures/account.fixture";
|
|
5
|
+
import { getMockedTransaction } from "../test/fixtures/transaction.fixture";
|
|
47
6
|
describe("js-transaction", () => {
|
|
48
7
|
let bridge;
|
|
8
|
+
const mockedAccount = getMockedAccount();
|
|
9
|
+
const mockedTransaction = getMockedTransaction();
|
|
49
10
|
beforeAll(() => {
|
|
50
11
|
const signer = jest.fn();
|
|
51
12
|
bridge = createBridges(signer);
|
|
52
13
|
});
|
|
53
14
|
test("createTransaction", () => {
|
|
54
|
-
const data =
|
|
55
|
-
const result = bridge.accountBridge.createTransaction(
|
|
15
|
+
const data = mockedTransaction;
|
|
16
|
+
const result = bridge.accountBridge.createTransaction(mockedAccount);
|
|
56
17
|
expect(result).toEqual(data);
|
|
57
18
|
});
|
|
58
19
|
test("updateTransaction", () => {
|
|
@@ -61,13 +22,13 @@ describe("js-transaction", () => {
|
|
|
61
22
|
recipient: "0.0.3",
|
|
62
23
|
useAllAmount: true,
|
|
63
24
|
};
|
|
64
|
-
const data = { ...
|
|
65
|
-
const result = updateTransaction(
|
|
25
|
+
const data = { ...mockedTransaction, ...patch };
|
|
26
|
+
const result = updateTransaction(mockedTransaction, patch);
|
|
66
27
|
expect(result).toEqual(data);
|
|
67
28
|
});
|
|
68
29
|
test("prepareTransaction", async () => {
|
|
69
|
-
const data =
|
|
70
|
-
const result = await bridge.accountBridge.prepareTransaction(
|
|
30
|
+
const data = mockedTransaction;
|
|
31
|
+
const result = await bridge.accountBridge.prepareTransaction(mockedAccount, mockedTransaction);
|
|
71
32
|
expect(result).toEqual(data);
|
|
72
33
|
});
|
|
73
34
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"js-transaction.test.js","sourceRoot":"","sources":["../../src/bridge/js-transaction.test.ts"],"names":[],"mappings":"AAAA,OAAO,SAAS,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"js-transaction.test.js","sourceRoot":"","sources":["../../src/bridge/js-transaction.test.ts"],"names":[],"mappings":"AAAA,OAAO,SAAS,MAAM,cAAc,CAAC;AACrC,OAAO,EAAE,iBAAiB,EAAE,MAAM,2CAA2C,CAAC;AAC9E,OAAO,EAAE,aAAa,EAAE,MAAM,GAAG,CAAC;AAClC,OAAO,EAAE,gBAAgB,EAAE,MAAM,kCAAkC,CAAC;AACpE,OAAO,EAAE,oBAAoB,EAAE,MAAM,sCAAsC,CAAC;AAG5E,QAAQ,CAAC,gBAAgB,EAAE,GAAG,EAAE;IAC9B,IAAI,MAAwC,CAAC;IAC7C,MAAM,aAAa,GAAG,gBAAgB,EAAE,CAAC;IACzC,MAAM,iBAAiB,GAAG,oBAAoB,EAAE,CAAC;IAEjD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imate ahead-of-time.
|
|
9
9
|
*
|
|
10
|
-
* @returns {Transaction}
|
|
11
10
|
*/
|
|
12
11
|
export declare const prepareTransaction: AccountBridge<Transaction>["prepareTransaction"];
|
|
13
12
|
//# sourceMappingURL=prepareTransaction.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prepareTransaction.d.ts","sourceRoot":"","sources":["../../src/bridge/prepareTransaction.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAG5C
|
|
1
|
+
{"version":3,"file":"prepareTransaction.d.ts","sourceRoot":"","sources":["../../src/bridge/prepareTransaction.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAG5C;;;;;;;GAOG;AACH,eAAO,MAAM,kBAAkB,EAAE,aAAa,CAAC,WAAW,CAAC,CAAC,oBAAoB,CAU/E,CAAC"}
|
|
@@ -6,7 +6,6 @@ import { calculateAmount } from "./utils";
|
|
|
6
6
|
* Hedera has fully client-side transactions and the fee
|
|
7
7
|
* is not possible to estimate ahead-of-time.
|
|
8
8
|
*
|
|
9
|
-
* @returns {Transaction}
|
|
10
9
|
*/
|
|
11
10
|
export const prepareTransaction = async (account, transaction) => {
|
|
12
11
|
// explicitly calculate transaction amount to account for `useAllAmount` flag (send max flow)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prepareTransaction.js","sourceRoot":"","sources":["../../src/bridge/prepareTransaction.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAE1C
|
|
1
|
+
{"version":3,"file":"prepareTransaction.js","sourceRoot":"","sources":["../../src/bridge/prepareTransaction.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAE1C;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAqD,KAAK,EACvF,OAAO,EACP,WAAW,EACW,EAAE;IACxB,6FAA6F;IAC7F,uHAAuH;IACvH,MAAM,EAAE,MAAM,EAAE,GAAG,MAAM,eAAe,CAAC,EAAE,OAAO,EAAE,WAAW,EAAE,CAAC,CAAC;IACnE,WAAW,CAAC,MAAM,GAAG,MAAM,CAAC;IAE5B,OAAO,WAAW,CAAC;AACrB,CAAC,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { AccountRaw, Account } from "@ledgerhq/types-live";
|
|
2
|
+
import type { HederaResources, HederaResourcesRaw } from "../types";
|
|
3
|
+
export declare function toHederaResourcesRaw(resources: HederaResources): HederaResourcesRaw;
|
|
4
|
+
export declare function fromHederaResourcesRaw(rawResources: HederaResourcesRaw): HederaResources;
|
|
5
|
+
export declare function assignToAccountRaw(account: Account, accountRaw: AccountRaw): void;
|
|
6
|
+
export declare function assignFromAccountRaw(accountRaw: AccountRaw, account: Account): void;
|
|
7
|
+
//# sourceMappingURL=serialization.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"serialization.d.ts","sourceRoot":"","sources":["../../src/bridge/serialization.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAChE,OAAO,KAAK,EAGV,eAAe,EACf,kBAAkB,EACnB,MAAM,UAAU,CAAC;AAElB,wBAAgB,oBAAoB,CAAC,SAAS,EAAE,eAAe,GAAG,kBAAkB,CAOnF;AAED,wBAAgB,sBAAsB,CAAC,YAAY,EAAE,kBAAkB,GAAG,eAAe,CAOxF;AAED,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,UAAU,GAAG,IAAI,CAOjF;AAED,wBAAgB,oBAAoB,CAAC,UAAU,EAAE,UAAU,EAAE,OAAO,EAAE,OAAO,QAO5E"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
export function toHederaResourcesRaw(resources) {
|
|
2
|
+
const { maxAutomaticTokenAssociations, isAutoTokenAssociationEnabled } = resources;
|
|
3
|
+
return {
|
|
4
|
+
maxAutomaticTokenAssociations,
|
|
5
|
+
isAutoTokenAssociationEnabled,
|
|
6
|
+
};
|
|
7
|
+
}
|
|
8
|
+
export function fromHederaResourcesRaw(rawResources) {
|
|
9
|
+
const { maxAutomaticTokenAssociations, isAutoTokenAssociationEnabled } = rawResources;
|
|
10
|
+
return {
|
|
11
|
+
maxAutomaticTokenAssociations,
|
|
12
|
+
isAutoTokenAssociationEnabled,
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
export function assignToAccountRaw(account, accountRaw) {
|
|
16
|
+
const hederaAccount = account;
|
|
17
|
+
const hederaAccountRaw = accountRaw;
|
|
18
|
+
if (hederaAccount.hederaResources) {
|
|
19
|
+
hederaAccountRaw.hederaResources = toHederaResourcesRaw(hederaAccount.hederaResources);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
export function assignFromAccountRaw(accountRaw, account) {
|
|
23
|
+
const hederaAccount = account;
|
|
24
|
+
const hederaAccountRaw = accountRaw;
|
|
25
|
+
if (hederaAccountRaw.hederaResources) {
|
|
26
|
+
hederaAccount.hederaResources = fromHederaResourcesRaw(hederaAccountRaw.hederaResources);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
//# sourceMappingURL=serialization.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"serialization.js","sourceRoot":"","sources":["../../src/bridge/serialization.ts"],"names":[],"mappings":"AAQA,MAAM,UAAU,oBAAoB,CAAC,SAA0B;IAC7D,MAAM,EAAE,6BAA6B,EAAE,6BAA6B,EAAE,GAAG,SAAS,CAAC;IAEnF,OAAO;QACL,6BAA6B;QAC7B,6BAA6B;KAC9B,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,sBAAsB,CAAC,YAAgC;IACrE,MAAM,EAAE,6BAA6B,EAAE,6BAA6B,EAAE,GAAG,YAAY,CAAC;IAEtF,OAAO;QACL,6BAA6B;QAC7B,6BAA6B;KAC9B,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,kBAAkB,CAAC,OAAgB,EAAE,UAAsB;IACzE,MAAM,aAAa,GAAG,OAAwB,CAAC;IAC/C,MAAM,gBAAgB,GAAG,UAA8B,CAAC;IAExD,IAAI,aAAa,CAAC,eAAe,EAAE,CAAC;QAClC,gBAAgB,CAAC,eAAe,GAAG,oBAAoB,CAAC,aAAa,CAAC,eAAe,CAAC,CAAC;IACzF,CAAC;AACH,CAAC;AAED,MAAM,UAAU,oBAAoB,CAAC,UAAsB,EAAE,OAAgB;IAC3E,MAAM,aAAa,GAAG,OAAwB,CAAC;IAC/C,MAAM,gBAAgB,GAAG,UAA8B,CAAC;IAExD,IAAI,gBAAgB,CAAC,eAAe,EAAE,CAAC;QACrC,aAAa,CAAC,eAAe,GAAG,sBAAsB,CAAC,gBAAgB,CAAC,eAAe,CAAC,CAAC;IAC3F,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"serialization.test.d.ts","sourceRoot":"","sources":["../../src/bridge/serialization.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { getMockedAccount, getMockedAccountRaw, mockHederaResources, mockHederaResourcesRaw, } from "../test/fixtures/account.fixture";
|
|
2
|
+
import { assignFromAccountRaw, assignToAccountRaw, fromHederaResourcesRaw, toHederaResourcesRaw, } from "./serialization";
|
|
3
|
+
const mockedAccount = getMockedAccount();
|
|
4
|
+
const mockedAccountRaw = getMockedAccountRaw();
|
|
5
|
+
describe("serialization", () => {
|
|
6
|
+
test("toHederaResourcesRaw should convert HederaResources to HederaResourcesRaw", () => {
|
|
7
|
+
const result = toHederaResourcesRaw(mockHederaResources);
|
|
8
|
+
expect(result).toEqual(mockHederaResourcesRaw);
|
|
9
|
+
});
|
|
10
|
+
test("fromHederaResourcesRaw should convert HederaResourcesRaw to HederaResources", () => {
|
|
11
|
+
const result = fromHederaResourcesRaw(mockHederaResourcesRaw);
|
|
12
|
+
expect(result).toEqual(mockHederaResources);
|
|
13
|
+
});
|
|
14
|
+
test("assignToAccountRaw should assign HederaResources to AccountRaw", () => {
|
|
15
|
+
assignToAccountRaw(mockedAccount, mockedAccountRaw);
|
|
16
|
+
expect(typeof mockedAccountRaw.hederaResources).toBe("object");
|
|
17
|
+
expect(mockedAccountRaw.hederaResources).not.toBeNull();
|
|
18
|
+
});
|
|
19
|
+
test("assignFromAccountRaw should assign HederaResourcesRaw to Account", () => {
|
|
20
|
+
assignFromAccountRaw(mockedAccountRaw, mockedAccount);
|
|
21
|
+
expect(typeof mockedAccountRaw.hederaResources).toBe("object");
|
|
22
|
+
expect(mockedAccountRaw.hederaResources).not.toBeNull();
|
|
23
|
+
});
|
|
24
|
+
});
|
|
25
|
+
//# sourceMappingURL=serialization.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"serialization.test.js","sourceRoot":"","sources":["../../src/bridge/serialization.test.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,gBAAgB,EAChB,mBAAmB,EACnB,mBAAmB,EACnB,sBAAsB,GACvB,MAAM,kCAAkC,CAAC;AAC1C,OAAO,EACL,oBAAoB,EACpB,kBAAkB,EAClB,sBAAsB,EACtB,oBAAoB,GACrB,MAAM,iBAAiB,CAAC;AAEzB,MAAM,aAAa,GAAG,gBAAgB,EAAE,CAAC;AACzC,MAAM,gBAAgB,GAAG,mBAAmB,EAAE,CAAC;AAE/C,QAAQ,CAAC,eAAe,EAAE,GAAG,EAAE;IAC7B,IAAI,CAAC,2EAA2E,EAAE,GAAG,EAAE;QACrF,MAAM,MAAM,GAAG,oBAAoB,CAAC,mBAAmB,CAAC,CAAC;QACzD,MAAM,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,sBAAsB,CAAC,CAAC;IACjD,CAAC,CAAC,CAAC;IAEH,IAAI,CAAC,6EAA6E,EAAE,GAAG,EAAE;QACvF,MAAM,MAAM,GAAG,sBAAsB,CAAC,sBAAsB,CAAC,CAAC;QAC9D,MAAM,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,mBAAmB,CAAC,CAAC;IAC9C,CAAC,CAAC,CAAC;IAEH,IAAI,CAAC,gEAAgE,EAAE,GAAG,EAAE;QAC1E,kBAAkB,CAAC,aAAa,EAAE,gBAAgB,CAAC,CAAC;QACpD,MAAM,CAAC,OAAO,gBAAgB,CAAC,eAAe,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QAC/D,MAAM,CAAC,gBAAgB,CAAC,eAAe,CAAC,CAAC,GAAG,CAAC,QAAQ,EAAE,CAAC;IAC1D,CAAC,CAAC,CAAC;IAEH,IAAI,CAAC,kEAAkE,EAAE,GAAG,EAAE;QAC5E,oBAAoB,CAAC,gBAAgB,EAAE,aAAa,CAAC,CAAC;QACtD,MAAM,CAAC,OAAO,gBAAgB,CAAC,eAAe,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QAC/D,MAAM,CAAC,gBAAgB,CAAC,eAAe,CAAC,CAAC,GAAG,CAAC,QAAQ,EAAE,CAAC;IAC1D,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import {
|
|
3
|
-
export declare const getAccountShape: GetAccountShape<
|
|
1
|
+
import type { GetAccountShape, IterateResultBuilder } from "@ledgerhq/coin-framework/bridge/jsHelpers";
|
|
2
|
+
import type { HederaAccount } from "../types";
|
|
3
|
+
export declare const getAccountShape: GetAccountShape<HederaAccount>;
|
|
4
4
|
export declare const buildIterateResult: IterateResultBuilder;
|
|
5
5
|
//# sourceMappingURL=synchronisation.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"synchronisation.d.ts","sourceRoot":"","sources":["../../src/bridge/synchronisation.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"synchronisation.d.ts","sourceRoot":"","sources":["../../src/bridge/synchronisation.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EACV,eAAe,EACf,oBAAoB,EACrB,MAAM,2CAA2C,CAAC;AAWnD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAG9C,eAAO,MAAM,eAAe,EAAE,eAAe,CAAC,aAAa,CA4E1D,CAAC;AAEF,eAAO,MAAM,kBAAkB,EAAE,oBAqBhC,CAAC"}
|
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
import invariant from "invariant";
|
|
2
|
-
import { getDerivationScheme, runDerivationScheme, } from "@ledgerhq/coin-framework/derivation";
|
|
3
1
|
import { BigNumber } from "bignumber.js";
|
|
4
|
-
import
|
|
5
|
-
import {
|
|
2
|
+
import invariant from "invariant";
|
|
3
|
+
import { getDerivationScheme, runDerivationScheme } from "@ledgerhq/coin-framework/derivation";
|
|
4
|
+
import { mergeOps } from "@ledgerhq/coin-framework/bridge/jsHelpers";
|
|
6
5
|
import { encodeAccountId } from "@ledgerhq/coin-framework/account";
|
|
7
|
-
import {
|
|
8
|
-
|
|
6
|
+
import { getAccount, getAccountsForPublicKey, getAccountTokens } from "../api/mirror";
|
|
7
|
+
import { getSubAccounts, prepareOperations, applyPendingExtras, mergeSubAccounts, getSyncHash, } from "./utils";
|
|
8
|
+
import { getOperationsForAccount } from "../api/utils";
|
|
9
|
+
export const getAccountShape = async (info, { blacklistedTokenIds }) => {
|
|
9
10
|
const { currency, derivationMode, address, initialAccount } = info;
|
|
10
11
|
invariant(address, "an hedera address is expected");
|
|
11
12
|
const liveAccountId = encodeAccountId({
|
|
@@ -15,31 +16,52 @@ export const getAccountShape = async (info) => {
|
|
|
15
16
|
xpubOrAddress: address,
|
|
16
17
|
derivationMode,
|
|
17
18
|
});
|
|
18
|
-
// get current account balance
|
|
19
|
-
|
|
20
|
-
//
|
|
19
|
+
// get current account balance and tokens
|
|
20
|
+
// tokens are fetched with separate requests to get "created_timestamp" for each token
|
|
21
|
+
// based on this, ASSOCIATE_TOKEN operations can be connected with tokens
|
|
22
|
+
const [mirrorAccount, mirrorTokens] = await Promise.all([
|
|
23
|
+
getAccount(address),
|
|
24
|
+
getAccountTokens(address),
|
|
25
|
+
]);
|
|
26
|
+
// we should sync again when new tokens are added or blacklist changes
|
|
27
|
+
const syncHash = getSyncHash(currency, blacklistedTokenIds);
|
|
28
|
+
const shouldSyncFromScratch = !initialAccount || syncHash !== initialAccount?.syncHash;
|
|
21
29
|
const oldOperations = initialAccount?.operations ?? [];
|
|
22
|
-
const
|
|
30
|
+
const pendingOperations = initialAccount?.pendingOperations ?? [];
|
|
31
|
+
// grab latest operation's consensus timestamp for incremental sync
|
|
32
|
+
const latestOperationTimestamp = !shouldSyncFromScratch && oldOperations[0]
|
|
23
33
|
? new BigNumber(Math.floor(oldOperations[0].date.getTime() / 1000))
|
|
24
34
|
: null;
|
|
25
|
-
|
|
26
|
-
const
|
|
27
|
-
const
|
|
35
|
+
const latestAccountOperations = await getOperationsForAccount(liveAccountId, address, latestOperationTimestamp ? latestOperationTimestamp.toString() : null);
|
|
36
|
+
const newSubAccounts = await getSubAccounts(liveAccountId, latestAccountOperations.tokenOperations, mirrorTokens);
|
|
37
|
+
const subAccounts = mergeSubAccounts(initialAccount, newSubAccounts);
|
|
38
|
+
const newOperations = prepareOperations(latestAccountOperations.coinOperations, latestAccountOperations.tokenOperations, mirrorTokens);
|
|
39
|
+
const enrichedNewOperations = applyPendingExtras(newOperations, pendingOperations);
|
|
40
|
+
const operations = shouldSyncFromScratch
|
|
41
|
+
? enrichedNewOperations
|
|
42
|
+
: mergeOps(oldOperations, enrichedNewOperations);
|
|
28
43
|
return {
|
|
29
44
|
id: liveAccountId,
|
|
30
45
|
freshAddress: address,
|
|
31
|
-
|
|
32
|
-
|
|
46
|
+
syncHash,
|
|
47
|
+
lastSyncDate: new Date(),
|
|
48
|
+
balance: new BigNumber(mirrorAccount.balance.balance),
|
|
49
|
+
spendableBalance: new BigNumber(mirrorAccount.balance.balance),
|
|
33
50
|
operations,
|
|
34
51
|
operationsCount: operations.length,
|
|
35
52
|
// NOTE: there are no "blocks" in hedera
|
|
36
53
|
// Set a value just so that operations are considered confirmed according to isConfirmedOperation
|
|
37
54
|
blockHeight: 10,
|
|
55
|
+
subAccounts,
|
|
56
|
+
hederaResources: {
|
|
57
|
+
maxAutomaticTokenAssociations: mirrorAccount.max_automatic_token_associations,
|
|
58
|
+
isAutoTokenAssociationEnabled: mirrorAccount.max_automatic_token_associations === -1,
|
|
59
|
+
},
|
|
38
60
|
};
|
|
39
61
|
};
|
|
40
62
|
export const buildIterateResult = async ({ result: rootResult }) => {
|
|
41
|
-
const
|
|
42
|
-
const addresses =
|
|
63
|
+
const mirrorAccounts = await getAccountsForPublicKey(rootResult.publicKey);
|
|
64
|
+
const addresses = mirrorAccounts.map(a => a.account);
|
|
43
65
|
return async ({ currency, derivationMode, index }) => {
|
|
44
66
|
const derivationScheme = getDerivationScheme({
|
|
45
67
|
derivationMode,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"synchronisation.js","sourceRoot":"","sources":["../../src/bridge/synchronisation.ts"],"names":[],"mappings":"AAAA,OAAO,SAAS,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"synchronisation.js","sourceRoot":"","sources":["../../src/bridge/synchronisation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,SAAS,MAAM,WAAW,CAAC;AAElC,OAAO,EAAE,mBAAmB,EAAE,mBAAmB,EAAE,MAAM,qCAAqC,CAAC;AAK/F,OAAO,EAAE,QAAQ,EAAE,MAAM,2CAA2C,CAAC;AACrE,OAAO,EAAE,eAAe,EAAE,MAAM,kCAAkC,CAAC;AAC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CAAC,gCAAgC,KAAK,CAAC,CAAC;SACrF;KACF,CAAC;AACJ,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,kBAAkB,GAAyB,KAAK,EAAE,EAAE,MAAM,EAAE,UAAU,EAAE,EAAE,EAAE;IACvF,MAAM,cAAc,GAAG,MAAM,uBAAuB,CAAC,UAAU,CAAC,SAAS,CAAC,CAAC;IAC3E,MAAM,SAAS,GAAG,cAAc,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC;IAErD,OAAO,KAAK,EAAE,EAAE,QAAQ,EAAE,cAAc,EAAE,KAAK,EAAE,EAAE,EAAE;QACnD,MAAM,gBAAgB,GAAG,mBAAmB,CAAC;YAC3C,cAAc;YACd,QAAQ;SACT,CAAC,CAAC;QACH,MAAM,gBAAgB,GAAG,mBAAmB,CAAC,gBAAgB,EAAE,QAAQ,EAAE;YACvE,OAAO,EAAE,KAAK;SACf,CAAC,CAAC;QAEH,OAAO,SAAS,CAAC,KAAK,CAAC;YACrB,CAAC,CAAE;gBACC,OAAO,EAAE,SAAS,CAAC,KAAK,CAAC;gBACzB,SAAS,EAAE,SAAS,CAAC,KAAK,CAAC;gBAC3B,IAAI,EAAE,gBAAgB;aACZ;YACd,CAAC,CAAC,IAAI,CAAC;IACX,CAAC,CAAC;AACJ,CAAC,CAAC"}
|
|
@@ -1,72 +1,31 @@
|
|
|
1
1
|
import BigNumber from "bignumber.js";
|
|
2
2
|
import { formatTransaction, fromTransactionRaw, toTransactionRaw } from "../transaction";
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
id: "",
|
|
6
|
-
seedIdentifier: "",
|
|
7
|
-
derivationMode: "",
|
|
8
|
-
index: 0,
|
|
9
|
-
freshAddress: "",
|
|
10
|
-
freshAddressPath: "",
|
|
11
|
-
used: false,
|
|
12
|
-
balance: new BigNumber(200000),
|
|
13
|
-
spendableBalance: new BigNumber(0),
|
|
14
|
-
creationDate: new Date(),
|
|
15
|
-
blockHeight: 0,
|
|
16
|
-
currency: {
|
|
17
|
-
type: "CryptoCurrency",
|
|
18
|
-
id: "hedera",
|
|
19
|
-
managerAppName: "",
|
|
20
|
-
coinType: 0,
|
|
21
|
-
scheme: "",
|
|
22
|
-
color: "",
|
|
23
|
-
family: "",
|
|
24
|
-
explorerViews: [],
|
|
25
|
-
name: "",
|
|
26
|
-
ticker: "",
|
|
27
|
-
units: [
|
|
28
|
-
{
|
|
29
|
-
name: "",
|
|
30
|
-
code: "",
|
|
31
|
-
magnitude: 0,
|
|
32
|
-
},
|
|
33
|
-
],
|
|
34
|
-
},
|
|
35
|
-
operationsCount: 0,
|
|
36
|
-
operations: [],
|
|
37
|
-
pendingOperations: [],
|
|
38
|
-
lastSyncDate: new Date(),
|
|
39
|
-
balanceHistoryCache: {
|
|
40
|
-
HOUR: { latestDate: null, balances: [] },
|
|
41
|
-
DAY: { latestDate: null, balances: [] },
|
|
42
|
-
WEEK: { latestDate: null, balances: [] },
|
|
43
|
-
},
|
|
44
|
-
swapHistory: [],
|
|
45
|
-
};
|
|
46
|
-
const transaction = {
|
|
47
|
-
family: "hedera",
|
|
48
|
-
amount: new BigNumber(1),
|
|
49
|
-
recipient: "0.0.3",
|
|
50
|
-
};
|
|
51
|
-
const transactionRaw = {
|
|
52
|
-
family: "hedera",
|
|
53
|
-
amount: "1",
|
|
54
|
-
recipient: "0.0.3",
|
|
55
|
-
};
|
|
3
|
+
import { getMockedAccount } from "../test/fixtures/account.fixture";
|
|
4
|
+
import { getMockedTransaction, getMockedTransactionRaw, } from "../test/fixtures/transaction.fixture";
|
|
56
5
|
describe("transaction", () => {
|
|
6
|
+
const mockedAccount = getMockedAccount();
|
|
7
|
+
const mockedTransaction = getMockedTransaction({
|
|
8
|
+
amount: new BigNumber(100000000),
|
|
9
|
+
recipient: "0.0.3",
|
|
10
|
+
});
|
|
11
|
+
const mockedTransactionRaw = getMockedTransactionRaw({
|
|
12
|
+
amount: "100000000",
|
|
13
|
+
recipient: "0.0.3",
|
|
14
|
+
});
|
|
57
15
|
test("formatTransaction", () => {
|
|
58
|
-
const result = formatTransaction(
|
|
59
|
-
const
|
|
16
|
+
const result = formatTransaction(mockedTransaction, mockedAccount);
|
|
17
|
+
const nonBreakingSpace = String.fromCharCode(160);
|
|
18
|
+
const string = `SEND 1${nonBreakingSpace}HBAR\nTO 0.0.3`;
|
|
60
19
|
expect(result).toEqual(string);
|
|
61
20
|
});
|
|
62
21
|
test("fromTransactionRaw", () => {
|
|
63
|
-
const result = fromTransactionRaw(
|
|
64
|
-
const data =
|
|
22
|
+
const result = fromTransactionRaw(mockedTransactionRaw);
|
|
23
|
+
const data = mockedTransaction;
|
|
65
24
|
expect(result).toEqual(data);
|
|
66
25
|
});
|
|
67
26
|
test("toTransactionRaw", () => {
|
|
68
|
-
const result = toTransactionRaw(
|
|
69
|
-
const data =
|
|
27
|
+
const result = toTransactionRaw(mockedTransaction);
|
|
28
|
+
const data = mockedTransactionRaw;
|
|
70
29
|
expect(result).toEqual(data);
|
|
71
30
|
});
|
|
72
31
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transaction.test.js","sourceRoot":"","sources":["../../src/bridge/transaction.test.ts"],"names":[],"mappings":"AAAA,OAAO,SAAS,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"transaction.test.js","sourceRoot":"","sources":["../../src/bridge/transaction.test.ts"],"names":[],"mappings":"AAAA,OAAO,SAAS,MAAM,cAAc,CAAC;AACrC,OAAO,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AACzF,OAAO,EAAE,gBAAgB,EAAE,MAAM,kCAAkC,CAAC;AACpE,OAAO,EACL,oBAAoB,EACpB,uBAAuB,GACxB,MAAM,sCAAsC,CAAC;AAE9C,QAAQ,CAAC,aAAa,EAAE,GAAG,EAAE;IAC3B,MAAM,aAAa,GAAG,gBAAgB,EAAE,CAAC;IACzC,MAAM,iBAAiB,GAAG,oBAAoB,CAAC;QAC7C,MAAM,EAAE,IAAI,SAAS,CAAC,SAAS,CAAC;QAChC,SAAS,EAAE,OAAO;KACnB,CAAC,CAAC;IACH,MAAM,oBAAoB,GAAG,uBAAuB,CAAC;QACnD,MAAM,EAAE,WAAW;QACnB,SAAS,EAAE,OAAO;KACnB,CAAC,CAAC;IAEH,IAAI,CAAC,mBAAmB,EAAE,GAAG,EAAE;QAC7B,MAAM,MAAM,GAAG,iBAAiB,CAAC,iBAAiB,EAAE,aAAa,CAAC,CAAC;QACnE,MAAM,gBAAgB,GAAG,MAAM,CAAC,YAAY,CAAC,GAAG,CAAC,CAAC;QAClD,MAAM,MAAM,GAAG,SAAS,gBAAgB,gBAAgB,CAAC;QAEzD,MAAM,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;IACjC,CAAC,CAAC,CAAC;IAEH,IAAI,CAAC,oBAAoB,EAAE,GAAG,EAAE;QAC9B,MAAM,MAAM,GAAG,kBAAkB,CAAC,oBAAoB,CAAC,CAAC;QACxD,MAAM,IAAI,GAAG,iBAAiB,CAAC;QAE/B,MAAM,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;IAC/B,CAAC,CAAC,CAAC;IAEH,IAAI,CAAC,kBAAkB,EAAE,GAAG,EAAE;QAC5B,MAAM,MAAM,GAAG,gBAAgB,CAAC,iBAAiB,CAAC,CAAC;QACnD,MAAM,IAAI,GAAG,oBAAoB,CAAC;QAElC,MAAM,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;IAC/B,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
package/lib-es/bridge/utils.d.ts
CHANGED
|
@@ -1,15 +1,29 @@
|
|
|
1
1
|
import BigNumber from "bignumber.js";
|
|
2
|
-
import type { Account, Operation } from "@ledgerhq/types-live";
|
|
2
|
+
import type { Account, Operation, TokenAccount } from "@ledgerhq/types-live";
|
|
3
|
+
import type { CryptoCurrency, Currency } from "@ledgerhq/types-cryptoassets";
|
|
3
4
|
import type { HederaOperationExtra, Transaction } from "../types";
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
export declare
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
}): Promise<{
|
|
5
|
+
import type { HederaMirrorToken } from "../api/types";
|
|
6
|
+
import { HEDERA_OPERATION_TYPES } from "../constants";
|
|
7
|
+
export declare const getCurrencyToUSDRate: import("@ledgerhq/live-network/cache").CacheRes<[currency: Currency], BigNumber | null>;
|
|
8
|
+
export declare const getEstimatedFees: (account: Account, operationType: HEDERA_OPERATION_TYPES) => Promise<BigNumber>;
|
|
9
|
+
interface CalculateAmountResult {
|
|
10
10
|
amount: BigNumber;
|
|
11
11
|
totalSpent: BigNumber;
|
|
12
|
-
}
|
|
12
|
+
}
|
|
13
|
+
export declare const calculateAmount: ({ account, transaction, }: {
|
|
14
|
+
account: Account;
|
|
15
|
+
transaction: Transaction;
|
|
16
|
+
}) => Promise<CalculateAmountResult>;
|
|
13
17
|
export declare function base64ToUrlSafeBase64(data: string): string;
|
|
18
|
+
export declare const getSyncHash: (currency: CryptoCurrency, blacklistedTokenIds?: string[]) => string;
|
|
19
|
+
export declare const getSubAccounts: (accountId: string, lastTokenOperations: Operation[], mirrorTokens: HederaMirrorToken[]) => Promise<TokenAccount[]>;
|
|
20
|
+
export declare const prepareOperations: (coinOperations: Operation[], tokenOperations: Operation[], mirrorTokens: HederaMirrorToken[]) => Operation[];
|
|
21
|
+
/**
|
|
22
|
+
* In charge of smartly merging sub accounts while maintaining references as much as possible
|
|
23
|
+
*/
|
|
24
|
+
export declare const mergeSubAccounts: (initialAccount: Account | undefined, newSubAccounts: TokenAccount[]) => Array<TokenAccount>;
|
|
25
|
+
export declare const applyPendingExtras: (existing: Operation[], pending: Operation[]) => Operation[];
|
|
14
26
|
export declare function patchOperationWithExtra(operation: Operation, extra: HederaOperationExtra): Operation;
|
|
27
|
+
export declare const checkAccountTokenAssociationStatus: import("@ledgerhq/live-network/cache").CacheRes<[accountId: string, tokenId: string], boolean>;
|
|
28
|
+
export {};
|
|
15
29
|
//# sourceMappingURL=utils.d.ts.map
|