@ledgerhq/live-common 21.23.0 → 21.25.1

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 (117) hide show
  1. package/lib/data/icons/react/index.d.ts +1 -0
  2. package/lib/data/icons/react/index.d.ts.map +1 -1
  3. package/lib/data/icons/react/index.js +4 -2
  4. package/lib/data/icons/react/index.js.map +1 -1
  5. package/lib/data/icons/react/ssv.d.ts +8 -0
  6. package/lib/data/icons/react/ssv.d.ts.map +1 -0
  7. package/lib/data/icons/react/ssv.js +31 -0
  8. package/lib/data/icons/react/ssv.js.map +1 -0
  9. package/lib/data/icons/reactNative/index.d.ts +1 -0
  10. package/lib/data/icons/reactNative/index.d.ts.map +1 -1
  11. package/lib/data/icons/reactNative/index.js +4 -2
  12. package/lib/data/icons/reactNative/index.js.map +1 -1
  13. package/lib/data/icons/reactNative/ssv.d.ts +8 -0
  14. package/lib/data/icons/reactNative/ssv.d.ts.map +1 -0
  15. package/lib/data/icons/reactNative/ssv.js +32 -0
  16. package/lib/data/icons/reactNative/ssv.js.map +1 -0
  17. package/lib/env.d.ts +10 -5
  18. package/lib/env.d.ts.map +1 -1
  19. package/lib/env.js +5 -0
  20. package/lib/env.js.map +1 -1
  21. package/lib/env.react.d.ts +1 -1
  22. package/lib/env.react.d.ts.map +1 -1
  23. package/lib/families/bitcoin/js-synchronisation.d.ts.map +1 -1
  24. package/lib/families/bitcoin/js-synchronisation.js +10 -12
  25. package/lib/families/bitcoin/js-synchronisation.js.map +1 -1
  26. package/lib/families/bitcoin/wallet-btc/crypto/base.d.ts.map +1 -1
  27. package/lib/families/bitcoin/wallet-btc/crypto/base.js +30 -22
  28. package/lib/families/bitcoin/wallet-btc/crypto/base.js.map +1 -1
  29. package/lib/families/bitcoin/wallet-btc/crypto/bip32.d.ts +11 -0
  30. package/lib/families/bitcoin/wallet-btc/crypto/bip32.d.ts.map +1 -0
  31. package/lib/families/bitcoin/wallet-btc/crypto/bip32.js +32 -0
  32. package/lib/families/bitcoin/wallet-btc/crypto/bip32.js.map +1 -0
  33. package/lib/families/bitcoin/wallet-btc/crypto/decred.d.ts.map +1 -1
  34. package/lib/families/bitcoin/wallet-btc/crypto/decred.js +3 -114
  35. package/lib/families/bitcoin/wallet-btc/crypto/decred.js.map +1 -1
  36. package/lib/families/bitcoin/wallet-btc/storage/index.d.ts +24 -8
  37. package/lib/families/bitcoin/wallet-btc/storage/index.d.ts.map +1 -1
  38. package/lib/families/bitcoin/wallet-btc/storage/index.js +114 -128
  39. package/lib/families/bitcoin/wallet-btc/storage/index.js.map +1 -1
  40. package/lib/families/bitcoin/wallet-btc/storage/types.d.ts +8 -7
  41. package/lib/families/bitcoin/wallet-btc/storage/types.d.ts.map +1 -1
  42. package/lib/families/bitcoin/wallet-btc/xpub.d.ts.map +1 -1
  43. package/lib/families/bitcoin/wallet-btc/xpub.js +42 -63
  44. package/lib/families/bitcoin/wallet-btc/xpub.js.map +1 -1
  45. package/lib/families/crypto_org/deviceTransactionConfig.d.ts +11 -0
  46. package/lib/families/crypto_org/deviceTransactionConfig.d.ts.map +1 -0
  47. package/lib/families/crypto_org/deviceTransactionConfig.js +40 -0
  48. package/lib/families/crypto_org/deviceTransactionConfig.js.map +1 -0
  49. package/lib/families/ethereum/modules/compound.d.ts.map +1 -1
  50. package/lib/families/ethereum/modules/compound.js +2 -1
  51. package/lib/families/ethereum/modules/compound.js.map +1 -1
  52. package/lib/families/ethereum/modules/erc1155.d.ts.map +1 -1
  53. package/lib/families/ethereum/modules/erc1155.js +2 -1
  54. package/lib/families/ethereum/modules/erc1155.js.map +1 -1
  55. package/lib/families/ethereum/modules/erc20.d.ts.map +1 -1
  56. package/lib/families/ethereum/modules/erc20.js +2 -1
  57. package/lib/families/ethereum/modules/erc20.js.map +1 -1
  58. package/lib/families/ethereum/modules/erc721.d.ts.map +1 -1
  59. package/lib/families/ethereum/modules/erc721.js +2 -1
  60. package/lib/families/ethereum/modules/erc721.js.map +1 -1
  61. package/lib/families/ethereum/modules/index.d.ts +5 -0
  62. package/lib/families/ethereum/modules/index.d.ts.map +1 -1
  63. package/lib/families/ethereum/modules/index.js.map +1 -1
  64. package/lib/families/ethereum/signOperation.d.ts.map +1 -1
  65. package/lib/families/ethereum/signOperation.js +33 -24
  66. package/lib/families/ethereum/signOperation.js.map +1 -1
  67. package/lib/families/polkadot/address.d.ts.map +1 -1
  68. package/lib/families/polkadot/address.js +5 -1
  69. package/lib/families/polkadot/address.js.map +1 -1
  70. package/lib/families/polkadot/js-getTransactionStatus.d.ts.map +1 -1
  71. package/lib/families/polkadot/js-getTransactionStatus.js +6 -2
  72. package/lib/families/polkadot/js-getTransactionStatus.js.map +1 -1
  73. package/lib/families/tezos/bridge/js.d.ts.map +1 -1
  74. package/lib/families/tezos/bridge/js.js +32 -16
  75. package/lib/families/tezos/bridge/js.js.map +1 -1
  76. package/lib/families/tezos/signOperation.d.ts.map +1 -1
  77. package/lib/families/tezos/signOperation.js +9 -0
  78. package/lib/families/tezos/signOperation.js.map +1 -1
  79. package/lib/families/tezos/synchronisation.js +1 -1
  80. package/lib/families/tezos/synchronisation.js.map +1 -1
  81. package/lib/generated/deviceTransactionConfig.d.ts +2 -0
  82. package/lib/generated/deviceTransactionConfig.d.ts.map +1 -1
  83. package/lib/generated/deviceTransactionConfig.js +18 -16
  84. package/lib/generated/deviceTransactionConfig.js.map +1 -1
  85. package/lib/hw/actions/transaction.d.ts +3 -1
  86. package/lib/hw/actions/transaction.d.ts.map +1 -1
  87. package/lib/hw/actions/transaction.js +4 -2
  88. package/lib/hw/actions/transaction.js.map +1 -1
  89. package/package.json +8 -8
  90. package/src/__tests__/__snapshots__/all.libcore.ts.snap +7 -7
  91. package/src/data/icons/react/index.tsx +1 -0
  92. package/src/data/icons/react/ssv.tsx +12 -0
  93. package/src/data/icons/reactNative/index.tsx +1 -0
  94. package/src/data/icons/reactNative/ssv.tsx +13 -0
  95. package/src/data/icons/svg/SSV.svg +4 -0
  96. package/src/env.ts +5 -0
  97. package/src/families/bitcoin/js-synchronisation.ts +14 -13
  98. package/src/families/bitcoin/wallet-btc/crypto/base.ts +33 -21
  99. package/src/families/bitcoin/wallet-btc/crypto/bip32.ts +36 -0
  100. package/src/families/bitcoin/wallet-btc/crypto/decred.ts +3 -154
  101. package/src/families/bitcoin/wallet-btc/storage/index.ts +23 -11
  102. package/src/families/bitcoin/wallet-btc/storage/types.ts +8 -10
  103. package/src/families/bitcoin/wallet-btc/xpub.ts +14 -10
  104. package/src/families/crypto_org/deviceTransactionConfig.ts +52 -0
  105. package/src/families/ethereum/modules/compound.ts +2 -0
  106. package/src/families/ethereum/modules/erc1155.ts +2 -0
  107. package/src/families/ethereum/modules/erc20.ts +2 -0
  108. package/src/families/ethereum/modules/erc721.ts +2 -0
  109. package/src/families/ethereum/modules/index.ts +10 -0
  110. package/src/families/ethereum/signOperation.ts +27 -8
  111. package/src/families/polkadot/address.ts +8 -2
  112. package/src/families/polkadot/js-getTransactionStatus.ts +6 -2
  113. package/src/families/tezos/bridge/js.ts +38 -17
  114. package/src/families/tezos/signOperation.ts +12 -0
  115. package/src/families/tezos/synchronisation.ts +1 -1
  116. package/src/generated/deviceTransactionConfig.ts +3 -0
  117. package/src/hw/actions/transaction.ts +7 -2
@@ -1 +1 @@
1
- {"version":3,"file":"transaction.d.ts","sourceRoot":"","sources":["../../../src/hw/actions/transaction.ts"],"names":[],"mappings":"AAAA,OAAO,EAAM,UAAU,EAAE,MAAM,MAAM,CAAC;AAKtC,OAAO,KAAK,EACV,aAAa,EACb,WAAW,EACX,OAAO,EACP,WAAW,EACX,iBAAiB,EACjB,eAAe,EAEhB,MAAM,aAAa,CAAC;AAIrB,OAAO,KAAK,EAAE,eAAe,EAAE,KAAK,IAAI,eAAe,EAAE,MAAM,eAAe,CAAC;AAC/E,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AAC9C,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,OAAO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E,MAAM,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AAC9C,OAAO,KAAK,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAElD,aAAK,KAAK,GAAG;IACX,eAAe,EAAE,eAAe,GAAG,IAAI,GAAG,SAAS,CAAC;IACpD,wBAAwB,EAAE,OAAO,CAAC;IAClC,uBAAuB,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC;IACnD,oBAAoB,EAAE,KAAK,GAAG,IAAI,GAAG,SAAS,CAAC;CAChD,CAAC;AACF,aAAK,gBAAgB,GAAG,QAAQ,GAAG,KAAK,CAAC;AACzC,aAAK,kBAAkB,GAAG;IACxB,aAAa,CAAC,EAAE,aAAa,GAAG,IAAI,GAAG,SAAS,CAAC;IACjD,aAAa,EAAE,OAAO,GAAG,IAAI,GAAG,SAAS,CAAC;IAC1C,OAAO,EAAE,WAAW,CAAC;IACrB,WAAW,EAAE,WAAW,CAAC;IACzB,MAAM,EAAE,iBAAiB,CAAC;IAC1B,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,YAAY,CAAC,EAAE,UAAU,EAAE,CAAC;IAC5B,qBAAqB,CAAC,EAAE,OAAO,CAAC;CACjC,CAAC;AACF,aAAK,iBAAiB,GAClB;IACE,eAAe,EAAE,eAAe,CAAC;IACjC,MAAM,EAAE,MAAM,CAAC;CAChB,GACD;IACE,oBAAoB,EAAE,KAAK,CAAC;CAC7B,CAAC;AACN,aAAK,iBAAiB,GAAG,MAAM,CAC7B,kBAAkB,EAClB,gBAAgB,EAChB,iBAAiB,CAClB,CAAC;AA2DF,eAAO,MAAM,YAAY,0BACA,eAAe,KAAK,WAAW,eAAe,CAAC,KACrE,iBAoEF,CAAC"}
@@ -80,11 +80,13 @@ var reducer = function (state, e) {
80
80
  };
81
81
  var createAction = function (connectAppExec) {
82
82
  var useHook = function (reduxDevice, txRequest) {
83
- var transaction = txRequest.transaction, appName = txRequest.appName;
83
+ var transaction = txRequest.transaction, appName = txRequest.appName, dependencies = txRequest.dependencies, requireLatestFirmware = txRequest.requireLatestFirmware;
84
84
  var mainAccount = (0, account_1.getMainAccount)(txRequest.account, txRequest.parentAccount);
85
85
  var appState = (0, app_1.createAction)(connectAppExec).useHook(reduxDevice, {
86
86
  account: mainAccount,
87
- appName: appName
87
+ appName: appName,
88
+ dependencies: dependencies,
89
+ requireLatestFirmware: requireLatestFirmware
88
90
  });
89
91
  var device = appState.device, opened = appState.opened, inWrongDeviceForAccount = appState.inWrongDeviceForAccount, error = appState.error;
90
92
  var _a = __read((0, react_1.useState)(initialState), 2), state = _a[0], setState = _a[1];
@@ -1 +1 @@
1
- {"version":3,"file":"transaction.js","sourceRoot":"","sources":["../../../src/hw/actions/transaction.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,6BAAsC;AACtC,4CAAuD;AACvD,+BAA4C;AAC5C,uCAAqC;AACrC,2CAAwD;AAUxD,uCAA0D;AAC1D,yCAA+C;AAC/C,uCAAgD;AAIhD,6BAAwD;AA8BxD,IAAM,SAAS,GAAG,UAAC,EAIA;QAHjB,MAAM,YAAA,EACN,eAAe,qBAAA,EACf,oBAAoB,0BAAA;IAEpB,OAAA,eAAe,IAAI,MAAM;QACvB,CAAC,CAAC;YACE,eAAe,iBAAA;YACf,MAAM,QAAA;SACP;QACH,CAAC,CAAC,oBAAoB;YACtB,CAAC,CAAC;gBACE,oBAAoB,sBAAA;aACrB;YACH,CAAC,CAAC,IAAI;AATR,CASQ,CAAC;AAQX,IAAM,YAAY,GAAG;IACnB,eAAe,EAAE,IAAI;IACrB,wBAAwB,EAAE,KAAK;IAC/B,uBAAuB,EAAE,IAAI;IAC7B,oBAAoB,EAAE,IAAI;CAC3B,CAAC;AAEF,IAAM,OAAO,GAAG,UAAC,KAAY,EAAE,CAAQ;IACrC,QAAQ,CAAC,CAAC,IAAI,EAAE;QACd,KAAK,OAAO,CAAC,CAAC;YACJ,IAAA,KAAK,GAAK,CAAC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
package/package.json CHANGED
@@ -8,7 +8,7 @@
8
8
  "type": "git",
9
9
  "url": "https://github.com/LedgerHQ/ledger-live-common"
10
10
  },
11
- "version": "21.23.0",
11
+ "version": "21.25.1",
12
12
  "main": "lib/index.js",
13
13
  "types": "lib/index.d.ts",
14
14
  "license": "Apache-2.0",
@@ -44,13 +44,13 @@
44
44
  "dependencies": {
45
45
  "@crypto-com/chain-jslib": "0.0.19",
46
46
  "@ledgerhq/compressjs": "1.3.2",
47
- "@ledgerhq/cryptoassets": "6.21.3",
47
+ "@ledgerhq/cryptoassets": "6.22.3",
48
48
  "@ledgerhq/devices": "6.20.0",
49
49
  "@ledgerhq/errors": "6.10.0",
50
50
  "@ledgerhq/hw-app-algorand": "6.20.0",
51
51
  "@ledgerhq/hw-app-btc": "6.21.0",
52
52
  "@ledgerhq/hw-app-cosmos": "6.20.0",
53
- "@ledgerhq/hw-app-eth": "6.21.3",
53
+ "@ledgerhq/hw-app-eth": "6.22.3",
54
54
  "@ledgerhq/hw-app-polkadot": "6.20.0",
55
55
  "@ledgerhq/hw-app-solana": "^6.20.0",
56
56
  "@ledgerhq/hw-app-str": "6.20.0",
@@ -101,7 +101,7 @@
101
101
  "ethereumjs-common": "^1.5.2",
102
102
  "ethereumjs-tx": "^2.1.2",
103
103
  "ethereumjs-util": "^7.1.3",
104
- "expect": "^27.4.2",
104
+ "expect": "^27.4.6",
105
105
  "generic-pool": "^3.8.2",
106
106
  "invariant": "^2.2.2",
107
107
  "isomorphic-ws": "^4.0.1",
@@ -127,7 +127,7 @@
127
127
  "stellar-sdk": "^9.1.0",
128
128
  "triple-beam": "^1.3.0",
129
129
  "winston": "^3.3.3",
130
- "xstate": "^4.26.1",
130
+ "xstate": "^4.27.0",
131
131
  "zcash-bitcore-lib": "^0.13.20-rc3"
132
132
  },
133
133
  "devDependencies": {
@@ -149,15 +149,15 @@
149
149
  "eslint-config-prettier": "^8.3.0",
150
150
  "eslint-config-typescript": "^3.0.0",
151
151
  "eslint-formatter-pretty": "^3.0.1",
152
- "eslint-plugin-import": "^2.25.3",
152
+ "eslint-plugin-import": "^2.25.4",
153
153
  "eslint-plugin-jsx-a11y": "^6.5.1",
154
154
  "eslint-plugin-prettier": "^3.4.0",
155
- "eslint-plugin-react": "^7.27.1",
155
+ "eslint-plugin-react": "^7.28.0",
156
156
  "eslint-plugin-react-hooks": "^4.3.0",
157
157
  "eslint-plugin-typescript": "^0.14.0",
158
158
  "fs": "^0.0.1-security",
159
159
  "glob": "^7.2.0",
160
- "jest": "^27.4.5",
160
+ "jest": "^27.4.7",
161
161
  "jest-file-snapshot": "^0.5.0",
162
162
  "prettier": "2.3.2",
163
163
  "react": "17.0.2",
@@ -15070,7 +15070,7 @@ Array [
15070
15070
  "starred": false,
15071
15071
  "subAccounts": Array [],
15072
15072
  "swapHistory": Array [],
15073
- "syncHash": "[\\"ethereum/erc20/ampleforth\\",\\"ethereum/erc20/steth\\"]_false_6033",
15073
+ "syncHash": "[\\"ethereum/erc20/ampleforth\\",\\"ethereum/erc20/steth\\"]_false_6043",
15074
15074
  "unitMagnitude": 18,
15075
15075
  "used": true,
15076
15076
  },
@@ -15111,7 +15111,7 @@ Array [
15111
15111
  "starred": false,
15112
15112
  "subAccounts": Array [],
15113
15113
  "swapHistory": Array [],
15114
- "syncHash": "[\\"ethereum/erc20/ampleforth\\",\\"ethereum/erc20/steth\\"]_false_6033",
15114
+ "syncHash": "[\\"ethereum/erc20/ampleforth\\",\\"ethereum/erc20/steth\\"]_false_6043",
15115
15115
  "unitMagnitude": 18,
15116
15116
  "used": true,
15117
15117
  },
@@ -15591,7 +15591,7 @@ Array [
15591
15591
  "starred": false,
15592
15592
  "subAccounts": Array [],
15593
15593
  "swapHistory": Array [],
15594
- "syncHash": "[\\"ethereum/erc20/ampleforth\\",\\"ethereum/erc20/steth\\"]_false_6033",
15594
+ "syncHash": "[\\"ethereum/erc20/ampleforth\\",\\"ethereum/erc20/steth\\"]_false_6043",
15595
15595
  "unitMagnitude": 18,
15596
15596
  "used": true,
15597
15597
  },
@@ -15926,7 +15926,7 @@ Array [
15926
15926
  "starred": false,
15927
15927
  "subAccounts": Array [],
15928
15928
  "swapHistory": Array [],
15929
- "syncHash": "[\\"ethereum/erc20/ampleforth\\",\\"ethereum/erc20/steth\\"]_false_6033",
15929
+ "syncHash": "[\\"ethereum/erc20/ampleforth\\",\\"ethereum/erc20/steth\\"]_false_6043",
15930
15930
  "unitMagnitude": 18,
15931
15931
  "used": true,
15932
15932
  },
@@ -16023,7 +16023,7 @@ Array [
16023
16023
  "starred": false,
16024
16024
  "subAccounts": Array [],
16025
16025
  "swapHistory": Array [],
16026
- "syncHash": "[\\"ethereum/erc20/ampleforth\\",\\"ethereum/erc20/steth\\"]_false_6033",
16026
+ "syncHash": "[\\"ethereum/erc20/ampleforth\\",\\"ethereum/erc20/steth\\"]_false_6043",
16027
16027
  "unitMagnitude": 18,
16028
16028
  "used": true,
16029
16029
  },
@@ -16148,7 +16148,7 @@ Array [
16148
16148
  "starred": false,
16149
16149
  "subAccounts": Array [],
16150
16150
  "swapHistory": Array [],
16151
- "syncHash": "[\\"ethereum/erc20/ampleforth\\",\\"ethereum/erc20/steth\\"]_false_6033",
16151
+ "syncHash": "[\\"ethereum/erc20/ampleforth\\",\\"ethereum/erc20/steth\\"]_false_6043",
16152
16152
  "unitMagnitude": 18,
16153
16153
  "used": true,
16154
16154
  },
@@ -16245,7 +16245,7 @@ Array [
16245
16245
  "starred": false,
16246
16246
  "subAccounts": Array [],
16247
16247
  "swapHistory": Array [],
16248
- "syncHash": "[\\"ethereum/erc20/ampleforth\\",\\"ethereum/erc20/steth\\"]_false_6033",
16248
+ "syncHash": "[\\"ethereum/erc20/ampleforth\\",\\"ethereum/erc20/steth\\"]_false_6043",
16249
16249
  "unitMagnitude": 18,
16250
16250
  "used": true,
16251
16251
  },
@@ -352,6 +352,7 @@ export { default as sol } from "./sol";
352
352
  export { default as spank } from "./spank";
353
353
  export { default as sphtx } from "./sphtx";
354
354
  export { default as srn } from "./srn";
355
+ export { default as ssv } from "./ssv";
355
356
  export { default as stak } from "./stak";
356
357
  export { default as start } from "./start";
357
358
  export { default as steem } from "./steem";
@@ -0,0 +1,12 @@
1
+
2
+ import * as React from "react";
3
+ interface Props {
4
+ size: number;
5
+ color?: string;
6
+ };
7
+
8
+ function ssv({size, color = "currentColor"}: Props) {
9
+ return <svg width={size} height={size} viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg"><path opacity={0.62} d="M177.641 404.919L242.226 325.315C248.972 316.999 261.661 316.999 268.407 325.315L332.991 404.919C338.013 411.108 338.013 419.97 332.991 426.16L268.407 505.764C261.661 514.079 248.972 514.079 242.226 505.764L177.641 426.16C172.62 419.97 172.62 411.108 177.641 404.919Z" fill={color} /><path fillRule="evenodd" clipRule="evenodd" d="M242.226 6.23638L177.641 85.8404C172.62 92.0303 172.62 100.892 177.641 107.082L242.226 186.686C248.972 195.001 261.661 195.001 268.407 186.686L332.991 107.082C338.013 100.892 338.013 92.0303 332.991 85.8404L268.407 6.23639C261.661 -2.07879 248.972 -2.0788 242.226 6.23638ZM76.7665 210.257L141.351 130.653C148.097 122.338 160.786 122.338 167.532 130.653L232.116 210.257C237.138 216.447 237.138 225.308 232.116 231.498L167.532 311.102C160.786 319.417 148.097 319.417 141.351 311.102L76.7665 231.498C71.7445 225.308 71.7445 216.447 76.7665 210.257ZM278.579 210.257L343.163 130.653C349.91 122.338 362.598 122.338 369.344 130.653L433.929 210.257C438.951 216.447 438.951 225.308 433.929 231.498L369.344 311.102C362.598 319.417 349.91 319.417 343.163 311.102L278.579 231.498C273.557 225.308 273.557 216.447 278.579 210.257Z" fill={color} /></svg>;
10
+ }
11
+
12
+ export default ssv;
@@ -352,6 +352,7 @@ export { default as sol } from "./sol";
352
352
  export { default as spank } from "./spank";
353
353
  export { default as sphtx } from "./sphtx";
354
354
  export { default as srn } from "./srn";
355
+ export { default as ssv } from "./ssv";
355
356
  export { default as stak } from "./stak";
356
357
  export { default as start } from "./start";
357
358
  export { default as steem } from "./steem";
@@ -0,0 +1,13 @@
1
+
2
+ import * as React from "react";
3
+ import Svg, { Path } from "react-native-svg";
4
+ interface Props {
5
+ size: number;
6
+ color: string;
7
+ };
8
+
9
+ function ssv({ size, color }: Props) {
10
+ return <Svg width={size} height={size} viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg"><Path opacity={0.62} d="M177.641 404.919L242.226 325.315C248.972 316.999 261.661 316.999 268.407 325.315L332.991 404.919C338.013 411.108 338.013 419.97 332.991 426.16L268.407 505.764C261.661 514.079 248.972 514.079 242.226 505.764L177.641 426.16C172.62 419.97 172.62 411.108 177.641 404.919Z" fill={color} /><Path fillRule="evenodd" clipRule="evenodd" d="M242.226 6.23638L177.641 85.8404C172.62 92.0303 172.62 100.892 177.641 107.082L242.226 186.686C248.972 195.001 261.661 195.001 268.407 186.686L332.991 107.082C338.013 100.892 338.013 92.0303 332.991 85.8404L268.407 6.23639C261.661 -2.07879 248.972 -2.0788 242.226 6.23638ZM76.7665 210.257L141.351 130.653C148.097 122.338 160.786 122.338 167.532 130.653L232.116 210.257C237.138 216.447 237.138 225.308 232.116 231.498L167.532 311.102C160.786 319.417 148.097 319.417 141.351 311.102L76.7665 231.498C71.7445 225.308 71.7445 216.447 76.7665 210.257ZM278.579 210.257L343.163 130.653C349.91 122.338 362.598 122.338 369.344 130.653L433.929 210.257C438.951 216.447 438.951 225.308 433.929 231.498L369.344 311.102C362.598 319.417 349.91 319.417 343.163 311.102L278.579 231.498C273.557 225.308 273.557 216.447 278.579 210.257Z" fill={color} /></Svg>;
11
+ }
12
+
13
+ export default ssv;
@@ -0,0 +1,4 @@
1
+ <svg width="512" height="512" viewBox="0 0 512 512" fill="none" xmlns="http://www.w3.org/2000/svg">
2
+ <path opacity="0.62" d="M177.641 404.919L242.226 325.315C248.972 316.999 261.661 316.999 268.407 325.315L332.991 404.919C338.013 411.108 338.013 419.97 332.991 426.16L268.407 505.764C261.661 514.079 248.972 514.079 242.226 505.764L177.641 426.16C172.62 419.97 172.62 411.108 177.641 404.919Z" fill="#1BA5F8"/>
3
+ <path fill-rule="evenodd" clip-rule="evenodd" d="M242.226 6.23638L177.641 85.8404C172.62 92.0303 172.62 100.892 177.641 107.082L242.226 186.686C248.972 195.001 261.661 195.001 268.407 186.686L332.991 107.082C338.013 100.892 338.013 92.0303 332.991 85.8404L268.407 6.23639C261.661 -2.07879 248.972 -2.0788 242.226 6.23638ZM76.7665 210.257L141.351 130.653C148.097 122.338 160.786 122.338 167.532 130.653L232.116 210.257C237.138 216.447 237.138 225.308 232.116 231.498L167.532 311.102C160.786 319.417 148.097 319.417 141.351 311.102L76.7665 231.498C71.7445 225.308 71.7445 216.447 76.7665 210.257ZM278.579 210.257L343.163 130.653C349.91 122.338 362.598 122.338 369.344 130.653L433.929 210.257C438.951 216.447 438.951 225.308 433.929 231.498L369.344 311.102C362.598 319.417 349.91 319.417 343.163 311.102L278.579 231.498C273.557 225.308 273.557 216.447 278.579 210.257Z" fill="#1BA5F8"/>
4
+ </svg>
package/src/env.ts CHANGED
@@ -506,6 +506,11 @@ const envDefinitions = {
506
506
  parser: boolParser,
507
507
  desc: "enable visibility of debug apps and tools in Platform Catalog",
508
508
  },
509
+ PLATFORM_EXPERIMENTAL_APPS: {
510
+ def: false,
511
+ parser: boolParser,
512
+ desc: "enable visibility of experimental apps and tools in Platform Catalog",
513
+ },
509
514
  PLATFORM_MANIFEST_API_URL: {
510
515
  def: "https://cdn.live.ledger.com/platform/apps/v1/data.json",
511
516
  parser: stringParser,
@@ -91,8 +91,8 @@ const mapTxToOperations = (
91
91
  tx: TX,
92
92
  currencyId: string,
93
93
  accountId: string,
94
- accountAddresses: string[],
95
- changeAddresses: string[]
94
+ accountAddresses: Set<string>,
95
+ changeAddresses: Set<string>
96
96
  ): $Shape<Operation[]> => {
97
97
  const operations: Operation[] = [];
98
98
  const hash = tx.hash;
@@ -116,7 +116,7 @@ const mapTxToOperations = (
116
116
  );
117
117
 
118
118
  if (input.value) {
119
- if (accountAddresses.includes(input.address)) {
119
+ if (accountAddresses.has(input.address)) {
120
120
  // This address is part of the account
121
121
  value = value.plus(input.value);
122
122
  accountInputs.push(input);
@@ -137,7 +137,7 @@ const mapTxToOperations = (
137
137
 
138
138
  for (const output of tx.outputs) {
139
139
  if (output.address) {
140
- if (!accountAddresses.includes(output.address)) {
140
+ if (!accountAddresses.has(output.address)) {
141
141
  // The output doesn't belong to this account
142
142
  if (
143
143
  accountInputs.length > 0 && // It's a SEND operation
@@ -154,7 +154,7 @@ const mapTxToOperations = (
154
154
  // The output belongs to this account
155
155
  accountOutputs.push(output);
156
156
 
157
- if (!changeAddresses.includes(output.address)) {
157
+ if (!changeAddresses.has(output.address)) {
158
158
  // The output isn't a change output of this account
159
159
  recipients.push(
160
160
  syncReplaceAddress
@@ -183,7 +183,7 @@ const mapTxToOperations = (
183
183
  if (accountInputs.length > 0) {
184
184
  // It's a SEND operation
185
185
  for (const output of accountOutputs) {
186
- if (changeAddresses.includes(output.address)) {
186
+ if (changeAddresses.has(output.address)) {
187
187
  value = value.minus(output.value);
188
188
  }
189
189
  }
@@ -214,7 +214,7 @@ const mapTxToOperations = (
214
214
  let finalAmount = new BigNumber(0);
215
215
 
216
216
  for (const output of accountOutputs) {
217
- if (!filterChangeAddresses || !changeAddresses.includes(output.address)) {
217
+ if (!filterChangeAddresses || !changeAddresses.has(output.address)) {
218
218
  finalAmount = finalAmount.plus(output.value);
219
219
  accountOutputCount += 1;
220
220
  }
@@ -324,17 +324,18 @@ const getAccountShape: GetAccountShape = async (info) => {
324
324
  const { txs: transactions } = await wallet.getAccountTransactions(
325
325
  walletAccount
326
326
  );
327
+
328
+ const accountAddresses: Set<string> = new Set<string>();
327
329
  const accountAddressesWithInfo = await walletAccount.xpub.getXpubAddresses();
328
- const accountAddresses = accountAddressesWithInfo
329
- ? accountAddressesWithInfo.map((a) => a.address)
330
- : [];
330
+ accountAddressesWithInfo.forEach((a) => accountAddresses.add(a.address));
331
+
332
+ const changeAddresses: Set<string> = new Set<string>();
331
333
  const changeAddressesWithInfo =
332
334
  await walletAccount.xpub.storage.getUniquesAddresses({
333
335
  account: 1,
334
336
  });
335
- const changeAddresses = changeAddressesWithInfo
336
- ? changeAddressesWithInfo.map((a) => a.address)
337
- : [];
337
+ changeAddressesWithInfo.forEach((a) => changeAddresses.add(a.address));
338
+
338
339
  const newOperations = transactions
339
340
  ?.map((tx) =>
340
341
  mapTxToOperations(
@@ -1,13 +1,15 @@
1
1
  // from https://github.com/LedgerHQ/xpub-scan/blob/master/src/actions/deriveAddresses.ts
2
2
 
3
3
  import * as bjs from "bitcoinjs-lib";
4
- import * as bip32 from "bip32";
5
4
  // eslint-disable-next-line @typescript-eslint/ban-ts-comment
6
5
  // @ts-ignore
7
6
  import { toOutputScript } from "bitcoinjs-lib/src/address";
8
7
  import bs58check from "bs58check";
9
8
  import { DerivationModes } from "../types";
10
9
  import { ICrypto } from "./types";
10
+ import bs58 from "bs58";
11
+ import bech32 from "bech32";
12
+ import BIP32 from "./bip32";
11
13
 
12
14
  export function fallbackValidateAddress(address: string): boolean {
13
15
  try {
@@ -41,7 +43,18 @@ class Base implements ICrypto {
41
43
 
42
44
  protected getPubkeyAt(xpub: string, account: number, index: number): Buffer {
43
45
  if (!Base.bech32Cache[xpub]) {
44
- Base.bech32Cache[xpub] = bip32.fromBase58(xpub, this.network);
46
+ const buffer: Buffer = bs58.decode(xpub);
47
+ const depth: number = buffer[4];
48
+ const i: number = buffer.readUInt32BE(9);
49
+ const chainCode: Buffer = buffer.slice(13, 45);
50
+ const publicKey: Buffer = buffer.slice(45, 78);
51
+ Base.bech32Cache[xpub] = new BIP32(
52
+ publicKey,
53
+ chainCode,
54
+ this.network,
55
+ depth,
56
+ i
57
+ );
45
58
  }
46
59
  if (Base.publickeyCache[`${xpub}-${account}-${index}`]) {
47
60
  return Base.publickeyCache[`${xpub}-${account}-${index}`];
@@ -62,33 +75,32 @@ class Base implements ICrypto {
62
75
 
63
76
  // derive legacy address at account and index positions
64
77
  getLegacyAddress(xpub: string, account: number, index: number): string {
65
- const { address } = bjs.payments.p2pkh({
66
- pubkey: this.getPubkeyAt(xpub, account, index),
67
- network: this.network,
68
- });
69
-
70
- return String(address);
78
+ const publicKeyBuffer: Buffer = this.getPubkeyAt(xpub, account, index);
79
+ const publicKeyHash160: Buffer = bjs.crypto.hash160(publicKeyBuffer);
80
+ return bjs.address.toBase58Check(publicKeyHash160, this.network.pubKeyHash);
71
81
  }
72
82
 
73
83
  // derive native SegWit at account and index positions
74
84
  getNativeSegWitAddress(xpub: string, account: number, index: number): string {
75
- const { address } = bjs.payments.p2wpkh({
76
- pubkey: this.getPubkeyAt(xpub, account, index),
77
- network: this.network,
78
- });
79
-
80
- return String(address);
85
+ const publicKeyBuffer: Buffer = this.getPubkeyAt(xpub, account, index);
86
+ const publicKeyHash160: Buffer = bjs.crypto.hash160(publicKeyBuffer);
87
+ const words: number[] = bech32.toWords(publicKeyHash160);
88
+ words.unshift(0x00);
89
+ return bech32.encode(this.network.bech32, words);
81
90
  }
82
91
 
83
92
  // derive SegWit at account and index positions
84
93
  getSegWitAddress(xpub: string, account: number, index: number): string {
85
- const { address } = bjs.payments.p2sh({
86
- redeem: bjs.payments.p2wpkh({
87
- pubkey: this.getPubkeyAt(xpub, account, index),
88
- network: this.network,
89
- }),
90
- });
91
- return String(address);
94
+ const publicKeyBuffer: Buffer = this.getPubkeyAt(xpub, account, index);
95
+ const redeemOutput: Buffer = bjs.script.compile([
96
+ 0,
97
+ bjs.crypto.hash160(publicKeyBuffer),
98
+ ]);
99
+ const publicKeyHash160: Buffer = bjs.crypto.hash160(redeemOutput);
100
+ const payload: Buffer = Buffer.allocUnsafe(21);
101
+ payload.writeUInt8(this.network.scriptHash, 0);
102
+ publicKeyHash160.copy(payload, 1);
103
+ return bs58check.encode(payload);
92
104
  }
93
105
 
94
106
  // get address given an address type
@@ -0,0 +1,36 @@
1
+ import ecc from "tiny-secp256k1";
2
+ import createHmac from "create-hmac";
3
+
4
+ // the BIP32 class is inspired from https://github.com/bitcoinjs/bip32/blob/master/src/bip32.js
5
+ class BIP32 {
6
+ publicKey: any;
7
+ chainCode: any;
8
+ network: any;
9
+ depth: number;
10
+ index: number;
11
+ constructor(
12
+ publicKey: any,
13
+ chainCode: any,
14
+ network: any,
15
+ depth = 0,
16
+ index = 0
17
+ ) {
18
+ this.publicKey = publicKey;
19
+ this.chainCode = chainCode;
20
+ this.network = network;
21
+ this.depth = depth;
22
+ this.index = index;
23
+ }
24
+ derive(index: number) {
25
+ const data = Buffer.allocUnsafe(37);
26
+ this.publicKey.copy(data, 0);
27
+ data.writeUInt32BE(index, 33);
28
+ const I = createHmac("sha512", this.chainCode).update(data).digest();
29
+ const IL = I.slice(0, 32);
30
+ const IR = I.slice(32);
31
+ const Ki = ecc.pointAddScalar(this.publicKey, IL, true);
32
+ return new BIP32(Ki, IR, this.network, this.depth + 1, index);
33
+ }
34
+ }
35
+
36
+ export default BIP32;
@@ -6,149 +6,7 @@ import bs58check from "bs58check";
6
6
  import createBlakeHash from "blake-hash";
7
7
  import RIPEMD160 from "ripemd160";
8
8
  import bs58 from "bs58";
9
- import ecc from "tiny-secp256k1";
10
- import createHash from "create-hash";
11
- import createHmac from "create-hmac";
12
-
13
- // the BIP32 class is inspired from https://github.com/bitcoinjs/bip32/blob/master/src/bip32.js
14
- class BIP32 {
15
- privateKey: any;
16
- publicKey: any;
17
- chainCode: any;
18
- network: any;
19
- depth: number;
20
- index: number;
21
- ParentFingerprint: number;
22
- lowR: boolean;
23
- constructor(
24
- privateKey,
25
- publicKey,
26
- chainCode,
27
- network,
28
- depth = 0,
29
- index = 0,
30
- ParentFingerprint = 0x00000000
31
- ) {
32
- this.privateKey = privateKey;
33
- this.publicKey = publicKey;
34
- this.chainCode = chainCode;
35
- this.network = network;
36
- this.depth = depth;
37
- this.index = index;
38
- this.ParentFingerprint = ParentFingerprint;
39
- this.lowR = false;
40
- }
41
- pk() {
42
- if (this.publicKey === undefined)
43
- this.publicKey = ecc.pointFromScalar(this.privateKey, true);
44
- return this.publicKey;
45
- }
46
- isNeutered() {
47
- return this.privateKey === undefined;
48
- }
49
- neutered() {
50
- return new BIP32(
51
- undefined,
52
- this.pk(),
53
- this.chainCode,
54
- this.network,
55
- this.depth,
56
- this.index,
57
- this.ParentFingerprint
58
- );
59
- }
60
- hmacSHA512(key, data) {
61
- return createHmac("sha512", key).update(data).digest();
62
- }
63
- hashSHA256(buffer) {
64
- return createHash("sha256").update(buffer).digest();
65
- }
66
- fingerprint() {
67
- return this.hashSHA256(this.pk()).slice(0, 4);
68
- }
69
-
70
- toBase58() {
71
- const network = this.network;
72
- const version = !this.isNeutered()
73
- ? network.bip32.private
74
- : network.bip32.public;
75
- const buffer = Buffer.allocUnsafe(78);
76
- // 4 bytes: version bytes
77
- buffer.writeUInt32BE(version, 0);
78
- // 1 byte: depth: 0x00 for master nodes, 0x01 for level-1 descendants, ....
79
- buffer.writeUInt8(this.depth, 4);
80
- // 4 bytes: the fingerprint of the parent's key (0x00000000 if master key)
81
- buffer.writeUInt32BE(this.ParentFingerprint, 5);
82
- // 4 bytes: child number. This is the number i in xi = xpar/i, with xi the key being serialized.
83
- // This is encoded in big endian. (0x00000000 if master key)
84
- buffer.writeUInt32BE(this.index, 9);
85
- // 32 bytes: the chain code
86
- this.chainCode.copy(buffer, 13);
87
- // 33 bytes: the public key or private key data
88
- if (!this.isNeutered()) {
89
- // 0x00 + k for private keys
90
- buffer.writeUInt8(0, 45);
91
- this.privateKey.copy(buffer, 46);
92
- // 33 bytes: the public key
93
- } else {
94
- // X9.62 encoding for public keys
95
- this.pk().copy(buffer, 45);
96
- }
97
- return bs58check.encode(buffer);
98
- }
99
- // https://github.com/bitcoin/bips/blob/master/bip-0032.mediawiki#child-key-derivation-ckd-functions
100
- derive(index) {
101
- const isHardened = index >= 0x80000000;
102
- const data = Buffer.allocUnsafe(37);
103
- // Hardened child
104
- if (isHardened) {
105
- data[0] = 0x00;
106
- this.privateKey.copy(data, 1);
107
- data.writeUInt32BE(index, 33);
108
- } else {
109
- this.pk().copy(data, 0);
110
- data.writeUInt32BE(index, 33);
111
- }
112
- const I = this.hmacSHA512(this.chainCode, data);
113
- const IL = I.slice(0, 32);
114
- const IR = I.slice(32);
115
- // if parse256(IL) >= n, proceed with the next value for i
116
- if (!ecc.isPrivate(IL)) return this.derive(index + 1);
117
- // Private parent key -> private child key
118
- let hd;
119
- if (!this.isNeutered()) {
120
- // ki = parse256(IL) + kpar (mod n)
121
- const ki = ecc.privateAdd(this.privateKey, IL);
122
- // In case ki == 0, proceed with the next value for i
123
- if (ki == null) return this.derive(index + 1);
124
- hd = new BIP32(
125
- ki,
126
- undefined,
127
- IR,
128
- this.network,
129
- this.depth + 1,
130
- index,
131
- this.fingerprint().readUInt32BE(0)
132
- );
133
- } else {
134
- // Ki = point(parse256(IL)) + Kpar
135
- // = G*IL + Kpar
136
- const Ki = ecc.pointAddScalar(this.pk(), IL, true);
137
- // In case Ki is the point at infinity, proceed with the next value for i
138
- if (Ki === null) return this.derive(index + 1);
139
- hd = new BIP32(
140
- undefined,
141
- Ki,
142
- IR,
143
- this.network,
144
- this.depth + 1,
145
- index,
146
- this.fingerprint().readUInt32BE(0)
147
- );
148
- }
149
- return hd;
150
- }
151
- }
9
+ import BIP32 from "./bip32";
152
10
 
153
11
  class Decred extends Base {
154
12
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
@@ -226,20 +84,11 @@ class Decred extends Base {
226
84
  buffer = bs58check.decode(xpub);
227
85
  }
228
86
  const depth = buffer[4];
229
- const parentFingerprint = buffer.readUInt32BE(5);
230
87
  const i = buffer.readUInt32BE(9);
231
88
  const chainCode = buffer.slice(13, 45);
232
89
  const X = buffer.slice(45, 78);
233
- const hd = new BIP32(
234
- undefined,
235
- X,
236
- chainCode,
237
- this.network,
238
- depth,
239
- i,
240
- parentFingerprint
241
- );
242
- const publicKey = hd.derive(account).derive(index).pk();
90
+ const hd = new BIP32(X, chainCode, this.network, depth, i);
91
+ const publicKey = hd.derive(account).derive(index).publicKey;
243
92
  const address = Decred.getAddressFromPk(publicKey);
244
93
  Base.addressCache[`${derivationMode}-${xpub}-${account}-${index}`] =
245
94
  address;