@firmachain/firma-js 0.2.26 → 0.2.27

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 (155) hide show
  1. package/package.json +1 -1
  2. package/dist/index.d.ts +0 -4
  3. package/dist/index.js +0 -16
  4. package/dist/sdk/FirmaBankService.d.ts +0 -15
  5. package/dist/sdk/FirmaBankService.js +0 -211
  6. package/dist/sdk/FirmaChainService.d.ts +0 -8
  7. package/dist/sdk/FirmaChainService.js +0 -86
  8. package/dist/sdk/FirmaConfig.d.ts +0 -18
  9. package/dist/sdk/FirmaConfig.js +0 -63
  10. package/dist/sdk/FirmaContractService.d.ts +0 -31
  11. package/dist/sdk/FirmaContractService.js +0 -413
  12. package/dist/sdk/FirmaDistributionService.d.ts +0 -31
  13. package/dist/sdk/FirmaDistributionService.js +0 -524
  14. package/dist/sdk/FirmaFeeGrantService.d.ts +0 -21
  15. package/dist/sdk/FirmaFeeGrantService.js +0 -341
  16. package/dist/sdk/FirmaGovService.d.ts +0 -35
  17. package/dist/sdk/FirmaGovService.js +0 -775
  18. package/dist/sdk/FirmaIpfsService.d.ts +0 -12
  19. package/dist/sdk/FirmaIpfsService.js +0 -185
  20. package/dist/sdk/FirmaMobileSDK.d.ts +0 -27
  21. package/dist/sdk/FirmaMobileSDK.js +0 -45
  22. package/dist/sdk/FirmaNftService.d.ts +0 -31
  23. package/dist/sdk/FirmaNftService.js +0 -372
  24. package/dist/sdk/FirmaSDK.d.ts +0 -29
  25. package/dist/sdk/FirmaSDK.js +0 -48
  26. package/dist/sdk/FirmaSlashingService.d.ts +0 -9
  27. package/dist/sdk/FirmaSlashingService.js +0 -105
  28. package/dist/sdk/FirmaStakingService.d.ts +0 -34
  29. package/dist/sdk/FirmaStakingService.js +0 -604
  30. package/dist/sdk/FirmaTokenService.d.ts +0 -26
  31. package/dist/sdk/FirmaTokenService.js +0 -416
  32. package/dist/sdk/FirmaUtil.d.ts +0 -37
  33. package/dist/sdk/FirmaUtil.js +0 -230
  34. package/dist/sdk/FirmaWalletService.d.ts +0 -36
  35. package/dist/sdk/FirmaWalletService.js +0 -309
  36. package/dist/sdk/firmachain/amino/addresses.d.ts +0 -5
  37. package/dist/sdk/firmachain/amino/addresses.js +0 -46
  38. package/dist/sdk/firmachain/amino/aminomsgs.d.ts +0 -281
  39. package/dist/sdk/firmachain/amino/aminomsgs.js +0 -77
  40. package/dist/sdk/firmachain/amino/aminotypes.d.ts +0 -22
  41. package/dist/sdk/firmachain/amino/aminotypes.js +0 -521
  42. package/dist/sdk/firmachain/amino/coins.d.ts +0 -30
  43. package/dist/sdk/firmachain/amino/coins.js +0 -69
  44. package/dist/sdk/firmachain/amino/encoding.d.ts +0 -24
  45. package/dist/sdk/firmachain/amino/encoding.js +0 -234
  46. package/dist/sdk/firmachain/amino/multisig.d.ts +0 -10
  47. package/dist/sdk/firmachain/amino/multisig.js +0 -42
  48. package/dist/sdk/firmachain/amino/paths.d.ts +0 -6
  49. package/dist/sdk/firmachain/amino/paths.js +0 -18
  50. package/dist/sdk/firmachain/amino/pubkeys.d.ts +0 -47
  51. package/dist/sdk/firmachain/amino/pubkeys.js +0 -29
  52. package/dist/sdk/firmachain/amino/secp256k1hdwallet.d.ts +0 -94
  53. package/dist/sdk/firmachain/amino/secp256k1hdwallet.js +0 -437
  54. package/dist/sdk/firmachain/amino/secp256k1wallet.d.ts +0 -23
  55. package/dist/sdk/firmachain/amino/secp256k1wallet.js +0 -141
  56. package/dist/sdk/firmachain/amino/signature.d.ts +0 -16
  57. package/dist/sdk/firmachain/amino/signature.js +0 -36
  58. package/dist/sdk/firmachain/amino/signdoc.d.ts +0 -26
  59. package/dist/sdk/firmachain/amino/signdoc.js +0 -42
  60. package/dist/sdk/firmachain/amino/signer.d.ts +0 -33
  61. package/dist/sdk/firmachain/amino/signer.js +0 -2
  62. package/dist/sdk/firmachain/amino/stdtx.d.ts +0 -15
  63. package/dist/sdk/firmachain/amino/stdtx.js +0 -17
  64. package/dist/sdk/firmachain/amino/wallet.d.ts +0 -32
  65. package/dist/sdk/firmachain/amino/wallet.js +0 -132
  66. package/dist/sdk/firmachain/bank/BankQueryClient.d.ts +0 -12
  67. package/dist/sdk/firmachain/bank/BankQueryClient.js +0 -116
  68. package/dist/sdk/firmachain/bank/BankTxClient.d.ts +0 -17
  69. package/dist/sdk/firmachain/bank/BankTxClient.js +0 -40
  70. package/dist/sdk/firmachain/bank/index.d.ts +0 -3
  71. package/dist/sdk/firmachain/bank/index.js +0 -15
  72. package/dist/sdk/firmachain/common/ITxClient.d.ts +0 -15
  73. package/dist/sdk/firmachain/common/ITxClient.js +0 -102
  74. package/dist/sdk/firmachain/common/LedgerSigningStargateClient.d.ts +0 -27
  75. package/dist/sdk/firmachain/common/LedgerSigningStargateClient.js +0 -165
  76. package/dist/sdk/firmachain/common/LedgerWallet.d.ts +0 -14
  77. package/dist/sdk/firmachain/common/LedgerWallet.js +0 -147
  78. package/dist/sdk/firmachain/common/QueryCommon.d.ts +0 -4
  79. package/dist/sdk/firmachain/common/QueryCommon.js +0 -2
  80. package/dist/sdk/firmachain/common/TendermintQueryClient.d.ts +0 -42
  81. package/dist/sdk/firmachain/common/TendermintQueryClient.js +0 -111
  82. package/dist/sdk/firmachain/common/TxCommon.d.ts +0 -87
  83. package/dist/sdk/firmachain/common/TxCommon.js +0 -18
  84. package/dist/sdk/firmachain/common/accounts.d.ts +0 -16
  85. package/dist/sdk/firmachain/common/accounts.js +0 -64
  86. package/dist/sdk/firmachain/common/index.d.ts +0 -2
  87. package/dist/sdk/firmachain/common/index.js +0 -14
  88. package/dist/sdk/firmachain/common/signing.d.ts +0 -10
  89. package/dist/sdk/firmachain/common/signing.js +0 -75
  90. package/dist/sdk/firmachain/common/signingstargateclient.d.ts +0 -37
  91. package/dist/sdk/firmachain/common/signingstargateclient.js +0 -298
  92. package/dist/sdk/firmachain/common/stargateclient.d.ts +0 -46
  93. package/dist/sdk/firmachain/common/stargateclient.js +0 -211
  94. package/dist/sdk/firmachain/contract/ContractQueryClient.d.ts +0 -32
  95. package/dist/sdk/firmachain/contract/ContractQueryClient.js +0 -156
  96. package/dist/sdk/firmachain/contract/ContractTxClient.d.ts +0 -17
  97. package/dist/sdk/firmachain/contract/ContractTxClient.js +0 -40
  98. package/dist/sdk/firmachain/contract/ContractTxTypes.d.ts +0 -69
  99. package/dist/sdk/firmachain/contract/ContractTxTypes.js +0 -483
  100. package/dist/sdk/firmachain/contract/index.d.ts +0 -3
  101. package/dist/sdk/firmachain/contract/index.js +0 -15
  102. package/dist/sdk/firmachain/distribution/DistributionQueryClient.d.ts +0 -18
  103. package/dist/sdk/firmachain/distribution/DistributionQueryClient.js +0 -167
  104. package/dist/sdk/firmachain/distribution/DistributionTxClient.d.ts +0 -27
  105. package/dist/sdk/firmachain/distribution/DistributionTxClient.js +0 -48
  106. package/dist/sdk/firmachain/distribution/index.d.ts +0 -3
  107. package/dist/sdk/firmachain/distribution/index.js +0 -15
  108. package/dist/sdk/firmachain/feegrant/FeeGrantQueryClient.d.ts +0 -17
  109. package/dist/sdk/firmachain/feegrant/FeeGrantQueryClient.js +0 -86
  110. package/dist/sdk/firmachain/feegrant/FeeGrantTxClient.d.ts +0 -17
  111. package/dist/sdk/firmachain/feegrant/FeeGrantTxClient.js +0 -40
  112. package/dist/sdk/firmachain/feegrant/FeeGrantTxTypes.d.ts +0 -76
  113. package/dist/sdk/firmachain/feegrant/FeeGrantTxTypes.js +0 -194
  114. package/dist/sdk/firmachain/feegrant/index.d.ts +0 -2
  115. package/dist/sdk/firmachain/feegrant/index.js +0 -15
  116. package/dist/sdk/firmachain/google/protobuf/any.d.ts +0 -128
  117. package/dist/sdk/firmachain/google/protobuf/any.js +0 -106
  118. package/dist/sdk/firmachain/google/protobuf/descriptor.d.ts +0 -996
  119. package/dist/sdk/firmachain/google/protobuf/descriptor.js +0 -5329
  120. package/dist/sdk/firmachain/google/protobuf/duration.d.ts +0 -91
  121. package/dist/sdk/firmachain/google/protobuf/duration.js +0 -107
  122. package/dist/sdk/firmachain/google/protobuf/timestamp.d.ts +0 -109
  123. package/dist/sdk/firmachain/google/protobuf/timestamp.js +0 -107
  124. package/dist/sdk/firmachain/gov/GovQueryClient.d.ts +0 -61
  125. package/dist/sdk/firmachain/gov/GovQueryClient.js +0 -152
  126. package/dist/sdk/firmachain/gov/GovTxClient.d.ts +0 -22
  127. package/dist/sdk/firmachain/gov/GovTxClient.js +0 -44
  128. package/dist/sdk/firmachain/gov/index.d.ts +0 -3
  129. package/dist/sdk/firmachain/gov/index.js +0 -15
  130. package/dist/sdk/firmachain/nft/NftQueryClient.d.ts +0 -20
  131. package/dist/sdk/firmachain/nft/NftQueryClient.js +0 -125
  132. package/dist/sdk/firmachain/nft/NftTxClient.d.ts +0 -22
  133. package/dist/sdk/firmachain/nft/NftTxClient.js +0 -44
  134. package/dist/sdk/firmachain/nft/NftTxTypes.d.ts +0 -86
  135. package/dist/sdk/firmachain/nft/NftTxTypes.js +0 -424
  136. package/dist/sdk/firmachain/nft/index.d.ts +0 -3
  137. package/dist/sdk/firmachain/nft/index.js +0 -15
  138. package/dist/sdk/firmachain/slashing/SlashingQueryClient.d.ts +0 -22
  139. package/dist/sdk/firmachain/slashing/SlashingQueryClient.js +0 -101
  140. package/dist/sdk/firmachain/slashing/index.d.ts +0 -2
  141. package/dist/sdk/firmachain/slashing/index.js +0 -14
  142. package/dist/sdk/firmachain/staking/StakingQueryClient.d.ts +0 -93
  143. package/dist/sdk/firmachain/staking/StakingQueryClient.js +0 -223
  144. package/dist/sdk/firmachain/staking/StakingTxClient.d.ts +0 -32
  145. package/dist/sdk/firmachain/staking/StakingTxClient.js +0 -52
  146. package/dist/sdk/firmachain/staking/index.d.ts +0 -3
  147. package/dist/sdk/firmachain/staking/index.js +0 -15
  148. package/dist/sdk/firmachain/token/TokenQueryClient.d.ts +0 -24
  149. package/dist/sdk/firmachain/token/TokenQueryClient.js +0 -106
  150. package/dist/sdk/firmachain/token/TokenTxClient.d.ts +0 -27
  151. package/dist/sdk/firmachain/token/TokenTxClient.js +0 -48
  152. package/dist/sdk/firmachain/token/TokenTxTypes.d.ts +0 -116
  153. package/dist/sdk/firmachain/token/TokenTxTypes.js +0 -685
  154. package/dist/sdk/firmachain/token/index.d.ts +0 -3
  155. package/dist/sdk/firmachain/token/index.js +0 -15
@@ -1,234 +0,0 @@
1
- "use strict";
2
- var __read = (this && this.__read) || function (o, n) {
3
- var m = typeof Symbol === "function" && o[Symbol.iterator];
4
- if (!m) return o;
5
- var i = m.call(o), r, ar = [], e;
6
- try {
7
- while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
8
- }
9
- catch (error) { e = { error: error }; }
10
- finally {
11
- try {
12
- if (r && !r.done && (m = i["return"])) m.call(i);
13
- }
14
- finally { if (e) throw e.error; }
15
- }
16
- return ar;
17
- };
18
- var __spreadArray = (this && this.__spreadArray) || function (to, from) {
19
- for (var i = 0, il = from.length, j = to.length; i < il; i++, j++)
20
- to[j] = from[i];
21
- return to;
22
- };
23
- var __values = (this && this.__values) || function(o) {
24
- var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
25
- if (m) return m.call(o);
26
- if (o && typeof o.length === "number") return {
27
- next: function () {
28
- if (o && i >= o.length) o = void 0;
29
- return { value: o && o[i++], done: !o };
30
- }
31
- };
32
- throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
33
- };
34
- Object.defineProperty(exports, "__esModule", { value: true });
35
- exports.encodeBech32Pubkey = exports.encodeAminoPubkey = exports.decodeBech32Pubkey = exports.decodeAminoPubkey = exports.encodeSecp256k1Pubkey = void 0;
36
- var encoding_1 = require("@cosmjs/encoding");
37
- var math_1 = require("@cosmjs/math");
38
- var utils_1 = require("@cosmjs/utils");
39
- var pubkeys_1 = require("./pubkeys");
40
- function encodeSecp256k1Pubkey(pubkey) {
41
- if (pubkey.length !== 33 || (pubkey[0] !== 0x02 && pubkey[0] !== 0x03)) {
42
- throw new Error("Public key must be compressed secp256k1, i.e. 33 bytes starting with 0x02 or 0x03");
43
- }
44
- return {
45
- type: pubkeys_1.pubkeyType.secp256k1,
46
- value: encoding_1.toBase64(pubkey),
47
- };
48
- }
49
- exports.encodeSecp256k1Pubkey = encodeSecp256k1Pubkey;
50
- // As discussed in https://github.com/binance-chain/javascript-sdk/issues/163
51
- // Prefixes listed here: https://github.com/tendermint/tendermint/blob/d419fffe18531317c28c29a292ad7d253f6cafdf/docs/spec/blockchain/encoding.md#public-key-cryptography
52
- // Last bytes is varint-encoded length prefix
53
- var pubkeyAminoPrefixSecp256k1 = encoding_1.fromHex("eb5ae987" + "21" /* fixed length */);
54
- var pubkeyAminoPrefixEd25519 = encoding_1.fromHex("1624de64" + "20" /* fixed length */);
55
- var pubkeyAminoPrefixSr25519 = encoding_1.fromHex("0dfb1005" + "20" /* fixed length */);
56
- /** See https://github.com/tendermint/tendermint/commit/38b401657e4ad7a7eeb3c30a3cbf512037df3740 */
57
- var pubkeyAminoPrefixMultisigThreshold = encoding_1.fromHex("22c1f7e2" /* variable length not included */);
58
- /**
59
- * Decodes a pubkey in the Amino binary format to a type/value object.
60
- */
61
- function decodeAminoPubkey(data) {
62
- if (utils_1.arrayContentStartsWith(data, pubkeyAminoPrefixSecp256k1)) {
63
- var rest = data.slice(pubkeyAminoPrefixSecp256k1.length);
64
- if (rest.length !== 33) {
65
- throw new Error("Invalid rest data length. Expected 33 bytes (compressed secp256k1 pubkey).");
66
- }
67
- return {
68
- type: pubkeys_1.pubkeyType.secp256k1,
69
- value: encoding_1.toBase64(rest),
70
- };
71
- }
72
- else if (utils_1.arrayContentStartsWith(data, pubkeyAminoPrefixEd25519)) {
73
- var rest = data.slice(pubkeyAminoPrefixEd25519.length);
74
- if (rest.length !== 32) {
75
- throw new Error("Invalid rest data length. Expected 32 bytes (Ed25519 pubkey).");
76
- }
77
- return {
78
- type: pubkeys_1.pubkeyType.ed25519,
79
- value: encoding_1.toBase64(rest),
80
- };
81
- }
82
- else if (utils_1.arrayContentStartsWith(data, pubkeyAminoPrefixSr25519)) {
83
- var rest = data.slice(pubkeyAminoPrefixSr25519.length);
84
- if (rest.length !== 32) {
85
- throw new Error("Invalid rest data length. Expected 32 bytes (Sr25519 pubkey).");
86
- }
87
- return {
88
- type: pubkeys_1.pubkeyType.sr25519,
89
- value: encoding_1.toBase64(rest),
90
- };
91
- }
92
- else if (utils_1.arrayContentStartsWith(data, pubkeyAminoPrefixMultisigThreshold)) {
93
- // eslint-disable-next-line @typescript-eslint/no-use-before-define
94
- return decodeMultisigPubkey(data);
95
- }
96
- else {
97
- throw new Error("Unsupported public key type. Amino data starts with: " + encoding_1.toHex(data.slice(0, 5)));
98
- }
99
- }
100
- exports.decodeAminoPubkey = decodeAminoPubkey;
101
- /**
102
- * Decodes a bech32 pubkey to Amino binary, which is then decoded to a type/value object.
103
- * The bech32 prefix is ignored and discareded.
104
- *
105
- * @param bechEncoded the bech32 encoded pubkey
106
- */
107
- function decodeBech32Pubkey(bechEncoded) {
108
- var data = encoding_1.Bech32.decode(bechEncoded).data;
109
- return decodeAminoPubkey(data);
110
- }
111
- exports.decodeBech32Pubkey = decodeBech32Pubkey;
112
- /**
113
- * Uvarint decoder for Amino.
114
- * @see https://github.com/tendermint/go-amino/blob/8e779b71f40d175/decoder.go#L64-76
115
- * @returns varint as number, and bytes count occupied by varaint
116
- */
117
- function decodeUvarint(reader) {
118
- if (reader.length < 1) {
119
- throw new Error("Can't decode varint. EOF");
120
- }
121
- if (reader[0] > 127) {
122
- throw new Error("Decoding numbers > 127 is not supported here. Please tell those lazy CosmJS maintainers to port the binary.Varint implementation from the Go standard library and write some tests.");
123
- }
124
- return [reader[0], 1];
125
- }
126
- /**
127
- * Decodes a multisig pubkey to type object.
128
- * Pubkey structure [ prefix + const + threshold + loop:(const + pubkeyLength + pubkey ) ]
129
- * [ 4b + 1b + varint + loop:(1b + varint + pubkeyLength bytes) ]
130
- * @param data encoded pubkey
131
- */
132
- function decodeMultisigPubkey(data) {
133
- var reader = Array.from(data);
134
- // remove multisig amino prefix;
135
- var prefixFromReader = reader.splice(0, pubkeyAminoPrefixMultisigThreshold.length);
136
- if (!utils_1.arrayContentStartsWith(prefixFromReader, pubkeyAminoPrefixMultisigThreshold)) {
137
- throw new Error("Invalid multisig prefix.");
138
- }
139
- // remove 0x08 threshold prefix;
140
- if (reader.shift() != 0x08) {
141
- throw new Error("Invalid multisig data. Expecting 0x08 prefix before threshold.");
142
- }
143
- // read threshold
144
- var _a = __read(decodeUvarint(reader), 2), threshold = _a[0], thresholdBytesLength = _a[1];
145
- reader.splice(0, thresholdBytesLength);
146
- // read participants pubkeys
147
- var pubkeys = [];
148
- while (reader.length > 0) {
149
- // remove 0x12 threshold prefix;
150
- if (reader.shift() != 0x12) {
151
- throw new Error("Invalid multisig data. Expecting 0x12 prefix before participant pubkey length.");
152
- }
153
- // read pubkey length
154
- var _b = __read(decodeUvarint(reader), 2), pubkeyLength = _b[0], pubkeyLengthBytesSize = _b[1];
155
- reader.splice(0, pubkeyLengthBytesSize);
156
- // verify that we can read pubkey
157
- if (reader.length < pubkeyLength) {
158
- throw new Error("Invalid multisig data length.");
159
- }
160
- // read and decode participant pubkey
161
- var encodedPubkey = reader.splice(0, pubkeyLength);
162
- var pubkey = decodeAminoPubkey(Uint8Array.from(encodedPubkey));
163
- pubkeys.push(pubkey);
164
- }
165
- return {
166
- type: pubkeys_1.pubkeyType.multisigThreshold,
167
- value: {
168
- threshold: threshold.toString(),
169
- pubkeys: pubkeys,
170
- },
171
- };
172
- }
173
- /**
174
- * Uvarint encoder for Amino. This is the same encoding as `binary.PutUvarint` from the Go
175
- * standard library.
176
- *
177
- * @see https://github.com/tendermint/go-amino/blob/8e779b71f40d175/encoder.go#L77-L85
178
- */
179
- function encodeUvarint(value) {
180
- var checked = math_1.Uint53.fromString(value.toString()).toNumber();
181
- if (checked > 127) {
182
- throw new Error("Encoding numbers > 127 is not supported here. Please tell those lazy CosmJS maintainers to port the binary.PutUvarint implementation from the Go standard library and write some tests.");
183
- }
184
- return [checked];
185
- }
186
- /**
187
- * Encodes a public key to binary Amino.
188
- */
189
- function encodeAminoPubkey(pubkey) {
190
- var e_1, _a;
191
- if (pubkeys_1.isMultisigThresholdPubkey(pubkey)) {
192
- var out = Array.from(pubkeyAminoPrefixMultisigThreshold);
193
- out.push(0x08); // TODO: What is this?
194
- out.push.apply(// TODO: What is this?
195
- out, __spreadArray([], __read(encodeUvarint(pubkey.value.threshold))));
196
- try {
197
- for (var _b = __values(pubkey.value.pubkeys.map(function (p) { return encodeAminoPubkey(p); })), _c = _b.next(); !_c.done; _c = _b.next()) {
198
- var pubkeyData = _c.value;
199
- out.push(0x12); // TODO: What is this?
200
- out.push.apply(// TODO: What is this?
201
- out, __spreadArray([], __read(encodeUvarint(pubkeyData.length))));
202
- out.push.apply(out, __spreadArray([], __read(pubkeyData)));
203
- }
204
- }
205
- catch (e_1_1) { e_1 = { error: e_1_1 }; }
206
- finally {
207
- try {
208
- if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
209
- }
210
- finally { if (e_1) throw e_1.error; }
211
- }
212
- return new Uint8Array(out);
213
- }
214
- else if (pubkeys_1.isEd25519Pubkey(pubkey)) {
215
- return new Uint8Array(__spreadArray(__spreadArray([], __read(pubkeyAminoPrefixEd25519)), __read(encoding_1.fromBase64(pubkey.value))));
216
- }
217
- else if (pubkeys_1.isSecp256k1Pubkey(pubkey)) {
218
- return new Uint8Array(__spreadArray(__spreadArray([], __read(pubkeyAminoPrefixSecp256k1)), __read(encoding_1.fromBase64(pubkey.value))));
219
- }
220
- else {
221
- throw new Error("Unsupported pubkey type");
222
- }
223
- }
224
- exports.encodeAminoPubkey = encodeAminoPubkey;
225
- /**
226
- * Encodes a public key to binary Amino and then to bech32.
227
- *
228
- * @param pubkey the public key to encode
229
- * @param prefix the bech32 prefix (human readable part)
230
- */
231
- function encodeBech32Pubkey(pubkey, prefix) {
232
- return encoding_1.Bech32.encode(prefix, encodeAminoPubkey(pubkey));
233
- }
234
- exports.encodeBech32Pubkey = encodeBech32Pubkey;
@@ -1,10 +0,0 @@
1
- import { MultisigThresholdPubkey, SinglePubkey } from "./pubkeys";
2
- /**
3
- * Compare arrays lexicographically.
4
- *
5
- * Returns value < 0 if `a < b`.
6
- * Returns value > 0 if `a > b`.
7
- * Returns 0 if `a === b`.
8
- */
9
- export declare function compareArrays(a: Uint8Array, b: Uint8Array): number;
10
- export declare function createMultisigThresholdPubkey(pubkeys: readonly SinglePubkey[], threshold: number, nosort?: boolean): MultisigThresholdPubkey;
@@ -1,42 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.createMultisigThresholdPubkey = exports.compareArrays = void 0;
4
- var encoding_1 = require("@cosmjs/encoding");
5
- var math_1 = require("@cosmjs/math");
6
- var addresses_1 = require("./addresses");
7
- /**
8
- * Compare arrays lexicographically.
9
- *
10
- * Returns value < 0 if `a < b`.
11
- * Returns value > 0 if `a > b`.
12
- * Returns 0 if `a === b`.
13
- */
14
- function compareArrays(a, b) {
15
- var aHex = encoding_1.toHex(a);
16
- var bHex = encoding_1.toHex(b);
17
- return aHex === bHex ? 0 : aHex < bHex ? -1 : 1;
18
- }
19
- exports.compareArrays = compareArrays;
20
- function createMultisigThresholdPubkey(pubkeys, threshold, nosort) {
21
- if (nosort === void 0) { nosort = false; }
22
- var uintThreshold = new math_1.Uint53(threshold);
23
- if (uintThreshold.toNumber() > pubkeys.length) {
24
- throw new Error("Threshold k = " + uintThreshold.toNumber() + " exceeds number of keys n = " + pubkeys.length);
25
- }
26
- var outPubkeys = nosort
27
- ? pubkeys
28
- : Array.from(pubkeys).sort(function (lhs, rhs) {
29
- // https://github.com/cosmos/cosmos-sdk/blob/v0.42.2/client/keys/add.go#L172-L174
30
- var addressLhs = addresses_1.pubkeyToRawAddress(lhs);
31
- var addressRhs = addresses_1.pubkeyToRawAddress(rhs);
32
- return compareArrays(addressLhs, addressRhs);
33
- });
34
- return {
35
- type: "tendermint/PubKeyMultisigThreshold",
36
- value: {
37
- threshold: uintThreshold.toString(),
38
- pubkeys: outPubkeys,
39
- },
40
- };
41
- }
42
- exports.createMultisigThresholdPubkey = createMultisigThresholdPubkey;
@@ -1,6 +0,0 @@
1
- import { HdPath } from "@cosmjs/crypto";
2
- /**
3
- * The Cosmos Hub derivation path in the form `m/44'/118'/0'/0/a`
4
- * with 0-based account index `a`.
5
- */
6
- export declare function makeCosmoshubPath(a: number): HdPath;
@@ -1,18 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.makeCosmoshubPath = void 0;
4
- var crypto_1 = require("@cosmjs/crypto");
5
- /**
6
- * The Cosmos Hub derivation path in the form `m/44'/118'/0'/0/a`
7
- * with 0-based account index `a`.
8
- */
9
- function makeCosmoshubPath(a) {
10
- return [
11
- crypto_1.Slip10RawIndex.hardened(44),
12
- crypto_1.Slip10RawIndex.hardened(118),
13
- crypto_1.Slip10RawIndex.hardened(0),
14
- crypto_1.Slip10RawIndex.normal(0),
15
- crypto_1.Slip10RawIndex.normal(a),
16
- ];
17
- }
18
- exports.makeCosmoshubPath = makeCosmoshubPath;
@@ -1,47 +0,0 @@
1
- export interface Pubkey {
2
- readonly type: string;
3
- readonly value: any;
4
- }
5
- export interface Ed25519Pubkey extends SinglePubkey {
6
- readonly type: "tendermint/PubKeyEd25519";
7
- readonly value: string;
8
- }
9
- export declare function isEd25519Pubkey(pubkey: Pubkey): pubkey is Ed25519Pubkey;
10
- export interface Secp256k1Pubkey extends SinglePubkey {
11
- readonly type: "tendermint/PubKeySecp256k1";
12
- readonly value: string;
13
- }
14
- export declare function isSecp256k1Pubkey(pubkey: Pubkey): pubkey is Secp256k1Pubkey;
15
- export declare const pubkeyType: {
16
- /** @see https://github.com/tendermint/tendermint/blob/v0.33.0/crypto/ed25519/ed25519.go#L22 */
17
- secp256k1: "tendermint/PubKeySecp256k1";
18
- /** @see https://github.com/tendermint/tendermint/blob/v0.33.0/crypto/secp256k1/secp256k1.go#L23 */
19
- ed25519: "tendermint/PubKeyEd25519";
20
- /** @see https://github.com/tendermint/tendermint/blob/v0.33.0/crypto/sr25519/codec.go#L12 */
21
- sr25519: "tendermint/PubKeySr25519";
22
- multisigThreshold: "tendermint/PubKeyMultisigThreshold";
23
- };
24
- /**
25
- * A pubkey which contains the data directly without further nesting.
26
- *
27
- * You can think of this as a non-multisig pubkey.
28
- */
29
- export interface SinglePubkey extends Pubkey {
30
- readonly type: string;
31
- /**
32
- * The base64 encoding of the Amino binary encoded pubkey.
33
- *
34
- * Note: if type is Secp256k1, this must contain a 33 bytes compressed pubkey.
35
- */
36
- readonly value: string;
37
- }
38
- export declare function isSinglePubkey(pubkey: Pubkey): pubkey is SinglePubkey;
39
- export interface MultisigThresholdPubkey extends Pubkey {
40
- readonly type: "tendermint/PubKeyMultisigThreshold";
41
- readonly value: {
42
- /** A string-encoded integer */
43
- readonly threshold: string;
44
- readonly pubkeys: readonly SinglePubkey[];
45
- };
46
- }
47
- export declare function isMultisigThresholdPubkey(pubkey: Pubkey): pubkey is MultisigThresholdPubkey;
@@ -1,29 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.isMultisigThresholdPubkey = exports.isSinglePubkey = exports.pubkeyType = exports.isSecp256k1Pubkey = exports.isEd25519Pubkey = void 0;
4
- function isEd25519Pubkey(pubkey) {
5
- return pubkey.type === "tendermint/PubKeyEd25519";
6
- }
7
- exports.isEd25519Pubkey = isEd25519Pubkey;
8
- function isSecp256k1Pubkey(pubkey) {
9
- return pubkey.type === "tendermint/PubKeySecp256k1";
10
- }
11
- exports.isSecp256k1Pubkey = isSecp256k1Pubkey;
12
- exports.pubkeyType = {
13
- /** @see https://github.com/tendermint/tendermint/blob/v0.33.0/crypto/ed25519/ed25519.go#L22 */
14
- secp256k1: "tendermint/PubKeySecp256k1",
15
- /** @see https://github.com/tendermint/tendermint/blob/v0.33.0/crypto/secp256k1/secp256k1.go#L23 */
16
- ed25519: "tendermint/PubKeyEd25519",
17
- /** @see https://github.com/tendermint/tendermint/blob/v0.33.0/crypto/sr25519/codec.go#L12 */
18
- sr25519: "tendermint/PubKeySr25519",
19
- multisigThreshold: "tendermint/PubKeyMultisigThreshold",
20
- };
21
- function isSinglePubkey(pubkey) {
22
- var singPubkeyTypes = [exports.pubkeyType.ed25519, exports.pubkeyType.secp256k1, exports.pubkeyType.sr25519];
23
- return singPubkeyTypes.includes(pubkey.type);
24
- }
25
- exports.isSinglePubkey = isSinglePubkey;
26
- function isMultisigThresholdPubkey(pubkey) {
27
- return pubkey.type === "tendermint/PubKeyMultisigThreshold";
28
- }
29
- exports.isMultisigThresholdPubkey = isMultisigThresholdPubkey;
@@ -1,94 +0,0 @@
1
- import { EnglishMnemonic, HdPath } from "@cosmjs/crypto";
2
- import { StdSignDoc } from "./signdoc";
3
- import { AccountData, AminoSignResponse, OfflineAminoSigner } from "./signer";
4
- import { EncryptionConfiguration, KdfConfiguration } from "./wallet";
5
- /**
6
- * This interface describes a JSON object holding the encrypted wallet and the meta data.
7
- * All fields in here must be JSON types.
8
- */
9
- export interface Secp256k1HdWalletSerialization {
10
- /** A format+version identifier for this serialization format */
11
- readonly type: string;
12
- /** Information about the key derivation function (i.e. password to encryption key) */
13
- readonly kdf: KdfConfiguration;
14
- /** Information about the symmetric encryption */
15
- readonly encryption: EncryptionConfiguration;
16
- /** An instance of Secp256k1HdWalletData, which is stringified, encrypted and base64 encoded. */
17
- readonly data: string;
18
- }
19
- export declare function extractKdfConfiguration(serialization: string): KdfConfiguration;
20
- export interface Secp256k1HdWalletOptions {
21
- /** The password to use when deriving a BIP39 seed from a mnemonic. */
22
- readonly bip39Password: string;
23
- /** The BIP-32/SLIP-10 derivation paths. Defaults to the Cosmos Hub/ATOM path `m/44'/118'/0'/0/0`. */
24
- readonly hdPaths: readonly HdPath[];
25
- /** The bech32 address prefix (human readable part). Defaults to "cosmos". */
26
- readonly prefix: string;
27
- }
28
- interface Secp256k1HdWalletConstructorOptions extends Partial<Secp256k1HdWalletOptions> {
29
- readonly seed: Uint8Array;
30
- }
31
- export declare class Secp256k1HdWallet implements OfflineAminoSigner {
32
- /**
33
- * Restores a wallet from the given BIP39 mnemonic.
34
- *
35
- * @param mnemonic Any valid English mnemonic.
36
- * @param options An optional `Secp256k1HdWalletOptions` object optionally containing a bip39Password, hdPaths, and prefix.
37
- */
38
- static fromMnemonic(mnemonic: string, options?: Partial<Secp256k1HdWalletOptions>): Promise<Secp256k1HdWallet>;
39
- /**
40
- * Generates a new wallet with a BIP39 mnemonic of the given length.
41
- *
42
- * @param length The number of words in the mnemonic (12, 15, 18, 21 or 24).
43
- * @param options An optional `Secp256k1HdWalletOptions` object optionally containing a bip39Password, hdPaths, and prefix.
44
- */
45
- static generate(length?: 12 | 15 | 18 | 21 | 24, options?: Partial<Secp256k1HdWalletOptions>): Promise<Secp256k1HdWallet>;
46
- /**
47
- * Restores a wallet from an encrypted serialization.
48
- *
49
- * @param password The user provided password used to generate an encryption key via a KDF.
50
- * This is not normalized internally (see "Unicode normalization" to learn more).
51
- */
52
- static deserialize(serialization: string, password: string): Promise<Secp256k1HdWallet>;
53
- /**
54
- * Restores a wallet from an encrypted serialization.
55
- *
56
- * This is an advanced alternative to calling `deserialize(serialization, password)` directly, which allows
57
- * you to offload the KDF execution to a non-UI thread (e.g. in a WebWorker).
58
- *
59
- * The caller is responsible for ensuring the key was derived with the given KDF configuration. This can be
60
- * done using `extractKdfConfiguration(serialization)` and `executeKdf(password, kdfConfiguration)` from this package.
61
- */
62
- static deserializeWithEncryptionKey(serialization: string, encryptionKey: Uint8Array): Promise<Secp256k1HdWallet>;
63
- private static deserializeTypeV1;
64
- /** Base secret */
65
- private readonly secret;
66
- /** BIP39 seed */
67
- private readonly seed;
68
- /** Derivation instruction */
69
- private readonly accounts;
70
- protected constructor(mnemonic: EnglishMnemonic, options: Secp256k1HdWalletConstructorOptions);
71
- get mnemonic(): string;
72
- getAccounts(): Promise<readonly AccountData[]>;
73
- signAmino(signerAddress: string, signDoc: StdSignDoc): Promise<AminoSignResponse>;
74
- /**
75
- * Generates an encrypted serialization of this wallet.
76
- *
77
- * @param password The user provided password used to generate an encryption key via a KDF.
78
- * This is not normalized internally (see "Unicode normalization" to learn more).
79
- */
80
- serialize(password: string): Promise<string>;
81
- /**
82
- * Generates an encrypted serialization of this wallet.
83
- *
84
- * This is an advanced alternative to calling `serialize(password)` directly, which allows you to
85
- * offload the KDF execution to a non-UI thread (e.g. in a WebWorker).
86
- *
87
- * The caller is responsible for ensuring the key was derived with the given KDF options. If this
88
- * is not the case, the wallet cannot be restored with the original password.
89
- */
90
- serializeWithEncryptionKey(encryptionKey: Uint8Array, kdfConfiguration: KdfConfiguration): Promise<string>;
91
- private getKeyPair;
92
- private getAccountsWithPrivkeys;
93
- }
94
- export {};