@ledgerhq/live-common 27.1.0 → 27.2.0-nightly.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/bot/index.d.ts.map +1 -1
- package/lib/bot/index.js +90 -81
- package/lib/bot/index.js.map +1 -1
- package/lib/bot/specs.d.ts.map +1 -1
- package/lib/bot/specs.js +11 -2
- package/lib/bot/specs.js.map +1 -1
- package/lib/families/bitcoin/hw-signMessage.d.ts +5 -3
- package/lib/families/bitcoin/hw-signMessage.d.ts.map +1 -1
- package/lib/families/bitcoin/hw-signMessage.js +2 -2
- package/lib/families/bitcoin/hw-signMessage.js.map +1 -1
- package/lib/families/cosmos/specs.d.ts.map +1 -1
- package/lib/families/cosmos/specs.js +12 -8
- package/lib/families/cosmos/specs.js.map +1 -1
- package/lib/families/ethereum/hw-signMessage.d.ts +7 -3
- package/lib/families/ethereum/hw-signMessage.d.ts.map +1 -1
- package/lib/families/ethereum/hw-signMessage.js +73 -14
- package/lib/families/ethereum/hw-signMessage.js.map +1 -1
- package/lib/families/ethereum/hw-signMessage.test.js +99 -23
- package/lib/families/ethereum/hw-signMessage.test.js.map +1 -1
- package/lib/families/ethereum/types.d.ts +6 -8
- package/lib/families/ethereum/types.d.ts.map +1 -1
- package/lib/families/filecoin/bridge.integration.test.js +1 -1
- package/lib/families/filecoin/bridge.integration.test.js.map +1 -1
- package/lib/families/filecoin/hw-signMessage.d.ts +5 -3
- package/lib/families/filecoin/hw-signMessage.d.ts.map +1 -1
- package/lib/families/filecoin/hw-signMessage.js +2 -2
- package/lib/families/filecoin/hw-signMessage.js.map +1 -1
- package/lib/families/osmosis/specs.d.ts.map +1 -1
- package/lib/families/osmosis/specs.js +32 -22
- package/lib/families/osmosis/specs.js.map +1 -1
- package/lib/families/tron/specs.js +1 -1
- package/lib/families/tron/specs.js.map +1 -1
- package/lib/featureFlags/defaultFeatures.d.ts.map +1 -1
- package/lib/featureFlags/defaultFeatures.js +9 -3
- package/lib/featureFlags/defaultFeatures.js.map +1 -1
- package/lib/generated/hw-signMessage.d.ts +10 -3
- package/lib/generated/hw-signMessage.d.ts.map +1 -1
- package/lib/hw/getOnboardingStatePolling.d.ts.map +1 -1
- package/lib/hw/getOnboardingStatePolling.js +1 -0
- package/lib/hw/getOnboardingStatePolling.js.map +1 -1
- package/lib/hw/signMessage/index.d.ts +5 -5
- package/lib/hw/signMessage/index.d.ts.map +1 -1
- package/lib/hw/signMessage/index.js +10 -6
- package/lib/hw/signMessage/index.js.map +1 -1
- package/lib/hw/signMessage/index.test.js +42 -43
- package/lib/hw/signMessage/index.test.js.map +1 -1
- package/lib/hw/signMessage/types.d.ts +1 -1
- package/lib/hw/signMessage/types.d.ts.map +1 -1
- package/lib/walletconnect/index.d.ts +1 -1
- package/lib/walletconnect/index.d.ts.map +1 -1
- package/lib/walletconnect/index.js +1 -9
- package/lib/walletconnect/index.js.map +1 -1
- package/lib/walletconnect/walletconnect.test.js.map +1 -1
- package/package.json +4 -4
- package/src/bot/index.ts +174 -113
- package/src/bot/specs.ts +16 -2
- package/src/currencies/__snapshots__/sortByMarketcap.test.ts.snap +1 -35
- package/src/families/bitcoin/hw-signMessage.ts +3 -3
- package/src/families/cosmos/specs.ts +14 -10
- package/src/families/ethereum/hw-signMessage.test.ts +105 -21
- package/src/families/ethereum/hw-signMessage.ts +68 -16
- package/src/families/ethereum/types.ts +6 -8
- package/src/families/filecoin/__snapshots__/bridge.integration.test.ts.snap +27 -0
- package/src/families/filecoin/bridge.integration.test.ts +6 -2
- package/src/families/filecoin/hw-signMessage.ts +3 -3
- package/src/families/osmosis/specs.ts +35 -25
- package/src/families/tron/specs.ts +1 -1
- package/src/featureFlags/defaultFeatures.ts +9 -3
- package/src/hw/getOnboardingStatePolling.ts +2 -0
- package/src/hw/signMessage/index.test.ts +48 -45
- package/src/hw/signMessage/index.ts +23 -9
- package/src/hw/signMessage/types.ts +4 -1
- package/src/walletconnect/index.ts +3 -11
- package/src/walletconnect/walletconnect.test.ts +2 -0
|
@@ -694,7 +694,6 @@ Array [
|
|
|
694
694
|
"ethereum/erc20/mark",
|
|
695
695
|
"ethereum/erc20/flip_token",
|
|
696
696
|
"ethereum/erc20/team",
|
|
697
|
-
"polygon/erc20/ig_orb_(pos)",
|
|
698
697
|
"ethereum/erc20/syncfab_manufacturing",
|
|
699
698
|
"ethereum/erc20/niobium",
|
|
700
699
|
"ethereum/erc20/bob_s_repair",
|
|
@@ -728,7 +727,7 @@ Array [
|
|
|
728
727
|
"ethereum/erc20/coinus",
|
|
729
728
|
"ethereum/erc20/rating",
|
|
730
729
|
"ethereum/erc20/uptrennd",
|
|
731
|
-
"
|
|
730
|
+
"ethereum/erc20/stoxtoken",
|
|
732
731
|
"ethereum/erc20/smartshare_token",
|
|
733
732
|
"ethereum/erc20/fti",
|
|
734
733
|
"ethereum/erc20/neurochain_clausius",
|
|
@@ -1579,7 +1578,6 @@ Array [
|
|
|
1579
1578
|
"ethereum/erc20/ape_stax",
|
|
1580
1579
|
"ethereum/erc20/apebullinu",
|
|
1581
1580
|
"ethereum/erc20/apecoin",
|
|
1582
|
-
"ethereum/erc20/apecoin_dev",
|
|
1583
1581
|
"ethereum/erc20/apehaven",
|
|
1584
1582
|
"ethereum/erc20/apenft",
|
|
1585
1583
|
"ethereum/erc20/apenftio",
|
|
@@ -1831,7 +1829,6 @@ Array [
|
|
|
1831
1829
|
"ethereum/erc20/bitboost",
|
|
1832
1830
|
"ethereum/erc20/bitcar_token",
|
|
1833
1831
|
"ethereum/erc20/bitcashpay",
|
|
1834
|
-
"ethereum/erc20/bitcci_cash",
|
|
1835
1832
|
"ethereum/erc20/bitcloud_token",
|
|
1836
1833
|
"ethereum/erc20/bitcoin_boutique",
|
|
1837
1834
|
"ethereum/erc20/bitcoin_zero",
|
|
@@ -2045,7 +2042,6 @@ Array [
|
|
|
2045
2042
|
"ethereum/erc20/capital_finance",
|
|
2046
2043
|
"ethereum/erc20/capitalsharetoken",
|
|
2047
2044
|
"ethereum/erc20/capsule_coin",
|
|
2048
|
-
"ethereum/erc20/captain_inu",
|
|
2049
2045
|
"ethereum/erc20/car_coin",
|
|
2050
2046
|
"ethereum/erc20/car_sharing_community",
|
|
2051
2047
|
"ethereum/erc20/carbcoin",
|
|
@@ -2070,7 +2066,6 @@ Array [
|
|
|
2070
2066
|
"ethereum/erc20/cat__blockcat_",
|
|
2071
2067
|
"ethereum/erc20/cat_trade",
|
|
2072
2068
|
"ethereum/erc20/catcoin",
|
|
2073
|
-
"ethereum/erc20/catecoin",
|
|
2074
2069
|
"ethereum/erc20/cavapoo",
|
|
2075
2070
|
"ethereum/erc20/cavo",
|
|
2076
2071
|
"ethereum/erc20/cbdao",
|
|
@@ -2109,7 +2104,6 @@ Array [
|
|
|
2109
2104
|
"ethereum/erc20/cherry_token",
|
|
2110
2105
|
"ethereum/erc20/chi_gastoken_by_1inch",
|
|
2111
2106
|
"ethereum/erc20/chicken",
|
|
2112
|
-
"ethereum/erc20/chihiro_inu",
|
|
2113
2107
|
"ethereum/erc20/chihua_token",
|
|
2114
2108
|
"ethereum/erc20/chihuahua",
|
|
2115
2109
|
"ethereum/erc20/chipz",
|
|
@@ -2261,7 +2255,6 @@ Array [
|
|
|
2261
2255
|
"ethereum/erc20/creedtoken",
|
|
2262
2256
|
"ethereum/erc20/cremit",
|
|
2263
2257
|
"ethereum/erc20/crespo",
|
|
2264
|
-
"ethereum/erc20/creverse",
|
|
2265
2258
|
"ethereum/erc20/criptoro_coin",
|
|
2266
2259
|
"ethereum/erc20/cro",
|
|
2267
2260
|
"ethereum/erc20/crossfi",
|
|
@@ -2688,7 +2681,6 @@ Array [
|
|
|
2688
2681
|
"ethereum/erc20/enkronostoken",
|
|
2689
2682
|
"ethereum/erc20/enreachdao",
|
|
2690
2683
|
"ethereum/erc20/entanmo",
|
|
2691
|
-
"ethereum/erc20/enter_governance_token",
|
|
2692
2684
|
"ethereum/erc20/entone",
|
|
2693
2685
|
"ethereum/erc20/entropy",
|
|
2694
2686
|
"ethereum/erc20/envicoin",
|
|
@@ -3027,7 +3019,6 @@ Array [
|
|
|
3027
3019
|
"ethereum/erc20/gera",
|
|
3028
3020
|
"ethereum/erc20/gerowallet",
|
|
3029
3021
|
"ethereum/erc20/geyser",
|
|
3030
|
-
"ethereum/erc20/gg_token",
|
|
3031
3022
|
"ethereum/erc20/ggcoin",
|
|
3032
3023
|
"ethereum/erc20/ggtoken",
|
|
3033
3024
|
"ethereum/erc20/ghoul",
|
|
@@ -3110,7 +3101,6 @@ Array [
|
|
|
3110
3101
|
"ethereum/erc20/grearn's_token",
|
|
3111
3102
|
"ethereum/erc20/green",
|
|
3112
3103
|
"ethereum/erc20/green_light_erc20",
|
|
3113
|
-
"ethereum/erc20/green_metaverse_token",
|
|
3114
3104
|
"ethereum/erc20/green_token",
|
|
3115
3105
|
"ethereum/erc20/greenmed",
|
|
3116
3106
|
"ethereum/erc20/grey_token",
|
|
@@ -3194,7 +3184,6 @@ Array [
|
|
|
3194
3184
|
"ethereum/erc20/hiz_finance",
|
|
3195
3185
|
"ethereum/erc20/hkg",
|
|
3196
3186
|
"ethereum/erc20/hlandtoken",
|
|
3197
|
-
"ethereum/erc20/hmmm",
|
|
3198
3187
|
"ethereum/erc20/hoard_token",
|
|
3199
3188
|
"ethereum/erc20/hobonickels",
|
|
3200
3189
|
"ethereum/erc20/hodlcoin",
|
|
@@ -3512,7 +3501,6 @@ Array [
|
|
|
3512
3501
|
"ethereum/erc20/libartysharetoken",
|
|
3513
3502
|
"ethereum/erc20/libera",
|
|
3514
3503
|
"ethereum/erc20/libereum",
|
|
3515
|
-
"ethereum/erc20/libero_financial_freedom",
|
|
3516
3504
|
"ethereum/erc20/libertas",
|
|
3517
3505
|
"ethereum/erc20/libfx",
|
|
3518
3506
|
"ethereum/erc20/libratoken",
|
|
@@ -3678,7 +3666,6 @@ Array [
|
|
|
3678
3666
|
"ethereum/erc20/meta_network",
|
|
3679
3667
|
"ethereum/erc20/metafabric",
|
|
3680
3668
|
"ethereum/erc20/metafactory",
|
|
3681
|
-
"ethereum/erc20/metafluence",
|
|
3682
3669
|
"ethereum/erc20/metaverse_index",
|
|
3683
3670
|
"ethereum/erc20/metaverse_nft_index",
|
|
3684
3671
|
"ethereum/erc20/metawhale_btc",
|
|
@@ -4263,7 +4250,6 @@ Array [
|
|
|
4263
4250
|
"ethereum/erc20/quannabu",
|
|
4264
4251
|
"ethereum/erc20/quantfury_data_token",
|
|
4265
4252
|
"ethereum/erc20/quantfury_token",
|
|
4266
|
-
"ethereum/erc20/quarashi",
|
|
4267
4253
|
"ethereum/erc20/quickmining_token",
|
|
4268
4254
|
"ethereum/erc20/quickswap",
|
|
4269
4255
|
"ethereum/erc20/quiverx",
|
|
@@ -4318,7 +4304,6 @@ Array [
|
|
|
4318
4304
|
"ethereum/erc20/reditoken",
|
|
4319
4305
|
"ethereum/erc20/reef_finance",
|
|
4320
4306
|
"ethereum/erc20/reeth_token",
|
|
4321
|
-
"ethereum/erc20/refi",
|
|
4322
4307
|
"ethereum/erc20/refine_medium_token",
|
|
4323
4308
|
"ethereum/erc20/reflect_finance",
|
|
4324
4309
|
"ethereum/erc20/reflector_finance",
|
|
@@ -4451,7 +4436,6 @@ Array [
|
|
|
4451
4436
|
"ethereum/erc20/savetoken",
|
|
4452
4437
|
"ethereum/erc20/savix",
|
|
4453
4438
|
"ethereum/erc20/scaleswaptoken",
|
|
4454
|
-
"ethereum/erc20/scallop",
|
|
4455
4439
|
"ethereum/erc20/scandiweb_coin",
|
|
4456
4440
|
"ethereum/erc20/scardust",
|
|
4457
4441
|
"ethereum/erc20/scatter_cx",
|
|
@@ -4461,14 +4445,12 @@ Array [
|
|
|
4461
4445
|
"ethereum/erc20/scifitoken",
|
|
4462
4446
|
"ethereum/erc20/scoobi-doge",
|
|
4463
4447
|
"ethereum/erc20/scott",
|
|
4464
|
-
"ethereum/erc20/scratchtoken",
|
|
4465
4448
|
"ethereum/erc20/scrl",
|
|
4466
4449
|
"ethereum/erc20/sdog",
|
|
4467
4450
|
"ethereum/erc20/sea_cucumber_chain",
|
|
4468
4451
|
"ethereum/erc20/sealblock_token",
|
|
4469
4452
|
"ethereum/erc20/sechain",
|
|
4470
4453
|
"ethereum/erc20/secret_finance",
|
|
4471
|
-
"ethereum/erc20/sector",
|
|
4472
4454
|
"ethereum/erc20/secure_pad",
|
|
4473
4455
|
"ethereum/erc20/securypto",
|
|
4474
4456
|
"ethereum/erc20/seed",
|
|
@@ -4859,7 +4841,6 @@ Array [
|
|
|
4859
4841
|
"ethereum/erc20/taklimakan_network",
|
|
4860
4842
|
"ethereum/erc20/talao",
|
|
4861
4843
|
"ethereum/erc20/talent_coin",
|
|
4862
|
-
"ethereum/erc20/talkado",
|
|
4863
4844
|
"ethereum/erc20/tama_egg_niftygotchi",
|
|
4864
4845
|
"ethereum/erc20/tamadoge",
|
|
4865
4846
|
"ethereum/erc20/tamy_token",
|
|
@@ -4953,7 +4934,6 @@ Array [
|
|
|
4953
4934
|
"ethereum/erc20/tingles",
|
|
4954
4935
|
"ethereum/erc20/tinku",
|
|
4955
4936
|
"ethereum/erc20/tio",
|
|
4956
|
-
"ethereum/erc20/titano",
|
|
4957
4937
|
"ethereum/erc20/titanswap",
|
|
4958
4938
|
"ethereum/erc20/tixl_token",
|
|
4959
4939
|
"ethereum/erc20/tknt",
|
|
@@ -5768,7 +5748,6 @@ Array [
|
|
|
5768
5748
|
"polygon/erc20/ground_coin",
|
|
5769
5749
|
"polygon/erc20/grumpy_cat",
|
|
5770
5750
|
"polygon/erc20/guaranteed_entrance_token",
|
|
5771
|
-
"polygon/erc20/guppy_treat_token",
|
|
5772
5751
|
"polygon/erc20/hashgard",
|
|
5773
5752
|
"polygon/erc20/hex",
|
|
5774
5753
|
"polygon/erc20/holotoken",
|
|
@@ -5784,10 +5763,6 @@ Array [
|
|
|
5784
5763
|
"polygon/erc20/instadapp_(pos)",
|
|
5785
5764
|
"polygon/erc20/internxt",
|
|
5786
5765
|
"polygon/erc20/inverse",
|
|
5787
|
-
"polygon/erc20/invictus_bitcoin_alpha",
|
|
5788
|
-
"polygon/erc20/invictus_crypto10_hedged",
|
|
5789
|
-
"polygon/erc20/invictus_crypto20",
|
|
5790
|
-
"polygon/erc20/invictus_stable_growth",
|
|
5791
5766
|
"polygon/erc20/iron_finance_ice_token",
|
|
5792
5767
|
"polygon/erc20/iron_stablecoin",
|
|
5793
5768
|
"polygon/erc20/iron_titanium_token",
|
|
@@ -5830,7 +5805,6 @@ Array [
|
|
|
5830
5805
|
"polygon/erc20/musd",
|
|
5831
5806
|
"polygon/erc20/museum_of_crypto_art",
|
|
5832
5807
|
"polygon/erc20/mysterium_(pos)",
|
|
5833
|
-
"polygon/erc20/nakamoto.games",
|
|
5834
5808
|
"polygon/erc20/napoleonx",
|
|
5835
5809
|
"polygon/erc20/neighbourhoods_token",
|
|
5836
5810
|
"polygon/erc20/neos_credits_(pos)",
|
|
@@ -5895,7 +5869,6 @@ Array [
|
|
|
5895
5869
|
"polygon/erc20/sand",
|
|
5896
5870
|
"polygon/erc20/sand_old",
|
|
5897
5871
|
"polygon/erc20/sapien_network",
|
|
5898
|
-
"polygon/erc20/sekuritance_(pos)",
|
|
5899
5872
|
"polygon/erc20/sentinel",
|
|
5900
5873
|
"polygon/erc20/serum",
|
|
5901
5874
|
"polygon/erc20/shiba_inu_(pos)",
|
|
@@ -6136,7 +6109,6 @@ Array [
|
|
|
6136
6109
|
"bsc/bep20/cartesi_token",
|
|
6137
6110
|
"bsc/bep20/catcoin",
|
|
6138
6111
|
"bsc/bep20/catecoin",
|
|
6139
|
-
"bsc/bep20/catecoin_old",
|
|
6140
6112
|
"bsc/bep20/ceek",
|
|
6141
6113
|
"bsc/bep20/cellframe_token",
|
|
6142
6114
|
"bsc/bep20/cerby_token",
|
|
@@ -6244,14 +6216,12 @@ Array [
|
|
|
6244
6216
|
"bsc/bep20/gamyfi",
|
|
6245
6217
|
"bsc/bep20/genta",
|
|
6246
6218
|
"bsc/bep20/gforce",
|
|
6247
|
-
"bsc/bep20/gg_token",
|
|
6248
6219
|
"bsc/bep20/gomining_token",
|
|
6249
6220
|
"bsc/bep20/goose_coin",
|
|
6250
6221
|
"bsc/bep20/goose_golden_egg",
|
|
6251
6222
|
"bsc/bep20/gorilladiamond",
|
|
6252
6223
|
"bsc/bep20/goswapp",
|
|
6253
6224
|
"bsc/bep20/gourmetgalaxy",
|
|
6254
|
-
"bsc/bep20/green_metaverse_token",
|
|
6255
6225
|
"bsc/bep20/gummy_bull_token",
|
|
6256
6226
|
"bsc/bep20/hachiro_inu",
|
|
6257
6227
|
"bsc/bep20/hacken_token",
|
|
@@ -6366,7 +6336,6 @@ Array [
|
|
|
6366
6336
|
"bsc/bep20/orbital_lps",
|
|
6367
6337
|
"bsc/bep20/orbs",
|
|
6368
6338
|
"bsc/bep20/oreo",
|
|
6369
|
-
"bsc/bep20/orica",
|
|
6370
6339
|
"bsc/bep20/ovr",
|
|
6371
6340
|
"bsc/bep20/paid_network",
|
|
6372
6341
|
"bsc/bep20/pancakeswap_token",
|
|
@@ -6402,7 +6371,6 @@ Array [
|
|
|
6402
6371
|
"bsc/bep20/puli_inu",
|
|
6403
6372
|
"bsc/bep20/qian_governance_token",
|
|
6404
6373
|
"bsc/bep20/qian_second_generation_dollar",
|
|
6405
|
-
"bsc/bep20/quarashi",
|
|
6406
6374
|
"bsc/bep20/quarkchain_token",
|
|
6407
6375
|
"bsc/bep20/qusd_stablecoin",
|
|
6408
6376
|
"bsc/bep20/rabbit_coin",
|
|
@@ -6473,7 +6441,6 @@ Array [
|
|
|
6473
6441
|
"bsc/bep20/swipe",
|
|
6474
6442
|
"bsc/bep20/switcheo_token",
|
|
6475
6443
|
"bsc/bep20/taco",
|
|
6476
|
-
"bsc/bep20/talkado",
|
|
6477
6444
|
"bsc/bep20/tbitcoin",
|
|
6478
6445
|
"bsc/bep20/tdogecoin",
|
|
6479
6446
|
"bsc/bep20/tenet",
|
|
@@ -6536,7 +6503,6 @@ Array [
|
|
|
6536
6503
|
"bsc/bep20/venus_xrp",
|
|
6537
6504
|
"bsc/bep20/venus_xvs",
|
|
6538
6505
|
"bsc/bep20/vfox",
|
|
6539
|
-
"bsc/bep20/volt_inu",
|
|
6540
6506
|
"bsc/bep20/vswap.fi",
|
|
6541
6507
|
"bsc/bep20/wall_street_games",
|
|
6542
6508
|
"bsc/bep20/wanaka_farm",
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import Btc from "@ledgerhq/hw-app-btc";
|
|
2
|
-
import type {
|
|
2
|
+
import type { SignMessage } from "../../hw/signMessage/types";
|
|
3
3
|
|
|
4
|
-
const
|
|
4
|
+
const signMessage: SignMessage = async (transport, { path, message }) => {
|
|
5
5
|
const btc = new Btc(transport);
|
|
6
6
|
const hexMessage = Buffer.from(message).toString("hex");
|
|
7
7
|
const result = await btc.signMessageNew(path, hexMessage);
|
|
@@ -16,4 +16,4 @@ const resolver: Resolver = async (transport, { path, message }) => {
|
|
|
16
16
|
};
|
|
17
17
|
};
|
|
18
18
|
|
|
19
|
-
export default
|
|
19
|
+
export default { signMessage };
|
|
@@ -26,7 +26,7 @@ import {
|
|
|
26
26
|
import { DeviceModelId } from "@ledgerhq/devices";
|
|
27
27
|
import { acceptTransaction } from "./speculos-deviceActions";
|
|
28
28
|
|
|
29
|
-
const minAmount = new BigNumber(
|
|
29
|
+
const minAmount = new BigNumber(10000);
|
|
30
30
|
const maxAccounts = 32;
|
|
31
31
|
|
|
32
32
|
// amounts of delegation are not exact so we are applying an approximation
|
|
@@ -158,13 +158,13 @@ const cosmos: AppSpec<Transaction> = {
|
|
|
158
158
|
"already enough delegations"
|
|
159
159
|
);
|
|
160
160
|
const data = getCurrentCosmosPreloadData();
|
|
161
|
-
const count = 1 + Math.
|
|
161
|
+
const count = 1 + Math.round(2 * Math.random() * Math.random());
|
|
162
162
|
let remaining = getMaxDelegationAvailable(
|
|
163
163
|
account as CosmosAccount,
|
|
164
164
|
count
|
|
165
165
|
)
|
|
166
166
|
.minus(minAmount.times(2))
|
|
167
|
-
.times(0.
|
|
167
|
+
.times(0.1 * Math.random());
|
|
168
168
|
invariant(remaining.gt(0), "not enough funds in account for delegate");
|
|
169
169
|
const all = data.validators.filter(
|
|
170
170
|
(v) =>
|
|
@@ -222,7 +222,7 @@ const cosmos: AppSpec<Transaction> = {
|
|
|
222
222
|
},
|
|
223
223
|
{
|
|
224
224
|
name: "undelegate",
|
|
225
|
-
maxRun:
|
|
225
|
+
maxRun: 5,
|
|
226
226
|
transaction: ({ account, bridge }) => {
|
|
227
227
|
invariant(canUndelegate(account as CosmosAccount), "can undelegate");
|
|
228
228
|
const { cosmosResources } = account as CosmosAccount;
|
|
@@ -246,8 +246,8 @@ const cosmos: AppSpec<Transaction> = {
|
|
|
246
246
|
);
|
|
247
247
|
invariant(undelegateCandidate, "already pending");
|
|
248
248
|
|
|
249
|
-
const amount = (undelegateCandidate as CosmosDelegation).amount
|
|
250
|
-
.times(Math.random() > 0.
|
|
249
|
+
const amount = (undelegateCandidate as CosmosDelegation).amount
|
|
250
|
+
.times(Math.random() > 0.2 ? 1 : Math.random()) // most of the time, undelegate all
|
|
251
251
|
.integerValue();
|
|
252
252
|
invariant(amount.gt(0), "random amount to be positive");
|
|
253
253
|
|
|
@@ -406,10 +406,14 @@ const cosmos: AppSpec<Transaction> = {
|
|
|
406
406
|
const d = (cosmosResources as CosmosResources).delegations.find(
|
|
407
407
|
(d) => d.validatorAddress === v.address
|
|
408
408
|
);
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
409
|
+
botTest("delegation exists in account", () =>
|
|
410
|
+
invariant(d, "delegation %s must be found in account", v.address)
|
|
411
|
+
);
|
|
412
|
+
botTest("reward is no longer claimable after claim", () =>
|
|
413
|
+
invariant(
|
|
414
|
+
!canClaimRewards(account as CosmosAccount, d as CosmosDelegation),
|
|
415
|
+
"reward no longer be claimable"
|
|
416
|
+
)
|
|
413
417
|
);
|
|
414
418
|
});
|
|
415
419
|
},
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import "../../__tests__/test-helpers/setup";
|
|
2
2
|
|
|
3
|
-
import EIP712Message from "@ledgerhq/hw-app-eth/
|
|
4
|
-
import
|
|
3
|
+
import { EIP712Message } from "@ledgerhq/hw-app-eth/lib/modules/EIP712";
|
|
4
|
+
import testEIP712Message from "@ledgerhq/hw-app-eth/tests/sample-messages/0.json";
|
|
5
|
+
import ethSign from "./hw-signMessage";
|
|
5
6
|
import { setEnv } from "../../env";
|
|
7
|
+
import { createFixtureCryptoCurrency } from "../../mock/fixtures/cryptoCurrencies";
|
|
6
8
|
|
|
7
9
|
const signPersonalMessage = jest.fn(() =>
|
|
8
10
|
Promise.resolve({
|
|
@@ -25,14 +27,81 @@ const signEIP712Message = jest.fn(() =>
|
|
|
25
27
|
v: 28,
|
|
26
28
|
})
|
|
27
29
|
);
|
|
30
|
+
// We only need to mock the defaut class returned
|
|
28
31
|
jest.mock("@ledgerhq/hw-app-eth", () => {
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
32
|
+
const originalModule = jest.requireActual("@ledgerhq/hw-app-eth");
|
|
33
|
+
return {
|
|
34
|
+
...originalModule,
|
|
35
|
+
default: class {
|
|
36
|
+
signPersonalMessage = signPersonalMessage;
|
|
37
|
+
signEIP712HashedMessage = signEIP712HashedMessage;
|
|
38
|
+
signEIP712Message = signEIP712Message;
|
|
39
|
+
},
|
|
33
40
|
};
|
|
34
41
|
});
|
|
35
42
|
|
|
43
|
+
describe("prepareMessageToSign", () => {
|
|
44
|
+
it("returns a MessageData object when message to sign is a simple string", () => {
|
|
45
|
+
// Given
|
|
46
|
+
const currency = createFixtureCryptoCurrency("ethereum");
|
|
47
|
+
const path = "44'/60'/0'/0/0";
|
|
48
|
+
const derivationMode = "ethM";
|
|
49
|
+
const message = "4d6573736167652064652074657374";
|
|
50
|
+
const expectedRawMessage = "0x4d6573736167652064652074657374";
|
|
51
|
+
|
|
52
|
+
// When
|
|
53
|
+
const result = ethSign.prepareMessageToSign(
|
|
54
|
+
currency,
|
|
55
|
+
path,
|
|
56
|
+
derivationMode,
|
|
57
|
+
message
|
|
58
|
+
);
|
|
59
|
+
|
|
60
|
+
// Then
|
|
61
|
+
expect(result).toEqual({
|
|
62
|
+
currency,
|
|
63
|
+
path: "44'/60'/0'/0/0",
|
|
64
|
+
derivationMode: "ethM",
|
|
65
|
+
message: "Message de test",
|
|
66
|
+
rawMessage: expectedRawMessage,
|
|
67
|
+
});
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
it("returns a TypedMessageData object when message to sign is an EIP712Message", () => {
|
|
71
|
+
// Given
|
|
72
|
+
const currency = createFixtureCryptoCurrency("ethereum");
|
|
73
|
+
const path = "44'/60'/0'/0/0";
|
|
74
|
+
const derivationMode = "ethM";
|
|
75
|
+
// testEIP712MessageHex
|
|
76
|
+
const message =
|
|
77
|
+
"7b0d0a2020202022646f6d61696e223a207b0d0a202020202020202022636861696e4964223a20352c0d0a2020202020202020226e616d65223a20224574686572204d61696c222c0d0a202020202020202022766572696679696e67436f6e7472616374223a2022307843634343636363634343434363434343434343634363436363436343434363436363636363636343222c0d0a20202020202020202276657273696f6e223a202231220d0a202020207d2c0d0a20202020226d657373616765223a207b0d0a202020202020202022636f6e74656e7473223a202248656c6c6f2c20426f6221222c0d0a20202020202020202266726f6d223a207b0d0a202020202020202020202020226e616d65223a2022436f77222c0d0a2020202020202020202020202277616c6c657473223a205b0d0a2020202020202020202020202020202022307843443261336439463933384531334344393437456330354162433746453733344466384444383236222c0d0a2020202020202020202020202020202022307844656144626565666445416462656566644561646245454664656164626545466445614462656546220d0a2020202020202020202020205d0d0a20202020202020207d2c0d0a202020202020202022746f223a207b0d0a202020202020202020202020226e616d65223a2022426f62222c0d0a2020202020202020202020202277616c6c657473223a205b0d0a2020202020202020202020202020202022307862426242424242626242424262626242626242626262624242624262626262426242626242426242222c0d0a2020202020202020202020202020202022307842304264614265613537423042444142654135376230626441424541353762304244616245613537222c0d0a2020202020202020202020202020202022307842304230623062306230623042303030303030303030303030303030303030303030303030303030220d0a2020202020202020202020205d0d0a20202020202020207d0d0a202020207d2c0d0a20202020227072696d61727954797065223a20224d61696c222c0d0a20202020227479706573223a207b0d0a202020202020202022454950373132446f6d61696e223a205b0d0a2020202020202020202020207b20226e616d65223a20226e616d65222c202274797065223a2022737472696e6722207d2c0d0a2020202020202020202020207b20226e616d65223a202276657273696f6e222c202274797065223a2022737472696e6722207d2c0d0a2020202020202020202020207b20226e616d65223a2022636861696e4964222c202274797065223a202275696e7432353622207d2c0d0a2020202020202020202020207b20226e616d65223a2022766572696679696e67436f6e7472616374222c202274797065223a20226164647265737322207d0d0a20202020202020205d2c0d0a2020202020202020224d61696c223a205b0d0a2020202020202020202020207b20226e616d65223a202266726f6d222c202274797065223a2022506572736f6e22207d2c0d0a2020202020202020202020207b20226e616d65223a2022746f222c202274797065223a2022506572736f6e22207d2c0d0a2020202020202020202020207b20226e616d65223a2022636f6e74656e7473222c202274797065223a2022737472696e6722207d0d0a20202020202020205d2c0d0a202020202020202022506572736f6e223a205b0d0a2020202020202020202020207b20226e616d65223a20226e616d65222c202274797065223a2022737472696e6722207d2c0d0a2020202020202020202020207b20226e616d65223a202277616c6c657473222c202274797065223a2022616464726573735b5d22207d0d0a20202020202020205d0d0a202020207d0d0a7d0d0a";
|
|
78
|
+
|
|
79
|
+
// When
|
|
80
|
+
const result = ethSign.prepareMessageToSign(
|
|
81
|
+
currency,
|
|
82
|
+
path,
|
|
83
|
+
derivationMode,
|
|
84
|
+
message
|
|
85
|
+
);
|
|
86
|
+
|
|
87
|
+
// Then
|
|
88
|
+
expect(result).toEqual({
|
|
89
|
+
currency,
|
|
90
|
+
path,
|
|
91
|
+
derivationMode,
|
|
92
|
+
message: testEIP712Message,
|
|
93
|
+
rawMessage: "0x" + message,
|
|
94
|
+
hashes: {
|
|
95
|
+
stringHash: "",
|
|
96
|
+
domainHash:
|
|
97
|
+
"0x6137beb405d9ff777172aa879e33edb34a1460e701802746c5ef96e741710e59",
|
|
98
|
+
messageHash:
|
|
99
|
+
"0x5476346eb09179b1f7d245c11a27ae6c498a419d7fad4d984d5b1e0ad081662a",
|
|
100
|
+
},
|
|
101
|
+
});
|
|
102
|
+
});
|
|
103
|
+
});
|
|
104
|
+
|
|
36
105
|
describe("Eth hw-signMessage", () => {
|
|
37
106
|
beforeEach(() => {
|
|
38
107
|
jest.clearAllMocks();
|
|
@@ -40,7 +109,7 @@ describe("Eth hw-signMessage", () => {
|
|
|
40
109
|
|
|
41
110
|
describe("parsing", () => {
|
|
42
111
|
it("should be using the signPersonalMessage method with string message", async () => {
|
|
43
|
-
await
|
|
112
|
+
await ethSign.signMessage({} as any, {
|
|
44
113
|
path: "",
|
|
45
114
|
message: "test",
|
|
46
115
|
rawMessage: "0xtest",
|
|
@@ -50,32 +119,47 @@ describe("Eth hw-signMessage", () => {
|
|
|
50
119
|
});
|
|
51
120
|
|
|
52
121
|
it("should be using the signEIP712HashedMessage method with stringified message", async () => {
|
|
53
|
-
await
|
|
122
|
+
await ethSign.signMessage({} as any, {
|
|
54
123
|
path: "",
|
|
55
|
-
message: JSON.stringify(
|
|
124
|
+
message: JSON.stringify(testEIP712Message),
|
|
56
125
|
rawMessage: "0xtest",
|
|
57
126
|
});
|
|
58
127
|
|
|
59
128
|
expect(signEIP712HashedMessage).toHaveBeenCalledTimes(1);
|
|
60
129
|
});
|
|
61
130
|
|
|
62
|
-
it("should be using the
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
await hwSignMessage({} as any, {
|
|
131
|
+
it("should be using the signEIP712HashedMessage method with EIP712Message message", async () => {
|
|
132
|
+
await ethSign.signMessage({} as any, {
|
|
66
133
|
path: "",
|
|
67
|
-
message: EIP712Message,
|
|
134
|
+
message: testEIP712Message as EIP712Message,
|
|
68
135
|
rawMessage: "0xtest",
|
|
69
136
|
});
|
|
70
137
|
|
|
71
|
-
expect(
|
|
72
|
-
|
|
138
|
+
expect(signEIP712HashedMessage).toHaveBeenCalledTimes(1);
|
|
139
|
+
});
|
|
140
|
+
|
|
141
|
+
describe("when EXPERIMENTAL_EIP712 env variable is set to true", () => {
|
|
142
|
+
beforeAll(() => {
|
|
143
|
+
setEnv("EXPERIMENTAL_EIP712", true);
|
|
144
|
+
});
|
|
145
|
+
|
|
146
|
+
afterAll(() => {
|
|
147
|
+
setEnv("EXPERIMENTAL_EIP712", false);
|
|
148
|
+
});
|
|
149
|
+
|
|
150
|
+
it("should be using the signEIP712Message method with EIP712Message message", async () => {
|
|
151
|
+
await ethSign.signMessage({} as any, {
|
|
152
|
+
path: "",
|
|
153
|
+
message: testEIP712Message as EIP712Message,
|
|
154
|
+
rawMessage: "0xtest",
|
|
155
|
+
});
|
|
156
|
+
});
|
|
73
157
|
});
|
|
74
158
|
});
|
|
75
159
|
|
|
76
160
|
describe("value of v", () => {
|
|
77
161
|
it("should returning parity for signPersonalMessage", async () => {
|
|
78
|
-
const { rsv } = await
|
|
162
|
+
const { rsv } = await ethSign.signMessage({} as any, {
|
|
79
163
|
path: "",
|
|
80
164
|
message: "test",
|
|
81
165
|
rawMessage: "0xtest",
|
|
@@ -85,9 +169,9 @@ describe("Eth hw-signMessage", () => {
|
|
|
85
169
|
});
|
|
86
170
|
|
|
87
171
|
it("should not be returning parity for signEIP712HashedMessage", async () => {
|
|
88
|
-
const { rsv } = await
|
|
172
|
+
const { rsv } = await ethSign.signMessage({} as any, {
|
|
89
173
|
path: "",
|
|
90
|
-
message: JSON.stringify(
|
|
174
|
+
message: JSON.stringify(testEIP712Message),
|
|
91
175
|
rawMessage: "0xtest",
|
|
92
176
|
});
|
|
93
177
|
|
|
@@ -97,9 +181,9 @@ describe("Eth hw-signMessage", () => {
|
|
|
97
181
|
it("should not be returning parity for signEIP712Message", async () => {
|
|
98
182
|
setEnv("EXPERIMENTAL_EIP712", true);
|
|
99
183
|
|
|
100
|
-
const { rsv } = await
|
|
184
|
+
const { rsv } = await ethSign.signMessage({} as any, {
|
|
101
185
|
path: "",
|
|
102
|
-
message:
|
|
186
|
+
message: testEIP712Message,
|
|
103
187
|
rawMessage: "0xtest",
|
|
104
188
|
});
|
|
105
189
|
|
|
@@ -1,15 +1,20 @@
|
|
|
1
|
+
import Eth, { isEIP712Message } from "@ledgerhq/hw-app-eth";
|
|
1
2
|
import { EIP712Message } from "@ledgerhq/hw-app-eth/lib/modules/EIP712/EIP712.types";
|
|
2
|
-
import Eth from "@ledgerhq/hw-app-eth";
|
|
3
3
|
import Transport from "@ledgerhq/hw-transport";
|
|
4
4
|
import { TypedDataUtils } from "eth-sig-util";
|
|
5
5
|
import { bufferToHex } from "ethereumjs-util";
|
|
6
6
|
import { getEnv } from "../../env";
|
|
7
7
|
import type { MessageData, Result } from "../../hw/signMessage/types";
|
|
8
8
|
import type { TypedMessageData } from "./types";
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
9
|
+
import { DerivationMode } from "../../derivation";
|
|
10
|
+
import { CryptoCurrency } from "@ledgerhq/types-cryptoassets";
|
|
11
|
+
|
|
12
|
+
type EthSignMessage = (
|
|
13
|
+
transport: Transport,
|
|
14
|
+
message: Pick<
|
|
15
|
+
MessageData | TypedMessageData,
|
|
16
|
+
"path" | "message" | "rawMessage"
|
|
17
|
+
>
|
|
13
18
|
) => Promise<Result>;
|
|
14
19
|
|
|
15
20
|
export const domainHash = (message: EIP712Message): Buffer => {
|
|
@@ -29,18 +34,65 @@ export const messageHash = (message: EIP712Message): Buffer => {
|
|
|
29
34
|
);
|
|
30
35
|
};
|
|
31
36
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
37
|
+
function tryConvertToJSON(message: string): string | EIP712Message {
|
|
38
|
+
try {
|
|
39
|
+
const parsedMessage = JSON.parse(message);
|
|
40
|
+
if (isEIP712Message(parsedMessage)) {
|
|
41
|
+
return parsedMessage as EIP712Message;
|
|
42
|
+
}
|
|
43
|
+
} catch {
|
|
44
|
+
// Not a JSON message
|
|
45
|
+
}
|
|
46
|
+
return message;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
const prepareMessageToSign = (
|
|
50
|
+
currency: CryptoCurrency,
|
|
51
|
+
path: string,
|
|
52
|
+
derivationMode: DerivationMode,
|
|
53
|
+
message: string
|
|
54
|
+
): MessageData | TypedMessageData => {
|
|
55
|
+
const hexToStringMessage = Buffer.from(message, "hex").toString();
|
|
56
|
+
const parsedMessage = tryConvertToJSON(hexToStringMessage);
|
|
57
|
+
|
|
58
|
+
const messageData = {
|
|
59
|
+
currency,
|
|
60
|
+
path,
|
|
61
|
+
derivationMode,
|
|
62
|
+
rawMessage: "0x" + message,
|
|
63
|
+
};
|
|
64
|
+
if (typeof parsedMessage === "string") {
|
|
65
|
+
return {
|
|
66
|
+
...messageData,
|
|
67
|
+
message: parsedMessage,
|
|
68
|
+
};
|
|
69
|
+
} else {
|
|
70
|
+
return {
|
|
71
|
+
...messageData,
|
|
72
|
+
message: parsedMessage,
|
|
73
|
+
hashes: {
|
|
74
|
+
stringHash: "",
|
|
75
|
+
domainHash: bufferToHex(domainHash(parsedMessage)),
|
|
76
|
+
messageHash: bufferToHex(messageHash(parsedMessage)),
|
|
77
|
+
},
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
type PartialMessageData = {
|
|
83
|
+
path: string;
|
|
84
|
+
message: string | EIP712Message;
|
|
85
|
+
rawMessage: string;
|
|
86
|
+
};
|
|
87
|
+
const signMessage: EthSignMessage = async (
|
|
88
|
+
transport: Transport,
|
|
89
|
+
{ path, message, rawMessage }: PartialMessageData
|
|
35
90
|
) => {
|
|
36
91
|
const eth = new Eth(transport);
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
return message;
|
|
42
|
-
}
|
|
43
|
-
})();
|
|
92
|
+
let parsedMessage = message;
|
|
93
|
+
if (typeof message === "string") {
|
|
94
|
+
parsedMessage = tryConvertToJSON(message);
|
|
95
|
+
}
|
|
44
96
|
|
|
45
97
|
let result: Awaited<ReturnType<typeof eth.signPersonalMessage>>;
|
|
46
98
|
if (typeof parsedMessage === "string") {
|
|
@@ -70,4 +122,4 @@ const resolver: EthResolver = async (
|
|
|
70
122
|
};
|
|
71
123
|
};
|
|
72
124
|
|
|
73
|
-
export default
|
|
125
|
+
export default { prepareMessageToSign, signMessage };
|
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import { EIP712Message } from "@ledgerhq/hw-app-eth/lib/modules/EIP712/EIP712.types";
|
|
2
1
|
import type { BigNumber } from "bignumber.js";
|
|
2
|
+
import { EIP712Message } from "@ledgerhq/hw-app-eth/lib/modules/EIP712/EIP712.types";
|
|
3
|
+
import type { Unit } from "@ledgerhq/types-cryptoassets";
|
|
3
4
|
import type { TransactionMode, ModeModule } from "./modules";
|
|
4
5
|
import type { Range, RangeRaw } from "../../range";
|
|
5
|
-
import type { DerivationMode } from "../../derivation";
|
|
6
6
|
import type {
|
|
7
7
|
TransactionCommon,
|
|
8
8
|
TransactionCommonRaw,
|
|
9
9
|
TransactionStatusCommon,
|
|
10
10
|
TransactionStatusCommonRaw,
|
|
11
11
|
} from "@ledgerhq/types-live";
|
|
12
|
-
import type {
|
|
12
|
+
import type { MessageData } from "../../hw/signMessage/types";
|
|
13
13
|
|
|
14
14
|
export type EthereumGasLimitRequest = {
|
|
15
15
|
from?: string;
|
|
@@ -61,14 +61,12 @@ export type TransactionRaw = TransactionCommonRaw & {
|
|
|
61
61
|
collectionName?: string;
|
|
62
62
|
quantities?: string[];
|
|
63
63
|
};
|
|
64
|
-
export type TypedMessageData = {
|
|
65
|
-
currency: CryptoCurrency;
|
|
66
|
-
path: string;
|
|
67
|
-
verify?: boolean;
|
|
68
|
-
derivationMode: DerivationMode;
|
|
64
|
+
export type TypedMessageData = Omit<MessageData, "message"> & {
|
|
69
65
|
message: EIP712Message;
|
|
70
66
|
hashes: {
|
|
71
67
|
stringHash: string;
|
|
68
|
+
domainHash: string;
|
|
69
|
+
messageHash: string;
|
|
72
70
|
};
|
|
73
71
|
};
|
|
74
72
|
|