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]
### 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
- 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])
- @cosmjs/tendermint-rpc: Remove `Adaptor` abstractions which are not needed
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.
[#1421]: https://github.com/cosmos/cosmjs/issues/1421
[#1484]: https://github.com/cosmos/cosmjs/pull/1484
### Deprecated
- @cosmjs/tendermint-rpc: `CometClient` should be used instead of
`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
### 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.
- @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.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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -10,8 +10,7 @@ import {
MsgStoreCode,
MsgUpdateAdmin,
} from "cosmjs-types/cosmwasm/wasm/v1/tx";
import { AccessType } from "cosmjs-types/cosmwasm/wasm/v1/types";
import Long from "long";
import { AccessConfig, AccessType } from "cosmjs-types/cosmwasm/wasm/v1/types";
export function accessTypeFromString(str: string): AccessType {
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
*/
export interface AccessConfig {
export interface AminoAccessConfig {
/**
* 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
@ -77,7 +76,7 @@ export interface AminoMsgStoreCode {
readonly sender: string;
/** Base64 encoded Wasm */
readonly wasm_byte_code: string;
readonly instantiate_permission?: AccessConfig;
readonly instantiate_permission?: AminoAccessConfig;
};
}
@ -226,11 +225,11 @@ export function createWasmAminoConverters(): AminoConverters {
sender: sender,
wasmByteCode: fromBase64(wasm_byte_code),
instantiatePermission: instantiate_permission
? {
? AccessConfig.fromPartial({
permission: accessTypeFromString(instantiate_permission.permission),
address: instantiate_permission.address ?? "",
addresses: instantiate_permission.addresses ?? [],
}
})
: undefined,
}),
},
@ -260,7 +259,7 @@ export function createWasmAminoConverters(): AminoConverters {
admin,
}: AminoMsgInstantiateContract["value"]): MsgInstantiateContract => ({
sender: sender,
codeId: Long.fromString(code_id),
codeId: BigInt(code_id),
label: label,
msg: toUtf8(JSON.stringify(msg)),
funds: [...funds],
@ -299,7 +298,7 @@ export function createWasmAminoConverters(): AminoConverters {
fix_msg,
}: AminoMsgInstantiateContract2["value"]): MsgInstantiateContract2 => ({
sender: sender,
codeId: Long.fromString(code_id),
codeId: BigInt(code_id),
label: label,
msg: toUtf8(JSON.stringify(msg)),
funds: [...funds],
@ -368,7 +367,7 @@ export function createWasmAminoConverters(): AminoConverters {
}: AminoMsgMigrateContract["value"]): MsgMigrateContract => ({
sender: sender,
contract: contract,
codeId: Long.fromString(code_id),
codeId: BigInt(code_id),
msg: toUtf8(JSON.stringify(msg)),
}),
},

View File

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

View File

@ -3,15 +3,16 @@ import { createPagination, createProtobufRpcClient, QueryClient } from "@cosmjs/
import {
QueryAllContractStateResponse,
QueryClientImpl,
QueryCodeRequest,
QueryCodeResponse,
QueryCodesResponse,
QueryContractHistoryResponse,
QueryContractInfoResponse,
QueryContractsByCodeRequest,
QueryContractsByCodeResponse,
QueryContractsByCreatorResponse,
QueryRawContractStateResponse,
} from "cosmjs-types/cosmwasm/wasm/v1/query";
import Long from "long";
/**
* 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);
},
getCode: async (id: number) => {
const request = { codeId: Long.fromNumber(id) };
const request = QueryCodeRequest.fromPartial({ codeId: BigInt(id) });
return queryService.Code(request);
},
listContractsByCodeId: async (id: number, paginationKey?: Uint8Array) => {
const request = {
codeId: Long.fromNumber(id),
const request = QueryContractsByCodeRequest.fromPartial({
codeId: BigInt(id),
pagination: createPagination(paginationKey),
};
});
return queryService.ContractsByCode(request);
},
listContractsByCreator: async (creator: string, paginationKey?: Uint8Array) => {

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -1,6 +1,6 @@
{
"name": "@cosmjs/proto-signing",
"version": "0.31.1",
"version": "0.31.3",
"description": "Utilities for protobuf based signing (Cosmos SDK 0.40+)",
"contributors": [
"Will Clark <willclarktech@users.noreply.github.com>",
@ -44,8 +44,7 @@
"@cosmjs/encoding": "workspace:^",
"@cosmjs/math": "workspace:^",
"@cosmjs/utils": "workspace:^",
"cosmjs-types": "^0.8.0",
"long": "^4.0.0"
"cosmjs-types": "^0.9.0"
},
"devDependencies": {
"@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 { SignMode } from "cosmjs-types/cosmos/tx/signing/v1beta1/signing";
import { Any } from "cosmjs-types/google/protobuf/any";
import Long from "long";
import { decodeTxRaw } from "./decode";
import { faucet, testVectors } from "./testutils.spec";
@ -46,11 +45,11 @@ describe("decode", () => {
},
multi: undefined,
},
sequence: Long.UZERO,
sequence: BigInt(0),
},
],
fee: {
gasLimit: Long.fromNumber(200000, true),
gasLimit: BigInt(200000),
payer: "",
granter: "",
amount: [{ amount: "2000", denom: "ucosm" }],
@ -58,7 +57,7 @@ describe("decode", () => {
}),
body: {
memo: "",
timeoutHeight: Long.UZERO,
timeoutHeight: BigInt(0),
messages: [expectedMsg],
extensionOptions: [],
nonCriticalExtensionOptions: [],

View File

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

View File

@ -97,6 +97,30 @@ export function decodePubkey(pubkey: Any): Pubkey {
return out;
}
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 { TxBody } from "cosmjs-types/cosmos/tx/v1beta1/tx";
import { Any } from "cosmjs-types/google/protobuf/any";
import Long from "long";
import { Field, Type } from "protobufjs";
import { isPbjsGeneratedType, isTsProtoGeneratedType, Registry } from "./registry";
@ -36,7 +35,7 @@ describe("registry demo", () => {
const txBody = TxBody.fromPartial({
messages: [msgSendWrapped],
memo: "Some memo",
timeoutHeight: Long.fromNumber(9999),
timeoutHeight: BigInt(9999),
extensionOptions: [],
});
const txBodyBytes = TxBody.encode(txBody).finish();
@ -84,7 +83,7 @@ describe("registry demo", () => {
const txBody = TxBody.fromPartial({
messages: [msgDemoWrapped],
memo: "Some memo",
timeoutHeight: Long.fromNumber(9999),
timeoutHeight: BigInt(9999),
extensionOptions: [],
});
const txBodyBytes = TxBody.encode(txBody).finish();

View File

@ -1,11 +1,29 @@
/* eslint-disable @typescript-eslint/naming-convention */
import { BinaryWriter } from "cosmjs-types/binary";
import { MsgSend } from "cosmjs-types/cosmos/bank/v1beta1/tx";
import { Coin } from "cosmjs-types/cosmos/base/v1beta1/coin";
import { TxBody } from "cosmjs-types/cosmos/tx/v1beta1/tx";
import { Any } from "cosmjs-types/google/protobuf/any";
import Long from "long";
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).
*/
@ -30,7 +48,12 @@ export interface PbjsGeneratedType {
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 {
return typeof (type as TsProtoGeneratedType).fromPartial === "function";
@ -60,7 +83,7 @@ export interface EncodeObject {
interface TxBodyValue {
readonly messages: readonly EncodeObject[];
readonly memo?: string;
readonly timeoutHeight?: Long;
readonly timeoutHeight?: bigint;
readonly extensionOptions?: Any[];
readonly nonCriticalExtensionOptions?: Any[];
}
@ -144,7 +167,10 @@ export class Registry {
return this.encodeTxBody(value);
}
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();
}
@ -164,6 +190,7 @@ export class Registry {
const wrappedMessages = txBodyFields.messages.map((message) => this.encodeAsAny(message));
const txBody = TxBody.fromPartial({
...txBodyFields,
timeoutHeight: BigInt(txBodyFields.timeoutHeight?.toString() ?? "0"),
messages: wrappedMessages,
});
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 { AuthInfo, SignDoc, SignerInfo } from "cosmjs-types/cosmos/tx/v1beta1/tx";
import { Any } from "cosmjs-types/google/protobuf/any";
import Long from "long";
/**
* 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.
*/
function makeSignerInfos(
signers: ReadonlyArray<{ readonly pubkey: Any; readonly sequence: number }>,
signers: ReadonlyArray<{ readonly pubkey: Any; readonly sequence: number | bigint }>,
signMode: SignMode,
): SignerInfo[] {
return signers.map(
@ -21,7 +20,7 @@ function makeSignerInfos(
modeInfo: {
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.
*/
export function makeAuthInfoBytes(
signers: ReadonlyArray<{ readonly pubkey: Any; readonly sequence: number }>,
signers: ReadonlyArray<{ readonly pubkey: Any; readonly sequence: bigint | number }>,
feeAmount: readonly Coin[],
gasLimit: number,
feeGranter: string | undefined,
@ -50,7 +49,7 @@ export function makeAuthInfoBytes(
signerInfos: makeSignerInfos(signers, signMode),
fee: {
amount: [...feeAmount],
gasLimit: Long.fromNumber(gasLimit),
gasLimit: BigInt(gasLimit),
granter: feeGranter,
payer: feePayer,
},
@ -68,7 +67,7 @@ export function makeSignDoc(
bodyBytes: bodyBytes,
authInfoBytes: authInfoBytes,
chainId: chainId,
accountNumber: Long.fromNumber(accountNumber),
accountNumber: BigInt(accountNumber),
};
}

View File

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

View File

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

View File

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

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