Skip to content

Commit 429c789

Browse files
author
Fabrice Bascoulergue
committed
Update core lib and adapte codebase accordingly
1 parent 69255ff commit 429c789

File tree

3 files changed

+101
-89
lines changed

3 files changed

+101
-89
lines changed

package.json

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -40,13 +40,13 @@
4040
"postdefine-proto": "prettier --write \"src/codec/**/*.ts\""
4141
},
4242
"dependencies": {
43-
"@cosmjs/crypto": "^0.24.0-alpha.25",
44-
"@cosmjs/encoding": "^0.24.0-alpha.25",
45-
"@cosmjs/math": "^0.24.0-alpha.25",
46-
"@cosmjs/proto-signing": "^0.24.0-alpha.25",
47-
"@cosmjs/stargate": "^0.24.0-alpha.25",
48-
"@cosmjs/tendermint-rpc": "^0.24.0-alpha.25",
49-
"@cosmjs/utils": "^0.23.2",
43+
"@cosmjs/crypto": "^0.24.0-alpha.26",
44+
"@cosmjs/encoding": "^0.24.0-alpha.26",
45+
"@cosmjs/math": "^0.24.0-alpha.26",
46+
"@cosmjs/proto-signing": "^0.24.0-alpha.26",
47+
"@cosmjs/stargate": "^0.24.0-alpha.26",
48+
"@cosmjs/tendermint-rpc": "^0.24.0-alpha.26",
49+
"@cosmjs/utils": "^0.24.0-alpha.26",
5050
"@types/uuid": "^8.3.0",
5151
"crypto-browserify": "^3.12.0",
5252
"crypto-js": "^4.0.0",

src/client/LumClient.ts

Lines changed: 25 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { Uint64 } from '@cosmjs/math';
2-
import { Client as TendermintClient, adaptor34 as TendermintAdaptor, StatusResponse } from '@cosmjs/tendermint-rpc';
2+
import { Tendermint34Client, StatusResponse } from '@cosmjs/tendermint-rpc';
33
import {
44
QueryClient as StargateQueryClient,
55
setupAuthExtension as StargateSetupAuthExtension,
@@ -19,7 +19,7 @@ import { sha256, generateAuthInfo, generateSignDoc, generateSignDocBytes, genera
1919
import { BroadcastTxCommitResponse, ValidatorsResponse, TxResponse, TxSearchParams, BlockResponse, Account, Coin, Fee } from '../types';
2020

2121
export class LumClient {
22-
readonly tmClient: TendermintClient;
22+
readonly tmClient: Tendermint34Client;
2323
readonly queryClient: StargateQueryClient & AuthExtension & BankExtension & DistributionExtension & StakingExtension;
2424
private chainId?: string;
2525

@@ -28,9 +28,24 @@ export class LumClient {
2828
*
2929
* @param tmClient tendermint RPC client
3030
*/
31-
constructor(tmClient: TendermintClient) {
31+
constructor(tmClient: Tendermint34Client) {
3232
this.tmClient = tmClient;
3333
this.queryClient = StargateQueryClient.withExtensions(tmClient, StargateSetupAuthExtension, StargateSetupBankExtension, StargateDistributionExtension, StargateStakingExtension);
34+
35+
// Used for debugging while gasWanted, gasUsed and codespace are still waiting to be included in the code lib
36+
// // @ts-ignore
37+
// this.tmClient.r.decodeTx = (data) => {
38+
// const res = adaptor34.responses.decodeTx(data);
39+
// if (res && res.result) {
40+
// // @ts-ignore
41+
// res.result.gasWanted = Int53.fromString(data.result.tx_result.gas_wanted || '0').toNumber();
42+
// // @ts-ignore
43+
// res.result.gasUsed = Int53.fromString(data.result.tx_result.gas_used || '0').toNumber();
44+
// // @ts-ignore
45+
// res.result.codespace = data.result.tx_result.codespace;
46+
// }
47+
// return res;
48+
// };
3449
}
3550

3651
/**
@@ -40,7 +55,7 @@ export class LumClient {
4055
* @param endpoint Blockchain node RPC url
4156
*/
4257
static connect = async (endpoint: string): Promise<LumClient> => {
43-
const tmClient = await TendermintClient.connect(endpoint, TendermintAdaptor);
58+
const tmClient = await Tendermint34Client.connect(endpoint);
4459
return new LumClient(tmClient);
4560
};
4661

@@ -177,13 +192,15 @@ export class LumClient {
177192
};
178193

179194
/**
180-
* Get all validators
195+
* Get validators (paginated)
181196
* Validators are sorted first by voting power (descending), then by address (ascending)
182197
*
183198
* @param blockHeight block height to return. If no height is provided, it will fetch validator set which corresponds to the latest block
199+
* @param page page to query (defaul to 1)
200+
* @param perPage results per page (default to 30)
184201
*/
185-
getValidators = async (blockHeight?: number | undefined): Promise<ValidatorsResponse> => {
186-
const results = await this.tmClient.validators(blockHeight);
202+
getValidators = async (blockHeight?: number | undefined, page = 1, perPage = 30): Promise<ValidatorsResponse> => {
203+
const results = await this.tmClient.validators({ height: blockHeight, page: page, per_page: perPage });
187204
return results;
188205
};
189206

@@ -209,7 +226,7 @@ export class LumClient {
209226
*
210227
* @param queries queries to run (see utils/search for helpers)
211228
* @param page page to query (default to 1)
212-
* @param perPage result per pages (default to 30)
229+
* @param perPage results per pages (default to 30)
213230
* @param includeProof whether or not to include proofs of the transactions inclusion in the block
214231
*/
215232
searchTx = async (queries: string[], page = 1, perPage = 30, includeProof?: boolean): Promise<TxResponse[]> => {

yarn.lock

Lines changed: 69 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -901,14 +901,14 @@
901901
ripemd160 "^2.0.2"
902902
sha.js "^2.4.11"
903903

904-
"@cosmjs/crypto@^0.24.0-alpha.25":
905-
version "0.24.0-alpha.25"
906-
resolved "https://registry.yarnpkg.com/@cosmjs/crypto/-/crypto-0.24.0-alpha.25.tgz#014d454ddf91ea0a323ccbd258fc5f297b843c38"
907-
integrity sha512-0+nAi2+Sdy300vPZFzCB0tPcF/T4fGZ3VgPTdR997uPm0xz4aBiAncuJGhkw/CR0VjLgTSk1IXVNnG7+xRtjsQ==
908-
dependencies:
909-
"@cosmjs/encoding" "^0.24.0-alpha.25"
910-
"@cosmjs/math" "^0.24.0-alpha.25"
911-
"@cosmjs/utils" "^0.24.0-alpha.25"
904+
"@cosmjs/crypto@^0.24.0-alpha.26":
905+
version "0.24.0-alpha.26"
906+
resolved "https://registry.yarnpkg.com/@cosmjs/crypto/-/crypto-0.24.0-alpha.26.tgz#f26c237e52a56caa3587a8cb240399205ae34fcb"
907+
integrity sha512-JPfwV0iXqGqPyUJTw0DWDkV1acXabldkBQ4QKk2tIpnaxwS+CCXIPshTb1XoS1f6sNOvrywxiYqTaLd3uDk8xg==
908+
dependencies:
909+
"@cosmjs/encoding" "^0.24.0-alpha.26"
910+
"@cosmjs/math" "^0.24.0-alpha.26"
911+
"@cosmjs/utils" "^0.24.0-alpha.26"
912912
bip39 "^3.0.2"
913913
bn.js "^4.11.8"
914914
elliptic "^6.5.3"
@@ -919,108 +919,103 @@
919919
sha.js "^2.4.11"
920920
unorm "^1.5.0"
921921

922-
"@cosmjs/encoding@^0.24.0-alpha.25":
923-
version "0.24.0-alpha.25"
924-
resolved "https://registry.yarnpkg.com/@cosmjs/encoding/-/encoding-0.24.0-alpha.25.tgz#ffd1170452ad1496d5352a0d2f4804f69ee3647d"
925-
integrity sha512-GzatT6a3AJ37+aMM3SrfLgmNMwSS3kPj29y5ASqpkQnR7lALlNzNrm2p0dqf6/qOU+P3o359PHxS58M2yQwTRg==
922+
"@cosmjs/encoding@^0.24.0-alpha.26":
923+
version "0.24.0-alpha.26"
924+
resolved "https://registry.yarnpkg.com/@cosmjs/encoding/-/encoding-0.24.0-alpha.26.tgz#e2b2237f95772dd777d87f6f697749271326231a"
925+
integrity sha512-ufcVPU/FUjv421vgayjJ2kwB3PkF8WDxVLOwGYG3fTU1DXFeRyoySVn6f9eKxwA7A0ChVMeNaE8N4yNOk1hOjw==
926926
dependencies:
927927
base64-js "^1.3.0"
928928
bech32 "^1.1.4"
929929
readonly-date "^1.0.0"
930930

931-
"@cosmjs/json-rpc@^0.24.0-alpha.25":
932-
version "0.24.0-alpha.25"
933-
resolved "https://registry.yarnpkg.com/@cosmjs/json-rpc/-/json-rpc-0.24.0-alpha.25.tgz#9c2f4686d182370cc453318b49ac671543048fba"
934-
integrity sha512-x69ouHL834esXpapWqAJg0cXXDXci2AhVo8//I7ZspRSXABKAPR7Eg+V3cmc9eV+CkSvfj72t6EE2Jvc0jWbxQ==
931+
"@cosmjs/json-rpc@^0.24.0-alpha.26":
932+
version "0.24.0-alpha.26"
933+
resolved "https://registry.yarnpkg.com/@cosmjs/json-rpc/-/json-rpc-0.24.0-alpha.26.tgz#9897a671222014292f46739cfa57ec6a34b5da99"
934+
integrity sha512-XMT94aJeKhmn2A8F871G/NbYIMT+AHXEKLYKNqTW+O9M3yrn1sm3dw0J5W++mHzaX6pnXPxPfw1gp8O+wLsk7Q==
935935
dependencies:
936-
"@cosmjs/stream" "^0.24.0-alpha.25"
936+
"@cosmjs/stream" "^0.24.0-alpha.26"
937937
xstream "^11.14.0"
938938

939-
"@cosmjs/launchpad@^0.24.0-alpha.25":
940-
version "0.24.0-alpha.25"
941-
resolved "https://registry.yarnpkg.com/@cosmjs/launchpad/-/launchpad-0.24.0-alpha.25.tgz#872897d9946ea576217d1d54ebb05d30602dfd87"
942-
integrity sha512-03MKM+ZYP8EDR8xxtGuxsMjc9vc/cDG+dScj8RiOLuLEz6WkKHkTRYJ/q9Q3/BVIzELmur+yEiqwfDgPDajTFw==
939+
"@cosmjs/launchpad@^0.24.0-alpha.26":
940+
version "0.24.0-alpha.26"
941+
resolved "https://registry.yarnpkg.com/@cosmjs/launchpad/-/launchpad-0.24.0-alpha.26.tgz#4983429dc5142b75bbcfd51f126b776f103b9254"
942+
integrity sha512-cXMwsvu1TnwbTRkE5DnaRRtT99HZG8uo/+t6J1R7NzbOGd//F7TiPU4Gqa4FicW9TOrBL+AJY3VlrDEtYiTZwQ==
943943
dependencies:
944-
"@cosmjs/crypto" "^0.24.0-alpha.25"
945-
"@cosmjs/encoding" "^0.24.0-alpha.25"
946-
"@cosmjs/math" "^0.24.0-alpha.25"
947-
"@cosmjs/utils" "^0.24.0-alpha.25"
944+
"@cosmjs/crypto" "^0.24.0-alpha.26"
945+
"@cosmjs/encoding" "^0.24.0-alpha.26"
946+
"@cosmjs/math" "^0.24.0-alpha.26"
947+
"@cosmjs/utils" "^0.24.0-alpha.26"
948948
axios "^0.21.1"
949949
fast-deep-equal "^3.1.3"
950950

951-
"@cosmjs/math@^0.24.0-alpha.25":
952-
version "0.24.0-alpha.25"
953-
resolved "https://registry.yarnpkg.com/@cosmjs/math/-/math-0.24.0-alpha.25.tgz#13a2f24ef5a8a1d9d1408bdc6c785c763d92ab55"
954-
integrity sha512-KIf2n0nGD8Wa58wgeausQCMxJPISLhs85bwyTbjzAVq5os/kY1+8IoS7RLnDw/huJZHrsB4Ucj82CK+N3JR+tg==
951+
"@cosmjs/math@^0.24.0-alpha.26":
952+
version "0.24.0-alpha.26"
953+
resolved "https://registry.yarnpkg.com/@cosmjs/math/-/math-0.24.0-alpha.26.tgz#886503ef7c10533b5e96478cbcbc99fdb96d20e2"
954+
integrity sha512-bvj05U5/iBnI0Ka+uUy3OTz/sOvP3o/b1JE8s+wRPLX1Y5sh6suYyqXZvmvYw09B1zLmB+30H5Q1QPR+kPsfZA==
955955
dependencies:
956956
bn.js "^4.11.8"
957957

958-
"@cosmjs/proto-signing@^0.24.0-alpha.25":
959-
version "0.24.0-alpha.25"
960-
resolved "https://registry.yarnpkg.com/@cosmjs/proto-signing/-/proto-signing-0.24.0-alpha.25.tgz#3f08e4edb40a4a3513ab00847dd5070104c89a8e"
961-
integrity sha512-sbldY4QKQH+udyNb6buoW4D9WgTPUQWq3qnWGrLMajquZnGD4pm4bcKk3x5P3qEDl9hwEWmRNuyXZynwbDM8hg==
958+
"@cosmjs/proto-signing@^0.24.0-alpha.26":
959+
version "0.24.0-alpha.26"
960+
resolved "https://registry.yarnpkg.com/@cosmjs/proto-signing/-/proto-signing-0.24.0-alpha.26.tgz#16deaa25f2b44ae4660221bc7153f39c831ae2b0"
961+
integrity sha512-sa0iwBmiIwqwuArcpN9KUtDSPiyzpq/1ybZdH85IVn/jakxTrLCvlgYIQJReGpf5ydv9Oy4JT4c7uzf9D83HNw==
962962
dependencies:
963-
"@cosmjs/launchpad" "^0.24.0-alpha.25"
963+
"@cosmjs/launchpad" "^0.24.0-alpha.26"
964964
long "^4.0.0"
965965
protobufjs "~6.10.2"
966966

967-
"@cosmjs/socket@^0.24.0-alpha.25":
968-
version "0.24.0-alpha.25"
969-
resolved "https://registry.yarnpkg.com/@cosmjs/socket/-/socket-0.24.0-alpha.25.tgz#f5aae2c38b0a8263f511945c2abb2f99432b37ad"
970-
integrity sha512-pVYMc2GWFcTYm8hnXXyfoTN19i8048DHmOBMzv2JB7Lj4RGbBH7vkFq5KFniCcRiGjw2mwN5yfh4NjTsRM93bQ==
967+
"@cosmjs/socket@^0.24.0-alpha.26":
968+
version "0.24.0-alpha.26"
969+
resolved "https://registry.yarnpkg.com/@cosmjs/socket/-/socket-0.24.0-alpha.26.tgz#0828c239ca70d0c65282d4dd4b2191680679498b"
970+
integrity sha512-NrmguK5joNtEo+btZgu6WWP18CI06Iq4CZ1Y2P8lVv+56MUU8IhuKhjYdHfBEgwf9PMzzvGv+S0wndYpowfgoQ==
971971
dependencies:
972-
"@cosmjs/stream" "^0.24.0-alpha.25"
972+
"@cosmjs/stream" "^0.24.0-alpha.26"
973973
isomorphic-ws "^4.0.1"
974974
ws "^6.2.0"
975975
xstream "^11.14.0"
976976

977-
"@cosmjs/stargate@^0.24.0-alpha.25":
978-
version "0.24.0-alpha.25"
979-
resolved "https://registry.yarnpkg.com/@cosmjs/stargate/-/stargate-0.24.0-alpha.25.tgz#d6de498651789bcb8b54fac18f37439e10a3662d"
980-
integrity sha512-gSBJ7h5suxBjo9367bE37eb6tcXXuSHzEjzb6rLkm1MYaofBUbuuWWgEHhuFuQhqOvs/ON1eOOTC6CRrnhtuSw==
977+
"@cosmjs/stargate@^0.24.0-alpha.26":
978+
version "0.24.0-alpha.26"
979+
resolved "https://registry.yarnpkg.com/@cosmjs/stargate/-/stargate-0.24.0-alpha.26.tgz#32a0029fac00270b5ff94d68910c576d64b367bb"
980+
integrity sha512-QonmhP6SQ/bjl95fUmR4gYjdIjWESAhCpLQLCnGrLTOIdYT7fRhD7uk3ZEOEaWUo1MIuOOUJkGqoCJ2UxPCAAQ==
981981
dependencies:
982982
"@confio/ics23" "^0.6.3"
983-
"@cosmjs/encoding" "^0.24.0-alpha.25"
984-
"@cosmjs/launchpad" "^0.24.0-alpha.25"
985-
"@cosmjs/math" "^0.24.0-alpha.25"
986-
"@cosmjs/proto-signing" "^0.24.0-alpha.25"
987-
"@cosmjs/stream" "^0.24.0-alpha.25"
988-
"@cosmjs/tendermint-rpc" "^0.24.0-alpha.25"
989-
"@cosmjs/utils" "^0.24.0-alpha.25"
983+
"@cosmjs/encoding" "^0.24.0-alpha.26"
984+
"@cosmjs/launchpad" "^0.24.0-alpha.26"
985+
"@cosmjs/math" "^0.24.0-alpha.26"
986+
"@cosmjs/proto-signing" "^0.24.0-alpha.26"
987+
"@cosmjs/stream" "^0.24.0-alpha.26"
988+
"@cosmjs/tendermint-rpc" "^0.24.0-alpha.26"
989+
"@cosmjs/utils" "^0.24.0-alpha.26"
990990
long "^4.0.0"
991991
protobufjs "~6.10.2"
992992

993-
"@cosmjs/stream@^0.24.0-alpha.25":
994-
version "0.24.0-alpha.25"
995-
resolved "https://registry.yarnpkg.com/@cosmjs/stream/-/stream-0.24.0-alpha.25.tgz#605d648ad6ad4ea1413607ad531e7bc804035aa4"
996-
integrity sha512-Zlsets6gCm+vp+kjk8b/w+S8GS7VWVJMmvRkG5+HYloMwUaew4qSAUAbMM4vvvLNUUVm6Dia4cI9ZhgVcf16Dw==
993+
"@cosmjs/stream@^0.24.0-alpha.26":
994+
version "0.24.0-alpha.26"
995+
resolved "https://registry.yarnpkg.com/@cosmjs/stream/-/stream-0.24.0-alpha.26.tgz#32bb0c9d04b3dfeac232dfe7d7d1d945492746c3"
996+
integrity sha512-PviQfPIPFIdhdgDqFHu/nzPz6dzd3RVncDEH2/eNU3bUu8NG0CxYzlmGUO3PGk9XLtjJaC8qIbwwtz6Bw8fe/w==
997997
dependencies:
998998
xstream "^11.14.0"
999999

1000-
"@cosmjs/tendermint-rpc@^0.24.0-alpha.25":
1001-
version "0.24.0-alpha.25"
1002-
resolved "https://registry.yarnpkg.com/@cosmjs/tendermint-rpc/-/tendermint-rpc-0.24.0-alpha.25.tgz#1029f42fe473a9553e7aa1506d7683dbc24779de"
1003-
integrity sha512-WNgzIEyK0jGc5W9ECUdfERO7cOKOcSzX8GcfdlKtHH3aUhmzOhpJo/pJiDwsAS5B2DSYU2m6yB56psCV5+XFLA==
1004-
dependencies:
1005-
"@cosmjs/crypto" "^0.24.0-alpha.25"
1006-
"@cosmjs/encoding" "^0.24.0-alpha.25"
1007-
"@cosmjs/json-rpc" "^0.24.0-alpha.25"
1008-
"@cosmjs/math" "^0.24.0-alpha.25"
1009-
"@cosmjs/socket" "^0.24.0-alpha.25"
1010-
"@cosmjs/stream" "^0.24.0-alpha.25"
1000+
"@cosmjs/tendermint-rpc@^0.24.0-alpha.26":
1001+
version "0.24.0-alpha.26"
1002+
resolved "https://registry.yarnpkg.com/@cosmjs/tendermint-rpc/-/tendermint-rpc-0.24.0-alpha.26.tgz#2e59f50d40c66c4f8488c199e34eabf33f279969"
1003+
integrity sha512-lFHwRZaVcEmrDnWgum4EkuKe8jbfVOdNvVYbDXehKmNGY+YBIuCjevS6jERQBc6CAfPnWEKRHDzHiqmXqzh+OQ==
1004+
dependencies:
1005+
"@cosmjs/crypto" "^0.24.0-alpha.26"
1006+
"@cosmjs/encoding" "^0.24.0-alpha.26"
1007+
"@cosmjs/json-rpc" "^0.24.0-alpha.26"
1008+
"@cosmjs/math" "^0.24.0-alpha.26"
1009+
"@cosmjs/socket" "^0.24.0-alpha.26"
1010+
"@cosmjs/stream" "^0.24.0-alpha.26"
10111011
axios "^0.21.1"
10121012
readonly-date "^1.0.0"
10131013
xstream "^11.14.0"
10141014

1015-
"@cosmjs/utils@^0.23.2":
1016-
version "0.23.2"
1017-
resolved "https://registry.yarnpkg.com/@cosmjs/utils/-/utils-0.23.2.tgz#6b7365fbb2c05e12de03e6a10499bc2cfa62b072"
1018-
integrity sha512-B5GKDDZjkc6l5fBiXe+CAZYsHd+O6fx4N80xyvGIMdEDzw9NbEBdTjUlGfOH2PdaHjLPfrgUg2KslWLCGWRdjw==
1019-
1020-
"@cosmjs/utils@^0.24.0-alpha.25":
1021-
version "0.24.0-alpha.25"
1022-
resolved "https://registry.yarnpkg.com/@cosmjs/utils/-/utils-0.24.0-alpha.25.tgz#25871033bb61dd21ec13a9fe042e80a64c165195"
1023-
integrity sha512-3vhd1iur5kNLa+mtZfJd/A21Dvy11BuFgjvvmgoJ0djknzyJcnnp/AOk3EheN/mq+u9whUW9SfXcvVoT0gC7cA==
1015+
"@cosmjs/utils@^0.24.0-alpha.26":
1016+
version "0.24.0-alpha.26"
1017+
resolved "https://registry.yarnpkg.com/@cosmjs/utils/-/utils-0.24.0-alpha.26.tgz#5c3c40ef3451b8cfd6d131d3f8bdbc869340cb23"
1018+
integrity sha512-QD0A0tx71jPDHZ2avAd2MPARQ7GEiMQxY/5CkQhN6xbtTDpyMIrkjTTNxByg/S7y3ztPC+V9gk/ayrfSCFUVGQ==
10241019

10251020
"@eslint/eslintrc@^0.3.0":
10261021
version "0.3.0"

0 commit comments

Comments
 (0)