From 82371597c33072107cc439c5bb95ca516760e7a8 Mon Sep 17 00:00:00 2001 From: Giancarlos Salas Date: Fri, 11 Nov 2022 11:49:42 -0600 Subject: [PATCH 01/13] Fix parse contract msg --- packages/cosmwasm-stargate/src/cosmwasmclient.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/cosmwasm-stargate/src/cosmwasmclient.ts b/packages/cosmwasm-stargate/src/cosmwasmclient.ts index ba896663..ab357d9a 100644 --- a/packages/cosmwasm-stargate/src/cosmwasmclient.ts +++ b/packages/cosmwasm-stargate/src/cosmwasmclient.ts @@ -1,5 +1,5 @@ /* eslint-disable @typescript-eslint/naming-convention */ -import { fromAscii, toHex } from "@cosmjs/encoding"; +import { fromUtf8, toHex } from "@cosmjs/encoding"; import { Uint53 } from "@cosmjs/math"; import { Account, @@ -415,7 +415,7 @@ export class CosmWasmClient { return { operation: operations[entry.operation], codeId: entry.codeId.toNumber(), - msg: JSON.parse(fromAscii(entry.msg)), + msg: JSON.parse(fromUtf8(entry.msg)), }; }); } From 0d75c02d960dcbc58660adfcaeceeb7a33795a9a Mon Sep 17 00:00:00 2001 From: Simon Warta Date: Mon, 14 Nov 2022 09:35:35 +0100 Subject: [PATCH 02/13] Upgrade socket.io --- .pnp.cjs | 106 +++++++----------- ...buffer-npm-1.0.2-066f9f7d09-fa3e58c758.zip | 3 - ...mitter-npm-3.1.0-3f778351c2-db069d9542.zip | 3 + ...itter-npm-1.2.10-95c27b794b-7589d3a10e.zip | 3 - ...mitter-npm-1.3.0-4b848565b9-b3c46de38f.zip | 3 - ...ine.io-npm-6.1.2-733cb68993-bd98d6ce2b.zip | 3 - ...ine.io-npm-6.2.0-a0c0d83e66-cc485c5ba2.zip | 3 + ...parser-npm-5.0.3-55c5b3beef-88d664420a.zip | 3 - ...parser-npm-5.0.4-27a510b395-d4ad0cef6f.zip | 3 + ...dapter-npm-2.3.3-4fd6b5d0bd-73890e0a33.zip | 3 - ...dapter-npm-2.4.0-36a74a6ea1-a84639946d.zip | 3 + ...ket.io-npm-4.4.1-b2ec7c47a5-a559ae5235.zip | 3 - ...ket.io-npm-4.5.3-30385c9144-2a7e4c64bb.zip | 3 + ...parser-npm-4.0.4-1dfc284556-c173b4f374.zip | 3 - ...parser-npm-4.2.1-7ef513b498-2582202f22.zip | 3 + yarn.lock | 73 +++++------- 16 files changed, 85 insertions(+), 136 deletions(-) delete mode 100644 .yarn/cache/@socket.io-base64-arraybuffer-npm-1.0.2-066f9f7d09-fa3e58c758.zip create mode 100644 .yarn/cache/@socket.io-component-emitter-npm-3.1.0-3f778351c2-db069d9542.zip delete mode 100644 .yarn/cache/@types-component-emitter-npm-1.2.10-95c27b794b-7589d3a10e.zip delete mode 100644 .yarn/cache/component-emitter-npm-1.3.0-4b848565b9-b3c46de38f.zip delete mode 100644 .yarn/cache/engine.io-npm-6.1.2-733cb68993-bd98d6ce2b.zip create mode 100644 .yarn/cache/engine.io-npm-6.2.0-a0c0d83e66-cc485c5ba2.zip delete mode 100644 .yarn/cache/engine.io-parser-npm-5.0.3-55c5b3beef-88d664420a.zip create mode 100644 .yarn/cache/engine.io-parser-npm-5.0.4-27a510b395-d4ad0cef6f.zip delete mode 100644 .yarn/cache/socket.io-adapter-npm-2.3.3-4fd6b5d0bd-73890e0a33.zip create mode 100644 .yarn/cache/socket.io-adapter-npm-2.4.0-36a74a6ea1-a84639946d.zip delete mode 100644 .yarn/cache/socket.io-npm-4.4.1-b2ec7c47a5-a559ae5235.zip create mode 100644 .yarn/cache/socket.io-npm-4.5.3-30385c9144-2a7e4c64bb.zip delete mode 100644 .yarn/cache/socket.io-parser-npm-4.0.4-1dfc284556-c173b4f374.zip create mode 100644 .yarn/cache/socket.io-parser-npm-4.2.1-7ef513b498-2582202f22.zip diff --git a/.pnp.cjs b/.pnp.cjs index e76e9db0..4454f4cc 100755 --- a/.pnp.cjs +++ b/.pnp.cjs @@ -416,8 +416,8 @@ function $$SETUP_STATE(hydrateRuntimeState, basePath) { "npm:1.1.0"\ ],\ [\ - "@socket.io/base64-arraybuffer",\ - "npm:1.0.2"\ + "@socket.io/component-emitter",\ + "npm:3.1.0"\ ],\ [\ "@tootallnate/once",\ @@ -447,10 +447,6 @@ function $$SETUP_STATE(hydrateRuntimeState, basePath) { "@types/body-parser",\ "npm:1.19.0"\ ],\ - [\ - "@types/component-emitter",\ - "npm:1.2.10"\ - ],\ [\ "@types/connect",\ "npm:3.4.34"\ @@ -995,10 +991,6 @@ function $$SETUP_STATE(hydrateRuntimeState, basePath) { "commondir",\ "npm:1.0.1"\ ],\ - [\ - "component-emitter",\ - "npm:1.3.0"\ - ],\ [\ "concat-map",\ "npm:0.0.1"\ @@ -1161,11 +1153,11 @@ function $$SETUP_STATE(hydrateRuntimeState, basePath) { ],\ [\ "engine.io",\ - "npm:6.1.2"\ + "npm:6.2.0"\ ],\ [\ "engine.io-parser",\ - "npm:5.0.3"\ + "npm:5.0.4"\ ],\ [\ "enhanced-resolve",\ @@ -2453,15 +2445,15 @@ function $$SETUP_STATE(hydrateRuntimeState, basePath) { ],\ [\ "socket.io",\ - "npm:4.4.1"\ + "npm:4.5.3"\ ],\ [\ "socket.io-adapter",\ - "npm:2.3.3"\ + "npm:2.4.0"\ ],\ [\ "socket.io-parser",\ - "npm:4.0.4"\ + "npm:4.2.1"\ ],\ [\ "socks",\ @@ -4318,11 +4310,11 @@ function $$SETUP_STATE(hydrateRuntimeState, basePath) { "linkType": "HARD"\ }]\ ]],\ - ["@socket.io/base64-arraybuffer", [\ - ["npm:1.0.2", {\ - "packageLocation": "./.yarn/cache/@socket.io-base64-arraybuffer-npm-1.0.2-066f9f7d09-fa3e58c758.zip/node_modules/@socket.io/base64-arraybuffer/",\ + ["@socket.io/component-emitter", [\ + ["npm:3.1.0", {\ + "packageLocation": "./.yarn/cache/@socket.io-component-emitter-npm-3.1.0-3f778351c2-db069d9542.zip/node_modules/@socket.io/component-emitter/",\ "packageDependencies": [\ - ["@socket.io/base64-arraybuffer", "npm:1.0.2"]\ + ["@socket.io/component-emitter", "npm:3.1.0"]\ ],\ "linkType": "HARD"\ }]\ @@ -4395,15 +4387,6 @@ function $$SETUP_STATE(hydrateRuntimeState, basePath) { "linkType": "HARD"\ }]\ ]],\ - ["@types/component-emitter", [\ - ["npm:1.2.10", {\ - "packageLocation": "./.yarn/cache/@types-component-emitter-npm-1.2.10-95c27b794b-7589d3a10e.zip/node_modules/@types/component-emitter/",\ - "packageDependencies": [\ - ["@types/component-emitter", "npm:1.2.10"]\ - ],\ - "linkType": "HARD"\ - }]\ - ]],\ ["@types/connect", [\ ["npm:3.4.34", {\ "packageLocation": "./.yarn/cache/@types-connect-npm-3.4.34-39e4f7bb55-c6e2aa299c.zip/node_modules/@types/connect/",\ @@ -6802,15 +6785,6 @@ function $$SETUP_STATE(hydrateRuntimeState, basePath) { "linkType": "HARD"\ }]\ ]],\ - ["component-emitter", [\ - ["npm:1.3.0", {\ - "packageLocation": "./.yarn/cache/component-emitter-npm-1.3.0-4b848565b9-b3c46de38f.zip/node_modules/component-emitter/",\ - "packageDependencies": [\ - ["component-emitter", "npm:1.3.0"]\ - ],\ - "linkType": "HARD"\ - }]\ - ]],\ ["concat-map", [\ ["npm:0.0.1", {\ "packageLocation": "./.yarn/cache/concat-map-npm-0.0.1-85a921b7ee-902a9f5d89.zip/node_modules/concat-map/",\ @@ -7296,10 +7270,10 @@ function $$SETUP_STATE(hydrateRuntimeState, basePath) { }]\ ]],\ ["engine.io", [\ - ["npm:6.1.2", {\ - "packageLocation": "./.yarn/cache/engine.io-npm-6.1.2-733cb68993-bd98d6ce2b.zip/node_modules/engine.io/",\ + ["npm:6.2.0", {\ + "packageLocation": "./.yarn/cache/engine.io-npm-6.2.0-a0c0d83e66-cc485c5ba2.zip/node_modules/engine.io/",\ "packageDependencies": [\ - ["engine.io", "npm:6.1.2"],\ + ["engine.io", "npm:6.2.0"],\ ["@types/cookie", "npm:0.4.1"],\ ["@types/cors", "npm:2.8.12"],\ ["@types/node", "npm:15.9.0"],\ @@ -7308,18 +7282,17 @@ function $$SETUP_STATE(hydrateRuntimeState, basePath) { ["cookie", "npm:0.4.1"],\ ["cors", "npm:2.8.5"],\ ["debug", "virtual:6d7ba8035a34a8cbc48e227f3e803dbc3acaabbab2521c3cd66a45a2853fa6bda5b3ccb3ab1942c8a738927bc0e228ea8d5baa6461d73e2cf6a345db629c4f47#npm:4.3.3"],\ - ["engine.io-parser", "npm:5.0.3"],\ - ["ws", "virtual:733cb6899318fc97abde396915533fc4f9852a2d62abe85daf265f0103211854a5c657d9a2fa18cdee56e1c047ccecb37162ba0f185d142200181f148b16695f#npm:8.2.3"]\ + ["engine.io-parser", "npm:5.0.4"],\ + ["ws", "virtual:a0c0d83e66563f51d601c822567e6d79b2ed7475481445e29115ee78d98a1ad5241e9e0cbf0e0eb707d80a4db444175061b5c5627b6aa1262f0868dc9ad1e7a1#npm:8.2.3"]\ ],\ "linkType": "HARD"\ }]\ ]],\ ["engine.io-parser", [\ - ["npm:5.0.3", {\ - "packageLocation": "./.yarn/cache/engine.io-parser-npm-5.0.3-55c5b3beef-88d664420a.zip/node_modules/engine.io-parser/",\ + ["npm:5.0.4", {\ + "packageLocation": "./.yarn/cache/engine.io-parser-npm-5.0.4-27a510b395-d4ad0cef6f.zip/node_modules/engine.io-parser/",\ "packageDependencies": [\ - ["engine.io-parser", "npm:5.0.3"],\ - ["@socket.io/base64-arraybuffer", "npm:1.0.2"]\ + ["engine.io-parser", "npm:5.0.4"]\ ],\ "linkType": "HARD"\ }]\ @@ -9272,7 +9245,7 @@ function $$SETUP_STATE(hydrateRuntimeState, basePath) { ["qjobs", "npm:1.2.0"],\ ["range-parser", "npm:1.2.1"],\ ["rimraf", "npm:3.0.2"],\ - ["socket.io", "npm:4.4.1"],\ + ["socket.io", "npm:4.5.3"],\ ["source-map", "npm:0.6.1"],\ ["tmp", "npm:0.2.1"],\ ["ua-parser-js", "npm:0.7.31"],\ @@ -11246,36 +11219,35 @@ function $$SETUP_STATE(hydrateRuntimeState, basePath) { }]\ ]],\ ["socket.io", [\ - ["npm:4.4.1", {\ - "packageLocation": "./.yarn/cache/socket.io-npm-4.4.1-b2ec7c47a5-a559ae5235.zip/node_modules/socket.io/",\ + ["npm:4.5.3", {\ + "packageLocation": "./.yarn/cache/socket.io-npm-4.5.3-30385c9144-2a7e4c64bb.zip/node_modules/socket.io/",\ "packageDependencies": [\ - ["socket.io", "npm:4.4.1"],\ + ["socket.io", "npm:4.5.3"],\ ["accepts", "npm:1.3.7"],\ ["base64id", "npm:2.0.0"],\ ["debug", "virtual:6d7ba8035a34a8cbc48e227f3e803dbc3acaabbab2521c3cd66a45a2853fa6bda5b3ccb3ab1942c8a738927bc0e228ea8d5baa6461d73e2cf6a345db629c4f47#npm:4.3.3"],\ - ["engine.io", "npm:6.1.2"],\ - ["socket.io-adapter", "npm:2.3.3"],\ - ["socket.io-parser", "npm:4.0.4"]\ + ["engine.io", "npm:6.2.0"],\ + ["socket.io-adapter", "npm:2.4.0"],\ + ["socket.io-parser", "npm:4.2.1"]\ ],\ "linkType": "HARD"\ }]\ ]],\ ["socket.io-adapter", [\ - ["npm:2.3.3", {\ - "packageLocation": "./.yarn/cache/socket.io-adapter-npm-2.3.3-4fd6b5d0bd-73890e0a33.zip/node_modules/socket.io-adapter/",\ + ["npm:2.4.0", {\ + "packageLocation": "./.yarn/cache/socket.io-adapter-npm-2.4.0-36a74a6ea1-a84639946d.zip/node_modules/socket.io-adapter/",\ "packageDependencies": [\ - ["socket.io-adapter", "npm:2.3.3"]\ + ["socket.io-adapter", "npm:2.4.0"]\ ],\ "linkType": "HARD"\ }]\ ]],\ ["socket.io-parser", [\ - ["npm:4.0.4", {\ - "packageLocation": "./.yarn/cache/socket.io-parser-npm-4.0.4-1dfc284556-c173b4f374.zip/node_modules/socket.io-parser/",\ + ["npm:4.2.1", {\ + "packageLocation": "./.yarn/cache/socket.io-parser-npm-4.2.1-7ef513b498-2582202f22.zip/node_modules/socket.io-parser/",\ "packageDependencies": [\ - ["socket.io-parser", "npm:4.0.4"],\ - ["@types/component-emitter", "npm:1.2.10"],\ - ["component-emitter", "npm:1.3.0"],\ + ["socket.io-parser", "npm:4.2.1"],\ + ["@socket.io/component-emitter", "npm:3.1.0"],\ ["debug", "virtual:6d7ba8035a34a8cbc48e227f3e803dbc3acaabbab2521c3cd66a45a2853fa6bda5b3ccb3ab1942c8a738927bc0e228ea8d5baa6461d73e2cf6a345db629c4f47#npm:4.3.3"]\ ],\ "linkType": "HARD"\ @@ -13751,10 +13723,10 @@ function $$SETUP_STATE(hydrateRuntimeState, basePath) { ],\ "linkType": "SOFT"\ }],\ - ["virtual:733cb6899318fc97abde396915533fc4f9852a2d62abe85daf265f0103211854a5c657d9a2fa18cdee56e1c047ccecb37162ba0f185d142200181f148b16695f#npm:8.2.3", {\ - "packageLocation": "./.yarn/__virtual__/ws-virtual-4b865e96d3/0/cache/ws-npm-8.2.3-03a35b8ad7-c869296ccb.zip/node_modules/ws/",\ + ["virtual:992e8a49329af27dec1603ba7ec6f83173fb73e1d5752e95d78d0bec9ff8e148a218f65e20742125a49b958677fd4d6119ec35f9c56f9b4ea72f0e32f53b591b#npm:7.4.6", {\ + "packageLocation": "./.yarn/__virtual__/ws-virtual-271fa5cbbc/0/cache/ws-npm-7.4.6-9c9a725604-3a990b32ed.zip/node_modules/ws/",\ "packageDependencies": [\ - ["ws", "virtual:733cb6899318fc97abde396915533fc4f9852a2d62abe85daf265f0103211854a5c657d9a2fa18cdee56e1c047ccecb37162ba0f185d142200181f148b16695f#npm:8.2.3"],\ + ["ws", "virtual:992e8a49329af27dec1603ba7ec6f83173fb73e1d5752e95d78d0bec9ff8e148a218f65e20742125a49b958677fd4d6119ec35f9c56f9b4ea72f0e32f53b591b#npm:7.4.6"],\ ["@types/bufferutil", null],\ ["@types/utf-8-validate", null],\ ["bufferutil", null],\ @@ -13768,10 +13740,10 @@ function $$SETUP_STATE(hydrateRuntimeState, basePath) { ],\ "linkType": "HARD"\ }],\ - ["virtual:992e8a49329af27dec1603ba7ec6f83173fb73e1d5752e95d78d0bec9ff8e148a218f65e20742125a49b958677fd4d6119ec35f9c56f9b4ea72f0e32f53b591b#npm:7.4.6", {\ - "packageLocation": "./.yarn/__virtual__/ws-virtual-271fa5cbbc/0/cache/ws-npm-7.4.6-9c9a725604-3a990b32ed.zip/node_modules/ws/",\ + ["virtual:a0c0d83e66563f51d601c822567e6d79b2ed7475481445e29115ee78d98a1ad5241e9e0cbf0e0eb707d80a4db444175061b5c5627b6aa1262f0868dc9ad1e7a1#npm:8.2.3", {\ + "packageLocation": "./.yarn/__virtual__/ws-virtual-d4fe871b31/0/cache/ws-npm-8.2.3-03a35b8ad7-c869296ccb.zip/node_modules/ws/",\ "packageDependencies": [\ - ["ws", "virtual:992e8a49329af27dec1603ba7ec6f83173fb73e1d5752e95d78d0bec9ff8e148a218f65e20742125a49b958677fd4d6119ec35f9c56f9b4ea72f0e32f53b591b#npm:7.4.6"],\ + ["ws", "virtual:a0c0d83e66563f51d601c822567e6d79b2ed7475481445e29115ee78d98a1ad5241e9e0cbf0e0eb707d80a4db444175061b5c5627b6aa1262f0868dc9ad1e7a1#npm:8.2.3"],\ ["@types/bufferutil", null],\ ["@types/utf-8-validate", null],\ ["bufferutil", null],\ diff --git a/.yarn/cache/@socket.io-base64-arraybuffer-npm-1.0.2-066f9f7d09-fa3e58c758.zip b/.yarn/cache/@socket.io-base64-arraybuffer-npm-1.0.2-066f9f7d09-fa3e58c758.zip deleted file mode 100644 index 67a2548c..00000000 --- a/.yarn/cache/@socket.io-base64-arraybuffer-npm-1.0.2-066f9f7d09-fa3e58c758.zip +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:c2ad54e3faf0c876ea3ffa2810fb52f12f781cdc998da63b6a216748299048da -size 9985 diff --git a/.yarn/cache/@socket.io-component-emitter-npm-3.1.0-3f778351c2-db069d9542.zip b/.yarn/cache/@socket.io-component-emitter-npm-3.1.0-3f778351c2-db069d9542.zip new file mode 100644 index 00000000..d102890d --- /dev/null +++ b/.yarn/cache/@socket.io-component-emitter-npm-3.1.0-3f778351c2-db069d9542.zip @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:1ae134513810b12efb61ae7cf83feac423d57fb7f8d571c1c922634266259c89 +size 6303 diff --git a/.yarn/cache/@types-component-emitter-npm-1.2.10-95c27b794b-7589d3a10e.zip b/.yarn/cache/@types-component-emitter-npm-1.2.10-95c27b794b-7589d3a10e.zip deleted file mode 100644 index 65266773..00000000 --- a/.yarn/cache/@types-component-emitter-npm-1.2.10-95c27b794b-7589d3a10e.zip +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:a6dd37f786919d8f75c8eea378ad1c717d68cebe31b5a00cbbdbde5dd0e64115 -size 2675 diff --git a/.yarn/cache/component-emitter-npm-1.3.0-4b848565b9-b3c46de38f.zip b/.yarn/cache/component-emitter-npm-1.3.0-4b848565b9-b3c46de38f.zip deleted file mode 100644 index 7b4998c7..00000000 --- a/.yarn/cache/component-emitter-npm-1.3.0-4b848565b9-b3c46de38f.zip +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:bd41a46711ed2ebe7543c9e3d19a24b3104253a2ed27c8112f8b44e3572670c7 -size 4136 diff --git a/.yarn/cache/engine.io-npm-6.1.2-733cb68993-bd98d6ce2b.zip b/.yarn/cache/engine.io-npm-6.1.2-733cb68993-bd98d6ce2b.zip deleted file mode 100644 index 532d9948..00000000 --- a/.yarn/cache/engine.io-npm-6.1.2-733cb68993-bd98d6ce2b.zip +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:7050381014d54a1e3dd7329fe3dfdfd04070caa91e547925846bd8970a457c39 -size 48901 diff --git a/.yarn/cache/engine.io-npm-6.2.0-a0c0d83e66-cc485c5ba2.zip b/.yarn/cache/engine.io-npm-6.2.0-a0c0d83e66-cc485c5ba2.zip new file mode 100644 index 00000000..cab17073 --- /dev/null +++ b/.yarn/cache/engine.io-npm-6.2.0-a0c0d83e66-cc485c5ba2.zip @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:9b291a71a65def90fd71407273493b3a2dd9ccaa6b77e0f1358b6a62a1e63067 +size 49239 diff --git a/.yarn/cache/engine.io-parser-npm-5.0.3-55c5b3beef-88d664420a.zip b/.yarn/cache/engine.io-parser-npm-5.0.3-55c5b3beef-88d664420a.zip deleted file mode 100644 index f9cd3c33..00000000 --- a/.yarn/cache/engine.io-parser-npm-5.0.3-55c5b3beef-88d664420a.zip +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:52685d3902a6dcf1dda953fe17ec1623fd0a82ebb381398d6dda8c001439c0fb -size 15220 diff --git a/.yarn/cache/engine.io-parser-npm-5.0.4-27a510b395-d4ad0cef6f.zip b/.yarn/cache/engine.io-parser-npm-5.0.4-27a510b395-d4ad0cef6f.zip new file mode 100644 index 00000000..7332c0d4 --- /dev/null +++ b/.yarn/cache/engine.io-parser-npm-5.0.4-27a510b395-d4ad0cef6f.zip @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:be71dc5f86b64782473f214300c18eaa7ad5ac356b3f63404033b097102dff70 +size 17550 diff --git a/.yarn/cache/socket.io-adapter-npm-2.3.3-4fd6b5d0bd-73890e0a33.zip b/.yarn/cache/socket.io-adapter-npm-2.3.3-4fd6b5d0bd-73890e0a33.zip deleted file mode 100644 index c0a8d74d..00000000 --- a/.yarn/cache/socket.io-adapter-npm-2.3.3-4fd6b5d0bd-73890e0a33.zip +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:0db1bbd33ec4629a5357cb58a343d51ec6848c813ab835ab10acecb6fa6f8920 -size 12890 diff --git a/.yarn/cache/socket.io-adapter-npm-2.4.0-36a74a6ea1-a84639946d.zip b/.yarn/cache/socket.io-adapter-npm-2.4.0-36a74a6ea1-a84639946d.zip new file mode 100644 index 00000000..858bc25f --- /dev/null +++ b/.yarn/cache/socket.io-adapter-npm-2.4.0-36a74a6ea1-a84639946d.zip @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:3d42eb84a716ede8bf22a9e41d13e83245d52b7374c89f5f34c799e53c136b5c +size 5691 diff --git a/.yarn/cache/socket.io-npm-4.4.1-b2ec7c47a5-a559ae5235.zip b/.yarn/cache/socket.io-npm-4.4.1-b2ec7c47a5-a559ae5235.zip deleted file mode 100644 index ff0f3faf..00000000 --- a/.yarn/cache/socket.io-npm-4.4.1-b2ec7c47a5-a559ae5235.zip +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:073a32fd7d3c4b3054c0906d5d8cda8dae28b2c04d60ca422f5e91f2d83980b7 -size 266600 diff --git a/.yarn/cache/socket.io-npm-4.5.3-30385c9144-2a7e4c64bb.zip b/.yarn/cache/socket.io-npm-4.5.3-30385c9144-2a7e4c64bb.zip new file mode 100644 index 00000000..bec2c672 --- /dev/null +++ b/.yarn/cache/socket.io-npm-4.5.3-30385c9144-2a7e4c64bb.zip @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:6c638b8c06c6c4a9e895c1bbe60fe3cae34e9001e959243e528dfa83f6301660 +size 298533 diff --git a/.yarn/cache/socket.io-parser-npm-4.0.4-1dfc284556-c173b4f374.zip b/.yarn/cache/socket.io-parser-npm-4.0.4-1dfc284556-c173b4f374.zip deleted file mode 100644 index 5a751147..00000000 --- a/.yarn/cache/socket.io-parser-npm-4.0.4-1dfc284556-c173b4f374.zip +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:6d68c38d9cc9838382413f2601921e59c78a86ceeb54e383bb50d0d61ed652cf -size 9840 diff --git a/.yarn/cache/socket.io-parser-npm-4.2.1-7ef513b498-2582202f22.zip b/.yarn/cache/socket.io-parser-npm-4.2.1-7ef513b498-2582202f22.zip new file mode 100644 index 00000000..282bdd7d --- /dev/null +++ b/.yarn/cache/socket.io-parser-npm-4.2.1-7ef513b498-2582202f22.zip @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:7ced28f6ee77fddd3fc6ce8e0db4aedafb44c4195094a3b3fac7325b6fc22fb7 +size 20850 diff --git a/yarn.lock b/yarn.lock index 9b842880..204c3bff 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1341,10 +1341,10 @@ __metadata: languageName: node linkType: hard -"@socket.io/base64-arraybuffer@npm:~1.0.2": - version: 1.0.2 - resolution: "@socket.io/base64-arraybuffer@npm:1.0.2" - checksum: fa3e58c7581643d0557969cd3bece20e198596df77968ff29ede6be329d488e65104bef900e68a67f39d8855abfa59baa2b08d96fb856504bd01cbdd8f52249c +"@socket.io/component-emitter@npm:~3.1.0": + version: 3.1.0 + resolution: "@socket.io/component-emitter@npm:3.1.0" + checksum: db069d95425b419de1514dffe945cc439795f6a8ef5b9465715acf5b8b50798e2c91b8719cbf5434b3fe7de179d6cdcd503c277b7871cb3dd03febb69bdd50fa languageName: node linkType: hard @@ -1406,13 +1406,6 @@ __metadata: languageName: node linkType: hard -"@types/component-emitter@npm:^1.2.10": - version: 1.2.10 - resolution: "@types/component-emitter@npm:1.2.10" - checksum: 7589d3a10ef4e1c60f415db0d7ad90680c2d60b589972d198c19ba092f06559988dde501f83c0293e945fe19b989ef2334da07802b802d1a9846b0dde7a34ab1 - languageName: node - linkType: hard - "@types/connect@npm:*": version: 3.4.34 resolution: "@types/connect@npm:3.4.34" @@ -2818,13 +2811,6 @@ __metadata: languageName: node linkType: hard -"component-emitter@npm:~1.3.0": - version: 1.3.0 - resolution: "component-emitter@npm:1.3.0" - checksum: b3c46de38ffd35c57d1c02488355be9f218e582aec72d72d1b8bbec95a3ac1b38c96cd6e03ff015577e68f550fbb361a3bfdbd9bb248be9390b7b3745691be6b - languageName: node - linkType: hard - "concat-map@npm:0.0.1": version: 0.0.1 resolution: "concat-map@npm:0.0.1" @@ -3214,18 +3200,16 @@ __metadata: languageName: node linkType: hard -"engine.io-parser@npm:~5.0.0": - version: 5.0.3 - resolution: "engine.io-parser@npm:5.0.3" - dependencies: - "@socket.io/base64-arraybuffer": ~1.0.2 - checksum: 88d664420a441dd02db17d110f7bbbd9efe971747918150bf666b82ee138df596a2f5038f461c8a01864c83af67cb202548364e4174543f8c0bf5f4776ca6e0d +"engine.io-parser@npm:~5.0.3": + version: 5.0.4 + resolution: "engine.io-parser@npm:5.0.4" + checksum: d4ad0cef6ff63c350e35696da9bb3dbd180f67b56e93e90375010cc40393e6c0639b780d5680807e1d93a7e2e3d7b4a1c3b27cf75db28eb8cbf605bc1497da03 languageName: node linkType: hard -"engine.io@npm:~6.1.0": - version: 6.1.2 - resolution: "engine.io@npm:6.1.2" +"engine.io@npm:~6.2.0": + version: 6.2.0 + resolution: "engine.io@npm:6.2.0" dependencies: "@types/cookie": ^0.4.1 "@types/cors": ^2.8.12 @@ -3235,9 +3219,9 @@ __metadata: cookie: ~0.4.1 cors: ~2.8.5 debug: ~4.3.1 - engine.io-parser: ~5.0.0 + engine.io-parser: ~5.0.3 ws: ~8.2.3 - checksum: bd98d6ce2b1e868e8ff0f65d7667a885b90bce62065d851ea0394a00c86686925be824ab91237151222d6a5acfd5610634f36966fa9b4c502e7cf362fbdf974a + checksum: cc485c5ba2e0c4f6ca02dcafd192b22f9dad89d01dc815005298780d3fb910db4cebab4696e8615290c473c2eeb259e8bee2a1fb7ab594d9c80f9f3485771911 languageName: node linkType: hard @@ -6634,35 +6618,34 @@ __metadata: languageName: node linkType: hard -"socket.io-adapter@npm:~2.3.3": - version: 2.3.3 - resolution: "socket.io-adapter@npm:2.3.3" - checksum: 73890e0a33e48a9e4be83e5fa2b8ea9728d2a35ae2fed373cad4d6744c6512c0e1c735e7820df9821e58c4738dc355bdaec5aae30bc56f4d6a41d999596d0c82 +"socket.io-adapter@npm:~2.4.0": + version: 2.4.0 + resolution: "socket.io-adapter@npm:2.4.0" + checksum: a84639946dce13547b95f6e09fe167cdcd5d80941afc2e46790cc23384e0fd3c901e690ecc9bdd600939ce6292261ee15094a0b486f797ed621cfc8783d87a0c languageName: node linkType: hard -"socket.io-parser@npm:~4.0.4": - version: 4.0.4 - resolution: "socket.io-parser@npm:4.0.4" +"socket.io-parser@npm:~4.2.0": + version: 4.2.1 + resolution: "socket.io-parser@npm:4.2.1" dependencies: - "@types/component-emitter": ^1.2.10 - component-emitter: ~1.3.0 + "@socket.io/component-emitter": ~3.1.0 debug: ~4.3.1 - checksum: c173b4f3747c51e2af802eca35212f4dcfa8fe55d7fdc07b9a01da1ecc956791c1bf6591e307952548eab69e6500bcfe27cea8aff1386b860d9bb51f98e4fafb + checksum: 2582202f22538d7e6b4436991378cb4cea3b2f8219cda24923ae35afd291ab5ad6120e7d093e41738256b6c6ad10c667dd25753c2d9a2340fead04e9286f152d languageName: node linkType: hard "socket.io@npm:^4.2.0": - version: 4.4.1 - resolution: "socket.io@npm:4.4.1" + version: 4.5.3 + resolution: "socket.io@npm:4.5.3" dependencies: accepts: ~1.3.4 base64id: ~2.0.0 debug: ~4.3.2 - engine.io: ~6.1.0 - socket.io-adapter: ~2.3.3 - socket.io-parser: ~4.0.4 - checksum: a559ae52359f1ca3ce5a347368cf985c72259e1ab1bf2bf769ca0add5db34e2a86f4e183a58f37f32676ec482c71fedb7b08d873dc31cf581f5ba0797a8382fe + engine.io: ~6.2.0 + socket.io-adapter: ~2.4.0 + socket.io-parser: ~4.2.0 + checksum: 2a7e4c64bbebb444d211bc66fb8356c14dd0fd4138d31e1781db03fa5a731a3abb7b305fa32cb6c7b57e5ac788601583aad14bea6ff9b8c4ca7b74118ba55f66 languageName: node linkType: hard From f7692776311cb18e203a9543c94dcceb2fcd43d1 Mon Sep 17 00:00:00 2001 From: Giancarlos Salas Date: Mon, 14 Nov 2022 10:58:32 -0600 Subject: [PATCH 03/13] Update CHANGELOG.md --- CHANGELOG.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index c77f8cc2..b8af0f84 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,12 @@ and this project adheres to ## [Unreleased] +### Fixed + +- @cosmjs/cosmwasm-stargate: Fix `ContractCodeHistory` decoding when msg contains non-printable ASCII ([#1320]). + +[#1320]: https://github.com/cosmos/cosmjs/pull/1320 + ## [0.29.3] - 2022-10-25 ### Added From c3c5517eafc150ece05b7457bd8a246a89dbbadd Mon Sep 17 00:00:00 2001 From: Simon Warta Date: Mon, 14 Nov 2022 23:59:02 +0100 Subject: [PATCH 04/13] Pull out function http and deduplicate tests --- .../src/rpcclients/http.spec.ts | 63 +++++++++++++++++++ .../tendermint-rpc/src/rpcclients/http.ts | 44 +++++++++++++ .../src/rpcclients/httpbatchclient.spec.ts | 58 ----------------- .../src/rpcclients/httpbatchclient.ts | 3 +- .../src/rpcclients/httpclient.spec.ts | 60 +----------------- .../src/rpcclients/httpclient.ts | 45 +------------ 6 files changed, 111 insertions(+), 162 deletions(-) create mode 100644 packages/tendermint-rpc/src/rpcclients/http.spec.ts create mode 100644 packages/tendermint-rpc/src/rpcclients/http.ts diff --git a/packages/tendermint-rpc/src/rpcclients/http.spec.ts b/packages/tendermint-rpc/src/rpcclients/http.spec.ts new file mode 100644 index 00000000..fa6b3b0f --- /dev/null +++ b/packages/tendermint-rpc/src/rpcclients/http.spec.ts @@ -0,0 +1,63 @@ +/* eslint-disable @typescript-eslint/naming-convention */ +import { createJsonRpcRequest } from "../jsonrpc"; +import { defaultInstance, pendingWithoutTendermint } from "../testutil.spec"; +import { http } from "./http"; + +function pendingWithoutHttpServer(): void { + if (!process.env.HTTPSERVER_ENABLED) { + pending("Set HTTPSERVER_ENABLED to enable HTTP tests"); + } +} + +const tendermintUrl = defaultInstance.url; +const echoUrl = "http://localhost:5555/echo_headers"; + +describe("http", () => { + it("can send a health request", async () => { + pendingWithoutTendermint(); + const response = await http("POST", `http://${tendermintUrl}`, undefined, createJsonRpcRequest("health")); + expect(response).toEqual(jasmine.objectContaining({ jsonrpc: "2.0" })); + }); + + it("errors for non-open port", async () => { + await expectAsync( + http("POST", `http://localhost:56745`, undefined, createJsonRpcRequest("health")), + ).toBeRejectedWithError(/(ECONNREFUSED|Failed to fetch)/i); + }); + + it("can send custom headers", async () => { + pendingWithoutHttpServer(); + // Without custom headers + const response1 = await http("POST", echoUrl, undefined, createJsonRpcRequest("health")); + expect(response1).toEqual({ + request_headers: jasmine.objectContaining({ + // Basic headers from http client + Accept: jasmine.any(String), + "Content-Length": jasmine.any(String), + "Content-Type": "application/json", + Host: jasmine.any(String), + "User-Agent": jasmine.any(String), + }), + }); + + // With custom headers + const response2 = await http( + "POST", + echoUrl, + { foo: "bar123", Authorization: "Basic Z3Vlc3Q6bm9QYXNzMTIz" }, + createJsonRpcRequest("health"), + ); + expect(response2).toEqual({ + request_headers: jasmine.objectContaining({ + // Basic headers from http client + "Content-Length": jasmine.any(String), + "Content-Type": "application/json", + Host: jasmine.any(String), + "User-Agent": jasmine.any(String), + // Custom headers + foo: "bar123", + Authorization: "Basic Z3Vlc3Q6bm9QYXNzMTIz", + }), + }); + }); +}); diff --git a/packages/tendermint-rpc/src/rpcclients/http.ts b/packages/tendermint-rpc/src/rpcclients/http.ts new file mode 100644 index 00000000..f7ec0b41 --- /dev/null +++ b/packages/tendermint-rpc/src/rpcclients/http.ts @@ -0,0 +1,44 @@ +import axios from "axios"; + +// Global symbols in some environments +// https://developer.mozilla.org/en-US/docs/Web/API/WindowOrWorkerGlobalScope/fetch +declare const fetch: any | undefined; + +function filterBadStatus(res: any): any { + if (res.status >= 400) { + throw new Error(`Bad status on response: ${res.status}`); + } + return res; +} + +/** + * Helper to work around missing CORS support in Tendermint (https://github.com/tendermint/tendermint/pull/2800) + * + * For some reason, fetch does not complain about missing server-side CORS support. + */ +// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types +export async function http( + method: "POST", + url: string, + headers: Record | undefined, + request?: any, +): Promise { + if (typeof fetch !== "undefined") { + const settings = { + method: method, + body: request ? JSON.stringify(request) : undefined, + headers: { + // eslint-disable-next-line @typescript-eslint/naming-convention + "Content-Type": "application/json", + ...headers, + }, + }; + return fetch(url, settings) + .then(filterBadStatus) + .then((res: any) => res.json()); + } else { + return axios + .request({ url: url, method: method, data: request, headers: headers }) + .then((res) => res.data); + } +} diff --git a/packages/tendermint-rpc/src/rpcclients/httpbatchclient.spec.ts b/packages/tendermint-rpc/src/rpcclients/httpbatchclient.spec.ts index c0362834..d242f84f 100644 --- a/packages/tendermint-rpc/src/rpcclients/httpbatchclient.spec.ts +++ b/packages/tendermint-rpc/src/rpcclients/httpbatchclient.spec.ts @@ -2,7 +2,6 @@ import { createJsonRpcRequest } from "../jsonrpc"; import { defaultInstance } from "../testutil.spec"; import { HttpBatchClient } from "./httpbatchclient"; -import { http } from "./httpclient"; function pendingWithoutTendermint(): void { if (!process.env.TENDERMINT_ENABLED) { @@ -10,64 +9,7 @@ function pendingWithoutTendermint(): void { } } -function pendingWithoutHttpServer(): void { - if (!process.env.HTTPSERVER_ENABLED) { - pending("Set HTTPSERVER_ENABLED to enable HTTP tests"); - } -} - const tendermintUrl = defaultInstance.url; -const echoUrl = "http://localhost:5555/echo_headers"; - -describe("http", () => { - it("can send a health request", async () => { - pendingWithoutTendermint(); - const response = await http("POST", `http://${tendermintUrl}`, undefined, createJsonRpcRequest("health")); - expect(response).toEqual(jasmine.objectContaining({ jsonrpc: "2.0" })); - }); - - it("errors for non-open port", async () => { - await expectAsync( - http("POST", `http://localhost:56745`, undefined, createJsonRpcRequest("health")), - ).toBeRejectedWithError(/(ECONNREFUSED|Failed to fetch)/i); - }); - - it("can send custom headers", async () => { - pendingWithoutHttpServer(); - // Without custom headers - const response1 = await http("POST", echoUrl, undefined, createJsonRpcRequest("health")); - expect(response1).toEqual({ - request_headers: jasmine.objectContaining({ - // Basic headers from http client - Accept: jasmine.any(String), - "Content-Length": jasmine.any(String), - "Content-Type": "application/json", - Host: jasmine.any(String), - "User-Agent": jasmine.any(String), - }), - }); - - // With custom headers - const response2 = await http( - "POST", - echoUrl, - { foo: "bar123", Authorization: "Basic Z3Vlc3Q6bm9QYXNzMTIz" }, - createJsonRpcRequest("health"), - ); - expect(response2).toEqual({ - request_headers: jasmine.objectContaining({ - // Basic headers from http client - "Content-Length": jasmine.any(String), - "Content-Type": "application/json", - Host: jasmine.any(String), - "User-Agent": jasmine.any(String), - // Custom headers - foo: "bar123", - Authorization: "Basic Z3Vlc3Q6bm9QYXNzMTIz", - }), - }); - }); -}); describe("HttpBatchClient", () => { it("can make a simple call", async () => { diff --git a/packages/tendermint-rpc/src/rpcclients/httpbatchclient.ts b/packages/tendermint-rpc/src/rpcclients/httpbatchclient.ts index 1b616c3b..f0bafc96 100644 --- a/packages/tendermint-rpc/src/rpcclients/httpbatchclient.ts +++ b/packages/tendermint-rpc/src/rpcclients/httpbatchclient.ts @@ -5,7 +5,8 @@ import { parseJsonRpcResponse, } from "@cosmjs/json-rpc"; -import { http, HttpEndpoint } from "./httpclient"; +import { http } from "./http"; +import { HttpEndpoint } from "./httpclient"; import { hasProtocol, RpcClient } from "./rpcclient"; export interface HttpBatchClientOptions { diff --git a/packages/tendermint-rpc/src/rpcclients/httpclient.spec.ts b/packages/tendermint-rpc/src/rpcclients/httpclient.spec.ts index 1c326508..11cf707e 100644 --- a/packages/tendermint-rpc/src/rpcclients/httpclient.spec.ts +++ b/packages/tendermint-rpc/src/rpcclients/httpclient.spec.ts @@ -1,7 +1,6 @@ -/* eslint-disable @typescript-eslint/naming-convention */ import { createJsonRpcRequest } from "../jsonrpc"; import { defaultInstance } from "../testutil.spec"; -import { http, HttpClient } from "./httpclient"; +import { HttpClient } from "./httpclient"; function pendingWithoutTendermint(): void { if (!process.env.TENDERMINT_ENABLED) { @@ -9,64 +8,7 @@ function pendingWithoutTendermint(): void { } } -function pendingWithoutHttpServer(): void { - if (!process.env.HTTPSERVER_ENABLED) { - pending("Set HTTPSERVER_ENABLED to enable HTTP tests"); - } -} - const tendermintUrl = defaultInstance.url; -const echoUrl = "http://localhost:5555/echo_headers"; - -describe("http", () => { - it("can send a health request", async () => { - pendingWithoutTendermint(); - const response = await http("POST", `http://${tendermintUrl}`, undefined, createJsonRpcRequest("health")); - expect(response).toEqual(jasmine.objectContaining({ jsonrpc: "2.0" })); - }); - - it("errors for non-open port", async () => { - await expectAsync( - http("POST", `http://localhost:56745`, undefined, createJsonRpcRequest("health")), - ).toBeRejectedWithError(/(ECONNREFUSED|Failed to fetch)/i); - }); - - it("can send custom headers", async () => { - pendingWithoutHttpServer(); - // Without custom headers - const response1 = await http("POST", echoUrl, undefined, createJsonRpcRequest("health")); - expect(response1).toEqual({ - request_headers: jasmine.objectContaining({ - // Basic headers from http client - Accept: jasmine.any(String), - "Content-Length": jasmine.any(String), - "Content-Type": "application/json", - Host: jasmine.any(String), - "User-Agent": jasmine.any(String), - }), - }); - - // With custom headers - const response2 = await http( - "POST", - echoUrl, - { foo: "bar123", Authorization: "Basic Z3Vlc3Q6bm9QYXNzMTIz" }, - createJsonRpcRequest("health"), - ); - expect(response2).toEqual({ - request_headers: jasmine.objectContaining({ - // Basic headers from http client - "Content-Length": jasmine.any(String), - "Content-Type": "application/json", - Host: jasmine.any(String), - "User-Agent": jasmine.any(String), - // Custom headers - foo: "bar123", - Authorization: "Basic Z3Vlc3Q6bm9QYXNzMTIz", - }), - }); - }); -}); describe("HttpClient", () => { it("can make a simple call", async () => { diff --git a/packages/tendermint-rpc/src/rpcclients/httpclient.ts b/packages/tendermint-rpc/src/rpcclients/httpclient.ts index 0b7dedac..a17e9699 100644 --- a/packages/tendermint-rpc/src/rpcclients/httpclient.ts +++ b/packages/tendermint-rpc/src/rpcclients/httpclient.ts @@ -4,53 +4,10 @@ import { JsonRpcSuccessResponse, parseJsonRpcResponse, } from "@cosmjs/json-rpc"; -import axios from "axios"; +import { http } from "./http"; import { hasProtocol, RpcClient } from "./rpcclient"; -// Global symbols in some environments -// https://developer.mozilla.org/en-US/docs/Web/API/WindowOrWorkerGlobalScope/fetch -declare const fetch: any | undefined; - -function filterBadStatus(res: any): any { - if (res.status >= 400) { - throw new Error(`Bad status on response: ${res.status}`); - } - return res; -} - -/** - * Helper to work around missing CORS support in Tendermint (https://github.com/tendermint/tendermint/pull/2800) - * - * For some reason, fetch does not complain about missing server-side CORS support. - */ -// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types -export async function http( - method: "POST", - url: string, - headers: Record | undefined, - request?: any, -): Promise { - if (typeof fetch !== "undefined") { - const settings = { - method: method, - body: request ? JSON.stringify(request) : undefined, - headers: { - // eslint-disable-next-line @typescript-eslint/naming-convention - "Content-Type": "application/json", - ...headers, - }, - }; - return fetch(url, settings) - .then(filterBadStatus) - .then((res: any) => res.json()); - } else { - return axios - .request({ url: url, method: method, data: request, headers: headers }) - .then((res) => res.data); - } -} - export interface HttpEndpoint { /** * The URL of the HTTP endpoint. From 9c623bd645ec78be603060767ff8f8428de4c882 Mon Sep 17 00:00:00 2001 From: Simon Warta Date: Tue, 15 Nov 2022 16:06:54 +0100 Subject: [PATCH 05/13] Format CHANGELOG --- CHANGELOG.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b8af0f84..31fde543 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,7 +8,8 @@ and this project adheres to ### Fixed -- @cosmjs/cosmwasm-stargate: Fix `ContractCodeHistory` decoding when msg contains non-printable ASCII ([#1320]). +- @cosmjs/cosmwasm-stargate: Fix `ContractCodeHistory` decoding when msg + contains non-printable ASCII ([#1320]). [#1320]: https://github.com/cosmos/cosmjs/pull/1320 From 3e6c9b6009ce7ab70f0a6e7656158c8a84896b21 Mon Sep 17 00:00:00 2001 From: Simon Warta Date: Tue, 15 Nov 2022 16:10:12 +0100 Subject: [PATCH 06/13] Bump elliptic version to ^6.5.4 --- CHANGELOG.md | 2 ++ packages/crypto/package.json | 2 +- yarn.lock | 4 ++-- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 31fde543..d8d7fabb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,8 @@ and this project adheres to - @cosmjs/cosmwasm-stargate: Fix `ContractCodeHistory` decoding when msg contains non-printable ASCII ([#1320]). +- @cosmjs/crypto: Bump elliptic version to ^6.5.4 due to + [CVE-2020-28498](https://github.com/advisories/GHSA-r9p9-mrjm-926w). [#1320]: https://github.com/cosmos/cosmjs/pull/1320 diff --git a/packages/crypto/package.json b/packages/crypto/package.json index 1ac84293..f8fa090e 100644 --- a/packages/crypto/package.json +++ b/packages/crypto/package.json @@ -46,7 +46,7 @@ "@cosmjs/utils": "workspace:^", "@noble/hashes": "^1", "bn.js": "^5.2.0", - "elliptic": "^6.5.3", + "elliptic": "^6.5.4", "libsodium-wrappers": "^0.7.6" }, "devDependencies": { diff --git a/yarn.lock b/yarn.lock index 204c3bff..6901f6c7 100644 --- a/yarn.lock +++ b/yarn.lock @@ -462,7 +462,7 @@ __metadata: "@typescript-eslint/parser": ^5.13.0 bn.js: ^5.2.0 buffer: ^6.0.3 - elliptic: ^6.5.3 + elliptic: ^6.5.4 eslint: ^7.5 eslint-config-prettier: ^8.3.0 eslint-import-resolver-node: ^0.3.4 @@ -3153,7 +3153,7 @@ __metadata: languageName: node linkType: hard -"elliptic@npm:^6.5.3": +"elliptic@npm:^6.5.4": version: 6.5.4 resolution: "elliptic@npm:6.5.4" dependencies: From 6fc3d331172b6a405fdada4042a78f156f6a9144 Mon Sep 17 00:00:00 2001 From: Simon Warta Date: Tue, 15 Nov 2022 16:10:35 +0100 Subject: [PATCH 07/13] Update @types/elliptic --- .pnp.cjs | 10 +++++----- ...types-elliptic-npm-6.4.12-02ae0f4627-35dc3b6b4b.zip | 3 --- ...types-elliptic-npm-6.4.14-77735f3256-d5a64f540e.zip | 3 +++ packages/crypto/package.json | 2 +- yarn.lock | 10 +++++----- 5 files changed, 14 insertions(+), 14 deletions(-) delete mode 100644 .yarn/cache/@types-elliptic-npm-6.4.12-02ae0f4627-35dc3b6b4b.zip create mode 100644 .yarn/cache/@types-elliptic-npm-6.4.14-77735f3256-d5a64f540e.zip diff --git a/.pnp.cjs b/.pnp.cjs index 4454f4cc..b540c162 100755 --- a/.pnp.cjs +++ b/.pnp.cjs @@ -473,7 +473,7 @@ function $$SETUP_STATE(hydrateRuntimeState, basePath) { ],\ [\ "@types/elliptic",\ - "npm:6.4.12"\ + "npm:6.4.14"\ ],\ [\ "@types/eslint",\ @@ -3327,7 +3327,7 @@ function $$SETUP_STATE(hydrateRuntimeState, basePath) { ["@istanbuljs/nyc-config-typescript", "virtual:4f1584ad4aba8733a24be7c8aebbffafef25607f2d00f4b314cf96717145c692763628a31c2b85d4686fbb091ff21ebffa3cc337399c042c19a32b9bdb786464#npm:1.0.1"],\ ["@noble/hashes", "npm:1.0.0"],\ ["@types/bn.js", "npm:5.1.0"],\ - ["@types/elliptic", "npm:6.4.12"],\ + ["@types/elliptic", "npm:6.4.14"],\ ["@types/eslint-plugin-prettier", "npm:3.1.0"],\ ["@types/jasmine", "npm:4.0.3"],\ ["@types/karma-firefox-launcher", "npm:2.1.0"],\ @@ -4447,10 +4447,10 @@ function $$SETUP_STATE(hydrateRuntimeState, basePath) { }]\ ]],\ ["@types/elliptic", [\ - ["npm:6.4.12", {\ - "packageLocation": "./.yarn/cache/@types-elliptic-npm-6.4.12-02ae0f4627-35dc3b6b4b.zip/node_modules/@types/elliptic/",\ + ["npm:6.4.14", {\ + "packageLocation": "./.yarn/cache/@types-elliptic-npm-6.4.14-77735f3256-d5a64f540e.zip/node_modules/@types/elliptic/",\ "packageDependencies": [\ - ["@types/elliptic", "npm:6.4.12"],\ + ["@types/elliptic", "npm:6.4.14"],\ ["@types/bn.js", "npm:5.1.0"]\ ],\ "linkType": "HARD"\ diff --git a/.yarn/cache/@types-elliptic-npm-6.4.12-02ae0f4627-35dc3b6b4b.zip b/.yarn/cache/@types-elliptic-npm-6.4.12-02ae0f4627-35dc3b6b4b.zip deleted file mode 100644 index 3342a7ad..00000000 --- a/.yarn/cache/@types-elliptic-npm-6.4.12-02ae0f4627-35dc3b6b4b.zip +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:0647abdfad876b993ec7391a3fc5d6f3bf4f63050345d4bdbe0f2136a431f5b5 -size 4392 diff --git a/.yarn/cache/@types-elliptic-npm-6.4.14-77735f3256-d5a64f540e.zip b/.yarn/cache/@types-elliptic-npm-6.4.14-77735f3256-d5a64f540e.zip new file mode 100644 index 00000000..1f359871 --- /dev/null +++ b/.yarn/cache/@types-elliptic-npm-6.4.14-77735f3256-d5a64f540e.zip @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:a0b980bc7d60169adc4cc24e3f2ab907befc8252ad290f646a3285b214a90148 +size 4409 diff --git a/packages/crypto/package.json b/packages/crypto/package.json index f8fa090e..9a7f71c8 100644 --- a/packages/crypto/package.json +++ b/packages/crypto/package.json @@ -52,7 +52,7 @@ "devDependencies": { "@istanbuljs/nyc-config-typescript": "^1.0.1", "@types/bn.js": "^5", - "@types/elliptic": "^6.4.12", + "@types/elliptic": "^6.4.14", "@types/eslint-plugin-prettier": "^3", "@types/jasmine": "^4", "@types/karma-firefox-launcher": "^2", diff --git a/yarn.lock b/yarn.lock index 6901f6c7..a9f0c953 100644 --- a/yarn.lock +++ b/yarn.lock @@ -450,7 +450,7 @@ __metadata: "@istanbuljs/nyc-config-typescript": ^1.0.1 "@noble/hashes": ^1 "@types/bn.js": ^5 - "@types/elliptic": ^6.4.12 + "@types/elliptic": ^6.4.14 "@types/eslint-plugin-prettier": ^3 "@types/jasmine": ^4 "@types/karma-firefox-launcher": ^2 @@ -1455,12 +1455,12 @@ __metadata: languageName: node linkType: hard -"@types/elliptic@npm:^6.4.12": - version: 6.4.12 - resolution: "@types/elliptic@npm:6.4.12" +"@types/elliptic@npm:^6.4.14": + version: 6.4.14 + resolution: "@types/elliptic@npm:6.4.14" dependencies: "@types/bn.js": "*" - checksum: 35dc3b6b4ba411b2e2ca2dfead45034d1411f5062183ec49270a693b7f2bdff27e3538aae8773a7fce2d04084018a28bacc8a442f578f594fad11431242d87aa + checksum: d5a64f540e0ed4b74a12dfa5cc88c0aa7b531eab3b7a9fab17948ffbfc6e01814230e63d7417ce1b607dbd8b5d70e1b64f5afac632deabf96e44875aaac0ae1b languageName: node linkType: hard From 37ed295a2e884c873ac94cde8a7a8e3ceab46666 Mon Sep 17 00:00:00 2001 From: Simon Warta Date: Tue, 15 Nov 2022 00:41:56 +0100 Subject: [PATCH 08/13] Improve HttpBatchClient constructor and add missing exports --- CHANGELOG.md | 11 +++++++++++ packages/tendermint-rpc/src/index.ts | 12 +++++++++--- .../src/rpcclients/httpbatchclient.ts | 15 +++++++++------ packages/tendermint-rpc/src/rpcclients/index.ts | 2 +- 4 files changed, 30 insertions(+), 10 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d8d7fabb..e6bf9dc9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,17 @@ and this project adheres to ## [Unreleased] +### Added + +- @cosmjs/tendermint-rpc: The options in the `HttpBatchClient` constructor are + now of type `Partial`, allowing you to set only the + fields you want to change ([#1309]). +- @cosmjs/tendermint-rpc: Add missing exports `HttpBatchClient`, + `HttpBatchClientOptions`, `RpcClient` ([#1311]). + +[#1309]: https://github.com/cosmos/cosmjs/issues/1309 +[#1311]: https://github.com/cosmos/cosmjs/issues/1311 + ### Fixed - @cosmjs/cosmwasm-stargate: Fix `ContractCodeHistory` decoding when msg diff --git a/packages/tendermint-rpc/src/index.ts b/packages/tendermint-rpc/src/index.ts index 8e307862..a1556d15 100644 --- a/packages/tendermint-rpc/src/index.ts +++ b/packages/tendermint-rpc/src/index.ts @@ -12,11 +12,17 @@ export { toRfc3339WithNanoseconds, toSeconds, } from "./dates"; +// The public Tendermint34Client.create constructor allows manually choosing an RpcClient. +// This is currently the only way to switch to the HttpBatchClient (which may become default at some point). +// Due to this API, we make RPC client implementations public. export { - // This type is part of the Tendermint34Client.connect API - HttpEndpoint, + HttpBatchClient, + HttpBatchClientOptions, + HttpClient, + HttpEndpoint, // This type is part of the Tendermint34Client.connect API + RpcClient, // Interface type in Tendermint34Client.create + WebsocketClient, } from "./rpcclients"; -export { HttpClient, WebsocketClient } from "./rpcclients"; // TODO: Why do we export those outside of this package? export { AbciInfoRequest, AbciInfoResponse, diff --git a/packages/tendermint-rpc/src/rpcclients/httpbatchclient.ts b/packages/tendermint-rpc/src/rpcclients/httpbatchclient.ts index f0bafc96..d91dc104 100644 --- a/packages/tendermint-rpc/src/rpcclients/httpbatchclient.ts +++ b/packages/tendermint-rpc/src/rpcclients/httpbatchclient.ts @@ -14,7 +14,10 @@ export interface HttpBatchClientOptions { batchSizeLimit: number; } -export const defaultHttpBatchClientOptions: HttpBatchClientOptions = { +// Those values are private and can change any time. +// Does a user need to know them? I don't think so. You either set +// a custom value or leave the option field unset. +const defaultHttpBatchClientOptions: HttpBatchClientOptions = { dispatchInterval: 20, batchSizeLimit: 20, }; @@ -31,11 +34,11 @@ export class HttpBatchClient implements RpcClient { reject: (a: Error) => void; }> = []; - public constructor( - endpoint: string | HttpEndpoint, - options: HttpBatchClientOptions = defaultHttpBatchClientOptions, - ) { - this.options = options; + public constructor(endpoint: string | HttpEndpoint, options: Partial = {}) { + this.options = { + batchSizeLimit: options.batchSizeLimit ?? defaultHttpBatchClientOptions.batchSizeLimit, + dispatchInterval: options.dispatchInterval ?? defaultHttpBatchClientOptions.dispatchInterval, + }; if (typeof endpoint === "string") { // accept host.name:port and assume http protocol this.url = hasProtocol(endpoint) ? endpoint : "http://" + endpoint; diff --git a/packages/tendermint-rpc/src/rpcclients/index.ts b/packages/tendermint-rpc/src/rpcclients/index.ts index cf7c1a70..ac89b9bb 100644 --- a/packages/tendermint-rpc/src/rpcclients/index.ts +++ b/packages/tendermint-rpc/src/rpcclients/index.ts @@ -1,6 +1,6 @@ // This folder contains Tendermint-specific RPC clients -export { defaultHttpBatchClientOptions, HttpBatchClient } from "./httpbatchclient"; +export { HttpBatchClient, HttpBatchClientOptions } from "./httpbatchclient"; export { HttpClient, HttpEndpoint } from "./httpclient"; export { instanceOfRpcStreamingClient, RpcClient, RpcStreamingClient, SubscriptionEvent } from "./rpcclient"; export { WebsocketClient } from "./websocketclient"; From 66124fcc93d1b3f5a8956f81678c72d59c5a5764 Mon Sep 17 00:00:00 2001 From: Simon Warta Date: Tue, 15 Nov 2022 01:23:47 +0100 Subject: [PATCH 09/13] Send batch immediately when full in HttpBatchClient --- CHANGELOG.md | 3 + .../src/rpcclients/httpbatchclient.spec.ts | 19 ++++++ .../src/rpcclients/httpbatchclient.ts | 59 +++++++++++++------ 3 files changed, 63 insertions(+), 18 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e6bf9dc9..0125474b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,8 +13,11 @@ and this project adheres to fields you want to change ([#1309]). - @cosmjs/tendermint-rpc: Add missing exports `HttpBatchClient`, `HttpBatchClientOptions`, `RpcClient` ([#1311]). +- @cosmjs/tendermint-rpc: Send batch immediately when full in `HttpBatchClient` + ([#1310]). [#1309]: https://github.com/cosmos/cosmjs/issues/1309 +[#1310]: https://github.com/cosmos/cosmjs/issues/1310 [#1311]: https://github.com/cosmos/cosmjs/issues/1311 ### Fixed diff --git a/packages/tendermint-rpc/src/rpcclients/httpbatchclient.spec.ts b/packages/tendermint-rpc/src/rpcclients/httpbatchclient.spec.ts index d242f84f..b05c3e56 100644 --- a/packages/tendermint-rpc/src/rpcclients/httpbatchclient.spec.ts +++ b/packages/tendermint-rpc/src/rpcclients/httpbatchclient.spec.ts @@ -30,4 +30,23 @@ describe("HttpBatchClient", () => { client.disconnect(); }); + + it("dispatches requests as soon as batch size limit is reached", async () => { + pendingWithoutTendermint(); + const client = new HttpBatchClient(tendermintUrl, { + dispatchInterval: 3600_000 /* 1h to make test time out if this is not working */, + batchSizeLimit: 3, + }); + + const healthResponse = await Promise.all([ + client.execute(createJsonRpcRequest("health")), + client.execute(createJsonRpcRequest("health")), + client.execute(createJsonRpcRequest("health")), + ]); + expect(healthResponse[0].result).toEqual({}); + expect(healthResponse[1].result).toEqual({}); + expect(healthResponse[2].result).toEqual({}); + + client.disconnect(); + }); }); diff --git a/packages/tendermint-rpc/src/rpcclients/httpbatchclient.ts b/packages/tendermint-rpc/src/rpcclients/httpbatchclient.ts index d91dc104..4b8e4fe6 100644 --- a/packages/tendermint-rpc/src/rpcclients/httpbatchclient.ts +++ b/packages/tendermint-rpc/src/rpcclients/httpbatchclient.ts @@ -10,7 +10,9 @@ import { HttpEndpoint } from "./httpclient"; import { hasProtocol, RpcClient } from "./rpcclient"; export interface HttpBatchClientOptions { + /** Interval for dispatching batches (in milliseconds) */ dispatchInterval: number; + /** Max number of items sent in one request */ batchSizeLimit: number; } @@ -58,6 +60,11 @@ export class HttpBatchClient implements RpcClient { public async execute(request: JsonRpcRequest): Promise { return new Promise((resolve, reject) => { this.queue.push({ request, resolve, reject }); + + if (this.queue.length >= this.options.batchSizeLimit) { + // this train is full, let's go + this.tick(); + } }); } @@ -71,27 +78,43 @@ export class HttpBatchClient implements RpcClient { } } - private async tick(): Promise { + /** + * This is called in an interval where promise rejections cannot be handled. + * So this is not async and HTTP errors need to be handled by the queued promises. + */ + private tick(): void { // Avoid race conditions - const queue = this.queue.splice(0, this.options.batchSizeLimit); + const batch = this.queue.splice(0, this.options.batchSizeLimit); - if (!queue.length) return; + if (!batch.length) return; - const request = queue.map((s) => s.request); - const raw = await http("POST", this.url, this.headers, request); - // Requests with a single entry return as an object - const arr = Array.isArray(raw) ? raw : [raw]; + const requests = batch.map((s) => s.request); + const requestIds = requests.map((request) => request.id); - arr.forEach((el) => { - const req = queue.find((s) => s.request.id === el.id); - if (!req) return; - const { reject, resolve } = req; - const response = parseJsonRpcResponse(el); - if (isJsonRpcErrorResponse(response)) { - reject(new Error(JSON.stringify(response.error))); - } else { - resolve(response); - } - }); + http("POST", this.url, this.headers, requests).then( + (raw) => { + // Requests with a single entry return as an object + const arr = Array.isArray(raw) ? raw : [raw]; + + arr.forEach((el) => { + const req = batch.find((s) => s.request.id === el.id); + if (!req) return; + const { reject, resolve } = req; + const response = parseJsonRpcResponse(el); + if (isJsonRpcErrorResponse(response)) { + reject(new Error(JSON.stringify(response.error))); + } else { + resolve(response); + } + }); + }, + (error) => { + for (const requestId of requestIds) { + const req = batch.find((s) => s.request.id === requestId); + if (!req) return; + req.reject(error); + } + }, + ); } } From fd0e6d7607a561292dc9b5b7f66d6899292c4abf Mon Sep 17 00:00:00 2001 From: Simon Warta Date: Tue, 15 Nov 2022 23:07:54 +0100 Subject: [PATCH 10/13] Set version 0.29.4 --- CHANGELOG.md | 5 ++++- packages/amino/package.json | 2 +- packages/cli/package.json | 2 +- packages/cosmwasm-stargate/package.json | 2 +- packages/crypto/package.json | 2 +- packages/encoding/package.json | 2 +- packages/faucet-client/package.json | 2 +- packages/faucet/package.json | 2 +- packages/json-rpc/package.json | 2 +- packages/ledger-amino/package.json | 2 +- packages/math/package.json | 2 +- packages/proto-signing/package.json | 2 +- packages/socket/package.json | 2 +- packages/stargate/package.json | 2 +- packages/stream/package.json | 2 +- packages/tendermint-rpc/package.json | 2 +- packages/utils/package.json | 2 +- 17 files changed, 20 insertions(+), 17 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0125474b..e1eeb462 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,8 @@ and this project adheres to ## [Unreleased] +## [0.29.4] - 2022-11-15 + ### Added - @cosmjs/tendermint-rpc: The options in the `HttpBatchClient` constructor are @@ -1110,7 +1112,8 @@ CHANGELOG entries missing. Please see [the diff][0.24.1]. `FeeTable`. @cosmjs/cosmwasm has its own `FeeTable` with those properties. - @cosmjs/sdk38: Rename package to @cosmjs/launchpad. -[unreleased]: https://github.com/cosmos/cosmjs/compare/v0.29.3...HEAD +[unreleased]: https://github.com/cosmos/cosmjs/compare/v0.29.4...HEAD +[0.29.4]: https://github.com/cosmos/cosmjs/compare/v0.29.3...v0.29.4 [0.29.3]: https://github.com/cosmos/cosmjs/compare/v0.29.2...v0.29.3 [0.29.2]: https://github.com/cosmos/cosmjs/compare/v0.29.1...v0.29.2 [0.29.1]: https://github.com/cosmos/cosmjs/compare/v0.29.0...v0.29.1 diff --git a/packages/amino/package.json b/packages/amino/package.json index 016fc0a4..49d28805 100644 --- a/packages/amino/package.json +++ b/packages/amino/package.json @@ -1,6 +1,6 @@ { "name": "@cosmjs/amino", - "version": "0.29.3", + "version": "0.29.4", "description": "Helpers for Amino based signing.", "contributors": [ "Simon Warta " diff --git a/packages/cli/package.json b/packages/cli/package.json index 40dfe408..e6b8656a 100644 --- a/packages/cli/package.json +++ b/packages/cli/package.json @@ -1,6 +1,6 @@ { "name": "@cosmjs/cli", - "version": "0.29.3", + "version": "0.29.4", "description": "Command line interface", "contributors": [ "IOV SAS ", diff --git a/packages/cosmwasm-stargate/package.json b/packages/cosmwasm-stargate/package.json index 95fbc9e7..a3a6ae7d 100644 --- a/packages/cosmwasm-stargate/package.json +++ b/packages/cosmwasm-stargate/package.json @@ -1,6 +1,6 @@ { "name": "@cosmjs/cosmwasm-stargate", - "version": "0.29.3", + "version": "0.29.4", "description": "CosmWasm SDK", "contributors": [ "Will Clark " diff --git a/packages/crypto/package.json b/packages/crypto/package.json index 9a7f71c8..c220e17c 100644 --- a/packages/crypto/package.json +++ b/packages/crypto/package.json @@ -1,6 +1,6 @@ { "name": "@cosmjs/crypto", - "version": "0.29.3", + "version": "0.29.4", "description": "Cryptography resources for blockchain projects", "contributors": [ "IOV SAS ", diff --git a/packages/encoding/package.json b/packages/encoding/package.json index 4dfd852c..86f8fc7f 100644 --- a/packages/encoding/package.json +++ b/packages/encoding/package.json @@ -1,6 +1,6 @@ { "name": "@cosmjs/encoding", - "version": "0.29.3", + "version": "0.29.4", "description": "Encoding helpers for blockchain projects", "contributors": [ "IOV SAS " diff --git a/packages/faucet-client/package.json b/packages/faucet-client/package.json index 9b022e7a..1b1000c3 100644 --- a/packages/faucet-client/package.json +++ b/packages/faucet-client/package.json @@ -1,6 +1,6 @@ { "name": "@cosmjs/faucet-client", - "version": "0.29.3", + "version": "0.29.4", "description": "The faucet client", "contributors": [ "Will Clark " diff --git a/packages/faucet/package.json b/packages/faucet/package.json index a508818a..7d500d83 100644 --- a/packages/faucet/package.json +++ b/packages/faucet/package.json @@ -1,6 +1,6 @@ { "name": "@cosmjs/faucet", - "version": "0.29.3", + "version": "0.29.4", "description": "The faucet", "contributors": [ "Ethan Frey ", diff --git a/packages/json-rpc/package.json b/packages/json-rpc/package.json index 8e503c39..c41f56c0 100644 --- a/packages/json-rpc/package.json +++ b/packages/json-rpc/package.json @@ -1,6 +1,6 @@ { "name": "@cosmjs/json-rpc", - "version": "0.29.3", + "version": "0.29.4", "description": "Framework for implementing a JSON-RPC 2.0 API", "contributors": [ "IOV SAS ", diff --git a/packages/ledger-amino/package.json b/packages/ledger-amino/package.json index 8575ea8e..50d1384d 100644 --- a/packages/ledger-amino/package.json +++ b/packages/ledger-amino/package.json @@ -1,6 +1,6 @@ { "name": "@cosmjs/ledger-amino", - "version": "0.29.3", + "version": "0.29.4", "description": "A library for signing Amino-encoded transactions using Ledger devices", "contributors": [ "Will Clark " diff --git a/packages/math/package.json b/packages/math/package.json index e16da5cd..b31aaf18 100644 --- a/packages/math/package.json +++ b/packages/math/package.json @@ -1,6 +1,6 @@ { "name": "@cosmjs/math", - "version": "0.29.3", + "version": "0.29.4", "description": "Math helpers for blockchain projects", "contributors": [ "IOV SAS " diff --git a/packages/proto-signing/package.json b/packages/proto-signing/package.json index 610014a8..211482ae 100644 --- a/packages/proto-signing/package.json +++ b/packages/proto-signing/package.json @@ -1,6 +1,6 @@ { "name": "@cosmjs/proto-signing", - "version": "0.29.3", + "version": "0.29.4", "description": "Utilities for protobuf based signing (Cosmos SDK 0.40+)", "contributors": [ "Will Clark ", diff --git a/packages/socket/package.json b/packages/socket/package.json index 0474d392..bb5aa18a 100644 --- a/packages/socket/package.json +++ b/packages/socket/package.json @@ -1,6 +1,6 @@ { "name": "@cosmjs/socket", - "version": "0.29.3", + "version": "0.29.4", "description": "Utility functions for working with WebSockets", "contributors": [ "IOV SAS ", diff --git a/packages/stargate/package.json b/packages/stargate/package.json index c52caae5..45035944 100644 --- a/packages/stargate/package.json +++ b/packages/stargate/package.json @@ -1,6 +1,6 @@ { "name": "@cosmjs/stargate", - "version": "0.29.3", + "version": "0.29.4", "description": "Utilities for Cosmos SDK 0.40", "contributors": [ "Simon Warta " diff --git a/packages/stream/package.json b/packages/stream/package.json index fba5b505..ce1b7225 100644 --- a/packages/stream/package.json +++ b/packages/stream/package.json @@ -1,6 +1,6 @@ { "name": "@cosmjs/stream", - "version": "0.29.3", + "version": "0.29.4", "description": "Utility functions for producing and consuming streams", "contributors": [ "IOV SAS ", diff --git a/packages/tendermint-rpc/package.json b/packages/tendermint-rpc/package.json index aac83d0d..8283d9c0 100644 --- a/packages/tendermint-rpc/package.json +++ b/packages/tendermint-rpc/package.json @@ -1,6 +1,6 @@ { "name": "@cosmjs/tendermint-rpc", - "version": "0.29.3", + "version": "0.29.4", "description": "Tendermint RPC clients", "contributors": [ "IOV SAS ", diff --git a/packages/utils/package.json b/packages/utils/package.json index 8f8254eb..0c484987 100644 --- a/packages/utils/package.json +++ b/packages/utils/package.json @@ -1,6 +1,6 @@ { "name": "@cosmjs/utils", - "version": "0.29.3", + "version": "0.29.4", "description": "Utility tools, primarily for testing code", "contributors": [ "IOV SAS " From 8c896162398f7ee6eff02ee6c1f6d4172c65f598 Mon Sep 17 00:00:00 2001 From: Simon Warta Date: Thu, 24 Nov 2022 19:26:48 +0100 Subject: [PATCH 11/13] Upgrade git-lfs_2.13.3_amd64.deb in CI --- .circleci/config.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 351d3168..ef088ec8 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -85,7 +85,7 @@ jobs: name: Install Git Large File Storage (LFS) # In the current image, `sudo apt install git-lfs` requires `sudo apt update` which is too slow command: | - wget -O "$HOME/git-lfs.deb" https://packagecloud.io/github/git-lfs/packages/ubuntu/focal/git-lfs_2.12.1_amd64.deb/download.deb + wget -O "$HOME/git-lfs.deb" https://packagecloud.io/github/git-lfs/packages/ubuntu/focal/git-lfs_2.13.3_amd64.deb/download.deb sudo dpkg -i "$HOME/git-lfs.deb" - checkout - run: # start early for less wait time below @@ -207,7 +207,7 @@ jobs: name: Install Git Large File Storage (LFS) # In the current image, `sudo apt install git-lfs` requires `sudo apt update` which is too slow command: | - wget -O "$HOME/git-lfs.deb" https://packagecloud.io/github/git-lfs/packages/ubuntu/focal/git-lfs_2.12.1_amd64.deb/download.deb + wget -O "$HOME/git-lfs.deb" https://packagecloud.io/github/git-lfs/packages/ubuntu/focal/git-lfs_2.13.3_amd64.deb/download.deb sudo dpkg -i "$HOME/git-lfs.deb" - checkout - run: # start early for less wait time below @@ -329,7 +329,7 @@ jobs: name: Install Git Large File Storage (LFS) # In the current image, `sudo apt install git-lfs` requires `sudo apt update` which is too slow command: | - wget -O "$HOME/git-lfs.deb" https://packagecloud.io/github/git-lfs/packages/ubuntu/focal/git-lfs_2.12.1_amd64.deb/download.deb + wget -O "$HOME/git-lfs.deb" https://packagecloud.io/github/git-lfs/packages/ubuntu/focal/git-lfs_2.13.3_amd64.deb/download.deb sudo dpkg -i "$HOME/git-lfs.deb" - checkout - run: # start early for less wait time below @@ -427,7 +427,7 @@ jobs: name: Install Git Large File Storage (LFS) # In the current image, `sudo apt install git-lfs` requires `sudo apt update` which is too slow command: | - wget -O "$HOME/git-lfs.deb" https://packagecloud.io/github/git-lfs/packages/ubuntu/focal/git-lfs_2.12.1_amd64.deb/download.deb + wget -O "$HOME/git-lfs.deb" https://packagecloud.io/github/git-lfs/packages/ubuntu/focal/git-lfs_2.13.3_amd64.deb/download.deb sudo dpkg -i "$HOME/git-lfs.deb" - checkout - run: # start early for less wait time below From 503e94996f34b8375392d9bd2fd431363f8f5cbe Mon Sep 17 00:00:00 2001 From: Simon Warta Date: Thu, 24 Nov 2022 15:27:03 +0100 Subject: [PATCH 12/13] Add QueryClient.queryAbci and deprecate QueryClient.queryUnverified --- CHANGELOG.md | 5 + .../src/queryclient/queryclient.spec.ts | 91 +++++++++++++++++++ .../stargate/src/queryclient/queryclient.ts | 40 +++++++- packages/stargate/src/queryclient/utils.ts | 5 +- 4 files changed, 138 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e1eeb462..8efd05b8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,11 @@ and this project adheres to ## [Unreleased] +### Deprecated + +- @cosmjs/stargate: Deprecate `QueryClient.queryUnverified` in favour of newly + added `QueryClient.queryAbci`. + ## [0.29.4] - 2022-11-15 ### Added diff --git a/packages/stargate/src/queryclient/queryclient.spec.ts b/packages/stargate/src/queryclient/queryclient.spec.ts index 823fb13a..05cc40ec 100644 --- a/packages/stargate/src/queryclient/queryclient.spec.ts +++ b/packages/stargate/src/queryclient/queryclient.spec.ts @@ -166,4 +166,95 @@ describe("QueryClient", () => { tmClient.disconnect(); }); }); + + describe("queryAbci", () => { + it("works via WebSockets", async () => { + pendingWithoutSimapp(); + const [client, tmClient] = await makeClient(simapp.tendermintUrlWs); + + const requestData = Uint8Array.from( + QueryAllBalancesRequest.encode({ address: unused.address }).finish(), + ); + const { value } = await client.queryAbci(`/cosmos.bank.v1beta1.Query/AllBalances`, requestData); + const response = QueryAllBalancesResponse.decode(value); + expect(response.balances.length).toEqual(2); + + tmClient.disconnect(); + }); + + it("works via http", async () => { + pendingWithoutSimapp(); + const [client, tmClient] = await makeClient(simapp.tendermintUrlHttp); + + const requestData = Uint8Array.from( + QueryAllBalancesRequest.encode({ address: unused.address }).finish(), + ); + const { value } = await client.queryAbci(`/cosmos.bank.v1beta1.Query/AllBalances`, requestData); + const response = QueryAllBalancesResponse.decode(value); + expect(response.balances.length).toEqual(2); + + tmClient.disconnect(); + }); + + it("works for height", async () => { + pendingWithoutSimapp(); + const [queryClient, tmClient] = await makeClient(simapp.tendermintUrlHttp); + + const joe = makeRandomAddress(); + const h1 = (await tmClient.status()).syncInfo.latestBlockHeight; + + // Send tokens to `recipient` + const wallet = await DirectSecp256k1HdWallet.fromMnemonic(faucet.mnemonic); + const client = await SigningStargateClient.connectWithSigner( + simapp.tendermintUrlHttp, + wallet, + defaultSigningClientOptions, + ); + const amount = coin(332211, simapp.denomFee); + await client.sendTokens(faucet.address0, joe, [amount], "auto"); + + const h2 = (await tmClient.status()).syncInfo.latestBlockHeight; + assert(h1 < h2); + + // Query with no height + { + const requestData = QueryBalanceRequest.encode({ address: joe, denom: simapp.denomFee }).finish(); + const { value, height } = await queryClient.queryAbci( + `/cosmos.bank.v1beta1.Query/Balance`, + requestData, + ); + const response = QueryBalanceResponse.decode(value); + expect(response.balance).toEqual(amount); + expect(height).toEqual(h2); + } + + // Query at h2 (after send) + { + const requestData = QueryBalanceRequest.encode({ address: joe, denom: simapp.denomFee }).finish(); + const { value, height } = await queryClient.queryAbci( + `/cosmos.bank.v1beta1.Query/Balance`, + requestData, + h2, + ); + const response = QueryBalanceResponse.decode(value); + expect(response.balance).toEqual(amount); + expect(height).toEqual(h2); + } + + // Query at h1 (before send) + { + const requestData = QueryBalanceRequest.encode({ address: joe, denom: simapp.denomFee }).finish(); + const { value, height } = await queryClient.queryAbci( + `/cosmos.bank.v1beta1.Query/Balance`, + requestData, + h1, + ); + const response = QueryBalanceResponse.decode(value); + expect(response.balance).toEqual({ amount: "0", denom: simapp.denomFee }); + expect(height).toEqual(h1); + } + + tmClient.disconnect(); + }); + }); }); diff --git a/packages/stargate/src/queryclient/queryclient.ts b/packages/stargate/src/queryclient/queryclient.ts index eceec992..2737d735 100644 --- a/packages/stargate/src/queryclient/queryclient.ts +++ b/packages/stargate/src/queryclient/queryclient.ts @@ -26,6 +26,16 @@ export interface ProvenQuery { readonly height: number; } +/** + * The response of an ABCI query to Tendermint. + * This is a subset of `tendermint34.AbciQueryResponse` in order + * to abstract away Tendermint versions. + */ +export interface QueryAbciResponse { + readonly value: Uint8Array; + readonly height: number; +} + export class QueryClient { /** Constructs a QueryClient with 0 extensions */ public static withExtensions(tmClient: Tendermint34Client): QueryClient; @@ -570,11 +580,32 @@ export class QueryClient { }; } + /** + * Performs an ABCI query to Tendermint without requesting a proof. + * + * @deprecated use queryAbci instead + */ public async queryUnverified( path: string, request: Uint8Array, desiredHeight?: number, ): Promise { + const response = await this.queryAbci(path, request, desiredHeight); + return response.value; + } + + /** + * Performs an ABCI query to Tendermint without requesting a proof. + * + * If the `desiredHeight` is set, a particular height is requested. Otherwise + * the latest height is requested. The response contains the actual height of + * the query. + */ + public async queryAbci( + path: string, + request: Uint8Array, + desiredHeight?: number, + ): Promise { const response = await this.tmClient.abciQuery({ path: path, data: request, @@ -586,7 +617,14 @@ export class QueryClient { throw new Error(`Query failed with (${response.code}): ${response.log}`); } - return response.value; + if (!response.height) { + throw new Error("No query height returned"); + } + + return { + value: response.value, + height: response.height, + }; } // this must return the header for height+1 diff --git a/packages/stargate/src/queryclient/utils.ts b/packages/stargate/src/queryclient/utils.ts index a0fb6220..4afa3739 100644 --- a/packages/stargate/src/queryclient/utils.ts +++ b/packages/stargate/src/queryclient/utils.ts @@ -31,9 +31,10 @@ export interface ProtobufRpcClient { export function createProtobufRpcClient(base: QueryClient): ProtobufRpcClient { return { - request: (service: string, method: string, data: Uint8Array): Promise => { + request: async (service: string, method: string, data: Uint8Array): Promise => { const path = `/${service}/${method}`; - return base.queryUnverified(path, data); + const response = await base.queryAbci(path, data, undefined); + return response.value; }, }; } From 51ca98eda12ca643d50d2d31308406623109c741 Mon Sep 17 00:00:00 2001 From: Simon Warta Date: Thu, 24 Nov 2022 19:18:58 +0100 Subject: [PATCH 13/13] Create authInfo with type --- packages/proto-signing/src/signing.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/proto-signing/src/signing.ts b/packages/proto-signing/src/signing.ts index 7ce7e476..985b89b2 100644 --- a/packages/proto-signing/src/signing.ts +++ b/packages/proto-signing/src/signing.ts @@ -46,7 +46,7 @@ export function makeAuthInfoBytes( ); assert(feePayer === undefined || typeof feePayer === "string", "feePayer must be undefined or string"); - const authInfo = { + const authInfo = AuthInfo.fromPartial({ signerInfos: makeSignerInfos(signers, signMode), fee: { amount: [...feeAmount], @@ -54,8 +54,8 @@ export function makeAuthInfoBytes( granter: feeGranter, payer: feePayer, }, - }; - return AuthInfo.encode(AuthInfo.fromPartial(authInfo)).finish(); + }); + return AuthInfo.encode(authInfo).finish(); } export function makeSignDoc(