diff --git a/package.json b/package.json index e57eda77..6d250da7 100644 --- a/package.json +++ b/package.json @@ -32,16 +32,16 @@ "node": ">=12" }, "dependencies": { - "@cosmjs/cosmwasm-stargate": "^0.29.2", - "@cosmjs/crypto": "^0.29.2", - "@cosmjs/encoding": "^0.29.2", - "@cosmjs/faucet-client": "^0.29.2", - "@cosmjs/math": "^0.29.2", - "@cosmjs/proto-signing": "^0.29.2", - "@cosmjs/stargate": "^0.29.2", - "@cosmjs/stream": "^0.29.2", - "@cosmjs/tendermint-rpc": "^0.29.2", - "@cosmjs/utils": "^0.29.2", + "@cosmjs/cosmwasm-stargate": "^0.29.5", + "@cosmjs/crypto": "^0.29.5", + "@cosmjs/encoding": "^0.29.5", + "@cosmjs/faucet-client": "^0.29.5", + "@cosmjs/math": "^0.29.5", + "@cosmjs/proto-signing": "^0.29.5", + "@cosmjs/stargate": "^0.29.5", + "@cosmjs/stream": "^0.29.5", + "@cosmjs/tendermint-rpc": "^0.29.5", + "@cosmjs/utils": "^0.29.5", "ajv": "7.1.1", "axios": "0.21.4", "commander": "7.1.0", diff --git a/src/lib/ibcclient.spec.ts b/src/lib/ibcclient.spec.ts index 30f9b9dd..7bfe1296 100644 --- a/src/lib/ibcclient.spec.ts +++ b/src/lib/ibcclient.spec.ts @@ -24,6 +24,8 @@ test.serial('create gaia client on wasmd', async (t) => { const preClients = await dest.query.ibc.client.allStates(); const preLen = preClients.clientStates.length; + t.log('preLen', preLen); + t.log('preClients', preClients.clientStates); const header = await src.latestHeader(); @@ -39,7 +41,10 @@ test.serial('create gaia client on wasmd', async (t) => { await dest.waitOneBlock(); const postClients = await dest.query.ibc.client.allStates(); - t.is(postClients.clientStates.length, preLen + 1); + const postLen = postClients.clientStates.length; + t.log('postLen', postLen); + t.log('postClients', postClients); + t.is(postLen, preLen + 1); }); test.serial('create and update wasmd client on gaia', async (t) => { diff --git a/src/lib/queries/ibc.ts b/src/lib/queries/ibc.ts index 0584440b..41379f58 100644 --- a/src/lib/queries/ibc.ts +++ b/src/lib/queries/ibc.ts @@ -1,4 +1,4 @@ -import { toAscii } from '@cosmjs/encoding'; +import { fromUtf8, toAscii } from '@cosmjs/encoding'; import { createPagination, createProtobufRpcClient, @@ -465,12 +465,18 @@ export function setupIbcExtension(base: QueryClient): IbcExtension { const clientStates = []; let response: QueryClientStatesResponse; let key: Uint8Array | undefined; + let page = 1; do { response = await clientQueryService.ClientStates({ pagination: createPagination(key), }); clientStates.push(...response.clientStates); key = response.pagination?.nextKey; + console.log( + `Page ${page++}, response count: ${ + response.clientStates.length + }, next key: ${key ? fromUtf8(key, true) : undefined}` + ); } while (key && key.length); return { clientStates, diff --git a/src/lib/utils.spec.ts b/src/lib/utils.spec.ts index c5737a05..73a649fb 100644 --- a/src/lib/utils.spec.ts +++ b/src/lib/utils.spec.ts @@ -70,7 +70,7 @@ test('stringifyEvent works', (t) => { type: 'coin_spent', attributes: [ { - key: '���', + key: '\0���', value: 'juno100s45s4h94qdkcafmmrqfltlrgyqwyn6e05jx2', }, { @@ -80,13 +80,16 @@ test('stringifyEvent works', (t) => { ], }); - // Invalid valud in one attribute + // Invalid value in one attribute const event3 = stringifyEvent({ type: 'coin_spent', attributes: [ { key: fromBase64('c3BlbmRlcg=='), - value: new Uint8Array([0, 159, 146, 150]), + // https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=7c1a7f484132afdebfa19b65dab60bbd + value: new Uint8Array([ + 72, 101, 108, 108, 111, 32, 240, 144, 128, 87, 111, 114, 108, 100, + ]), }, { key: fromBase64('YW1vdW50'), @@ -99,7 +102,7 @@ test('stringifyEvent works', (t) => { attributes: [ { key: 'spender', - value: '�����', + value: 'Hello �World', }, { key: 'amount', diff --git a/src/lib/utils.ts b/src/lib/utils.ts index 169a266d..ffc6ec66 100644 --- a/src/lib/utils.ts +++ b/src/lib/utils.ts @@ -205,19 +205,10 @@ export function stringifyEvent(event: tendermint34.Event): ParsedEvent { return { type, attributes: attributes.map(({ key, value }): ParsedAttribute => { - let keyStr = '���'; - let valueStr = '�����'; - try { - keyStr = fromUtf8(key); - // eslint-disable-next-line no-empty - } catch {} - try { - valueStr = fromUtf8(value); - // eslint-disable-next-line no-empty - } catch {} return { - key: keyStr, - value: valueStr, + // Lossy UTF-8 conversion using � replacement characters + key: fromUtf8(key, true), + value: fromUtf8(value, true), }; }), }; diff --git a/yarn.lock b/yarn.lock index 4988572f..c71afddb 100644 --- a/yarn.lock +++ b/yarn.lock @@ -417,145 +417,145 @@ "@noble/hashes" "^1.0.0" protobufjs "^6.8.8" -"@cosmjs/amino@^0.29.2": - version "0.29.2" - resolved "https://registry.yarnpkg.com/@cosmjs/amino/-/amino-0.29.2.tgz#2d9f87041d4cad7da4828b96f4d51121a19763bd" - integrity sha512-59Ta3liptOPPFNclziqaScm8Uvs5iwUkEU/Nl6SRMrmRU7lOdOYbNqsBgp27Ozc5jL2d8+ML4AyrJ1S5x8jgAw== - dependencies: - "@cosmjs/crypto" "^0.29.2" - "@cosmjs/encoding" "^0.29.2" - "@cosmjs/math" "^0.29.2" - "@cosmjs/utils" "^0.29.2" - -"@cosmjs/cosmwasm-stargate@^0.29.2": - version "0.29.2" - resolved "https://registry.yarnpkg.com/@cosmjs/cosmwasm-stargate/-/cosmwasm-stargate-0.29.2.tgz#c35f2aa26f310f642a0e296b93eee53bd652771b" - integrity sha512-NC3e0QOJR0iTpexPogEDiJgQ1HIIL6fahowLmmsTO60RbnARd/gEjf5AmdJ/6I8KigN8pSqQOr9Yvu6M73/9yg== - dependencies: - "@cosmjs/amino" "^0.29.2" - "@cosmjs/crypto" "^0.29.2" - "@cosmjs/encoding" "^0.29.2" - "@cosmjs/math" "^0.29.2" - "@cosmjs/proto-signing" "^0.29.2" - "@cosmjs/stargate" "^0.29.2" - "@cosmjs/tendermint-rpc" "^0.29.2" - "@cosmjs/utils" "^0.29.2" +"@cosmjs/amino@^0.29.5": + version "0.29.5" + resolved "https://registry.yarnpkg.com/@cosmjs/amino/-/amino-0.29.5.tgz#053b4739a90b15b9e2b781ccd484faf64bd49aec" + integrity sha512-Qo8jpC0BiziTSUqpkNatBcwtKNhCovUnFul9SlT/74JUCdLYaeG5hxr3q1cssQt++l4LvlcpF+OUXL48XjNjLw== + dependencies: + "@cosmjs/crypto" "^0.29.5" + "@cosmjs/encoding" "^0.29.5" + "@cosmjs/math" "^0.29.5" + "@cosmjs/utils" "^0.29.5" + +"@cosmjs/cosmwasm-stargate@^0.29.5": + version "0.29.5" + resolved "https://registry.yarnpkg.com/@cosmjs/cosmwasm-stargate/-/cosmwasm-stargate-0.29.5.tgz#3f257da682658833e0f4eb9e8ff758e4d927663a" + integrity sha512-TNdSvm2tEE3XMCuxHxquzls56t40hC8qnLeYJWHsY2ECZmRK3KrnpRReEr7N7bLtODToK7X/riYrV0JaYxjrYA== + dependencies: + "@cosmjs/amino" "^0.29.5" + "@cosmjs/crypto" "^0.29.5" + "@cosmjs/encoding" "^0.29.5" + "@cosmjs/math" "^0.29.5" + "@cosmjs/proto-signing" "^0.29.5" + "@cosmjs/stargate" "^0.29.5" + "@cosmjs/tendermint-rpc" "^0.29.5" + "@cosmjs/utils" "^0.29.5" cosmjs-types "^0.5.2" long "^4.0.0" pako "^2.0.2" -"@cosmjs/crypto@^0.29.2": - version "0.29.2" - resolved "https://registry.yarnpkg.com/@cosmjs/crypto/-/crypto-0.29.2.tgz#63308d8c91ade0de73861ef1e5099cba26db5d1b" - integrity sha512-mm4BNiuLAvfJOPYilP8uCs4MKJIogri2A5jb0xn+ZiyFTdIw6xp5eLU7SLxI/V+F2VMPfQDNfS+syPEkDN7g/w== +"@cosmjs/crypto@^0.29.5": + version "0.29.5" + resolved "https://registry.yarnpkg.com/@cosmjs/crypto/-/crypto-0.29.5.tgz#ab99fc382b93d8a8db075780cf07487a0f9519fd" + integrity sha512-2bKkaLGictaNL0UipQCL6C1afaisv6k8Wr/GCLx9FqiyFkh9ZgRHDyetD64ZsjnWV/N/D44s/esI+k6oPREaiQ== dependencies: - "@cosmjs/encoding" "^0.29.2" - "@cosmjs/math" "^0.29.2" - "@cosmjs/utils" "^0.29.2" + "@cosmjs/encoding" "^0.29.5" + "@cosmjs/math" "^0.29.5" + "@cosmjs/utils" "^0.29.5" "@noble/hashes" "^1" bn.js "^5.2.0" - elliptic "^6.5.3" + elliptic "^6.5.4" libsodium-wrappers "^0.7.6" -"@cosmjs/encoding@^0.29.2": - version "0.29.2" - resolved "https://registry.yarnpkg.com/@cosmjs/encoding/-/encoding-0.29.2.tgz#705a1e4509e4f347ebb25adcfa958a4d6e6b87cb" - integrity sha512-v62YsTVvDOSbSAHpD2u5oe0yk/ljitkgi+CM/hpL1qytaVKIlr1RSwBDhJ5cW11oqkIjMWM8UNsGeIG8lyt9JA== +"@cosmjs/encoding@^0.29.5": + version "0.29.5" + resolved "https://registry.yarnpkg.com/@cosmjs/encoding/-/encoding-0.29.5.tgz#009a4b1c596cdfd326f30ccfa79f5e56daa264f2" + integrity sha512-G4rGl/Jg4dMCw5u6PEZHZcoHnUBlukZODHbm/wcL4Uu91fkn5jVo5cXXZcvs4VCkArVGrEj/52eUgTZCmOBGWQ== dependencies: base64-js "^1.3.0" bech32 "^1.1.4" readonly-date "^1.0.0" -"@cosmjs/faucet-client@^0.29.2": - version "0.29.2" - resolved "https://registry.yarnpkg.com/@cosmjs/faucet-client/-/faucet-client-0.29.2.tgz#b8d994f159344c2b79a69483ee058b6715e0b340" - integrity sha512-mhxi/rwbcCh999C4iYgrcDF8cMVWqU+f3qynYlILnlpNYwXwJEnV/IkLMgK5xhGYbVw+R8zClPKTP5h1AvoGoA== +"@cosmjs/faucet-client@^0.29.5": + version "0.29.5" + resolved "https://registry.yarnpkg.com/@cosmjs/faucet-client/-/faucet-client-0.29.5.tgz#696412a747888690c6d925a2f1610e8338deb882" + integrity sha512-9H/bp+oHYixVUFMf4+jdvuvYGoJN2R990LyXgi+qsxT3fRO6Z/8pnzkUW7dYXelqLVXAm6JSsj7UZ6yyk4p7GA== dependencies: axios "^0.21.2" -"@cosmjs/json-rpc@^0.29.2": - version "0.29.2" - resolved "https://registry.yarnpkg.com/@cosmjs/json-rpc/-/json-rpc-0.29.2.tgz#ccc46e8b334e3affa7ca7b32eace92fbbcd50410" - integrity sha512-oJA12dZflR/VU8zqiu+6gTt1SbKAhJSr/D5qAbIPdUcRzfI44J5h6tOvxnAuzJIig4oAid4u92KeuibAKFRJeA== +"@cosmjs/json-rpc@^0.29.5": + version "0.29.5" + resolved "https://registry.yarnpkg.com/@cosmjs/json-rpc/-/json-rpc-0.29.5.tgz#5e483a9bd98a6270f935adf0dfd8a1e7eb777fe4" + integrity sha512-C78+X06l+r9xwdM1yFWIpGl03LhB9NdM1xvZpQHwgCOl0Ir/WV8pw48y3Ez2awAoUBRfTeejPe4KvrE6NoIi/w== dependencies: - "@cosmjs/stream" "^0.29.2" + "@cosmjs/stream" "^0.29.5" xstream "^11.14.0" -"@cosmjs/math@^0.29.2": - version "0.29.2" - resolved "https://registry.yarnpkg.com/@cosmjs/math/-/math-0.29.2.tgz#00e7b7d4db8fb79ca1f73aa50d011bba2140bc72" - integrity sha512-WhgvinqNauEG0GNF7OMNU/cWqBZQ537Zy5d6FAO1+5lOpLhxxBPshEJIO4l2VPU702/JcC5qa49AxyiV3JuGmA== +"@cosmjs/math@^0.29.5": + version "0.29.5" + resolved "https://registry.yarnpkg.com/@cosmjs/math/-/math-0.29.5.tgz#722c96e080d6c2b62215ce9f4c70da7625b241b6" + integrity sha512-2GjKcv+A9f86MAWYLUkjhw1/WpRl2R1BTb3m9qPG7lzMA7ioYff9jY5SPCfafKdxM4TIQGxXQlYGewQL16O68Q== dependencies: bn.js "^5.2.0" -"@cosmjs/proto-signing@^0.29.2": - version "0.29.2" - resolved "https://registry.yarnpkg.com/@cosmjs/proto-signing/-/proto-signing-0.29.2.tgz#758f7d0ac4a7446f5eb2c59d5beadf37771c4839" - integrity sha512-+YU1u/SVbvBTiWXkUPca/HNKChSOHuVMrWbhNOzEJgJphYVYwCXabpSFguCymJ1lOFwa0WXIykVqsIzQdEgMQw== +"@cosmjs/proto-signing@^0.29.5": + version "0.29.5" + resolved "https://registry.yarnpkg.com/@cosmjs/proto-signing/-/proto-signing-0.29.5.tgz#af3b62a46c2c2f1d2327d678b13b7262db1fe87c" + integrity sha512-QRrS7CiKaoETdgIqvi/7JC2qCwCR7lnWaUsTzh/XfRy3McLkEd+cXbKAW3cygykv7IN0VAEIhZd2lyIfT8KwNA== dependencies: - "@cosmjs/amino" "^0.29.2" - "@cosmjs/crypto" "^0.29.2" - "@cosmjs/encoding" "^0.29.2" - "@cosmjs/math" "^0.29.2" - "@cosmjs/utils" "^0.29.2" + "@cosmjs/amino" "^0.29.5" + "@cosmjs/crypto" "^0.29.5" + "@cosmjs/encoding" "^0.29.5" + "@cosmjs/math" "^0.29.5" + "@cosmjs/utils" "^0.29.5" cosmjs-types "^0.5.2" long "^4.0.0" -"@cosmjs/socket@^0.29.2": - version "0.29.2" - resolved "https://registry.yarnpkg.com/@cosmjs/socket/-/socket-0.29.2.tgz#a332f1bd786d4ecb0ac534d9afd3c639f7107cc2" - integrity sha512-SllIOXmn5x3wWfcknv5gmd25kNS2aJmiHEjOM1D+ZUACXzLZBqKTNolg5+8e0yVfR+4yxsJS9w5ocINrY6j0rA== +"@cosmjs/socket@^0.29.5": + version "0.29.5" + resolved "https://registry.yarnpkg.com/@cosmjs/socket/-/socket-0.29.5.tgz#a48df6b4c45dc6a6ef8e47232725dd4aa556ac2d" + integrity sha512-5VYDupIWbIXq3ftPV1LkS5Ya/T7Ol/AzWVhNxZ79hPe/mBfv1bGau/LqIYOm2zxGlgm9hBHOTmWGqNYDwr9LNQ== dependencies: - "@cosmjs/stream" "^0.29.2" + "@cosmjs/stream" "^0.29.5" isomorphic-ws "^4.0.1" ws "^7" xstream "^11.14.0" -"@cosmjs/stargate@^0.29.2": - version "0.29.2" - resolved "https://registry.yarnpkg.com/@cosmjs/stargate/-/stargate-0.29.2.tgz#674711938fc031196968ddf7e409d407572ed50f" - integrity sha512-jCspWI+S+g1DE/rE8wR/JDzmeur120OOacinAADBKiHjSqu9R3qAaiC9kKPsQWl2PYk4qAs8sxLkjg+gq2vRGw== +"@cosmjs/stargate@^0.29.5": + version "0.29.5" + resolved "https://registry.yarnpkg.com/@cosmjs/stargate/-/stargate-0.29.5.tgz#d597af1c85a3c2af7b5bdbec34d5d40692cc09e4" + integrity sha512-hjEv8UUlJruLrYGJcUZXM/CziaINOKwfVm2BoSdUnNTMxGvY/jC1ABHKeZUYt9oXHxEJ1n9+pDqzbKc8pT0nBw== dependencies: "@confio/ics23" "^0.6.8" - "@cosmjs/amino" "^0.29.2" - "@cosmjs/encoding" "^0.29.2" - "@cosmjs/math" "^0.29.2" - "@cosmjs/proto-signing" "^0.29.2" - "@cosmjs/stream" "^0.29.2" - "@cosmjs/tendermint-rpc" "^0.29.2" - "@cosmjs/utils" "^0.29.2" + "@cosmjs/amino" "^0.29.5" + "@cosmjs/encoding" "^0.29.5" + "@cosmjs/math" "^0.29.5" + "@cosmjs/proto-signing" "^0.29.5" + "@cosmjs/stream" "^0.29.5" + "@cosmjs/tendermint-rpc" "^0.29.5" + "@cosmjs/utils" "^0.29.5" cosmjs-types "^0.5.2" long "^4.0.0" protobufjs "~6.11.3" xstream "^11.14.0" -"@cosmjs/stream@^0.29.2": - version "0.29.2" - resolved "https://registry.yarnpkg.com/@cosmjs/stream/-/stream-0.29.2.tgz#4974742b9d579c96c5cdb29de59ae44f4236949b" - integrity sha512-ov0N6paYO1VVBl9gOu+i7RJyMR7wAWkN+xcxLN123+UHzRgTPWggJ18RqUCZ2Z87hKWHCkzD8pagi8Rf4uY7cg== +"@cosmjs/stream@^0.29.5": + version "0.29.5" + resolved "https://registry.yarnpkg.com/@cosmjs/stream/-/stream-0.29.5.tgz#350981cac496d04939b92ee793b9b19f44bc1d4e" + integrity sha512-TToTDWyH1p05GBtF0Y8jFw2C+4783ueDCmDyxOMM6EU82IqpmIbfwcdMOCAm0JhnyMh+ocdebbFvnX/sGKzRAA== dependencies: xstream "^11.14.0" -"@cosmjs/tendermint-rpc@^0.29.2": - version "0.29.2" - resolved "https://registry.yarnpkg.com/@cosmjs/tendermint-rpc/-/tendermint-rpc-0.29.2.tgz#8e32cd7dd56b1c191c6772d2b9033af4bc2b92c1" - integrity sha512-l3SFzBhJwN5+7gg7elknSFhw1e+YN7QjVTanMZJ0hPH5njeIxaUkabk2y3fqWMBxoUkuCsmxJEIeCSByX/6R8A== - dependencies: - "@cosmjs/crypto" "^0.29.2" - "@cosmjs/encoding" "^0.29.2" - "@cosmjs/json-rpc" "^0.29.2" - "@cosmjs/math" "^0.29.2" - "@cosmjs/socket" "^0.29.2" - "@cosmjs/stream" "^0.29.2" - "@cosmjs/utils" "^0.29.2" +"@cosmjs/tendermint-rpc@^0.29.5": + version "0.29.5" + resolved "https://registry.yarnpkg.com/@cosmjs/tendermint-rpc/-/tendermint-rpc-0.29.5.tgz#f205c10464212bdf843f91bb2e4a093b618cb5c2" + integrity sha512-ar80twieuAxsy0x2za/aO3kBr2DFPAXDmk2ikDbmkda+qqfXgl35l9CVAAjKRqd9d+cRvbQyb5M4wy6XQpEV6w== + dependencies: + "@cosmjs/crypto" "^0.29.5" + "@cosmjs/encoding" "^0.29.5" + "@cosmjs/json-rpc" "^0.29.5" + "@cosmjs/math" "^0.29.5" + "@cosmjs/socket" "^0.29.5" + "@cosmjs/stream" "^0.29.5" + "@cosmjs/utils" "^0.29.5" axios "^0.21.2" readonly-date "^1.0.0" xstream "^11.14.0" -"@cosmjs/utils@^0.29.2": - version "0.29.2" - resolved "https://registry.yarnpkg.com/@cosmjs/utils/-/utils-0.29.2.tgz#1a32338f40decb8ec60b45e9b14476df66e2d915" - integrity sha512-gckp8mbNXF8XCAEwCzH90fpaA0K2O9CC5Rg5v75zsRySYkAaoJIm9f+f8yW2qn6ADge2BnmIT1IkAfmswThCJQ== +"@cosmjs/utils@^0.29.5": + version "0.29.5" + resolved "https://registry.yarnpkg.com/@cosmjs/utils/-/utils-0.29.5.tgz#3fed1b3528ae8c5f1eb5d29b68755bebfd3294ee" + integrity sha512-m7h+RXDUxOzEOGt4P+3OVPX7PuakZT3GBmaM/Y2u+abN3xZkziykD/NvedYFvvCCdQo714XcGl33bwifS9FZPQ== "@dabh/diagnostics@^2.0.2": version "2.0.3" @@ -1838,7 +1838,7 @@ electron-to-chromium@^1.4.164: resolved "https://registry.yarnpkg.com/electron-to-chromium/-/electron-to-chromium-1.4.168.tgz#8f6bda320a434ac963850d18e41d83220973cbdd" integrity sha512-yz247hclRBaP8ABB1hf9kL7AMfa+yC2hB9F3XF8Y87VWMnYgq4QYvV6acRACcDkTDxfGQ4GYK/aZPQiuFMGbaA== -elliptic@^6.5.3: +elliptic@^6.5.4: version "6.5.4" resolved "https://registry.yarnpkg.com/elliptic/-/elliptic-6.5.4.tgz#da37cebd31e79a1367e941b592ed1fbebd58abbb" integrity sha512-iLhC6ULemrljPZb+QutR5TQGB+pdW6KGD5RSegS+8sorOZT+rdQFbsQFJgvN3eRqNALqJer4oQ16YvJHlU8hzQ==