@ledgerhq/live-common 21.21.3 → 21.23.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 (266) hide show
  1. package/lib/account/formatters.d.ts.map +1 -1
  2. package/lib/account/formatters.js +1 -0
  3. package/lib/account/formatters.js.map +1 -1
  4. package/lib/account/support.d.ts.map +1 -1
  5. package/lib/account/support.js +1 -0
  6. package/lib/account/support.js.map +1 -1
  7. package/lib/apps/polyfill.d.ts.map +1 -1
  8. package/lib/apps/polyfill.js +1 -0
  9. package/lib/apps/polyfill.js.map +1 -1
  10. package/lib/bot/engine.js +1 -1
  11. package/lib/bot/engine.js.map +1 -1
  12. package/lib/bot/specs.d.ts +1 -0
  13. package/lib/bot/specs.d.ts.map +1 -1
  14. package/lib/bot/specs.js +3 -1
  15. package/lib/bot/specs.js.map +1 -1
  16. package/lib/data/icons/react/sol.js +4 -2
  17. package/lib/data/icons/react/sol.js.map +1 -1
  18. package/lib/data/icons/reactNative/sol.js +4 -2
  19. package/lib/data/icons/reactNative/sol.js.map +1 -1
  20. package/lib/derivation.d.ts.map +1 -1
  21. package/lib/derivation.js +0 -3
  22. package/lib/derivation.js.map +1 -1
  23. package/lib/env.d.ts +5 -10
  24. package/lib/env.d.ts.map +1 -1
  25. package/lib/env.js +1 -6
  26. package/lib/env.js.map +1 -1
  27. package/lib/env.react.d.ts +1 -1
  28. package/lib/env.react.d.ts.map +1 -1
  29. package/lib/families/algorand/account.d.ts.map +1 -1
  30. package/lib/families/algorand/account.js +0 -4
  31. package/lib/families/algorand/account.js.map +1 -1
  32. package/lib/families/algorand/api/algodv2.d.ts +5 -0
  33. package/lib/families/algorand/api/algodv2.d.ts.map +1 -0
  34. package/lib/families/algorand/api/algodv2.js +118 -0
  35. package/lib/families/algorand/api/algodv2.js.map +1 -0
  36. package/lib/families/algorand/api/algodv2.types.d.ts +24 -0
  37. package/lib/families/algorand/api/algodv2.types.d.ts.map +1 -0
  38. package/lib/families/algorand/api/algodv2.types.js +3 -0
  39. package/lib/families/algorand/api/algodv2.types.js.map +1 -0
  40. package/lib/families/algorand/api/index.d.ts +5 -0
  41. package/lib/families/algorand/api/index.d.ts.map +1 -0
  42. package/lib/families/algorand/api/index.js +17 -0
  43. package/lib/families/algorand/api/index.js.map +1 -0
  44. package/lib/families/algorand/api/indexer.d.ts +3 -0
  45. package/lib/families/algorand/api/indexer.d.ts.map +1 -0
  46. package/lib/families/algorand/api/indexer.js +134 -0
  47. package/lib/families/algorand/api/indexer.js.map +1 -0
  48. package/lib/families/algorand/api/indexer.types.d.ts +35 -0
  49. package/lib/families/algorand/api/indexer.types.d.ts.map +1 -0
  50. package/lib/families/algorand/api/indexer.types.js +10 -0
  51. package/lib/families/algorand/api/indexer.types.js.map +1 -0
  52. package/lib/families/algorand/bridge/js.d.ts +8 -0
  53. package/lib/families/algorand/bridge/js.d.ts.map +1 -0
  54. package/lib/families/algorand/bridge/js.js +85 -0
  55. package/lib/families/algorand/bridge/js.js.map +1 -0
  56. package/lib/families/algorand/bridge/libcore.d.ts +3 -3
  57. package/lib/families/algorand/bridge/libcore.d.ts.map +1 -1
  58. package/lib/families/algorand/bridge/libcore.js.map +1 -1
  59. package/lib/families/algorand/bridge/mock.d.ts +2 -2
  60. package/lib/families/algorand/bridge/mock.d.ts.map +1 -1
  61. package/lib/families/algorand/bridge/mock.js.map +1 -1
  62. package/lib/families/algorand/buildTransaction.d.ts +8 -0
  63. package/lib/families/algorand/buildTransaction.d.ts.map +1 -0
  64. package/lib/families/algorand/buildTransaction.js +101 -0
  65. package/lib/families/algorand/buildTransaction.js.map +1 -0
  66. package/lib/families/algorand/cli-transaction.js +1 -1
  67. package/lib/families/algorand/cli-transaction.js.map +1 -1
  68. package/lib/families/algorand/deviceTransactionConfig.d.ts +2 -2
  69. package/lib/families/algorand/deviceTransactionConfig.d.ts.map +1 -1
  70. package/lib/families/algorand/deviceTransactionConfig.js +0 -13
  71. package/lib/families/algorand/deviceTransactionConfig.js.map +1 -1
  72. package/lib/families/algorand/hw-getAddress.d.ts.map +1 -1
  73. package/lib/families/algorand/hw-getAddress.js +2 -24
  74. package/lib/families/algorand/hw-getAddress.js.map +1 -1
  75. package/lib/families/algorand/js-broadcast.d.ts +9 -0
  76. package/lib/families/algorand/js-broadcast.d.ts.map +1 -0
  77. package/lib/families/algorand/js-broadcast.js +63 -0
  78. package/lib/families/algorand/js-broadcast.js.map +1 -0
  79. package/lib/families/algorand/js-estimateMaxSpendable.d.ts +9 -0
  80. package/lib/families/algorand/js-estimateMaxSpendable.d.ts.map +1 -0
  81. package/lib/families/algorand/js-estimateMaxSpendable.js +89 -0
  82. package/lib/families/algorand/js-estimateMaxSpendable.js.map +1 -0
  83. package/lib/families/algorand/js-getFeesForTransaction.d.ts +5 -0
  84. package/lib/families/algorand/js-getFeesForTransaction.d.ts.map +1 -0
  85. package/lib/families/algorand/js-getFeesForTransaction.js +69 -0
  86. package/lib/families/algorand/js-getFeesForTransaction.js.map +1 -0
  87. package/lib/families/algorand/js-getTransactionStatus.d.ts +11 -0
  88. package/lib/families/algorand/js-getTransactionStatus.d.ts.map +1 -0
  89. package/lib/families/algorand/js-getTransactionStatus.js +201 -0
  90. package/lib/families/algorand/js-getTransactionStatus.js.map +1 -0
  91. package/lib/families/algorand/js-prepareTransaction.d.ts +5 -0
  92. package/lib/families/algorand/js-prepareTransaction.d.ts.map +1 -0
  93. package/lib/families/algorand/js-prepareTransaction.js +101 -0
  94. package/lib/families/algorand/js-prepareTransaction.js.map +1 -0
  95. package/lib/families/algorand/js-signOperation.d.ts +10 -0
  96. package/lib/families/algorand/js-signOperation.d.ts.map +1 -0
  97. package/lib/families/algorand/js-signOperation.js +164 -0
  98. package/lib/families/algorand/js-signOperation.js.map +1 -0
  99. package/lib/families/algorand/js-synchronization.d.ts +10 -0
  100. package/lib/families/algorand/js-synchronization.d.ts.map +1 -0
  101. package/lib/families/algorand/js-synchronization.js +411 -0
  102. package/lib/families/algorand/js-synchronization.js.map +1 -0
  103. package/lib/families/algorand/libcore-buildTransaction.d.ts +2 -2
  104. package/lib/families/algorand/libcore-buildTransaction.d.ts.map +1 -1
  105. package/lib/families/algorand/libcore-getFeesForTransaction.d.ts +4 -4
  106. package/lib/families/algorand/libcore-getFeesForTransaction.d.ts.map +1 -1
  107. package/lib/families/algorand/libcore-getFeesForTransaction.js +2 -2
  108. package/lib/families/algorand/libcore-getFeesForTransaction.js.map +1 -1
  109. package/lib/families/algorand/libcore-postBuildAccount.d.ts.map +1 -1
  110. package/lib/families/algorand/libcore-postBuildAccount.js +5 -11
  111. package/lib/families/algorand/libcore-postBuildAccount.js.map +1 -1
  112. package/lib/families/algorand/libcore-signOperation.d.ts +2 -2
  113. package/lib/families/algorand/libcore-signOperation.d.ts.map +1 -1
  114. package/lib/families/algorand/libcore-signOperation.js.map +1 -1
  115. package/lib/families/algorand/logic.d.ts +10 -0
  116. package/lib/families/algorand/logic.d.ts.map +1 -1
  117. package/lib/families/algorand/logic.js +79 -1
  118. package/lib/families/algorand/logic.js.map +1 -1
  119. package/lib/families/algorand/mock.d.ts.map +1 -1
  120. package/lib/families/algorand/mock.js +4 -11
  121. package/lib/families/algorand/mock.js.map +1 -1
  122. package/lib/families/algorand/serialization.js +4 -4
  123. package/lib/families/algorand/serialization.js.map +1 -1
  124. package/lib/families/algorand/specs.d.ts +2 -2
  125. package/lib/families/algorand/specs.d.ts.map +1 -1
  126. package/lib/families/algorand/specs.js +8 -16
  127. package/lib/families/algorand/specs.js.map +1 -1
  128. package/lib/families/algorand/speculos-deviceActions.d.ts +2 -2
  129. package/lib/families/algorand/speculos-deviceActions.d.ts.map +1 -1
  130. package/lib/families/algorand/speculos-deviceActions.js +4 -0
  131. package/lib/families/algorand/speculos-deviceActions.js.map +1 -1
  132. package/lib/families/algorand/test-dataset.d.ts +2 -2
  133. package/lib/families/algorand/test-dataset.d.ts.map +1 -1
  134. package/lib/families/algorand/test-dataset.js +1 -2
  135. package/lib/families/algorand/test-dataset.js.map +1 -1
  136. package/lib/families/algorand/tokens.d.ts.map +1 -1
  137. package/lib/families/algorand/tokens.js.map +1 -1
  138. package/lib/families/algorand/transaction.d.ts +5 -5
  139. package/lib/families/algorand/transaction.d.ts.map +1 -1
  140. package/lib/families/algorand/transaction.js.map +1 -1
  141. package/lib/families/algorand/types.d.ts +7 -5
  142. package/lib/families/algorand/types.d.ts.map +1 -1
  143. package/lib/families/algorand/types.js.map +1 -1
  144. package/lib/families/bitcoin/js-prepareTransaction.d.ts.map +1 -1
  145. package/lib/families/bitcoin/js-prepareTransaction.js +3 -2
  146. package/lib/families/bitcoin/js-prepareTransaction.js.map +1 -1
  147. package/lib/families/bitcoin/js-synchronisation.d.ts.map +1 -1
  148. package/lib/families/bitcoin/js-synchronisation.js +3 -2
  149. package/lib/families/bitcoin/js-synchronisation.js.map +1 -1
  150. package/lib/families/bitcoin/wallet-btc/crypto/decred.d.ts.map +1 -1
  151. package/lib/families/bitcoin/wallet-btc/crypto/decred.js +3 -4
  152. package/lib/families/bitcoin/wallet-btc/crypto/decred.js.map +1 -1
  153. package/lib/families/tezos/bridge/js.d.ts.map +1 -1
  154. package/lib/families/tezos/bridge/js.js +90 -50
  155. package/lib/families/tezos/bridge/js.js.map +1 -1
  156. package/lib/families/tezos/bridge/libcore.d.ts.map +1 -1
  157. package/lib/families/tezos/bridge/libcore.js +2 -1
  158. package/lib/families/tezos/bridge/libcore.js.map +1 -1
  159. package/lib/families/tezos/bridge/mock.d.ts.map +1 -1
  160. package/lib/families/tezos/bridge/mock.js +2 -1
  161. package/lib/families/tezos/bridge/mock.js.map +1 -1
  162. package/lib/families/tezos/signOperation.d.ts.map +1 -1
  163. package/lib/families/tezos/signOperation.js +28 -19
  164. package/lib/families/tezos/signOperation.js.map +1 -1
  165. package/lib/families/tezos/specs.d.ts.map +1 -1
  166. package/lib/families/tezos/specs.js +8 -4
  167. package/lib/families/tezos/specs.js.map +1 -1
  168. package/lib/families/tezos/speculos-deviceActions.js +6 -7
  169. package/lib/families/tezos/speculos-deviceActions.js.map +1 -1
  170. package/lib/families/tezos/synchronisation.d.ts.map +1 -1
  171. package/lib/families/tezos/synchronisation.js +7 -4
  172. package/lib/families/tezos/synchronisation.js.map +1 -1
  173. package/lib/families/tezos/synchronisation.test.d.ts.map +1 -1
  174. package/lib/families/tezos/synchronisation.test.js +0 -3
  175. package/lib/families/tezos/synchronisation.test.js.map +1 -1
  176. package/lib/families/tezos/test-dataset.d.ts +2 -2
  177. package/lib/families/tezos/test-dataset.d.ts.map +1 -1
  178. package/lib/families/tezos/test-dataset.js +45 -319
  179. package/lib/families/tezos/test-dataset.js.map +1 -1
  180. package/lib/families/tezos/transaction.d.ts +2 -2
  181. package/lib/families/tezos/transaction.d.ts.map +1 -1
  182. package/lib/families/tezos/transaction.js +4 -4
  183. package/lib/families/tezos/transaction.js.map +1 -1
  184. package/lib/families/tezos/types.d.ts +2 -0
  185. package/lib/families/tezos/types.d.ts.map +1 -1
  186. package/lib/families/tezos/types.js.map +1 -1
  187. package/lib/generated/bridge/js.d.ts +4 -0
  188. package/lib/generated/bridge/js.d.ts.map +1 -1
  189. package/lib/generated/bridge/js.js +26 -24
  190. package/lib/generated/bridge/js.js.map +1 -1
  191. package/lib/generated/bridge/libcore.d.ts +1 -1
  192. package/lib/generated/bridge/mock.d.ts +1 -1
  193. package/lib/generated/specs.d.ts +1 -1
  194. package/lib/generated/speculos-deviceActions.d.ts +1 -1
  195. package/lib/generated/test-dataset.d.ts +1 -1
  196. package/lib/generated/transaction.d.ts +4 -4
  197. package/lib/libcore/buildAccount/index.d.ts.map +1 -1
  198. package/lib/libcore/buildAccount/index.js +0 -1
  199. package/lib/libcore/buildAccount/index.js.map +1 -1
  200. package/lib/mock/account.js +21 -21
  201. package/lib/mock/account.js.map +1 -1
  202. package/lib/types/operation.d.ts +1 -1
  203. package/lib/types/operation.d.ts.map +1 -1
  204. package/package.json +10 -9
  205. package/src/__tests__/__snapshots__/all.libcore.ts.snap +0 -107
  206. package/src/account/formatters.ts +1 -0
  207. package/src/account/support.ts +1 -0
  208. package/src/apps/polyfill.ts +1 -0
  209. package/src/bot/engine.ts +1 -1
  210. package/src/bot/specs.ts +7 -1
  211. package/src/data/icons/react/sol.tsx +1 -1
  212. package/src/data/icons/reactNative/sol.tsx +1 -1
  213. package/src/data/icons/svg/SOL.svg +1 -3
  214. package/src/derivation.ts +0 -2
  215. package/src/env.ts +1 -6
  216. package/src/families/algorand/account.ts +0 -9
  217. package/src/families/algorand/api/algodv2.ts +68 -0
  218. package/src/families/algorand/api/algodv2.types.ts +27 -0
  219. package/src/families/algorand/api/index.ts +4 -0
  220. package/src/families/algorand/api/indexer.ts +99 -0
  221. package/src/families/algorand/api/indexer.types.ts +41 -0
  222. package/src/families/algorand/bridge/js.ts +46 -0
  223. package/src/families/algorand/bridge/libcore.ts +4 -4
  224. package/src/families/algorand/bridge/mock.ts +3 -3
  225. package/src/families/algorand/buildTransaction.ts +100 -0
  226. package/src/families/algorand/cli-transaction.ts +1 -1
  227. package/src/families/algorand/deviceTransactionConfig.ts +2 -16
  228. package/src/families/algorand/hw-getAddress.ts +1 -10
  229. package/src/families/algorand/js-broadcast.ts +17 -0
  230. package/src/families/algorand/js-estimateMaxSpendable.ts +51 -0
  231. package/src/families/algorand/js-getFeesForTransaction.ts +25 -0
  232. package/src/families/algorand/js-getTransactionStatus.ts +178 -0
  233. package/src/families/algorand/js-prepareTransaction.ts +42 -0
  234. package/src/families/algorand/js-signOperation.ts +145 -0
  235. package/src/families/algorand/js-synchronization.ts +433 -0
  236. package/src/families/algorand/libcore-buildTransaction.ts +2 -2
  237. package/src/families/algorand/libcore-getFeesForTransaction.ts +4 -4
  238. package/src/families/algorand/libcore-postBuildAccount.ts +2 -7
  239. package/src/families/algorand/libcore-signOperation.ts +2 -2
  240. package/src/families/algorand/logic.ts +47 -0
  241. package/src/families/algorand/mock.ts +2 -12
  242. package/src/families/algorand/serialization.ts +4 -4
  243. package/src/families/algorand/specs.ts +16 -22
  244. package/src/families/algorand/speculos-deviceActions.ts +87 -82
  245. package/src/families/algorand/test-dataset.ts +5 -6
  246. package/src/families/algorand/tokens.ts +1 -0
  247. package/src/families/algorand/transaction.ts +13 -4
  248. package/src/families/algorand/types.ts +10 -5
  249. package/src/families/bitcoin/js-prepareTransaction.ts +3 -2
  250. package/src/families/bitcoin/js-synchronisation.ts +3 -2
  251. package/src/families/bitcoin/wallet-btc/crypto/decred.ts +3 -4
  252. package/src/families/tezos/bridge/js.ts +77 -36
  253. package/src/families/tezos/bridge/libcore.ts +1 -0
  254. package/src/families/tezos/bridge/mock.ts +1 -0
  255. package/src/families/tezos/signOperation.ts +19 -8
  256. package/src/families/tezos/specs.ts +16 -5
  257. package/src/families/tezos/speculos-deviceActions.ts +5 -5
  258. package/src/families/tezos/synchronisation.test.ts +0 -3
  259. package/src/families/tezos/synchronisation.ts +6 -3
  260. package/src/families/tezos/test-dataset.ts +33 -363
  261. package/src/families/tezos/transaction.ts +7 -1
  262. package/src/families/tezos/types.ts +2 -0
  263. package/src/generated/bridge/js.ts +3 -0
  264. package/src/libcore/buildAccount/index.ts +1 -2
  265. package/src/mock/account.ts +27 -27
  266. package/src/types/operation.ts +9 -4
@@ -64,6 +64,7 @@ const createTransaction = (): Transaction => ({
64
64
  networkInfo: null,
65
65
  useAllAmount: false,
66
66
  taquitoError: null,
67
+ estimatedFees: null,
67
68
  });
68
69
 
69
70
  const updateTransaction = (t, patch) => ({ ...t, ...patch });
@@ -38,40 +38,51 @@ export const signOperation = ({
38
38
  );
39
39
  tezos.setProvider({ signer: ledgerSigner });
40
40
 
41
+ // disable the broadcast because we want to do it in a second phase (broadcast hook)
41
42
  // eslint-disable-next-line @typescript-eslint/ban-ts-comment
42
43
  // @ts-ignore
43
- tezos.contract.context.injector.inject = async () => ""; // disable broadcast
44
+ tezos.contract.context.injector.inject = async () => "";
44
45
 
45
46
  o.next({ type: "device-signature-requested" });
46
47
 
48
+ let type = "OUT";
49
+
47
50
  let res, signature, opbytes;
51
+ const params = {
52
+ fee: transaction.fees?.toNumber() || 0,
53
+ storageLimit: transaction.storageLimit?.toNumber() || 0,
54
+ gasLimit: transaction.gasLimit?.toNumber() || 0,
55
+ };
48
56
  switch (transaction.mode) {
49
57
  case "send":
50
58
  res = await tezos.contract.transfer({
59
+ mutez: true,
51
60
  to: transaction.recipient,
52
- amount: transaction.amount.div(10 ** 6).toNumber(),
53
- fee: transaction.fees?.toNumber() || 0,
54
- storageLimit: transaction.storageLimit?.toNumber() || 0,
55
- gasLimit: transaction.gasLimit?.toNumber() || 0,
61
+ amount: transaction.amount.toNumber(),
62
+ ...params,
56
63
  });
57
64
  signature = res.raw.opOb.signature;
58
65
  opbytes = res.raw.opbytes;
59
66
  break;
60
67
  case "delegate":
61
68
  res = await tezos.contract.setDelegate({
69
+ ...params,
62
70
  source: freshAddress,
63
71
  delegate: transaction.recipient,
64
72
  });
65
73
  opbytes = res.raw.opbytes;
74
+ type = "DELEGATE";
66
75
  break;
67
76
  case "undelegate":
68
77
  res = await tezos.contract.setDelegate({
78
+ ...params,
69
79
  source: freshAddress,
70
80
  });
71
81
  opbytes = res.raw.opbytes;
82
+ type = "UNDELEGATE";
72
83
  break;
73
84
  default:
74
- throw "not supported";
85
+ throw new Error("not supported");
75
86
  }
76
87
 
77
88
  if (cancelled) {
@@ -88,9 +99,9 @@ export const signOperation = ({
88
99
 
89
100
  // currently, all mode are always at least one OUT tx on ETH parent
90
101
  const operation = {
91
- id: `${accountId}-${txHash}-OUT`,
102
+ id: `${accountId}-${txHash}-${type}`,
92
103
  hash: txHash,
93
- type: "OUT",
104
+ type,
94
105
  value: transaction.amount,
95
106
  fee: fees,
96
107
  extra: {
@@ -6,7 +6,7 @@ import { getCryptoCurrencyById, parseCurrencyUnit } from "../../currencies";
6
6
  import { pickSiblings } from "../../bot/specs";
7
7
  import type { AppSpec } from "../../bot/types";
8
8
  import { DeviceModelId } from "@ledgerhq/devices";
9
- import { getAccountDelegationSync } from "./bakers";
9
+ import { getAccountDelegationSync, isAccountDelegating } from "./bakers";
10
10
  import whitelist from "./bakers.whitelist-default";
11
11
 
12
12
  const maxAccount = 12;
@@ -31,10 +31,11 @@ const tezos: AppSpec<Transaction> = {
31
31
  model: DeviceModelId.nanoS,
32
32
  appName: "TezosWallet",
33
33
  },
34
+ testTimeout: 2 * 60 * 1000,
34
35
  transactionCheck: ({ maxSpendable }) => {
35
36
  invariant(
36
37
  maxSpendable.gt(
37
- parseCurrencyUnit(getCryptoCurrencyById("tezos").units[0], "0.1")
38
+ parseCurrencyUnit(getCryptoCurrencyById("tezos").units[0], "0.02")
38
39
  ),
39
40
  "balance is too low"
40
41
  );
@@ -69,9 +70,13 @@ const tezos: AppSpec<Transaction> = {
69
70
  },
70
71
  },
71
72
  {
72
- name: "send max",
73
+ name: "send max (non delegating)",
73
74
  maxRun: 3,
74
75
  transaction: ({ account, siblings, bridge }) => {
76
+ invariant(
77
+ !isAccountDelegating(account),
78
+ "account must not be delegating"
79
+ );
75
80
  const sibling = pickSiblings(siblings, maxAccount);
76
81
  const recipient = sibling.freshAddress;
77
82
  return {
@@ -85,7 +90,10 @@ const tezos: AppSpec<Transaction> = {
85
90
  maxRun: 1,
86
91
  transaction: ({ account, bridge }) => {
87
92
  expectUnrevealed(account);
88
- const recipient = sample(whitelist);
93
+ const d = getAccountDelegationSync(account);
94
+ const recipient = sample(
95
+ d ? whitelist.filter((w) => w !== d.address) : whitelist
96
+ );
89
97
  return {
90
98
  transaction: bridge.createTransaction(account),
91
99
  updates: [{ recipient, mode: "delegate" }],
@@ -97,7 +105,10 @@ const tezos: AppSpec<Transaction> = {
97
105
  maxRun: 1,
98
106
  transaction: ({ account, bridge }) => {
99
107
  expectRevealed(account);
100
- const recipient = sample(whitelist);
108
+ const d = getAccountDelegationSync(account);
109
+ const recipient = sample(
110
+ d ? whitelist.filter((w) => w !== d.address) : whitelist
111
+ );
101
112
  return {
102
113
  transaction: bridge.createTransaction(account),
103
114
  updates: [{ recipient, mode: "delegate" }],
@@ -15,13 +15,13 @@ const acceptTransaction: DeviceAction<Transaction, any> = deviceActionFlow({
15
15
  button: "Rr",
16
16
  },
17
17
  {
18
+ title: "Custom Delegate",
19
+ button: "Rr",
20
+ },
21
+ {
22
+ // device sometimes know the text of a given delegator, we're not validating the actual text
18
23
  title: "Delegate",
19
24
  button: "Rr",
20
- expectedValue: ({ transaction }) => {
21
- return transaction.mode === "undelegate"
22
- ? "None"
23
- : transaction.recipient;
24
- },
25
25
  },
26
26
  {
27
27
  title: "Delegate Name",
@@ -9,8 +9,6 @@ import { makeSync } from "../../bridge/jsHelpers";
9
9
  import { getAccountShape } from "./synchronisation";
10
10
 
11
11
  const accounts = [
12
- // "tz1cf8diKsP1WoeucTQm1BcVfdyrmaBnL4nC", // FIXME
13
- // "tz1ZshTmtorFVkcZ7CpceCAxCn7HBJqTfmpk", // FIXME
14
12
  "tz1ZL36Xw6LJ9RK6tb7QW85o7SVYfFKSMw8c",
15
13
  "tz1VacAyLcnHU3pEY3VNNK45F1CvVyTYXA3z",
16
14
  "tz1hpWkvAVVgftPy4CW8rD3u6tdVd8g1RU58",
@@ -24,7 +22,6 @@ const accounts = [
24
22
  "tz1PTxfn1fge2tJwGGpW9zNuYf6BseM3GJXt",
25
23
  "tz1SBHto1BasGvxojr48r5PFiGb1Wq4cynGY",
26
24
  "tz1fAfYNSkgci3ko2xikDtYtcSf1X1YdAKoK",
27
- "tz1hobi4RsAeswm9JA7mHB96vqc1eAWRzxDc",
28
25
  ];
29
26
 
30
27
  jest.setTimeout(30 * 1000);
@@ -75,6 +75,11 @@ export const getAccountShape: GetAccountShape = async (infoInput) => {
75
75
  id: accountId,
76
76
  blockHeight,
77
77
  lastSyncDate: new Date(),
78
+ tezosResources: {
79
+ revealed: false,
80
+ counter: 0,
81
+ publicKey: "",
82
+ },
78
83
  };
79
84
  }
80
85
  invariant(
@@ -232,9 +237,7 @@ const txToOp =
232
237
  blockHash,
233
238
  accountId,
234
239
  date: new Date(timestamp),
235
- extra: {
236
- id,
237
- },
240
+ extra: { id },
238
241
  hasFailed,
239
242
  };
240
243
  };
@@ -1,431 +1,101 @@
1
- import invariant from "invariant";
2
- import {
3
- NotEnoughBalance,
4
- NotEnoughBalanceInParentAccount,
5
- InvalidAddressBecauseDestinationIsAlsoSource,
6
- RecommendUndelegation,
7
- NotSupportedLegacyAddress,
8
- } from "@ledgerhq/errors";
9
- import { BigNumber } from "bignumber.js";
10
- import { fromTransactionRaw } from "./transaction";
11
1
  import type { DatasetTest } from "../../types";
12
2
  import type { Transaction } from "./types";
13
- import tezosScanAccounts1 from "./datasets/tezos.scanAccounts.1";
3
+
4
+ // TODO restore
5
+ // import tezosScanAccounts1 from "./datasets/tezos.scanAccounts.1";
6
+
7
+ // FIXME these accounts no longer reflect their expected states..
14
8
  export const accountTZrevealedDelegating = makeAccount(
15
9
  "TZrevealedDelegating",
16
- "02389ffd73423626894cb151416e51c72ec285376673daf83545eb5edb45b261ce",
10
+ "tz1boBHAVpwcvKkNFAQHYr7mjxAz1PpVgKq7",
17
11
  "tezbox"
18
12
  );
13
+ /*
19
14
  const accountTZwithKT = makeAccount(
20
15
  "TZwithKT",
21
- "0294e8344ae6df2d3123fa100b5abd40cee339c67838b1c34c4f243cc582f4d2d8",
16
+ "tz1T72nyqnJWwxad6RQnh7imKQz7mzToamWd",
22
17
  "tezbox"
23
18
  );
19
+ */
24
20
  const accountTZnew = makeAccount(
25
21
  "TZnew",
26
- "02a9ae8b0ff5f9a43565793ad78e10db6f12177d904d208ada591b8a5b9999e3fd",
22
+ "tz1VSichevvJSNkSSntgwKDKikWNB6iqNJii",
27
23
  "tezbox"
28
24
  );
29
25
  const accountTZnotRevealed = makeAccount(
30
26
  "TZnotRevealed",
31
- "020162dc75ad3c2b6e097d15a1513033c60d8a033f2312ff5a6ead812228d9d653",
27
+ "tz1PWFt4Ym6HedY78MgUP2kVDtSampGwprs5",
32
28
  "tezosbip44h"
33
29
  );
34
30
  const accountTZRevealedNoDelegate = makeAccount(
35
31
  "TZRevealedNoDelegate",
36
- "029bfe70b3e94ff23623f6c42f6e081a9ca8cc78f74b0d8da58f0d4cdc41c33c1a",
32
+ "tz1YkAjh5mm5gJ5u3VbFLEtpAG7cFo7PfCux",
37
33
  "tezosbip44h"
38
34
  );
35
+ /*
39
36
  const accountTZemptyWithKT = makeAccount(
40
37
  "TZemptyWithKT",
41
- "020c38103f932f446dc4c09ac946e9643386609453e77716d3df45f1149aa52072",
38
+ "tz1TeawWFnUmeP1qQLf4JWe5D7LaNp1qxgMW",
42
39
  "tezbox"
43
40
  );
44
- const addressAccountTZrevealedDelegating =
45
- "tz1boBHAVpwcvKkNFAQHYr7mjxAz1PpVgKq7";
46
- const addressTZregular = "tz1T72nyqnJWwxad6RQnh7imKQz7mzToamWd";
47
- const addressTZnew = "tz1VSichevvJSNkSSntgwKDKikWNB6iqNJii";
48
- const addressKT = "KT1V99vDN5DHNpU9swVXg1cAT2ji981cccXC";
49
- const addressDelegator = "tz1WCd2jm4uSt4vntk4vSuUWoZQGhLcDuR9q";
50
-
51
- const reservedAmountForStorageLimit = (storageLimit) =>
52
- new BigNumber(storageLimit || 0).times("1000");
41
+ */
53
42
 
54
43
  const dataset: DatasetTest<Transaction> = {
55
- implementations: ["libcore"],
56
- // @ts-expect-error we disable the test by giving an empty object
57
- currencies: {} || {
44
+ implementations: ["js"],
45
+ currencies: {
58
46
  tezos: {
59
47
  FIXME_ignoreOperationFields: ["blockHeight"],
60
- scanAccounts: [tezosScanAccounts1],
48
+ // scanAccounts: [tezosScanAccounts1],
49
+ scanAccounts: [],
61
50
  accounts: [
62
51
  {
63
- FIXME_tests: [
64
- "balance is sum of ops", // https://ledgerhq.atlassian.net/browse/LLC-591
65
- ],
66
52
  raw: accountTZrevealedDelegating,
67
- transactions: [
68
- {
69
- name: "send max to new account (explicit)",
70
- transaction: fromTransactionRaw({
71
- amount: "0",
72
- recipient: addressTZnew,
73
- useAllAmount: true,
74
- family: "tezos",
75
- mode: "send",
76
- networkInfo: {
77
- family: "tezos",
78
- fees: "3075",
79
- },
80
- fees: "3075",
81
- gasLimit: "10600",
82
- storageLimit: "300",
83
- taquitoError: null,
84
- }),
85
- expectedStatus: (account) => ({
86
- errors: {},
87
- warnings: {
88
- amount: new RecommendUndelegation(),
89
- },
90
- estimatedFees: new BigNumber("3075"),
91
- amount: account.balance
92
- .minus(reservedAmountForStorageLimit("300"))
93
- .minus("3075"),
94
- totalSpent: account.balance,
95
- }),
96
- },
97
- {
98
- name: "overflow send to new account",
99
- transaction: (t, account) => ({
100
- ...t,
101
- amount: account.balance.minus(t.fees || 0).minus("1000"),
102
- recipient: addressTZnew,
103
- }),
104
- expectedStatus: {
105
- errors: {
106
- amount: new NotEnoughBalance(),
107
- },
108
- warnings: {},
109
- },
110
- },
111
- {
112
- name: "send max to new account (dynamic)",
113
- transaction: (t) => ({
114
- ...t,
115
- recipient: addressTZnew,
116
- useAllAmount: true,
117
- }),
118
- expectedStatus: (account, { storageLimit, fees }) => (
119
- invariant(fees, "fees are required"),
120
- {
121
- errors: {},
122
- warnings: {
123
- amount: new RecommendUndelegation(),
124
- },
125
- estimatedFees: fees,
126
- amount: account.balance
127
- .minus(reservedAmountForStorageLimit(storageLimit))
128
- .minus(fees as BigNumber),
129
- totalSpent: account.balance,
130
- }
131
- ),
132
- },
133
- {
134
- name: "send max to existing account",
135
- transaction: (t) => ({
136
- ...t,
137
- recipient: addressTZregular,
138
- useAllAmount: true,
139
- }),
140
- expectedStatus: (account, { fees }) => (
141
- invariant(fees, "fees are required"),
142
- {
143
- errors: {},
144
- warnings: {
145
- amount: new RecommendUndelegation(),
146
- },
147
- estimatedFees: fees,
148
- amount: account.balance.minus(fees as BigNumber),
149
- totalSpent: account.balance,
150
- }
151
- ),
152
- },
153
- {
154
- name: "self tx forbidden",
155
- transaction: (t) => ({
156
- ...t,
157
- recipient: addressAccountTZrevealedDelegating,
158
- amount: new BigNumber(0.1),
159
- }),
160
- expectedStatus: {
161
- errors: {
162
- recipient: new InvalidAddressBecauseDestinationIsAlsoSource(),
163
- },
164
- warnings: {},
165
- },
166
- },
167
- {
168
- name: "undelegate",
169
- transaction: (t) => ({ ...t, mode: "undelegate" }),
170
- expectedStatus: (account, { fees }) => (
171
- invariant(fees, "fees are required"),
172
- {
173
- errors: {},
174
- warnings: {},
175
- amount: new BigNumber(0),
176
- estimatedFees: fees,
177
- }
178
- ),
179
- },
180
- ],
53
+ transactions: [],
181
54
  },
182
55
  {
183
- FIXME_tests: [
184
- "balance is sum of ops", // https://ledgerhq.atlassian.net/browse/LLC-591
185
- ],
186
56
  raw: accountTZRevealedNoDelegate,
187
- transactions: [
188
- {
189
- name: "send max to new account",
190
- transaction: (t) => ({
191
- ...t,
192
- recipient: addressTZnew,
193
- useAllAmount: true,
194
- }),
195
- expectedStatus: (account, { storageLimit, fees }) => (
196
- invariant(fees, "fees are required"),
197
- {
198
- errors: {},
199
- warnings: {},
200
- estimatedFees: fees,
201
- amount: account.balance
202
- .minus(reservedAmountForStorageLimit(storageLimit))
203
- .minus(fees as BigNumber),
204
- totalSpent: account.balance,
205
- }
206
- ),
207
- },
208
- {
209
- name: "send max to existing account",
210
- transaction: (t) => ({
211
- ...t,
212
- recipient: addressTZregular,
213
- useAllAmount: true,
214
- }),
215
- expectedStatus: (account, { fees }) => (
216
- invariant(fees, "fees are required"),
217
- {
218
- errors: {},
219
- warnings: {},
220
- estimatedFees: fees,
221
- amount: account.balance.minus(fees as BigNumber),
222
- totalSpent: account.balance,
223
- }
224
- ),
225
- },
226
- {
227
- name: "delegate",
228
- transaction: (t) => ({
229
- ...t,
230
- recipient: addressDelegator,
231
- mode: "delegate",
232
- }),
233
- expectedStatus: (account, { fees }) => (
234
- invariant(fees, "fees are required"),
235
- {
236
- errors: {},
237
- warnings: {},
238
- amount: new BigNumber(0),
239
- estimatedFees: fees,
240
- }
241
- ),
242
- },
243
- ],
57
+ transactions: [],
244
58
  },
245
59
  {
246
60
  raw: accountTZnotRevealed,
247
- FIXME_tests: [
248
- "balance is sum of ops", // https://ledgerhq.atlassian.net/browse/LLC-591
249
- ],
250
- transactions: [
251
- {
252
- name: "send 10% to KT",
253
- transaction: (t, account) => ({
254
- ...t,
255
- recipient: addressKT,
256
- amount: account.balance.div(10),
257
- }),
258
- expectedStatus: {
259
- errors: {
260
- recipient: new NotSupportedLegacyAddress(),
261
- },
262
- warnings: {},
263
- },
264
- },
265
- {
266
- name: "send 10% to existing tz",
267
- transaction: (t, account) => ({
268
- ...t,
269
- recipient: addressTZnew,
270
- amount: account.balance.div(10),
271
- }),
272
- expectedStatus: (account, { fees }) => (
273
- invariant(fees, "fees are required"),
274
- {
275
- errors: {},
276
- warnings: {},
277
- estimatedFees: (fees as BigNumber).times(2),
278
- amount: account.balance.div(10),
279
- totalSpent: account.balance
280
- .div(10)
281
- .plus((fees as BigNumber).times(2)),
282
- }
283
- ),
284
- },
285
- ],
61
+ transactions: [],
286
62
  },
287
63
  {
288
64
  raw: accountTZnew,
289
65
  test: (expect, account) => {
290
66
  expect(account.operations).toEqual([]);
291
67
  },
292
- transactions: [
293
- {
294
- name: "send 10% to existing tz",
295
- transaction: (t) => ({
296
- ...t,
297
- recipient: addressTZregular,
298
- useAllAmount: true,
299
- }),
300
- expectedStatus: {
301
- errors: {
302
- amount: new NotEnoughBalance(),
303
- },
304
- warnings: {},
305
- },
306
- },
307
- ],
68
+ transactions: [],
308
69
  },
70
+ // FIXME these accounts have issue
71
+ /*
309
72
  {
310
- FIXME_tests: [
311
- "balance is sum of ops", // https://ledgerhq.atlassian.net/browse/LLC-503
312
- // because of prev bug we have bug on:
313
- "from KT 2, send max to existing account",
314
- ],
315
73
  raw: accountTZwithKT,
316
74
  transactions: [
317
- {
318
- name: "from KT 1, send max to new account",
319
- transaction: (t, account) => (
320
- invariant(account.subAccounts, "subAccounts"),
321
- {
322
- ...t,
323
- subAccountId: account.subAccounts?.[0].id,
324
- recipient: addressTZnew,
325
- useAllAmount: true,
326
- }
327
- ),
328
- expectedStatus: ({ subAccounts }, { storageLimit, fees }) => (
329
- invariant(fees && subAccounts, "fees are required"),
330
- {
331
- errors: {},
332
- warnings: {},
333
- estimatedFees: fees,
334
- amount: subAccounts?.[0].balance.minus(
335
- reservedAmountForStorageLimit(storageLimit)
336
- ),
337
- totalSpent: subAccounts?.[0].balance,
338
- }
339
- ),
340
- },
341
- {
342
- name: "from KT 2, send max to existing account",
343
- transaction: (t, account) => (
344
- invariant(
345
- account.subAccounts && account.subAccounts[1],
346
- "subAccounts"
347
- ),
348
- {
349
- ...t,
350
- subAccountId: account.subAccounts?.[1].id,
351
- recipient: addressTZnew,
352
- useAllAmount: true,
353
- }
354
- ),
355
- expectedStatus: ({ subAccounts }, { fees, storageLimit }) => (
356
- invariant(
357
- subAccounts && fees && storageLimit,
358
- "fees are required"
359
- ),
360
- {
361
- errors: {},
362
- warnings: {},
363
- estimatedFees: fees,
364
- amount: subAccounts?.[1].balance,
365
- totalSpent: subAccounts?.[1].balance,
366
- }
367
- ),
368
- },
369
75
  ],
370
76
  },
77
+ */
78
+ /*
371
79
  {
372
- FIXME_tests: [
373
- "balance is sum of ops", // https://ledgerhq.atlassian.net/browse/LLC-591
374
- ],
375
80
  raw: accountTZemptyWithKT,
376
81
  transactions: [
377
- {
378
- name: "from KT 1, send max",
379
- transaction: (t, account) => (
380
- invariant(account.subAccounts, "subAccounts"),
381
- {
382
- ...t,
383
- subAccountId: account.subAccounts?.[0].id,
384
- recipient: addressTZregular,
385
- useAllAmount: true,
386
- }
387
- ),
388
- expectedStatus: {
389
- errors: {
390
- amount: new NotEnoughBalanceInParentAccount(),
391
- },
392
- warnings: {},
393
- },
394
- },
395
- {
396
- name: "from KT 1, send 10%",
397
- transaction: (t, account) => (
398
- invariant(account.subAccounts, "subAccounts"),
399
- {
400
- ...t,
401
- subAccountId: account.subAccounts?.[0].id,
402
- amount: account.balance.div(10),
403
- recipient: addressTZregular,
404
- }
405
- ),
406
- expectedStatus: {
407
- errors: {
408
- amount: new NotEnoughBalanceInParentAccount(),
409
- },
410
- warnings: {},
411
- },
412
- },
413
82
  ],
414
83
  },
84
+ */
415
85
  ],
416
86
  },
417
87
  },
418
88
  };
419
89
  export default dataset;
420
90
 
421
- function makeAccount(name, pubKey, derivationMode) {
91
+ function makeAccount(name, address, derivationMode) {
422
92
  return {
423
- id: `libcore:1:tezos:${pubKey}:${derivationMode}`,
424
- seedIdentifier: pubKey,
93
+ id: `js:2:tezos:${address}:${derivationMode}`,
94
+ seedIdentifier: address,
425
95
  name: "Tezos " + name,
426
96
  derivationMode,
427
97
  index: 0,
428
- freshAddress: "",
98
+ freshAddress: address,
429
99
  freshAddressPath: "",
430
100
  freshAddresses: [],
431
101
  blockHeight: 0,
@@ -435,7 +105,7 @@ function makeAccount(name, pubKey, derivationMode) {
435
105
  unitMagnitude: 6,
436
106
  lastSyncDate: "",
437
107
  balance: "0",
438
- xpub: pubKey,
108
+ xpub: "",
439
109
  subAccounts: [],
440
110
  };
441
111
  }