@ledgerhq/live-common 22.0.3 → 22.1.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/__tests__/families/bitcoin/wallet-btc/xpub.txs.dogecoin.test.d.ts +2 -0
- package/lib/__tests__/families/bitcoin/wallet-btc/xpub.txs.dogecoin.test.d.ts.map +1 -0
- package/lib/__tests__/families/bitcoin/wallet-btc/xpub.txs.dogecoin.test.js +147 -0
- package/lib/__tests__/families/bitcoin/wallet-btc/xpub.txs.dogecoin.test.js.map +1 -0
- package/lib/api/Ripple.d.ts +17 -21
- package/lib/api/Ripple.d.ts.map +1 -1
- package/lib/api/Ripple.js +117 -176
- package/lib/api/Ripple.js.map +1 -1
- package/lib/api/index.d.ts.map +1 -1
- package/lib/api/index.js +1 -5
- package/lib/api/index.js.map +1 -1
- package/lib/env.d.ts +6 -6
- package/lib/env.d.ts.map +1 -1
- package/lib/env.js +3 -3
- package/lib/env.js.map +1 -1
- package/lib/env.react.d.ts +1 -1
- package/lib/env.react.d.ts.map +1 -1
- package/lib/errors.d.ts +3 -0
- package/lib/errors.d.ts.map +1 -1
- package/lib/errors.js +2 -1
- package/lib/errors.js.map +1 -1
- package/lib/families/bitcoin/getAccountNetworkInfo.d.ts.map +1 -1
- package/lib/families/bitcoin/getAccountNetworkInfo.js +4 -2
- package/lib/families/bitcoin/getAccountNetworkInfo.js.map +1 -1
- package/lib/families/bitcoin/specs.d.ts.map +1 -1
- package/lib/families/bitcoin/specs.js +5 -2
- package/lib/families/bitcoin/specs.js.map +1 -1
- package/lib/families/bitcoin/wallet-btc/utils.d.ts +2 -0
- package/lib/families/bitcoin/wallet-btc/utils.d.ts.map +1 -1
- package/lib/families/bitcoin/wallet-btc/utils.js +9 -1
- package/lib/families/bitcoin/wallet-btc/utils.js.map +1 -1
- package/lib/families/bitcoin/wallet-btc/wallet.d.ts.map +1 -1
- package/lib/families/bitcoin/wallet-btc/wallet.js +11 -11
- package/lib/families/bitcoin/wallet-btc/wallet.js.map +1 -1
- package/lib/families/cosmos/js-prepareTransaction.d.ts.map +1 -1
- package/lib/families/cosmos/js-prepareTransaction.js +29 -5
- package/lib/families/cosmos/js-prepareTransaction.js.map +1 -1
- package/lib/families/cosmos/js-signOperation.d.ts.map +1 -1
- package/lib/families/cosmos/js-signOperation.js +76 -39
- package/lib/families/cosmos/js-signOperation.js.map +1 -1
- package/lib/families/cosmos/validators.js +1 -1
- package/lib/families/ripple/bridge/js.d.ts +2 -1
- package/lib/families/ripple/bridge/js.d.ts.map +1 -1
- package/lib/families/ripple/bridge/js.js +96 -466
- package/lib/families/ripple/bridge/js.js.map +1 -1
- package/lib/families/ripple/bridge.test.js +0 -48
- package/lib/families/ripple/bridge.test.js.map +1 -1
- package/lib/families/ripple/js-synchronization.d.ts +10 -0
- package/lib/families/ripple/js-synchronization.d.ts.map +1 -0
- package/lib/families/ripple/js-synchronization.js +156 -0
- package/lib/families/ripple/js-synchronization.js.map +1 -0
- package/lib/families/ripple/test-dataset.d.ts.map +1 -1
- package/lib/families/ripple/test-dataset.js +1 -1
- package/lib/families/ripple/test-dataset.js.map +1 -1
- package/lib/families/ripple/types.api.d.ts +24 -0
- package/lib/families/ripple/types.api.d.ts.map +1 -0
- package/lib/families/ripple/types.api.js +3 -0
- package/lib/families/ripple/types.api.js.map +1 -0
- package/lib/families/solana/api/chain/instruction/token/types.d.ts +3 -3
- package/lib/featureFlags/defaultFeatures.d.ts.map +1 -1
- package/lib/featureFlags/defaultFeatures.js +46 -0
- package/lib/featureFlags/defaultFeatures.js.map +1 -1
- package/lib/featureFlags/types.d.ts +2 -1
- package/lib/featureFlags/types.d.ts.map +1 -1
- package/lib/platform/providers/GlobalCatalogProvider/api/mock.json +0 -26
- package/lib/platform/providers/RemoteLiveAppProvider/api/mock.json +0 -63
- package/lib/types/nft.d.ts +1 -1
- package/lib/types/nft.d.ts.map +1 -1
- package/package.json +7 -7
- package/src/__tests__/families/bitcoin/wallet-btc/xpub.txs.dogecoin.test.ts +96 -0
- package/src/api/Ripple.ts +95 -160
- package/src/api/index.ts +0 -2
- package/src/currencies/__snapshots__/sortByMarketcap.test.ts.snap +47 -3
- package/src/env.ts +3 -3
- package/src/errors.ts +4 -0
- package/src/families/bitcoin/getAccountNetworkInfo.ts +4 -2
- package/src/families/bitcoin/specs.ts +4 -5
- package/src/families/bitcoin/wallet-btc/utils.ts +8 -0
- package/src/families/bitcoin/wallet-btc/wallet.ts +24 -12
- package/src/families/cosmos/__snapshots__/bridge.test.ts.snap +128 -7
- package/src/families/cosmos/js-prepareTransaction.ts +7 -5
- package/src/families/cosmos/js-signOperation.ts +54 -36
- package/src/families/cosmos/validators.ts +1 -1
- package/src/families/ripple/bridge/js.ts +89 -494
- package/src/families/ripple/bridge.test.ts +0 -6
- package/src/families/ripple/js-synchronization.ts +153 -0
- package/src/families/ripple/test-dataset.ts +2 -0
- package/src/families/ripple/types.api.ts +23 -0
- package/src/featureFlags/defaultFeatures.ts +47 -0
- package/src/featureFlags/types.ts +7 -1
- package/src/platform/providers/GlobalCatalogProvider/api/mock.json +0 -26
- package/src/platform/providers/RemoteLiveAppProvider/api/mock.json +0 -63
- package/src/types/nft.ts +1 -1
- package/src/.DS_Store +0 -0
- package/src/__tests__/.DS_Store +0 -0
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
exports[`cosmos currency bridge scanAccounts cosmos seed 1 1`] = `
|
|
4
4
|
Array [
|
|
5
5
|
Object {
|
|
6
|
-
"balance": "
|
|
6
|
+
"balance": "2264526",
|
|
7
7
|
"cosmosResources": Object {
|
|
8
8
|
"delegatedBalance": "2139044",
|
|
9
9
|
"withdrawAddress": "cosmos1g84934jpu3v5de5yqukkkhxmcvsw3u2ajxvpdl",
|
|
@@ -22,7 +22,7 @@ Array [
|
|
|
22
22
|
"index": 0,
|
|
23
23
|
"name": "Cosmos 1",
|
|
24
24
|
"nfts": undefined,
|
|
25
|
-
"operationsCount":
|
|
25
|
+
"operationsCount": 23,
|
|
26
26
|
"pendingOperations": Array [],
|
|
27
27
|
"seedIdentifier": "0388459b2653519948b12492f1a0b464720110c147a8155d23d423a5cc3c21d89a",
|
|
28
28
|
"starred": false,
|
|
@@ -33,7 +33,7 @@ Array [
|
|
|
33
33
|
"xpub": "cosmos1g84934jpu3v5de5yqukkkhxmcvsw3u2ajxvpdl",
|
|
34
34
|
},
|
|
35
35
|
Object {
|
|
36
|
-
"balance": "
|
|
36
|
+
"balance": "300000",
|
|
37
37
|
"cosmosResources": Object {
|
|
38
38
|
"delegatedBalance": "0",
|
|
39
39
|
"withdrawAddress": "cosmos108uy5q9jt59gwugq5yrdhkzcd9jryslmpcstk5",
|
|
@@ -52,7 +52,7 @@ Array [
|
|
|
52
52
|
"index": 1,
|
|
53
53
|
"name": "Cosmos 2",
|
|
54
54
|
"nfts": undefined,
|
|
55
|
-
"operationsCount":
|
|
55
|
+
"operationsCount": 14,
|
|
56
56
|
"pendingOperations": Array [],
|
|
57
57
|
"seedIdentifier": "0388459b2653519948b12492f1a0b464720110c147a8155d23d423a5cc3c21d89a",
|
|
58
58
|
"starred": false,
|
|
@@ -63,9 +63,9 @@ Array [
|
|
|
63
63
|
"xpub": "cosmos108uy5q9jt59gwugq5yrdhkzcd9jryslmpcstk5",
|
|
64
64
|
},
|
|
65
65
|
Object {
|
|
66
|
-
"balance": "
|
|
66
|
+
"balance": "367382",
|
|
67
67
|
"cosmosResources": Object {
|
|
68
|
-
"delegatedBalance": "
|
|
68
|
+
"delegatedBalance": "0",
|
|
69
69
|
"withdrawAddress": "cosmos1cgc696ay2pg6d4gcejek2y8la66j7e5y3c7kyw",
|
|
70
70
|
},
|
|
71
71
|
"currencyId": "cosmos",
|
|
@@ -82,7 +82,7 @@ Array [
|
|
|
82
82
|
"index": 2,
|
|
83
83
|
"name": "Cosmos 3",
|
|
84
84
|
"nfts": undefined,
|
|
85
|
-
"operationsCount":
|
|
85
|
+
"operationsCount": 10,
|
|
86
86
|
"pendingOperations": Array [],
|
|
87
87
|
"seedIdentifier": "0388459b2653519948b12492f1a0b464720110c147a8155d23d423a5cc3c21d89a",
|
|
88
88
|
"starred": false,
|
|
@@ -224,6 +224,30 @@ Array [
|
|
|
224
224
|
"type": "IN",
|
|
225
225
|
"value": "1000",
|
|
226
226
|
},
|
|
227
|
+
Object {
|
|
228
|
+
"accountId": "js:2:cosmos:cosmos1g84934jpu3v5de5yqukkkhxmcvsw3u2ajxvpdl:",
|
|
229
|
+
"blockHash": null,
|
|
230
|
+
"blockHeight": "10348199",
|
|
231
|
+
"contract": undefined,
|
|
232
|
+
"extra": Object {
|
|
233
|
+
"validators": Array [],
|
|
234
|
+
},
|
|
235
|
+
"fee": "3345",
|
|
236
|
+
"hash": "381E494804FFC8EBDBA17B457D7D666DCE377D6D757F6B298FD820250450D409",
|
|
237
|
+
"id": "js:2:cosmos:cosmos1g84934jpu3v5de5yqukkkhxmcvsw3u2ajxvpdl:-381E494804FFC8EBDBA17B457D7D666DCE377D6D757F6B298FD820250450D409-OUT",
|
|
238
|
+
"operator": undefined,
|
|
239
|
+
"recipients": Array [
|
|
240
|
+
"cosmos108uy5q9jt59gwugq5yrdhkzcd9jryslmpcstk5",
|
|
241
|
+
],
|
|
242
|
+
"senders": Array [
|
|
243
|
+
"cosmos1g84934jpu3v5de5yqukkkhxmcvsw3u2ajxvpdl",
|
|
244
|
+
],
|
|
245
|
+
"standard": undefined,
|
|
246
|
+
"tokenId": undefined,
|
|
247
|
+
"transactionSequenceNumber": 79,
|
|
248
|
+
"type": "OUT",
|
|
249
|
+
"value": "203345",
|
|
250
|
+
},
|
|
227
251
|
Object {
|
|
228
252
|
"accountId": "js:2:cosmos:cosmos1g84934jpu3v5de5yqukkkhxmcvsw3u2ajxvpdl:",
|
|
229
253
|
"blockHash": null,
|
|
@@ -710,6 +734,30 @@ Array [
|
|
|
710
734
|
"type": "IN",
|
|
711
735
|
"value": "1000",
|
|
712
736
|
},
|
|
737
|
+
Object {
|
|
738
|
+
"accountId": "js:2:cosmos:cosmos108uy5q9jt59gwugq5yrdhkzcd9jryslmpcstk5:",
|
|
739
|
+
"blockHash": null,
|
|
740
|
+
"blockHeight": "10348199",
|
|
741
|
+
"contract": undefined,
|
|
742
|
+
"extra": Object {
|
|
743
|
+
"validators": Array [],
|
|
744
|
+
},
|
|
745
|
+
"fee": "3345",
|
|
746
|
+
"hash": "381E494804FFC8EBDBA17B457D7D666DCE377D6D757F6B298FD820250450D409",
|
|
747
|
+
"id": "js:2:cosmos:cosmos108uy5q9jt59gwugq5yrdhkzcd9jryslmpcstk5:-381E494804FFC8EBDBA17B457D7D666DCE377D6D757F6B298FD820250450D409-IN",
|
|
748
|
+
"operator": undefined,
|
|
749
|
+
"recipients": Array [
|
|
750
|
+
"cosmos108uy5q9jt59gwugq5yrdhkzcd9jryslmpcstk5",
|
|
751
|
+
],
|
|
752
|
+
"senders": Array [
|
|
753
|
+
"cosmos1g84934jpu3v5de5yqukkkhxmcvsw3u2ajxvpdl",
|
|
754
|
+
],
|
|
755
|
+
"standard": undefined,
|
|
756
|
+
"tokenId": undefined,
|
|
757
|
+
"transactionSequenceNumber": 79,
|
|
758
|
+
"type": "IN",
|
|
759
|
+
"value": "200000",
|
|
760
|
+
},
|
|
713
761
|
Object {
|
|
714
762
|
"accountId": "js:2:cosmos:cosmos108uy5q9jt59gwugq5yrdhkzcd9jryslmpcstk5:",
|
|
715
763
|
"blockHash": null,
|
|
@@ -950,6 +998,30 @@ Array [
|
|
|
950
998
|
"type": "OUT",
|
|
951
999
|
"value": "15050",
|
|
952
1000
|
},
|
|
1001
|
+
Object {
|
|
1002
|
+
"accountId": "js:2:cosmos:cosmos108uy5q9jt59gwugq5yrdhkzcd9jryslmpcstk5:",
|
|
1003
|
+
"blockHash": null,
|
|
1004
|
+
"blockHeight": "10348072",
|
|
1005
|
+
"contract": undefined,
|
|
1006
|
+
"extra": Object {
|
|
1007
|
+
"validators": Array [],
|
|
1008
|
+
},
|
|
1009
|
+
"fee": "3342",
|
|
1010
|
+
"hash": "E7F1D275353E097E0A19217A1D0BFE2DC8947100213E912EFCC896329D950981",
|
|
1011
|
+
"id": "js:2:cosmos:cosmos108uy5q9jt59gwugq5yrdhkzcd9jryslmpcstk5:-E7F1D275353E097E0A19217A1D0BFE2DC8947100213E912EFCC896329D950981-IN",
|
|
1012
|
+
"operator": undefined,
|
|
1013
|
+
"recipients": Array [
|
|
1014
|
+
"cosmos108uy5q9jt59gwugq5yrdhkzcd9jryslmpcstk5",
|
|
1015
|
+
],
|
|
1016
|
+
"senders": Array [
|
|
1017
|
+
"cosmos1cgc696ay2pg6d4gcejek2y8la66j7e5y3c7kyw",
|
|
1018
|
+
],
|
|
1019
|
+
"standard": undefined,
|
|
1020
|
+
"tokenId": undefined,
|
|
1021
|
+
"transactionSequenceNumber": 28,
|
|
1022
|
+
"type": "IN",
|
|
1023
|
+
"value": "100000",
|
|
1024
|
+
},
|
|
953
1025
|
],
|
|
954
1026
|
Array [
|
|
955
1027
|
Object {
|
|
@@ -1121,6 +1193,31 @@ Array [
|
|
|
1121
1193
|
"type": "OUT",
|
|
1122
1194
|
"value": "6565",
|
|
1123
1195
|
},
|
|
1196
|
+
Object {
|
|
1197
|
+
"accountId": "js:2:cosmos:cosmos1cgc696ay2pg6d4gcejek2y8la66j7e5y3c7kyw:",
|
|
1198
|
+
"blockHash": null,
|
|
1199
|
+
"blockHeight": "10337853",
|
|
1200
|
+
"contract": undefined,
|
|
1201
|
+
"extra": Object {
|
|
1202
|
+
"validators": Array [
|
|
1203
|
+
Object {
|
|
1204
|
+
"address": "cosmosvaloper17zcpywlhgcpk7ff505vr8mnc4wwpv5fcta6enz",
|
|
1205
|
+
"amount": "1000",
|
|
1206
|
+
},
|
|
1207
|
+
],
|
|
1208
|
+
},
|
|
1209
|
+
"fee": "7719",
|
|
1210
|
+
"hash": "DD5085AF922A2BAD032131A2F9168EB1498E615063ECBC6C86CE31D5B9981E2A",
|
|
1211
|
+
"id": "js:2:cosmos:cosmos1cgc696ay2pg6d4gcejek2y8la66j7e5y3c7kyw:-DD5085AF922A2BAD032131A2F9168EB1498E615063ECBC6C86CE31D5B9981E2A-UNDELEGATE",
|
|
1212
|
+
"operator": undefined,
|
|
1213
|
+
"recipients": Array [],
|
|
1214
|
+
"senders": Array [],
|
|
1215
|
+
"standard": undefined,
|
|
1216
|
+
"tokenId": undefined,
|
|
1217
|
+
"transactionSequenceNumber": 27,
|
|
1218
|
+
"type": "UNDELEGATE",
|
|
1219
|
+
"value": "7719",
|
|
1220
|
+
},
|
|
1124
1221
|
Object {
|
|
1125
1222
|
"accountId": "js:2:cosmos:cosmos1cgc696ay2pg6d4gcejek2y8la66j7e5y3c7kyw:",
|
|
1126
1223
|
"blockHash": null,
|
|
@@ -1150,6 +1247,30 @@ Array [
|
|
|
1150
1247
|
"type": "DELEGATE",
|
|
1151
1248
|
"value": "8399",
|
|
1152
1249
|
},
|
|
1250
|
+
Object {
|
|
1251
|
+
"accountId": "js:2:cosmos:cosmos1cgc696ay2pg6d4gcejek2y8la66j7e5y3c7kyw:",
|
|
1252
|
+
"blockHash": null,
|
|
1253
|
+
"blockHeight": "10348072",
|
|
1254
|
+
"contract": undefined,
|
|
1255
|
+
"extra": Object {
|
|
1256
|
+
"validators": Array [],
|
|
1257
|
+
},
|
|
1258
|
+
"fee": "3342",
|
|
1259
|
+
"hash": "E7F1D275353E097E0A19217A1D0BFE2DC8947100213E912EFCC896329D950981",
|
|
1260
|
+
"id": "js:2:cosmos:cosmos1cgc696ay2pg6d4gcejek2y8la66j7e5y3c7kyw:-E7F1D275353E097E0A19217A1D0BFE2DC8947100213E912EFCC896329D950981-OUT",
|
|
1261
|
+
"operator": undefined,
|
|
1262
|
+
"recipients": Array [
|
|
1263
|
+
"cosmos108uy5q9jt59gwugq5yrdhkzcd9jryslmpcstk5",
|
|
1264
|
+
],
|
|
1265
|
+
"senders": Array [
|
|
1266
|
+
"cosmos1cgc696ay2pg6d4gcejek2y8la66j7e5y3c7kyw",
|
|
1267
|
+
],
|
|
1268
|
+
"standard": undefined,
|
|
1269
|
+
"tokenId": undefined,
|
|
1270
|
+
"transactionSequenceNumber": 28,
|
|
1271
|
+
"type": "OUT",
|
|
1272
|
+
"value": "103342",
|
|
1273
|
+
},
|
|
1153
1274
|
],
|
|
1154
1275
|
Array [],
|
|
1155
1276
|
]
|
|
@@ -2,7 +2,6 @@ import { Account } from "../../types";
|
|
|
2
2
|
import { Transaction } from "./types";
|
|
3
3
|
import BigNumber from "bignumber.js";
|
|
4
4
|
import { simulate } from "./api/Cosmos";
|
|
5
|
-
import { encodePubkey } from "@cosmjs/proto-signing";
|
|
6
5
|
import { getEnv } from "../../env";
|
|
7
6
|
import { buildTransaction, postBuildTransaction } from "./js-buildTransaction";
|
|
8
7
|
import { getMaxEstimatedBalance } from "./logic";
|
|
@@ -50,10 +49,13 @@ const getEstimatedFees = async (
|
|
|
50
49
|
|
|
51
50
|
// be sure payload is complete
|
|
52
51
|
if (unsignedPayload) {
|
|
53
|
-
const pubkey =
|
|
54
|
-
|
|
55
|
-
value:
|
|
56
|
-
|
|
52
|
+
const pubkey = {
|
|
53
|
+
typeUrl: "/cosmos.crypto.secp256k1.PubKey",
|
|
54
|
+
value: new Uint8Array([
|
|
55
|
+
...new Uint8Array([10, 33]),
|
|
56
|
+
...new Uint8Array(Buffer.from(account.seedIdentifier, "hex")),
|
|
57
|
+
]),
|
|
58
|
+
};
|
|
57
59
|
|
|
58
60
|
const tx_bytes = await postBuildTransaction(
|
|
59
61
|
account,
|
|
@@ -8,13 +8,12 @@ import type { Transaction } from "./types";
|
|
|
8
8
|
import { getAccount, getChainId } from "./api/Cosmos";
|
|
9
9
|
import { Observable } from "rxjs";
|
|
10
10
|
import { withDevice } from "../../hw/deviceAccess";
|
|
11
|
-
import { encodePubkey } from "@cosmjs/proto-signing";
|
|
12
11
|
import { encodeOperationId } from "../../operation";
|
|
13
|
-
import
|
|
12
|
+
import Cosmos from "@ledgerhq/hw-app-cosmos";
|
|
14
13
|
import { AminoTypes } from "@cosmjs/stargate";
|
|
15
|
-
import { stringToPath } from "@cosmjs/crypto";
|
|
16
14
|
import { buildTransaction, postBuildTransaction } from "./js-buildTransaction";
|
|
17
15
|
import BigNumber from "bignumber.js";
|
|
16
|
+
import { Secp256k1Signature } from "@cosmjs/crypto";
|
|
18
17
|
|
|
19
18
|
const aminoTypes = new AminoTypes({ prefix: "cosmos" });
|
|
20
19
|
|
|
@@ -32,52 +31,39 @@ const signOperation = ({
|
|
|
32
31
|
let cancelled;
|
|
33
32
|
|
|
34
33
|
async function main() {
|
|
34
|
+
const hwApp = new Cosmos(transport);
|
|
35
|
+
|
|
35
36
|
const { accountNumber, sequence } = await getAccount(
|
|
36
37
|
account.freshAddress
|
|
37
38
|
);
|
|
38
39
|
|
|
39
40
|
const chainId = await getChainId();
|
|
40
41
|
|
|
41
|
-
const hdPaths: any = stringToPath("m/" + account.freshAddressPath);
|
|
42
|
-
|
|
43
|
-
const ledgerSigner = new LedgerSigner(transport, {
|
|
44
|
-
hdPaths: [hdPaths],
|
|
45
|
-
});
|
|
46
|
-
|
|
47
42
|
o.next({ type: "device-signature-requested" });
|
|
48
43
|
|
|
49
|
-
const
|
|
50
|
-
|
|
51
|
-
|
|
44
|
+
const { publicKey } = await hwApp.getAddress(
|
|
45
|
+
account.freshAddressPath,
|
|
46
|
+
"cosmos",
|
|
47
|
+
false
|
|
48
|
+
);
|
|
52
49
|
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
});
|
|
50
|
+
const pubkey = {
|
|
51
|
+
typeUrl: "/cosmos.crypto.secp256k1.PubKey",
|
|
52
|
+
value: new Uint8Array([
|
|
53
|
+
...new Uint8Array([10, 33]),
|
|
54
|
+
...new Uint8Array(Buffer.from(publicKey, "hex")),
|
|
55
|
+
]),
|
|
56
|
+
};
|
|
61
57
|
|
|
62
58
|
const unsignedPayload = await buildTransaction(account, transaction);
|
|
63
59
|
|
|
64
60
|
const msgs = unsignedPayload.map((msg) => aminoTypes.toAmino(msg));
|
|
65
61
|
|
|
66
62
|
// Note:
|
|
67
|
-
//
|
|
68
|
-
// Cosmos App support legacy StdTx and required to be ordered in a strict way,
|
|
69
|
-
// Cosmos API expects a different sorting, resulting in a separate signature.
|
|
70
|
-
// https://github.com/LedgerHQ/app-cosmos/blob/6c194daa28936e273f9548eabca9e72ba04bb632/app/src/tx_parser.c#L52
|
|
71
|
-
|
|
72
|
-
// Cosmos App sign data in Amino way only, not Protobuf.
|
|
63
|
+
// Cosmos Nano App sign data in Amino way only, not Protobuf.
|
|
73
64
|
// This is a legacy outdated standard and a long-term blocking point.
|
|
74
65
|
|
|
75
|
-
|
|
76
|
-
// by the AminoConverter from @cosmjs/stargate. There's two things who don't work:
|
|
77
|
-
// 1st, the way who message is sorted.
|
|
78
|
-
// 2nd, cast of numeric value (integer/numeric versus string).
|
|
79
|
-
|
|
80
|
-
const signed = await ledgerSigner.signAmino(account.freshAddress, {
|
|
66
|
+
const message = {
|
|
81
67
|
chain_id: chainId,
|
|
82
68
|
account_number: accountNumber.toString(),
|
|
83
69
|
sequence: sequence.toString(),
|
|
@@ -92,17 +78,30 @@ const signOperation = ({
|
|
|
92
78
|
},
|
|
93
79
|
msgs: msgs,
|
|
94
80
|
memo: transaction.memo || "",
|
|
95
|
-
}
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
const { signature } = await hwApp.sign(
|
|
84
|
+
account.freshAddressPath,
|
|
85
|
+
JSON.stringify(sortedObject(message))
|
|
86
|
+
);
|
|
87
|
+
|
|
88
|
+
if (!signature) {
|
|
89
|
+
throw new Error("Cosmos: no Signature Found");
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
const secp256k1Signature = Secp256k1Signature.fromDer(
|
|
93
|
+
new Uint8Array(signature)
|
|
94
|
+
).toFixedLength();
|
|
96
95
|
|
|
97
96
|
const tx_bytes = await postBuildTransaction(
|
|
98
97
|
account,
|
|
99
98
|
transaction,
|
|
100
99
|
pubkey,
|
|
101
100
|
unsignedPayload,
|
|
102
|
-
|
|
101
|
+
secp256k1Signature
|
|
103
102
|
);
|
|
104
103
|
|
|
105
|
-
const
|
|
104
|
+
const signed = Buffer.from(tx_bytes).toString("hex");
|
|
106
105
|
|
|
107
106
|
if (cancelled) {
|
|
108
107
|
return;
|
|
@@ -169,7 +168,7 @@ const signOperation = ({
|
|
|
169
168
|
type: "signed",
|
|
170
169
|
signedOperation: {
|
|
171
170
|
operation,
|
|
172
|
-
signature,
|
|
171
|
+
signature: signed,
|
|
173
172
|
expirationDate: null,
|
|
174
173
|
},
|
|
175
174
|
});
|
|
@@ -186,4 +185,23 @@ const signOperation = ({
|
|
|
186
185
|
})
|
|
187
186
|
);
|
|
188
187
|
|
|
188
|
+
const sortedObject = (obj) => {
|
|
189
|
+
if (typeof obj !== "object" || obj === null) {
|
|
190
|
+
return obj;
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
if (Array.isArray(obj)) {
|
|
194
|
+
return obj.map(sortedObject);
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
const sortedKeys = Object.keys(obj).sort();
|
|
198
|
+
const result = {};
|
|
199
|
+
|
|
200
|
+
sortedKeys.forEach((key) => {
|
|
201
|
+
result[key] = sortedObject(obj[key]);
|
|
202
|
+
});
|
|
203
|
+
|
|
204
|
+
return result;
|
|
205
|
+
};
|
|
206
|
+
|
|
189
207
|
export default signOperation;
|
|
@@ -31,7 +31,7 @@ const cacheValidators = makeLRUCache(
|
|
|
31
31
|
if (isStargate(currency)) {
|
|
32
32
|
const url = `${getBaseApiUrl(
|
|
33
33
|
currency
|
|
34
|
-
)}/${namespace}/staking/${version}/validators?status=BOND_STATUS_BONDED&pagination.limit=
|
|
34
|
+
)}/${namespace}/staking/${version}/validators?status=BOND_STATUS_BONDED&pagination.limit=175`;
|
|
35
35
|
const { data } = await network({
|
|
36
36
|
url,
|
|
37
37
|
method: "GET",
|