@ledgerhq/coin-tezos 0.4.0-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 +20 -0
- package/.turbo/turbo-build.log +4 -0
- package/.unimportedrc.json +39 -0
- package/CHANGELOG.md +12 -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 +81 -0
- package/lib/api/tzkt.d.ts.map +1 -0
- package/lib/api/tzkt.js +52 -0
- package/lib/api/tzkt.js.map +1 -0
- package/lib/bridge/broadcast.d.ts +6 -0
- package/lib/bridge/broadcast.d.ts.map +1 -0
- package/lib/bridge/broadcast.js +22 -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 +40 -0
- package/lib/bridge/broadcast.test.js.map +1 -0
- package/lib/bridge/createTransaction.d.ts +3 -0
- package/lib/bridge/createTransaction.d.ts.map +1 -0
- package/lib/bridge/createTransaction.js +23 -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 +10 -0
- package/lib/bridge/estimateMaxSpendable.d.ts.map +1 -0
- package/lib/bridge/estimateMaxSpendable.js +29 -0
- package/lib/bridge/estimateMaxSpendable.js.map +1 -0
- package/lib/bridge/getAccountShape.d.ts +5 -0
- package/lib/bridge/getAccountShape.d.ts.map +1 -0
- package/lib/bridge/getAccountShape.js +253 -0
- package/lib/bridge/getAccountShape.js.map +1 -0
- package/lib/bridge/getAccountShape.test.d.ts +2 -0
- package/lib/bridge/getAccountShape.test.d.ts.map +1 -0
- package/lib/bridge/getAccountShape.test.js +33 -0
- package/lib/bridge/getAccountShape.test.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 +58 -0
- package/lib/bridge/index.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 +9 -0
- package/lib/bridge/prepareTransaction.d.ts.map +1 -0
- package/lib/bridge/prepareTransaction.js +157 -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 +147 -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/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/bridge/transactionStatus.d.ts +3 -0
- package/lib/bridge/transactionStatus.d.ts.map +1 -0
- package/lib/bridge/transactionStatus.js +114 -0
- package/lib/bridge/transactionStatus.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 +81 -0
- package/lib-es/api/tzkt.d.ts.map +1 -0
- package/lib-es/api/tzkt.js +47 -0
- package/lib-es/api/tzkt.js.map +1 -0
- package/lib-es/bridge/broadcast.d.ts +6 -0
- package/lib-es/bridge/broadcast.d.ts.map +1 -0
- package/lib-es/bridge/broadcast.js +20 -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/createTransaction.d.ts +3 -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 +10 -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/getAccountShape.d.ts +5 -0
- package/lib-es/bridge/getAccountShape.d.ts.map +1 -0
- package/lib-es/bridge/getAccountShape.js +245 -0
- package/lib-es/bridge/getAccountShape.js.map +1 -0
- package/lib-es/bridge/getAccountShape.test.d.ts +2 -0
- package/lib-es/bridge/getAccountShape.test.d.ts.map +1 -0
- package/lib-es/bridge/getAccountShape.test.js +31 -0
- package/lib-es/bridge/getAccountShape.test.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 +51 -0
- package/lib-es/bridge/index.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 +9 -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 +143 -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/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/bridge/transactionStatus.d.ts +3 -0
- package/lib-es/bridge/transactionStatus.d.ts.map +1 -0
- package/lib-es/bridge/transactionStatus.js +107 -0
- package/lib-es/bridge/transactionStatus.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 +116 -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 +112 -0
- package/src/bridge/broadcast.test.ts +30 -0
- package/src/bridge/broadcast.ts +18 -0
- package/src/bridge/createTransaction.ts +18 -0
- package/src/bridge/deviceTransactionConfig.ts +74 -0
- package/src/bridge/estimateMaxSpendable.ts +32 -0
- package/src/bridge/getAccountShape.test.ts +22 -0
- package/src/bridge/getAccountShape.ts +289 -0
- package/src/bridge/index.ts +65 -0
- package/src/bridge/preload.ts +18 -0
- package/src/bridge/prepareTransaction.ts +160 -0
- package/src/bridge/serialization.ts +27 -0
- package/src/bridge/signOperation.test.ts +211 -0
- package/src/bridge/signOperation.ts +213 -0
- package/src/bridge/transaction.ts +94 -0
- package/src/bridge/transactionStatus.ts +130 -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
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
export default {
|
|
2
|
+
name: "tezos seed 1",
|
|
3
|
+
unstableAccounts: true,
|
|
4
|
+
// accounts are staking so receive over time. we disable for now snapshot comparison
|
|
5
|
+
apdus: `
|
|
6
|
+
=> 800200000d038000002c800006c180000000
|
|
7
|
+
<= 2102ac76ba226118e2d593d09cd7e395546b7540c0e7fb3eb430da59f7982af632969000
|
|
8
|
+
=> 8002000015058000002c800006c1800000008000000080000001
|
|
9
|
+
<= 2102b058662fd530e6463d774e3951a40ddd5e430dbeb62673f90caca0cec58735fd9000
|
|
10
|
+
=> 8002000011048000002c800006c18000000080000001
|
|
11
|
+
<= 2102670e5e92d06e725b68edda589678fdf0f85a582df06ee634d841cf8042db63839000
|
|
12
|
+
=> 8002000015058000002c800006c1800000008000000080000000
|
|
13
|
+
<= 2102f7ed85c519f7d39a664935a410d1a41ca302dfa3eee228e92cbe0dc12aba7a189000
|
|
14
|
+
=> 8002000015058000002c800006c1800000018000000080000000
|
|
15
|
+
<= 2102c26d0da1978b7a7596c9853d80d0beac20519c73e76e7f677540db47165d94f39000
|
|
16
|
+
=> 8002000015058000002c800006c1800000028000000080000000
|
|
17
|
+
<= 21020058c0efd324fa13d778c4b0995f6fa8d9c85e561c1465d770d4011993f557509000
|
|
18
|
+
=> 8002000015058000002c800006c1800000038000000080000000
|
|
19
|
+
<= 21029bfe70b3e94ff23623f6c42f6e081a9ca8cc78f74b0d8da58f0d4cdc41c33c1a9000
|
|
20
|
+
=> 8002000015058000002c800006c1800000048000000080000000
|
|
21
|
+
<= 21021d3b9b84feb81d5215cca4f0a016e99fc6cf86d06e864cb4a5098709f16aa2219000
|
|
22
|
+
=> 8002000015058000002c800006c1800000058000000080000000
|
|
23
|
+
<= 21020162dc75ad3c2b6e097d15a1513033c60d8a033f2312ff5a6ead812228d9d6539000
|
|
24
|
+
=> 8002000015058000002c800006c1800000068000000080000000
|
|
25
|
+
<= 21021831897c4224296519d496d32fdf9e17fb4af680635c5dbbc46cde84fe11dcc99000
|
|
26
|
+
=> 8002000011048000002c800006c18000000080000000
|
|
27
|
+
<= 210294e8344ae6df2d3123fa100b5abd40cee339c67838b1c34c4f243cc582f4d2d89000
|
|
28
|
+
=> 8002000011048000002c800006c18000000180000000
|
|
29
|
+
<= 2102389ffd73423626894cb151416e51c72ec285376673daf83545eb5edb45b261ce9000
|
|
30
|
+
=> 8002000011048000002c800006c18000000280000000
|
|
31
|
+
<= 2102e4c49994c90ffe2e5480826d2f49fb9d0f45280e20bd0a61c488f652d7af0f9c9000
|
|
32
|
+
=> 8002000011048000002c800006c18000000380000000
|
|
33
|
+
<= 2102a9ae8b0ff5f9a43565793ad78e10db6f12177d904d208ada591b8a5b9999e3fd9000
|
|
34
|
+
`,
|
|
35
|
+
};
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { GetAddressFn } from "@ledgerhq/coin-framework/bridge/getAddressWrapper";
|
|
2
|
+
import { SignerContext } from "@ledgerhq/coin-framework/signer";
|
|
3
|
+
import { GetAddressOptions } from "@ledgerhq/coin-framework/derivation";
|
|
4
|
+
import type { TezosSigner } from "../types";
|
|
5
|
+
|
|
6
|
+
const getAddress = (signerContext: SignerContext<TezosSigner>): GetAddressFn => {
|
|
7
|
+
return async (deviceId: string, { path, verify }: GetAddressOptions) => {
|
|
8
|
+
const r = await signerContext(deviceId, signer => signer.getAddress(path, { verify }));
|
|
9
|
+
return { ...r, path };
|
|
10
|
+
};
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
export default getAddress;
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import type { DeviceAction } from "@ledgerhq/coin-framework/bot/types";
|
|
2
|
+
import type { Transaction } from "../types";
|
|
3
|
+
import {
|
|
4
|
+
deviceActionFlow,
|
|
5
|
+
formatDeviceAmount,
|
|
6
|
+
SpeculosButton,
|
|
7
|
+
} from "@ledgerhq/coin-framework/bot/specs";
|
|
8
|
+
|
|
9
|
+
export const acceptTransaction: DeviceAction<Transaction, any> = deviceActionFlow({
|
|
10
|
+
steps: [
|
|
11
|
+
{
|
|
12
|
+
title: "Review",
|
|
13
|
+
button: SpeculosButton.RIGHT,
|
|
14
|
+
},
|
|
15
|
+
{
|
|
16
|
+
title: "Withdraw",
|
|
17
|
+
button: SpeculosButton.RIGHT,
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
title: "Custom Delegate",
|
|
21
|
+
button: SpeculosButton.RIGHT,
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
// device sometimes know the text of a given delegator, we're not validating the actual text
|
|
25
|
+
title: "Delegate",
|
|
26
|
+
button: SpeculosButton.RIGHT,
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
title: "Delegate Name",
|
|
30
|
+
button: SpeculosButton.RIGHT,
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
title: "Confirm",
|
|
34
|
+
button: SpeculosButton.RIGHT,
|
|
35
|
+
expectedValue: ({ transaction }) => {
|
|
36
|
+
return transaction.mode === "send" ? "Transaction" : "Delegation";
|
|
37
|
+
},
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
title: "Amount",
|
|
41
|
+
button: SpeculosButton.RIGHT,
|
|
42
|
+
expectedValue: ({ account, transaction }) =>
|
|
43
|
+
formatDeviceAmount(account.currency, transaction.amount, {
|
|
44
|
+
postfixCode: true,
|
|
45
|
+
}),
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
title: "Fee",
|
|
49
|
+
button: SpeculosButton.RIGHT,
|
|
50
|
+
expectedValue: ({ account, status }) =>
|
|
51
|
+
formatDeviceAmount(account.currency, status.estimatedFees, {
|
|
52
|
+
postfixCode: true,
|
|
53
|
+
}),
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
title: "Source",
|
|
57
|
+
button: SpeculosButton.RIGHT,
|
|
58
|
+
expectedValue: ({ account }) => account.freshAddress,
|
|
59
|
+
},
|
|
60
|
+
{
|
|
61
|
+
title: "Destination",
|
|
62
|
+
button: SpeculosButton.RIGHT,
|
|
63
|
+
expectedValue: ({ transaction }) => transaction.recipient,
|
|
64
|
+
},
|
|
65
|
+
{
|
|
66
|
+
title: "Storage Limit",
|
|
67
|
+
button: SpeculosButton.RIGHT,
|
|
68
|
+
expectedValue: ({ transaction }) => transaction.storageLimit?.toString() || "",
|
|
69
|
+
},
|
|
70
|
+
{
|
|
71
|
+
title: "Reject",
|
|
72
|
+
button: SpeculosButton.RIGHT,
|
|
73
|
+
},
|
|
74
|
+
{
|
|
75
|
+
title: "Accept",
|
|
76
|
+
button: SpeculosButton.BOTH,
|
|
77
|
+
},
|
|
78
|
+
],
|
|
79
|
+
});
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
import sample from "lodash/sample";
|
|
2
|
+
import invariant from "invariant";
|
|
3
|
+
import { getCryptoCurrencyById } from "@ledgerhq/cryptoassets/index";
|
|
4
|
+
import { parseCurrencyUnit } from "@ledgerhq/coin-framework/currencies/index";
|
|
5
|
+
import { genericTestDestination, pickSiblings } from "@ledgerhq/coin-framework/bot/specs";
|
|
6
|
+
import type { AppSpec } from "@ledgerhq/coin-framework/bot/types";
|
|
7
|
+
import { DeviceModelId } from "@ledgerhq/devices";
|
|
8
|
+
import { isTezosAccount, type Transaction } from "../types";
|
|
9
|
+
import { getAccountDelegationSync, isAccountDelegating } from "../api/bakers";
|
|
10
|
+
import whitelist from "../api/bakers.whitelist-default";
|
|
11
|
+
import { acceptTransaction } from "./bot-deviceActions";
|
|
12
|
+
import { Account } from "@ledgerhq/types-live";
|
|
13
|
+
|
|
14
|
+
const maxAccount = 12;
|
|
15
|
+
|
|
16
|
+
function expectUnrevealed(account: Account) {
|
|
17
|
+
if (!isTezosAccount(account)) throw Error("Not TezosAccount type");
|
|
18
|
+
invariant(account.tezosResources?.revealed === false, "account must be unreleaved");
|
|
19
|
+
}
|
|
20
|
+
function expectRevealed(account: Account) {
|
|
21
|
+
if (!isTezosAccount(account)) throw Error("Not TezosAccount type");
|
|
22
|
+
invariant(account.tezosResources?.revealed === true, "account must be releaved");
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
const tezosUnit = getCryptoCurrencyById("tezos").units[0];
|
|
26
|
+
|
|
27
|
+
const safeMinimumForDestinationNotCreated = parseCurrencyUnit(tezosUnit, "0.6");
|
|
28
|
+
const strictMin = parseCurrencyUnit(tezosUnit, "0.02");
|
|
29
|
+
|
|
30
|
+
const tezos: AppSpec<Transaction> = {
|
|
31
|
+
name: "Tezos",
|
|
32
|
+
currency: getCryptoCurrencyById("tezos"),
|
|
33
|
+
appQuery: {
|
|
34
|
+
model: DeviceModelId.nanoS,
|
|
35
|
+
appName: "TezosWallet",
|
|
36
|
+
},
|
|
37
|
+
genericDeviceAction: acceptTransaction,
|
|
38
|
+
testTimeout: 2 * 60 * 1000,
|
|
39
|
+
minViableAmount: strictMin,
|
|
40
|
+
transactionCheck: ({ maxSpendable }) => {
|
|
41
|
+
invariant(maxSpendable.gt(strictMin), "balance is too low");
|
|
42
|
+
},
|
|
43
|
+
mutations: [
|
|
44
|
+
{
|
|
45
|
+
name: "send unrevealed",
|
|
46
|
+
maxRun: 1,
|
|
47
|
+
testDestination: genericTestDestination,
|
|
48
|
+
transaction: ({ maxSpendable, account, siblings, bridge }) => {
|
|
49
|
+
expectUnrevealed(account);
|
|
50
|
+
const sibling = pickSiblings(siblings, maxAccount);
|
|
51
|
+
const recipient = sibling.freshAddress;
|
|
52
|
+
const amount = maxSpendable.div(2).integerValue();
|
|
53
|
+
if (sibling.balance.eq(0) && amount.lt(safeMinimumForDestinationNotCreated)) {
|
|
54
|
+
throw new Error("need more funds to send to new address");
|
|
55
|
+
}
|
|
56
|
+
return {
|
|
57
|
+
transaction: bridge.createTransaction(account),
|
|
58
|
+
updates: [{ recipient, amount }],
|
|
59
|
+
};
|
|
60
|
+
},
|
|
61
|
+
},
|
|
62
|
+
{
|
|
63
|
+
name: "send revealed",
|
|
64
|
+
maxRun: 2,
|
|
65
|
+
testDestination: genericTestDestination,
|
|
66
|
+
transaction: ({ maxSpendable, account, siblings, bridge }) => {
|
|
67
|
+
expectRevealed(account);
|
|
68
|
+
const sibling = pickSiblings(siblings, maxAccount);
|
|
69
|
+
const recipient = sibling.freshAddress;
|
|
70
|
+
const amount = maxSpendable.div(2).integerValue();
|
|
71
|
+
if (sibling.balance.eq(0) && amount.lt(safeMinimumForDestinationNotCreated)) {
|
|
72
|
+
throw new Error("need more funds to send to new address");
|
|
73
|
+
}
|
|
74
|
+
return {
|
|
75
|
+
transaction: bridge.createTransaction(account),
|
|
76
|
+
updates: [{ recipient, amount }],
|
|
77
|
+
};
|
|
78
|
+
},
|
|
79
|
+
},
|
|
80
|
+
{
|
|
81
|
+
name: "send max (non delegating)",
|
|
82
|
+
maxRun: 3,
|
|
83
|
+
testDestination: genericTestDestination,
|
|
84
|
+
transaction: ({ account, siblings, bridge, maxSpendable }) => {
|
|
85
|
+
invariant(!isAccountDelegating(account), "account must not be delegating");
|
|
86
|
+
const sibling = pickSiblings(siblings, maxAccount);
|
|
87
|
+
const recipient = sibling.freshAddress;
|
|
88
|
+
if (sibling.balance.eq(0) && maxSpendable.lt(safeMinimumForDestinationNotCreated)) {
|
|
89
|
+
throw new Error("need more funds to send to new address");
|
|
90
|
+
}
|
|
91
|
+
return {
|
|
92
|
+
transaction: bridge.createTransaction(account),
|
|
93
|
+
updates: [{ recipient, useAllAmount: true }],
|
|
94
|
+
};
|
|
95
|
+
},
|
|
96
|
+
},
|
|
97
|
+
{
|
|
98
|
+
name: "delegate unrevealed",
|
|
99
|
+
maxRun: 1,
|
|
100
|
+
transaction: ({ account, bridge }) => {
|
|
101
|
+
expectUnrevealed(account);
|
|
102
|
+
const d = getAccountDelegationSync(account);
|
|
103
|
+
const recipient = sample(d ? whitelist.filter(w => w !== d.address) : whitelist);
|
|
104
|
+
return {
|
|
105
|
+
transaction: bridge.createTransaction(account),
|
|
106
|
+
updates: [{ recipient, mode: "delegate" }],
|
|
107
|
+
};
|
|
108
|
+
},
|
|
109
|
+
},
|
|
110
|
+
{
|
|
111
|
+
name: "delegate revealed",
|
|
112
|
+
maxRun: 1,
|
|
113
|
+
transaction: ({ account, bridge }) => {
|
|
114
|
+
expectRevealed(account);
|
|
115
|
+
const d = getAccountDelegationSync(account);
|
|
116
|
+
const recipient = sample(d ? whitelist.filter(w => w !== d.address) : whitelist);
|
|
117
|
+
return {
|
|
118
|
+
transaction: bridge.createTransaction(account),
|
|
119
|
+
updates: [{ recipient, mode: "delegate" }],
|
|
120
|
+
};
|
|
121
|
+
},
|
|
122
|
+
},
|
|
123
|
+
{
|
|
124
|
+
name: "undelegate unrevealed",
|
|
125
|
+
maxRun: 1,
|
|
126
|
+
transaction: ({ account, bridge }) => {
|
|
127
|
+
invariant(getAccountDelegationSync(account), "account must be delegating");
|
|
128
|
+
expectUnrevealed(account);
|
|
129
|
+
return {
|
|
130
|
+
transaction: bridge.createTransaction(account),
|
|
131
|
+
updates: [{ mode: "undelegate" }],
|
|
132
|
+
};
|
|
133
|
+
},
|
|
134
|
+
},
|
|
135
|
+
{
|
|
136
|
+
name: "undelegate revealed",
|
|
137
|
+
maxRun: 1,
|
|
138
|
+
transaction: ({ account, bridge }) => {
|
|
139
|
+
invariant(getAccountDelegationSync(account), "account must be delegating");
|
|
140
|
+
expectRevealed(account);
|
|
141
|
+
return {
|
|
142
|
+
transaction: bridge.createTransaction(account),
|
|
143
|
+
updates: [{ mode: "undelegate" }],
|
|
144
|
+
};
|
|
145
|
+
},
|
|
146
|
+
},
|
|
147
|
+
],
|
|
148
|
+
};
|
|
149
|
+
|
|
150
|
+
export default {
|
|
151
|
+
tezos,
|
|
152
|
+
};
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
import { AmountRequired, NotEnoughBalance } from "@ledgerhq/errors";
|
|
2
|
+
import type { DatasetTest, DerivationMode } from "@ledgerhq/types-live";
|
|
3
|
+
import type { TezosAccountRaw, Transaction } from "../types";
|
|
4
|
+
import tezosScanAccounts1 from "../datasets/tezos.scanAccounts.1";
|
|
5
|
+
|
|
6
|
+
function makeAccountRaw(
|
|
7
|
+
name: string,
|
|
8
|
+
pubkey: string,
|
|
9
|
+
address: string,
|
|
10
|
+
derivationMode: DerivationMode,
|
|
11
|
+
): TezosAccountRaw {
|
|
12
|
+
return {
|
|
13
|
+
id: `js:2:tezos:${pubkey}:${derivationMode}`,
|
|
14
|
+
seedIdentifier: address,
|
|
15
|
+
name: "Tezos " + name,
|
|
16
|
+
derivationMode,
|
|
17
|
+
index: 0,
|
|
18
|
+
freshAddress: address,
|
|
19
|
+
freshAddressPath: "",
|
|
20
|
+
blockHeight: 0,
|
|
21
|
+
operations: [],
|
|
22
|
+
pendingOperations: [],
|
|
23
|
+
currencyId: "tezos",
|
|
24
|
+
lastSyncDate: "",
|
|
25
|
+
balance: "0",
|
|
26
|
+
xpub: pubkey,
|
|
27
|
+
subAccounts: [],
|
|
28
|
+
tezosResources: { revealed: true, counter: 0 },
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export const accountTZrevealedDelegating = makeAccountRaw(
|
|
33
|
+
"TZrevealedDelegating",
|
|
34
|
+
"02389ffd73423626894cb151416e51c72ec285376673daf83545eb5edb45b261ce",
|
|
35
|
+
"tz1boBHAVpwcvKkNFAQHYr7mjxAz1PpVgKq7",
|
|
36
|
+
"tezbox",
|
|
37
|
+
);
|
|
38
|
+
|
|
39
|
+
const accountTZnew = makeAccountRaw(
|
|
40
|
+
"TZnew",
|
|
41
|
+
"02a9ae8b0ff5f9a43565793ad78e10db6f12177d904d208ada591b8a5b9999e3fd",
|
|
42
|
+
"tz1VSichevvJSNkSSntgwKDKikWNB6iqNJii",
|
|
43
|
+
"tezbox",
|
|
44
|
+
);
|
|
45
|
+
|
|
46
|
+
const accountTZnotRevealed = makeAccountRaw(
|
|
47
|
+
"TZnotRevealed",
|
|
48
|
+
"020162dc75ad3c2b6e097d15a1513033c60d8a033f2312ff5a6ead812228d9d653",
|
|
49
|
+
"tz1PWFt4Ym6HedY78MgUP2kVDtSampGwprs5",
|
|
50
|
+
"tezosbip44h",
|
|
51
|
+
);
|
|
52
|
+
|
|
53
|
+
const accountTZRevealedNoDelegate = makeAccountRaw(
|
|
54
|
+
"TZRevealedNoDelegate",
|
|
55
|
+
"029bfe70b3e94ff23623f6c42f6e081a9ca8cc78f74b0d8da58f0d4cdc41c33c1a",
|
|
56
|
+
"tz1YkAjh5mm5gJ5u3VbFLEtpAG7cFo7PfCux",
|
|
57
|
+
"tezosbip44h",
|
|
58
|
+
);
|
|
59
|
+
|
|
60
|
+
export const dataset: DatasetTest<Transaction> = {
|
|
61
|
+
implementations: ["js"],
|
|
62
|
+
currencies: {
|
|
63
|
+
tezos: {
|
|
64
|
+
FIXME_ignoreOperationFields: ["blockHeight"],
|
|
65
|
+
scanAccounts: [tezosScanAccounts1],
|
|
66
|
+
accounts: [
|
|
67
|
+
{
|
|
68
|
+
raw: accountTZrevealedDelegating,
|
|
69
|
+
transactions: [
|
|
70
|
+
{
|
|
71
|
+
name: "No amount",
|
|
72
|
+
transaction: t => ({
|
|
73
|
+
...t,
|
|
74
|
+
recipient: "tz1VSichevvJSNkSSntgwKDKikWNB6iqNJii",
|
|
75
|
+
}),
|
|
76
|
+
expectedStatus: {
|
|
77
|
+
errors: { amount: new AmountRequired() },
|
|
78
|
+
warnings: {},
|
|
79
|
+
},
|
|
80
|
+
},
|
|
81
|
+
],
|
|
82
|
+
},
|
|
83
|
+
{
|
|
84
|
+
raw: accountTZRevealedNoDelegate,
|
|
85
|
+
transactions: [],
|
|
86
|
+
},
|
|
87
|
+
{
|
|
88
|
+
raw: accountTZnotRevealed,
|
|
89
|
+
transactions: [
|
|
90
|
+
{
|
|
91
|
+
name: "send more than min allowed",
|
|
92
|
+
transaction: (t, account) => ({
|
|
93
|
+
...t,
|
|
94
|
+
amount: account.balance.minus("100"),
|
|
95
|
+
recipient: "tz1VSichevvJSNkSSntgwKDKikWNB6iqNJii",
|
|
96
|
+
}),
|
|
97
|
+
expectedStatus: {
|
|
98
|
+
errors: {
|
|
99
|
+
amount: new NotEnoughBalance(),
|
|
100
|
+
},
|
|
101
|
+
warnings: {},
|
|
102
|
+
},
|
|
103
|
+
},
|
|
104
|
+
/* // FIXME broken test
|
|
105
|
+
{
|
|
106
|
+
name: "Amount > spendablebalance",
|
|
107
|
+
transaction: (t, account) => ({
|
|
108
|
+
...t,
|
|
109
|
+
amount: account.balance,
|
|
110
|
+
recipient: accountTZnew.freshAddress,
|
|
111
|
+
}),
|
|
112
|
+
expectedStatus: {
|
|
113
|
+
errors: {
|
|
114
|
+
amount: new NotEnoughBalance(),
|
|
115
|
+
},
|
|
116
|
+
warnings: {},
|
|
117
|
+
},
|
|
118
|
+
},
|
|
119
|
+
*/
|
|
120
|
+
],
|
|
121
|
+
},
|
|
122
|
+
{
|
|
123
|
+
raw: accountTZnew,
|
|
124
|
+
test: (expect, account) => {
|
|
125
|
+
expect(account.operations).toEqual([]);
|
|
126
|
+
},
|
|
127
|
+
transactions: [],
|
|
128
|
+
},
|
|
129
|
+
],
|
|
130
|
+
},
|
|
131
|
+
},
|
|
132
|
+
};
|
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
|
+
}
|