@ledgerhq/coin-tezos 0.4.0-next.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 +20 -0
- package/.turbo/turbo-build.log +4 -0
- package/.unimportedrc.json +39 -0
- package/CHANGELOG.md +23 -0
- package/LICENSE.txt +21 -0
- package/jest.config.js +6 -0
- package/lib/api/bakers.d.ts +14 -0
- package/lib/api/bakers.d.ts.map +1 -0
- package/lib/api/bakers.integration.test.d.ts +2 -0
- package/lib/api/bakers.integration.test.d.ts.map +1 -0
- package/lib/api/bakers.integration.test.js +61 -0
- package/lib/api/bakers.integration.test.js.map +1 -0
- package/lib/api/bakers.js +141 -0
- package/lib/api/bakers.js.map +1 -0
- package/lib/api/bakers.test.d.ts +2 -0
- package/lib/api/bakers.test.d.ts.map +1 -0
- package/lib/api/bakers.test.js +146 -0
- package/lib/api/bakers.test.js.map +1 -0
- package/lib/api/bakers.whitelist-default.d.ts +4 -0
- package/lib/api/bakers.whitelist-default.d.ts.map +1 -0
- package/lib/api/bakers.whitelist-default.js +34 -0
- package/lib/api/bakers.whitelist-default.js.map +1 -0
- package/lib/api/index.d.ts +3 -0
- package/lib/api/index.d.ts.map +1 -0
- package/lib/api/index.js +19 -0
- package/lib/api/index.js.map +1 -0
- package/lib/api/tzkt.d.ts +82 -0
- package/lib/api/tzkt.d.ts.map +1 -0
- package/lib/api/tzkt.js +74 -0
- package/lib/api/tzkt.js.map +1 -0
- package/lib/bridge/broadcast.d.ts +4 -0
- package/lib/bridge/broadcast.d.ts.map +1 -0
- package/lib/bridge/broadcast.js +23 -0
- package/lib/bridge/broadcast.js.map +1 -0
- package/lib/bridge/broadcast.test.d.ts +2 -0
- package/lib/bridge/broadcast.test.d.ts.map +1 -0
- package/lib/bridge/broadcast.test.js +37 -0
- package/lib/bridge/broadcast.test.js.map +1 -0
- package/lib/bridge/buildOptimisticOperation.d.ts +4 -0
- package/lib/bridge/buildOptimisticOperation.d.ts.map +1 -0
- package/lib/bridge/buildOptimisticOperation.js +28 -0
- package/lib/bridge/buildOptimisticOperation.js.map +1 -0
- package/lib/bridge/createTransaction.d.ts +4 -0
- package/lib/bridge/createTransaction.d.ts.map +1 -0
- package/lib/bridge/createTransaction.js +24 -0
- package/lib/bridge/createTransaction.js.map +1 -0
- package/lib/bridge/deviceTransactionConfig.d.ts +19 -0
- package/lib/bridge/deviceTransactionConfig.d.ts.map +1 -0
- package/lib/bridge/deviceTransactionConfig.js +44 -0
- package/lib/bridge/deviceTransactionConfig.js.map +1 -0
- package/lib/bridge/estimateMaxSpendable.d.ts +5 -0
- package/lib/bridge/estimateMaxSpendable.d.ts.map +1 -0
- package/lib/bridge/estimateMaxSpendable.js +28 -0
- package/lib/bridge/estimateMaxSpendable.js.map +1 -0
- package/lib/bridge/getTransactionStatus.d.ts +4 -0
- package/lib/bridge/getTransactionStatus.d.ts.map +1 -0
- package/lib/bridge/getTransactionStatus.js +113 -0
- package/lib/bridge/getTransactionStatus.js.map +1 -0
- package/lib/bridge/index.d.ts +8 -0
- package/lib/bridge/index.d.ts.map +1 -0
- package/lib/bridge/index.js +57 -0
- package/lib/bridge/index.js.map +1 -0
- package/lib/bridge/logic.d.ts +10 -0
- package/lib/bridge/logic.d.ts.map +1 -0
- package/lib/bridge/logic.js +160 -0
- package/lib/bridge/logic.js.map +1 -0
- package/lib/bridge/preload.d.ts +9 -0
- package/lib/bridge/preload.d.ts.map +1 -0
- package/lib/bridge/preload.js +32 -0
- package/lib/bridge/preload.js.map +1 -0
- package/lib/bridge/prepareTransaction.d.ts +10 -0
- package/lib/bridge/prepareTransaction.d.ts.map +1 -0
- package/lib/bridge/prepareTransaction.js +158 -0
- package/lib/bridge/prepareTransaction.js.map +1 -0
- package/lib/bridge/serialization.d.ts +7 -0
- package/lib/bridge/serialization.d.ts.map +1 -0
- package/lib/bridge/serialization.js +27 -0
- package/lib/bridge/serialization.js.map +1 -0
- package/lib/bridge/signOperation.d.ts +19 -0
- package/lib/bridge/signOperation.d.ts.map +1 -0
- package/lib/bridge/signOperation.js +129 -0
- package/lib/bridge/signOperation.js.map +1 -0
- package/lib/bridge/signOperation.test.d.ts +2 -0
- package/lib/bridge/signOperation.test.d.ts.map +1 -0
- package/lib/bridge/signOperation.test.js +223 -0
- package/lib/bridge/signOperation.test.js.map +1 -0
- package/lib/bridge/synchronization.d.ts +5 -0
- package/lib/bridge/synchronization.d.ts.map +1 -0
- package/lib/bridge/synchronization.js +108 -0
- package/lib/bridge/synchronization.js.map +1 -0
- package/lib/bridge/synchronization.test.d.ts +2 -0
- package/lib/bridge/synchronization.test.d.ts.map +1 -0
- package/lib/bridge/synchronization.test.js +33 -0
- package/lib/bridge/synchronization.test.js.map +1 -0
- package/lib/bridge/transaction.d.ts +15 -0
- package/lib/bridge/transaction.d.ts.map +1 -0
- package/lib/bridge/transaction.js +52 -0
- package/lib/bridge/transaction.js.map +1 -0
- package/lib/datasets/tezos.scanAccounts.1.d.ts +7 -0
- package/lib/datasets/tezos.scanAccounts.1.d.ts.map +1 -0
- package/lib/datasets/tezos.scanAccounts.1.js +38 -0
- package/lib/datasets/tezos.scanAccounts.1.js.map +1 -0
- package/lib/index.d.ts +3 -0
- package/lib/index.d.ts.map +1 -0
- package/lib/index.js +21 -0
- package/lib/index.js.map +1 -0
- package/lib/signer/getAddress.d.ts +6 -0
- package/lib/signer/getAddress.d.ts.map +1 -0
- package/lib/signer/getAddress.js +19 -0
- package/lib/signer/getAddress.js.map +1 -0
- package/lib/signer/index.d.ts +6 -0
- package/lib/signer/index.d.ts.map +1 -0
- package/lib/signer/index.js +11 -0
- package/lib/signer/index.js.map +1 -0
- package/lib/test/bot-deviceActions.d.ts +4 -0
- package/lib/test/bot-deviceActions.d.ts.map +1 -0
- package/lib/test/bot-deviceActions.js +74 -0
- package/lib/test/bot-deviceActions.js.map +1 -0
- package/lib/test/bot-specs.d.ts +7 -0
- package/lib/test/bot-specs.d.ts.map +1 -0
- package/lib/test/bot-specs.js +154 -0
- package/lib/test/bot-specs.js.map +1 -0
- package/lib/test/bridgeDatasetTest.d.ts +5 -0
- package/lib/test/bridgeDatasetTest.d.ts.map +1 -0
- package/lib/test/bridgeDatasetTest.js +99 -0
- package/lib/test/bridgeDatasetTest.js.map +1 -0
- package/lib/test/cli.d.ts +78 -0
- package/lib/test/cli.d.ts.map +1 -0
- package/lib/test/cli.js +97 -0
- package/lib/test/cli.js.map +1 -0
- package/lib/test/index.d.ts +2 -0
- package/lib/test/index.d.ts.map +1 -0
- package/lib/test/index.js +18 -0
- package/lib/test/index.js.map +1 -0
- package/lib/types/errors.d.ts +4 -0
- package/lib/types/errors.d.ts.map +1 -0
- package/lib/types/errors.js +6 -0
- package/lib/types/errors.js.map +1 -0
- package/lib/types/index.d.ts +4 -0
- package/lib/types/index.d.ts.map +1 -0
- package/lib/types/index.js +20 -0
- package/lib/types/index.js.map +1 -0
- package/lib/types/model.d.ts +92 -0
- package/lib/types/model.d.ts.map +1 -0
- package/lib/types/model.fixture.d.ts +5 -0
- package/lib/types/model.fixture.d.ts.map +1 -0
- package/lib/types/model.fixture.js +85 -0
- package/lib/types/model.fixture.js.map +1 -0
- package/lib/types/model.js +8 -0
- package/lib/types/model.js.map +1 -0
- package/lib/types/signer.d.ts +37 -0
- package/lib/types/signer.d.ts.map +1 -0
- package/lib/types/signer.js +3 -0
- package/lib/types/signer.js.map +1 -0
- package/lib-es/api/bakers.d.ts +14 -0
- package/lib-es/api/bakers.d.ts.map +1 -0
- package/lib-es/api/bakers.integration.test.d.ts +2 -0
- package/lib-es/api/bakers.integration.test.d.ts.map +1 -0
- package/lib-es/api/bakers.integration.test.js +56 -0
- package/lib-es/api/bakers.integration.test.js.map +1 -0
- package/lib-es/api/bakers.js +125 -0
- package/lib-es/api/bakers.js.map +1 -0
- package/lib-es/api/bakers.test.d.ts +2 -0
- package/lib-es/api/bakers.test.d.ts.map +1 -0
- package/lib-es/api/bakers.test.js +141 -0
- package/lib-es/api/bakers.test.js.map +1 -0
- package/lib-es/api/bakers.whitelist-default.d.ts +4 -0
- package/lib-es/api/bakers.whitelist-default.d.ts.map +1 -0
- package/lib-es/api/bakers.whitelist-default.js +31 -0
- package/lib-es/api/bakers.whitelist-default.js.map +1 -0
- package/lib-es/api/index.d.ts +3 -0
- package/lib-es/api/index.d.ts.map +1 -0
- package/lib-es/api/index.js +3 -0
- package/lib-es/api/index.js.map +1 -0
- package/lib-es/api/tzkt.d.ts +82 -0
- package/lib-es/api/tzkt.d.ts.map +1 -0
- package/lib-es/api/tzkt.js +67 -0
- package/lib-es/api/tzkt.js.map +1 -0
- package/lib-es/bridge/broadcast.d.ts +4 -0
- package/lib-es/bridge/broadcast.d.ts.map +1 -0
- package/lib-es/bridge/broadcast.js +19 -0
- package/lib-es/bridge/broadcast.js.map +1 -0
- package/lib-es/bridge/broadcast.test.d.ts +2 -0
- package/lib-es/bridge/broadcast.test.d.ts.map +1 -0
- package/lib-es/bridge/broadcast.test.js +35 -0
- package/lib-es/bridge/broadcast.test.js.map +1 -0
- package/lib-es/bridge/buildOptimisticOperation.d.ts +4 -0
- package/lib-es/bridge/buildOptimisticOperation.d.ts.map +1 -0
- package/lib-es/bridge/buildOptimisticOperation.js +21 -0
- package/lib-es/bridge/buildOptimisticOperation.js.map +1 -0
- package/lib-es/bridge/createTransaction.d.ts +4 -0
- package/lib-es/bridge/createTransaction.d.ts.map +1 -0
- package/lib-es/bridge/createTransaction.js +17 -0
- package/lib-es/bridge/createTransaction.js.map +1 -0
- package/lib-es/bridge/deviceTransactionConfig.d.ts +19 -0
- package/lib-es/bridge/deviceTransactionConfig.d.ts.map +1 -0
- package/lib-es/bridge/deviceTransactionConfig.js +42 -0
- package/lib-es/bridge/deviceTransactionConfig.js.map +1 -0
- package/lib-es/bridge/estimateMaxSpendable.d.ts +5 -0
- package/lib-es/bridge/estimateMaxSpendable.d.ts.map +1 -0
- package/lib-es/bridge/estimateMaxSpendable.js +24 -0
- package/lib-es/bridge/estimateMaxSpendable.js.map +1 -0
- package/lib-es/bridge/getTransactionStatus.d.ts +4 -0
- package/lib-es/bridge/getTransactionStatus.d.ts.map +1 -0
- package/lib-es/bridge/getTransactionStatus.js +106 -0
- package/lib-es/bridge/getTransactionStatus.js.map +1 -0
- package/lib-es/bridge/index.d.ts +8 -0
- package/lib-es/bridge/index.d.ts.map +1 -0
- package/lib-es/bridge/index.js +50 -0
- package/lib-es/bridge/index.js.map +1 -0
- package/lib-es/bridge/logic.d.ts +10 -0
- package/lib-es/bridge/logic.d.ts.map +1 -0
- package/lib-es/bridge/logic.js +150 -0
- package/lib-es/bridge/logic.js.map +1 -0
- package/lib-es/bridge/preload.d.ts +9 -0
- package/lib-es/bridge/preload.d.ts.map +1 -0
- package/lib-es/bridge/preload.js +26 -0
- package/lib-es/bridge/preload.js.map +1 -0
- package/lib-es/bridge/prepareTransaction.d.ts +10 -0
- package/lib-es/bridge/prepareTransaction.d.ts.map +1 -0
- package/lib-es/bridge/prepareTransaction.js +150 -0
- package/lib-es/bridge/prepareTransaction.js.map +1 -0
- 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 +20 -0
- package/lib-es/bridge/serialization.js.map +1 -0
- package/lib-es/bridge/signOperation.d.ts +19 -0
- package/lib-es/bridge/signOperation.d.ts.map +1 -0
- package/lib-es/bridge/signOperation.js +124 -0
- package/lib-es/bridge/signOperation.js.map +1 -0
- package/lib-es/bridge/signOperation.test.d.ts +2 -0
- package/lib-es/bridge/signOperation.test.d.ts.map +1 -0
- package/lib-es/bridge/signOperation.test.js +195 -0
- package/lib-es/bridge/signOperation.test.js.map +1 -0
- package/lib-es/bridge/synchronization.d.ts +5 -0
- package/lib-es/bridge/synchronization.d.ts.map +1 -0
- package/lib-es/bridge/synchronization.js +78 -0
- package/lib-es/bridge/synchronization.js.map +1 -0
- package/lib-es/bridge/synchronization.test.d.ts +2 -0
- package/lib-es/bridge/synchronization.test.d.ts.map +1 -0
- package/lib-es/bridge/synchronization.test.js +31 -0
- package/lib-es/bridge/synchronization.test.js.map +1 -0
- package/lib-es/bridge/transaction.d.ts +15 -0
- package/lib-es/bridge/transaction.d.ts.map +1 -0
- package/lib-es/bridge/transaction.js +46 -0
- package/lib-es/bridge/transaction.js.map +1 -0
- package/lib-es/datasets/tezos.scanAccounts.1.d.ts +7 -0
- package/lib-es/datasets/tezos.scanAccounts.1.d.ts.map +1 -0
- package/lib-es/datasets/tezos.scanAccounts.1.js +36 -0
- package/lib-es/datasets/tezos.scanAccounts.1.js.map +1 -0
- package/lib-es/index.d.ts +3 -0
- package/lib-es/index.d.ts.map +1 -0
- package/lib-es/index.js +3 -0
- package/lib-es/index.js.map +1 -0
- package/lib-es/signer/getAddress.d.ts +6 -0
- package/lib-es/signer/getAddress.d.ts.map +1 -0
- package/lib-es/signer/getAddress.js +17 -0
- package/lib-es/signer/getAddress.js.map +1 -0
- package/lib-es/signer/index.d.ts +6 -0
- package/lib-es/signer/index.d.ts.map +1 -0
- package/lib-es/signer/index.js +6 -0
- package/lib-es/signer/index.js.map +1 -0
- package/lib-es/test/bot-deviceActions.d.ts +4 -0
- package/lib-es/test/bot-deviceActions.d.ts.map +1 -0
- package/lib-es/test/bot-deviceActions.js +71 -0
- package/lib-es/test/bot-deviceActions.js.map +1 -0
- package/lib-es/test/bot-specs.d.ts +7 -0
- package/lib-es/test/bot-specs.d.ts.map +1 -0
- package/lib-es/test/bot-specs.js +149 -0
- package/lib-es/test/bot-specs.js.map +1 -0
- package/lib-es/test/bridgeDatasetTest.d.ts +5 -0
- package/lib-es/test/bridgeDatasetTest.d.ts.map +1 -0
- package/lib-es/test/bridgeDatasetTest.js +93 -0
- package/lib-es/test/bridgeDatasetTest.js.map +1 -0
- package/lib-es/test/cli.d.ts +78 -0
- package/lib-es/test/cli.d.ts.map +1 -0
- package/lib-es/test/cli.js +91 -0
- package/lib-es/test/cli.js.map +1 -0
- package/lib-es/test/index.d.ts +2 -0
- package/lib-es/test/index.d.ts.map +1 -0
- package/lib-es/test/index.js +2 -0
- package/lib-es/test/index.js.map +1 -0
- package/lib-es/types/errors.d.ts +4 -0
- package/lib-es/types/errors.d.ts.map +1 -0
- package/lib-es/types/errors.js +3 -0
- package/lib-es/types/errors.js.map +1 -0
- package/lib-es/types/index.d.ts +4 -0
- package/lib-es/types/index.d.ts.map +1 -0
- package/lib-es/types/index.js +4 -0
- package/lib-es/types/index.js.map +1 -0
- package/lib-es/types/model.d.ts +92 -0
- package/lib-es/types/model.d.ts.map +1 -0
- package/lib-es/types/model.fixture.d.ts +5 -0
- package/lib-es/types/model.fixture.d.ts.map +1 -0
- package/lib-es/types/model.fixture.js +76 -0
- package/lib-es/types/model.fixture.js.map +1 -0
- package/lib-es/types/model.js +4 -0
- package/lib-es/types/model.js.map +1 -0
- package/lib-es/types/signer.d.ts +37 -0
- package/lib-es/types/signer.d.ts.map +1 -0
- package/lib-es/types/signer.js +2 -0
- package/lib-es/types/signer.js.map +1 -0
- package/package.json +117 -0
- package/please-add-coverage.test.ts +3 -0
- package/src/README.md +29 -0
- package/src/api/bakers.integration.test.ts +61 -0
- package/src/api/bakers.test.ts +140 -0
- package/src/api/bakers.ts +139 -0
- package/src/api/bakers.whitelist-default.ts +33 -0
- package/src/api/index.ts +2 -0
- package/src/api/tzkt.ts +134 -0
- package/src/bridge/broadcast.test.ts +30 -0
- package/src/bridge/broadcast.ts +17 -0
- package/src/bridge/buildOptimisticOperation.ts +28 -0
- package/src/bridge/createTransaction.ts +19 -0
- package/src/bridge/deviceTransactionConfig.ts +74 -0
- package/src/bridge/estimateMaxSpendable.ts +32 -0
- package/src/bridge/getTransactionStatus.ts +122 -0
- package/src/bridge/index.ts +65 -0
- package/src/bridge/logic.ts +175 -0
- package/src/bridge/preload.ts +18 -0
- package/src/bridge/prepareTransaction.ts +161 -0
- package/src/bridge/serialization.ts +27 -0
- package/src/bridge/signOperation.test.ts +211 -0
- package/src/bridge/signOperation.ts +191 -0
- package/src/bridge/synchronization.test.ts +22 -0
- package/src/bridge/synchronization.ts +99 -0
- package/src/bridge/transaction.ts +94 -0
- package/src/datasets/tezos.scanAccounts.1.ts +35 -0
- package/src/index.ts +3 -0
- package/src/signer/getAddress.ts +13 -0
- package/src/signer/index.ts +7 -0
- package/src/test/bot-deviceActions.ts +79 -0
- package/src/test/bot-specs.ts +152 -0
- package/src/test/bridgeDatasetTest.ts +132 -0
- package/src/test/cli.ts +137 -0
- package/src/test/index.ts +1 -0
- package/src/types/errors.ts +5 -0
- package/src/types/index.ts +3 -0
- package/src/types/model.fixture.ts +89 -0
- package/src/types/model.ts +123 -0
- package/src/types/signer.ts +48 -0
- package/tsconfig.json +13 -0
- package/types/@taquito/ledger-signer/index.d.ts +3 -0
package/src/test/cli.ts
ADDED
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
import { from, Observable } from "rxjs";
|
|
2
|
+
import { map } from "rxjs/operators";
|
|
3
|
+
import invariant from "invariant";
|
|
4
|
+
import { BigNumber } from "bignumber.js";
|
|
5
|
+
import flatMap from "lodash/flatMap";
|
|
6
|
+
import type { Account, AccountLike, AccountLikeArray, SubAccount } from "@ledgerhq/types-live";
|
|
7
|
+
import type { Transaction, Baker } from "../types";
|
|
8
|
+
import { listBakers, fetchAllBakers } from "../api/bakers";
|
|
9
|
+
import defaultList from "../api/bakers.whitelist-default";
|
|
10
|
+
|
|
11
|
+
const options = [
|
|
12
|
+
{
|
|
13
|
+
name: "mode",
|
|
14
|
+
type: String,
|
|
15
|
+
desc: "mode of transaction",
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
name: "storageLimit",
|
|
19
|
+
type: String,
|
|
20
|
+
desc: "how much storageLimit. default is estimated with the recipient",
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
name: "subAccount",
|
|
24
|
+
type: String,
|
|
25
|
+
desc: "use a sub account instead of the parent by index",
|
|
26
|
+
multiple: true,
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
name: "fees",
|
|
30
|
+
type: String,
|
|
31
|
+
desc: "how much fees",
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
name: "gasLimit",
|
|
35
|
+
type: String,
|
|
36
|
+
desc: "how much gasLimit. default is estimated with the recipient",
|
|
37
|
+
},
|
|
38
|
+
];
|
|
39
|
+
|
|
40
|
+
function inferAccounts(account: Account, opts: Record<string, any>): AccountLikeArray {
|
|
41
|
+
invariant(account.currency.family === "tezos", "tezos family");
|
|
42
|
+
|
|
43
|
+
if (!opts.subAccount) {
|
|
44
|
+
const accounts: Account[] = [account];
|
|
45
|
+
return accounts;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
const { subAccounts } = account;
|
|
49
|
+
invariant(subAccounts, "no sub accounts");
|
|
50
|
+
return opts.subAccount.map((i: number) => {
|
|
51
|
+
const acc = (subAccounts as SubAccount[])[i];
|
|
52
|
+
invariant(acc, "sub account not found (index %s)", i);
|
|
53
|
+
return acc;
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
function inferTransactions(
|
|
58
|
+
transactions: Array<{
|
|
59
|
+
account: AccountLike;
|
|
60
|
+
transaction: Transaction;
|
|
61
|
+
}>,
|
|
62
|
+
opts: Record<string, any>,
|
|
63
|
+
{ inferAmount }: any,
|
|
64
|
+
): Transaction[] {
|
|
65
|
+
return flatMap(transactions, ({ transaction, account }) => {
|
|
66
|
+
invariant(transaction.family === "tezos", "tezos family");
|
|
67
|
+
let subAccountId;
|
|
68
|
+
|
|
69
|
+
return {
|
|
70
|
+
...transaction,
|
|
71
|
+
mode: opts.mode || "send",
|
|
72
|
+
subAccountId,
|
|
73
|
+
fees: opts.fees ? inferAmount(account, opts.fees) : null,
|
|
74
|
+
gasLimit: opts.gasLimit ? new BigNumber(opts.gasLimit) : null,
|
|
75
|
+
storageLimit: opts.storageLimit ? new BigNumber(opts.storageLimit) : null,
|
|
76
|
+
};
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
const bakersFormatters = {
|
|
81
|
+
json: (list: Baker[]) => JSON.stringify(list),
|
|
82
|
+
default: (list: Baker[]) =>
|
|
83
|
+
list
|
|
84
|
+
.map(b => `${b.address} "${b.name}" ${b.nominalYield} ${b.capacityStatus} ${b.logoURL}`)
|
|
85
|
+
.join("\n"),
|
|
86
|
+
};
|
|
87
|
+
const tezosListBakers = {
|
|
88
|
+
args: [
|
|
89
|
+
{
|
|
90
|
+
name: "whitelist",
|
|
91
|
+
desc: "filter whitelist",
|
|
92
|
+
type: Boolean,
|
|
93
|
+
},
|
|
94
|
+
{
|
|
95
|
+
name: "format",
|
|
96
|
+
desc: Object.keys(bakersFormatters).join(" | "),
|
|
97
|
+
type: String,
|
|
98
|
+
},
|
|
99
|
+
],
|
|
100
|
+
job: ({
|
|
101
|
+
whitelist,
|
|
102
|
+
format,
|
|
103
|
+
}: Partial<{
|
|
104
|
+
whitelist: boolean;
|
|
105
|
+
format: "json" | "default";
|
|
106
|
+
}>): Observable<string> =>
|
|
107
|
+
from(whitelist ? listBakers(defaultList) : fetchAllBakers()).pipe(
|
|
108
|
+
map((list: Baker[]) => {
|
|
109
|
+
const f = (format && bakersFormatters[format]) || bakersFormatters.default;
|
|
110
|
+
return f(list);
|
|
111
|
+
}),
|
|
112
|
+
),
|
|
113
|
+
};
|
|
114
|
+
|
|
115
|
+
export type CliTools = {
|
|
116
|
+
options: typeof options;
|
|
117
|
+
inferTransactions: (
|
|
118
|
+
transactions: Array<{
|
|
119
|
+
account: AccountLike;
|
|
120
|
+
transaction: Transaction;
|
|
121
|
+
}>,
|
|
122
|
+
opts: Record<string, any>,
|
|
123
|
+
{ inferAmount }: any,
|
|
124
|
+
) => Transaction[];
|
|
125
|
+
commands: { tezosListBakers: typeof tezosListBakers };
|
|
126
|
+
};
|
|
127
|
+
|
|
128
|
+
export default function makeCliTools() {
|
|
129
|
+
return {
|
|
130
|
+
options,
|
|
131
|
+
inferAccounts,
|
|
132
|
+
inferTransactions,
|
|
133
|
+
commands: {
|
|
134
|
+
tezosListBakers,
|
|
135
|
+
},
|
|
136
|
+
};
|
|
137
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./bridgeDatasetTest";
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import BigNumber from "bignumber.js";
|
|
2
|
+
import { faker } from "@faker-js/faker";
|
|
3
|
+
import type {
|
|
4
|
+
TezosAccount,
|
|
5
|
+
TezosOperation,
|
|
6
|
+
TezosOperationExtra,
|
|
7
|
+
TezosResources,
|
|
8
|
+
Transaction,
|
|
9
|
+
} from "./model";
|
|
10
|
+
import { getAbandonSeedAddress } from "@ledgerhq/cryptoassets/abandonseed";
|
|
11
|
+
import { listCryptoCurrencies } from "@ledgerhq/cryptoassets/currencies";
|
|
12
|
+
import { emptyHistoryCache } from "@ledgerhq/coin-framework/account/index";
|
|
13
|
+
|
|
14
|
+
const currency = listCryptoCurrencies(true).find(c => c.id === "tezos")!;
|
|
15
|
+
|
|
16
|
+
export function createFixtureAccount(account?: Partial<TezosAccount>): TezosAccount {
|
|
17
|
+
const tezosResources: TezosResources = account?.tezosResources || {
|
|
18
|
+
revealed: account?.tezosResources?.revealed || true,
|
|
19
|
+
counter: account?.tezosResources?.counter || faker.number.int(),
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
const freshAddress = {
|
|
23
|
+
// Value coming from taquito.io documentation
|
|
24
|
+
address: "tz1VSUr8wwNhLAzempoch5d6hLRiTh8Cjcjb",
|
|
25
|
+
derivationPath: "derivation_path",
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
return {
|
|
29
|
+
type: "Account",
|
|
30
|
+
id: faker.string.uuid(),
|
|
31
|
+
seedIdentifier: faker.string.uuid(),
|
|
32
|
+
derivationMode: "",
|
|
33
|
+
index: faker.number.int(),
|
|
34
|
+
freshAddress: account?.freshAddress || freshAddress.address,
|
|
35
|
+
freshAddressPath: freshAddress.derivationPath,
|
|
36
|
+
used: true,
|
|
37
|
+
balance: account?.balance || new BigNumber(0),
|
|
38
|
+
spendableBalance: account?.spendableBalance || new BigNumber(0),
|
|
39
|
+
creationDate: faker.date.past(),
|
|
40
|
+
blockHeight: faker.number.int({ min: 100_000, max: 200_000 }),
|
|
41
|
+
currency,
|
|
42
|
+
operationsCount: account?.operationsCount || 0,
|
|
43
|
+
operations: account?.operations || [],
|
|
44
|
+
pendingOperations: account?.pendingOperations || [],
|
|
45
|
+
lastSyncDate: new Date(),
|
|
46
|
+
balanceHistoryCache: emptyHistoryCache,
|
|
47
|
+
swapHistory: [],
|
|
48
|
+
|
|
49
|
+
tezosResources,
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export function createFixtureTransaction(tx?: Partial<Transaction>): Transaction {
|
|
54
|
+
return {
|
|
55
|
+
amount: tx?.amount || new BigNumber(0),
|
|
56
|
+
recipient: tx?.recipient || getAbandonSeedAddress("tezos"),
|
|
57
|
+
|
|
58
|
+
family: "tezos",
|
|
59
|
+
mode: tx?.mode || "send",
|
|
60
|
+
networkInfo: tx?.networkInfo || undefined,
|
|
61
|
+
fees: tx?.fees || undefined,
|
|
62
|
+
gasLimit: tx?.gasLimit || undefined,
|
|
63
|
+
storageLimit: tx?.storageLimit || undefined,
|
|
64
|
+
estimatedFees: tx?.estimatedFees || undefined,
|
|
65
|
+
taquitoError: tx?.taquitoError || undefined,
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
export function createFixtureOperation(operation?: Partial<TezosOperation>): TezosOperation {
|
|
70
|
+
const extra: TezosOperationExtra = {
|
|
71
|
+
id: operation?.extra?.id || 0,
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
return {
|
|
75
|
+
id: operation?.id || faker.string.uuid(),
|
|
76
|
+
hash: operation?.hash || faker.string.uuid(),
|
|
77
|
+
type: operation?.type || "ACTIVATE",
|
|
78
|
+
value: operation?.value || new BigNumber(faker.string.numeric()),
|
|
79
|
+
fee: operation?.fee || new BigNumber(0),
|
|
80
|
+
// senders & recipients addresses
|
|
81
|
+
senders: operation?.senders || [],
|
|
82
|
+
recipients: operation?.recipients || [],
|
|
83
|
+
blockHeight: operation?.blockHeight || undefined,
|
|
84
|
+
blockHash: operation?.blockHash || undefined,
|
|
85
|
+
accountId: operation?.accountId || faker.string.uuid(),
|
|
86
|
+
date: operation?.date || faker.date.past(),
|
|
87
|
+
extra,
|
|
88
|
+
};
|
|
89
|
+
}
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
Account,
|
|
3
|
+
AccountRaw,
|
|
4
|
+
Operation,
|
|
5
|
+
TransactionCommon,
|
|
6
|
+
TransactionCommonRaw,
|
|
7
|
+
TransactionStatusCommon,
|
|
8
|
+
TransactionStatusCommonRaw,
|
|
9
|
+
} from "@ledgerhq/types-live";
|
|
10
|
+
import type { BigNumber } from "bignumber.js";
|
|
11
|
+
|
|
12
|
+
export type TezosResources = {
|
|
13
|
+
revealed: boolean;
|
|
14
|
+
counter: number;
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
export type TezosResourcesRaw = {
|
|
18
|
+
revealed: boolean;
|
|
19
|
+
counter: number;
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
export type TezosOperationMode = "send" | "delegate" | "undelegate";
|
|
23
|
+
|
|
24
|
+
export type NetworkInfo = {
|
|
25
|
+
family: "tezos";
|
|
26
|
+
fees: BigNumber;
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
export type NetworkInfoRaw = {
|
|
30
|
+
family: "tezos";
|
|
31
|
+
fees: string;
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
// TODO add a field for indicating if staking
|
|
35
|
+
export type Transaction = TransactionCommon & {
|
|
36
|
+
family: "tezos";
|
|
37
|
+
mode: TezosOperationMode;
|
|
38
|
+
networkInfo: NetworkInfo | null | undefined;
|
|
39
|
+
fees: BigNumber | null | undefined;
|
|
40
|
+
gasLimit: BigNumber | null | undefined;
|
|
41
|
+
storageLimit: BigNumber | null | undefined;
|
|
42
|
+
estimatedFees: BigNumber | null | undefined;
|
|
43
|
+
taquitoError: string | null | undefined;
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
export type TransactionRaw = TransactionCommonRaw & {
|
|
47
|
+
family: "tezos";
|
|
48
|
+
mode: TezosOperationMode;
|
|
49
|
+
networkInfo: NetworkInfoRaw | null | undefined;
|
|
50
|
+
fees: string | null | undefined;
|
|
51
|
+
gasLimit: string | null | undefined;
|
|
52
|
+
storageLimit: string | null | undefined;
|
|
53
|
+
estimatedFees: string | null | undefined;
|
|
54
|
+
taquitoError: string | null | undefined;
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
type CapacityStatus = "normal" | "full";
|
|
58
|
+
|
|
59
|
+
export type Baker = {
|
|
60
|
+
address: string;
|
|
61
|
+
name: string;
|
|
62
|
+
logoURL: string;
|
|
63
|
+
nominalYield: `${number} %`;
|
|
64
|
+
capacityStatus: CapacityStatus;
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
// type used by UI to facilitate business logic of current delegation data
|
|
68
|
+
export type Delegation = {
|
|
69
|
+
// delegator address
|
|
70
|
+
address: string;
|
|
71
|
+
// if not defined, we need to render "Unknown" on the UI. we don't know who is delegator.
|
|
72
|
+
baker: Baker | null | undefined;
|
|
73
|
+
// operation related to delegation (to know the date info)
|
|
74
|
+
operation: Operation;
|
|
75
|
+
// true if the delegation is pending (optimistic update)
|
|
76
|
+
isPending: boolean;
|
|
77
|
+
// true if a receive should inform it will top up the delegation
|
|
78
|
+
receiveShouldWarnDelegation: boolean;
|
|
79
|
+
// true if a send should inform it will top down the delegation
|
|
80
|
+
sendShouldWarnDelegation: boolean;
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
export type API_BAKER = {
|
|
84
|
+
address: string;
|
|
85
|
+
name: string;
|
|
86
|
+
logo: string;
|
|
87
|
+
balance: number;
|
|
88
|
+
stakingBalance: number;
|
|
89
|
+
stakingCapacity: number;
|
|
90
|
+
maxStakingBalance: number;
|
|
91
|
+
freeSpace: number;
|
|
92
|
+
fee: number;
|
|
93
|
+
minDelegation: number;
|
|
94
|
+
payoutDelay: number;
|
|
95
|
+
payoutPeriod: number;
|
|
96
|
+
openForDelegation: true;
|
|
97
|
+
estimatedRoi: number;
|
|
98
|
+
serviceType: string;
|
|
99
|
+
serviceHealth: string;
|
|
100
|
+
payoutTiming: string;
|
|
101
|
+
payoutAccuracy: string;
|
|
102
|
+
audit?: string;
|
|
103
|
+
insuranceCoverage: number;
|
|
104
|
+
};
|
|
105
|
+
|
|
106
|
+
export type TezosAccount = Account & { tezosResources: TezosResources };
|
|
107
|
+
export function isTezosAccount(account: Account): account is TezosAccount {
|
|
108
|
+
return "tezosResources" in account;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
export type TezosAccountRaw = AccountRaw & {
|
|
112
|
+
tezosResources: TezosResourcesRaw;
|
|
113
|
+
};
|
|
114
|
+
|
|
115
|
+
export type TransactionStatus = TransactionStatusCommon;
|
|
116
|
+
|
|
117
|
+
export type TransactionStatusRaw = TransactionStatusCommonRaw;
|
|
118
|
+
|
|
119
|
+
export type TezosOperation = Operation<TezosOperationExtra>;
|
|
120
|
+
|
|
121
|
+
export type TezosOperationExtra = {
|
|
122
|
+
id?: number; // Used as most recent operation id for incremental sync
|
|
123
|
+
};
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
export type TezosAddress = {
|
|
2
|
+
address: string;
|
|
3
|
+
publicKey: string;
|
|
4
|
+
};
|
|
5
|
+
export type TezosSignature = {
|
|
6
|
+
signature: string;
|
|
7
|
+
};
|
|
8
|
+
// Type coming from hw-app-tezos
|
|
9
|
+
type TezosCurves = {
|
|
10
|
+
ED25519: 0x00;
|
|
11
|
+
SECP256K1: 0x01;
|
|
12
|
+
SECP256R1: 0x02;
|
|
13
|
+
};
|
|
14
|
+
export type Curve = TezosCurves[keyof TezosCurves];
|
|
15
|
+
|
|
16
|
+
export type LedgerSigner = {
|
|
17
|
+
publicKey(): Promise<string>;
|
|
18
|
+
publicKeyHash(): Promise<string>;
|
|
19
|
+
sign(
|
|
20
|
+
bytes: string,
|
|
21
|
+
watermark?: Uint8Array,
|
|
22
|
+
): Promise<{
|
|
23
|
+
bytes: string;
|
|
24
|
+
sig: string;
|
|
25
|
+
prefixSig: string;
|
|
26
|
+
sbytes: string;
|
|
27
|
+
}>;
|
|
28
|
+
secretKey(): Promise<string | undefined>;
|
|
29
|
+
};
|
|
30
|
+
export interface TezosSigner {
|
|
31
|
+
getAddress(
|
|
32
|
+
path: string,
|
|
33
|
+
options: {
|
|
34
|
+
verify?: boolean;
|
|
35
|
+
curve?: Curve;
|
|
36
|
+
ins?: number;
|
|
37
|
+
},
|
|
38
|
+
): Promise<TezosAddress>;
|
|
39
|
+
signOperation(
|
|
40
|
+
path: string,
|
|
41
|
+
rawTxHex: string,
|
|
42
|
+
options: {
|
|
43
|
+
curve?: Curve;
|
|
44
|
+
},
|
|
45
|
+
): Promise<TezosSignature>;
|
|
46
|
+
// Tezos [LedgerSigner](https://www.npmjs.com/package/@taquito/ledger-signer)
|
|
47
|
+
createLedgerSigner(path: string, prompt: boolean, derivationType: number): LedgerSigner;
|
|
48
|
+
}
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
{
|
|
2
|
+
"extends": "../../../tsconfig.base",
|
|
3
|
+
"compilerOptions": {
|
|
4
|
+
"declaration": true,
|
|
5
|
+
"declarationMap": true,
|
|
6
|
+
"module": "commonjs",
|
|
7
|
+
"downlevelIteration": true,
|
|
8
|
+
"lib": ["es2020", "dom"],
|
|
9
|
+
"outDir": "lib",
|
|
10
|
+
"typeRoots": ["./node_modules/@types", "./types/@taquito"]
|
|
11
|
+
},
|
|
12
|
+
"include": ["src/**/*"]
|
|
13
|
+
}
|