Merge pull request #1484 from cosmos/new-cosmjs-types

Upgrade to new cosmjs-types (Telescope 1.0, big int 🔥)
This commit is contained in:
Simon Warta 2023-10-25 11:54:24 +02:00 committed by GitHub
commit 08200aeb22
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
50 changed files with 328 additions and 303 deletions

23
.pnp.cjs generated
View File

@ -1056,7 +1056,7 @@ function $$SETUP_STATE(hydrateRuntimeState, basePath) {
],\ ],\
[\ [\
"cosmjs-types",\ "cosmjs-types",\
"npm:0.8.0"\ "npm:0.9.0"\
],\ ],\
[\ [\
"cross-spawn",\ "cross-spawn",\
@ -3291,7 +3291,7 @@ function $$SETUP_STATE(hydrateRuntimeState, basePath) {
["axios", "npm:0.21.4"],\ ["axios", "npm:0.21.4"],\
["babylon", "npm:6.18.0"],\ ["babylon", "npm:6.18.0"],\
["chalk", "npm:4.1.2"],\ ["chalk", "npm:4.1.2"],\
["cosmjs-types", "npm:0.8.0"],\ ["cosmjs-types", "npm:0.9.0"],\
["diff", "npm:4.0.2"],\ ["diff", "npm:4.0.2"],\
["eslint", "npm:7.26.0"],\ ["eslint", "npm:7.26.0"],\
["eslint-config-prettier", "virtual:4f1584ad4aba8733a24be7c8aebbffafef25607f2d00f4b314cf96717145c692763628a31c2b85d4686fbb091ff21ebffa3cc337399c042c19a32b9bdb786464#npm:8.3.0"],\ ["eslint-config-prettier", "virtual:4f1584ad4aba8733a24be7c8aebbffafef25607f2d00f4b314cf96717145c692763628a31c2b85d4686fbb091ff21ebffa3cc337399c042c19a32b9bdb786464#npm:8.3.0"],\
@ -3337,7 +3337,7 @@ function $$SETUP_STATE(hydrateRuntimeState, basePath) {
["@types/pako", "npm:1.0.1"],\ ["@types/pako", "npm:1.0.1"],\
["@typescript-eslint/eslint-plugin", "virtual:4f1584ad4aba8733a24be7c8aebbffafef25607f2d00f4b314cf96717145c692763628a31c2b85d4686fbb091ff21ebffa3cc337399c042c19a32b9bdb786464#npm:5.54.0"],\ ["@typescript-eslint/eslint-plugin", "virtual:4f1584ad4aba8733a24be7c8aebbffafef25607f2d00f4b314cf96717145c692763628a31c2b85d4686fbb091ff21ebffa3cc337399c042c19a32b9bdb786464#npm:5.54.0"],\
["@typescript-eslint/parser", "virtual:4f1584ad4aba8733a24be7c8aebbffafef25607f2d00f4b314cf96717145c692763628a31c2b85d4686fbb091ff21ebffa3cc337399c042c19a32b9bdb786464#npm:5.54.0"],\ ["@typescript-eslint/parser", "virtual:4f1584ad4aba8733a24be7c8aebbffafef25607f2d00f4b314cf96717145c692763628a31c2b85d4686fbb091ff21ebffa3cc337399c042c19a32b9bdb786464#npm:5.54.0"],\
["cosmjs-types", "npm:0.8.0"],\ ["cosmjs-types", "npm:0.9.0"],\
["eslint", "npm:7.26.0"],\ ["eslint", "npm:7.26.0"],\
["eslint-config-prettier", "virtual:4f1584ad4aba8733a24be7c8aebbffafef25607f2d00f4b314cf96717145c692763628a31c2b85d4686fbb091ff21ebffa3cc337399c042c19a32b9bdb786464#npm:8.3.0"],\ ["eslint-config-prettier", "virtual:4f1584ad4aba8733a24be7c8aebbffafef25607f2d00f4b314cf96717145c692763628a31c2b85d4686fbb091ff21ebffa3cc337399c042c19a32b9bdb786464#npm:8.3.0"],\
["eslint-import-resolver-node", "npm:0.3.4"],\ ["eslint-import-resolver-node", "npm:0.3.4"],\
@ -3353,11 +3353,9 @@ function $$SETUP_STATE(hydrateRuntimeState, basePath) {
["karma-firefox-launcher", "npm:2.1.0"],\ ["karma-firefox-launcher", "npm:2.1.0"],\
["karma-jasmine", "virtual:4f1584ad4aba8733a24be7c8aebbffafef25607f2d00f4b314cf96717145c692763628a31c2b85d4686fbb091ff21ebffa3cc337399c042c19a32b9bdb786464#npm:5.1.0"],\ ["karma-jasmine", "virtual:4f1584ad4aba8733a24be7c8aebbffafef25607f2d00f4b314cf96717145c692763628a31c2b85d4686fbb091ff21ebffa3cc337399c042c19a32b9bdb786464#npm:5.1.0"],\
["karma-jasmine-html-reporter", "virtual:4f1584ad4aba8733a24be7c8aebbffafef25607f2d00f4b314cf96717145c692763628a31c2b85d4686fbb091ff21ebffa3cc337399c042c19a32b9bdb786464#npm:1.6.0"],\ ["karma-jasmine-html-reporter", "virtual:4f1584ad4aba8733a24be7c8aebbffafef25607f2d00f4b314cf96717145c692763628a31c2b85d4686fbb091ff21ebffa3cc337399c042c19a32b9bdb786464#npm:1.6.0"],\
["long", "npm:4.0.0"],\
["nyc", "npm:15.1.0"],\ ["nyc", "npm:15.1.0"],\
["pako", "npm:2.0.3"],\ ["pako", "npm:2.0.3"],\
["prettier", "npm:2.8.8"],\ ["prettier", "npm:2.8.8"],\
["protobufjs", "npm:6.11.4"],\
["readonly-date", "npm:1.0.0"],\ ["readonly-date", "npm:1.0.0"],\
["ses", "npm:0.11.1"],\ ["ses", "npm:0.11.1"],\
["source-map-support", "npm:0.5.21"],\ ["source-map-support", "npm:0.5.21"],\
@ -3710,7 +3708,7 @@ function $$SETUP_STATE(hydrateRuntimeState, basePath) {
["@types/node", "npm:18.15.11"],\ ["@types/node", "npm:18.15.11"],\
["@typescript-eslint/eslint-plugin", "virtual:4f1584ad4aba8733a24be7c8aebbffafef25607f2d00f4b314cf96717145c692763628a31c2b85d4686fbb091ff21ebffa3cc337399c042c19a32b9bdb786464#npm:5.54.0"],\ ["@typescript-eslint/eslint-plugin", "virtual:4f1584ad4aba8733a24be7c8aebbffafef25607f2d00f4b314cf96717145c692763628a31c2b85d4686fbb091ff21ebffa3cc337399c042c19a32b9bdb786464#npm:5.54.0"],\
["@typescript-eslint/parser", "virtual:4f1584ad4aba8733a24be7c8aebbffafef25607f2d00f4b314cf96717145c692763628a31c2b85d4686fbb091ff21ebffa3cc337399c042c19a32b9bdb786464#npm:5.54.0"],\ ["@typescript-eslint/parser", "virtual:4f1584ad4aba8733a24be7c8aebbffafef25607f2d00f4b314cf96717145c692763628a31c2b85d4686fbb091ff21ebffa3cc337399c042c19a32b9bdb786464#npm:5.54.0"],\
["cosmjs-types", "npm:0.8.0"],\ ["cosmjs-types", "npm:0.9.0"],\
["eslint", "npm:7.26.0"],\ ["eslint", "npm:7.26.0"],\
["eslint-config-prettier", "virtual:4f1584ad4aba8733a24be7c8aebbffafef25607f2d00f4b314cf96717145c692763628a31c2b85d4686fbb091ff21ebffa3cc337399c042c19a32b9bdb786464#npm:8.3.0"],\ ["eslint-config-prettier", "virtual:4f1584ad4aba8733a24be7c8aebbffafef25607f2d00f4b314cf96717145c692763628a31c2b85d4686fbb091ff21ebffa3cc337399c042c19a32b9bdb786464#npm:8.3.0"],\
["eslint-import-resolver-node", "npm:0.3.4"],\ ["eslint-import-resolver-node", "npm:0.3.4"],\
@ -3726,7 +3724,6 @@ function $$SETUP_STATE(hydrateRuntimeState, basePath) {
["karma-firefox-launcher", "npm:2.1.0"],\ ["karma-firefox-launcher", "npm:2.1.0"],\
["karma-jasmine", "virtual:4f1584ad4aba8733a24be7c8aebbffafef25607f2d00f4b314cf96717145c692763628a31c2b85d4686fbb091ff21ebffa3cc337399c042c19a32b9bdb786464#npm:5.1.0"],\ ["karma-jasmine", "virtual:4f1584ad4aba8733a24be7c8aebbffafef25607f2d00f4b314cf96717145c692763628a31c2b85d4686fbb091ff21ebffa3cc337399c042c19a32b9bdb786464#npm:5.1.0"],\
["karma-jasmine-html-reporter", "virtual:4f1584ad4aba8733a24be7c8aebbffafef25607f2d00f4b314cf96717145c692763628a31c2b85d4686fbb091ff21ebffa3cc337399c042c19a32b9bdb786464#npm:1.6.0"],\ ["karma-jasmine-html-reporter", "virtual:4f1584ad4aba8733a24be7c8aebbffafef25607f2d00f4b314cf96717145c692763628a31c2b85d4686fbb091ff21ebffa3cc337399c042c19a32b9bdb786464#npm:1.6.0"],\
["long", "npm:4.0.0"],\
["nyc", "npm:15.1.0"],\ ["nyc", "npm:15.1.0"],\
["prettier", "npm:2.8.8"],\ ["prettier", "npm:2.8.8"],\
["protobufjs", "npm:6.11.4"],\ ["protobufjs", "npm:6.11.4"],\
@ -3811,7 +3808,7 @@ function $$SETUP_STATE(hydrateRuntimeState, basePath) {
["@types/node", "npm:18.15.11"],\ ["@types/node", "npm:18.15.11"],\
["@typescript-eslint/eslint-plugin", "virtual:4f1584ad4aba8733a24be7c8aebbffafef25607f2d00f4b314cf96717145c692763628a31c2b85d4686fbb091ff21ebffa3cc337399c042c19a32b9bdb786464#npm:5.54.0"],\ ["@typescript-eslint/eslint-plugin", "virtual:4f1584ad4aba8733a24be7c8aebbffafef25607f2d00f4b314cf96717145c692763628a31c2b85d4686fbb091ff21ebffa3cc337399c042c19a32b9bdb786464#npm:5.54.0"],\
["@typescript-eslint/parser", "virtual:4f1584ad4aba8733a24be7c8aebbffafef25607f2d00f4b314cf96717145c692763628a31c2b85d4686fbb091ff21ebffa3cc337399c042c19a32b9bdb786464#npm:5.54.0"],\ ["@typescript-eslint/parser", "virtual:4f1584ad4aba8733a24be7c8aebbffafef25607f2d00f4b314cf96717145c692763628a31c2b85d4686fbb091ff21ebffa3cc337399c042c19a32b9bdb786464#npm:5.54.0"],\
["cosmjs-types", "npm:0.8.0"],\ ["cosmjs-types", "npm:0.9.0"],\
["eslint", "npm:7.26.0"],\ ["eslint", "npm:7.26.0"],\
["eslint-config-prettier", "virtual:4f1584ad4aba8733a24be7c8aebbffafef25607f2d00f4b314cf96717145c692763628a31c2b85d4686fbb091ff21ebffa3cc337399c042c19a32b9bdb786464#npm:8.3.0"],\ ["eslint-config-prettier", "virtual:4f1584ad4aba8733a24be7c8aebbffafef25607f2d00f4b314cf96717145c692763628a31c2b85d4686fbb091ff21ebffa3cc337399c042c19a32b9bdb786464#npm:8.3.0"],\
["eslint-import-resolver-node", "npm:0.3.4"],\ ["eslint-import-resolver-node", "npm:0.3.4"],\
@ -3827,10 +3824,8 @@ function $$SETUP_STATE(hydrateRuntimeState, basePath) {
["karma-firefox-launcher", "npm:2.1.0"],\ ["karma-firefox-launcher", "npm:2.1.0"],\
["karma-jasmine", "virtual:4f1584ad4aba8733a24be7c8aebbffafef25607f2d00f4b314cf96717145c692763628a31c2b85d4686fbb091ff21ebffa3cc337399c042c19a32b9bdb786464#npm:5.1.0"],\ ["karma-jasmine", "virtual:4f1584ad4aba8733a24be7c8aebbffafef25607f2d00f4b314cf96717145c692763628a31c2b85d4686fbb091ff21ebffa3cc337399c042c19a32b9bdb786464#npm:5.1.0"],\
["karma-jasmine-html-reporter", "virtual:4f1584ad4aba8733a24be7c8aebbffafef25607f2d00f4b314cf96717145c692763628a31c2b85d4686fbb091ff21ebffa3cc337399c042c19a32b9bdb786464#npm:1.6.0"],\ ["karma-jasmine-html-reporter", "virtual:4f1584ad4aba8733a24be7c8aebbffafef25607f2d00f4b314cf96717145c692763628a31c2b85d4686fbb091ff21ebffa3cc337399c042c19a32b9bdb786464#npm:1.6.0"],\
["long", "npm:4.0.0"],\
["nyc", "npm:15.1.0"],\ ["nyc", "npm:15.1.0"],\
["prettier", "npm:2.8.8"],\ ["prettier", "npm:2.8.8"],\
["protobufjs", "npm:6.11.4"],\
["readonly-date", "npm:1.0.0"],\ ["readonly-date", "npm:1.0.0"],\
["ses", "npm:0.11.1"],\ ["ses", "npm:0.11.1"],\
["source-map-support", "npm:0.5.21"],\ ["source-map-support", "npm:0.5.21"],\
@ -7152,12 +7147,10 @@ function $$SETUP_STATE(hydrateRuntimeState, basePath) {
}]\ }]\
]],\ ]],\
["cosmjs-types", [\ ["cosmjs-types", [\
["npm:0.8.0", {\ ["npm:0.9.0", {\
"packageLocation": "./.yarn/cache/cosmjs-types-npm-0.8.0-4c175fd383-99714ec956.zip/node_modules/cosmjs-types/",\ "packageLocation": "./.yarn/cache/cosmjs-types-npm-0.9.0-e5d36a4ae5-9b00d169ec.zip/node_modules/cosmjs-types/",\
"packageDependencies": [\ "packageDependencies": [\
["cosmjs-types", "npm:0.8.0"],\ ["cosmjs-types", "npm:0.9.0"]\
["long", "npm:4.0.0"],\
["protobufjs", "npm:6.11.4"]\
],\ ],\
"linkType": "HARD"\ "linkType": "HARD"\
}]\ }]\

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.

View File

@ -8,6 +8,10 @@ and this project adheres to
### 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.
@ -16,6 +20,7 @@ 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

View File

@ -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

@ -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({
creator: alice.address0, codeId: BigInt(hackatomCodeId),
label: "my escrow", creator: alice.address0,
admin: "", label: "my escrow",
ibcPortId: "", admin: "",
created: AbsoluteTxPosition.fromPartial({ ibcPortId: "",
blockHeight: Long.fromNumber(instantiateResult.height, true), created: AbsoluteTxPosition.fromPartial({
txIndex: Long.UZERO, blockHeight: BigInt(instantiateResult.height),
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()));
@ -1275,11 +1271,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) {
@ -1405,7 +1399,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

@ -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

@ -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,

View File

@ -4,7 +4,6 @@ import { Tendermint34Client } from "@cosmjs/tendermint-rpc";
import { assert } from "@cosmjs/utils"; import { assert } from "@cosmjs/utils";
import { BaseAccount } from "cosmjs-types/cosmos/auth/v1beta1/auth"; import { BaseAccount } from "cosmjs-types/cosmos/auth/v1beta1/auth";
import { Any } from "cosmjs-types/google/protobuf/any"; import { Any } from "cosmjs-types/google/protobuf/any";
import Long from "long";
import { QueryClient } from "../../queryclient"; import { QueryClient } from "../../queryclient";
import { nonExistentAddress, pendingWithoutSimapp, simapp, unused, validator } from "../../testutils.spec"; import { nonExistentAddress, pendingWithoutSimapp, simapp, unused, validator } from "../../testutils.spec";
@ -26,12 +25,13 @@ describe("AuthExtension", () => {
assert(account); assert(account);
expect(account.typeUrl).toEqual("/cosmos.auth.v1beta1.BaseAccount"); expect(account.typeUrl).toEqual("/cosmos.auth.v1beta1.BaseAccount");
expect(BaseAccount.decode(account.value)).toEqual({ expect(BaseAccount.decode(account.value)).toEqual(
address: unused.address, jasmine.objectContaining({
pubKey: undefined, address: unused.address,
accountNumber: Long.fromNumber(unused.accountNumber, true), accountNumber: BigInt(unused.accountNumber),
sequence: Long.UZERO, sequence: BigInt(0),
}); }),
);
tmClient.disconnect(); tmClient.disconnect();
}); });
@ -46,8 +46,8 @@ describe("AuthExtension", () => {
expect(BaseAccount.decode(account.value)).toEqual({ expect(BaseAccount.decode(account.value)).toEqual({
address: validator.delegatorAddress, address: validator.delegatorAddress,
pubKey: Any.fromPartial(encodePubkey(validator.pubkey)), pubKey: Any.fromPartial(encodePubkey(validator.pubkey)),
accountNumber: Long.UZERO, accountNumber: BigInt(0),
sequence: Long.fromNumber(validator.sequence, true), sequence: BigInt(validator.sequence),
}); });
tmClient.disconnect(); tmClient.disconnect();

View File

@ -1,7 +1,12 @@
/* eslint-disable @typescript-eslint/naming-convention */ /* eslint-disable @typescript-eslint/naming-convention */
import { assert } from "@cosmjs/utils"; import { assert } from "@cosmjs/utils";
import { Metadata } from "cosmjs-types/cosmos/bank/v1beta1/bank"; import { Metadata } from "cosmjs-types/cosmos/bank/v1beta1/bank";
import { QueryClientImpl, QueryTotalSupplyResponse } from "cosmjs-types/cosmos/bank/v1beta1/query"; import {
QueryAllBalancesRequest,
QueryClientImpl,
QueryDenomsMetadataRequest,
QueryTotalSupplyResponse,
} from "cosmjs-types/cosmos/bank/v1beta1/query";
import { Coin } from "cosmjs-types/cosmos/base/v1beta1/coin"; import { Coin } from "cosmjs-types/cosmos/base/v1beta1/coin";
import { createPagination, createProtobufRpcClient, QueryClient } from "../../queryclient"; import { createPagination, createProtobufRpcClient, QueryClient } from "../../queryclient";
@ -31,7 +36,9 @@ export function setupBankExtension(base: QueryClient): BankExtension {
return balance; return balance;
}, },
allBalances: async (address: string) => { allBalances: async (address: string) => {
const { balances } = await queryService.AllBalances({ address: address }); const { balances } = await queryService.AllBalances(
QueryAllBalancesRequest.fromPartial({ address: address }),
);
return balances; return balances;
}, },
totalSupply: async (paginationKey?: Uint8Array) => { totalSupply: async (paginationKey?: Uint8Array) => {
@ -51,9 +58,11 @@ export function setupBankExtension(base: QueryClient): BankExtension {
return metadata; return metadata;
}, },
denomsMetadata: async () => { denomsMetadata: async () => {
const { metadatas } = await queryService.DenomsMetadata({ const { metadatas } = await queryService.DenomsMetadata(
pagination: undefined, // Not implemented QueryDenomsMetadataRequest.fromPartial({
}); pagination: undefined, // Not implemented
}),
);
return metadatas; return metadatas;
}, },
}, },

View File

@ -11,7 +11,6 @@ import {
QueryValidatorOutstandingRewardsResponse, QueryValidatorOutstandingRewardsResponse,
QueryValidatorSlashesResponse, QueryValidatorSlashesResponse,
} from "cosmjs-types/cosmos/distribution/v1beta1/query"; } from "cosmjs-types/cosmos/distribution/v1beta1/query";
import Long from "long";
import { createPagination, createProtobufRpcClient, QueryClient } from "../../queryclient"; import { createPagination, createProtobufRpcClient, QueryClient } from "../../queryclient";
@ -100,8 +99,8 @@ export function setupDistributionExtension(base: QueryClient): DistributionExten
) => { ) => {
const response = await queryService.ValidatorSlashes({ const response = await queryService.ValidatorSlashes({
validatorAddress: validatorAddress, validatorAddress: validatorAddress,
startingHeight: Long.fromNumber(startingHeight, true), startingHeight: BigInt(startingHeight),
endingHeight: Long.fromNumber(endingHeight, true), endingHeight: BigInt(endingHeight),
pagination: createPagination(paginationKey), pagination: createPagination(paginationKey),
}); });
return response; return response;

View File

@ -1,7 +1,6 @@
/* eslint-disable @typescript-eslint/naming-convention */ /* eslint-disable @typescript-eslint/naming-convention */
import { TextProposal, VoteOption } from "cosmjs-types/cosmos/gov/v1beta1/gov"; import { TextProposal, VoteOption } from "cosmjs-types/cosmos/gov/v1beta1/gov";
import { MsgDeposit, MsgSubmitProposal, MsgVote, MsgVoteWeighted } from "cosmjs-types/cosmos/gov/v1beta1/tx"; import { MsgDeposit, MsgSubmitProposal, MsgVote, MsgVoteWeighted } from "cosmjs-types/cosmos/gov/v1beta1/tx";
import Long from "long";
import { AminoTypes } from "../../aminotypes"; import { AminoTypes } from "../../aminotypes";
import { import {
@ -18,7 +17,7 @@ describe("AminoTypes", () => {
const msg: MsgDeposit = { const msg: MsgDeposit = {
amount: [{ amount: "12300000", denom: "ustake" }], amount: [{ amount: "12300000", denom: "ustake" }],
depositor: "cosmos10dyr9899g6t0pelew4nvf4j5c3jcgv0r73qga5", depositor: "cosmos10dyr9899g6t0pelew4nvf4j5c3jcgv0r73qga5",
proposalId: Long.fromNumber(5), proposalId: BigInt(5),
}; };
const aminoTypes = new AminoTypes(createGovAminoConverters()); const aminoTypes = new AminoTypes(createGovAminoConverters());
const aminoMsg = aminoTypes.toAmino({ const aminoMsg = aminoTypes.toAmino({
@ -73,7 +72,7 @@ describe("AminoTypes", () => {
it("works for MsgVote", () => { it("works for MsgVote", () => {
const msg: MsgVote = { const msg: MsgVote = {
option: VoteOption.VOTE_OPTION_NO_WITH_VETO, option: VoteOption.VOTE_OPTION_NO_WITH_VETO,
proposalId: Long.fromNumber(5), proposalId: BigInt(5),
voter: "cosmos1xy4yqngt0nlkdcenxymg8tenrghmek4nmqm28k", voter: "cosmos1xy4yqngt0nlkdcenxymg8tenrghmek4nmqm28k",
}; };
const aminoTypes = new AminoTypes(createGovAminoConverters()); const aminoTypes = new AminoTypes(createGovAminoConverters());
@ -94,7 +93,7 @@ describe("AminoTypes", () => {
it("works for MsgVoteWeighted", () => { it("works for MsgVoteWeighted", () => {
const msg: MsgVoteWeighted = { const msg: MsgVoteWeighted = {
proposalId: Long.fromNumber(5), proposalId: BigInt(5),
voter: "cosmos1xy4yqngt0nlkdcenxymg8tenrghmek4nmqm28k", voter: "cosmos1xy4yqngt0nlkdcenxymg8tenrghmek4nmqm28k",
options: [ options: [
{ option: VoteOption.VOTE_OPTION_NO_WITH_VETO, weight: "700000000000000000" /* 0.7 */ }, { option: VoteOption.VOTE_OPTION_NO_WITH_VETO, weight: "700000000000000000" /* 0.7 */ },
@ -135,7 +134,7 @@ describe("AminoTypes", () => {
const expectedValue: MsgDeposit = { const expectedValue: MsgDeposit = {
amount: [{ amount: "12300000", denom: "ustake" }], amount: [{ amount: "12300000", denom: "ustake" }],
depositor: "cosmos10dyr9899g6t0pelew4nvf4j5c3jcgv0r73qga5", depositor: "cosmos10dyr9899g6t0pelew4nvf4j5c3jcgv0r73qga5",
proposalId: Long.fromNumber(5), proposalId: BigInt(5),
}; };
expect(msg).toEqual({ expect(msg).toEqual({
typeUrl: "/cosmos.gov.v1beta1.MsgDeposit", typeUrl: "/cosmos.gov.v1beta1.MsgDeposit",
@ -188,7 +187,7 @@ describe("AminoTypes", () => {
const msg = new AminoTypes(createGovAminoConverters()).fromAmino(aminoMsg); const msg = new AminoTypes(createGovAminoConverters()).fromAmino(aminoMsg);
const expectedValue: MsgVote = { const expectedValue: MsgVote = {
option: VoteOption.VOTE_OPTION_NO_WITH_VETO, option: VoteOption.VOTE_OPTION_NO_WITH_VETO,
proposalId: Long.fromNumber(5), proposalId: BigInt(5),
voter: "cosmos1xy4yqngt0nlkdcenxymg8tenrghmek4nmqm28k", voter: "cosmos1xy4yqngt0nlkdcenxymg8tenrghmek4nmqm28k",
}; };
expect(msg).toEqual({ expect(msg).toEqual({
@ -211,7 +210,7 @@ describe("AminoTypes", () => {
}; };
const msg = new AminoTypes(createGovAminoConverters()).fromAmino(aminoMsg); const msg = new AminoTypes(createGovAminoConverters()).fromAmino(aminoMsg);
const expectedValue: MsgVoteWeighted = { const expectedValue: MsgVoteWeighted = {
proposalId: Long.fromNumber(5), proposalId: BigInt(5),
voter: "cosmos1xy4yqngt0nlkdcenxymg8tenrghmek4nmqm28k", voter: "cosmos1xy4yqngt0nlkdcenxymg8tenrghmek4nmqm28k",
options: [ options: [
{ option: VoteOption.VOTE_OPTION_NO_WITH_VETO, weight: "750000000000000000" }, { option: VoteOption.VOTE_OPTION_NO_WITH_VETO, weight: "750000000000000000" },

View File

@ -5,7 +5,6 @@ import { assert, assertDefinedAndNotNull, isNonNullObject } from "@cosmjs/utils"
import { TextProposal, voteOptionFromJSON } from "cosmjs-types/cosmos/gov/v1beta1/gov"; import { TextProposal, voteOptionFromJSON } from "cosmjs-types/cosmos/gov/v1beta1/gov";
import { MsgDeposit, MsgSubmitProposal, MsgVote, MsgVoteWeighted } from "cosmjs-types/cosmos/gov/v1beta1/tx"; import { MsgDeposit, MsgSubmitProposal, MsgVote, MsgVoteWeighted } from "cosmjs-types/cosmos/gov/v1beta1/tx";
import { Any } from "cosmjs-types/google/protobuf/any"; import { Any } from "cosmjs-types/google/protobuf/any";
import Long from "long";
import { AminoConverters } from "../../aminotypes"; import { AminoConverters } from "../../aminotypes";
import { decodeCosmosSdkDecFromProto } from "../../queryclient"; import { decodeCosmosSdkDecFromProto } from "../../queryclient";
@ -120,7 +119,7 @@ export function createGovAminoConverters(): AminoConverters {
return { return {
amount: Array.from(amount), amount: Array.from(amount),
depositor, depositor,
proposalId: Long.fromString(proposal_id), proposalId: BigInt(proposal_id),
}; };
}, },
}, },
@ -136,7 +135,7 @@ export function createGovAminoConverters(): AminoConverters {
fromAmino: ({ option, proposal_id, voter }: AminoMsgVote["value"]): MsgVote => { fromAmino: ({ option, proposal_id, voter }: AminoMsgVote["value"]): MsgVote => {
return { return {
option: voteOptionFromJSON(option), option: voteOptionFromJSON(option),
proposalId: Long.fromString(proposal_id), proposalId: BigInt(proposal_id),
voter: voter, voter: voter,
}; };
}, },
@ -157,7 +156,7 @@ export function createGovAminoConverters(): AminoConverters {
}, },
fromAmino: ({ options, proposal_id, voter }: AminoMsgVoteWeighted["value"]): MsgVoteWeighted => { fromAmino: ({ options, proposal_id, voter }: AminoMsgVoteWeighted["value"]): MsgVoteWeighted => {
return { return {
proposalId: Long.fromString(proposal_id), proposalId: BigInt(proposal_id),
voter: voter, voter: voter,
options: options.map((o) => ({ options: options.map((o) => ({
option: voteOptionFromJSON(o.option), option: voteOptionFromJSON(o.option),

View File

@ -11,7 +11,6 @@ import {
WeightedVoteOption, WeightedVoteOption,
} from "cosmjs-types/cosmos/gov/v1beta1/gov"; } from "cosmjs-types/cosmos/gov/v1beta1/gov";
import { Any } from "cosmjs-types/google/protobuf/any"; import { Any } from "cosmjs-types/google/protobuf/any";
import Long from "long";
import { longify, QueryClient } from "../../queryclient"; import { longify, QueryClient } from "../../queryclient";
import { SigningStargateClient } from "../../signingstargateclient"; import { SigningStargateClient } from "../../signingstargateclient";
@ -161,7 +160,7 @@ describe("GovExtension", () => {
depositParams: { depositParams: {
minDeposit: simapp.govMinDeposit, minDeposit: simapp.govMinDeposit,
maxDepositPeriod: { maxDepositPeriod: {
seconds: Long.fromNumber(172800, false), seconds: BigInt(172800),
nanos: 0, nanos: 0,
}, },
}, },
@ -199,7 +198,7 @@ describe("GovExtension", () => {
jasmine.objectContaining({ jasmine.objectContaining({
votingParams: { votingParams: {
votingPeriod: { votingPeriod: {
seconds: Long.fromNumber(172800, false), seconds: BigInt(172800),
nanos: 0, nanos: 0,
}, },
}, },
@ -230,11 +229,11 @@ describe("GovExtension", () => {
proposalId: longify(proposalId), proposalId: longify(proposalId),
status: ProposalStatus.PROPOSAL_STATUS_VOTING_PERIOD, status: ProposalStatus.PROPOSAL_STATUS_VOTING_PERIOD,
finalTallyResult: { yes: "0", abstain: "0", no: "0", noWithVeto: "0" }, finalTallyResult: { yes: "0", abstain: "0", no: "0", noWithVeto: "0" },
submitTime: { seconds: jasmine.any(Long), nanos: jasmine.any(Number) }, submitTime: { seconds: jasmine.anything(), nanos: jasmine.any(Number) },
depositEndTime: { seconds: jasmine.any(Long), nanos: jasmine.any(Number) }, depositEndTime: { seconds: jasmine.anything(), nanos: jasmine.any(Number) },
totalDeposit: initialDeposit, totalDeposit: initialDeposit,
votingStartTime: { seconds: jasmine.any(Long), nanos: jasmine.any(Number) }, votingStartTime: { seconds: jasmine.anything(), nanos: jasmine.any(Number) },
votingEndTime: { seconds: jasmine.any(Long), nanos: jasmine.any(Number) }, votingEndTime: { seconds: jasmine.anything(), nanos: jasmine.any(Number) },
}); });
tmClient.disconnect(); tmClient.disconnect();
@ -256,11 +255,12 @@ describe("GovExtension", () => {
proposalId: longify(proposalId), proposalId: longify(proposalId),
status: ProposalStatus.PROPOSAL_STATUS_VOTING_PERIOD, status: ProposalStatus.PROPOSAL_STATUS_VOTING_PERIOD,
finalTallyResult: { yes: "0", abstain: "0", no: "0", noWithVeto: "0" }, finalTallyResult: { yes: "0", abstain: "0", no: "0", noWithVeto: "0" },
submitTime: { seconds: jasmine.any(Long), nanos: jasmine.any(Number) }, // Note: jasmine.any(Bigint) does not seem to work as expected in Jasmine 4.6
depositEndTime: { seconds: jasmine.any(Long), nanos: jasmine.any(Number) }, submitTime: { seconds: jasmine.anything(), nanos: jasmine.any(Number) },
depositEndTime: { seconds: jasmine.anything(), nanos: jasmine.any(Number) },
totalDeposit: initialDeposit, totalDeposit: initialDeposit,
votingStartTime: { seconds: jasmine.any(Long), nanos: jasmine.any(Number) }, votingStartTime: { seconds: jasmine.anything(), nanos: jasmine.any(Number) },
votingEndTime: { seconds: jasmine.any(Long), nanos: jasmine.any(Number) }, votingEndTime: { seconds: jasmine.anything(), nanos: jasmine.any(Number) },
}); });
tmClient.disconnect(); tmClient.disconnect();

View File

@ -11,13 +11,12 @@ import {
QueryVoteResponse, QueryVoteResponse,
QueryVotesResponse, QueryVotesResponse,
} from "cosmjs-types/cosmos/gov/v1beta1/query"; } from "cosmjs-types/cosmos/gov/v1beta1/query";
import Long from "long";
import { createPagination, createProtobufRpcClient, longify, QueryClient } from "../../queryclient"; import { createPagination, createProtobufRpcClient, longify, QueryClient } from "../../queryclient";
export type GovParamsType = "deposit" | "tallying" | "voting"; export type GovParamsType = "deposit" | "tallying" | "voting";
export type GovProposalId = string | number | Long | Uint64; export type GovProposalId = string | number | Uint64;
export interface GovExtension { export interface GovExtension {
readonly gov: { readonly gov: {

View File

@ -1,7 +1,6 @@
/* eslint-disable @typescript-eslint/naming-convention */ /* eslint-disable @typescript-eslint/naming-convention */
import { coin } from "@cosmjs/proto-signing"; import { coin } from "@cosmjs/proto-signing";
import { MsgTransfer } from "cosmjs-types/ibc/applications/transfer/v1/tx"; import { MsgTransfer } from "cosmjs-types/ibc/applications/transfer/v1/tx";
import Long from "long";
import { AminoTypes } from "../../aminotypes"; import { AminoTypes } from "../../aminotypes";
import { AminoMsgTransfer, createIbcAminoConverters } from "./aminomessages"; import { AminoMsgTransfer, createIbcAminoConverters } from "./aminomessages";
@ -16,10 +15,10 @@ describe("AminoTypes", () => {
sender: "cosmos1pkptre7fdkl6gfrzlesjjvhxhlc3r4gmmk8rs6", sender: "cosmos1pkptre7fdkl6gfrzlesjjvhxhlc3r4gmmk8rs6",
receiver: "cosmos10dyr9899g6t0pelew4nvf4j5c3jcgv0r73qga5", receiver: "cosmos10dyr9899g6t0pelew4nvf4j5c3jcgv0r73qga5",
timeoutHeight: { timeoutHeight: {
revisionHeight: Long.fromString("123", true), revisionHeight: BigInt("123"),
revisionNumber: Long.fromString("456", true), revisionNumber: BigInt("456"),
}, },
timeoutTimestamp: Long.fromString("789", true), timeoutTimestamp: BigInt("789"),
memo: "", memo: "",
}; };
const aminoTypes = new AminoTypes(createIbcAminoConverters()); const aminoTypes = new AminoTypes(createIbcAminoConverters());
@ -54,10 +53,10 @@ describe("AminoTypes", () => {
sender: "cosmos1pkptre7fdkl6gfrzlesjjvhxhlc3r4gmmk8rs6", sender: "cosmos1pkptre7fdkl6gfrzlesjjvhxhlc3r4gmmk8rs6",
receiver: "cosmos10dyr9899g6t0pelew4nvf4j5c3jcgv0r73qga5", receiver: "cosmos10dyr9899g6t0pelew4nvf4j5c3jcgv0r73qga5",
timeoutHeight: { timeoutHeight: {
revisionHeight: Long.UZERO, revisionHeight: BigInt(0),
revisionNumber: Long.UZERO, revisionNumber: BigInt(0),
}, },
timeoutTimestamp: Long.UZERO, timeoutTimestamp: BigInt(0),
memo: "", memo: "",
}; };
const aminoTypes = new AminoTypes(createIbcAminoConverters()); const aminoTypes = new AminoTypes(createIbcAminoConverters());
@ -85,16 +84,16 @@ describe("AminoTypes", () => {
}); });
it("works for MsgTransfer with no height timeout", () => { it("works for MsgTransfer with no height timeout", () => {
const msg: MsgTransfer = { const msg = MsgTransfer.fromPartial({
sourcePort: "testport", sourcePort: "testport",
sourceChannel: "testchannel", sourceChannel: "testchannel",
token: coin(1234, "utest"), token: coin(1234, "utest"),
sender: "cosmos1pkptre7fdkl6gfrzlesjjvhxhlc3r4gmmk8rs6", sender: "cosmos1pkptre7fdkl6gfrzlesjjvhxhlc3r4gmmk8rs6",
receiver: "cosmos10dyr9899g6t0pelew4nvf4j5c3jcgv0r73qga5", receiver: "cosmos10dyr9899g6t0pelew4nvf4j5c3jcgv0r73qga5",
timeoutHeight: undefined, timeoutHeight: undefined,
timeoutTimestamp: Long.UZERO, timeoutTimestamp: BigInt(0),
memo: "", memo: "",
}; });
const aminoMsg = new AminoTypes(createIbcAminoConverters()).toAmino({ const aminoMsg = new AminoTypes(createIbcAminoConverters()).toAmino({
typeUrl: "/ibc.applications.transfer.v1.MsgTransfer", typeUrl: "/ibc.applications.transfer.v1.MsgTransfer",
value: msg, value: msg,
@ -107,7 +106,10 @@ describe("AminoTypes", () => {
token: coin(1234, "utest"), token: coin(1234, "utest"),
sender: "cosmos1pkptre7fdkl6gfrzlesjjvhxhlc3r4gmmk8rs6", sender: "cosmos1pkptre7fdkl6gfrzlesjjvhxhlc3r4gmmk8rs6",
receiver: "cosmos10dyr9899g6t0pelew4nvf4j5c3jcgv0r73qga5", receiver: "cosmos10dyr9899g6t0pelew4nvf4j5c3jcgv0r73qga5",
timeout_height: {}, timeout_height: {
revision_number: undefined,
revision_height: undefined,
},
timeout_timestamp: undefined, timeout_timestamp: undefined,
memo: undefined, memo: undefined,
}, },
@ -141,10 +143,10 @@ describe("AminoTypes", () => {
sender: "cosmos1pkptre7fdkl6gfrzlesjjvhxhlc3r4gmmk8rs6", sender: "cosmos1pkptre7fdkl6gfrzlesjjvhxhlc3r4gmmk8rs6",
receiver: "cosmos10dyr9899g6t0pelew4nvf4j5c3jcgv0r73qga5", receiver: "cosmos10dyr9899g6t0pelew4nvf4j5c3jcgv0r73qga5",
timeoutHeight: { timeoutHeight: {
revisionHeight: Long.fromString("123", true), revisionHeight: BigInt("123"),
revisionNumber: Long.fromString("456", true), revisionNumber: BigInt("456"),
}, },
timeoutTimestamp: Long.fromString("789", true), timeoutTimestamp: BigInt("789"),
memo: "", memo: "",
}; };
expect(msg).toEqual({ expect(msg).toEqual({
@ -177,10 +179,10 @@ describe("AminoTypes", () => {
sender: "cosmos1pkptre7fdkl6gfrzlesjjvhxhlc3r4gmmk8rs6", sender: "cosmos1pkptre7fdkl6gfrzlesjjvhxhlc3r4gmmk8rs6",
receiver: "cosmos10dyr9899g6t0pelew4nvf4j5c3jcgv0r73qga5", receiver: "cosmos10dyr9899g6t0pelew4nvf4j5c3jcgv0r73qga5",
timeoutHeight: { timeoutHeight: {
revisionHeight: Long.UZERO, revisionHeight: BigInt(0),
revisionNumber: Long.UZERO, revisionNumber: BigInt(0),
}, },
timeoutTimestamp: Long.UZERO, timeoutTimestamp: BigInt(0),
memo: "", memo: "",
}; };
expect(msg).toEqual({ expect(msg).toEqual({

View File

@ -1,7 +1,6 @@
/* eslint-disable @typescript-eslint/naming-convention */ /* eslint-disable @typescript-eslint/naming-convention */
import { AminoMsg, Coin } from "@cosmjs/amino"; import { AminoMsg, Coin } from "@cosmjs/amino";
import { MsgTransfer } from "cosmjs-types/ibc/applications/transfer/v1/tx"; import { MsgTransfer } from "cosmjs-types/ibc/applications/transfer/v1/tx";
import Long from "long";
import { AminoConverters } from "../../aminotypes"; import { AminoConverters } from "../../aminotypes";
@ -46,7 +45,7 @@ export function isAminoMsgTransfer(msg: AminoMsg): msg is AminoMsgTransfer {
return msg.type === "cosmos-sdk/MsgTransfer"; return msg.type === "cosmos-sdk/MsgTransfer";
} }
function omitDefault<T extends string | number | Long>(input: T): T | undefined { function omitDefault<T extends string | number | bigint>(input: T): T | undefined {
if (typeof input === "string") { if (typeof input === "string") {
return input === "" ? undefined : input; return input === "" ? undefined : input;
} }
@ -55,8 +54,8 @@ function omitDefault<T extends string | number | Long>(input: T): T | undefined
return input === 0 ? undefined : input; return input === 0 ? undefined : input;
} }
if (Long.isLong(input)) { if (typeof input === "bigint") {
return input.isZero() ? undefined : input; return input === BigInt(0) ? undefined : input;
} }
throw new Error(`Got unsupported type '${typeof input}'`); throw new Error(`Got unsupported type '${typeof input}'`);
@ -107,11 +106,11 @@ export function createIbcAminoConverters(): AminoConverters {
receiver: receiver, receiver: receiver,
timeoutHeight: timeout_height timeoutHeight: timeout_height
? { ? {
revisionHeight: Long.fromString(timeout_height.revision_height || "0", true), revisionHeight: BigInt(timeout_height.revision_height || "0"),
revisionNumber: Long.fromString(timeout_height.revision_number || "0", true), revisionNumber: BigInt(timeout_height.revision_number || "0"),
} }
: undefined, : undefined,
timeoutTimestamp: Long.fromString(timeout_timestamp || "0", true), timeoutTimestamp: BigInt(timeout_timestamp || "0"),
}), }),
}, },
}; };

View File

@ -15,7 +15,6 @@ import {
State as ConnectionState, State as ConnectionState,
Version, Version,
} from "cosmjs-types/ibc/core/connection/v1/connection"; } from "cosmjs-types/ibc/core/connection/v1/connection";
import Long from "long";
// From scripts/simapp42/genesis-ibc.json // From scripts/simapp42/genesis-ibc.json
@ -61,7 +60,7 @@ export const commitment = {
export const packetState = PacketState.fromPartial({ export const packetState = PacketState.fromPartial({
portId: portId, portId: portId,
channelId: channelId, channelId: channelId,
sequence: Long.fromInt(commitment.sequence, true), sequence: BigInt(commitment.sequence),
data: commitment.data, data: commitment.data,
}); });

View File

@ -1,5 +1,4 @@
import { Tendermint34Client } from "@cosmjs/tendermint-rpc"; import { Tendermint34Client } from "@cosmjs/tendermint-rpc";
import Long from "long";
import { QueryClient } from "../../queryclient"; import { QueryClient } from "../../queryclient";
import { simapp } from "../../testutils.spec"; import { simapp } from "../../testutils.spec";
@ -233,7 +232,7 @@ describe("IbcExtension", () => {
ibcTest.channelId, ibcTest.channelId,
[1, 2, 3], [1, 2, 3],
); );
expect(response.sequences).toEqual([1, 2, 3].map((n) => Long.fromInt(n, true))); expect(response.sequences).toEqual([1, 2, 3].map((n) => BigInt(n)));
expect(response.height).toBeDefined(); expect(response.height).toBeDefined();
tmClient.disconnect(); tmClient.disconnect();
@ -250,7 +249,7 @@ describe("IbcExtension", () => {
ibcTest.channelId, ibcTest.channelId,
[1, 2, 3, 4, 5, 6, 7], [1, 2, 3, 4, 5, 6, 7],
); );
expect(response.sequences).toEqual([Long.fromInt(ibcTest.commitment.sequence, true)]); expect(response.sequences).toEqual([BigInt(ibcTest.commitment.sequence)]);
expect(response.height).toBeDefined(); expect(response.height).toBeDefined();
tmClient.disconnect(); tmClient.disconnect();
@ -263,7 +262,7 @@ describe("IbcExtension", () => {
const [client, tmClient] = await makeClientWithIbc(simapp.tendermintUrl); const [client, tmClient] = await makeClientWithIbc(simapp.tendermintUrl);
const response = await client.ibc.channel.nextSequenceReceive(ibcTest.portId, ibcTest.channelId); const response = await client.ibc.channel.nextSequenceReceive(ibcTest.portId, ibcTest.channelId);
expect(response.nextSequenceReceive).toEqual(Long.fromInt(1, true)); expect(response.nextSequenceReceive).toEqual(BigInt(1));
expect(response.proofHeight).toBeDefined(); expect(response.proofHeight).toBeDefined();
expect(response.proofHeight).not.toBeNull(); expect(response.proofHeight).not.toBeNull();

View File

@ -49,9 +49,8 @@ import {
ClientState as TendermintClientState, ClientState as TendermintClientState,
ConsensusState as TendermintConsensusState, ConsensusState as TendermintConsensusState,
} from "cosmjs-types/ibc/lightclients/tendermint/v1/tendermint"; } from "cosmjs-types/ibc/lightclients/tendermint/v1/tendermint";
import Long from "long";
import { createPagination, createProtobufRpcClient, QueryClient } from "../../queryclient"; import { createPagination, createProtobufRpcClient, longify, QueryClient } from "../../queryclient";
function decodeTendermintClientStateAny(clientState: Any | undefined): TendermintClientState { function decodeTendermintClientStateAny(clientState: Any | undefined): TendermintClientState {
if (clientState?.typeUrl !== "/ibc.lightclients.tendermint.v1.ClientState") { if (clientState?.typeUrl !== "/ibc.lightclients.tendermint.v1.ClientState") {
@ -218,10 +217,10 @@ export function setupIbcExtension(base: QueryClient): IbcExtension {
channels.push(...response.channels); channels.push(...response.channels);
key = response.pagination?.nextKey; key = response.pagination?.nextKey;
} while (key && key.length); } while (key && key.length);
return { return QueryChannelsResponse.fromPartial({
channels: channels, channels: channels,
height: response.height, height: response.height,
}; });
}, },
connectionChannels: async (connection: string, paginationKey?: Uint8Array) => connectionChannels: async (connection: string, paginationKey?: Uint8Array) =>
channelQueryService.ConnectionChannels({ channelQueryService.ConnectionChannels({
@ -240,10 +239,10 @@ export function setupIbcExtension(base: QueryClient): IbcExtension {
channels.push(...response.channels); channels.push(...response.channels);
key = response.pagination?.nextKey; key = response.pagination?.nextKey;
} while (key && key.length); } while (key && key.length);
return { return QueryConnectionChannelsResponse.fromPartial({
channels: channels, channels: channels,
height: response.height, height: response.height,
}; });
}, },
clientState: async (portId: string, channelId: string) => clientState: async (portId: string, channelId: string) =>
channelQueryService.ChannelClientState({ channelQueryService.ChannelClientState({
@ -259,14 +258,14 @@ export function setupIbcExtension(base: QueryClient): IbcExtension {
channelQueryService.ChannelConsensusState({ channelQueryService.ChannelConsensusState({
portId: portId, portId: portId,
channelId: channelId, channelId: channelId,
revisionNumber: Long.fromNumber(revisionNumber, true), revisionNumber: BigInt(revisionNumber),
revisionHeight: Long.fromNumber(revisionHeight, true), revisionHeight: BigInt(revisionHeight),
}), }),
packetCommitment: async (portId: string, channelId: string, sequence: number) => packetCommitment: async (portId: string, channelId: string, sequence: number) =>
channelQueryService.PacketCommitment({ channelQueryService.PacketCommitment({
portId: portId, portId: portId,
channelId: channelId, channelId: channelId,
sequence: Long.fromNumber(sequence, true), sequence: longify(sequence),
}), }),
packetCommitments: async (portId: string, channelId: string, paginationKey?: Uint8Array) => packetCommitments: async (portId: string, channelId: string, paginationKey?: Uint8Array) =>
channelQueryService.PacketCommitments({ channelQueryService.PacketCommitments({
@ -287,22 +286,22 @@ export function setupIbcExtension(base: QueryClient): IbcExtension {
commitments.push(...response.commitments); commitments.push(...response.commitments);
key = response.pagination?.nextKey; key = response.pagination?.nextKey;
} while (key && key.length); } while (key && key.length);
return { return QueryPacketCommitmentsResponse.fromPartial({
commitments: commitments, commitments: commitments,
height: response.height, height: response.height,
}; });
}, },
packetReceipt: async (portId: string, channelId: string, sequence: number) => packetReceipt: async (portId: string, channelId: string, sequence: number) =>
channelQueryService.PacketReceipt({ channelQueryService.PacketReceipt({
portId: portId, portId: portId,
channelId: channelId, channelId: channelId,
sequence: Long.fromNumber(sequence, true), sequence: longify(sequence),
}), }),
packetAcknowledgement: async (portId: string, channelId: string, sequence: number) => packetAcknowledgement: async (portId: string, channelId: string, sequence: number) =>
channelQueryService.PacketAcknowledgement({ channelQueryService.PacketAcknowledgement({
portId: portId, portId: portId,
channelId: channelId, channelId: channelId,
sequence: Long.fromNumber(sequence, true), sequence: longify(sequence),
}), }),
packetAcknowledgements: async (portId: string, channelId: string, paginationKey?: Uint8Array) => { packetAcknowledgements: async (portId: string, channelId: string, paginationKey?: Uint8Array) => {
const request = QueryPacketAcknowledgementsRequest.fromPartial({ const request = QueryPacketAcknowledgementsRequest.fromPartial({
@ -326,10 +325,10 @@ export function setupIbcExtension(base: QueryClient): IbcExtension {
acknowledgements.push(...response.acknowledgements); acknowledgements.push(...response.acknowledgements);
key = response.pagination?.nextKey; key = response.pagination?.nextKey;
} while (key && key.length); } while (key && key.length);
return { return QueryPacketAcknowledgementsResponse.fromPartial({
acknowledgements: acknowledgements, acknowledgements: acknowledgements,
height: response.height, height: response.height,
}; });
}, },
unreceivedPackets: async ( unreceivedPackets: async (
portId: string, portId: string,
@ -339,13 +338,13 @@ export function setupIbcExtension(base: QueryClient): IbcExtension {
channelQueryService.UnreceivedPackets({ channelQueryService.UnreceivedPackets({
portId: portId, portId: portId,
channelId: channelId, channelId: channelId,
packetCommitmentSequences: packetCommitmentSequences.map((s) => Long.fromNumber(s, true)), packetCommitmentSequences: packetCommitmentSequences.map((s) => BigInt(s)),
}), }),
unreceivedAcks: async (portId: string, channelId: string, packetAckSequences: readonly number[]) => unreceivedAcks: async (portId: string, channelId: string, packetAckSequences: readonly number[]) =>
channelQueryService.UnreceivedAcks({ channelQueryService.UnreceivedAcks({
portId: portId, portId: portId,
channelId: channelId, channelId: channelId,
packetAckSequences: packetAckSequences.map((s) => Long.fromNumber(s, true)), packetAckSequences: packetAckSequences.map((s) => BigInt(s)),
}), }),
nextSequenceReceive: async (portId: string, channelId: string) => nextSequenceReceive: async (portId: string, channelId: string) =>
channelQueryService.NextSequenceReceive({ channelQueryService.NextSequenceReceive({
@ -370,16 +369,15 @@ export function setupIbcExtension(base: QueryClient): IbcExtension {
clientStates.push(...response.clientStates); clientStates.push(...response.clientStates);
key = response.pagination?.nextKey; key = response.pagination?.nextKey;
} while (key && key.length); } while (key && key.length);
return { return QueryClientStatesResponse.fromPartial({
clientStates: clientStates, clientStates: clientStates,
}; });
}, },
consensusState: async (clientId: string, consensusHeight?: number) => consensusState: async (clientId: string, consensusHeight?: number) =>
clientQueryService.ConsensusState( clientQueryService.ConsensusState(
QueryConsensusStateRequest.fromPartial({ QueryConsensusStateRequest.fromPartial({
clientId: clientId, clientId: clientId,
revisionHeight: revisionHeight: consensusHeight !== undefined ? BigInt(consensusHeight) : undefined,
consensusHeight !== undefined ? Long.fromNumber(consensusHeight, true) : undefined,
latestHeight: consensusHeight === undefined, latestHeight: consensusHeight === undefined,
}), }),
), ),
@ -400,9 +398,9 @@ export function setupIbcExtension(base: QueryClient): IbcExtension {
consensusStates.push(...response.consensusStates); consensusStates.push(...response.consensusStates);
key = response.pagination?.nextKey; key = response.pagination?.nextKey;
} while (key && key.length); } while (key && key.length);
return { return QueryConsensusStatesResponse.fromPartial({
consensusStates: consensusStates, consensusStates: consensusStates,
}; });
}, },
params: async () => clientQueryService.ClientParams({}), params: async () => clientQueryService.ClientParams({}),
stateTm: async (clientId: string) => { stateTm: async (clientId: string) => {
@ -460,10 +458,10 @@ export function setupIbcExtension(base: QueryClient): IbcExtension {
connections.push(...response.connections); connections.push(...response.connections);
key = response.pagination?.nextKey; key = response.pagination?.nextKey;
} while (key && key.length); } while (key && key.length);
return { return QueryConnectionsResponse.fromPartial({
connections: connections, connections: connections,
height: response.height, height: response.height,
}; });
}, },
clientConnections: async (clientId: string) => clientConnections: async (clientId: string) =>
connectionQueryService.ClientConnections({ connectionQueryService.ClientConnections({
@ -477,7 +475,7 @@ export function setupIbcExtension(base: QueryClient): IbcExtension {
connectionQueryService.ConnectionConsensusState( connectionQueryService.ConnectionConsensusState(
QueryConnectionConsensusStateRequest.fromPartial({ QueryConnectionConsensusStateRequest.fromPartial({
connectionId: connectionId, connectionId: connectionId,
revisionHeight: Long.fromNumber(revisionHeight, true), revisionHeight: BigInt(revisionHeight),
}), }),
), ),
}, },
@ -498,9 +496,9 @@ export function setupIbcExtension(base: QueryClient): IbcExtension {
denomTraces.push(...response.denomTraces); denomTraces.push(...response.denomTraces);
key = response.pagination?.nextKey; key = response.pagination?.nextKey;
} while (key && key.length); } while (key && key.length);
return { return QueryDenomTracesResponse.fromPartial({
denomTraces: denomTraces, denomTraces: denomTraces,
}; });
}, },
params: async () => transferQueryService.Params({}), params: async () => transferQueryService.Params({}),
}, },

View File

@ -18,8 +18,8 @@ describe("MintExtension", () => {
const [client, tmClient] = await makeClientWithMint(simapp.tendermintUrl); const [client, tmClient] = await makeClientWithMint(simapp.tendermintUrl);
const params = await client.mint.params(); const params = await client.mint.params();
expect(params.blocksPerYear.toNumber()).toBeGreaterThan(100_000); expect(Number(params.blocksPerYear)).toBeGreaterThan(100_000);
expect(params.blocksPerYear.toNumber()).toBeLessThan(100_000_000); expect(Number(params.blocksPerYear)).toBeLessThan(100_000_000);
expect(params.goalBonded.toString()).toEqual("0.67"); expect(params.goalBonded.toString()).toEqual("0.67");
expect(params.inflationMin.toString()).toEqual("0.07"); expect(params.inflationMin.toString()).toEqual("0.07");
expect(params.inflationMax.toString()).toEqual("0.2"); expect(params.inflationMax.toString()).toEqual("0.2");

View File

@ -233,7 +233,7 @@ describe("StakingExtension", () => {
}, },
balance: { denom: "ustake", amount: "3000000" }, balance: { denom: "ustake", amount: "3000000" },
}); });
expect(response.pagination?.total.toNumber()).toBeGreaterThanOrEqual(2); expect(Number(response.pagination!.total)).toBeGreaterThanOrEqual(2);
tmClient.disconnect(); tmClient.disconnect();
}); });

View File

@ -17,7 +17,6 @@ import {
QueryValidatorUnbondingDelegationsResponse, QueryValidatorUnbondingDelegationsResponse,
} from "cosmjs-types/cosmos/staking/v1beta1/query"; } from "cosmjs-types/cosmos/staking/v1beta1/query";
import { BondStatus } from "cosmjs-types/cosmos/staking/v1beta1/staking"; import { BondStatus } from "cosmjs-types/cosmos/staking/v1beta1/staking";
import Long from "long";
import { createPagination, createProtobufRpcClient, QueryClient } from "../../queryclient"; import { createPagination, createProtobufRpcClient, QueryClient } from "../../queryclient";
@ -118,9 +117,9 @@ export function setupStakingExtension(base: QueryClient): StakingExtension {
}); });
return response; return response;
}, },
historicalInfo: async (height: number) => { historicalInfo: async (height: number | bigint) => {
const response = await queryService.HistoricalInfo({ const response = await queryService.HistoricalInfo({
height: Long.fromNumber(height, true), height: BigInt(height),
}); });
return response; return response;
}, },

View File

@ -2,7 +2,6 @@ import { coin, coins, DirectSecp256k1HdWallet, Registry } from "@cosmjs/proto-si
import { Tendermint34Client } from "@cosmjs/tendermint-rpc"; import { Tendermint34Client } from "@cosmjs/tendermint-rpc";
import { assertDefined, sleep } from "@cosmjs/utils"; import { assertDefined, sleep } from "@cosmjs/utils";
import { MsgDelegate } from "cosmjs-types/cosmos/staking/v1beta1/tx"; import { MsgDelegate } from "cosmjs-types/cosmos/staking/v1beta1/tx";
import Long from "long";
import { QueryClient } from "../../queryclient"; import { QueryClient } from "../../queryclient";
import { defaultRegistryTypes, SigningStargateClient } from "../../signingstargateclient"; import { defaultRegistryTypes, SigningStargateClient } from "../../signingstargateclient";
@ -94,11 +93,11 @@ describe("TxExtension", () => {
const { sequence } = await sequenceClient.getSequence(faucet.address0); const { sequence } = await sequenceClient.getSequence(faucet.address0);
const response = await client.tx.simulate([msgAny], "foo", faucet.pubkey0, sequence); const response = await client.tx.simulate([msgAny], "foo", faucet.pubkey0, sequence);
expect(response.gasInfo?.gasUsed.toNumber()).toBeGreaterThanOrEqual(101_000); expect(response.gasInfo?.gasUsed).toBeGreaterThanOrEqual(101_000);
expect(response.gasInfo?.gasUsed.toNumber()).toBeLessThanOrEqual(200_000); expect(response.gasInfo?.gasUsed).toBeLessThanOrEqual(200_000);
expect(response.gasInfo?.gasWanted).toEqual( expect(response.gasInfo?.gasWanted).toEqual(
// Some dummy value. Value does not matter for regular users. // Some dummy value. Value does not matter for regular users.
simapp44Enabled() ? Long.UZERO : Long.MAX_UNSIGNED_VALUE, simapp44Enabled() ? BigInt(0) : BigInt("0xffffffffffffffff"),
); );
tmClient.disconnect(); tmClient.disconnect();

View File

@ -10,7 +10,6 @@ import {
} from "cosmjs-types/cosmos/tx/v1beta1/service"; } from "cosmjs-types/cosmos/tx/v1beta1/service";
import { AuthInfo, Fee, Tx, TxBody } from "cosmjs-types/cosmos/tx/v1beta1/tx"; import { AuthInfo, Fee, Tx, 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 { createProtobufRpcClient, QueryClient } from "../../queryclient"; import { createProtobufRpcClient, QueryClient } from "../../queryclient";
@ -56,7 +55,7 @@ export function setupTxExtension(base: QueryClient): TxExtension {
signerInfos: [ signerInfos: [
{ {
publicKey: encodePubkey(signer), publicKey: encodePubkey(signer),
sequence: Long.fromNumber(sequence, true), sequence: BigInt(sequence),
modeInfo: { single: { mode: SignMode.SIGN_MODE_UNSPECIFIED } }, modeInfo: { single: { mode: SignMode.SIGN_MODE_UNSPECIFIED } },
}, },
], ],

View File

@ -1,7 +1,6 @@
/* eslint-disable @typescript-eslint/naming-convention */ /* eslint-disable @typescript-eslint/naming-convention */
import { coins } from "@cosmjs/amino"; import { coins } from "@cosmjs/amino";
import { MsgCreateVestingAccount } from "cosmjs-types/cosmos/vesting/v1beta1/tx"; import { MsgCreateVestingAccount } from "cosmjs-types/cosmos/vesting/v1beta1/tx";
import Long from "long";
import { AminoTypes } from "../../aminotypes"; import { AminoTypes } from "../../aminotypes";
import { AminoMsgCreateVestingAccount, createVestingAminoConverters } from "./aminomessages"; import { AminoMsgCreateVestingAccount, createVestingAminoConverters } from "./aminomessages";
@ -13,7 +12,7 @@ describe("vesting Amino messages", () => {
fromAddress: "cosmos10dyr9899g6t0pelew4nvf4j5c3jcgv0r73qga5", fromAddress: "cosmos10dyr9899g6t0pelew4nvf4j5c3jcgv0r73qga5",
toAddress: "cosmos1xy4yqngt0nlkdcenxymg8tenrghmek4nmqm28k", toAddress: "cosmos1xy4yqngt0nlkdcenxymg8tenrghmek4nmqm28k",
amount: coins(1234, "ucosm"), amount: coins(1234, "ucosm"),
endTime: Long.fromString("1838718434"), endTime: BigInt("1838718434"),
delayed: true, delayed: true,
}); });
const aminoTypes = new AminoTypes(createVestingAminoConverters()); const aminoTypes = new AminoTypes(createVestingAminoConverters());
@ -52,7 +51,7 @@ describe("vesting Amino messages", () => {
fromAddress: "cosmos10dyr9899g6t0pelew4nvf4j5c3jcgv0r73qga5", fromAddress: "cosmos10dyr9899g6t0pelew4nvf4j5c3jcgv0r73qga5",
toAddress: "cosmos1xy4yqngt0nlkdcenxymg8tenrghmek4nmqm28k", toAddress: "cosmos1xy4yqngt0nlkdcenxymg8tenrghmek4nmqm28k",
amount: coins(1234, "ucosm"), amount: coins(1234, "ucosm"),
endTime: Long.fromString("1838718434"), endTime: BigInt("1838718434"),
delayed: true, delayed: true,
}; };
expect(msg).toEqual({ expect(msg).toEqual({

View File

@ -1,7 +1,6 @@
/* eslint-disable @typescript-eslint/naming-convention */ /* eslint-disable @typescript-eslint/naming-convention */
import { AminoMsg, Coin } from "@cosmjs/amino"; import { AminoMsg, Coin } from "@cosmjs/amino";
import { MsgCreateVestingAccount } from "cosmjs-types/cosmos/vesting/v1beta1/tx"; import { MsgCreateVestingAccount } from "cosmjs-types/cosmos/vesting/v1beta1/tx";
import Long from "long";
import { AminoConverters } from "../../aminotypes"; import { AminoConverters } from "../../aminotypes";
@ -49,7 +48,7 @@ export function createVestingAminoConverters(): AminoConverters {
fromAddress: from_address, fromAddress: from_address,
toAddress: to_address, toAddress: to_address,
amount: [...amount], amount: [...amount],
endTime: Long.fromString(end_time), endTime: BigInt(end_time),
delayed: delayed, delayed: delayed,
}), }),
}, },

View File

@ -1,7 +1,6 @@
import { coin, coins, Secp256k1HdWallet } from "@cosmjs/amino"; import { coin, coins, Secp256k1HdWallet } from "@cosmjs/amino";
import { DirectSecp256k1HdWallet } from "@cosmjs/proto-signing"; import { DirectSecp256k1HdWallet } from "@cosmjs/proto-signing";
import { MsgCreateVestingAccount } from "cosmjs-types/cosmos/vesting/v1beta1/tx"; import { MsgCreateVestingAccount } from "cosmjs-types/cosmos/vesting/v1beta1/tx";
import Long from "long";
import { SigningStargateClient } from "../../signingstargateclient"; import { SigningStargateClient } from "../../signingstargateclient";
import { assertIsDeliverTxSuccess } from "../../stargateclient"; import { assertIsDeliverTxSuccess } from "../../stargateclient";
@ -33,7 +32,7 @@ describe("vesting messages", () => {
fromAddress: faucet.address0, fromAddress: faucet.address0,
toAddress: recipient, toAddress: recipient,
amount: coins(1234, "ucosm"), amount: coins(1234, "ucosm"),
endTime: Long.fromString("1838718434"), endTime: BigInt("1838718434"),
delayed: true, delayed: true,
}), }),
}; };
@ -63,7 +62,7 @@ describe("vesting messages", () => {
fromAddress: faucet.address0, fromAddress: faucet.address0,
toAddress: recipient, toAddress: recipient,
amount: coins(1234, "ucosm"), amount: coins(1234, "ucosm"),
endTime: Long.fromString("1838718434"), endTime: BigInt("1838718434"),
delayed: true, delayed: true,
}), }),
}; };

View File

@ -5,7 +5,6 @@ import { CompactBitArray, MultiSignature } from "cosmjs-types/cosmos/crypto/mult
import { SignMode } from "cosmjs-types/cosmos/tx/signing/v1beta1/signing"; import { SignMode } from "cosmjs-types/cosmos/tx/signing/v1beta1/signing";
import { AuthInfo, SignerInfo } from "cosmjs-types/cosmos/tx/v1beta1/tx"; import { AuthInfo, SignerInfo } from "cosmjs-types/cosmos/tx/v1beta1/tx";
import { TxRaw } from "cosmjs-types/cosmos/tx/v1beta1/tx"; import { TxRaw } from "cosmjs-types/cosmos/tx/v1beta1/tx";
import Long from "long";
export function makeCompactBitArray(bits: readonly boolean[]): CompactBitArray { export function makeCompactBitArray(bits: readonly boolean[]): CompactBitArray {
const byteCount = Math.ceil(bits.length / 8); const byteCount = Math.ceil(bits.length / 8);
@ -58,14 +57,14 @@ export function makeMultisignedTx(
modeInfos: signaturesList.map((_) => ({ single: { mode: SignMode.SIGN_MODE_LEGACY_AMINO_JSON } })), modeInfos: signaturesList.map((_) => ({ single: { mode: SignMode.SIGN_MODE_LEGACY_AMINO_JSON } })),
}, },
}, },
sequence: Long.fromNumber(sequence), sequence: BigInt(sequence),
}; };
const authInfo = AuthInfo.fromPartial({ const authInfo = AuthInfo.fromPartial({
signerInfos: [signerInfo], signerInfos: [signerInfo],
fee: { fee: {
amount: [...fee.amount], amount: [...fee.amount],
gasLimit: Long.fromString(fee.gas), gasLimit: BigInt(fee.gas),
}, },
}); });

View File

@ -98,7 +98,9 @@ describe("QueryClient", () => {
const [client, tmClient] = await makeClient(simapp.tendermintUrlWs); const [client, tmClient] = await makeClient(simapp.tendermintUrlWs);
const requestData = Uint8Array.from( const requestData = Uint8Array.from(
QueryAllBalancesRequest.encode({ address: unused.address }).finish(), QueryAllBalancesRequest.encode(
QueryAllBalancesRequest.fromPartial({ address: unused.address }),
).finish(),
); );
const { value } = await client.queryAbci(`/cosmos.bank.v1beta1.Query/AllBalances`, requestData); const { value } = await client.queryAbci(`/cosmos.bank.v1beta1.Query/AllBalances`, requestData);
const response = QueryAllBalancesResponse.decode(value); const response = QueryAllBalancesResponse.decode(value);
@ -112,7 +114,9 @@ describe("QueryClient", () => {
const [client, tmClient] = await makeClient(simapp.tendermintUrlHttp); const [client, tmClient] = await makeClient(simapp.tendermintUrlHttp);
const requestData = Uint8Array.from( const requestData = Uint8Array.from(
QueryAllBalancesRequest.encode({ address: unused.address }).finish(), QueryAllBalancesRequest.encode(
QueryAllBalancesRequest.fromPartial({ address: unused.address }),
).finish(),
); );
const { value } = await client.queryAbci(`/cosmos.bank.v1beta1.Query/AllBalances`, requestData); const { value } = await client.queryAbci(`/cosmos.bank.v1beta1.Query/AllBalances`, requestData);
const response = QueryAllBalancesResponse.decode(value); const response = QueryAllBalancesResponse.decode(value);

View File

@ -1,7 +1,6 @@
import { fromAscii, fromBech32 } from "@cosmjs/encoding"; import { fromAscii, fromBech32 } from "@cosmjs/encoding";
import { Decimal, Uint64 } from "@cosmjs/math"; import { Decimal, Uint64 } from "@cosmjs/math";
import { PageRequest } from "cosmjs-types/cosmos/base/query/v1beta1/pagination"; import { PageRequest } from "cosmjs-types/cosmos/base/query/v1beta1/pagination";
import Long from "long";
import { QueryClient } from "./queryclient"; import { QueryClient } from "./queryclient";
@ -21,8 +20,8 @@ export function toAccAddress(address: string): Uint8Array {
* Use this with a query response's pagination next key to * Use this with a query response's pagination next key to
* request the next page. * request the next page.
*/ */
export function createPagination(paginationKey?: Uint8Array): PageRequest | undefined { export function createPagination(paginationKey?: Uint8Array): PageRequest {
return paginationKey ? PageRequest.fromPartial({ key: paginationKey }) : undefined; return paginationKey ? PageRequest.fromPartial({ key: paginationKey }) : PageRequest.fromPartial({});
} }
export interface ProtobufRpcClient { export interface ProtobufRpcClient {
@ -40,12 +39,12 @@ export function createProtobufRpcClient(base: QueryClient): ProtobufRpcClient {
} }
/** /**
* Takes a uint64 value as string, number, Long or Uint64 and returns an unsigned Long instance * Takes a uint64 value as string, number, BigInt or Uint64 and returns a BigInt
* of it. * of it.
*/ */
export function longify(value: string | number | Long | Uint64): Long { export function longify(value: string | number | Uint64): bigint {
const checkedValue = Uint64.fromString(value.toString()); const checkedValue = Uint64.fromString(value.toString());
return Long.fromBytesBE([...checkedValue.toBytesBigEndian()], true); return BigInt(checkedValue.toString());
} }
/** /**

View File

@ -11,6 +11,7 @@ import {
import { Tendermint34Client } from "@cosmjs/tendermint-rpc"; import { Tendermint34Client } from "@cosmjs/tendermint-rpc";
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 { BasicAllowance } from "cosmjs-types/cosmos/feegrant/v1beta1/feegrant"; import { BasicAllowance } from "cosmjs-types/cosmos/feegrant/v1beta1/feegrant";
@ -18,8 +19,6 @@ import { MsgGrantAllowance } from "cosmjs-types/cosmos/feegrant/v1beta1/tx";
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 { Any } from "cosmjs-types/google/protobuf/any"; import { Any } from "cosmjs-types/google/protobuf/any";
import Long from "long";
import protobuf from "protobufjs/minimal";
import { AminoTypes } from "./aminotypes"; import { AminoTypes } from "./aminotypes";
import { import {
@ -190,14 +189,16 @@ describe("SigningStargateClient", () => {
const allowance: Any = { const allowance: Any = {
typeUrl: "/cosmos.feegrant.v1beta1.BasicAllowance", typeUrl: "/cosmos.feegrant.v1beta1.BasicAllowance",
value: Uint8Array.from( value: Uint8Array.from(
BasicAllowance.encode({ BasicAllowance.encode(
spendLimit: [ BasicAllowance.fromPartial({
{ spendLimit: [
denom: "ucosm", {
amount: "1234567", denom: "ucosm",
}, amount: "1234567",
], },
}).finish(), ],
}),
).finish(),
), ),
}; };
const grantMsg = { const grantMsg = {
@ -260,7 +261,7 @@ describe("SigningStargateClient", () => {
coin(1234, "ucosm"), coin(1234, "ucosm"),
"fooPort", "fooPort",
"fooChannel", "fooChannel",
{ revisionHeight: Long.fromNumber(123), revisionNumber: Long.fromNumber(456) }, { revisionHeight: BigInt(123), revisionNumber: BigInt(456) },
Math.floor(Date.now() / 1000) + 60, Math.floor(Date.now() / 1000) + 60,
fee, fee,
memo, memo,
@ -309,7 +310,7 @@ describe("SigningStargateClient", () => {
coin(1234, "ucosm"), coin(1234, "ucosm"),
"fooPort", "fooPort",
"fooChannel", "fooChannel",
{ revisionHeight: Long.fromNumber(123), revisionNumber: Long.fromNumber(456) }, { revisionHeight: BigInt(123), revisionNumber: BigInt(456) },
Math.floor(Date.now() / 1000) + 60, Math.floor(Date.now() / 1000) + 60,
fee, fee,
memo, memo,
@ -455,7 +456,7 @@ describe("SigningStargateClient", () => {
// 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(tx.authInfo.fee!.gasLimit).toEqual(BigInt(333333));
}); });
}); });
@ -558,10 +559,8 @@ describe("SigningStargateClient", () => {
}; };
const CustomMsgDelegate = { const CustomMsgDelegate = {
// Adapted from autogenerated MsgDelegate implementation // Adapted from autogenerated MsgDelegate implementation
encode( typeUrl: "foobar",
message: CustomMsgDelegate, encode(message: CustomMsgDelegate, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter {
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) {
@ -685,7 +684,7 @@ describe("SigningStargateClient", () => {
// 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(tx.authInfo.fee!.gasLimit).toEqual(BigInt(333333));
}); });
}); });
}); });
@ -906,7 +905,7 @@ describe("SigningStargateClient", () => {
// 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(authInfo.fee!.gasLimit).toEqual(BigInt(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()));
@ -991,11 +990,9 @@ describe("SigningStargateClient", () => {
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) {
@ -1118,7 +1115,7 @@ describe("SigningStargateClient", () => {
// 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(authInfo.fee!.gasLimit).toEqual(BigInt(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

@ -26,7 +26,6 @@ import { SignMode } from "cosmjs-types/cosmos/tx/signing/v1beta1/signing";
import { TxRaw } from "cosmjs-types/cosmos/tx/v1beta1/tx"; import { TxRaw } from "cosmjs-types/cosmos/tx/v1beta1/tx";
import { MsgTransfer } from "cosmjs-types/ibc/applications/transfer/v1/tx"; import { MsgTransfer } from "cosmjs-types/ibc/applications/transfer/v1/tx";
import { Height } from "cosmjs-types/ibc/core/client/v1/client"; import { Height } from "cosmjs-types/ibc/core/client/v1/client";
import Long from "long";
import { AminoConverters, AminoTypes } from "./aminotypes"; import { AminoConverters, AminoTypes } from "./aminotypes";
import { calculateFee, GasPrice } from "./fee"; import { calculateFee, GasPrice } from "./fee";
@ -291,7 +290,7 @@ export class SigningStargateClient extends StargateClient {
memo = "", memo = "",
): Promise<DeliverTxResponse> { ): Promise<DeliverTxResponse> {
const timeoutTimestampNanoseconds = timeoutTimestamp const timeoutTimestampNanoseconds = timeoutTimestamp
? Long.fromNumber(timeoutTimestamp).multiply(1_000_000_000) ? BigInt(timeoutTimestamp) * BigInt(1_000_000_000)
: undefined; : undefined;
const transferMsg: MsgTransferEncodeObject = { const transferMsg: MsgTransferEncodeObject = {
typeUrl: "/ibc.applications.transfer.v1.MsgTransfer", typeUrl: "/ibc.applications.transfer.v1.MsgTransfer",

View File

@ -9,6 +9,7 @@ import {
DirectSignResponse, DirectSignResponse,
makeAuthInfoBytes, makeAuthInfoBytes,
} from "@cosmjs/proto-signing"; } from "@cosmjs/proto-signing";
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";
@ -230,10 +231,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: 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

@ -358,7 +358,7 @@ __metadata:
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
eslint: ^7.5 eslint: ^7.5
eslint-config-prettier: ^8.3.0 eslint-config-prettier: ^8.3.0
@ -404,7 +404,7 @@ __metadata:
"@types/pako": ^1.0.1 "@types/pako": ^1.0.1
"@typescript-eslint/eslint-plugin": ^5.54.0 "@typescript-eslint/eslint-plugin": ^5.54.0
"@typescript-eslint/parser": ^5.54.0 "@typescript-eslint/parser": ^5.54.0
cosmjs-types: ^0.8.0 cosmjs-types: ^0.9.0
eslint: ^7.5 eslint: ^7.5
eslint-config-prettier: ^8.3.0 eslint-config-prettier: ^8.3.0
eslint-import-resolver-node: ^0.3.4 eslint-import-resolver-node: ^0.3.4
@ -420,11 +420,9 @@ __metadata:
karma-firefox-launcher: ^2.1.0 karma-firefox-launcher: ^2.1.0
karma-jasmine: ^5 karma-jasmine: ^5
karma-jasmine-html-reporter: ^1.5.4 karma-jasmine-html-reporter: ^1.5.4
long: ^4.0.0
nyc: ^15.1.0 nyc: ^15.1.0
pako: ^2.0.2 pako: ^2.0.2
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
@ -763,7 +761,7 @@ __metadata:
"@types/node": ^18 "@types/node": ^18
"@typescript-eslint/eslint-plugin": ^5.54.0 "@typescript-eslint/eslint-plugin": ^5.54.0
"@typescript-eslint/parser": ^5.54.0 "@typescript-eslint/parser": ^5.54.0
cosmjs-types: ^0.8.0 cosmjs-types: ^0.9.0
eslint: ^7.5 eslint: ^7.5
eslint-config-prettier: ^8.3.0 eslint-config-prettier: ^8.3.0
eslint-import-resolver-node: ^0.3.4 eslint-import-resolver-node: ^0.3.4
@ -779,7 +777,6 @@ __metadata:
karma-firefox-launcher: ^2.1.0 karma-firefox-launcher: ^2.1.0
karma-jasmine: ^5 karma-jasmine: ^5
karma-jasmine-html-reporter: ^1.5.4 karma-jasmine-html-reporter: ^1.5.4
long: ^4.0.0
nyc: ^15.1.0 nyc: ^15.1.0
prettier: ^2.8.1 prettier: ^2.8.1
protobufjs: ~6.11.4 protobufjs: ~6.11.4
@ -860,7 +857,7 @@ __metadata:
"@types/node": ^18 "@types/node": ^18
"@typescript-eslint/eslint-plugin": ^5.54.0 "@typescript-eslint/eslint-plugin": ^5.54.0
"@typescript-eslint/parser": ^5.54.0 "@typescript-eslint/parser": ^5.54.0
cosmjs-types: ^0.8.0 cosmjs-types: ^0.9.0
eslint: ^7.5 eslint: ^7.5
eslint-config-prettier: ^8.3.0 eslint-config-prettier: ^8.3.0
eslint-import-resolver-node: ^0.3.4 eslint-import-resolver-node: ^0.3.4
@ -876,10 +873,8 @@ __metadata:
karma-firefox-launcher: ^2.1.0 karma-firefox-launcher: ^2.1.0
karma-jasmine: ^5 karma-jasmine: ^5
karma-jasmine-html-reporter: ^1.5.4 karma-jasmine-html-reporter: ^1.5.4
long: ^4.0.0
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
@ -3079,13 +3074,10 @@ __metadata:
languageName: unknown languageName: unknown
linkType: soft linkType: soft
"cosmjs-types@npm:^0.8.0": "cosmjs-types@npm:^0.9.0":
version: 0.8.0 version: 0.9.0
resolution: "cosmjs-types@npm:0.8.0" resolution: "cosmjs-types@npm:0.9.0"
dependencies: checksum: 9b00d169eca334f27418bb80b39e0cff0196af40b0079e1f85536246059279207b853bdb6ec224ead0a02d15d4b7f6bf16bc096d41c436426aa5f8976ed2b430
long: ^4.0.0
protobufjs: ~6.11.2
checksum: 99714ec956d2cb2e521d39896c9c9a24cf9df0d370265c203646ea015b51e86472efc0cb11f67a80f0649d178b0bcff77ac659e67fdfc8b2437cd7a42018577f
languageName: node languageName: node
linkType: hard linkType: hard
@ -6368,7 +6360,7 @@ __metadata:
languageName: node languageName: node
linkType: hard linkType: hard
"protobufjs@npm:^6.8.8, protobufjs@npm:~6.11.2, protobufjs@npm:~6.11.4": "protobufjs@npm:^6.8.8, protobufjs@npm:~6.11.4":
version: 6.11.4 version: 6.11.4
resolution: "protobufjs@npm:6.11.4" resolution: "protobufjs@npm:6.11.4"
dependencies: dependencies: