Merge remote-tracking branch 'upstream/main' into feat/timeout-height

This commit is contained in:
janfabian 2023-10-25 16:37:14 +02:00
commit d7bf870e6c
130 changed files with 1196 additions and 900 deletions

677
.pnp.cjs generated

File diff suppressed because it is too large Load Diff

BIN
.yarn/cache/@ampproject-remapping-npm-2.2.1-3da3d624be-03c04fd526.zip (Stored with Git LFS) vendored Normal file

Binary file not shown.

Binary file not shown.

BIN
.yarn/cache/@babel-code-frame-npm-7.22.13-2782581d20-22e342c807.zip (Stored with Git LFS) vendored Normal file

Binary file not shown.

Binary file not shown.

BIN
.yarn/cache/@babel-compat-data-npm-7.23.2-763f35b25b-d8dc27437d.zip (Stored with Git LFS) vendored Normal file

Binary file not shown.

Binary file not shown.

BIN
.yarn/cache/@babel-core-npm-7.23.2-b93f586907-003897718d.zip (Stored with Git LFS) vendored Normal file

Binary file not shown.

Binary file not shown.

BIN
.yarn/cache/@babel-generator-npm-7.23.0-08841c5369-8efe24adad.zip (Stored with Git LFS) vendored Normal file

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

BIN
.yarn/cache/@babel-helpers-npm-7.23.2-aa45e8b40c-aaf4828df7.zip (Stored with Git LFS) vendored Normal file

Binary file not shown.

Binary file not shown.

BIN
.yarn/cache/@babel-highlight-npm-7.22.20-5de7aba88d-84bd034dca.zip (Stored with Git LFS) vendored Normal file

Binary file not shown.

Binary file not shown.

BIN
.yarn/cache/@babel-parser-npm-7.23.0-8a7b151672-453fdf8b9e.zip (Stored with Git LFS) vendored Normal file

Binary file not shown.

Binary file not shown.

BIN
.yarn/cache/@babel-runtime-npm-7.23.2-d013d6cf7e-6c4df4839e.zip (Stored with Git LFS) vendored Normal file

Binary file not shown.

Binary file not shown.

BIN
.yarn/cache/@babel-template-npm-7.22.15-0b464facb4-1f3e7dcd6c.zip (Stored with Git LFS) vendored Normal file

Binary file not shown.

Binary file not shown.

BIN
.yarn/cache/@babel-traverse-npm-7.23.2-4758feee42-26a1eea0dd.zip (Stored with Git LFS) vendored Normal file

Binary file not shown.

Binary file not shown.

BIN
.yarn/cache/@babel-types-npm-7.23.0-332fd21daf-215fe04bd7.zip (Stored with Git LFS) vendored Normal file

Binary file not shown.

BIN
.yarn/cache/@jridgewell-gen-mapping-npm-0.3.3-1815eba94c-4a74944bd3.zip (Stored with Git LFS) vendored Normal file

Binary file not shown.

Binary file not shown.

BIN
.yarn/cache/@types-jasmine-npm-4.6.1-55b5288466-1c34321d0b.zip (Stored with Git LFS) vendored Normal file

Binary file not shown.

BIN
.yarn/cache/browserslist-npm-4.22.1-cccae6d74e-7e6b10c53f.zip (Stored with Git LFS) vendored Normal file

Binary file not shown.

BIN
.yarn/cache/caniuse-lite-npm-1.0.30001553-af33af7fcd-45d6a2a3c3.zip (Stored with Git LFS) vendored Normal file

Binary file not shown.

BIN
.yarn/cache/convert-source-map-npm-2.0.0-7ab664dc4e-63ae9933be.zip (Stored with Git LFS) vendored Normal file

Binary file not shown.

Binary file not shown.

BIN
.yarn/cache/cosmjs-types-npm-0.9.0-e5d36a4ae5-9b00d169ec.zip (Stored with Git LFS) vendored Normal file

Binary file not shown.

BIN
.yarn/cache/electron-to-chromium-npm-1.4.565-e46f4c4b3f-5baa0ea0b5.zip (Stored with Git LFS) vendored Normal file

Binary file not shown.

Binary file not shown.

BIN
.yarn/cache/jasmine-core-npm-4.6.0-57a71d0bb0-c5c5ce16c5.zip (Stored with Git LFS) vendored Normal file

Binary file not shown.

BIN
.yarn/cache/jasmine-npm-4.2.1-b8c8f1d620-3fe11afead.zip (Stored with Git LFS) vendored

Binary file not shown.

BIN
.yarn/cache/jasmine-npm-4.6.0-610a07828e-1034466aac.zip (Stored with Git LFS) vendored Normal file

Binary file not shown.

BIN
.yarn/cache/json5-npm-2.2.0-da49dc7cb5-e88fc5274b.zip (Stored with Git LFS) vendored

Binary file not shown.

BIN
.yarn/cache/json5-npm-2.2.3-9962c55073-2a7436a933.zip (Stored with Git LFS) vendored Normal file

Binary file not shown.

BIN
.yarn/cache/lru-cache-npm-5.1.1-f475882a51-c154ae1cbb.zip (Stored with Git LFS) vendored Normal file

Binary file not shown.

BIN
.yarn/cache/node-releases-npm-2.0.13-1f2e177887-17ec8f315d.zip (Stored with Git LFS) vendored Normal file

Binary file not shown.

BIN
.yarn/cache/picocolors-npm-1.0.0-d81e0b1927-a2e8092dd8.zip (Stored with Git LFS) vendored Normal file

Binary file not shown.

Binary file not shown.

BIN
.yarn/cache/regenerator-runtime-npm-0.14.0-e060897cf7-1c977ad82a.zip (Stored with Git LFS) vendored Normal file

Binary file not shown.

BIN
.yarn/cache/semver-npm-6.3.1-bcba31fdbe-ae47d06de2.zip (Stored with Git LFS) vendored Normal file

Binary file not shown.

Binary file not shown.

BIN
.yarn/cache/update-browserslist-db-npm-1.0.13-ea7b8ee24d-1e47d80182.zip (Stored with Git LFS) vendored Normal file

Binary file not shown.

BIN
.yarn/cache/yallist-npm-3.1.1-a568a556b4-48f7bb00dc.zip (Stored with Git LFS) vendored Normal file

Binary file not shown.

View File

@ -6,15 +6,12 @@ and this project adheres to
## [Unreleased] ## [Unreleased]
### Fixed
- @cosmjs/stargate: Add missing memo field to Amino JSON representation of
`MsgTransfer` and adapt converters. ([#1456])
[#1456]: https://github.com/cosmos/cosmjs/issues/1429
### Changed ### Changed
- all: Upgrade cosmjs-types to 0.9.0. This makes a few fields non-optional. It
changes all 64 bit int fields from type `long` to `bigint`. As part of the
upgrade, the types do not require the `long` and `protobufjs` anymore.
([#1484])
- Drop support for Node.js 14 and add support for Node.js 20. ([#1421]) - Drop support for Node.js 14 and add support for Node.js 20. ([#1421])
- @cosmjs/tendermint-rpc: Remove `Adaptor` abstractions which are not needed - @cosmjs/tendermint-rpc: Remove `Adaptor` abstractions which are not needed
anymore by haing a dedicated client for each backend. anymore by haing a dedicated client for each backend.
@ -23,12 +20,31 @@ and this project adheres to
`connectComet` for auto-detecting the right client for a provided endpoint. `connectComet` for auto-detecting the right client for a provided endpoint.
[#1421]: https://github.com/cosmos/cosmjs/issues/1421 [#1421]: https://github.com/cosmos/cosmjs/issues/1421
[#1484]: https://github.com/cosmos/cosmjs/pull/1484
### Deprecated ### Deprecated
- @cosmjs/tendermint-rpc: `CometClient` should be used instead of - @cosmjs/tendermint-rpc: `CometClient` should be used instead of
`TendermintClient`. `TendermintClient`.
## [0.31.3] - 2023-10-25
### Fixed
- @cosmjs/stargate: Add missing memo field to `fromAmino` implementation for
`MsgTransfer`. ([#1493])
[#1493]: https://github.com/cosmos/cosmjs/issues/1493
## [0.31.2] - 2023-10-24
### Fixed
- @cosmjs/stargate: Add missing memo field to Amino JSON representation of
`MsgTransfer` and adapt converters. ([#1456])
[#1456]: https://github.com/cosmos/cosmjs/pull/1456
## [0.31.1] - 2023-08-21 ## [0.31.1] - 2023-08-21
### Fixed ### Fixed
@ -1318,7 +1334,9 @@ CHANGELOG entries missing. Please see [the diff][0.24.1].
`FeeTable`. @cosmjs/cosmwasm has its own `FeeTable` with those properties. `FeeTable`. @cosmjs/cosmwasm has its own `FeeTable` with those properties.
- @cosmjs/sdk38: Rename package to @cosmjs/launchpad. - @cosmjs/sdk38: Rename package to @cosmjs/launchpad.
[unreleased]: https://github.com/cosmos/cosmjs/compare/v0.31.1...HEAD [unreleased]: https://github.com/cosmos/cosmjs/compare/v0.31.3...HEAD
[0.31.3]: https://github.com/cosmos/cosmjs/compare/v0.31.2...v0.31.3
[0.31.2]: https://github.com/cosmos/cosmjs/compare/v0.31.1...v0.31.2
[0.31.1]: https://github.com/cosmos/cosmjs/compare/v0.31.0...v0.31.1 [0.31.1]: https://github.com/cosmos/cosmjs/compare/v0.31.0...v0.31.1
[0.31.0]: https://github.com/cosmos/cosmjs/compare/v0.30.1...v0.31.0 [0.31.0]: https://github.com/cosmos/cosmjs/compare/v0.30.1...v0.31.0
[0.30.1]: https://github.com/cosmos/cosmjs/compare/v0.30.0...v0.30.1 [0.30.1]: https://github.com/cosmos/cosmjs/compare/v0.30.0...v0.30.1

View File

@ -1,6 +1,6 @@
{ {
"name": "@cosmjs/amino", "name": "@cosmjs/amino",
"version": "0.31.1", "version": "0.31.3",
"description": "Helpers for Amino based signing.", "description": "Helpers for Amino based signing.",
"contributors": [ "contributors": [
"Simon Warta <webmaster128@users.noreply.github.com>" "Simon Warta <webmaster128@users.noreply.github.com>"

View File

@ -1,6 +1,6 @@
{ {
"name": "@cosmjs/cli", "name": "@cosmjs/cli",
"version": "0.31.1", "version": "0.31.3",
"description": "Command line interface", "description": "Command line interface",
"contributors": [ "contributors": [
"IOV SAS <admin@iov.one>", "IOV SAS <admin@iov.one>",
@ -54,7 +54,7 @@
"axios": "^0.21.2", "axios": "^0.21.2",
"babylon": "^6.18.0", "babylon": "^6.18.0",
"chalk": "^4", "chalk": "^4",
"cosmjs-types": "^0.8.0", "cosmjs-types": "^0.9.0",
"diff": "^4", "diff": "^4",
"recast": "^0.20", "recast": "^0.20",
"ts-node": "^8", "ts-node": "^8",

View File

@ -1,6 +1,6 @@
{ {
"name": "@cosmjs/cosmwasm-stargate", "name": "@cosmjs/cosmwasm-stargate",
"version": "0.31.1", "version": "0.31.3",
"description": "CosmWasm SDK", "description": "CosmWasm SDK",
"contributors": [ "contributors": [
"Will Clark <willclarktech@users.noreply.github.com>" "Will Clark <willclarktech@users.noreply.github.com>"
@ -46,8 +46,7 @@
"@cosmjs/stargate": "workspace:^", "@cosmjs/stargate": "workspace:^",
"@cosmjs/tendermint-rpc": "workspace:^", "@cosmjs/tendermint-rpc": "workspace:^",
"@cosmjs/utils": "workspace:^", "@cosmjs/utils": "workspace:^",
"cosmjs-types": "^0.8.0", "cosmjs-types": "^0.9.0",
"long": "^4.0.0",
"pako": "^2.0.2" "pako": "^2.0.2"
}, },
"devDependencies": { "devDependencies": {
@ -79,7 +78,6 @@
"karma-jasmine-html-reporter": "^1.5.4", "karma-jasmine-html-reporter": "^1.5.4",
"nyc": "^15.1.0", "nyc": "^15.1.0",
"prettier": "^2.8.1", "prettier": "^2.8.1",
"protobufjs": "~6.11.4",
"readonly-date": "^1.0.0", "readonly-date": "^1.0.0",
"ses": "^0.11.0", "ses": "^0.11.0",
"source-map-support": "^0.5.19", "source-map-support": "^0.5.19",

View File

@ -339,7 +339,7 @@ export class CosmWasmClient {
return allCodes.map((entry: CodeInfoResponse): Code => { return allCodes.map((entry: CodeInfoResponse): Code => {
assert(entry.creator && entry.codeId && entry.dataHash, "entry incomplete"); assert(entry.creator && entry.codeId && entry.dataHash, "entry incomplete");
return { return {
id: entry.codeId.toNumber(), id: Number(entry.codeId),
creator: entry.creator, creator: entry.creator,
checksum: toHex(entry.dataHash), checksum: toHex(entry.dataHash),
}; };
@ -356,7 +356,7 @@ export class CosmWasmClient {
"codeInfo missing or incomplete", "codeInfo missing or incomplete",
); );
const codeDetails: CodeDetails = { const codeDetails: CodeDetails = {
id: codeInfo.codeId.toNumber(), id: Number(codeInfo.codeId),
creator: codeInfo.creator, creator: codeInfo.creator,
checksum: toHex(codeInfo.dataHash), checksum: toHex(codeInfo.dataHash),
data: data, data: data,
@ -413,7 +413,7 @@ export class CosmWasmClient {
assert(contractInfo.codeId && contractInfo.creator && contractInfo.label, "contractInfo incomplete"); assert(contractInfo.codeId && contractInfo.creator && contractInfo.label, "contractInfo incomplete");
return { return {
address: retrievedAddress, address: retrievedAddress,
codeId: contractInfo.codeId.toNumber(), codeId: Number(contractInfo.codeId),
creator: contractInfo.creator, creator: contractInfo.creator,
admin: contractInfo.admin || undefined, admin: contractInfo.admin || undefined,
label: contractInfo.label, label: contractInfo.label,
@ -436,7 +436,7 @@ export class CosmWasmClient {
assert(entry.operation && entry.codeId && entry.msg); assert(entry.operation && entry.codeId && entry.msg);
return { return {
operation: operations[entry.operation], operation: operations[entry.operation],
codeId: entry.codeId.toNumber(), codeId: Number(entry.codeId),
msg: JSON.parse(fromUtf8(entry.msg)), msg: JSON.parse(fromUtf8(entry.msg)),
}; };
}); });

View File

@ -11,7 +11,6 @@ import {
MsgUpdateAdmin, MsgUpdateAdmin,
} from "cosmjs-types/cosmwasm/wasm/v1/tx"; } from "cosmjs-types/cosmwasm/wasm/v1/tx";
import { AccessType } from "cosmjs-types/cosmwasm/wasm/v1/types"; import { AccessType } from "cosmjs-types/cosmwasm/wasm/v1/types";
import Long from "long";
import { import {
AminoMsgClearAdmin, AminoMsgClearAdmin,
@ -27,11 +26,10 @@ import {
describe("AminoTypes", () => { describe("AminoTypes", () => {
describe("toAmino", () => { describe("toAmino", () => {
it("works for MsgStoreCode", () => { it("works for MsgStoreCode", () => {
const msg: MsgStoreCode = { const msg = MsgStoreCode.fromPartial({
sender: "cosmos1pkptre7fdkl6gfrzlesjjvhxhlc3r4gmmk8rs6", sender: "cosmos1pkptre7fdkl6gfrzlesjjvhxhlc3r4gmmk8rs6",
wasmByteCode: fromBase64("WUVMTE9XIFNVQk1BUklORQ=="), wasmByteCode: fromBase64("WUVMTE9XIFNVQk1BUklORQ=="),
instantiatePermission: undefined, });
};
const aminoMsg = new AminoTypes(createWasmAminoConverters()).toAmino({ const aminoMsg = new AminoTypes(createWasmAminoConverters()).toAmino({
typeUrl: "/cosmwasm.wasm.v1.MsgStoreCode", typeUrl: "/cosmwasm.wasm.v1.MsgStoreCode",
value: msg, value: msg,
@ -81,7 +79,7 @@ describe("AminoTypes", () => {
{ {
const msg: MsgInstantiateContract = { const msg: MsgInstantiateContract = {
sender: "cosmos1pkptre7fdkl6gfrzlesjjvhxhlc3r4gmmk8rs6", sender: "cosmos1pkptre7fdkl6gfrzlesjjvhxhlc3r4gmmk8rs6",
codeId: Long.fromString("12345"), codeId: BigInt("12345"),
label: "sticky", label: "sticky",
msg: toUtf8(`{"foo":"bar"}`), msg: toUtf8(`{"foo":"bar"}`),
funds: coins(1234, "ucosm"), funds: coins(1234, "ucosm"),
@ -109,7 +107,7 @@ describe("AminoTypes", () => {
{ {
const msg: MsgInstantiateContract = { const msg: MsgInstantiateContract = {
sender: "cosmos1pkptre7fdkl6gfrzlesjjvhxhlc3r4gmmk8rs6", sender: "cosmos1pkptre7fdkl6gfrzlesjjvhxhlc3r4gmmk8rs6",
codeId: Long.fromString("12345"), codeId: BigInt("12345"),
label: "sticky", label: "sticky",
msg: toUtf8(`{"foo":"bar"}`), msg: toUtf8(`{"foo":"bar"}`),
funds: coins(1234, "ucosm"), funds: coins(1234, "ucosm"),
@ -139,7 +137,7 @@ describe("AminoTypes", () => {
{ {
const msg: MsgInstantiateContract2 = { const msg: MsgInstantiateContract2 = {
sender: "cosmos1pkptre7fdkl6gfrzlesjjvhxhlc3r4gmmk8rs6", sender: "cosmos1pkptre7fdkl6gfrzlesjjvhxhlc3r4gmmk8rs6",
codeId: Long.fromString("12345"), codeId: BigInt("12345"),
label: "sticky", label: "sticky",
msg: toUtf8(`{"foo":"bar"}`), msg: toUtf8(`{"foo":"bar"}`),
funds: coins(1234, "ucosm"), funds: coins(1234, "ucosm"),
@ -171,7 +169,7 @@ describe("AminoTypes", () => {
{ {
const msg: MsgInstantiateContract2 = { const msg: MsgInstantiateContract2 = {
sender: "cosmos1pkptre7fdkl6gfrzlesjjvhxhlc3r4gmmk8rs6", sender: "cosmos1pkptre7fdkl6gfrzlesjjvhxhlc3r4gmmk8rs6",
codeId: Long.fromString("12345"), codeId: BigInt("12345"),
label: "sticky", label: "sticky",
msg: toUtf8(`{"foo":"bar"}`), msg: toUtf8(`{"foo":"bar"}`),
funds: coins(1234, "ucosm"), funds: coins(1234, "ucosm"),
@ -267,7 +265,7 @@ describe("AminoTypes", () => {
const msg: MsgMigrateContract = { const msg: MsgMigrateContract = {
sender: "cosmos1pkptre7fdkl6gfrzlesjjvhxhlc3r4gmmk8rs6", sender: "cosmos1pkptre7fdkl6gfrzlesjjvhxhlc3r4gmmk8rs6",
contract: "cosmos1xy4yqngt0nlkdcenxymg8tenrghmek4nmqm28k", contract: "cosmos1xy4yqngt0nlkdcenxymg8tenrghmek4nmqm28k",
codeId: Long.fromString("98765"), codeId: BigInt("98765"),
msg: toUtf8(`{"foo":"bar"}`), msg: toUtf8(`{"foo":"bar"}`),
}; };
const aminoMsg = new AminoTypes(createWasmAminoConverters()).toAmino({ const aminoMsg = new AminoTypes(createWasmAminoConverters()).toAmino({
@ -297,11 +295,10 @@ describe("AminoTypes", () => {
}, },
}; };
const msg = new AminoTypes(createWasmAminoConverters()).fromAmino(aminoMsg); const msg = new AminoTypes(createWasmAminoConverters()).fromAmino(aminoMsg);
const expectedValue: MsgStoreCode = { const expectedValue = MsgStoreCode.fromPartial({
sender: "cosmos1pkptre7fdkl6gfrzlesjjvhxhlc3r4gmmk8rs6", sender: "cosmos1pkptre7fdkl6gfrzlesjjvhxhlc3r4gmmk8rs6",
wasmByteCode: fromBase64("WUVMTE9XIFNVQk1BUklORQ=="), wasmByteCode: fromBase64("WUVMTE9XIFNVQk1BUklORQ=="),
instantiatePermission: undefined, });
};
expect(msg).toEqual({ expect(msg).toEqual({
typeUrl: "/cosmwasm.wasm.v1.MsgStoreCode", typeUrl: "/cosmwasm.wasm.v1.MsgStoreCode",
value: expectedValue, value: expectedValue,
@ -354,7 +351,7 @@ describe("AminoTypes", () => {
const msg = new AminoTypes(createWasmAminoConverters()).fromAmino(aminoMsg); const msg = new AminoTypes(createWasmAminoConverters()).fromAmino(aminoMsg);
const expectedValue: MsgInstantiateContract = { const expectedValue: MsgInstantiateContract = {
sender: "cosmos1pkptre7fdkl6gfrzlesjjvhxhlc3r4gmmk8rs6", sender: "cosmos1pkptre7fdkl6gfrzlesjjvhxhlc3r4gmmk8rs6",
codeId: Long.fromString("12345"), codeId: BigInt("12345"),
label: "sticky", label: "sticky",
msg: toUtf8(`{"foo":"bar"}`), msg: toUtf8(`{"foo":"bar"}`),
funds: coins(1234, "ucosm"), funds: coins(1234, "ucosm"),
@ -381,7 +378,7 @@ describe("AminoTypes", () => {
const msg = new AminoTypes(createWasmAminoConverters()).fromAmino(aminoMsg); const msg = new AminoTypes(createWasmAminoConverters()).fromAmino(aminoMsg);
const expectedValue: MsgInstantiateContract = { const expectedValue: MsgInstantiateContract = {
sender: "cosmos1pkptre7fdkl6gfrzlesjjvhxhlc3r4gmmk8rs6", sender: "cosmos1pkptre7fdkl6gfrzlesjjvhxhlc3r4gmmk8rs6",
codeId: Long.fromString("12345"), codeId: BigInt("12345"),
label: "sticky", label: "sticky",
msg: toUtf8(`{"foo":"bar"}`), msg: toUtf8(`{"foo":"bar"}`),
funds: coins(1234, "ucosm"), funds: coins(1234, "ucosm"),
@ -471,7 +468,7 @@ describe("AminoTypes", () => {
const expectedValue: MsgMigrateContract = { const expectedValue: MsgMigrateContract = {
sender: "cosmos1pkptre7fdkl6gfrzlesjjvhxhlc3r4gmmk8rs6", sender: "cosmos1pkptre7fdkl6gfrzlesjjvhxhlc3r4gmmk8rs6",
contract: "cosmos1xy4yqngt0nlkdcenxymg8tenrghmek4nmqm28k", contract: "cosmos1xy4yqngt0nlkdcenxymg8tenrghmek4nmqm28k",
codeId: Long.fromString("98765"), codeId: BigInt("98765"),
msg: toUtf8(`{"foo":"bar"}`), msg: toUtf8(`{"foo":"bar"}`),
}; };
expect(msg).toEqual({ expect(msg).toEqual({

View File

@ -10,8 +10,7 @@ import {
MsgStoreCode, MsgStoreCode,
MsgUpdateAdmin, MsgUpdateAdmin,
} from "cosmjs-types/cosmwasm/wasm/v1/tx"; } from "cosmjs-types/cosmwasm/wasm/v1/tx";
import { AccessType } from "cosmjs-types/cosmwasm/wasm/v1/types"; import { AccessConfig, AccessType } from "cosmjs-types/cosmwasm/wasm/v1/types";
import Long from "long";
export function accessTypeFromString(str: string): AccessType { export function accessTypeFromString(str: string): AccessType {
switch (str) { switch (str) {
@ -51,7 +50,7 @@ export function accessTypeToString(object: any): string {
/** /**
* @see https://github.com/CosmWasm/wasmd/blob/v0.18.0-rc1/proto/cosmwasm/wasm/v1/types.proto#L36-L41 * @see https://github.com/CosmWasm/wasmd/blob/v0.18.0-rc1/proto/cosmwasm/wasm/v1/types.proto#L36-L41
*/ */
export interface AccessConfig { export interface AminoAccessConfig {
/** /**
* Permission should be one kind of string 'Nobody', 'OnlyAddress', 'Everybody', 'AnyOfAddresses', 'Unspecified' * Permission should be one kind of string 'Nobody', 'OnlyAddress', 'Everybody', 'AnyOfAddresses', 'Unspecified'
* @see https://github.com/CosmWasm/wasmd/blob/v0.31.0/x/wasm/types/params.go#L54 * @see https://github.com/CosmWasm/wasmd/blob/v0.31.0/x/wasm/types/params.go#L54
@ -77,7 +76,7 @@ export interface AminoMsgStoreCode {
readonly sender: string; readonly sender: string;
/** Base64 encoded Wasm */ /** Base64 encoded Wasm */
readonly wasm_byte_code: string; readonly wasm_byte_code: string;
readonly instantiate_permission?: AccessConfig; readonly instantiate_permission?: AminoAccessConfig;
}; };
} }
@ -226,11 +225,11 @@ export function createWasmAminoConverters(): AminoConverters {
sender: sender, sender: sender,
wasmByteCode: fromBase64(wasm_byte_code), wasmByteCode: fromBase64(wasm_byte_code),
instantiatePermission: instantiate_permission instantiatePermission: instantiate_permission
? { ? AccessConfig.fromPartial({
permission: accessTypeFromString(instantiate_permission.permission), permission: accessTypeFromString(instantiate_permission.permission),
address: instantiate_permission.address ?? "", address: instantiate_permission.address ?? "",
addresses: instantiate_permission.addresses ?? [], addresses: instantiate_permission.addresses ?? [],
} })
: undefined, : undefined,
}), }),
}, },
@ -260,7 +259,7 @@ export function createWasmAminoConverters(): AminoConverters {
admin, admin,
}: AminoMsgInstantiateContract["value"]): MsgInstantiateContract => ({ }: AminoMsgInstantiateContract["value"]): MsgInstantiateContract => ({
sender: sender, sender: sender,
codeId: Long.fromString(code_id), codeId: BigInt(code_id),
label: label, label: label,
msg: toUtf8(JSON.stringify(msg)), msg: toUtf8(JSON.stringify(msg)),
funds: [...funds], funds: [...funds],
@ -299,7 +298,7 @@ export function createWasmAminoConverters(): AminoConverters {
fix_msg, fix_msg,
}: AminoMsgInstantiateContract2["value"]): MsgInstantiateContract2 => ({ }: AminoMsgInstantiateContract2["value"]): MsgInstantiateContract2 => ({
sender: sender, sender: sender,
codeId: Long.fromString(code_id), codeId: BigInt(code_id),
label: label, label: label,
msg: toUtf8(JSON.stringify(msg)), msg: toUtf8(JSON.stringify(msg)),
funds: [...funds], funds: [...funds],
@ -368,7 +367,7 @@ export function createWasmAminoConverters(): AminoConverters {
}: AminoMsgMigrateContract["value"]): MsgMigrateContract => ({ }: AminoMsgMigrateContract["value"]): MsgMigrateContract => ({
sender: sender, sender: sender,
contract: contract, contract: contract,
codeId: Long.fromString(code_id), codeId: BigInt(code_id),
msg: toUtf8(JSON.stringify(msg)), msg: toUtf8(JSON.stringify(msg)),
}), }),
}, },

View File

@ -14,7 +14,6 @@ import {
import { assert, assertDefined } from "@cosmjs/utils"; import { assert, assertDefined } from "@cosmjs/utils";
import { MsgExecuteContract, MsgInstantiateContract, MsgStoreCode } from "cosmjs-types/cosmwasm/wasm/v1/tx"; import { MsgExecuteContract, MsgInstantiateContract, MsgStoreCode } from "cosmjs-types/cosmwasm/wasm/v1/tx";
import { AbsoluteTxPosition, ContractCodeHistoryOperationType } from "cosmjs-types/cosmwasm/wasm/v1/types"; import { AbsoluteTxPosition, ContractCodeHistoryOperationType } from "cosmjs-types/cosmwasm/wasm/v1/types";
import Long from "long";
import { SigningCosmWasmClient } from "../../signingcosmwasmclient"; import { SigningCosmWasmClient } from "../../signingcosmwasmclient";
import { import {
@ -74,7 +73,7 @@ async function instantiateContract(
typeUrl: "/cosmwasm.wasm.v1.MsgInstantiateContract", typeUrl: "/cosmwasm.wasm.v1.MsgInstantiateContract",
value: MsgInstantiateContract.fromPartial({ value: MsgInstantiateContract.fromPartial({
sender: alice.address0, sender: alice.address0,
codeId: Long.fromNumber(codeId), codeId: BigInt(codeId),
label: "my escrow", label: "my escrow",
msg: toUtf8( msg: toUtf8(
JSON.stringify({ JSON.stringify({
@ -161,7 +160,7 @@ describe("WasmExtension", () => {
const { codeInfos } = await client.wasm.listCodeInfo(); const { codeInfos } = await client.wasm.listCodeInfo();
assert(codeInfos); assert(codeInfos);
const lastCode = codeInfos[codeInfos.length - 1]; const lastCode = codeInfos[codeInfos.length - 1];
expect(lastCode.codeId.toNumber()).toEqual(hackatomCodeId); expect(Number(lastCode.codeId)).toEqual(hackatomCodeId);
expect(lastCode.creator).toEqual(alice.address0); expect(lastCode.creator).toEqual(alice.address0);
expect(toHex(lastCode.dataHash)).toEqual(toHex(sha256(hackatom.data))); expect(toHex(lastCode.dataHash)).toEqual(toHex(sha256(hackatom.data)));
}); });
@ -174,7 +173,7 @@ describe("WasmExtension", () => {
const client = await makeWasmClient(wasmd.endpoint); const client = await makeWasmClient(wasmd.endpoint);
const { codeInfo, data } = await client.wasm.getCode(hackatomCodeId); const { codeInfo, data } = await client.wasm.getCode(hackatomCodeId);
assert(codeInfo); assert(codeInfo);
expect(codeInfo.codeId.toNumber()).toEqual(hackatomCodeId); expect(Number(codeInfo.codeId)).toEqual(hackatomCodeId);
expect(codeInfo.creator).toEqual(alice.address0); expect(codeInfo.creator).toEqual(alice.address0);
expect(toHex(codeInfo.dataHash)).toEqual(toHex(sha256(hackatom.data))); expect(toHex(codeInfo.dataHash)).toEqual(toHex(sha256(hackatom.data)));
expect(data).toEqual(hackatom.data); expect(data).toEqual(hackatom.data);
@ -213,18 +212,20 @@ describe("WasmExtension", () => {
const { contractInfo } = await client.wasm.getContractInfo(myAddress); const { contractInfo } = await client.wasm.getContractInfo(myAddress);
assert(contractInfo); assert(contractInfo);
expect(contractInfo).toEqual({ expect(contractInfo).toEqual(
codeId: Long.fromNumber(hackatomCodeId, true), jasmine.objectContaining({
codeId: BigInt(hackatomCodeId),
creator: alice.address0, creator: alice.address0,
label: "my escrow", label: "my escrow",
admin: "", admin: "",
ibcPortId: "", ibcPortId: "",
created: AbsoluteTxPosition.fromPartial({ created: AbsoluteTxPosition.fromPartial({
blockHeight: Long.fromNumber(instantiateResult.height, true), blockHeight: BigInt(instantiateResult.height),
txIndex: Long.UZERO, txIndex: BigInt(0),
}), }),
extension: undefined, extension: undefined,
}); }),
);
expect(contractInfo.admin).toEqual(""); expect(contractInfo.admin).toEqual("");
}); });
@ -261,7 +262,7 @@ describe("WasmExtension", () => {
assert(history.entries); assert(history.entries);
expect(history.entries).toContain( expect(history.entries).toContain(
jasmine.objectContaining({ jasmine.objectContaining({
codeId: Long.fromNumber(hackatomCodeId, true), codeId: BigInt(hackatomCodeId),
operation: ContractCodeHistoryOperationType.CONTRACT_CODE_HISTORY_OPERATION_TYPE_INIT, operation: ContractCodeHistoryOperationType.CONTRACT_CODE_HISTORY_OPERATION_TYPE_INIT,
msg: toUtf8( msg: toUtf8(
JSON.stringify({ JSON.stringify({

View File

@ -3,15 +3,16 @@ import { createPagination, createProtobufRpcClient, QueryClient } from "@cosmjs/
import { import {
QueryAllContractStateResponse, QueryAllContractStateResponse,
QueryClientImpl, QueryClientImpl,
QueryCodeRequest,
QueryCodeResponse, QueryCodeResponse,
QueryCodesResponse, QueryCodesResponse,
QueryContractHistoryResponse, QueryContractHistoryResponse,
QueryContractInfoResponse, QueryContractInfoResponse,
QueryContractsByCodeRequest,
QueryContractsByCodeResponse, QueryContractsByCodeResponse,
QueryContractsByCreatorResponse, QueryContractsByCreatorResponse,
QueryRawContractStateResponse, QueryRawContractStateResponse,
} from "cosmjs-types/cosmwasm/wasm/v1/query"; } from "cosmjs-types/cosmwasm/wasm/v1/query";
import Long from "long";
/** /**
* An object containing a parsed JSON document. The result of JSON.parse(). * An object containing a parsed JSON document. The result of JSON.parse().
@ -88,14 +89,14 @@ export function setupWasmExtension(base: QueryClient): WasmExtension {
return queryService.Codes(request); return queryService.Codes(request);
}, },
getCode: async (id: number) => { getCode: async (id: number) => {
const request = { codeId: Long.fromNumber(id) }; const request = QueryCodeRequest.fromPartial({ codeId: BigInt(id) });
return queryService.Code(request); return queryService.Code(request);
}, },
listContractsByCodeId: async (id: number, paginationKey?: Uint8Array) => { listContractsByCodeId: async (id: number, paginationKey?: Uint8Array) => {
const request = { const request = QueryContractsByCodeRequest.fromPartial({
codeId: Long.fromNumber(id), codeId: BigInt(id),
pagination: createPagination(paginationKey), pagination: createPagination(paginationKey),
}; });
return queryService.ContractsByCode(request); return queryService.ContractsByCode(request);
}, },
listContractsByCreator: async (creator: string, paginationKey?: Uint8Array) => { listContractsByCreator: async (creator: string, paginationKey?: Uint8Array) => {

View File

@ -15,15 +15,14 @@ import {
} from "@cosmjs/stargate"; } from "@cosmjs/stargate";
import { assert, sleep } from "@cosmjs/utils"; import { assert, sleep } from "@cosmjs/utils";
import { DeepPartial } from "cosmjs-types"; import { DeepPartial } from "cosmjs-types";
import { BinaryWriter } from "cosmjs-types/binary";
import { MsgSend } from "cosmjs-types/cosmos/bank/v1beta1/tx"; import { MsgSend } from "cosmjs-types/cosmos/bank/v1beta1/tx";
import { Coin } from "cosmjs-types/cosmos/base/v1beta1/coin"; import { Coin } from "cosmjs-types/cosmos/base/v1beta1/coin";
import { MsgDelegate } from "cosmjs-types/cosmos/staking/v1beta1/tx"; import { MsgDelegate } from "cosmjs-types/cosmos/staking/v1beta1/tx";
import { AuthInfo, TxBody, TxRaw } from "cosmjs-types/cosmos/tx/v1beta1/tx"; import { AuthInfo, TxBody, TxRaw } from "cosmjs-types/cosmos/tx/v1beta1/tx";
import { MsgExecuteContract, MsgStoreCode } from "cosmjs-types/cosmwasm/wasm/v1/tx"; import { MsgExecuteContract, MsgStoreCode } from "cosmjs-types/cosmwasm/wasm/v1/tx";
import { AccessConfig, AccessType } from "cosmjs-types/cosmwasm/wasm/v1/types"; import { AccessConfig, AccessType } from "cosmjs-types/cosmwasm/wasm/v1/types";
import Long from "long";
import pako from "pako"; import pako from "pako";
import protobuf from "protobufjs/minimal";
import { instantiate2Address } from "./instantiate2"; import { instantiate2Address } from "./instantiate2";
import { MsgExecuteContractEncodeObject, MsgStoreCodeEncodeObject } from "./modules"; import { MsgExecuteContractEncodeObject, MsgStoreCodeEncodeObject } from "./modules";
@ -481,7 +480,7 @@ describe("SigningCosmWasmClient", () => {
assert(contractInfo2); assert(contractInfo2);
expect({ ...contractInfo2 }).toEqual({ expect({ ...contractInfo2 }).toEqual({
...contractInfo1, ...contractInfo1,
codeId: Long.fromNumber(codeId2, true), codeId: BigInt(codeId2),
}); });
client.disconnect(); client.disconnect();
@ -526,7 +525,7 @@ describe("SigningCosmWasmClient", () => {
assert(contractInfo2); assert(contractInfo2);
expect({ ...contractInfo2 }).toEqual({ expect({ ...contractInfo2 }).toEqual({
...contractInfo1, ...contractInfo1,
codeId: Long.fromNumber(codeId2, true), codeId: BigInt(codeId2),
}); });
client.disconnect(); client.disconnect();
@ -879,7 +878,7 @@ describe("SigningCosmWasmClient", () => {
// From ModifyingDirectSecp256k1HdWallet // From ModifyingDirectSecp256k1HdWallet
expect(tx.body.memo).toEqual("This was modified"); expect(tx.body.memo).toEqual("This was modified");
expect({ ...tx.authInfo.fee!.amount[0] }).toEqual(coin(3000, "ucosm")); expect({ ...tx.authInfo.fee!.amount[0] }).toEqual(coin(3000, "ucosm"));
expect(tx.authInfo.fee!.gasLimit.toNumber()).toEqual(333333); expect(Number(tx.authInfo.fee!.gasLimit)).toEqual(333333);
client.disconnect(); client.disconnect();
}); });
@ -949,11 +948,10 @@ describe("SigningCosmWasmClient", () => {
}); });
const { data } = getHackatom(); const { data } = getHackatom();
const msgStoreCode: MsgStoreCode = { const msgStoreCode = MsgStoreCode.fromPartial({
sender: alice.address0, sender: alice.address0,
wasmByteCode: pako.gzip(data), wasmByteCode: pako.gzip(data),
instantiatePermission: undefined, });
};
const msgAny: MsgStoreCodeEncodeObject = { const msgAny: MsgStoreCodeEncodeObject = {
typeUrl: "/cosmwasm.wasm.v1.MsgStoreCode", typeUrl: "/cosmwasm.wasm.v1.MsgStoreCode",
value: msgStoreCode, value: msgStoreCode,
@ -985,11 +983,9 @@ describe("SigningCosmWasmClient", () => {
customValidatorAddress: "", customValidatorAddress: "",
}; };
const CustomMsgDelegate = { const CustomMsgDelegate = {
typeUrl: "foobar",
// Adapted from autogenerated MsgDelegate implementation // Adapted from autogenerated MsgDelegate implementation
encode( encode(message: CustomMsgDelegate, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter {
message: CustomMsgDelegate,
writer: protobuf.Writer = protobuf.Writer.create(),
): protobuf.Writer {
writer.uint32(10).string(message.customDelegatorAddress ?? ""); writer.uint32(10).string(message.customDelegatorAddress ?? "");
writer.uint32(18).string(message.customValidatorAddress ?? ""); writer.uint32(18).string(message.customValidatorAddress ?? "");
if (message.customAmount !== undefined) { if (message.customAmount !== undefined) {
@ -1118,7 +1114,7 @@ describe("SigningCosmWasmClient", () => {
// From ModifyingSecp256k1HdWallet // From ModifyingSecp256k1HdWallet
expect(tx.body.memo).toEqual("This was modified"); expect(tx.body.memo).toEqual("This was modified");
expect({ ...tx.authInfo.fee!.amount[0] }).toEqual(coin(3000, "ucosm")); expect({ ...tx.authInfo.fee!.amount[0] }).toEqual(coin(3000, "ucosm"));
expect(tx.authInfo.fee!.gasLimit.toNumber()).toEqual(333333); expect(Number(tx.authInfo.fee!.gasLimit)).toEqual(333333);
client.disconnect(); client.disconnect();
}); });
@ -1187,7 +1183,7 @@ describe("SigningCosmWasmClient", () => {
// From ModifyingDirectSecp256k1HdWallet // From ModifyingDirectSecp256k1HdWallet
expect(body.memo).toEqual("This was modified"); expect(body.memo).toEqual("This was modified");
expect({ ...authInfo.fee!.amount[0] }).toEqual(coin(3000, "ucosm")); expect({ ...authInfo.fee!.amount[0] }).toEqual(coin(3000, "ucosm"));
expect(authInfo.fee!.gasLimit.toNumber()).toEqual(333333); expect(Number(authInfo.fee!.gasLimit)).toEqual(333333);
// ensure signature is valid // ensure signature is valid
const result = await client.broadcastTx(Uint8Array.from(TxRaw.encode(signed).finish())); const result = await client.broadcastTx(Uint8Array.from(TxRaw.encode(signed).finish()));
@ -1313,11 +1309,9 @@ describe("SigningCosmWasmClient", () => {
customValidatorAddress: "", customValidatorAddress: "",
}; };
const CustomMsgDelegate = { const CustomMsgDelegate = {
typeUrl: "foobar",
// Adapted from autogenerated MsgDelegate implementation // Adapted from autogenerated MsgDelegate implementation
encode( encode(message: CustomMsgDelegate, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter {
message: CustomMsgDelegate,
writer: protobuf.Writer = protobuf.Writer.create(),
): protobuf.Writer {
writer.uint32(10).string(message.customDelegatorAddress ?? ""); writer.uint32(10).string(message.customDelegatorAddress ?? "");
writer.uint32(18).string(message.customValidatorAddress ?? ""); writer.uint32(18).string(message.customValidatorAddress ?? "");
if (message.customAmount !== undefined && message.customAmount !== undefined) { if (message.customAmount !== undefined && message.customAmount !== undefined) {
@ -1443,7 +1437,7 @@ describe("SigningCosmWasmClient", () => {
// From ModifyingSecp256k1HdWallet // From ModifyingSecp256k1HdWallet
expect(body.memo).toEqual("This was modified"); expect(body.memo).toEqual("This was modified");
expect({ ...authInfo.fee!.amount[0] }).toEqual(coin(3000, "ucosm")); expect({ ...authInfo.fee!.amount[0] }).toEqual(coin(3000, "ucosm"));
expect(authInfo.fee!.gasLimit.toNumber()).toEqual(333333); expect(Number(authInfo.fee!.gasLimit)).toEqual(333333);
// ensure signature is valid // ensure signature is valid
const result = await client.broadcastTx(Uint8Array.from(TxRaw.encode(signed).finish())); const result = await client.broadcastTx(Uint8Array.from(TxRaw.encode(signed).finish()));

View File

@ -47,7 +47,6 @@ import {
MsgUpdateAdmin, MsgUpdateAdmin,
} from "cosmjs-types/cosmwasm/wasm/v1/tx"; } from "cosmjs-types/cosmwasm/wasm/v1/tx";
import { AccessConfig } from "cosmjs-types/cosmwasm/wasm/v1/types"; import { AccessConfig } from "cosmjs-types/cosmwasm/wasm/v1/types";
import Long from "long";
import pako from "pako"; import pako from "pako";
import { CosmWasmClient } from "./cosmwasmclient"; import { CosmWasmClient } from "./cosmwasmclient";
@ -317,7 +316,7 @@ export class SigningCosmWasmClient extends CosmWasmClient {
typeUrl: "/cosmwasm.wasm.v1.MsgInstantiateContract", typeUrl: "/cosmwasm.wasm.v1.MsgInstantiateContract",
value: MsgInstantiateContract.fromPartial({ value: MsgInstantiateContract.fromPartial({
sender: senderAddress, sender: senderAddress,
codeId: Long.fromString(new Uint53(codeId).toString()), codeId: BigInt(new Uint53(codeId).toString()),
label: label, label: label,
msg: toUtf8(JSON.stringify(msg)), msg: toUtf8(JSON.stringify(msg)),
funds: [...(options.funds || [])], funds: [...(options.funds || [])],
@ -354,7 +353,7 @@ export class SigningCosmWasmClient extends CosmWasmClient {
typeUrl: "/cosmwasm.wasm.v1.MsgInstantiateContract2", typeUrl: "/cosmwasm.wasm.v1.MsgInstantiateContract2",
value: MsgInstantiateContract2.fromPartial({ value: MsgInstantiateContract2.fromPartial({
sender: senderAddress, sender: senderAddress,
codeId: Long.fromString(new Uint53(codeId).toString()), codeId: BigInt(new Uint53(codeId).toString()),
label: label, label: label,
msg: toUtf8(JSON.stringify(msg)), msg: toUtf8(JSON.stringify(msg)),
funds: [...(options.funds || [])], funds: [...(options.funds || [])],
@ -449,7 +448,7 @@ export class SigningCosmWasmClient extends CosmWasmClient {
value: MsgMigrateContract.fromPartial({ value: MsgMigrateContract.fromPartial({
sender: senderAddress, sender: senderAddress,
contract: contractAddress, contract: contractAddress,
codeId: Long.fromString(new Uint53(codeId).toString()), codeId: BigInt(new Uint53(codeId).toString()),
msg: toUtf8(JSON.stringify(migrateMsg)), msg: toUtf8(JSON.stringify(migrateMsg)),
}), }),
}; };

View File

@ -19,6 +19,7 @@ import {
setupBankExtension, setupBankExtension,
} from "@cosmjs/stargate"; } from "@cosmjs/stargate";
import { Tendermint34Client } from "@cosmjs/tendermint-rpc"; import { Tendermint34Client } from "@cosmjs/tendermint-rpc";
import { assertDefinedAndNotNull } from "@cosmjs/utils";
import { SignMode } from "cosmjs-types/cosmos/tx/signing/v1beta1/signing"; import { SignMode } from "cosmjs-types/cosmos/tx/signing/v1beta1/signing";
import { AuthInfo, SignDoc, TxBody } from "cosmjs-types/cosmos/tx/v1beta1/tx"; import { AuthInfo, SignDoc, TxBody } from "cosmjs-types/cosmos/tx/v1beta1/tx";
@ -219,10 +220,13 @@ export class ModifyingDirectSecp256k1HdWallet extends DirectSecp256k1HdWallet {
memo: "This was modified", memo: "This was modified",
}); });
const authInfo = AuthInfo.decode(signDoc.authInfoBytes); const authInfo = AuthInfo.decode(signDoc.authInfoBytes);
const signers = authInfo.signerInfos.map((signerInfo) => ({ const signers = authInfo.signerInfos.map((signerInfo) => {
pubkey: signerInfo.publicKey!, assertDefinedAndNotNull(signerInfo.publicKey);
sequence: signerInfo.sequence.toNumber(), return {
})); pubkey: signerInfo.publicKey,
sequence: Number(signerInfo.sequence),
};
});
const modifiedFeeAmount = coins(3000, "ucosm"); const modifiedFeeAmount = coins(3000, "ucosm");
const modifiedGasLimit = 333333; const modifiedGasLimit = 333333;
const modifiedFeeGranter = undefined; const modifiedFeeGranter = undefined;

View File

@ -1,6 +1,6 @@
{ {
"name": "@cosmjs/crypto", "name": "@cosmjs/crypto",
"version": "0.31.1", "version": "0.31.3",
"description": "Cryptography resources for blockchain projects", "description": "Cryptography resources for blockchain projects",
"contributors": [ "contributors": [
"IOV SAS <admin@iov.one>", "IOV SAS <admin@iov.one>",

View File

@ -1,6 +1,6 @@
{ {
"name": "@cosmjs/encoding", "name": "@cosmjs/encoding",
"version": "0.31.1", "version": "0.31.3",
"description": "Encoding helpers for blockchain projects", "description": "Encoding helpers for blockchain projects",
"contributors": [ "contributors": [
"IOV SAS <admin@iov.one>" "IOV SAS <admin@iov.one>"

View File

@ -1,6 +1,6 @@
{ {
"name": "@cosmjs/faucet-client", "name": "@cosmjs/faucet-client",
"version": "0.31.1", "version": "0.31.3",
"description": "The faucet client", "description": "The faucet client",
"contributors": [ "contributors": [
"Will Clark <willclarktech@users.noreply.github.com>" "Will Clark <willclarktech@users.noreply.github.com>"

View File

@ -1,6 +1,6 @@
{ {
"name": "@cosmjs/faucet", "name": "@cosmjs/faucet",
"version": "0.31.1", "version": "0.31.3",
"description": "The faucet", "description": "The faucet",
"contributors": [ "contributors": [
"Ethan Frey <ethanfrey@users.noreply.github.com>", "Ethan Frey <ethanfrey@users.noreply.github.com>",

View File

@ -1,6 +1,6 @@
{ {
"name": "@cosmjs/json-rpc", "name": "@cosmjs/json-rpc",
"version": "0.31.1", "version": "0.31.3",
"description": "Framework for implementing a JSON-RPC 2.0 API", "description": "Framework for implementing a JSON-RPC 2.0 API",
"contributors": [ "contributors": [
"IOV SAS <admin@iov.one>", "IOV SAS <admin@iov.one>",

View File

@ -1,6 +1,6 @@
{ {
"name": "@cosmjs/ledger-amino", "name": "@cosmjs/ledger-amino",
"version": "0.31.1", "version": "0.31.3",
"description": "A library for signing Amino-encoded transactions using Ledger devices", "description": "A library for signing Amino-encoded transactions using Ledger devices",
"contributors": [ "contributors": [
"Will Clark <willclarktech@users.noreply.github.com>" "Will Clark <willclarktech@users.noreply.github.com>"

View File

@ -1,6 +1,6 @@
{ {
"name": "@cosmjs/math", "name": "@cosmjs/math",
"version": "0.31.1", "version": "0.31.3",
"description": "Math helpers for blockchain projects", "description": "Math helpers for blockchain projects",
"contributors": [ "contributors": [
"IOV SAS <admin@iov.one>" "IOV SAS <admin@iov.one>"

View File

@ -1,6 +1,6 @@
{ {
"name": "@cosmjs/proto-signing", "name": "@cosmjs/proto-signing",
"version": "0.31.1", "version": "0.31.3",
"description": "Utilities for protobuf based signing (Cosmos SDK 0.40+)", "description": "Utilities for protobuf based signing (Cosmos SDK 0.40+)",
"contributors": [ "contributors": [
"Will Clark <willclarktech@users.noreply.github.com>", "Will Clark <willclarktech@users.noreply.github.com>",
@ -44,8 +44,7 @@
"@cosmjs/encoding": "workspace:^", "@cosmjs/encoding": "workspace:^",
"@cosmjs/math": "workspace:^", "@cosmjs/math": "workspace:^",
"@cosmjs/utils": "workspace:^", "@cosmjs/utils": "workspace:^",
"cosmjs-types": "^0.8.0", "cosmjs-types": "^0.9.0"
"long": "^4.0.0"
}, },
"devDependencies": { "devDependencies": {
"@istanbuljs/nyc-config-typescript": "^1.0.1", "@istanbuljs/nyc-config-typescript": "^1.0.1",

View File

@ -3,7 +3,6 @@ import { MsgSend } from "cosmjs-types/cosmos/bank/v1beta1/tx";
import { PubKey } from "cosmjs-types/cosmos/crypto/secp256k1/keys"; import { PubKey } from "cosmjs-types/cosmos/crypto/secp256k1/keys";
import { SignMode } from "cosmjs-types/cosmos/tx/signing/v1beta1/signing"; import { SignMode } from "cosmjs-types/cosmos/tx/signing/v1beta1/signing";
import { Any } from "cosmjs-types/google/protobuf/any"; import { Any } from "cosmjs-types/google/protobuf/any";
import Long from "long";
import { decodeTxRaw } from "./decode"; import { decodeTxRaw } from "./decode";
import { faucet, testVectors } from "./testutils.spec"; import { faucet, testVectors } from "./testutils.spec";
@ -46,11 +45,11 @@ describe("decode", () => {
}, },
multi: undefined, multi: undefined,
}, },
sequence: Long.UZERO, sequence: BigInt(0),
}, },
], ],
fee: { fee: {
gasLimit: Long.fromNumber(200000, true), gasLimit: BigInt(200000),
payer: "", payer: "",
granter: "", granter: "",
amount: [{ amount: "2000", denom: "ucosm" }], amount: [{ amount: "2000", denom: "ucosm" }],
@ -58,7 +57,7 @@ describe("decode", () => {
}), }),
body: { body: {
memo: "", memo: "",
timeoutHeight: Long.UZERO, timeoutHeight: BigInt(0),
messages: [expectedMsg], messages: [expectedMsg],
extensionOptions: [], extensionOptions: [],
nonCriticalExtensionOptions: [], nonCriticalExtensionOptions: [],

View File

@ -8,7 +8,7 @@ export {
} from "./directsecp256k1hdwallet"; } from "./directsecp256k1hdwallet";
export { DirectSecp256k1Wallet } from "./directsecp256k1wallet"; export { DirectSecp256k1Wallet } from "./directsecp256k1wallet";
export { makeCosmoshubPath } from "./paths"; export { makeCosmoshubPath } from "./paths";
export { anyToSinglePubkey, decodePubkey, encodePubkey } from "./pubkey"; export { anyToSinglePubkey, decodeOptionalPubkey, decodePubkey, encodePubkey } from "./pubkey";
export { export {
DecodeObject, DecodeObject,
EncodeObject, EncodeObject,

View File

@ -97,6 +97,30 @@ export function decodePubkey(pubkey: Any): Pubkey {
return out; return out;
} }
default: default:
throw new Error(`Pubkey type_url ${pubkey.typeUrl} not recognized`); throw new Error(`Pubkey type URL '${pubkey.typeUrl}' not recognized`);
}
}
/**
* Decodes an optional pubkey from a protobuf `Any` into `Pubkey | null`.
* This supports single pubkeys such as Cosmos ed25519 and secp256k1 keys
* as well as multisig threshold pubkeys.
*/
export function decodeOptionalPubkey(pubkey: Any | null | undefined): Pubkey | null {
if (!pubkey) return null;
if (pubkey.typeUrl) {
if (pubkey.value.length) {
// both set
return decodePubkey(pubkey);
} else {
throw new Error(`Pubkey is an Any with type URL '${pubkey.typeUrl}' but an empty value`);
}
} else {
if (pubkey.value.length) {
throw new Error(`Pubkey is an Any with an empty type URL but a value set`);
} else {
// both unset, assuming this empty instance means null
return null;
}
} }
} }

View File

@ -4,7 +4,6 @@ import { assert } from "@cosmjs/utils";
import { MsgSend as IMsgSend } from "cosmjs-types/cosmos/bank/v1beta1/tx"; import { MsgSend as IMsgSend } from "cosmjs-types/cosmos/bank/v1beta1/tx";
import { TxBody } from "cosmjs-types/cosmos/tx/v1beta1/tx"; import { TxBody } from "cosmjs-types/cosmos/tx/v1beta1/tx";
import { Any } from "cosmjs-types/google/protobuf/any"; import { Any } from "cosmjs-types/google/protobuf/any";
import Long from "long";
import { Field, Type } from "protobufjs"; import { Field, Type } from "protobufjs";
import { isPbjsGeneratedType, isTsProtoGeneratedType, Registry } from "./registry"; import { isPbjsGeneratedType, isTsProtoGeneratedType, Registry } from "./registry";
@ -36,7 +35,7 @@ describe("registry demo", () => {
const txBody = TxBody.fromPartial({ const txBody = TxBody.fromPartial({
messages: [msgSendWrapped], messages: [msgSendWrapped],
memo: "Some memo", memo: "Some memo",
timeoutHeight: Long.fromNumber(9999), timeoutHeight: BigInt(9999),
extensionOptions: [], extensionOptions: [],
}); });
const txBodyBytes = TxBody.encode(txBody).finish(); const txBodyBytes = TxBody.encode(txBody).finish();
@ -84,7 +83,7 @@ describe("registry demo", () => {
const txBody = TxBody.fromPartial({ const txBody = TxBody.fromPartial({
messages: [msgDemoWrapped], messages: [msgDemoWrapped],
memo: "Some memo", memo: "Some memo",
timeoutHeight: Long.fromNumber(9999), timeoutHeight: BigInt(9999),
extensionOptions: [], extensionOptions: [],
}); });
const txBodyBytes = TxBody.encode(txBody).finish(); const txBodyBytes = TxBody.encode(txBody).finish();

View File

@ -1,11 +1,29 @@
/* eslint-disable @typescript-eslint/naming-convention */ /* eslint-disable @typescript-eslint/naming-convention */
import { BinaryWriter } from "cosmjs-types/binary";
import { MsgSend } from "cosmjs-types/cosmos/bank/v1beta1/tx"; import { MsgSend } from "cosmjs-types/cosmos/bank/v1beta1/tx";
import { Coin } from "cosmjs-types/cosmos/base/v1beta1/coin"; import { Coin } from "cosmjs-types/cosmos/base/v1beta1/coin";
import { TxBody } from "cosmjs-types/cosmos/tx/v1beta1/tx"; import { TxBody } from "cosmjs-types/cosmos/tx/v1beta1/tx";
import { Any } from "cosmjs-types/google/protobuf/any"; import { Any } from "cosmjs-types/google/protobuf/any";
import Long from "long";
import type protobuf from "protobufjs"; import type protobuf from "protobufjs";
/**
* A type generated by Telescope 1.0.
*/
export interface TelescopeGeneratedType {
/** This may or may not exist depending on the code generator settings. Don't rely on it. */
readonly typeUrl?: string;
readonly encode: (
message:
| any
| {
[k: string]: any;
},
writer?: BinaryWriter,
) => BinaryWriter;
readonly decode: (input: Uint8Array, length?: number) => any;
readonly fromPartial: (object: any) => any;
}
/** /**
* A type generated by [ts-proto](https://github.com/stephenh/ts-proto). * A type generated by [ts-proto](https://github.com/stephenh/ts-proto).
*/ */
@ -30,7 +48,12 @@ export interface PbjsGeneratedType {
readonly decode: (reader: protobuf.Reader | Uint8Array, length?: number) => any; readonly decode: (reader: protobuf.Reader | Uint8Array, length?: number) => any;
} }
export type GeneratedType = TsProtoGeneratedType | PbjsGeneratedType; export type GeneratedType = TelescopeGeneratedType | TsProtoGeneratedType | PbjsGeneratedType;
export function isTelescopeGeneratedType(type: GeneratedType): type is TelescopeGeneratedType {
const casted = type as TelescopeGeneratedType;
return typeof casted.fromPartial === "function" && typeof casted.typeUrl == "string";
}
export function isTsProtoGeneratedType(type: GeneratedType): type is TsProtoGeneratedType { export function isTsProtoGeneratedType(type: GeneratedType): type is TsProtoGeneratedType {
return typeof (type as TsProtoGeneratedType).fromPartial === "function"; return typeof (type as TsProtoGeneratedType).fromPartial === "function";
@ -60,7 +83,7 @@ export interface EncodeObject {
interface TxBodyValue { interface TxBodyValue {
readonly messages: readonly EncodeObject[]; readonly messages: readonly EncodeObject[];
readonly memo?: string; readonly memo?: string;
readonly timeoutHeight?: Long; readonly timeoutHeight?: bigint;
readonly extensionOptions?: Any[]; readonly extensionOptions?: Any[];
readonly nonCriticalExtensionOptions?: Any[]; readonly nonCriticalExtensionOptions?: Any[];
} }
@ -144,7 +167,10 @@ export class Registry {
return this.encodeTxBody(value); return this.encodeTxBody(value);
} }
const type = this.lookupTypeWithError(typeUrl); const type = this.lookupTypeWithError(typeUrl);
const instance = isTsProtoGeneratedType(type) ? type.fromPartial(value) : type.create(value); const instance =
isTelescopeGeneratedType(type) || isTsProtoGeneratedType(type)
? type.fromPartial(value)
: type.create(value);
return type.encode(instance).finish(); return type.encode(instance).finish();
} }
@ -164,6 +190,7 @@ export class Registry {
const wrappedMessages = txBodyFields.messages.map((message) => this.encodeAsAny(message)); const wrappedMessages = txBodyFields.messages.map((message) => this.encodeAsAny(message));
const txBody = TxBody.fromPartial({ const txBody = TxBody.fromPartial({
...txBodyFields, ...txBodyFields,
timeoutHeight: BigInt(txBodyFields.timeoutHeight?.toString() ?? "0"),
messages: wrappedMessages, messages: wrappedMessages,
}); });
return TxBody.encode(txBody).finish(); return TxBody.encode(txBody).finish();

View File

@ -4,7 +4,6 @@ import { Coin } from "cosmjs-types/cosmos/base/v1beta1/coin";
import { SignMode } from "cosmjs-types/cosmos/tx/signing/v1beta1/signing"; import { SignMode } from "cosmjs-types/cosmos/tx/signing/v1beta1/signing";
import { AuthInfo, SignDoc, SignerInfo } from "cosmjs-types/cosmos/tx/v1beta1/tx"; import { AuthInfo, SignDoc, SignerInfo } from "cosmjs-types/cosmos/tx/v1beta1/tx";
import { Any } from "cosmjs-types/google/protobuf/any"; import { Any } from "cosmjs-types/google/protobuf/any";
import Long from "long";
/** /**
* Create signer infos from the provided signers. * Create signer infos from the provided signers.
@ -12,7 +11,7 @@ import Long from "long";
* This implementation does not support different signing modes for the different signers. * This implementation does not support different signing modes for the different signers.
*/ */
function makeSignerInfos( function makeSignerInfos(
signers: ReadonlyArray<{ readonly pubkey: Any; readonly sequence: number }>, signers: ReadonlyArray<{ readonly pubkey: Any; readonly sequence: number | bigint }>,
signMode: SignMode, signMode: SignMode,
): SignerInfo[] { ): SignerInfo[] {
return signers.map( return signers.map(
@ -21,7 +20,7 @@ function makeSignerInfos(
modeInfo: { modeInfo: {
single: { mode: signMode }, single: { mode: signMode },
}, },
sequence: Long.fromNumber(sequence), sequence: BigInt(sequence),
}), }),
); );
} }
@ -32,7 +31,7 @@ function makeSignerInfos(
* This implementation does not support different signing modes for the different signers. * This implementation does not support different signing modes for the different signers.
*/ */
export function makeAuthInfoBytes( export function makeAuthInfoBytes(
signers: ReadonlyArray<{ readonly pubkey: Any; readonly sequence: number }>, signers: ReadonlyArray<{ readonly pubkey: Any; readonly sequence: bigint | number }>,
feeAmount: readonly Coin[], feeAmount: readonly Coin[],
gasLimit: number, gasLimit: number,
feeGranter: string | undefined, feeGranter: string | undefined,
@ -50,7 +49,7 @@ export function makeAuthInfoBytes(
signerInfos: makeSignerInfos(signers, signMode), signerInfos: makeSignerInfos(signers, signMode),
fee: { fee: {
amount: [...feeAmount], amount: [...feeAmount],
gasLimit: Long.fromNumber(gasLimit), gasLimit: BigInt(gasLimit),
granter: feeGranter, granter: feeGranter,
payer: feePayer, payer: feePayer,
}, },
@ -68,7 +67,7 @@ export function makeSignDoc(
bodyBytes: bodyBytes, bodyBytes: bodyBytes,
authInfoBytes: authInfoBytes, authInfoBytes: authInfoBytes,
chainId: chainId, chainId: chainId,
accountNumber: Long.fromNumber(accountNumber), accountNumber: BigInt(accountNumber),
}; };
} }

View File

@ -1,6 +1,6 @@
{ {
"name": "@cosmjs/socket", "name": "@cosmjs/socket",
"version": "0.31.1", "version": "0.31.3",
"description": "Utility functions for working with WebSockets", "description": "Utility functions for working with WebSockets",
"contributors": [ "contributors": [
"IOV SAS <admin@iov.one>", "IOV SAS <admin@iov.one>",

View File

@ -1,6 +1,6 @@
{ {
"name": "@cosmjs/stargate", "name": "@cosmjs/stargate",
"version": "0.31.1", "version": "0.31.3",
"description": "Utilities for Cosmos SDK 0.40", "description": "Utilities for Cosmos SDK 0.40",
"contributors": [ "contributors": [
"Simon Warta <webmaster128@users.noreply.github.com>" "Simon Warta <webmaster128@users.noreply.github.com>"
@ -46,9 +46,7 @@
"@cosmjs/stream": "workspace:^", "@cosmjs/stream": "workspace:^",
"@cosmjs/tendermint-rpc": "workspace:^", "@cosmjs/tendermint-rpc": "workspace:^",
"@cosmjs/utils": "workspace:^", "@cosmjs/utils": "workspace:^",
"cosmjs-types": "^0.8.0", "cosmjs-types": "^0.9.0",
"long": "^4.0.0",
"protobufjs": "~6.11.4",
"xstream": "^11.14.0" "xstream": "^11.14.0"
}, },
"devDependencies": { "devDependencies": {

View File

@ -1,6 +1,6 @@
import { Pubkey } from "@cosmjs/amino"; import { Pubkey } from "@cosmjs/amino";
import { Uint64 } from "@cosmjs/math"; import { Uint64 } from "@cosmjs/math";
import { decodePubkey } from "@cosmjs/proto-signing"; import { decodeOptionalPubkey } from "@cosmjs/proto-signing";
import { assert } from "@cosmjs/utils"; import { assert } from "@cosmjs/utils";
import { BaseAccount, ModuleAccount } from "cosmjs-types/cosmos/auth/v1beta1/auth"; import { BaseAccount, ModuleAccount } from "cosmjs-types/cosmos/auth/v1beta1/auth";
import { import {
@ -10,7 +10,6 @@ import {
PeriodicVestingAccount, PeriodicVestingAccount,
} from "cosmjs-types/cosmos/vesting/v1beta1/vesting"; } from "cosmjs-types/cosmos/vesting/v1beta1/vesting";
import { Any } from "cosmjs-types/google/protobuf/any"; import { Any } from "cosmjs-types/google/protobuf/any";
import Long from "long";
export interface Account { export interface Account {
/** Bech32 account address */ /** Bech32 account address */
@ -20,13 +19,13 @@ export interface Account {
readonly sequence: number; readonly sequence: number;
} }
function uint64FromProto(input: number | Long): Uint64 { function uint64FromProto(input: number | bigint): Uint64 {
return Uint64.fromString(input.toString()); return Uint64.fromString(input.toString());
} }
function accountFromBaseAccount(input: BaseAccount): Account { function accountFromBaseAccount(input: BaseAccount): Account {
const { address, pubKey, accountNumber, sequence } = input; const { address, pubKey, accountNumber, sequence } = input;
const pubkey = pubKey ? decodePubkey(pubKey) : null; const pubkey = decodeOptionalPubkey(pubKey);
return { return {
address: address, address: address,
pubkey: pubkey, pubkey: pubkey,

Some files were not shown because too many files have changed in this diff Show More