@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.
Files changed (325) hide show
  1. package/.eslintrc.js +20 -0
  2. package/.turbo/turbo-build.log +4 -0
  3. package/.unimportedrc.json +39 -0
  4. package/CHANGELOG.md +12 -0
  5. package/LICENSE.txt +21 -0
  6. package/jest.config.js +6 -0
  7. package/lib/api/bakers.d.ts +14 -0
  8. package/lib/api/bakers.d.ts.map +1 -0
  9. package/lib/api/bakers.integration.test.d.ts +2 -0
  10. package/lib/api/bakers.integration.test.d.ts.map +1 -0
  11. package/lib/api/bakers.integration.test.js +61 -0
  12. package/lib/api/bakers.integration.test.js.map +1 -0
  13. package/lib/api/bakers.js +141 -0
  14. package/lib/api/bakers.js.map +1 -0
  15. package/lib/api/bakers.test.d.ts +2 -0
  16. package/lib/api/bakers.test.d.ts.map +1 -0
  17. package/lib/api/bakers.test.js +146 -0
  18. package/lib/api/bakers.test.js.map +1 -0
  19. package/lib/api/bakers.whitelist-default.d.ts +4 -0
  20. package/lib/api/bakers.whitelist-default.d.ts.map +1 -0
  21. package/lib/api/bakers.whitelist-default.js +34 -0
  22. package/lib/api/bakers.whitelist-default.js.map +1 -0
  23. package/lib/api/index.d.ts +3 -0
  24. package/lib/api/index.d.ts.map +1 -0
  25. package/lib/api/index.js +19 -0
  26. package/lib/api/index.js.map +1 -0
  27. package/lib/api/tzkt.d.ts +81 -0
  28. package/lib/api/tzkt.d.ts.map +1 -0
  29. package/lib/api/tzkt.js +52 -0
  30. package/lib/api/tzkt.js.map +1 -0
  31. package/lib/bridge/broadcast.d.ts +6 -0
  32. package/lib/bridge/broadcast.d.ts.map +1 -0
  33. package/lib/bridge/broadcast.js +22 -0
  34. package/lib/bridge/broadcast.js.map +1 -0
  35. package/lib/bridge/broadcast.test.d.ts +2 -0
  36. package/lib/bridge/broadcast.test.d.ts.map +1 -0
  37. package/lib/bridge/broadcast.test.js +40 -0
  38. package/lib/bridge/broadcast.test.js.map +1 -0
  39. package/lib/bridge/createTransaction.d.ts +3 -0
  40. package/lib/bridge/createTransaction.d.ts.map +1 -0
  41. package/lib/bridge/createTransaction.js +23 -0
  42. package/lib/bridge/createTransaction.js.map +1 -0
  43. package/lib/bridge/deviceTransactionConfig.d.ts +19 -0
  44. package/lib/bridge/deviceTransactionConfig.d.ts.map +1 -0
  45. package/lib/bridge/deviceTransactionConfig.js +44 -0
  46. package/lib/bridge/deviceTransactionConfig.js.map +1 -0
  47. package/lib/bridge/estimateMaxSpendable.d.ts +10 -0
  48. package/lib/bridge/estimateMaxSpendable.d.ts.map +1 -0
  49. package/lib/bridge/estimateMaxSpendable.js +29 -0
  50. package/lib/bridge/estimateMaxSpendable.js.map +1 -0
  51. package/lib/bridge/getAccountShape.d.ts +5 -0
  52. package/lib/bridge/getAccountShape.d.ts.map +1 -0
  53. package/lib/bridge/getAccountShape.js +253 -0
  54. package/lib/bridge/getAccountShape.js.map +1 -0
  55. package/lib/bridge/getAccountShape.test.d.ts +2 -0
  56. package/lib/bridge/getAccountShape.test.d.ts.map +1 -0
  57. package/lib/bridge/getAccountShape.test.js +33 -0
  58. package/lib/bridge/getAccountShape.test.js.map +1 -0
  59. package/lib/bridge/index.d.ts +8 -0
  60. package/lib/bridge/index.d.ts.map +1 -0
  61. package/lib/bridge/index.js +58 -0
  62. package/lib/bridge/index.js.map +1 -0
  63. package/lib/bridge/preload.d.ts +9 -0
  64. package/lib/bridge/preload.d.ts.map +1 -0
  65. package/lib/bridge/preload.js +32 -0
  66. package/lib/bridge/preload.js.map +1 -0
  67. package/lib/bridge/prepareTransaction.d.ts +9 -0
  68. package/lib/bridge/prepareTransaction.d.ts.map +1 -0
  69. package/lib/bridge/prepareTransaction.js +157 -0
  70. package/lib/bridge/prepareTransaction.js.map +1 -0
  71. package/lib/bridge/serialization.d.ts +7 -0
  72. package/lib/bridge/serialization.d.ts.map +1 -0
  73. package/lib/bridge/serialization.js +27 -0
  74. package/lib/bridge/serialization.js.map +1 -0
  75. package/lib/bridge/signOperation.d.ts +19 -0
  76. package/lib/bridge/signOperation.d.ts.map +1 -0
  77. package/lib/bridge/signOperation.js +147 -0
  78. package/lib/bridge/signOperation.js.map +1 -0
  79. package/lib/bridge/signOperation.test.d.ts +2 -0
  80. package/lib/bridge/signOperation.test.d.ts.map +1 -0
  81. package/lib/bridge/signOperation.test.js +223 -0
  82. package/lib/bridge/signOperation.test.js.map +1 -0
  83. package/lib/bridge/transaction.d.ts +15 -0
  84. package/lib/bridge/transaction.d.ts.map +1 -0
  85. package/lib/bridge/transaction.js +52 -0
  86. package/lib/bridge/transaction.js.map +1 -0
  87. package/lib/bridge/transactionStatus.d.ts +3 -0
  88. package/lib/bridge/transactionStatus.d.ts.map +1 -0
  89. package/lib/bridge/transactionStatus.js +114 -0
  90. package/lib/bridge/transactionStatus.js.map +1 -0
  91. package/lib/datasets/tezos.scanAccounts.1.d.ts +7 -0
  92. package/lib/datasets/tezos.scanAccounts.1.d.ts.map +1 -0
  93. package/lib/datasets/tezos.scanAccounts.1.js +38 -0
  94. package/lib/datasets/tezos.scanAccounts.1.js.map +1 -0
  95. package/lib/index.d.ts +3 -0
  96. package/lib/index.d.ts.map +1 -0
  97. package/lib/index.js +21 -0
  98. package/lib/index.js.map +1 -0
  99. package/lib/signer/getAddress.d.ts +6 -0
  100. package/lib/signer/getAddress.d.ts.map +1 -0
  101. package/lib/signer/getAddress.js +19 -0
  102. package/lib/signer/getAddress.js.map +1 -0
  103. package/lib/signer/index.d.ts +6 -0
  104. package/lib/signer/index.d.ts.map +1 -0
  105. package/lib/signer/index.js +11 -0
  106. package/lib/signer/index.js.map +1 -0
  107. package/lib/test/bot-deviceActions.d.ts +4 -0
  108. package/lib/test/bot-deviceActions.d.ts.map +1 -0
  109. package/lib/test/bot-deviceActions.js +74 -0
  110. package/lib/test/bot-deviceActions.js.map +1 -0
  111. package/lib/test/bot-specs.d.ts +7 -0
  112. package/lib/test/bot-specs.d.ts.map +1 -0
  113. package/lib/test/bot-specs.js +154 -0
  114. package/lib/test/bot-specs.js.map +1 -0
  115. package/lib/test/bridgeDatasetTest.d.ts +5 -0
  116. package/lib/test/bridgeDatasetTest.d.ts.map +1 -0
  117. package/lib/test/bridgeDatasetTest.js +99 -0
  118. package/lib/test/bridgeDatasetTest.js.map +1 -0
  119. package/lib/test/cli.d.ts +78 -0
  120. package/lib/test/cli.d.ts.map +1 -0
  121. package/lib/test/cli.js +97 -0
  122. package/lib/test/cli.js.map +1 -0
  123. package/lib/test/index.d.ts +2 -0
  124. package/lib/test/index.d.ts.map +1 -0
  125. package/lib/test/index.js +18 -0
  126. package/lib/test/index.js.map +1 -0
  127. package/lib/types/errors.d.ts +4 -0
  128. package/lib/types/errors.d.ts.map +1 -0
  129. package/lib/types/errors.js +6 -0
  130. package/lib/types/errors.js.map +1 -0
  131. package/lib/types/index.d.ts +4 -0
  132. package/lib/types/index.d.ts.map +1 -0
  133. package/lib/types/index.js +20 -0
  134. package/lib/types/index.js.map +1 -0
  135. package/lib/types/model.d.ts +92 -0
  136. package/lib/types/model.d.ts.map +1 -0
  137. package/lib/types/model.fixture.d.ts +5 -0
  138. package/lib/types/model.fixture.d.ts.map +1 -0
  139. package/lib/types/model.fixture.js +85 -0
  140. package/lib/types/model.fixture.js.map +1 -0
  141. package/lib/types/model.js +8 -0
  142. package/lib/types/model.js.map +1 -0
  143. package/lib/types/signer.d.ts +37 -0
  144. package/lib/types/signer.d.ts.map +1 -0
  145. package/lib/types/signer.js +3 -0
  146. package/lib/types/signer.js.map +1 -0
  147. package/lib-es/api/bakers.d.ts +14 -0
  148. package/lib-es/api/bakers.d.ts.map +1 -0
  149. package/lib-es/api/bakers.integration.test.d.ts +2 -0
  150. package/lib-es/api/bakers.integration.test.d.ts.map +1 -0
  151. package/lib-es/api/bakers.integration.test.js +56 -0
  152. package/lib-es/api/bakers.integration.test.js.map +1 -0
  153. package/lib-es/api/bakers.js +125 -0
  154. package/lib-es/api/bakers.js.map +1 -0
  155. package/lib-es/api/bakers.test.d.ts +2 -0
  156. package/lib-es/api/bakers.test.d.ts.map +1 -0
  157. package/lib-es/api/bakers.test.js +141 -0
  158. package/lib-es/api/bakers.test.js.map +1 -0
  159. package/lib-es/api/bakers.whitelist-default.d.ts +4 -0
  160. package/lib-es/api/bakers.whitelist-default.d.ts.map +1 -0
  161. package/lib-es/api/bakers.whitelist-default.js +31 -0
  162. package/lib-es/api/bakers.whitelist-default.js.map +1 -0
  163. package/lib-es/api/index.d.ts +3 -0
  164. package/lib-es/api/index.d.ts.map +1 -0
  165. package/lib-es/api/index.js +3 -0
  166. package/lib-es/api/index.js.map +1 -0
  167. package/lib-es/api/tzkt.d.ts +81 -0
  168. package/lib-es/api/tzkt.d.ts.map +1 -0
  169. package/lib-es/api/tzkt.js +47 -0
  170. package/lib-es/api/tzkt.js.map +1 -0
  171. package/lib-es/bridge/broadcast.d.ts +6 -0
  172. package/lib-es/bridge/broadcast.d.ts.map +1 -0
  173. package/lib-es/bridge/broadcast.js +20 -0
  174. package/lib-es/bridge/broadcast.js.map +1 -0
  175. package/lib-es/bridge/broadcast.test.d.ts +2 -0
  176. package/lib-es/bridge/broadcast.test.d.ts.map +1 -0
  177. package/lib-es/bridge/broadcast.test.js +35 -0
  178. package/lib-es/bridge/broadcast.test.js.map +1 -0
  179. package/lib-es/bridge/createTransaction.d.ts +3 -0
  180. package/lib-es/bridge/createTransaction.d.ts.map +1 -0
  181. package/lib-es/bridge/createTransaction.js +17 -0
  182. package/lib-es/bridge/createTransaction.js.map +1 -0
  183. package/lib-es/bridge/deviceTransactionConfig.d.ts +19 -0
  184. package/lib-es/bridge/deviceTransactionConfig.d.ts.map +1 -0
  185. package/lib-es/bridge/deviceTransactionConfig.js +42 -0
  186. package/lib-es/bridge/deviceTransactionConfig.js.map +1 -0
  187. package/lib-es/bridge/estimateMaxSpendable.d.ts +10 -0
  188. package/lib-es/bridge/estimateMaxSpendable.d.ts.map +1 -0
  189. package/lib-es/bridge/estimateMaxSpendable.js +24 -0
  190. package/lib-es/bridge/estimateMaxSpendable.js.map +1 -0
  191. package/lib-es/bridge/getAccountShape.d.ts +5 -0
  192. package/lib-es/bridge/getAccountShape.d.ts.map +1 -0
  193. package/lib-es/bridge/getAccountShape.js +245 -0
  194. package/lib-es/bridge/getAccountShape.js.map +1 -0
  195. package/lib-es/bridge/getAccountShape.test.d.ts +2 -0
  196. package/lib-es/bridge/getAccountShape.test.d.ts.map +1 -0
  197. package/lib-es/bridge/getAccountShape.test.js +31 -0
  198. package/lib-es/bridge/getAccountShape.test.js.map +1 -0
  199. package/lib-es/bridge/index.d.ts +8 -0
  200. package/lib-es/bridge/index.d.ts.map +1 -0
  201. package/lib-es/bridge/index.js +51 -0
  202. package/lib-es/bridge/index.js.map +1 -0
  203. package/lib-es/bridge/preload.d.ts +9 -0
  204. package/lib-es/bridge/preload.d.ts.map +1 -0
  205. package/lib-es/bridge/preload.js +26 -0
  206. package/lib-es/bridge/preload.js.map +1 -0
  207. package/lib-es/bridge/prepareTransaction.d.ts +9 -0
  208. package/lib-es/bridge/prepareTransaction.d.ts.map +1 -0
  209. package/lib-es/bridge/prepareTransaction.js +150 -0
  210. package/lib-es/bridge/prepareTransaction.js.map +1 -0
  211. package/lib-es/bridge/serialization.d.ts +7 -0
  212. package/lib-es/bridge/serialization.d.ts.map +1 -0
  213. package/lib-es/bridge/serialization.js +20 -0
  214. package/lib-es/bridge/serialization.js.map +1 -0
  215. package/lib-es/bridge/signOperation.d.ts +19 -0
  216. package/lib-es/bridge/signOperation.d.ts.map +1 -0
  217. package/lib-es/bridge/signOperation.js +143 -0
  218. package/lib-es/bridge/signOperation.js.map +1 -0
  219. package/lib-es/bridge/signOperation.test.d.ts +2 -0
  220. package/lib-es/bridge/signOperation.test.d.ts.map +1 -0
  221. package/lib-es/bridge/signOperation.test.js +195 -0
  222. package/lib-es/bridge/signOperation.test.js.map +1 -0
  223. package/lib-es/bridge/transaction.d.ts +15 -0
  224. package/lib-es/bridge/transaction.d.ts.map +1 -0
  225. package/lib-es/bridge/transaction.js +46 -0
  226. package/lib-es/bridge/transaction.js.map +1 -0
  227. package/lib-es/bridge/transactionStatus.d.ts +3 -0
  228. package/lib-es/bridge/transactionStatus.d.ts.map +1 -0
  229. package/lib-es/bridge/transactionStatus.js +107 -0
  230. package/lib-es/bridge/transactionStatus.js.map +1 -0
  231. package/lib-es/datasets/tezos.scanAccounts.1.d.ts +7 -0
  232. package/lib-es/datasets/tezos.scanAccounts.1.d.ts.map +1 -0
  233. package/lib-es/datasets/tezos.scanAccounts.1.js +36 -0
  234. package/lib-es/datasets/tezos.scanAccounts.1.js.map +1 -0
  235. package/lib-es/index.d.ts +3 -0
  236. package/lib-es/index.d.ts.map +1 -0
  237. package/lib-es/index.js +3 -0
  238. package/lib-es/index.js.map +1 -0
  239. package/lib-es/signer/getAddress.d.ts +6 -0
  240. package/lib-es/signer/getAddress.d.ts.map +1 -0
  241. package/lib-es/signer/getAddress.js +17 -0
  242. package/lib-es/signer/getAddress.js.map +1 -0
  243. package/lib-es/signer/index.d.ts +6 -0
  244. package/lib-es/signer/index.d.ts.map +1 -0
  245. package/lib-es/signer/index.js +6 -0
  246. package/lib-es/signer/index.js.map +1 -0
  247. package/lib-es/test/bot-deviceActions.d.ts +4 -0
  248. package/lib-es/test/bot-deviceActions.d.ts.map +1 -0
  249. package/lib-es/test/bot-deviceActions.js +71 -0
  250. package/lib-es/test/bot-deviceActions.js.map +1 -0
  251. package/lib-es/test/bot-specs.d.ts +7 -0
  252. package/lib-es/test/bot-specs.d.ts.map +1 -0
  253. package/lib-es/test/bot-specs.js +149 -0
  254. package/lib-es/test/bot-specs.js.map +1 -0
  255. package/lib-es/test/bridgeDatasetTest.d.ts +5 -0
  256. package/lib-es/test/bridgeDatasetTest.d.ts.map +1 -0
  257. package/lib-es/test/bridgeDatasetTest.js +93 -0
  258. package/lib-es/test/bridgeDatasetTest.js.map +1 -0
  259. package/lib-es/test/cli.d.ts +78 -0
  260. package/lib-es/test/cli.d.ts.map +1 -0
  261. package/lib-es/test/cli.js +91 -0
  262. package/lib-es/test/cli.js.map +1 -0
  263. package/lib-es/test/index.d.ts +2 -0
  264. package/lib-es/test/index.d.ts.map +1 -0
  265. package/lib-es/test/index.js +2 -0
  266. package/lib-es/test/index.js.map +1 -0
  267. package/lib-es/types/errors.d.ts +4 -0
  268. package/lib-es/types/errors.d.ts.map +1 -0
  269. package/lib-es/types/errors.js +3 -0
  270. package/lib-es/types/errors.js.map +1 -0
  271. package/lib-es/types/index.d.ts +4 -0
  272. package/lib-es/types/index.d.ts.map +1 -0
  273. package/lib-es/types/index.js +4 -0
  274. package/lib-es/types/index.js.map +1 -0
  275. package/lib-es/types/model.d.ts +92 -0
  276. package/lib-es/types/model.d.ts.map +1 -0
  277. package/lib-es/types/model.fixture.d.ts +5 -0
  278. package/lib-es/types/model.fixture.d.ts.map +1 -0
  279. package/lib-es/types/model.fixture.js +76 -0
  280. package/lib-es/types/model.fixture.js.map +1 -0
  281. package/lib-es/types/model.js +4 -0
  282. package/lib-es/types/model.js.map +1 -0
  283. package/lib-es/types/signer.d.ts +37 -0
  284. package/lib-es/types/signer.d.ts.map +1 -0
  285. package/lib-es/types/signer.js +2 -0
  286. package/lib-es/types/signer.js.map +1 -0
  287. package/package.json +116 -0
  288. package/src/README.md +29 -0
  289. package/src/api/bakers.integration.test.ts +61 -0
  290. package/src/api/bakers.test.ts +140 -0
  291. package/src/api/bakers.ts +139 -0
  292. package/src/api/bakers.whitelist-default.ts +33 -0
  293. package/src/api/index.ts +2 -0
  294. package/src/api/tzkt.ts +112 -0
  295. package/src/bridge/broadcast.test.ts +30 -0
  296. package/src/bridge/broadcast.ts +18 -0
  297. package/src/bridge/createTransaction.ts +18 -0
  298. package/src/bridge/deviceTransactionConfig.ts +74 -0
  299. package/src/bridge/estimateMaxSpendable.ts +32 -0
  300. package/src/bridge/getAccountShape.test.ts +22 -0
  301. package/src/bridge/getAccountShape.ts +289 -0
  302. package/src/bridge/index.ts +65 -0
  303. package/src/bridge/preload.ts +18 -0
  304. package/src/bridge/prepareTransaction.ts +160 -0
  305. package/src/bridge/serialization.ts +27 -0
  306. package/src/bridge/signOperation.test.ts +211 -0
  307. package/src/bridge/signOperation.ts +213 -0
  308. package/src/bridge/transaction.ts +94 -0
  309. package/src/bridge/transactionStatus.ts +130 -0
  310. package/src/datasets/tezos.scanAccounts.1.ts +35 -0
  311. package/src/index.ts +3 -0
  312. package/src/signer/getAddress.ts +13 -0
  313. package/src/signer/index.ts +7 -0
  314. package/src/test/bot-deviceActions.ts +79 -0
  315. package/src/test/bot-specs.ts +152 -0
  316. package/src/test/bridgeDatasetTest.ts +132 -0
  317. package/src/test/cli.ts +137 -0
  318. package/src/test/index.ts +1 -0
  319. package/src/types/errors.ts +5 -0
  320. package/src/types/index.ts +3 -0
  321. package/src/types/model.fixture.ts +89 -0
  322. package/src/types/model.ts +123 -0
  323. package/src/types/signer.ts +48 -0
  324. package/tsconfig.json +13 -0
  325. 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,3 @@
1
+ export * from "./types";
2
+
3
+ export { createBridges } from "./bridge/index";
@@ -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,7 @@
1
+ /**
2
+ * This directory is the home for all types and logic based on Ledgers signer.
3
+ */
4
+
5
+ import getAddress from "./getAddress";
6
+
7
+ 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
+ };
@@ -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,5 @@
1
+ import { createCustomErrorClass } from "@ledgerhq/errors";
2
+
3
+ export const InvalidAddressBecauseAlreadyDelegated = createCustomErrorClass(
4
+ "InvalidAddressBecauseAlreadyDelegated",
5
+ );
@@ -0,0 +1,3 @@
1
+ export * from "./errors";
2
+ export * from "./model";
3
+ export * from "./signer";
@@ -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
+ }