Merge pull request #616 from cosmos/586-ts-proto-spike
Investigate ts-proto
This commit is contained in:
commit
dfe39c034e
@ -5,7 +5,9 @@ workflows:
|
||||
# Keep those job names in sync with .mergify.yml
|
||||
jobs:
|
||||
- build
|
||||
- docs-build
|
||||
- docs-build:
|
||||
requires:
|
||||
- build
|
||||
- docs-deploy:
|
||||
requires:
|
||||
- docs-build
|
||||
@ -14,7 +16,9 @@ workflows:
|
||||
filters:
|
||||
branches:
|
||||
only: main
|
||||
- lint
|
||||
- lint:
|
||||
requires:
|
||||
- build
|
||||
- test:
|
||||
requires:
|
||||
- build
|
||||
@ -534,6 +538,11 @@ jobs:
|
||||
name: Install Git Large File Storage (LFS)
|
||||
command: sudo apt-get install git-lfs
|
||||
- checkout
|
||||
- attach_workspace:
|
||||
at: /tmp/builds
|
||||
- run:
|
||||
name: Merge build folders into project (merge with hardlinks)
|
||||
command: cp --recursive --link /tmp/builds/* .
|
||||
- run:
|
||||
name: Version information
|
||||
command: echo "node $(node --version)"; echo "yarn $(yarn --version)"
|
||||
@ -584,6 +593,11 @@ jobs:
|
||||
- image: circleci/node:10-buster
|
||||
steps:
|
||||
- checkout
|
||||
- attach_workspace:
|
||||
at: /tmp/builds
|
||||
- run:
|
||||
name: Merge build folders into project (merge with hardlinks)
|
||||
command: cp --recursive --link /tmp/builds/* .
|
||||
- run:
|
||||
name: Install shfmt
|
||||
command: |
|
||||
|
||||
@ -60,6 +60,7 @@
|
||||
"ses": "^0.11.0",
|
||||
"shx": "^0.3.2",
|
||||
"source-map-support": "^0.5.19",
|
||||
"ts-proto": "^1.53.0",
|
||||
"typedoc": "^0.19",
|
||||
"typescript": "~4.0",
|
||||
"webpack": "^4.43.0",
|
||||
|
||||
@ -96,9 +96,10 @@ export class Cw3CosmWasmClient extends SigningCosmWasmClient {
|
||||
return this.queryContractSmart(this.cw3ContractAddress, { proposal: { proposal_id: proposalId } });
|
||||
}
|
||||
|
||||
public listProposals({ startAfter, limit }: StartAfterNumberPaginationOptions = {}): Promise<
|
||||
ProposalsResult
|
||||
> {
|
||||
public listProposals({
|
||||
startAfter,
|
||||
limit,
|
||||
}: StartAfterNumberPaginationOptions = {}): Promise<ProposalsResult> {
|
||||
return this.queryContractSmart(this.cw3ContractAddress, {
|
||||
list_proposals: {
|
||||
start_after: startAfter,
|
||||
@ -107,9 +108,10 @@ export class Cw3CosmWasmClient extends SigningCosmWasmClient {
|
||||
});
|
||||
}
|
||||
|
||||
public reverseProposals({ startBefore, limit }: StartBeforeNumberPaginationOptions = {}): Promise<
|
||||
ProposalsResult
|
||||
> {
|
||||
public reverseProposals({
|
||||
startBefore,
|
||||
limit,
|
||||
}: StartBeforeNumberPaginationOptions = {}): Promise<ProposalsResult> {
|
||||
return this.queryContractSmart(this.cw3ContractAddress, {
|
||||
reverse_proposals: {
|
||||
start_before: startBefore,
|
||||
|
||||
@ -31,8 +31,8 @@
|
||||
"move-types": "shx rm -rf ./types/* && shx mv build/types/* ./types && rm -rf ./types/testdata ./types/*.spec.d.ts ./types/*/*.spec.d.ts",
|
||||
"format-types": "prettier --write --loglevel warn \"./types/**/*.d.ts\"",
|
||||
"prebuild": "shx rm -rf ./build",
|
||||
"build": "tsc && shx mkdir -p build/codec/generated && shx cp ./src/codec/generated/*.js ./build/codec/generated",
|
||||
"postbuild": "shx mkdir -p ./build/types/codec/generated && shx cp ./src/codec/generated/*.d.ts ./build/types/codec/generated && yarn move-types && yarn format-types",
|
||||
"build": "tsc && shx cp -R ./src/codec ./build/ && shx mkdir -p ./build/types/codec && shx cp -R ./src/codec ./build/types/",
|
||||
"postbuild": "yarn move-types && yarn format-types",
|
||||
"build-or-skip": "[ -n \"$SKIP_BUILD\" ] || yarn build",
|
||||
"test-node": "node jasmine-testrunner.js",
|
||||
"test-firefox": "yarn pack-web && karma start --single-run --browsers Firefox",
|
||||
@ -42,9 +42,8 @@
|
||||
"pack-web": "yarn build-or-skip && webpack --mode development --config webpack.web.config.js",
|
||||
"preget-proto": "shx rm -rf proto",
|
||||
"get-proto": "WASM_REF=v0.14.0 COSMOS_REF=v0.40.0 ./scripts/get-proto.sh",
|
||||
"predefine-proto": "./scripts/predefine-proto.sh",
|
||||
"define-proto": "./scripts/define-proto.sh",
|
||||
"postdefine-proto": "prettier --write \"src/codec/generated/codecimpl.*\""
|
||||
"postdefine-proto": "prettier --write \"src/codec/**/*.ts\""
|
||||
},
|
||||
"dependencies": {
|
||||
"@cosmjs/cosmwasm-launchpad": "^0.24.0-alpha.22",
|
||||
|
||||
@ -2,15 +2,28 @@
|
||||
set -o errexit -o nounset -o pipefail
|
||||
command -v shellcheck >/dev/null && shellcheck "$0"
|
||||
|
||||
TMP_DIR="./tmp"
|
||||
JS_SOURCE_FILE="$TMP_DIR/codecimpl.js"
|
||||
DEFINITIONS_FILE="$TMP_DIR/codecimpl.d.ts"
|
||||
OUTPUT_DIR="./src/codec/generated/"
|
||||
ROOT_PROTO_DIR="./proto"
|
||||
COSMOS_PROTO_DIR="$ROOT_PROTO_DIR/cosmos/cosmos-sdk/proto"
|
||||
THIRD_PARTY_PROTO_DIR="$ROOT_PROTO_DIR/cosmos/cosmos-sdk/third_party/proto"
|
||||
WASMD_PROTO_DIR="$ROOT_PROTO_DIR/cosmwasm/wasmd"
|
||||
OUT_DIR="./src/codec/"
|
||||
|
||||
yarn pbts "$JS_SOURCE_FILE" -o "$DEFINITIONS_FILE"
|
||||
# Remove comments after using them for the .d.ts
|
||||
# Note "When input files are specified on the command line, tsconfig.json files are ignored." (https://www.typescriptlang.org/docs/handbook/tsconfig-json.html)
|
||||
yarn tsc --removeComments --target es2017 --module commonjs --outDir "$OUTPUT_DIR" --allowJs "$JS_SOURCE_FILE"
|
||||
mkdir -p "$OUT_DIR"
|
||||
|
||||
cp "$DEFINITIONS_FILE" "$OUTPUT_DIR"
|
||||
rm "$DEFINITIONS_FILE" "$JS_SOURCE_FILE"
|
||||
protoc \
|
||||
--plugin="$(yarn bin protoc-gen-ts_proto)" \
|
||||
--ts_proto_out="$OUT_DIR" \
|
||||
--proto_path="$COSMOS_PROTO_DIR" \
|
||||
--proto_path="$THIRD_PARTY_PROTO_DIR" \
|
||||
--proto_path="$WASMD_PROTO_DIR" \
|
||||
--ts_proto_opt="esModuleInterop=true,forceLong=long,useOptionals=true" \
|
||||
"$WASMD_PROTO_DIR/x/wasm/internal/types/types.proto" \
|
||||
"$WASMD_PROTO_DIR/x/wasm/internal/types/query.proto" \
|
||||
"$WASMD_PROTO_DIR/x/wasm/internal/types/tx.proto" \
|
||||
"$COSMOS_PROTO_DIR/cosmos/base/v1beta1/coin.proto" \
|
||||
"$COSMOS_PROTO_DIR/cosmos/base/query/v1beta1/pagination.proto"
|
||||
|
||||
# Remove unnecessary codec files
|
||||
rm -rf \
|
||||
src/codec/gogoproto/ \
|
||||
src/codec/google/
|
||||
|
||||
@ -1,30 +0,0 @@
|
||||
#!/bin/bash
|
||||
set -o errexit -o nounset -o pipefail
|
||||
command -v shellcheck >/dev/null && shellcheck "$0"
|
||||
|
||||
GENERATED_DIR="./tmp"
|
||||
ROOT_PROTO_DIR="./proto"
|
||||
WASM_PROTO_DIR="$ROOT_PROTO_DIR/cosmwasm/wasmd/x/wasm"
|
||||
COSMOS_PROTO_DIR="$ROOT_PROTO_DIR/cosmos/cosmos-sdk/proto/cosmos"
|
||||
|
||||
mkdir -p "$GENERATED_DIR"
|
||||
# Can't use --sparse for some reason. Seems related to https://github.com/protobufjs/protobuf.js/issues/1165
|
||||
yarn pbjs \
|
||||
-t static-module \
|
||||
--es6 \
|
||||
-w commonjs \
|
||||
-o "$GENERATED_DIR/codecimpl.js" \
|
||||
--no-beautify \
|
||||
--no-delimited \
|
||||
--no-verify \
|
||||
--no-convert \
|
||||
--force-long \
|
||||
"$WASM_PROTO_DIR/internal/types/query.proto" \
|
||||
"$WASM_PROTO_DIR/internal/types/tx.proto" \
|
||||
"$WASM_PROTO_DIR/internal/types/types.proto" \
|
||||
"$COSMOS_PROTO_DIR/base/v1beta1/coin.proto" \
|
||||
"$COSMOS_PROTO_DIR/base/query/v1beta1/pagination.proto"
|
||||
|
||||
# Work around https://github.com/protobufjs/protobuf.js/issues/1477
|
||||
# shellcheck disable=SC2016
|
||||
sed -i "" -e 's/^const \$root =.*$/const \$root = {};/' "$GENERATED_DIR/codecimpl.js"
|
||||
@ -1,11 +1,11 @@
|
||||
/* eslint-disable @typescript-eslint/naming-convention */
|
||||
import {
|
||||
MsgClearAdmin,
|
||||
MsgExecuteContract,
|
||||
MsgInstantiateContract,
|
||||
MsgMigrateContract,
|
||||
MsgStoreCode,
|
||||
MsgUpdateAdmin,
|
||||
MsgClearAdmin as LaunchpadMsgClearAdmin,
|
||||
MsgExecuteContract as LaunchpadMsgExecuteContract,
|
||||
MsgInstantiateContract as LaunchpadMsgInstantiateContract,
|
||||
MsgMigrateContract as LaunchpadMsgMigrateContract,
|
||||
MsgStoreCode as LaunchpadMsgStoreCode,
|
||||
MsgUpdateAdmin as LaunchpadMsgUpdateAdmin,
|
||||
} from "@cosmjs/cosmwasm-launchpad";
|
||||
import { fromBase64, toUtf8 } from "@cosmjs/encoding";
|
||||
import { coins } from "@cosmjs/launchpad";
|
||||
@ -13,29 +13,30 @@ import { AminoTypes } from "@cosmjs/stargate";
|
||||
import Long from "long";
|
||||
|
||||
import { cosmWasmTypes } from "./aminotypes";
|
||||
import { cosmwasm } from "./codec";
|
||||
|
||||
type IMsgStoreCode = cosmwasm.wasm.v1beta1.IMsgStoreCode;
|
||||
type IMsgInstantiateContract = cosmwasm.wasm.v1beta1.IMsgInstantiateContract;
|
||||
type IMsgUpdateAdmin = cosmwasm.wasm.v1beta1.IMsgUpdateAdmin;
|
||||
type IMsgClearAdmin = cosmwasm.wasm.v1beta1.IMsgClearAdmin;
|
||||
type IMsgExecuteContract = cosmwasm.wasm.v1beta1.IMsgExecuteContract;
|
||||
type IMsgMigrateContract = cosmwasm.wasm.v1beta1.IMsgMigrateContract;
|
||||
import {
|
||||
MsgClearAdmin,
|
||||
MsgExecuteContract,
|
||||
MsgInstantiateContract,
|
||||
MsgMigrateContract,
|
||||
MsgStoreCode,
|
||||
MsgUpdateAdmin,
|
||||
} from "./codec/x/wasm/internal/types/tx";
|
||||
|
||||
describe("AminoTypes", () => {
|
||||
describe("toAmino", () => {
|
||||
it("works for MsgStoreCode", () => {
|
||||
const msg: IMsgStoreCode = {
|
||||
const msg: MsgStoreCode = {
|
||||
sender: "cosmos1pkptre7fdkl6gfrzlesjjvhxhlc3r4gmmk8rs6",
|
||||
wasmByteCode: fromBase64("WUVMTE9XIFNVQk1BUklORQ=="),
|
||||
source: "Arrabiata",
|
||||
builder: "Bob",
|
||||
instantiatePermission: undefined,
|
||||
};
|
||||
const aminoMsg = new AminoTypes({ additions: cosmWasmTypes }).toAmino({
|
||||
typeUrl: "/cosmwasm.wasm.v1beta1.MsgStoreCode",
|
||||
value: msg,
|
||||
});
|
||||
const expected: MsgStoreCode = {
|
||||
const expected: LaunchpadMsgStoreCode = {
|
||||
type: "wasm/MsgStoreCode",
|
||||
value: {
|
||||
sender: "cosmos1pkptre7fdkl6gfrzlesjjvhxhlc3r4gmmk8rs6",
|
||||
@ -48,7 +49,7 @@ describe("AminoTypes", () => {
|
||||
});
|
||||
|
||||
it("works for MsgInstantiateContract", () => {
|
||||
const msg: IMsgInstantiateContract = {
|
||||
const msg: MsgInstantiateContract = {
|
||||
sender: "cosmos1pkptre7fdkl6gfrzlesjjvhxhlc3r4gmmk8rs6",
|
||||
codeId: Long.fromString("12345"),
|
||||
label: "sticky",
|
||||
@ -64,7 +65,7 @@ describe("AminoTypes", () => {
|
||||
typeUrl: "/cosmwasm.wasm.v1beta1.MsgInstantiateContract",
|
||||
value: msg,
|
||||
});
|
||||
const expected: MsgInstantiateContract = {
|
||||
const expected: LaunchpadMsgInstantiateContract = {
|
||||
type: "wasm/MsgInstantiateContract",
|
||||
value: {
|
||||
sender: "cosmos1pkptre7fdkl6gfrzlesjjvhxhlc3r4gmmk8rs6",
|
||||
@ -81,7 +82,7 @@ describe("AminoTypes", () => {
|
||||
});
|
||||
|
||||
it("works for MsgUpdateAdmin", () => {
|
||||
const msg: IMsgUpdateAdmin = {
|
||||
const msg: MsgUpdateAdmin = {
|
||||
sender: "cosmos1pkptre7fdkl6gfrzlesjjvhxhlc3r4gmmk8rs6",
|
||||
newAdmin: "cosmos10dyr9899g6t0pelew4nvf4j5c3jcgv0r73qga5",
|
||||
contract: "cosmos1xy4yqngt0nlkdcenxymg8tenrghmek4nmqm28k",
|
||||
@ -90,7 +91,7 @@ describe("AminoTypes", () => {
|
||||
typeUrl: "/cosmwasm.wasm.v1beta1.MsgUpdateAdmin",
|
||||
value: msg,
|
||||
});
|
||||
const expected: MsgUpdateAdmin = {
|
||||
const expected: LaunchpadMsgUpdateAdmin = {
|
||||
type: "wasm/MsgUpdateAdmin",
|
||||
value: {
|
||||
sender: "cosmos1pkptre7fdkl6gfrzlesjjvhxhlc3r4gmmk8rs6",
|
||||
@ -102,7 +103,7 @@ describe("AminoTypes", () => {
|
||||
});
|
||||
|
||||
it("works for MsgClearAdmin", () => {
|
||||
const msg: IMsgClearAdmin = {
|
||||
const msg: MsgClearAdmin = {
|
||||
sender: "cosmos1pkptre7fdkl6gfrzlesjjvhxhlc3r4gmmk8rs6",
|
||||
contract: "cosmos1xy4yqngt0nlkdcenxymg8tenrghmek4nmqm28k",
|
||||
};
|
||||
@ -110,7 +111,7 @@ describe("AminoTypes", () => {
|
||||
typeUrl: "/cosmwasm.wasm.v1beta1.MsgClearAdmin",
|
||||
value: msg,
|
||||
});
|
||||
const expected: MsgClearAdmin = {
|
||||
const expected: LaunchpadMsgClearAdmin = {
|
||||
type: "wasm/MsgClearAdmin",
|
||||
value: {
|
||||
sender: "cosmos1pkptre7fdkl6gfrzlesjjvhxhlc3r4gmmk8rs6",
|
||||
@ -121,7 +122,7 @@ describe("AminoTypes", () => {
|
||||
});
|
||||
|
||||
it("works for MsgExecuteContract", () => {
|
||||
const msg: IMsgExecuteContract = {
|
||||
const msg: MsgExecuteContract = {
|
||||
sender: "cosmos1pkptre7fdkl6gfrzlesjjvhxhlc3r4gmmk8rs6",
|
||||
contract: "cosmos1xy4yqngt0nlkdcenxymg8tenrghmek4nmqm28k",
|
||||
msg: toUtf8(
|
||||
@ -135,7 +136,7 @@ describe("AminoTypes", () => {
|
||||
typeUrl: "/cosmwasm.wasm.v1beta1.MsgExecuteContract",
|
||||
value: msg,
|
||||
});
|
||||
const expected: MsgExecuteContract = {
|
||||
const expected: LaunchpadMsgExecuteContract = {
|
||||
type: "wasm/MsgExecuteContract",
|
||||
value: {
|
||||
sender: "cosmos1pkptre7fdkl6gfrzlesjjvhxhlc3r4gmmk8rs6",
|
||||
@ -150,7 +151,7 @@ describe("AminoTypes", () => {
|
||||
});
|
||||
|
||||
it("works for MsgMigrateContract", () => {
|
||||
const msg: IMsgMigrateContract = {
|
||||
const msg: MsgMigrateContract = {
|
||||
sender: "cosmos1pkptre7fdkl6gfrzlesjjvhxhlc3r4gmmk8rs6",
|
||||
contract: "cosmos1xy4yqngt0nlkdcenxymg8tenrghmek4nmqm28k",
|
||||
codeId: Long.fromString("98765"),
|
||||
@ -164,7 +165,7 @@ describe("AminoTypes", () => {
|
||||
typeUrl: "/cosmwasm.wasm.v1beta1.MsgMigrateContract",
|
||||
value: msg,
|
||||
});
|
||||
const expected: MsgMigrateContract = {
|
||||
const expected: LaunchpadMsgMigrateContract = {
|
||||
type: "wasm/MsgMigrateContract",
|
||||
value: {
|
||||
sender: "cosmos1pkptre7fdkl6gfrzlesjjvhxhlc3r4gmmk8rs6",
|
||||
@ -181,7 +182,7 @@ describe("AminoTypes", () => {
|
||||
|
||||
describe("fromAmino", () => {
|
||||
it("works for MsgStoreCode", () => {
|
||||
const aminoMsg: MsgStoreCode = {
|
||||
const aminoMsg: LaunchpadMsgStoreCode = {
|
||||
type: "wasm/MsgStoreCode",
|
||||
value: {
|
||||
sender: "cosmos1pkptre7fdkl6gfrzlesjjvhxhlc3r4gmmk8rs6",
|
||||
@ -191,11 +192,12 @@ describe("AminoTypes", () => {
|
||||
},
|
||||
};
|
||||
const msg = new AminoTypes({ additions: cosmWasmTypes }).fromAmino(aminoMsg);
|
||||
const expectedValue: IMsgStoreCode = {
|
||||
const expectedValue: MsgStoreCode = {
|
||||
sender: "cosmos1pkptre7fdkl6gfrzlesjjvhxhlc3r4gmmk8rs6",
|
||||
wasmByteCode: fromBase64("WUVMTE9XIFNVQk1BUklORQ=="),
|
||||
source: "Arrabiata",
|
||||
builder: "Bob",
|
||||
instantiatePermission: undefined,
|
||||
};
|
||||
expect(msg).toEqual({
|
||||
typeUrl: "/cosmwasm.wasm.v1beta1.MsgStoreCode",
|
||||
@ -204,7 +206,7 @@ describe("AminoTypes", () => {
|
||||
});
|
||||
|
||||
it("works for MsgInstantiateContract", () => {
|
||||
const aminoMsg: MsgInstantiateContract = {
|
||||
const aminoMsg: LaunchpadMsgInstantiateContract = {
|
||||
type: "wasm/MsgInstantiateContract",
|
||||
value: {
|
||||
sender: "cosmos1pkptre7fdkl6gfrzlesjjvhxhlc3r4gmmk8rs6",
|
||||
@ -218,7 +220,7 @@ describe("AminoTypes", () => {
|
||||
},
|
||||
};
|
||||
const msg = new AminoTypes({ additions: cosmWasmTypes }).fromAmino(aminoMsg);
|
||||
const expectedValue: IMsgInstantiateContract = {
|
||||
const expectedValue: MsgInstantiateContract = {
|
||||
sender: "cosmos1pkptre7fdkl6gfrzlesjjvhxhlc3r4gmmk8rs6",
|
||||
codeId: Long.fromString("12345"),
|
||||
label: "sticky",
|
||||
@ -237,7 +239,7 @@ describe("AminoTypes", () => {
|
||||
});
|
||||
|
||||
it("works for MsgUpdateAdmin", () => {
|
||||
const aminoMsg: MsgUpdateAdmin = {
|
||||
const aminoMsg: LaunchpadMsgUpdateAdmin = {
|
||||
type: "wasm/MsgUpdateAdmin",
|
||||
value: {
|
||||
sender: "cosmos1pkptre7fdkl6gfrzlesjjvhxhlc3r4gmmk8rs6",
|
||||
@ -246,7 +248,7 @@ describe("AminoTypes", () => {
|
||||
},
|
||||
};
|
||||
const msg = new AminoTypes({ additions: cosmWasmTypes }).fromAmino(aminoMsg);
|
||||
const expectedValue: IMsgUpdateAdmin = {
|
||||
const expectedValue: MsgUpdateAdmin = {
|
||||
sender: "cosmos1pkptre7fdkl6gfrzlesjjvhxhlc3r4gmmk8rs6",
|
||||
newAdmin: "cosmos10dyr9899g6t0pelew4nvf4j5c3jcgv0r73qga5",
|
||||
contract: "cosmos1xy4yqngt0nlkdcenxymg8tenrghmek4nmqm28k",
|
||||
@ -258,7 +260,7 @@ describe("AminoTypes", () => {
|
||||
});
|
||||
|
||||
it("works for MsgClearAdmin", () => {
|
||||
const aminoMsg: MsgClearAdmin = {
|
||||
const aminoMsg: LaunchpadMsgClearAdmin = {
|
||||
type: "wasm/MsgClearAdmin",
|
||||
value: {
|
||||
sender: "cosmos1pkptre7fdkl6gfrzlesjjvhxhlc3r4gmmk8rs6",
|
||||
@ -266,7 +268,7 @@ describe("AminoTypes", () => {
|
||||
},
|
||||
};
|
||||
const msg = new AminoTypes({ additions: cosmWasmTypes }).fromAmino(aminoMsg);
|
||||
const expectedValue: IMsgClearAdmin = {
|
||||
const expectedValue: MsgClearAdmin = {
|
||||
sender: "cosmos1pkptre7fdkl6gfrzlesjjvhxhlc3r4gmmk8rs6",
|
||||
contract: "cosmos1xy4yqngt0nlkdcenxymg8tenrghmek4nmqm28k",
|
||||
};
|
||||
@ -277,7 +279,7 @@ describe("AminoTypes", () => {
|
||||
});
|
||||
|
||||
it("works for MsgExecuteContract", () => {
|
||||
const aminoMsg: MsgExecuteContract = {
|
||||
const aminoMsg: LaunchpadMsgExecuteContract = {
|
||||
type: "wasm/MsgExecuteContract",
|
||||
value: {
|
||||
sender: "cosmos1pkptre7fdkl6gfrzlesjjvhxhlc3r4gmmk8rs6",
|
||||
@ -289,7 +291,7 @@ describe("AminoTypes", () => {
|
||||
},
|
||||
};
|
||||
const msg = new AminoTypes({ additions: cosmWasmTypes }).fromAmino(aminoMsg);
|
||||
const expectedValue: IMsgExecuteContract = {
|
||||
const expectedValue: MsgExecuteContract = {
|
||||
sender: "cosmos1pkptre7fdkl6gfrzlesjjvhxhlc3r4gmmk8rs6",
|
||||
contract: "cosmos1xy4yqngt0nlkdcenxymg8tenrghmek4nmqm28k",
|
||||
msg: toUtf8(
|
||||
@ -306,7 +308,7 @@ describe("AminoTypes", () => {
|
||||
});
|
||||
|
||||
it("works for MsgMigrateContract", () => {
|
||||
const aminoMsg: MsgMigrateContract = {
|
||||
const aminoMsg: LaunchpadMsgMigrateContract = {
|
||||
type: "wasm/MsgMigrateContract",
|
||||
value: {
|
||||
sender: "cosmos1pkptre7fdkl6gfrzlesjjvhxhlc3r4gmmk8rs6",
|
||||
@ -318,7 +320,7 @@ describe("AminoTypes", () => {
|
||||
},
|
||||
};
|
||||
const msg = new AminoTypes({ additions: cosmWasmTypes }).fromAmino(aminoMsg);
|
||||
const expectedValue: IMsgMigrateContract = {
|
||||
const expectedValue: MsgMigrateContract = {
|
||||
sender: "cosmos1pkptre7fdkl6gfrzlesjjvhxhlc3r4gmmk8rs6",
|
||||
contract: "cosmos1xy4yqngt0nlkdcenxymg8tenrghmek4nmqm28k",
|
||||
codeId: Long.fromString("98765"),
|
||||
|
||||
@ -1,4 +1,17 @@
|
||||
/* eslint-disable @typescript-eslint/naming-convention */
|
||||
import {
|
||||
MsgClearAdmin as LaunchpadMsgClearAdmin,
|
||||
MsgExecuteContract as LaunchpadMsgExecuteContract,
|
||||
MsgInstantiateContract as LaunchpadMsgInstantiateContract,
|
||||
MsgMigrateContract as LaunchpadMsgMigrateContract,
|
||||
MsgStoreCode as LaunchpadMsgStoreCode,
|
||||
MsgUpdateAdmin as LaunchpadMsgUpdateAdmin,
|
||||
} from "@cosmjs/cosmwasm-launchpad";
|
||||
import { fromBase64, fromUtf8, toBase64, toUtf8 } from "@cosmjs/encoding";
|
||||
import { AminoConverter, coinFromProto } from "@cosmjs/stargate";
|
||||
import { assertDefinedAndNotNull } from "@cosmjs/utils";
|
||||
import Long from "long";
|
||||
|
||||
import {
|
||||
MsgClearAdmin,
|
||||
MsgExecuteContract,
|
||||
@ -6,25 +19,12 @@ import {
|
||||
MsgMigrateContract,
|
||||
MsgStoreCode,
|
||||
MsgUpdateAdmin,
|
||||
} from "@cosmjs/cosmwasm-launchpad";
|
||||
import { fromBase64, fromUtf8, toBase64, toUtf8 } from "@cosmjs/encoding";
|
||||
import { AminoConverter, coinFromProto } from "@cosmjs/stargate";
|
||||
import { assertDefinedAndNotNull } from "@cosmjs/utils";
|
||||
import Long from "long";
|
||||
|
||||
import { cosmwasm } from "./codec";
|
||||
|
||||
type IMsgStoreCode = cosmwasm.wasm.v1beta1.IMsgStoreCode;
|
||||
type IMsgInstantiateContract = cosmwasm.wasm.v1beta1.IMsgInstantiateContract;
|
||||
type IMsgUpdateAdmin = cosmwasm.wasm.v1beta1.IMsgUpdateAdmin;
|
||||
type IMsgClearAdmin = cosmwasm.wasm.v1beta1.IMsgClearAdmin;
|
||||
type IMsgExecuteContract = cosmwasm.wasm.v1beta1.IMsgExecuteContract;
|
||||
type IMsgMigrateContract = cosmwasm.wasm.v1beta1.IMsgMigrateContract;
|
||||
} from "./codec/x/wasm/internal/types/tx";
|
||||
|
||||
export const cosmWasmTypes: Record<string, AminoConverter> = {
|
||||
"/cosmwasm.wasm.v1beta1.MsgStoreCode": {
|
||||
aminoType: "wasm/MsgStoreCode",
|
||||
toAmino: ({ sender, wasmByteCode, source, builder }: IMsgStoreCode): MsgStoreCode["value"] => {
|
||||
toAmino: ({ sender, wasmByteCode, source, builder }: MsgStoreCode): LaunchpadMsgStoreCode["value"] => {
|
||||
assertDefinedAndNotNull(sender, "missing sender");
|
||||
assertDefinedAndNotNull(wasmByteCode, "missing wasmByteCode");
|
||||
assertDefinedAndNotNull(source, "missing source");
|
||||
@ -36,11 +36,17 @@ export const cosmWasmTypes: Record<string, AminoConverter> = {
|
||||
builder: builder,
|
||||
};
|
||||
},
|
||||
fromAmino: ({ sender, wasm_byte_code, source, builder }: MsgStoreCode["value"]): IMsgStoreCode => ({
|
||||
fromAmino: ({
|
||||
sender,
|
||||
wasm_byte_code,
|
||||
source,
|
||||
builder,
|
||||
}: LaunchpadMsgStoreCode["value"]): MsgStoreCode => ({
|
||||
sender: sender,
|
||||
wasmByteCode: fromBase64(wasm_byte_code),
|
||||
source: source,
|
||||
builder: builder,
|
||||
instantiatePermission: undefined,
|
||||
}),
|
||||
},
|
||||
"/cosmwasm.wasm.v1beta1.MsgInstantiateContract": {
|
||||
@ -52,7 +58,7 @@ export const cosmWasmTypes: Record<string, AminoConverter> = {
|
||||
initMsg,
|
||||
initFunds,
|
||||
admin,
|
||||
}: IMsgInstantiateContract): MsgInstantiateContract["value"] => {
|
||||
}: MsgInstantiateContract): LaunchpadMsgInstantiateContract["value"] => {
|
||||
assertDefinedAndNotNull(sender, "missing sender");
|
||||
assertDefinedAndNotNull(codeId, "missing codeId");
|
||||
assertDefinedAndNotNull(label, "missing label");
|
||||
@ -74,18 +80,18 @@ export const cosmWasmTypes: Record<string, AminoConverter> = {
|
||||
init_msg,
|
||||
init_funds,
|
||||
admin,
|
||||
}: MsgInstantiateContract["value"]): IMsgInstantiateContract => ({
|
||||
}: LaunchpadMsgInstantiateContract["value"]): MsgInstantiateContract => ({
|
||||
sender: sender,
|
||||
codeId: Long.fromString(code_id),
|
||||
label: label,
|
||||
initMsg: toUtf8(JSON.stringify(init_msg)),
|
||||
initFunds: [...init_funds],
|
||||
admin: admin,
|
||||
admin: admin ?? "",
|
||||
}),
|
||||
},
|
||||
"/cosmwasm.wasm.v1beta1.MsgUpdateAdmin": {
|
||||
aminoType: "wasm/MsgUpdateAdmin",
|
||||
toAmino: ({ sender, newAdmin, contract }: IMsgUpdateAdmin): MsgUpdateAdmin["value"] => {
|
||||
toAmino: ({ sender, newAdmin, contract }: MsgUpdateAdmin): LaunchpadMsgUpdateAdmin["value"] => {
|
||||
assertDefinedAndNotNull(sender, "missing sender");
|
||||
assertDefinedAndNotNull(newAdmin, "missing newAdmin");
|
||||
assertDefinedAndNotNull(contract, "missing contract");
|
||||
@ -95,7 +101,7 @@ export const cosmWasmTypes: Record<string, AminoConverter> = {
|
||||
contract: contract,
|
||||
};
|
||||
},
|
||||
fromAmino: ({ sender, new_admin, contract }: MsgUpdateAdmin["value"]): IMsgUpdateAdmin => ({
|
||||
fromAmino: ({ sender, new_admin, contract }: LaunchpadMsgUpdateAdmin["value"]): MsgUpdateAdmin => ({
|
||||
sender: sender,
|
||||
newAdmin: new_admin,
|
||||
contract: contract,
|
||||
@ -103,7 +109,7 @@ export const cosmWasmTypes: Record<string, AminoConverter> = {
|
||||
},
|
||||
"/cosmwasm.wasm.v1beta1.MsgClearAdmin": {
|
||||
aminoType: "wasm/MsgClearAdmin",
|
||||
toAmino: ({ sender, contract }: IMsgClearAdmin): MsgClearAdmin["value"] => {
|
||||
toAmino: ({ sender, contract }: MsgClearAdmin): LaunchpadMsgClearAdmin["value"] => {
|
||||
assertDefinedAndNotNull(sender, "missing sender");
|
||||
assertDefinedAndNotNull(contract, "missing contract");
|
||||
return {
|
||||
@ -111,14 +117,19 @@ export const cosmWasmTypes: Record<string, AminoConverter> = {
|
||||
contract: contract,
|
||||
};
|
||||
},
|
||||
fromAmino: ({ sender, contract }: MsgClearAdmin["value"]): IMsgClearAdmin => ({
|
||||
fromAmino: ({ sender, contract }: LaunchpadMsgClearAdmin["value"]): MsgClearAdmin => ({
|
||||
sender: sender,
|
||||
contract: contract,
|
||||
}),
|
||||
},
|
||||
"/cosmwasm.wasm.v1beta1.MsgExecuteContract": {
|
||||
aminoType: "wasm/MsgExecuteContract",
|
||||
toAmino: ({ sender, contract, msg, sentFunds }: IMsgExecuteContract): MsgExecuteContract["value"] => {
|
||||
toAmino: ({
|
||||
sender,
|
||||
contract,
|
||||
msg,
|
||||
sentFunds,
|
||||
}: MsgExecuteContract): LaunchpadMsgExecuteContract["value"] => {
|
||||
assertDefinedAndNotNull(sender, "missing sender");
|
||||
assertDefinedAndNotNull(contract, "missing contract");
|
||||
assertDefinedAndNotNull(msg, "missing msg");
|
||||
@ -130,7 +141,12 @@ export const cosmWasmTypes: Record<string, AminoConverter> = {
|
||||
sent_funds: sentFunds.map(coinFromProto),
|
||||
};
|
||||
},
|
||||
fromAmino: ({ sender, contract, msg, sent_funds }: MsgExecuteContract["value"]): IMsgExecuteContract => ({
|
||||
fromAmino: ({
|
||||
sender,
|
||||
contract,
|
||||
msg,
|
||||
sent_funds,
|
||||
}: LaunchpadMsgExecuteContract["value"]): MsgExecuteContract => ({
|
||||
sender: sender,
|
||||
contract: contract,
|
||||
msg: toUtf8(JSON.stringify(msg)),
|
||||
@ -139,7 +155,12 @@ export const cosmWasmTypes: Record<string, AminoConverter> = {
|
||||
},
|
||||
"/cosmwasm.wasm.v1beta1.MsgMigrateContract": {
|
||||
aminoType: "wasm/MsgMigrateContract",
|
||||
toAmino: ({ sender, contract, codeId, migrateMsg }: IMsgMigrateContract): MsgMigrateContract["value"] => {
|
||||
toAmino: ({
|
||||
sender,
|
||||
contract,
|
||||
codeId,
|
||||
migrateMsg,
|
||||
}: MsgMigrateContract): LaunchpadMsgMigrateContract["value"] => {
|
||||
assertDefinedAndNotNull(sender, "missing sender");
|
||||
assertDefinedAndNotNull(contract, "missing contract");
|
||||
assertDefinedAndNotNull(codeId, "missing codeId");
|
||||
@ -151,7 +172,12 @@ export const cosmWasmTypes: Record<string, AminoConverter> = {
|
||||
msg: JSON.parse(fromUtf8(migrateMsg)),
|
||||
};
|
||||
},
|
||||
fromAmino: ({ sender, contract, code_id, msg }: MsgMigrateContract["value"]): IMsgMigrateContract => ({
|
||||
fromAmino: ({
|
||||
sender,
|
||||
contract,
|
||||
code_id,
|
||||
msg,
|
||||
}: LaunchpadMsgMigrateContract["value"]): MsgMigrateContract => ({
|
||||
sender: sender,
|
||||
contract: contract,
|
||||
codeId: Long.fromString(code_id),
|
||||
|
||||
@ -0,0 +1,269 @@
|
||||
/* eslint-disable */
|
||||
import Long from "long";
|
||||
import _m0 from "protobufjs/minimal";
|
||||
|
||||
export const protobufPackage = "cosmos.base.query.v1beta1";
|
||||
|
||||
/**
|
||||
* PageRequest is to be embedded in gRPC request messages for efficient
|
||||
* pagination. Ex:
|
||||
*
|
||||
* message SomeRequest {
|
||||
* Foo some_parameter = 1;
|
||||
* PageRequest pagination = 2;
|
||||
* }
|
||||
*/
|
||||
export interface PageRequest {
|
||||
/**
|
||||
* key is a value returned in PageResponse.next_key to begin
|
||||
* querying the next page most efficiently. Only one of offset or key
|
||||
* should be set.
|
||||
*/
|
||||
key: Uint8Array;
|
||||
/**
|
||||
* offset is a numeric offset that can be used when key is unavailable.
|
||||
* It is less efficient than using key. Only one of offset or key should
|
||||
* be set.
|
||||
*/
|
||||
offset: Long;
|
||||
/**
|
||||
* limit is the total number of results to be returned in the result page.
|
||||
* If left empty it will default to a value to be set by each app.
|
||||
*/
|
||||
limit: Long;
|
||||
/**
|
||||
* count_total is set to true to indicate that the result set should include
|
||||
* a count of the total number of items available for pagination in UIs.
|
||||
* count_total is only respected when offset is used. It is ignored when key
|
||||
* is set.
|
||||
*/
|
||||
countTotal: boolean;
|
||||
}
|
||||
|
||||
/**
|
||||
* PageResponse is to be embedded in gRPC response messages where the
|
||||
* corresponding request message has used PageRequest.
|
||||
*
|
||||
* message SomeResponse {
|
||||
* repeated Bar results = 1;
|
||||
* PageResponse page = 2;
|
||||
* }
|
||||
*/
|
||||
export interface PageResponse {
|
||||
/**
|
||||
* next_key is the key to be passed to PageRequest.key to
|
||||
* query the next page most efficiently
|
||||
*/
|
||||
nextKey: Uint8Array;
|
||||
/**
|
||||
* total is total number of results available if PageRequest.count_total
|
||||
* was set, its value is undefined otherwise
|
||||
*/
|
||||
total: Long;
|
||||
}
|
||||
|
||||
const basePageRequest: object = { offset: Long.UZERO, limit: Long.UZERO, countTotal: false };
|
||||
|
||||
export const PageRequest = {
|
||||
encode(message: PageRequest, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer {
|
||||
writer.uint32(10).bytes(message.key);
|
||||
writer.uint32(16).uint64(message.offset);
|
||||
writer.uint32(24).uint64(message.limit);
|
||||
writer.uint32(32).bool(message.countTotal);
|
||||
return writer;
|
||||
},
|
||||
|
||||
decode(input: _m0.Reader | Uint8Array, length?: number): PageRequest {
|
||||
const reader = input instanceof Uint8Array ? new _m0.Reader(input) : input;
|
||||
let end = length === undefined ? reader.len : reader.pos + length;
|
||||
const message = { ...basePageRequest } as PageRequest;
|
||||
while (reader.pos < end) {
|
||||
const tag = reader.uint32();
|
||||
switch (tag >>> 3) {
|
||||
case 1:
|
||||
message.key = reader.bytes();
|
||||
break;
|
||||
case 2:
|
||||
message.offset = reader.uint64() as Long;
|
||||
break;
|
||||
case 3:
|
||||
message.limit = reader.uint64() as Long;
|
||||
break;
|
||||
case 4:
|
||||
message.countTotal = reader.bool();
|
||||
break;
|
||||
default:
|
||||
reader.skipType(tag & 7);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return message;
|
||||
},
|
||||
|
||||
fromJSON(object: any): PageRequest {
|
||||
const message = { ...basePageRequest } as PageRequest;
|
||||
if (object.key !== undefined && object.key !== null) {
|
||||
message.key = bytesFromBase64(object.key);
|
||||
}
|
||||
if (object.offset !== undefined && object.offset !== null) {
|
||||
message.offset = Long.fromString(object.offset);
|
||||
} else {
|
||||
message.offset = Long.UZERO;
|
||||
}
|
||||
if (object.limit !== undefined && object.limit !== null) {
|
||||
message.limit = Long.fromString(object.limit);
|
||||
} else {
|
||||
message.limit = Long.UZERO;
|
||||
}
|
||||
if (object.countTotal !== undefined && object.countTotal !== null) {
|
||||
message.countTotal = Boolean(object.countTotal);
|
||||
} else {
|
||||
message.countTotal = false;
|
||||
}
|
||||
return message;
|
||||
},
|
||||
|
||||
fromPartial(object: DeepPartial<PageRequest>): PageRequest {
|
||||
const message = { ...basePageRequest } as PageRequest;
|
||||
if (object.key !== undefined && object.key !== null) {
|
||||
message.key = object.key;
|
||||
} else {
|
||||
message.key = new Uint8Array();
|
||||
}
|
||||
if (object.offset !== undefined && object.offset !== null) {
|
||||
message.offset = object.offset as Long;
|
||||
} else {
|
||||
message.offset = Long.UZERO;
|
||||
}
|
||||
if (object.limit !== undefined && object.limit !== null) {
|
||||
message.limit = object.limit as Long;
|
||||
} else {
|
||||
message.limit = Long.UZERO;
|
||||
}
|
||||
if (object.countTotal !== undefined && object.countTotal !== null) {
|
||||
message.countTotal = object.countTotal;
|
||||
} else {
|
||||
message.countTotal = false;
|
||||
}
|
||||
return message;
|
||||
},
|
||||
|
||||
toJSON(message: PageRequest): unknown {
|
||||
const obj: any = {};
|
||||
message.key !== undefined &&
|
||||
(obj.key = base64FromBytes(message.key !== undefined ? message.key : new Uint8Array()));
|
||||
message.offset !== undefined && (obj.offset = (message.offset || Long.UZERO).toString());
|
||||
message.limit !== undefined && (obj.limit = (message.limit || Long.UZERO).toString());
|
||||
message.countTotal !== undefined && (obj.countTotal = message.countTotal);
|
||||
return obj;
|
||||
},
|
||||
};
|
||||
|
||||
const basePageResponse: object = { total: Long.UZERO };
|
||||
|
||||
export const PageResponse = {
|
||||
encode(message: PageResponse, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer {
|
||||
writer.uint32(10).bytes(message.nextKey);
|
||||
writer.uint32(16).uint64(message.total);
|
||||
return writer;
|
||||
},
|
||||
|
||||
decode(input: _m0.Reader | Uint8Array, length?: number): PageResponse {
|
||||
const reader = input instanceof Uint8Array ? new _m0.Reader(input) : input;
|
||||
let end = length === undefined ? reader.len : reader.pos + length;
|
||||
const message = { ...basePageResponse } as PageResponse;
|
||||
while (reader.pos < end) {
|
||||
const tag = reader.uint32();
|
||||
switch (tag >>> 3) {
|
||||
case 1:
|
||||
message.nextKey = reader.bytes();
|
||||
break;
|
||||
case 2:
|
||||
message.total = reader.uint64() as Long;
|
||||
break;
|
||||
default:
|
||||
reader.skipType(tag & 7);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return message;
|
||||
},
|
||||
|
||||
fromJSON(object: any): PageResponse {
|
||||
const message = { ...basePageResponse } as PageResponse;
|
||||
if (object.nextKey !== undefined && object.nextKey !== null) {
|
||||
message.nextKey = bytesFromBase64(object.nextKey);
|
||||
}
|
||||
if (object.total !== undefined && object.total !== null) {
|
||||
message.total = Long.fromString(object.total);
|
||||
} else {
|
||||
message.total = Long.UZERO;
|
||||
}
|
||||
return message;
|
||||
},
|
||||
|
||||
fromPartial(object: DeepPartial<PageResponse>): PageResponse {
|
||||
const message = { ...basePageResponse } as PageResponse;
|
||||
if (object.nextKey !== undefined && object.nextKey !== null) {
|
||||
message.nextKey = object.nextKey;
|
||||
} else {
|
||||
message.nextKey = new Uint8Array();
|
||||
}
|
||||
if (object.total !== undefined && object.total !== null) {
|
||||
message.total = object.total as Long;
|
||||
} else {
|
||||
message.total = Long.UZERO;
|
||||
}
|
||||
return message;
|
||||
},
|
||||
|
||||
toJSON(message: PageResponse): unknown {
|
||||
const obj: any = {};
|
||||
message.nextKey !== undefined &&
|
||||
(obj.nextKey = base64FromBytes(message.nextKey !== undefined ? message.nextKey : new Uint8Array()));
|
||||
message.total !== undefined && (obj.total = (message.total || Long.UZERO).toString());
|
||||
return obj;
|
||||
},
|
||||
};
|
||||
|
||||
declare var self: any | undefined;
|
||||
declare var window: any | undefined;
|
||||
var globalThis: any = (() => {
|
||||
if (typeof globalThis !== "undefined") return globalThis;
|
||||
if (typeof self !== "undefined") return self;
|
||||
if (typeof window !== "undefined") return window;
|
||||
if (typeof global !== "undefined") return global;
|
||||
throw new Error("Unable to locate global object");
|
||||
})();
|
||||
|
||||
const atob: (b64: string) => string =
|
||||
globalThis.atob || ((b64) => globalThis.Buffer.from(b64, "base64").toString("binary"));
|
||||
function bytesFromBase64(b64: string): Uint8Array {
|
||||
const bin = atob(b64);
|
||||
const arr = new Uint8Array(bin.length);
|
||||
for (let i = 0; i < bin.length; ++i) {
|
||||
arr[i] = bin.charCodeAt(i);
|
||||
}
|
||||
return arr;
|
||||
}
|
||||
|
||||
const btoa: (bin: string) => string =
|
||||
globalThis.btoa || ((bin) => globalThis.Buffer.from(bin, "binary").toString("base64"));
|
||||
function base64FromBytes(arr: Uint8Array): string {
|
||||
const bin: string[] = [];
|
||||
for (let i = 0; i < arr.byteLength; ++i) {
|
||||
bin.push(String.fromCharCode(arr[i]));
|
||||
}
|
||||
return btoa(bin.join(""));
|
||||
}
|
||||
|
||||
type Builtin = Date | Function | Uint8Array | string | number | undefined | Long;
|
||||
export type DeepPartial<T> = T extends Builtin
|
||||
? T
|
||||
: T extends Array<infer U>
|
||||
? Array<DeepPartial<U>>
|
||||
: T extends ReadonlyArray<infer U>
|
||||
? ReadonlyArray<DeepPartial<U>>
|
||||
: T extends {}
|
||||
? { [K in keyof T]?: DeepPartial<T[K]> }
|
||||
: Partial<T>;
|
||||
290
packages/cosmwasm-stargate/src/codec/cosmos/base/v1beta1/coin.ts
Normal file
290
packages/cosmwasm-stargate/src/codec/cosmos/base/v1beta1/coin.ts
Normal file
@ -0,0 +1,290 @@
|
||||
/* eslint-disable */
|
||||
import Long from "long";
|
||||
import _m0 from "protobufjs/minimal";
|
||||
|
||||
export const protobufPackage = "cosmos.base.v1beta1";
|
||||
|
||||
/**
|
||||
* Coin defines a token with a denomination and an amount.
|
||||
*
|
||||
* NOTE: The amount field is an Int which implements the custom method
|
||||
* signatures required by gogoproto.
|
||||
*/
|
||||
export interface Coin {
|
||||
denom: string;
|
||||
amount: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* DecCoin defines a token with a denomination and a decimal amount.
|
||||
*
|
||||
* NOTE: The amount field is an Dec which implements the custom method
|
||||
* signatures required by gogoproto.
|
||||
*/
|
||||
export interface DecCoin {
|
||||
denom: string;
|
||||
amount: string;
|
||||
}
|
||||
|
||||
/** IntProto defines a Protobuf wrapper around an Int object. */
|
||||
export interface IntProto {
|
||||
int: string;
|
||||
}
|
||||
|
||||
/** DecProto defines a Protobuf wrapper around a Dec object. */
|
||||
export interface DecProto {
|
||||
dec: string;
|
||||
}
|
||||
|
||||
const baseCoin: object = { denom: "", amount: "" };
|
||||
|
||||
export const Coin = {
|
||||
encode(message: Coin, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer {
|
||||
writer.uint32(10).string(message.denom);
|
||||
writer.uint32(18).string(message.amount);
|
||||
return writer;
|
||||
},
|
||||
|
||||
decode(input: _m0.Reader | Uint8Array, length?: number): Coin {
|
||||
const reader = input instanceof Uint8Array ? new _m0.Reader(input) : input;
|
||||
let end = length === undefined ? reader.len : reader.pos + length;
|
||||
const message = { ...baseCoin } as Coin;
|
||||
while (reader.pos < end) {
|
||||
const tag = reader.uint32();
|
||||
switch (tag >>> 3) {
|
||||
case 1:
|
||||
message.denom = reader.string();
|
||||
break;
|
||||
case 2:
|
||||
message.amount = reader.string();
|
||||
break;
|
||||
default:
|
||||
reader.skipType(tag & 7);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return message;
|
||||
},
|
||||
|
||||
fromJSON(object: any): Coin {
|
||||
const message = { ...baseCoin } as Coin;
|
||||
if (object.denom !== undefined && object.denom !== null) {
|
||||
message.denom = String(object.denom);
|
||||
} else {
|
||||
message.denom = "";
|
||||
}
|
||||
if (object.amount !== undefined && object.amount !== null) {
|
||||
message.amount = String(object.amount);
|
||||
} else {
|
||||
message.amount = "";
|
||||
}
|
||||
return message;
|
||||
},
|
||||
|
||||
fromPartial(object: DeepPartial<Coin>): Coin {
|
||||
const message = { ...baseCoin } as Coin;
|
||||
if (object.denom !== undefined && object.denom !== null) {
|
||||
message.denom = object.denom;
|
||||
} else {
|
||||
message.denom = "";
|
||||
}
|
||||
if (object.amount !== undefined && object.amount !== null) {
|
||||
message.amount = object.amount;
|
||||
} else {
|
||||
message.amount = "";
|
||||
}
|
||||
return message;
|
||||
},
|
||||
|
||||
toJSON(message: Coin): unknown {
|
||||
const obj: any = {};
|
||||
message.denom !== undefined && (obj.denom = message.denom);
|
||||
message.amount !== undefined && (obj.amount = message.amount);
|
||||
return obj;
|
||||
},
|
||||
};
|
||||
|
||||
const baseDecCoin: object = { denom: "", amount: "" };
|
||||
|
||||
export const DecCoin = {
|
||||
encode(message: DecCoin, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer {
|
||||
writer.uint32(10).string(message.denom);
|
||||
writer.uint32(18).string(message.amount);
|
||||
return writer;
|
||||
},
|
||||
|
||||
decode(input: _m0.Reader | Uint8Array, length?: number): DecCoin {
|
||||
const reader = input instanceof Uint8Array ? new _m0.Reader(input) : input;
|
||||
let end = length === undefined ? reader.len : reader.pos + length;
|
||||
const message = { ...baseDecCoin } as DecCoin;
|
||||
while (reader.pos < end) {
|
||||
const tag = reader.uint32();
|
||||
switch (tag >>> 3) {
|
||||
case 1:
|
||||
message.denom = reader.string();
|
||||
break;
|
||||
case 2:
|
||||
message.amount = reader.string();
|
||||
break;
|
||||
default:
|
||||
reader.skipType(tag & 7);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return message;
|
||||
},
|
||||
|
||||
fromJSON(object: any): DecCoin {
|
||||
const message = { ...baseDecCoin } as DecCoin;
|
||||
if (object.denom !== undefined && object.denom !== null) {
|
||||
message.denom = String(object.denom);
|
||||
} else {
|
||||
message.denom = "";
|
||||
}
|
||||
if (object.amount !== undefined && object.amount !== null) {
|
||||
message.amount = String(object.amount);
|
||||
} else {
|
||||
message.amount = "";
|
||||
}
|
||||
return message;
|
||||
},
|
||||
|
||||
fromPartial(object: DeepPartial<DecCoin>): DecCoin {
|
||||
const message = { ...baseDecCoin } as DecCoin;
|
||||
if (object.denom !== undefined && object.denom !== null) {
|
||||
message.denom = object.denom;
|
||||
} else {
|
||||
message.denom = "";
|
||||
}
|
||||
if (object.amount !== undefined && object.amount !== null) {
|
||||
message.amount = object.amount;
|
||||
} else {
|
||||
message.amount = "";
|
||||
}
|
||||
return message;
|
||||
},
|
||||
|
||||
toJSON(message: DecCoin): unknown {
|
||||
const obj: any = {};
|
||||
message.denom !== undefined && (obj.denom = message.denom);
|
||||
message.amount !== undefined && (obj.amount = message.amount);
|
||||
return obj;
|
||||
},
|
||||
};
|
||||
|
||||
const baseIntProto: object = { int: "" };
|
||||
|
||||
export const IntProto = {
|
||||
encode(message: IntProto, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer {
|
||||
writer.uint32(10).string(message.int);
|
||||
return writer;
|
||||
},
|
||||
|
||||
decode(input: _m0.Reader | Uint8Array, length?: number): IntProto {
|
||||
const reader = input instanceof Uint8Array ? new _m0.Reader(input) : input;
|
||||
let end = length === undefined ? reader.len : reader.pos + length;
|
||||
const message = { ...baseIntProto } as IntProto;
|
||||
while (reader.pos < end) {
|
||||
const tag = reader.uint32();
|
||||
switch (tag >>> 3) {
|
||||
case 1:
|
||||
message.int = reader.string();
|
||||
break;
|
||||
default:
|
||||
reader.skipType(tag & 7);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return message;
|
||||
},
|
||||
|
||||
fromJSON(object: any): IntProto {
|
||||
const message = { ...baseIntProto } as IntProto;
|
||||
if (object.int !== undefined && object.int !== null) {
|
||||
message.int = String(object.int);
|
||||
} else {
|
||||
message.int = "";
|
||||
}
|
||||
return message;
|
||||
},
|
||||
|
||||
fromPartial(object: DeepPartial<IntProto>): IntProto {
|
||||
const message = { ...baseIntProto } as IntProto;
|
||||
if (object.int !== undefined && object.int !== null) {
|
||||
message.int = object.int;
|
||||
} else {
|
||||
message.int = "";
|
||||
}
|
||||
return message;
|
||||
},
|
||||
|
||||
toJSON(message: IntProto): unknown {
|
||||
const obj: any = {};
|
||||
message.int !== undefined && (obj.int = message.int);
|
||||
return obj;
|
||||
},
|
||||
};
|
||||
|
||||
const baseDecProto: object = { dec: "" };
|
||||
|
||||
export const DecProto = {
|
||||
encode(message: DecProto, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer {
|
||||
writer.uint32(10).string(message.dec);
|
||||
return writer;
|
||||
},
|
||||
|
||||
decode(input: _m0.Reader | Uint8Array, length?: number): DecProto {
|
||||
const reader = input instanceof Uint8Array ? new _m0.Reader(input) : input;
|
||||
let end = length === undefined ? reader.len : reader.pos + length;
|
||||
const message = { ...baseDecProto } as DecProto;
|
||||
while (reader.pos < end) {
|
||||
const tag = reader.uint32();
|
||||
switch (tag >>> 3) {
|
||||
case 1:
|
||||
message.dec = reader.string();
|
||||
break;
|
||||
default:
|
||||
reader.skipType(tag & 7);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return message;
|
||||
},
|
||||
|
||||
fromJSON(object: any): DecProto {
|
||||
const message = { ...baseDecProto } as DecProto;
|
||||
if (object.dec !== undefined && object.dec !== null) {
|
||||
message.dec = String(object.dec);
|
||||
} else {
|
||||
message.dec = "";
|
||||
}
|
||||
return message;
|
||||
},
|
||||
|
||||
fromPartial(object: DeepPartial<DecProto>): DecProto {
|
||||
const message = { ...baseDecProto } as DecProto;
|
||||
if (object.dec !== undefined && object.dec !== null) {
|
||||
message.dec = object.dec;
|
||||
} else {
|
||||
message.dec = "";
|
||||
}
|
||||
return message;
|
||||
},
|
||||
|
||||
toJSON(message: DecProto): unknown {
|
||||
const obj: any = {};
|
||||
message.dec !== undefined && (obj.dec = message.dec);
|
||||
return obj;
|
||||
},
|
||||
};
|
||||
|
||||
type Builtin = Date | Function | Uint8Array | string | number | undefined | Long;
|
||||
export type DeepPartial<T> = T extends Builtin
|
||||
? T
|
||||
: T extends Array<infer U>
|
||||
? Array<DeepPartial<U>>
|
||||
: T extends ReadonlyArray<infer U>
|
||||
? ReadonlyArray<DeepPartial<U>>
|
||||
: T extends {}
|
||||
? { [K in keyof T]?: DeepPartial<T[K]> }
|
||||
: Partial<T>;
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -1,9 +0,0 @@
|
||||
import Long from "long";
|
||||
import protobuf from "protobufjs/minimal";
|
||||
|
||||
// Ensure the protobuf module has a Long implementation, which otherwise only works
|
||||
// in Node.js (see https://github.com/protobufjs/protobuf.js/issues/921#issuecomment-334925145)
|
||||
protobuf.util.Long = Long;
|
||||
protobuf.configure();
|
||||
|
||||
export { cosmwasm } from "./generated/codecimpl";
|
||||
1516
packages/cosmwasm-stargate/src/codec/x/wasm/internal/types/query.ts
Normal file
1516
packages/cosmwasm-stargate/src/codec/x/wasm/internal/types/query.ts
Normal file
File diff suppressed because it is too large
Load Diff
1113
packages/cosmwasm-stargate/src/codec/x/wasm/internal/types/tx.ts
Normal file
1113
packages/cosmwasm-stargate/src/codec/x/wasm/internal/types/tx.ts
Normal file
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,899 @@
|
||||
/* eslint-disable */
|
||||
import Long from "long";
|
||||
import _m0 from "protobufjs/minimal";
|
||||
|
||||
export const protobufPackage = "cosmwasm.wasm.v1beta1";
|
||||
|
||||
/** AccessType permission types */
|
||||
export enum AccessType {
|
||||
/** ACCESS_TYPE_UNSPECIFIED - AccessTypeUnspecified placeholder for empty value */
|
||||
ACCESS_TYPE_UNSPECIFIED = 0,
|
||||
/** ACCESS_TYPE_NOBODY - AccessTypeNobody forbidden */
|
||||
ACCESS_TYPE_NOBODY = 1,
|
||||
/** ACCESS_TYPE_ONLY_ADDRESS - AccessTypeOnlyAddress restricted to an address */
|
||||
ACCESS_TYPE_ONLY_ADDRESS = 2,
|
||||
/** ACCESS_TYPE_EVERYBODY - AccessTypeEverybody unrestricted */
|
||||
ACCESS_TYPE_EVERYBODY = 3,
|
||||
UNRECOGNIZED = -1,
|
||||
}
|
||||
|
||||
export function accessTypeFromJSON(object: any): AccessType {
|
||||
switch (object) {
|
||||
case 0:
|
||||
case "ACCESS_TYPE_UNSPECIFIED":
|
||||
return AccessType.ACCESS_TYPE_UNSPECIFIED;
|
||||
case 1:
|
||||
case "ACCESS_TYPE_NOBODY":
|
||||
return AccessType.ACCESS_TYPE_NOBODY;
|
||||
case 2:
|
||||
case "ACCESS_TYPE_ONLY_ADDRESS":
|
||||
return AccessType.ACCESS_TYPE_ONLY_ADDRESS;
|
||||
case 3:
|
||||
case "ACCESS_TYPE_EVERYBODY":
|
||||
return AccessType.ACCESS_TYPE_EVERYBODY;
|
||||
case -1:
|
||||
case "UNRECOGNIZED":
|
||||
default:
|
||||
return AccessType.UNRECOGNIZED;
|
||||
}
|
||||
}
|
||||
|
||||
export function accessTypeToJSON(object: AccessType): string {
|
||||
switch (object) {
|
||||
case AccessType.ACCESS_TYPE_UNSPECIFIED:
|
||||
return "ACCESS_TYPE_UNSPECIFIED";
|
||||
case AccessType.ACCESS_TYPE_NOBODY:
|
||||
return "ACCESS_TYPE_NOBODY";
|
||||
case AccessType.ACCESS_TYPE_ONLY_ADDRESS:
|
||||
return "ACCESS_TYPE_ONLY_ADDRESS";
|
||||
case AccessType.ACCESS_TYPE_EVERYBODY:
|
||||
return "ACCESS_TYPE_EVERYBODY";
|
||||
default:
|
||||
return "UNKNOWN";
|
||||
}
|
||||
}
|
||||
|
||||
/** ContractCodeHistoryOperationType actions that caused a code change */
|
||||
export enum ContractCodeHistoryOperationType {
|
||||
/** CONTRACT_CODE_HISTORY_OPERATION_TYPE_UNSPECIFIED - ContractCodeHistoryOperationTypeUnspecified placeholder for empty value */
|
||||
CONTRACT_CODE_HISTORY_OPERATION_TYPE_UNSPECIFIED = 0,
|
||||
/** CONTRACT_CODE_HISTORY_OPERATION_TYPE_INIT - ContractCodeHistoryOperationTypeInit on chain contract instantiation */
|
||||
CONTRACT_CODE_HISTORY_OPERATION_TYPE_INIT = 1,
|
||||
/** CONTRACT_CODE_HISTORY_OPERATION_TYPE_MIGRATE - ContractCodeHistoryOperationTypeMigrate code migration */
|
||||
CONTRACT_CODE_HISTORY_OPERATION_TYPE_MIGRATE = 2,
|
||||
/** CONTRACT_CODE_HISTORY_OPERATION_TYPE_GENESIS - ContractCodeHistoryOperationTypeGenesis based on genesis data */
|
||||
CONTRACT_CODE_HISTORY_OPERATION_TYPE_GENESIS = 3,
|
||||
UNRECOGNIZED = -1,
|
||||
}
|
||||
|
||||
export function contractCodeHistoryOperationTypeFromJSON(object: any): ContractCodeHistoryOperationType {
|
||||
switch (object) {
|
||||
case 0:
|
||||
case "CONTRACT_CODE_HISTORY_OPERATION_TYPE_UNSPECIFIED":
|
||||
return ContractCodeHistoryOperationType.CONTRACT_CODE_HISTORY_OPERATION_TYPE_UNSPECIFIED;
|
||||
case 1:
|
||||
case "CONTRACT_CODE_HISTORY_OPERATION_TYPE_INIT":
|
||||
return ContractCodeHistoryOperationType.CONTRACT_CODE_HISTORY_OPERATION_TYPE_INIT;
|
||||
case 2:
|
||||
case "CONTRACT_CODE_HISTORY_OPERATION_TYPE_MIGRATE":
|
||||
return ContractCodeHistoryOperationType.CONTRACT_CODE_HISTORY_OPERATION_TYPE_MIGRATE;
|
||||
case 3:
|
||||
case "CONTRACT_CODE_HISTORY_OPERATION_TYPE_GENESIS":
|
||||
return ContractCodeHistoryOperationType.CONTRACT_CODE_HISTORY_OPERATION_TYPE_GENESIS;
|
||||
case -1:
|
||||
case "UNRECOGNIZED":
|
||||
default:
|
||||
return ContractCodeHistoryOperationType.UNRECOGNIZED;
|
||||
}
|
||||
}
|
||||
|
||||
export function contractCodeHistoryOperationTypeToJSON(object: ContractCodeHistoryOperationType): string {
|
||||
switch (object) {
|
||||
case ContractCodeHistoryOperationType.CONTRACT_CODE_HISTORY_OPERATION_TYPE_UNSPECIFIED:
|
||||
return "CONTRACT_CODE_HISTORY_OPERATION_TYPE_UNSPECIFIED";
|
||||
case ContractCodeHistoryOperationType.CONTRACT_CODE_HISTORY_OPERATION_TYPE_INIT:
|
||||
return "CONTRACT_CODE_HISTORY_OPERATION_TYPE_INIT";
|
||||
case ContractCodeHistoryOperationType.CONTRACT_CODE_HISTORY_OPERATION_TYPE_MIGRATE:
|
||||
return "CONTRACT_CODE_HISTORY_OPERATION_TYPE_MIGRATE";
|
||||
case ContractCodeHistoryOperationType.CONTRACT_CODE_HISTORY_OPERATION_TYPE_GENESIS:
|
||||
return "CONTRACT_CODE_HISTORY_OPERATION_TYPE_GENESIS";
|
||||
default:
|
||||
return "UNKNOWN";
|
||||
}
|
||||
}
|
||||
|
||||
/** AccessTypeParam */
|
||||
export interface AccessTypeParam {
|
||||
value: AccessType;
|
||||
}
|
||||
|
||||
/** AccessConfig access control type. */
|
||||
export interface AccessConfig {
|
||||
permission: AccessType;
|
||||
address: string;
|
||||
}
|
||||
|
||||
/** Params defines the set of wasm parameters. */
|
||||
export interface Params {
|
||||
codeUploadAccess?: AccessConfig;
|
||||
instantiateDefaultPermission: AccessType;
|
||||
maxWasmCodeSize: Long;
|
||||
}
|
||||
|
||||
/** CodeInfo is data for the uploaded contract WASM code */
|
||||
export interface CodeInfo {
|
||||
/** CodeHash is the unique CodeID */
|
||||
codeHash: Uint8Array;
|
||||
/** Creator address who initially stored the code */
|
||||
creator: string;
|
||||
/** Source is a valid absolute HTTPS URI to the contract's source code, optional */
|
||||
source: string;
|
||||
/** Builder is a valid docker image name with tag, optional */
|
||||
builder: string;
|
||||
/** InstantiateConfig access control to apply on contract creation, optional */
|
||||
instantiateConfig?: AccessConfig;
|
||||
}
|
||||
|
||||
/** ContractInfo stores a WASM contract instance */
|
||||
export interface ContractInfo {
|
||||
/** CodeID is the reference to the stored Wasm code */
|
||||
codeId: Long;
|
||||
/** Creator address who initially instantiated the contract */
|
||||
creator: string;
|
||||
/** Admin is an optional address that can execute migrations */
|
||||
admin: string;
|
||||
/** Label is optional metadata to be stored with a contract instance. */
|
||||
label: string;
|
||||
/**
|
||||
* Created Tx position when the contract was instantiated.
|
||||
* This data should kept internal and not be exposed via query results. Just use for sorting
|
||||
*/
|
||||
created?: AbsoluteTxPosition;
|
||||
}
|
||||
|
||||
/** ContractCodeHistoryEntry metadata to a contract. */
|
||||
export interface ContractCodeHistoryEntry {
|
||||
operation: ContractCodeHistoryOperationType;
|
||||
/** CodeID is the reference to the stored WASM code */
|
||||
codeId: Long;
|
||||
/** Updated Tx position when the operation was executed. */
|
||||
updated?: AbsoluteTxPosition;
|
||||
msg: Uint8Array;
|
||||
}
|
||||
|
||||
/** AbsoluteTxPosition is a unique transaction position that allows for global ordering of transactions. */
|
||||
export interface AbsoluteTxPosition {
|
||||
/** BlockHeight is the block the contract was created at */
|
||||
blockHeight: Long;
|
||||
/** TxIndex is a monotonic counter within the block (actual transaction index, or gas consumed) */
|
||||
txIndex: Long;
|
||||
}
|
||||
|
||||
/** Model is a struct that holds a KV pair */
|
||||
export interface Model {
|
||||
/** hex-encode key to read it better (this is often ascii) */
|
||||
key: Uint8Array;
|
||||
/** base64-encode raw value */
|
||||
value: Uint8Array;
|
||||
}
|
||||
|
||||
const baseAccessTypeParam: object = { value: 0 };
|
||||
|
||||
export const AccessTypeParam = {
|
||||
encode(message: AccessTypeParam, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer {
|
||||
writer.uint32(8).int32(message.value);
|
||||
return writer;
|
||||
},
|
||||
|
||||
decode(input: _m0.Reader | Uint8Array, length?: number): AccessTypeParam {
|
||||
const reader = input instanceof Uint8Array ? new _m0.Reader(input) : input;
|
||||
let end = length === undefined ? reader.len : reader.pos + length;
|
||||
const message = { ...baseAccessTypeParam } as AccessTypeParam;
|
||||
while (reader.pos < end) {
|
||||
const tag = reader.uint32();
|
||||
switch (tag >>> 3) {
|
||||
case 1:
|
||||
message.value = reader.int32() as any;
|
||||
break;
|
||||
default:
|
||||
reader.skipType(tag & 7);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return message;
|
||||
},
|
||||
|
||||
fromJSON(object: any): AccessTypeParam {
|
||||
const message = { ...baseAccessTypeParam } as AccessTypeParam;
|
||||
if (object.value !== undefined && object.value !== null) {
|
||||
message.value = accessTypeFromJSON(object.value);
|
||||
} else {
|
||||
message.value = 0;
|
||||
}
|
||||
return message;
|
||||
},
|
||||
|
||||
fromPartial(object: DeepPartial<AccessTypeParam>): AccessTypeParam {
|
||||
const message = { ...baseAccessTypeParam } as AccessTypeParam;
|
||||
if (object.value !== undefined && object.value !== null) {
|
||||
message.value = object.value;
|
||||
} else {
|
||||
message.value = 0;
|
||||
}
|
||||
return message;
|
||||
},
|
||||
|
||||
toJSON(message: AccessTypeParam): unknown {
|
||||
const obj: any = {};
|
||||
message.value !== undefined && (obj.value = accessTypeToJSON(message.value));
|
||||
return obj;
|
||||
},
|
||||
};
|
||||
|
||||
const baseAccessConfig: object = { permission: 0, address: "" };
|
||||
|
||||
export const AccessConfig = {
|
||||
encode(message: AccessConfig, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer {
|
||||
writer.uint32(8).int32(message.permission);
|
||||
writer.uint32(18).string(message.address);
|
||||
return writer;
|
||||
},
|
||||
|
||||
decode(input: _m0.Reader | Uint8Array, length?: number): AccessConfig {
|
||||
const reader = input instanceof Uint8Array ? new _m0.Reader(input) : input;
|
||||
let end = length === undefined ? reader.len : reader.pos + length;
|
||||
const message = { ...baseAccessConfig } as AccessConfig;
|
||||
while (reader.pos < end) {
|
||||
const tag = reader.uint32();
|
||||
switch (tag >>> 3) {
|
||||
case 1:
|
||||
message.permission = reader.int32() as any;
|
||||
break;
|
||||
case 2:
|
||||
message.address = reader.string();
|
||||
break;
|
||||
default:
|
||||
reader.skipType(tag & 7);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return message;
|
||||
},
|
||||
|
||||
fromJSON(object: any): AccessConfig {
|
||||
const message = { ...baseAccessConfig } as AccessConfig;
|
||||
if (object.permission !== undefined && object.permission !== null) {
|
||||
message.permission = accessTypeFromJSON(object.permission);
|
||||
} else {
|
||||
message.permission = 0;
|
||||
}
|
||||
if (object.address !== undefined && object.address !== null) {
|
||||
message.address = String(object.address);
|
||||
} else {
|
||||
message.address = "";
|
||||
}
|
||||
return message;
|
||||
},
|
||||
|
||||
fromPartial(object: DeepPartial<AccessConfig>): AccessConfig {
|
||||
const message = { ...baseAccessConfig } as AccessConfig;
|
||||
if (object.permission !== undefined && object.permission !== null) {
|
||||
message.permission = object.permission;
|
||||
} else {
|
||||
message.permission = 0;
|
||||
}
|
||||
if (object.address !== undefined && object.address !== null) {
|
||||
message.address = object.address;
|
||||
} else {
|
||||
message.address = "";
|
||||
}
|
||||
return message;
|
||||
},
|
||||
|
||||
toJSON(message: AccessConfig): unknown {
|
||||
const obj: any = {};
|
||||
message.permission !== undefined && (obj.permission = accessTypeToJSON(message.permission));
|
||||
message.address !== undefined && (obj.address = message.address);
|
||||
return obj;
|
||||
},
|
||||
};
|
||||
|
||||
const baseParams: object = { instantiateDefaultPermission: 0, maxWasmCodeSize: Long.UZERO };
|
||||
|
||||
export const Params = {
|
||||
encode(message: Params, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer {
|
||||
if (message.codeUploadAccess !== undefined && message.codeUploadAccess !== undefined) {
|
||||
AccessConfig.encode(message.codeUploadAccess, writer.uint32(10).fork()).ldelim();
|
||||
}
|
||||
writer.uint32(16).int32(message.instantiateDefaultPermission);
|
||||
writer.uint32(24).uint64(message.maxWasmCodeSize);
|
||||
return writer;
|
||||
},
|
||||
|
||||
decode(input: _m0.Reader | Uint8Array, length?: number): Params {
|
||||
const reader = input instanceof Uint8Array ? new _m0.Reader(input) : input;
|
||||
let end = length === undefined ? reader.len : reader.pos + length;
|
||||
const message = { ...baseParams } as Params;
|
||||
while (reader.pos < end) {
|
||||
const tag = reader.uint32();
|
||||
switch (tag >>> 3) {
|
||||
case 1:
|
||||
message.codeUploadAccess = AccessConfig.decode(reader, reader.uint32());
|
||||
break;
|
||||
case 2:
|
||||
message.instantiateDefaultPermission = reader.int32() as any;
|
||||
break;
|
||||
case 3:
|
||||
message.maxWasmCodeSize = reader.uint64() as Long;
|
||||
break;
|
||||
default:
|
||||
reader.skipType(tag & 7);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return message;
|
||||
},
|
||||
|
||||
fromJSON(object: any): Params {
|
||||
const message = { ...baseParams } as Params;
|
||||
if (object.codeUploadAccess !== undefined && object.codeUploadAccess !== null) {
|
||||
message.codeUploadAccess = AccessConfig.fromJSON(object.codeUploadAccess);
|
||||
} else {
|
||||
message.codeUploadAccess = undefined;
|
||||
}
|
||||
if (object.instantiateDefaultPermission !== undefined && object.instantiateDefaultPermission !== null) {
|
||||
message.instantiateDefaultPermission = accessTypeFromJSON(object.instantiateDefaultPermission);
|
||||
} else {
|
||||
message.instantiateDefaultPermission = 0;
|
||||
}
|
||||
if (object.maxWasmCodeSize !== undefined && object.maxWasmCodeSize !== null) {
|
||||
message.maxWasmCodeSize = Long.fromString(object.maxWasmCodeSize);
|
||||
} else {
|
||||
message.maxWasmCodeSize = Long.UZERO;
|
||||
}
|
||||
return message;
|
||||
},
|
||||
|
||||
fromPartial(object: DeepPartial<Params>): Params {
|
||||
const message = { ...baseParams } as Params;
|
||||
if (object.codeUploadAccess !== undefined && object.codeUploadAccess !== null) {
|
||||
message.codeUploadAccess = AccessConfig.fromPartial(object.codeUploadAccess);
|
||||
} else {
|
||||
message.codeUploadAccess = undefined;
|
||||
}
|
||||
if (object.instantiateDefaultPermission !== undefined && object.instantiateDefaultPermission !== null) {
|
||||
message.instantiateDefaultPermission = object.instantiateDefaultPermission;
|
||||
} else {
|
||||
message.instantiateDefaultPermission = 0;
|
||||
}
|
||||
if (object.maxWasmCodeSize !== undefined && object.maxWasmCodeSize !== null) {
|
||||
message.maxWasmCodeSize = object.maxWasmCodeSize as Long;
|
||||
} else {
|
||||
message.maxWasmCodeSize = Long.UZERO;
|
||||
}
|
||||
return message;
|
||||
},
|
||||
|
||||
toJSON(message: Params): unknown {
|
||||
const obj: any = {};
|
||||
message.codeUploadAccess !== undefined &&
|
||||
(obj.codeUploadAccess = message.codeUploadAccess
|
||||
? AccessConfig.toJSON(message.codeUploadAccess)
|
||||
: undefined);
|
||||
message.instantiateDefaultPermission !== undefined &&
|
||||
(obj.instantiateDefaultPermission = accessTypeToJSON(message.instantiateDefaultPermission));
|
||||
message.maxWasmCodeSize !== undefined &&
|
||||
(obj.maxWasmCodeSize = (message.maxWasmCodeSize || Long.UZERO).toString());
|
||||
return obj;
|
||||
},
|
||||
};
|
||||
|
||||
const baseCodeInfo: object = { creator: "", source: "", builder: "" };
|
||||
|
||||
export const CodeInfo = {
|
||||
encode(message: CodeInfo, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer {
|
||||
writer.uint32(10).bytes(message.codeHash);
|
||||
writer.uint32(18).string(message.creator);
|
||||
writer.uint32(26).string(message.source);
|
||||
writer.uint32(34).string(message.builder);
|
||||
if (message.instantiateConfig !== undefined && message.instantiateConfig !== undefined) {
|
||||
AccessConfig.encode(message.instantiateConfig, writer.uint32(42).fork()).ldelim();
|
||||
}
|
||||
return writer;
|
||||
},
|
||||
|
||||
decode(input: _m0.Reader | Uint8Array, length?: number): CodeInfo {
|
||||
const reader = input instanceof Uint8Array ? new _m0.Reader(input) : input;
|
||||
let end = length === undefined ? reader.len : reader.pos + length;
|
||||
const message = { ...baseCodeInfo } as CodeInfo;
|
||||
while (reader.pos < end) {
|
||||
const tag = reader.uint32();
|
||||
switch (tag >>> 3) {
|
||||
case 1:
|
||||
message.codeHash = reader.bytes();
|
||||
break;
|
||||
case 2:
|
||||
message.creator = reader.string();
|
||||
break;
|
||||
case 3:
|
||||
message.source = reader.string();
|
||||
break;
|
||||
case 4:
|
||||
message.builder = reader.string();
|
||||
break;
|
||||
case 5:
|
||||
message.instantiateConfig = AccessConfig.decode(reader, reader.uint32());
|
||||
break;
|
||||
default:
|
||||
reader.skipType(tag & 7);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return message;
|
||||
},
|
||||
|
||||
fromJSON(object: any): CodeInfo {
|
||||
const message = { ...baseCodeInfo } as CodeInfo;
|
||||
if (object.codeHash !== undefined && object.codeHash !== null) {
|
||||
message.codeHash = bytesFromBase64(object.codeHash);
|
||||
}
|
||||
if (object.creator !== undefined && object.creator !== null) {
|
||||
message.creator = String(object.creator);
|
||||
} else {
|
||||
message.creator = "";
|
||||
}
|
||||
if (object.source !== undefined && object.source !== null) {
|
||||
message.source = String(object.source);
|
||||
} else {
|
||||
message.source = "";
|
||||
}
|
||||
if (object.builder !== undefined && object.builder !== null) {
|
||||
message.builder = String(object.builder);
|
||||
} else {
|
||||
message.builder = "";
|
||||
}
|
||||
if (object.instantiateConfig !== undefined && object.instantiateConfig !== null) {
|
||||
message.instantiateConfig = AccessConfig.fromJSON(object.instantiateConfig);
|
||||
} else {
|
||||
message.instantiateConfig = undefined;
|
||||
}
|
||||
return message;
|
||||
},
|
||||
|
||||
fromPartial(object: DeepPartial<CodeInfo>): CodeInfo {
|
||||
const message = { ...baseCodeInfo } as CodeInfo;
|
||||
if (object.codeHash !== undefined && object.codeHash !== null) {
|
||||
message.codeHash = object.codeHash;
|
||||
} else {
|
||||
message.codeHash = new Uint8Array();
|
||||
}
|
||||
if (object.creator !== undefined && object.creator !== null) {
|
||||
message.creator = object.creator;
|
||||
} else {
|
||||
message.creator = "";
|
||||
}
|
||||
if (object.source !== undefined && object.source !== null) {
|
||||
message.source = object.source;
|
||||
} else {
|
||||
message.source = "";
|
||||
}
|
||||
if (object.builder !== undefined && object.builder !== null) {
|
||||
message.builder = object.builder;
|
||||
} else {
|
||||
message.builder = "";
|
||||
}
|
||||
if (object.instantiateConfig !== undefined && object.instantiateConfig !== null) {
|
||||
message.instantiateConfig = AccessConfig.fromPartial(object.instantiateConfig);
|
||||
} else {
|
||||
message.instantiateConfig = undefined;
|
||||
}
|
||||
return message;
|
||||
},
|
||||
|
||||
toJSON(message: CodeInfo): unknown {
|
||||
const obj: any = {};
|
||||
message.codeHash !== undefined &&
|
||||
(obj.codeHash = base64FromBytes(message.codeHash !== undefined ? message.codeHash : new Uint8Array()));
|
||||
message.creator !== undefined && (obj.creator = message.creator);
|
||||
message.source !== undefined && (obj.source = message.source);
|
||||
message.builder !== undefined && (obj.builder = message.builder);
|
||||
message.instantiateConfig !== undefined &&
|
||||
(obj.instantiateConfig = message.instantiateConfig
|
||||
? AccessConfig.toJSON(message.instantiateConfig)
|
||||
: undefined);
|
||||
return obj;
|
||||
},
|
||||
};
|
||||
|
||||
const baseContractInfo: object = { codeId: Long.UZERO, creator: "", admin: "", label: "" };
|
||||
|
||||
export const ContractInfo = {
|
||||
encode(message: ContractInfo, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer {
|
||||
writer.uint32(8).uint64(message.codeId);
|
||||
writer.uint32(18).string(message.creator);
|
||||
writer.uint32(26).string(message.admin);
|
||||
writer.uint32(34).string(message.label);
|
||||
if (message.created !== undefined && message.created !== undefined) {
|
||||
AbsoluteTxPosition.encode(message.created, writer.uint32(42).fork()).ldelim();
|
||||
}
|
||||
return writer;
|
||||
},
|
||||
|
||||
decode(input: _m0.Reader | Uint8Array, length?: number): ContractInfo {
|
||||
const reader = input instanceof Uint8Array ? new _m0.Reader(input) : input;
|
||||
let end = length === undefined ? reader.len : reader.pos + length;
|
||||
const message = { ...baseContractInfo } as ContractInfo;
|
||||
while (reader.pos < end) {
|
||||
const tag = reader.uint32();
|
||||
switch (tag >>> 3) {
|
||||
case 1:
|
||||
message.codeId = reader.uint64() as Long;
|
||||
break;
|
||||
case 2:
|
||||
message.creator = reader.string();
|
||||
break;
|
||||
case 3:
|
||||
message.admin = reader.string();
|
||||
break;
|
||||
case 4:
|
||||
message.label = reader.string();
|
||||
break;
|
||||
case 5:
|
||||
message.created = AbsoluteTxPosition.decode(reader, reader.uint32());
|
||||
break;
|
||||
default:
|
||||
reader.skipType(tag & 7);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return message;
|
||||
},
|
||||
|
||||
fromJSON(object: any): ContractInfo {
|
||||
const message = { ...baseContractInfo } as ContractInfo;
|
||||
if (object.codeId !== undefined && object.codeId !== null) {
|
||||
message.codeId = Long.fromString(object.codeId);
|
||||
} else {
|
||||
message.codeId = Long.UZERO;
|
||||
}
|
||||
if (object.creator !== undefined && object.creator !== null) {
|
||||
message.creator = String(object.creator);
|
||||
} else {
|
||||
message.creator = "";
|
||||
}
|
||||
if (object.admin !== undefined && object.admin !== null) {
|
||||
message.admin = String(object.admin);
|
||||
} else {
|
||||
message.admin = "";
|
||||
}
|
||||
if (object.label !== undefined && object.label !== null) {
|
||||
message.label = String(object.label);
|
||||
} else {
|
||||
message.label = "";
|
||||
}
|
||||
if (object.created !== undefined && object.created !== null) {
|
||||
message.created = AbsoluteTxPosition.fromJSON(object.created);
|
||||
} else {
|
||||
message.created = undefined;
|
||||
}
|
||||
return message;
|
||||
},
|
||||
|
||||
fromPartial(object: DeepPartial<ContractInfo>): ContractInfo {
|
||||
const message = { ...baseContractInfo } as ContractInfo;
|
||||
if (object.codeId !== undefined && object.codeId !== null) {
|
||||
message.codeId = object.codeId as Long;
|
||||
} else {
|
||||
message.codeId = Long.UZERO;
|
||||
}
|
||||
if (object.creator !== undefined && object.creator !== null) {
|
||||
message.creator = object.creator;
|
||||
} else {
|
||||
message.creator = "";
|
||||
}
|
||||
if (object.admin !== undefined && object.admin !== null) {
|
||||
message.admin = object.admin;
|
||||
} else {
|
||||
message.admin = "";
|
||||
}
|
||||
if (object.label !== undefined && object.label !== null) {
|
||||
message.label = object.label;
|
||||
} else {
|
||||
message.label = "";
|
||||
}
|
||||
if (object.created !== undefined && object.created !== null) {
|
||||
message.created = AbsoluteTxPosition.fromPartial(object.created);
|
||||
} else {
|
||||
message.created = undefined;
|
||||
}
|
||||
return message;
|
||||
},
|
||||
|
||||
toJSON(message: ContractInfo): unknown {
|
||||
const obj: any = {};
|
||||
message.codeId !== undefined && (obj.codeId = (message.codeId || Long.UZERO).toString());
|
||||
message.creator !== undefined && (obj.creator = message.creator);
|
||||
message.admin !== undefined && (obj.admin = message.admin);
|
||||
message.label !== undefined && (obj.label = message.label);
|
||||
message.created !== undefined &&
|
||||
(obj.created = message.created ? AbsoluteTxPosition.toJSON(message.created) : undefined);
|
||||
return obj;
|
||||
},
|
||||
};
|
||||
|
||||
const baseContractCodeHistoryEntry: object = { operation: 0, codeId: Long.UZERO };
|
||||
|
||||
export const ContractCodeHistoryEntry = {
|
||||
encode(message: ContractCodeHistoryEntry, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer {
|
||||
writer.uint32(8).int32(message.operation);
|
||||
writer.uint32(16).uint64(message.codeId);
|
||||
if (message.updated !== undefined && message.updated !== undefined) {
|
||||
AbsoluteTxPosition.encode(message.updated, writer.uint32(26).fork()).ldelim();
|
||||
}
|
||||
writer.uint32(34).bytes(message.msg);
|
||||
return writer;
|
||||
},
|
||||
|
||||
decode(input: _m0.Reader | Uint8Array, length?: number): ContractCodeHistoryEntry {
|
||||
const reader = input instanceof Uint8Array ? new _m0.Reader(input) : input;
|
||||
let end = length === undefined ? reader.len : reader.pos + length;
|
||||
const message = { ...baseContractCodeHistoryEntry } as ContractCodeHistoryEntry;
|
||||
while (reader.pos < end) {
|
||||
const tag = reader.uint32();
|
||||
switch (tag >>> 3) {
|
||||
case 1:
|
||||
message.operation = reader.int32() as any;
|
||||
break;
|
||||
case 2:
|
||||
message.codeId = reader.uint64() as Long;
|
||||
break;
|
||||
case 3:
|
||||
message.updated = AbsoluteTxPosition.decode(reader, reader.uint32());
|
||||
break;
|
||||
case 4:
|
||||
message.msg = reader.bytes();
|
||||
break;
|
||||
default:
|
||||
reader.skipType(tag & 7);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return message;
|
||||
},
|
||||
|
||||
fromJSON(object: any): ContractCodeHistoryEntry {
|
||||
const message = { ...baseContractCodeHistoryEntry } as ContractCodeHistoryEntry;
|
||||
if (object.operation !== undefined && object.operation !== null) {
|
||||
message.operation = contractCodeHistoryOperationTypeFromJSON(object.operation);
|
||||
} else {
|
||||
message.operation = 0;
|
||||
}
|
||||
if (object.codeId !== undefined && object.codeId !== null) {
|
||||
message.codeId = Long.fromString(object.codeId);
|
||||
} else {
|
||||
message.codeId = Long.UZERO;
|
||||
}
|
||||
if (object.updated !== undefined && object.updated !== null) {
|
||||
message.updated = AbsoluteTxPosition.fromJSON(object.updated);
|
||||
} else {
|
||||
message.updated = undefined;
|
||||
}
|
||||
if (object.msg !== undefined && object.msg !== null) {
|
||||
message.msg = bytesFromBase64(object.msg);
|
||||
}
|
||||
return message;
|
||||
},
|
||||
|
||||
fromPartial(object: DeepPartial<ContractCodeHistoryEntry>): ContractCodeHistoryEntry {
|
||||
const message = { ...baseContractCodeHistoryEntry } as ContractCodeHistoryEntry;
|
||||
if (object.operation !== undefined && object.operation !== null) {
|
||||
message.operation = object.operation;
|
||||
} else {
|
||||
message.operation = 0;
|
||||
}
|
||||
if (object.codeId !== undefined && object.codeId !== null) {
|
||||
message.codeId = object.codeId as Long;
|
||||
} else {
|
||||
message.codeId = Long.UZERO;
|
||||
}
|
||||
if (object.updated !== undefined && object.updated !== null) {
|
||||
message.updated = AbsoluteTxPosition.fromPartial(object.updated);
|
||||
} else {
|
||||
message.updated = undefined;
|
||||
}
|
||||
if (object.msg !== undefined && object.msg !== null) {
|
||||
message.msg = object.msg;
|
||||
} else {
|
||||
message.msg = new Uint8Array();
|
||||
}
|
||||
return message;
|
||||
},
|
||||
|
||||
toJSON(message: ContractCodeHistoryEntry): unknown {
|
||||
const obj: any = {};
|
||||
message.operation !== undefined &&
|
||||
(obj.operation = contractCodeHistoryOperationTypeToJSON(message.operation));
|
||||
message.codeId !== undefined && (obj.codeId = (message.codeId || Long.UZERO).toString());
|
||||
message.updated !== undefined &&
|
||||
(obj.updated = message.updated ? AbsoluteTxPosition.toJSON(message.updated) : undefined);
|
||||
message.msg !== undefined &&
|
||||
(obj.msg = base64FromBytes(message.msg !== undefined ? message.msg : new Uint8Array()));
|
||||
return obj;
|
||||
},
|
||||
};
|
||||
|
||||
const baseAbsoluteTxPosition: object = { blockHeight: Long.UZERO, txIndex: Long.UZERO };
|
||||
|
||||
export const AbsoluteTxPosition = {
|
||||
encode(message: AbsoluteTxPosition, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer {
|
||||
writer.uint32(8).uint64(message.blockHeight);
|
||||
writer.uint32(16).uint64(message.txIndex);
|
||||
return writer;
|
||||
},
|
||||
|
||||
decode(input: _m0.Reader | Uint8Array, length?: number): AbsoluteTxPosition {
|
||||
const reader = input instanceof Uint8Array ? new _m0.Reader(input) : input;
|
||||
let end = length === undefined ? reader.len : reader.pos + length;
|
||||
const message = { ...baseAbsoluteTxPosition } as AbsoluteTxPosition;
|
||||
while (reader.pos < end) {
|
||||
const tag = reader.uint32();
|
||||
switch (tag >>> 3) {
|
||||
case 1:
|
||||
message.blockHeight = reader.uint64() as Long;
|
||||
break;
|
||||
case 2:
|
||||
message.txIndex = reader.uint64() as Long;
|
||||
break;
|
||||
default:
|
||||
reader.skipType(tag & 7);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return message;
|
||||
},
|
||||
|
||||
fromJSON(object: any): AbsoluteTxPosition {
|
||||
const message = { ...baseAbsoluteTxPosition } as AbsoluteTxPosition;
|
||||
if (object.blockHeight !== undefined && object.blockHeight !== null) {
|
||||
message.blockHeight = Long.fromString(object.blockHeight);
|
||||
} else {
|
||||
message.blockHeight = Long.UZERO;
|
||||
}
|
||||
if (object.txIndex !== undefined && object.txIndex !== null) {
|
||||
message.txIndex = Long.fromString(object.txIndex);
|
||||
} else {
|
||||
message.txIndex = Long.UZERO;
|
||||
}
|
||||
return message;
|
||||
},
|
||||
|
||||
fromPartial(object: DeepPartial<AbsoluteTxPosition>): AbsoluteTxPosition {
|
||||
const message = { ...baseAbsoluteTxPosition } as AbsoluteTxPosition;
|
||||
if (object.blockHeight !== undefined && object.blockHeight !== null) {
|
||||
message.blockHeight = object.blockHeight as Long;
|
||||
} else {
|
||||
message.blockHeight = Long.UZERO;
|
||||
}
|
||||
if (object.txIndex !== undefined && object.txIndex !== null) {
|
||||
message.txIndex = object.txIndex as Long;
|
||||
} else {
|
||||
message.txIndex = Long.UZERO;
|
||||
}
|
||||
return message;
|
||||
},
|
||||
|
||||
toJSON(message: AbsoluteTxPosition): unknown {
|
||||
const obj: any = {};
|
||||
message.blockHeight !== undefined && (obj.blockHeight = (message.blockHeight || Long.UZERO).toString());
|
||||
message.txIndex !== undefined && (obj.txIndex = (message.txIndex || Long.UZERO).toString());
|
||||
return obj;
|
||||
},
|
||||
};
|
||||
|
||||
const baseModel: object = {};
|
||||
|
||||
export const Model = {
|
||||
encode(message: Model, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer {
|
||||
writer.uint32(10).bytes(message.key);
|
||||
writer.uint32(18).bytes(message.value);
|
||||
return writer;
|
||||
},
|
||||
|
||||
decode(input: _m0.Reader | Uint8Array, length?: number): Model {
|
||||
const reader = input instanceof Uint8Array ? new _m0.Reader(input) : input;
|
||||
let end = length === undefined ? reader.len : reader.pos + length;
|
||||
const message = { ...baseModel } as Model;
|
||||
while (reader.pos < end) {
|
||||
const tag = reader.uint32();
|
||||
switch (tag >>> 3) {
|
||||
case 1:
|
||||
message.key = reader.bytes();
|
||||
break;
|
||||
case 2:
|
||||
message.value = reader.bytes();
|
||||
break;
|
||||
default:
|
||||
reader.skipType(tag & 7);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return message;
|
||||
},
|
||||
|
||||
fromJSON(object: any): Model {
|
||||
const message = { ...baseModel } as Model;
|
||||
if (object.key !== undefined && object.key !== null) {
|
||||
message.key = bytesFromBase64(object.key);
|
||||
}
|
||||
if (object.value !== undefined && object.value !== null) {
|
||||
message.value = bytesFromBase64(object.value);
|
||||
}
|
||||
return message;
|
||||
},
|
||||
|
||||
fromPartial(object: DeepPartial<Model>): Model {
|
||||
const message = { ...baseModel } as Model;
|
||||
if (object.key !== undefined && object.key !== null) {
|
||||
message.key = object.key;
|
||||
} else {
|
||||
message.key = new Uint8Array();
|
||||
}
|
||||
if (object.value !== undefined && object.value !== null) {
|
||||
message.value = object.value;
|
||||
} else {
|
||||
message.value = new Uint8Array();
|
||||
}
|
||||
return message;
|
||||
},
|
||||
|
||||
toJSON(message: Model): unknown {
|
||||
const obj: any = {};
|
||||
message.key !== undefined &&
|
||||
(obj.key = base64FromBytes(message.key !== undefined ? message.key : new Uint8Array()));
|
||||
message.value !== undefined &&
|
||||
(obj.value = base64FromBytes(message.value !== undefined ? message.value : new Uint8Array()));
|
||||
return obj;
|
||||
},
|
||||
};
|
||||
|
||||
declare var self: any | undefined;
|
||||
declare var window: any | undefined;
|
||||
var globalThis: any = (() => {
|
||||
if (typeof globalThis !== "undefined") return globalThis;
|
||||
if (typeof self !== "undefined") return self;
|
||||
if (typeof window !== "undefined") return window;
|
||||
if (typeof global !== "undefined") return global;
|
||||
throw new Error("Unable to locate global object");
|
||||
})();
|
||||
|
||||
const atob: (b64: string) => string =
|
||||
globalThis.atob || ((b64) => globalThis.Buffer.from(b64, "base64").toString("binary"));
|
||||
function bytesFromBase64(b64: string): Uint8Array {
|
||||
const bin = atob(b64);
|
||||
const arr = new Uint8Array(bin.length);
|
||||
for (let i = 0; i < bin.length; ++i) {
|
||||
arr[i] = bin.charCodeAt(i);
|
||||
}
|
||||
return arr;
|
||||
}
|
||||
|
||||
const btoa: (bin: string) => string =
|
||||
globalThis.btoa || ((bin) => globalThis.Buffer.from(bin, "binary").toString("base64"));
|
||||
function base64FromBytes(arr: Uint8Array): string {
|
||||
const bin: string[] = [];
|
||||
for (let i = 0; i < arr.byteLength; ++i) {
|
||||
bin.push(String.fromCharCode(arr[i]));
|
||||
}
|
||||
return btoa(bin.join(""));
|
||||
}
|
||||
|
||||
type Builtin = Date | Function | Uint8Array | string | number | undefined | Long;
|
||||
export type DeepPartial<T> = T extends Builtin
|
||||
? T
|
||||
: T extends Array<infer U>
|
||||
? Array<DeepPartial<U>>
|
||||
: T extends ReadonlyArray<infer U>
|
||||
? ReadonlyArray<DeepPartial<U>>
|
||||
: T extends {}
|
||||
? { [K in keyof T]?: DeepPartial<T[K]> }
|
||||
: Partial<T>;
|
||||
@ -8,7 +8,8 @@ import {
|
||||
makeSignDoc,
|
||||
Registry,
|
||||
} from "@cosmjs/proto-signing";
|
||||
import { BroadcastTxResponse, codec, isBroadcastTxFailure, isBroadcastTxSuccess } from "@cosmjs/stargate";
|
||||
import { BroadcastTxResponse, isBroadcastTxFailure, isBroadcastTxSuccess } from "@cosmjs/stargate";
|
||||
import { Tx, TxRaw } from "@cosmjs/stargate/build/codec/cosmos/tx/v1beta1/tx";
|
||||
import { assert, sleep } from "@cosmjs/utils";
|
||||
|
||||
import { CosmWasmClient } from "./cosmwasmclient";
|
||||
@ -21,8 +22,6 @@ import {
|
||||
wasmdEnabled,
|
||||
} from "./testutils.spec";
|
||||
|
||||
const { Tx, TxRaw } = codec.cosmos.tx.v1beta1;
|
||||
|
||||
interface TestTxSend {
|
||||
readonly sender: string;
|
||||
readonly recipient: string;
|
||||
@ -77,7 +76,7 @@ async function sendTokens(
|
||||
const chainId = await client.getChainId();
|
||||
const signDoc = makeSignDoc(txBodyBytes, authInfoBytes, chainId, accountNumber);
|
||||
const { signature } = await wallet.signDirect(walletAddress, signDoc);
|
||||
const txRaw = TxRaw.create({
|
||||
const txRaw = TxRaw.fromPartial({
|
||||
bodyBytes: txBodyBytes,
|
||||
authInfoBytes: authInfoBytes,
|
||||
signatures: [fromBase64(signature.signature)],
|
||||
@ -227,9 +226,9 @@ describe("CosmWasmClient.getTx and .searchTx", () => {
|
||||
// Check basic structure of all results
|
||||
for (const result of results) {
|
||||
const tx = Tx.decode(result.tx);
|
||||
const filteredMsgs = tx.body!.messages!.filter(({ type_url: typeUrl, value }) => {
|
||||
const filteredMsgs = tx.body!.messages.filter(({ typeUrl: typeUrl, value }) => {
|
||||
if (typeUrl !== "/cosmos.bank.v1beta1.MsgSend") return false;
|
||||
const decoded = registry.decode({ typeUrl: typeUrl, value: value! });
|
||||
const decoded = registry.decode({ typeUrl: typeUrl, value: value });
|
||||
return decoded.fromAddress === sendSuccessful?.sender;
|
||||
});
|
||||
expect(filteredMsgs.length).toBeGreaterThanOrEqual(1);
|
||||
@ -255,9 +254,9 @@ describe("CosmWasmClient.getTx and .searchTx", () => {
|
||||
// Check basic structure of all results
|
||||
for (const result of results) {
|
||||
const tx = Tx.decode(result.tx);
|
||||
const filteredMsgs = tx.body!.messages!.filter(({ type_url: typeUrl, value }) => {
|
||||
const filteredMsgs = tx.body!.messages.filter(({ typeUrl: typeUrl, value }) => {
|
||||
if (typeUrl !== "/cosmos.bank.v1beta1.MsgSend") return false;
|
||||
const decoded = registry.decode({ typeUrl: typeUrl, value: value! });
|
||||
const decoded = registry.decode({ typeUrl: typeUrl, value: value });
|
||||
return decoded.toAddress === sendSuccessful?.recipient;
|
||||
});
|
||||
expect(filteredMsgs.length).toBeGreaterThanOrEqual(1);
|
||||
@ -341,9 +340,9 @@ describe("CosmWasmClient.getTx and .searchTx", () => {
|
||||
// Check basic structure of all results
|
||||
for (const result of results) {
|
||||
const tx = Tx.decode(result.tx);
|
||||
const { type_url: typeUrl, value } = fromOneElementArray(tx.body!.messages!);
|
||||
const { typeUrl, value } = fromOneElementArray(tx.body!.messages);
|
||||
expect(typeUrl).toEqual("/cosmos.bank.v1beta1.MsgSend");
|
||||
const decoded = registry.decode({ typeUrl: typeUrl!, value: value! });
|
||||
const decoded = registry.decode({ typeUrl: typeUrl, value: value });
|
||||
expect(decoded.toAddress).toEqual(sendSuccessful.recipient);
|
||||
}
|
||||
|
||||
|
||||
@ -11,7 +11,8 @@ import {
|
||||
makeSignDoc,
|
||||
Registry,
|
||||
} from "@cosmjs/proto-signing";
|
||||
import { assertIsBroadcastTxSuccess, codec, parseRawLog } from "@cosmjs/stargate";
|
||||
import { assertIsBroadcastTxSuccess, parseRawLog } from "@cosmjs/stargate";
|
||||
import { TxRaw } from "@cosmjs/stargate/build/codec/cosmos/tx/v1beta1/tx";
|
||||
import { assert, sleep } from "@cosmjs/utils";
|
||||
import { ReadonlyDate } from "readonly-date";
|
||||
|
||||
@ -29,8 +30,6 @@ import {
|
||||
wasmdEnabled,
|
||||
} from "./testutils.spec";
|
||||
|
||||
const { TxRaw } = codec.cosmos.tx.v1beta1;
|
||||
|
||||
interface HackatomInstance {
|
||||
readonly initMsg: {
|
||||
readonly verifier: string;
|
||||
@ -203,7 +202,7 @@ describe("CosmWasmClient", () => {
|
||||
const authInfoBytes = makeAuthInfoBytes([pubkeyAny], fee.amount, gasLimit, sequence);
|
||||
const signDoc = makeSignDoc(txBodyBytes, authInfoBytes, chainId, accountNumber);
|
||||
const { signed, signature } = await wallet.signDirect(alice.address0, signDoc);
|
||||
const txRaw = TxRaw.create({
|
||||
const txRaw = TxRaw.fromPartial({
|
||||
bodyBytes: signed.bodyBytes,
|
||||
authInfoBytes: signed.authInfoBytes,
|
||||
signatures: [fromBase64(signature.signature)],
|
||||
@ -370,8 +369,7 @@ describe("CosmWasmClient", () => {
|
||||
|
||||
const client = await CosmWasmClient.connect(wasmd.endpoint);
|
||||
const raw = await client.queryContractRaw(contract.address, otherKey);
|
||||
assert(raw, "must get result");
|
||||
expect(Uint8Array.from(raw)).toEqual(new Uint8Array());
|
||||
expect(raw).toBeNull();
|
||||
});
|
||||
|
||||
it("errors for non-existent contract", async () => {
|
||||
|
||||
@ -23,7 +23,6 @@ import {
|
||||
AuthExtension,
|
||||
BankExtension,
|
||||
BroadcastTxResponse,
|
||||
codec,
|
||||
coinFromProto,
|
||||
IndexedTx,
|
||||
QueryClient,
|
||||
@ -31,6 +30,7 @@ import {
|
||||
setupAuthExtension,
|
||||
setupBankExtension,
|
||||
} from "@cosmjs/stargate";
|
||||
import { TxMsgData } from "@cosmjs/stargate/build/codec/cosmos/base/abci/v1beta1/abci";
|
||||
import {
|
||||
adaptor34,
|
||||
broadcastTxCommitSuccess,
|
||||
@ -39,15 +39,10 @@ import {
|
||||
} from "@cosmjs/tendermint-rpc";
|
||||
import { assert } from "@cosmjs/utils";
|
||||
|
||||
import { cosmwasm } from "./codec";
|
||||
import { CodeInfoResponse } from "./codec/x/wasm/internal/types/query";
|
||||
import { ContractCodeHistoryOperationType } from "./codec/x/wasm/internal/types/types";
|
||||
import { setupWasmExtension, WasmExtension } from "./queries";
|
||||
|
||||
type ICodeInfoResponse = cosmwasm.wasm.v1beta1.ICodeInfoResponse;
|
||||
type ContractCodeHistoryOperationType = cosmwasm.wasm.v1beta1.ContractCodeHistoryOperationType;
|
||||
|
||||
const { TxMsgData } = codec.cosmos.base.abci.v1beta1;
|
||||
const { ContractCodeHistoryOperationType } = cosmwasm.wasm.v1beta1;
|
||||
|
||||
/** Use for testing only */
|
||||
export interface PrivateCosmWasmClient {
|
||||
readonly tmClient: TendermintClient;
|
||||
@ -207,7 +202,7 @@ export class CosmWasmClient {
|
||||
public async getCodes(): Promise<readonly Code[]> {
|
||||
const { codeInfos } = await this.queryClient.unverified.wasm.listCodeInfo();
|
||||
return (codeInfos || []).map(
|
||||
(entry: ICodeInfoResponse): Code => {
|
||||
(entry: CodeInfoResponse): Code => {
|
||||
assert(entry.creator && entry.codeId && entry.dataHash, "entry incomplete");
|
||||
return {
|
||||
id: entry.codeId.toNumber(),
|
||||
|
||||
@ -1,4 +1,3 @@
|
||||
export * as codec from "./codec";
|
||||
export { cosmWasmTypes } from "./aminotypes";
|
||||
export { CosmWasmClient } from "./cosmwasmclient";
|
||||
export { SigningCosmWasmClient, SigningCosmWasmClientOptions } from "./signingcosmwasmclient";
|
||||
|
||||
@ -12,7 +12,15 @@ import {
|
||||
import { assert, assertDefined } from "@cosmjs/utils";
|
||||
import Long from "long";
|
||||
|
||||
import { cosmwasm } from "../codec";
|
||||
import {
|
||||
MsgExecuteContract,
|
||||
MsgExecuteContractResponse,
|
||||
MsgInstantiateContract,
|
||||
MsgInstantiateContractResponse,
|
||||
MsgStoreCode,
|
||||
MsgStoreCodeResponse,
|
||||
} from "../codec/x/wasm/internal/types/tx";
|
||||
import { ContractCodeHistoryOperationType } from "../codec/x/wasm/internal/types/types";
|
||||
import { SigningCosmWasmClient } from "../signingcosmwasmclient";
|
||||
import {
|
||||
alice,
|
||||
@ -28,15 +36,6 @@ import {
|
||||
wasmdEnabled,
|
||||
} from "../testutils.spec";
|
||||
|
||||
const {
|
||||
MsgExecuteContract,
|
||||
MsgExecuteContractResponse,
|
||||
MsgInstantiateContract,
|
||||
MsgInstantiateContractResponse,
|
||||
MsgStoreCode,
|
||||
MsgStoreCodeResponse,
|
||||
} = cosmwasm.wasm.v1beta1;
|
||||
|
||||
const registry = new Registry([
|
||||
["/cosmwasm.wasm.v1beta1.MsgExecuteContract", MsgExecuteContract],
|
||||
["/cosmwasm.wasm.v1beta1.MsgStoreCode", MsgStoreCode],
|
||||
@ -50,7 +49,7 @@ async function uploadContract(
|
||||
const memo = "My first contract on chain";
|
||||
const theMsg = {
|
||||
typeUrl: "/cosmwasm.wasm.v1beta1.MsgStoreCode",
|
||||
value: MsgStoreCode.create({
|
||||
value: MsgStoreCode.fromPartial({
|
||||
sender: alice.address0,
|
||||
wasmByteCode: contract.data,
|
||||
source: contract.source || "",
|
||||
@ -75,7 +74,7 @@ async function instantiateContract(
|
||||
const memo = "Create an escrow instance";
|
||||
const theMsg = {
|
||||
typeUrl: "/cosmwasm.wasm.v1beta1.MsgInstantiateContract",
|
||||
value: MsgInstantiateContract.create({
|
||||
value: MsgInstantiateContract.fromPartial({
|
||||
sender: alice.address0,
|
||||
codeId: Long.fromNumber(codeId),
|
||||
label: "my escrow",
|
||||
@ -106,7 +105,7 @@ async function executeContract(
|
||||
const memo = "Time for action";
|
||||
const theMsg = {
|
||||
typeUrl: "/cosmwasm.wasm.v1beta1.MsgExecuteContract",
|
||||
value: MsgExecuteContract.create({
|
||||
value: MsgExecuteContract.fromPartial({
|
||||
sender: alice.address0,
|
||||
contract: contractAddress,
|
||||
msg: toAscii(JSON.stringify(msg)),
|
||||
@ -157,11 +156,11 @@ describe("WasmExtension", () => {
|
||||
const { codeInfos } = await client.unverified.wasm.listCodeInfo();
|
||||
assert(codeInfos);
|
||||
const lastCode = codeInfos[codeInfos.length - 1];
|
||||
expect(lastCode.codeId!.toNumber()).toEqual(hackatomCodeId);
|
||||
expect(lastCode.codeId.toNumber()).toEqual(hackatomCodeId);
|
||||
expect(lastCode.creator).toEqual(alice.address0);
|
||||
expect(lastCode.source).toEqual(hackatom.source);
|
||||
expect(lastCode.builder).toEqual(hackatom.builder);
|
||||
expect(toHex(lastCode.dataHash!)).toEqual(toHex(sha256(hackatom.data)));
|
||||
expect(lastCode.source).toEqual(hackatom.source ?? "");
|
||||
expect(lastCode.builder).toEqual(hackatom.builder ?? "");
|
||||
expect(toHex(lastCode.dataHash)).toEqual(toHex(sha256(hackatom.data)));
|
||||
});
|
||||
});
|
||||
|
||||
@ -171,11 +170,11 @@ describe("WasmExtension", () => {
|
||||
assert(hackatomCodeId);
|
||||
const client = await makeWasmClient(wasmd.endpoint);
|
||||
const { codeInfo, data } = await client.unverified.wasm.getCode(hackatomCodeId);
|
||||
expect(codeInfo!.codeId!.toNumber()).toEqual(hackatomCodeId);
|
||||
expect(codeInfo!.codeId.toNumber()).toEqual(hackatomCodeId);
|
||||
expect(codeInfo!.creator).toEqual(alice.address0);
|
||||
expect(codeInfo!.source).toEqual(hackatom.source);
|
||||
expect(codeInfo!.builder).toEqual(hackatom.builder);
|
||||
expect(toHex(codeInfo!.dataHash!)).toEqual(toHex(sha256(hackatom.data)));
|
||||
expect(codeInfo!.source).toEqual(hackatom.source ?? "");
|
||||
expect(codeInfo!.builder).toEqual(hackatom.builder ?? "");
|
||||
expect(toHex(codeInfo!.dataHash)).toEqual(toHex(sha256(hackatom.data)));
|
||||
expect(data).toEqual(hackatom.data);
|
||||
});
|
||||
});
|
||||
@ -197,9 +196,10 @@ describe("WasmExtension", () => {
|
||||
assert(existingContractInfos);
|
||||
for (const { address, contractInfo } of existingContractInfos) {
|
||||
expect(address).toMatch(bech32AddressMatcher);
|
||||
expect(contractInfo!.codeId!.toNumber()).toEqual(hackatomCodeId);
|
||||
expect(contractInfo!.creator).toMatch(bech32AddressMatcher);
|
||||
expect(contractInfo!.label).toMatch(/^.+$/);
|
||||
assertDefined(contractInfo);
|
||||
expect(contractInfo.codeId.toNumber()).toEqual(hackatomCodeId);
|
||||
expect(contractInfo.creator).toMatch(bech32AddressMatcher);
|
||||
expect(contractInfo.label).toMatch(/^.+$/);
|
||||
}
|
||||
|
||||
const result = await instantiateContract(wallet, hackatomCodeId, beneficiaryAddress, transferAmount);
|
||||
@ -218,6 +218,7 @@ describe("WasmExtension", () => {
|
||||
codeId: Long.fromNumber(hackatomCodeId, true),
|
||||
creator: alice.address0,
|
||||
label: "my escrow",
|
||||
admin: "",
|
||||
});
|
||||
|
||||
const { contractInfo } = await client.unverified.wasm.getContractInfo(myAddress);
|
||||
@ -226,6 +227,7 @@ describe("WasmExtension", () => {
|
||||
codeId: Long.fromNumber(hackatomCodeId, true),
|
||||
creator: alice.address0,
|
||||
label: "my escrow",
|
||||
admin: "",
|
||||
});
|
||||
expect(contractInfo.admin).toEqual("");
|
||||
});
|
||||
@ -263,8 +265,7 @@ describe("WasmExtension", () => {
|
||||
expect(history.entries).toContain(
|
||||
jasmine.objectContaining({
|
||||
codeId: Long.fromNumber(hackatomCodeId, true),
|
||||
operation:
|
||||
cosmwasm.wasm.v1beta1.ContractCodeHistoryOperationType.CONTRACT_CODE_HISTORY_OPERATION_TYPE_INIT,
|
||||
operation: ContractCodeHistoryOperationType.CONTRACT_CODE_HISTORY_OPERATION_TYPE_INIT,
|
||||
msg: toAscii(
|
||||
JSON.stringify({
|
||||
verifier: alice.address0,
|
||||
@ -295,7 +296,7 @@ describe("WasmExtension", () => {
|
||||
expect(models.length).toEqual(1);
|
||||
const data = models[0];
|
||||
expect(data.key).toEqual(hackatomConfigKey);
|
||||
const value = JSON.parse(fromAscii(data.value!));
|
||||
const value = JSON.parse(fromAscii(data.value));
|
||||
expect(value.verifier).toMatch(base64Matcher);
|
||||
expect(value.beneficiary).toMatch(base64Matcher);
|
||||
});
|
||||
@ -322,15 +323,15 @@ describe("WasmExtension", () => {
|
||||
expect(model.beneficiary).toMatch(base64Matcher);
|
||||
});
|
||||
|
||||
it("returns empty object for missing key", async () => {
|
||||
it("returns undefined for missing key", async () => {
|
||||
pendingWithoutWasmd();
|
||||
assert(hackatomContractAddress);
|
||||
const client = await makeWasmClient(wasmd.endpoint);
|
||||
const response = await client.unverified.wasm.queryContractRaw(
|
||||
const { data } = await client.unverified.wasm.queryContractRaw(
|
||||
hackatomContractAddress,
|
||||
fromHex("cafe0dad"),
|
||||
);
|
||||
expect({ ...response }).toEqual({});
|
||||
expect(data).toBeUndefined();
|
||||
});
|
||||
|
||||
it("returns null for non-existent address", async () => {
|
||||
@ -398,8 +399,8 @@ describe("WasmExtension", () => {
|
||||
assertDefined(result.data);
|
||||
const msgData = fromOneElementArray(result.data);
|
||||
expect(msgData.msgType).toEqual("store-code");
|
||||
expect(MsgStoreCodeResponse.decode(msgData.data!)).toEqual(
|
||||
MsgStoreCodeResponse.create({ codeId: Long.fromNumber(codeId, true) }),
|
||||
expect(MsgStoreCodeResponse.decode(msgData.data)).toEqual(
|
||||
MsgStoreCodeResponse.fromPartial({ codeId: Long.fromNumber(codeId, true) }),
|
||||
);
|
||||
}
|
||||
|
||||
@ -418,8 +419,8 @@ describe("WasmExtension", () => {
|
||||
assertDefined(result.data);
|
||||
const msgData = fromOneElementArray(result.data);
|
||||
expect(msgData.msgType).toEqual("instantiate");
|
||||
expect(MsgInstantiateContractResponse.decode(msgData.data!)).toEqual(
|
||||
MsgInstantiateContractResponse.create({ address: contractAddress }),
|
||||
expect(MsgInstantiateContractResponse.decode(msgData.data)).toEqual(
|
||||
MsgInstantiateContractResponse.fromPartial({ address: contractAddress }),
|
||||
);
|
||||
|
||||
const balanceUcosm = await client.bank.balance(contractAddress, "ucosm");
|
||||
@ -444,8 +445,8 @@ describe("WasmExtension", () => {
|
||||
assertDefined(result.data);
|
||||
const msgData = fromOneElementArray(result.data);
|
||||
expect(msgData.msgType).toEqual("execute");
|
||||
expect(MsgExecuteContractResponse.decode(msgData.data!)).toEqual(
|
||||
MsgExecuteContractResponse.create({ data: fromHex("F00BAA") }),
|
||||
expect(MsgExecuteContractResponse.decode(msgData.data)).toEqual(
|
||||
MsgExecuteContractResponse.fromPartial({ data: fromHex("F00BAA") }),
|
||||
);
|
||||
|
||||
// Verify token transfer from contract to beneficiary
|
||||
|
||||
@ -1,46 +1,45 @@
|
||||
/* eslint-disable @typescript-eslint/naming-convention */
|
||||
import { JsonObject } from "@cosmjs/cosmwasm-launchpad";
|
||||
import { fromUtf8, toAscii } from "@cosmjs/encoding";
|
||||
import { QueryClient } from "@cosmjs/stargate";
|
||||
import { createPagination, createRpc, QueryClient } from "@cosmjs/stargate";
|
||||
import Long from "long";
|
||||
|
||||
import { cosmwasm } from "../codec";
|
||||
|
||||
type IQueryAllContractStateResponse = cosmwasm.wasm.v1beta1.IQueryAllContractStateResponse;
|
||||
type IQueryCodesResponse = cosmwasm.wasm.v1beta1.IQueryCodesResponse;
|
||||
type IQueryCodeResponse = cosmwasm.wasm.v1beta1.IQueryCodeResponse;
|
||||
type IQueryContractHistoryResponse = cosmwasm.wasm.v1beta1.IQueryContractHistoryResponse;
|
||||
type IQueryContractInfoResponse = cosmwasm.wasm.v1beta1.IQueryContractInfoResponse;
|
||||
type IQueryContractsByCodeResponse = cosmwasm.wasm.v1beta1.IQueryContractsByCodeResponse;
|
||||
type IQueryRawContractStateResponse = cosmwasm.wasm.v1beta1.IQueryRawContractStateResponse;
|
||||
|
||||
const { Query } = cosmwasm.wasm.v1beta1;
|
||||
import {
|
||||
QueryAllContractStateResponse,
|
||||
QueryClientImpl,
|
||||
QueryCodeResponse,
|
||||
QueryCodesResponse,
|
||||
QueryContractHistoryResponse,
|
||||
QueryContractInfoResponse,
|
||||
QueryContractsByCodeResponse,
|
||||
QueryRawContractStateResponse,
|
||||
} from "../codec/x/wasm/internal/types/query";
|
||||
|
||||
export interface WasmExtension {
|
||||
readonly unverified: {
|
||||
readonly wasm: {
|
||||
readonly listCodeInfo: (paginationKey?: Uint8Array) => Promise<IQueryCodesResponse>;
|
||||
readonly listCodeInfo: (paginationKey?: Uint8Array) => Promise<QueryCodesResponse>;
|
||||
/**
|
||||
* Downloads the original wasm bytecode by code ID.
|
||||
*
|
||||
* Throws an error if no code with this id
|
||||
*/
|
||||
readonly getCode: (id: number) => Promise<IQueryCodeResponse>;
|
||||
readonly getCode: (id: number) => Promise<QueryCodeResponse>;
|
||||
readonly listContractsByCodeId: (
|
||||
id: number,
|
||||
paginationKey?: Uint8Array,
|
||||
) => Promise<IQueryContractsByCodeResponse>;
|
||||
) => Promise<QueryContractsByCodeResponse>;
|
||||
/**
|
||||
* Returns null when contract was not found at this address.
|
||||
*/
|
||||
readonly getContractInfo: (address: string) => Promise<IQueryContractInfoResponse>;
|
||||
readonly getContractInfo: (address: string) => Promise<QueryContractInfoResponse>;
|
||||
/**
|
||||
* Returns null when contract history was not found for this address.
|
||||
*/
|
||||
readonly getContractCodeHistory: (
|
||||
address: string,
|
||||
paginationKey?: Uint8Array,
|
||||
) => Promise<IQueryContractHistoryResponse>;
|
||||
) => Promise<QueryContractHistoryResponse>;
|
||||
/**
|
||||
* Returns all contract state.
|
||||
* This is an empty array if no such contract, or contract has no data.
|
||||
@ -48,15 +47,12 @@ export interface WasmExtension {
|
||||
readonly getAllContractState: (
|
||||
address: string,
|
||||
paginationKey?: Uint8Array,
|
||||
) => Promise<IQueryAllContractStateResponse>;
|
||||
) => Promise<QueryAllContractStateResponse>;
|
||||
/**
|
||||
* Returns the data at the key if present (unknown decoded json),
|
||||
* or null if no data at this (contract address, key) pair
|
||||
*/
|
||||
readonly queryContractRaw: (
|
||||
address: string,
|
||||
key: Uint8Array,
|
||||
) => Promise<IQueryRawContractStateResponse>;
|
||||
readonly queryContractRaw: (address: string, key: Uint8Array) => Promise<QueryRawContractStateResponse>;
|
||||
/**
|
||||
* Makes a smart query on the contract and parses the response as JSON.
|
||||
* Throws error if no such contract exists, the query format is invalid or the response is invalid.
|
||||
@ -67,54 +63,60 @@ export interface WasmExtension {
|
||||
}
|
||||
|
||||
export function setupWasmExtension(base: QueryClient): WasmExtension {
|
||||
const queryService = Query.create((method: any, requestData, callback) => {
|
||||
const path = `/cosmwasm.wasm.v1beta1.Query/${method.name}`;
|
||||
base
|
||||
.queryUnverified(path, requestData)
|
||||
.then((response) => callback(null, response))
|
||||
.catch((error) => callback(error));
|
||||
});
|
||||
const rpc = createRpc(base);
|
||||
// Use this service to get easy typed access to query methods
|
||||
// This cannot be used for proof verification
|
||||
const queryService = new QueryClientImpl(rpc);
|
||||
|
||||
return {
|
||||
unverified: {
|
||||
wasm: {
|
||||
listCodeInfo: async (paginationKey?: Uint8Array) => {
|
||||
const request = paginationKey ? { pagination: { key: paginationKey } } : {};
|
||||
return queryService.codes(request);
|
||||
const request = {
|
||||
pagination: createPagination(paginationKey),
|
||||
};
|
||||
return queryService.Codes(request);
|
||||
},
|
||||
getCode: async (id: number) => {
|
||||
const request = { codeId: Long.fromNumber(id) };
|
||||
return queryService.code(request);
|
||||
return queryService.Code(request);
|
||||
},
|
||||
listContractsByCodeId: async (id: number, paginationKey?: Uint8Array) => {
|
||||
const pagination = paginationKey ? { pagination: { key: paginationKey } } : {};
|
||||
const pagination = {
|
||||
pagination: createPagination(paginationKey),
|
||||
};
|
||||
const request = { ...pagination, codeId: Long.fromNumber(id) };
|
||||
return queryService.contractsByCode(request);
|
||||
return queryService.ContractsByCode(request);
|
||||
},
|
||||
getContractInfo: async (address: string) => {
|
||||
const request = { address: address };
|
||||
return queryService.contractInfo(request);
|
||||
return queryService.ContractInfo(request);
|
||||
},
|
||||
|
||||
getContractCodeHistory: async (address: string, paginationKey?: Uint8Array) => {
|
||||
const pagination = paginationKey ? { pagination: { key: paginationKey } } : {};
|
||||
const pagination = {
|
||||
pagination: createPagination(paginationKey),
|
||||
};
|
||||
const request = { ...pagination, address: address };
|
||||
return queryService.contractHistory(request);
|
||||
return queryService.ContractHistory(request);
|
||||
},
|
||||
|
||||
getAllContractState: async (address: string, paginationKey?: Uint8Array) => {
|
||||
const pagination = paginationKey ? { pagination: { key: paginationKey } } : {};
|
||||
const pagination = {
|
||||
pagination: createPagination(paginationKey),
|
||||
};
|
||||
const request = { ...pagination, address: address };
|
||||
return queryService.allContractState(request);
|
||||
return queryService.AllContractState(request);
|
||||
},
|
||||
|
||||
queryContractRaw: async (address: string, key: Uint8Array) => {
|
||||
const request = { address: address, queryData: key };
|
||||
return queryService.rawContractState(request);
|
||||
return queryService.RawContractState(request);
|
||||
},
|
||||
|
||||
queryContractSmart: async (address: string, query: Record<string, unknown>) => {
|
||||
const request = { address: address, queryData: toAscii(JSON.stringify(query)) };
|
||||
const { data } = await queryService.smartContractState(request);
|
||||
const { data } = await queryService.SmartContractState(request);
|
||||
// By convention, smart queries must return a valid JSON document (see https://github.com/CosmWasm/cosmwasm/issues/144)
|
||||
try {
|
||||
return JSON.parse(fromUtf8(data));
|
||||
|
||||
@ -9,14 +9,18 @@ import {
|
||||
MsgDelegate as LaunchpadMsgDelegate,
|
||||
Secp256k1HdWallet,
|
||||
} from "@cosmjs/launchpad";
|
||||
import { Coin, cosmosField, DirectSecp256k1HdWallet, registered, Registry } from "@cosmjs/proto-signing";
|
||||
import { AminoTypes, assertIsBroadcastTxSuccess, codec } from "@cosmjs/stargate";
|
||||
import { DirectSecp256k1HdWallet, Registry } from "@cosmjs/proto-signing";
|
||||
import { AminoTypes, assertIsBroadcastTxSuccess } from "@cosmjs/stargate";
|
||||
import { DeepPartial, MsgSend } from "@cosmjs/stargate/build/codec/cosmos/bank/v1beta1/tx";
|
||||
import { Coin } from "@cosmjs/stargate/build/codec/cosmos/base/v1beta1/coin";
|
||||
import { MsgDelegate } from "@cosmjs/stargate/build/codec/cosmos/staking/v1beta1/tx";
|
||||
import { Tx } from "@cosmjs/stargate/build/codec/cosmos/tx/v1beta1/tx";
|
||||
import { assert, sleep } from "@cosmjs/utils";
|
||||
import Long from "long";
|
||||
import pako from "pako";
|
||||
import { Message } from "protobufjs";
|
||||
import protobuf from "protobufjs/minimal";
|
||||
|
||||
import { cosmwasm } from "./codec";
|
||||
import { MsgStoreCode } from "./codec/x/wasm/internal/types/tx";
|
||||
import { PrivateSigningCosmWasmClient, SigningCosmWasmClient } from "./signingcosmwasmclient";
|
||||
import {
|
||||
alice,
|
||||
@ -31,14 +35,6 @@ import {
|
||||
wasmd,
|
||||
} from "./testutils.spec";
|
||||
|
||||
type IMsgSend = codec.cosmos.bank.v1beta1.IMsgSend;
|
||||
type IMsgDelegate = codec.cosmos.staking.v1beta1.IMsgDelegate;
|
||||
type IMsgStoreCode = cosmwasm.wasm.v1beta1.IMsgStoreCode;
|
||||
|
||||
const { MsgSend } = codec.cosmos.bank.v1beta1;
|
||||
const { MsgDelegate } = codec.cosmos.staking.v1beta1;
|
||||
const { Tx } = codec.cosmos.tx.v1beta1;
|
||||
|
||||
describe("SigningCosmWasmClient", () => {
|
||||
describe("connectWithSigner", () => {
|
||||
it("can be constructed", async () => {
|
||||
@ -515,7 +511,7 @@ describe("SigningCosmWasmClient", () => {
|
||||
const options = { prefix: wasmd.prefix, registry: registry };
|
||||
const client = await SigningCosmWasmClient.connectWithSigner(wasmd.endpoint, wallet, options);
|
||||
|
||||
const msg = MsgDelegate.create({
|
||||
const msg = MsgDelegate.fromPartial({
|
||||
delegatorAddress: alice.address0,
|
||||
validatorAddress: validator.validatorAddress,
|
||||
amount: coin(1234, "ustake"),
|
||||
@ -546,7 +542,7 @@ describe("SigningCosmWasmClient", () => {
|
||||
const options = { prefix: wasmd.prefix, registry: registry };
|
||||
const client = await SigningCosmWasmClient.connectWithSigner(wasmd.endpoint, wallet, options);
|
||||
|
||||
const msg = MsgDelegate.create({
|
||||
const msg = MsgDelegate.fromPartial({
|
||||
delegatorAddress: alice.address0,
|
||||
validatorAddress: validator.validatorAddress,
|
||||
amount: coin(1234, "ustake"),
|
||||
@ -570,36 +566,19 @@ describe("SigningCosmWasmClient", () => {
|
||||
const tx = Tx.decode(searchResult.tx);
|
||||
// From ModifyingDirectSecp256k1HdWallet
|
||||
expect(tx.body!.memo).toEqual("This was modified");
|
||||
expect({ ...tx.authInfo!.fee!.amount![0] }).toEqual(coin(3000, "ucosm"));
|
||||
expect(tx.authInfo!.fee!.gasLimit!.toNumber()).toEqual(333333);
|
||||
expect({ ...tx.authInfo!.fee!.amount[0] }).toEqual(coin(3000, "ucosm"));
|
||||
expect(tx.authInfo!.fee!.gasLimit.toNumber()).toEqual(333333);
|
||||
});
|
||||
});
|
||||
|
||||
describe("legacy Amino mode", () => {
|
||||
// NOTE: One custom registry shared between tests
|
||||
// See https://github.com/protobufjs/protobuf.js#using-decorators
|
||||
// > Decorated types reside in protobuf.roots["decorated"] using a flat structure, so no duplicate names.
|
||||
const customRegistry = new Registry();
|
||||
const msgDelegateTypeUrl = "/cosmos.staking.v1beta1.MsgDelegate";
|
||||
|
||||
@registered(customRegistry, msgDelegateTypeUrl)
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
class CustomMsgDelegate extends Message {
|
||||
@cosmosField.string(1)
|
||||
public readonly custom_delegator_address?: string;
|
||||
@cosmosField.string(2)
|
||||
public readonly custom_validator_address?: string;
|
||||
@cosmosField.message(3, Coin)
|
||||
public readonly custom_amount?: Coin;
|
||||
}
|
||||
|
||||
it("works with bank MsgSend", async () => {
|
||||
pendingWithoutWasmd();
|
||||
const wallet = await Secp256k1HdWallet.fromMnemonic(alice.mnemonic, undefined, wasmd.prefix);
|
||||
const options = { prefix: wasmd.prefix };
|
||||
const client = await SigningCosmWasmClient.connectWithSigner(wasmd.endpoint, wallet, options);
|
||||
|
||||
const msgSend: IMsgSend = {
|
||||
const msgSend: MsgSend = {
|
||||
fromAddress: alice.address0,
|
||||
toAddress: makeRandomAddress(),
|
||||
amount: coins(1234, "ucosm"),
|
||||
@ -623,7 +602,7 @@ describe("SigningCosmWasmClient", () => {
|
||||
const options = { prefix: wasmd.prefix };
|
||||
const client = await SigningCosmWasmClient.connectWithSigner(wasmd.endpoint, wallet, options);
|
||||
|
||||
const msgDelegate: IMsgDelegate = {
|
||||
const msgDelegate: MsgDelegate = {
|
||||
delegatorAddress: alice.address0,
|
||||
validatorAddress: validator.validatorAddress,
|
||||
amount: coin(1234, "ustake"),
|
||||
@ -648,11 +627,12 @@ describe("SigningCosmWasmClient", () => {
|
||||
const client = await SigningCosmWasmClient.connectWithSigner(wasmd.endpoint, wallet, options);
|
||||
const { data, builder, source } = getHackatom();
|
||||
|
||||
const msgStoreCode: IMsgStoreCode = {
|
||||
const msgStoreCode: MsgStoreCode = {
|
||||
sender: alice.address0,
|
||||
wasmByteCode: pako.gzip(data),
|
||||
source: source,
|
||||
builder: builder,
|
||||
source: source ?? "",
|
||||
builder: builder ?? "",
|
||||
instantiatePermission: undefined,
|
||||
};
|
||||
const msgAny = {
|
||||
typeUrl: "/cosmwasm.wasm.v1beta1.MsgStoreCode",
|
||||
@ -670,27 +650,85 @@ describe("SigningCosmWasmClient", () => {
|
||||
it("works with a custom registry and custom message", async () => {
|
||||
pendingWithoutWasmd();
|
||||
const wallet = await Secp256k1HdWallet.fromMnemonic(alice.mnemonic, undefined, wasmd.prefix);
|
||||
|
||||
const customRegistry = new Registry();
|
||||
const msgDelegateTypeUrl = "/cosmos.staking.v1beta1.MsgDelegate";
|
||||
interface CustomMsgDelegate {
|
||||
customDelegatorAddress?: string;
|
||||
customValidatorAddress?: string;
|
||||
customAmount?: Coin;
|
||||
}
|
||||
const baseCustomMsgDelegate: CustomMsgDelegate = {
|
||||
customDelegatorAddress: "",
|
||||
customValidatorAddress: "",
|
||||
};
|
||||
const CustomMsgDelegate = {
|
||||
// Adapted from autogenerated MsgDelegate implementation
|
||||
encode(
|
||||
message: CustomMsgDelegate,
|
||||
writer: protobuf.Writer = protobuf.Writer.create(),
|
||||
): protobuf.Writer {
|
||||
writer.uint32(10).string(message.customDelegatorAddress ?? "");
|
||||
writer.uint32(18).string(message.customValidatorAddress ?? "");
|
||||
if (message.customAmount !== undefined && message.customAmount !== undefined) {
|
||||
Coin.encode(message.customAmount, writer.uint32(26).fork()).ldelim();
|
||||
}
|
||||
return writer;
|
||||
},
|
||||
|
||||
decode(): CustomMsgDelegate {
|
||||
throw new Error("decode method should not be required");
|
||||
},
|
||||
|
||||
fromJSON(): CustomMsgDelegate {
|
||||
throw new Error("fromJSON method should not be required");
|
||||
},
|
||||
|
||||
fromPartial(object: DeepPartial<CustomMsgDelegate>): CustomMsgDelegate {
|
||||
const message = { ...baseCustomMsgDelegate } as CustomMsgDelegate;
|
||||
if (object.customDelegatorAddress !== undefined && object.customDelegatorAddress !== null) {
|
||||
message.customDelegatorAddress = object.customDelegatorAddress;
|
||||
} else {
|
||||
message.customDelegatorAddress = "";
|
||||
}
|
||||
if (object.customValidatorAddress !== undefined && object.customValidatorAddress !== null) {
|
||||
message.customValidatorAddress = object.customValidatorAddress;
|
||||
} else {
|
||||
message.customValidatorAddress = "";
|
||||
}
|
||||
if (object.customAmount !== undefined && object.customAmount !== null) {
|
||||
message.customAmount = Coin.fromPartial(object.customAmount);
|
||||
} else {
|
||||
message.customAmount = undefined;
|
||||
}
|
||||
return message;
|
||||
},
|
||||
|
||||
toJSON(): unknown {
|
||||
throw new Error("toJSON method should not be required");
|
||||
},
|
||||
};
|
||||
customRegistry.register(msgDelegateTypeUrl, CustomMsgDelegate);
|
||||
const customAminoTypes = new AminoTypes({
|
||||
prefix: wasmd.prefix,
|
||||
additions: {
|
||||
"/cosmos.staking.v1beta1.MsgDelegate": {
|
||||
aminoType: "cosmos-sdk/MsgDelegate",
|
||||
toAmino: ({
|
||||
custom_delegator_address,
|
||||
custom_validator_address,
|
||||
custom_amount,
|
||||
customDelegatorAddress,
|
||||
customValidatorAddress,
|
||||
customAmount,
|
||||
}: CustomMsgDelegate): LaunchpadMsgDelegate["value"] => {
|
||||
assert(custom_delegator_address, "missing custom_delegator_address");
|
||||
assert(custom_validator_address, "missing validator_address");
|
||||
assert(custom_amount, "missing amount");
|
||||
assert(custom_amount.amount, "missing amount.amount");
|
||||
assert(custom_amount.denom, "missing amount.denom");
|
||||
assert(customDelegatorAddress, "missing customDelegatorAddress");
|
||||
assert(customValidatorAddress, "missing validatorAddress");
|
||||
assert(customAmount, "missing amount");
|
||||
assert(customAmount.amount, "missing amount.amount");
|
||||
assert(customAmount.denom, "missing amount.denom");
|
||||
return {
|
||||
delegator_address: custom_delegator_address,
|
||||
validator_address: custom_validator_address,
|
||||
delegator_address: customDelegatorAddress,
|
||||
validator_address: customValidatorAddress,
|
||||
amount: {
|
||||
amount: custom_amount.amount,
|
||||
denom: custom_amount.denom,
|
||||
amount: customAmount.amount,
|
||||
denom: customAmount.denom,
|
||||
},
|
||||
};
|
||||
},
|
||||
@ -698,12 +736,11 @@ describe("SigningCosmWasmClient", () => {
|
||||
delegator_address,
|
||||
validator_address,
|
||||
amount,
|
||||
}: LaunchpadMsgDelegate["value"]): CustomMsgDelegate =>
|
||||
CustomMsgDelegate.create({
|
||||
custom_delegator_address: delegator_address,
|
||||
custom_validator_address: validator_address,
|
||||
custom_amount: Coin.create(amount),
|
||||
}),
|
||||
}: LaunchpadMsgDelegate["value"]): CustomMsgDelegate => ({
|
||||
customDelegatorAddress: delegator_address,
|
||||
customValidatorAddress: validator_address,
|
||||
customAmount: Coin.fromPartial(amount),
|
||||
}),
|
||||
},
|
||||
},
|
||||
});
|
||||
@ -711,9 +748,9 @@ describe("SigningCosmWasmClient", () => {
|
||||
const client = await SigningCosmWasmClient.connectWithSigner(wasmd.endpoint, wallet, options);
|
||||
|
||||
const msg = {
|
||||
custom_delegator_address: alice.address0,
|
||||
custom_validator_address: validator.validatorAddress,
|
||||
custom_amount: coin(1234, "ustake"),
|
||||
customDelegatorAddress: alice.address0,
|
||||
customValidatorAddress: validator.validatorAddress,
|
||||
customAmount: coin(1234, "ustake"),
|
||||
};
|
||||
const msgAny = {
|
||||
typeUrl: "/cosmos.staking.v1beta1.MsgDelegate",
|
||||
@ -740,7 +777,7 @@ describe("SigningCosmWasmClient", () => {
|
||||
amount: coin(1234, "ustake"),
|
||||
};
|
||||
const msgAny = {
|
||||
typeUrl: msgDelegateTypeUrl,
|
||||
typeUrl: "/cosmos.staking.v1beta1.MsgDelegate",
|
||||
value: msg,
|
||||
};
|
||||
const fee = {
|
||||
@ -758,8 +795,8 @@ describe("SigningCosmWasmClient", () => {
|
||||
const tx = Tx.decode(searchResult.tx);
|
||||
// From ModifyingSecp256k1HdWallet
|
||||
expect(tx.body!.memo).toEqual("This was modified");
|
||||
expect({ ...tx.authInfo!.fee!.amount![0] }).toEqual(coin(3000, "ucosm"));
|
||||
expect(tx.authInfo!.fee!.gasLimit!.toNumber()).toEqual(333333);
|
||||
expect({ ...tx.authInfo!.fee!.amount[0] }).toEqual(coin(3000, "ucosm"));
|
||||
expect(tx.authInfo!.fee!.gasLimit.toNumber()).toEqual(333333);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@ -38,29 +38,26 @@ import {
|
||||
AminoTypes,
|
||||
BroadcastTxFailure,
|
||||
BroadcastTxResponse,
|
||||
codec,
|
||||
defaultRegistryTypes,
|
||||
isBroadcastTxFailure,
|
||||
parseRawLog,
|
||||
} from "@cosmjs/stargate";
|
||||
import { SignMode } from "@cosmjs/stargate/build/codec/cosmos/tx/signing/v1beta1/signing";
|
||||
import { TxRaw } from "@cosmjs/stargate/build/codec/cosmos/tx/v1beta1/tx";
|
||||
import { adaptor34, Client as TendermintClient } from "@cosmjs/tendermint-rpc";
|
||||
import Long from "long";
|
||||
import pako from "pako";
|
||||
|
||||
import { cosmWasmTypes } from "./aminotypes";
|
||||
import { cosmwasm } from "./codec";
|
||||
import { CosmWasmClient } from "./cosmwasmclient";
|
||||
|
||||
const { SignMode } = codec.cosmos.tx.signing.v1beta1;
|
||||
const { TxRaw } = codec.cosmos.tx.v1beta1;
|
||||
const {
|
||||
import {
|
||||
MsgClearAdmin,
|
||||
MsgExecuteContract,
|
||||
MsgInstantiateContract,
|
||||
MsgMigrateContract,
|
||||
MsgStoreCode,
|
||||
MsgUpdateAdmin,
|
||||
} = cosmwasm.wasm.v1beta1;
|
||||
} from "./codec/x/wasm/internal/types/tx";
|
||||
import { CosmWasmClient } from "./cosmwasmclient";
|
||||
|
||||
function prepareBuilder(builder: string | undefined): string {
|
||||
if (builder === undefined) {
|
||||
@ -156,7 +153,7 @@ export class SigningCosmWasmClient extends CosmWasmClient {
|
||||
const compressed = pako.gzip(wasmCode, { level: 9 });
|
||||
const storeCodeMsg = {
|
||||
typeUrl: "/cosmwasm.wasm.v1beta1.MsgStoreCode",
|
||||
value: MsgStoreCode.create({
|
||||
value: MsgStoreCode.fromPartial({
|
||||
sender: senderAddress,
|
||||
wasmByteCode: compressed,
|
||||
source: source,
|
||||
@ -190,7 +187,7 @@ export class SigningCosmWasmClient extends CosmWasmClient {
|
||||
): Promise<InstantiateResult> {
|
||||
const instantiateMsg = {
|
||||
typeUrl: "/cosmwasm.wasm.v1beta1.MsgInstantiateContract",
|
||||
value: MsgInstantiateContract.create({
|
||||
value: MsgInstantiateContract.fromPartial({
|
||||
sender: senderAddress,
|
||||
codeId: Long.fromString(new Uint53(codeId).toString()),
|
||||
label: label,
|
||||
@ -220,7 +217,7 @@ export class SigningCosmWasmClient extends CosmWasmClient {
|
||||
): Promise<ChangeAdminResult> {
|
||||
const updateAdminMsg = {
|
||||
typeUrl: "/cosmwasm.wasm.v1beta1.MsgUpdateAdmin",
|
||||
value: MsgUpdateAdmin.create({
|
||||
value: MsgUpdateAdmin.fromPartial({
|
||||
sender: senderAddress,
|
||||
contract: contractAddress,
|
||||
newAdmin: newAdmin,
|
||||
@ -243,7 +240,7 @@ export class SigningCosmWasmClient extends CosmWasmClient {
|
||||
): Promise<ChangeAdminResult> {
|
||||
const clearAdminMsg = {
|
||||
typeUrl: "/cosmwasm.wasm.v1beta1.MsgClearAdmin",
|
||||
value: MsgClearAdmin.create({
|
||||
value: MsgClearAdmin.fromPartial({
|
||||
sender: senderAddress,
|
||||
contract: contractAddress,
|
||||
}),
|
||||
@ -267,7 +264,7 @@ export class SigningCosmWasmClient extends CosmWasmClient {
|
||||
): Promise<MigrateResult> {
|
||||
const msg = {
|
||||
typeUrl: "/cosmwasm.wasm.v1beta1.MsgMigrateContract",
|
||||
value: MsgMigrateContract.create({
|
||||
value: MsgMigrateContract.fromPartial({
|
||||
sender: senderAddress,
|
||||
contract: contractAddress,
|
||||
codeId: Long.fromString(new Uint53(codeId).toString()),
|
||||
@ -293,7 +290,7 @@ export class SigningCosmWasmClient extends CosmWasmClient {
|
||||
): Promise<ExecuteResult> {
|
||||
const executeMsg = {
|
||||
typeUrl: "/cosmwasm.wasm.v1beta1.MsgExecuteContract",
|
||||
value: MsgExecuteContract.create({
|
||||
value: MsgExecuteContract.fromPartial({
|
||||
sender: senderAddress,
|
||||
contract: contractAddress,
|
||||
msg: toAscii(JSON.stringify(handleMsg)),
|
||||
@ -372,7 +369,7 @@ export class SigningCosmWasmClient extends CosmWasmClient {
|
||||
const authInfoBytes = makeAuthInfoBytes([pubkeyAny], fee.amount, gasLimit, sequence);
|
||||
const signDoc = makeSignDoc(txBodyBytes, authInfoBytes, chainId, accountNumber);
|
||||
const { signature, signed } = await this.signer.signDirect(signerAddress, signDoc);
|
||||
const txRaw = TxRaw.create({
|
||||
const txRaw = TxRaw.fromPartial({
|
||||
bodyBytes: signed.bodyBytes,
|
||||
authInfoBytes: signed.authInfoBytes,
|
||||
signatures: [fromBase64(signature.signature)],
|
||||
@ -403,7 +400,7 @@ export class SigningCosmWasmClient extends CosmWasmClient {
|
||||
signedSequence,
|
||||
signMode,
|
||||
);
|
||||
const txRaw = TxRaw.create({
|
||||
const txRaw = TxRaw.fromPartial({
|
||||
bodyBytes: signedTxBodyBytes,
|
||||
authInfoBytes: signedAuthInfoBytes,
|
||||
signatures: [fromBase64(signature.signature)],
|
||||
|
||||
@ -12,20 +12,17 @@ import { DirectSecp256k1HdWallet, DirectSignResponse, makeAuthInfoBytes } from "
|
||||
import {
|
||||
AuthExtension,
|
||||
BankExtension,
|
||||
codec,
|
||||
QueryClient,
|
||||
setupAuthExtension,
|
||||
setupBankExtension,
|
||||
} from "@cosmjs/stargate";
|
||||
import { SignMode } from "@cosmjs/stargate/build/codec/cosmos/tx/signing/v1beta1/signing";
|
||||
import { AuthInfo, SignDoc, TxBody } from "@cosmjs/stargate/build/codec/cosmos/tx/v1beta1/tx";
|
||||
import { adaptor34, Client as TendermintClient } from "@cosmjs/tendermint-rpc";
|
||||
|
||||
import { setupWasmExtension, WasmExtension } from "./queries";
|
||||
import hackatom from "./testdata/contract.json";
|
||||
|
||||
type ISignDoc = codec.cosmos.tx.v1beta1.ISignDoc;
|
||||
const { AuthInfo, TxBody } = codec.cosmos.tx.v1beta1;
|
||||
const { SignMode } = codec.cosmos.tx.signing.v1beta1;
|
||||
|
||||
/** An internal testing type. SigningCosmWasmClient has a similar but different interface */
|
||||
export interface ContractUploadInstructions {
|
||||
/** The wasm bytecode */
|
||||
@ -268,15 +265,15 @@ export class ModifyingDirectSecp256k1HdWallet extends DirectSecp256k1HdWallet {
|
||||
);
|
||||
}
|
||||
|
||||
public async signDirect(address: string, signDoc: ISignDoc): Promise<DirectSignResponse> {
|
||||
const txBody = TxBody.decode(signDoc.bodyBytes!);
|
||||
const modifiedTxBody = TxBody.create({
|
||||
public async signDirect(address: string, signDoc: SignDoc): Promise<DirectSignResponse> {
|
||||
const txBody = TxBody.decode(signDoc.bodyBytes);
|
||||
const modifiedTxBody = TxBody.fromPartial({
|
||||
...txBody,
|
||||
memo: "This was modified",
|
||||
});
|
||||
const authInfo = AuthInfo.decode(signDoc.authInfoBytes!);
|
||||
const authInfo = AuthInfo.decode(signDoc.authInfoBytes);
|
||||
const pubkeys = authInfo.signerInfos.map((signerInfo) => signerInfo.publicKey!);
|
||||
const sequence = authInfo.signerInfos[0].sequence!.toNumber();
|
||||
const sequence = authInfo.signerInfos[0].sequence.toNumber();
|
||||
const modifiedFeeAmount = coins(3000, "ucosm");
|
||||
const modifiedGasLimit = 333333;
|
||||
const modifiedSignDoc = {
|
||||
|
||||
86
packages/cosmwasm-stargate/types/codec/cosmos/base/query/v1beta1/pagination.d.ts
vendored
Normal file
86
packages/cosmwasm-stargate/types/codec/cosmos/base/query/v1beta1/pagination.d.ts
vendored
Normal file
@ -0,0 +1,86 @@
|
||||
import Long from "long";
|
||||
import _m0 from "protobufjs/minimal";
|
||||
export declare const protobufPackage = "cosmos.base.query.v1beta1";
|
||||
/**
|
||||
* PageRequest is to be embedded in gRPC request messages for efficient
|
||||
* pagination. Ex:
|
||||
*
|
||||
* message SomeRequest {
|
||||
* Foo some_parameter = 1;
|
||||
* PageRequest pagination = 2;
|
||||
* }
|
||||
*/
|
||||
export interface PageRequest {
|
||||
/**
|
||||
* key is a value returned in PageResponse.next_key to begin
|
||||
* querying the next page most efficiently. Only one of offset or key
|
||||
* should be set.
|
||||
*/
|
||||
key: Uint8Array;
|
||||
/**
|
||||
* offset is a numeric offset that can be used when key is unavailable.
|
||||
* It is less efficient than using key. Only one of offset or key should
|
||||
* be set.
|
||||
*/
|
||||
offset: Long;
|
||||
/**
|
||||
* limit is the total number of results to be returned in the result page.
|
||||
* If left empty it will default to a value to be set by each app.
|
||||
*/
|
||||
limit: Long;
|
||||
/**
|
||||
* count_total is set to true to indicate that the result set should include
|
||||
* a count of the total number of items available for pagination in UIs.
|
||||
* count_total is only respected when offset is used. It is ignored when key
|
||||
* is set.
|
||||
*/
|
||||
countTotal: boolean;
|
||||
}
|
||||
/**
|
||||
* PageResponse is to be embedded in gRPC response messages where the
|
||||
* corresponding request message has used PageRequest.
|
||||
*
|
||||
* message SomeResponse {
|
||||
* repeated Bar results = 1;
|
||||
* PageResponse page = 2;
|
||||
* }
|
||||
*/
|
||||
export interface PageResponse {
|
||||
/**
|
||||
* next_key is the key to be passed to PageRequest.key to
|
||||
* query the next page most efficiently
|
||||
*/
|
||||
nextKey: Uint8Array;
|
||||
/**
|
||||
* total is total number of results available if PageRequest.count_total
|
||||
* was set, its value is undefined otherwise
|
||||
*/
|
||||
total: Long;
|
||||
}
|
||||
export declare const PageRequest: {
|
||||
encode(message: PageRequest, writer?: _m0.Writer): _m0.Writer;
|
||||
decode(input: _m0.Reader | Uint8Array, length?: number | undefined): PageRequest;
|
||||
fromJSON(object: any): PageRequest;
|
||||
fromPartial(object: DeepPartial<PageRequest>): PageRequest;
|
||||
toJSON(message: PageRequest): unknown;
|
||||
};
|
||||
export declare const PageResponse: {
|
||||
encode(message: PageResponse, writer?: _m0.Writer): _m0.Writer;
|
||||
decode(input: _m0.Reader | Uint8Array, length?: number | undefined): PageResponse;
|
||||
fromJSON(object: any): PageResponse;
|
||||
fromPartial(object: DeepPartial<PageResponse>): PageResponse;
|
||||
toJSON(message: PageResponse): unknown;
|
||||
};
|
||||
declare type Builtin = Date | Function | Uint8Array | string | number | undefined | Long;
|
||||
export declare type DeepPartial<T> = T extends Builtin
|
||||
? T
|
||||
: T extends Array<infer U>
|
||||
? Array<DeepPartial<U>>
|
||||
: T extends ReadonlyArray<infer U>
|
||||
? ReadonlyArray<DeepPartial<U>>
|
||||
: T extends {}
|
||||
? {
|
||||
[K in keyof T]?: DeepPartial<T[K]>;
|
||||
}
|
||||
: Partial<T>;
|
||||
export {};
|
||||
@ -0,0 +1,269 @@
|
||||
/* eslint-disable */
|
||||
import Long from "long";
|
||||
import _m0 from "protobufjs/minimal";
|
||||
|
||||
export const protobufPackage = "cosmos.base.query.v1beta1";
|
||||
|
||||
/**
|
||||
* PageRequest is to be embedded in gRPC request messages for efficient
|
||||
* pagination. Ex:
|
||||
*
|
||||
* message SomeRequest {
|
||||
* Foo some_parameter = 1;
|
||||
* PageRequest pagination = 2;
|
||||
* }
|
||||
*/
|
||||
export interface PageRequest {
|
||||
/**
|
||||
* key is a value returned in PageResponse.next_key to begin
|
||||
* querying the next page most efficiently. Only one of offset or key
|
||||
* should be set.
|
||||
*/
|
||||
key: Uint8Array;
|
||||
/**
|
||||
* offset is a numeric offset that can be used when key is unavailable.
|
||||
* It is less efficient than using key. Only one of offset or key should
|
||||
* be set.
|
||||
*/
|
||||
offset: Long;
|
||||
/**
|
||||
* limit is the total number of results to be returned in the result page.
|
||||
* If left empty it will default to a value to be set by each app.
|
||||
*/
|
||||
limit: Long;
|
||||
/**
|
||||
* count_total is set to true to indicate that the result set should include
|
||||
* a count of the total number of items available for pagination in UIs.
|
||||
* count_total is only respected when offset is used. It is ignored when key
|
||||
* is set.
|
||||
*/
|
||||
countTotal: boolean;
|
||||
}
|
||||
|
||||
/**
|
||||
* PageResponse is to be embedded in gRPC response messages where the
|
||||
* corresponding request message has used PageRequest.
|
||||
*
|
||||
* message SomeResponse {
|
||||
* repeated Bar results = 1;
|
||||
* PageResponse page = 2;
|
||||
* }
|
||||
*/
|
||||
export interface PageResponse {
|
||||
/**
|
||||
* next_key is the key to be passed to PageRequest.key to
|
||||
* query the next page most efficiently
|
||||
*/
|
||||
nextKey: Uint8Array;
|
||||
/**
|
||||
* total is total number of results available if PageRequest.count_total
|
||||
* was set, its value is undefined otherwise
|
||||
*/
|
||||
total: Long;
|
||||
}
|
||||
|
||||
const basePageRequest: object = { offset: Long.UZERO, limit: Long.UZERO, countTotal: false };
|
||||
|
||||
export const PageRequest = {
|
||||
encode(message: PageRequest, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer {
|
||||
writer.uint32(10).bytes(message.key);
|
||||
writer.uint32(16).uint64(message.offset);
|
||||
writer.uint32(24).uint64(message.limit);
|
||||
writer.uint32(32).bool(message.countTotal);
|
||||
return writer;
|
||||
},
|
||||
|
||||
decode(input: _m0.Reader | Uint8Array, length?: number): PageRequest {
|
||||
const reader = input instanceof Uint8Array ? new _m0.Reader(input) : input;
|
||||
let end = length === undefined ? reader.len : reader.pos + length;
|
||||
const message = { ...basePageRequest } as PageRequest;
|
||||
while (reader.pos < end) {
|
||||
const tag = reader.uint32();
|
||||
switch (tag >>> 3) {
|
||||
case 1:
|
||||
message.key = reader.bytes();
|
||||
break;
|
||||
case 2:
|
||||
message.offset = reader.uint64() as Long;
|
||||
break;
|
||||
case 3:
|
||||
message.limit = reader.uint64() as Long;
|
||||
break;
|
||||
case 4:
|
||||
message.countTotal = reader.bool();
|
||||
break;
|
||||
default:
|
||||
reader.skipType(tag & 7);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return message;
|
||||
},
|
||||
|
||||
fromJSON(object: any): PageRequest {
|
||||
const message = { ...basePageRequest } as PageRequest;
|
||||
if (object.key !== undefined && object.key !== null) {
|
||||
message.key = bytesFromBase64(object.key);
|
||||
}
|
||||
if (object.offset !== undefined && object.offset !== null) {
|
||||
message.offset = Long.fromString(object.offset);
|
||||
} else {
|
||||
message.offset = Long.UZERO;
|
||||
}
|
||||
if (object.limit !== undefined && object.limit !== null) {
|
||||
message.limit = Long.fromString(object.limit);
|
||||
} else {
|
||||
message.limit = Long.UZERO;
|
||||
}
|
||||
if (object.countTotal !== undefined && object.countTotal !== null) {
|
||||
message.countTotal = Boolean(object.countTotal);
|
||||
} else {
|
||||
message.countTotal = false;
|
||||
}
|
||||
return message;
|
||||
},
|
||||
|
||||
fromPartial(object: DeepPartial<PageRequest>): PageRequest {
|
||||
const message = { ...basePageRequest } as PageRequest;
|
||||
if (object.key !== undefined && object.key !== null) {
|
||||
message.key = object.key;
|
||||
} else {
|
||||
message.key = new Uint8Array();
|
||||
}
|
||||
if (object.offset !== undefined && object.offset !== null) {
|
||||
message.offset = object.offset as Long;
|
||||
} else {
|
||||
message.offset = Long.UZERO;
|
||||
}
|
||||
if (object.limit !== undefined && object.limit !== null) {
|
||||
message.limit = object.limit as Long;
|
||||
} else {
|
||||
message.limit = Long.UZERO;
|
||||
}
|
||||
if (object.countTotal !== undefined && object.countTotal !== null) {
|
||||
message.countTotal = object.countTotal;
|
||||
} else {
|
||||
message.countTotal = false;
|
||||
}
|
||||
return message;
|
||||
},
|
||||
|
||||
toJSON(message: PageRequest): unknown {
|
||||
const obj: any = {};
|
||||
message.key !== undefined &&
|
||||
(obj.key = base64FromBytes(message.key !== undefined ? message.key : new Uint8Array()));
|
||||
message.offset !== undefined && (obj.offset = (message.offset || Long.UZERO).toString());
|
||||
message.limit !== undefined && (obj.limit = (message.limit || Long.UZERO).toString());
|
||||
message.countTotal !== undefined && (obj.countTotal = message.countTotal);
|
||||
return obj;
|
||||
},
|
||||
};
|
||||
|
||||
const basePageResponse: object = { total: Long.UZERO };
|
||||
|
||||
export const PageResponse = {
|
||||
encode(message: PageResponse, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer {
|
||||
writer.uint32(10).bytes(message.nextKey);
|
||||
writer.uint32(16).uint64(message.total);
|
||||
return writer;
|
||||
},
|
||||
|
||||
decode(input: _m0.Reader | Uint8Array, length?: number): PageResponse {
|
||||
const reader = input instanceof Uint8Array ? new _m0.Reader(input) : input;
|
||||
let end = length === undefined ? reader.len : reader.pos + length;
|
||||
const message = { ...basePageResponse } as PageResponse;
|
||||
while (reader.pos < end) {
|
||||
const tag = reader.uint32();
|
||||
switch (tag >>> 3) {
|
||||
case 1:
|
||||
message.nextKey = reader.bytes();
|
||||
break;
|
||||
case 2:
|
||||
message.total = reader.uint64() as Long;
|
||||
break;
|
||||
default:
|
||||
reader.skipType(tag & 7);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return message;
|
||||
},
|
||||
|
||||
fromJSON(object: any): PageResponse {
|
||||
const message = { ...basePageResponse } as PageResponse;
|
||||
if (object.nextKey !== undefined && object.nextKey !== null) {
|
||||
message.nextKey = bytesFromBase64(object.nextKey);
|
||||
}
|
||||
if (object.total !== undefined && object.total !== null) {
|
||||
message.total = Long.fromString(object.total);
|
||||
} else {
|
||||
message.total = Long.UZERO;
|
||||
}
|
||||
return message;
|
||||
},
|
||||
|
||||
fromPartial(object: DeepPartial<PageResponse>): PageResponse {
|
||||
const message = { ...basePageResponse } as PageResponse;
|
||||
if (object.nextKey !== undefined && object.nextKey !== null) {
|
||||
message.nextKey = object.nextKey;
|
||||
} else {
|
||||
message.nextKey = new Uint8Array();
|
||||
}
|
||||
if (object.total !== undefined && object.total !== null) {
|
||||
message.total = object.total as Long;
|
||||
} else {
|
||||
message.total = Long.UZERO;
|
||||
}
|
||||
return message;
|
||||
},
|
||||
|
||||
toJSON(message: PageResponse): unknown {
|
||||
const obj: any = {};
|
||||
message.nextKey !== undefined &&
|
||||
(obj.nextKey = base64FromBytes(message.nextKey !== undefined ? message.nextKey : new Uint8Array()));
|
||||
message.total !== undefined && (obj.total = (message.total || Long.UZERO).toString());
|
||||
return obj;
|
||||
},
|
||||
};
|
||||
|
||||
declare var self: any | undefined;
|
||||
declare var window: any | undefined;
|
||||
var globalThis: any = (() => {
|
||||
if (typeof globalThis !== "undefined") return globalThis;
|
||||
if (typeof self !== "undefined") return self;
|
||||
if (typeof window !== "undefined") return window;
|
||||
if (typeof global !== "undefined") return global;
|
||||
throw new Error("Unable to locate global object");
|
||||
})();
|
||||
|
||||
const atob: (b64: string) => string =
|
||||
globalThis.atob || ((b64) => globalThis.Buffer.from(b64, "base64").toString("binary"));
|
||||
function bytesFromBase64(b64: string): Uint8Array {
|
||||
const bin = atob(b64);
|
||||
const arr = new Uint8Array(bin.length);
|
||||
for (let i = 0; i < bin.length; ++i) {
|
||||
arr[i] = bin.charCodeAt(i);
|
||||
}
|
||||
return arr;
|
||||
}
|
||||
|
||||
const btoa: (bin: string) => string =
|
||||
globalThis.btoa || ((bin) => globalThis.Buffer.from(bin, "binary").toString("base64"));
|
||||
function base64FromBytes(arr: Uint8Array): string {
|
||||
const bin: string[] = [];
|
||||
for (let i = 0; i < arr.byteLength; ++i) {
|
||||
bin.push(String.fromCharCode(arr[i]));
|
||||
}
|
||||
return btoa(bin.join(""));
|
||||
}
|
||||
|
||||
type Builtin = Date | Function | Uint8Array | string | number | undefined | Long;
|
||||
export type DeepPartial<T> = T extends Builtin
|
||||
? T
|
||||
: T extends Array<infer U>
|
||||
? Array<DeepPartial<U>>
|
||||
: T extends ReadonlyArray<infer U>
|
||||
? ReadonlyArray<DeepPartial<U>>
|
||||
: T extends {}
|
||||
? { [K in keyof T]?: DeepPartial<T[K]> }
|
||||
: Partial<T>;
|
||||
72
packages/cosmwasm-stargate/types/codec/cosmos/base/v1beta1/coin.d.ts
vendored
Normal file
72
packages/cosmwasm-stargate/types/codec/cosmos/base/v1beta1/coin.d.ts
vendored
Normal file
@ -0,0 +1,72 @@
|
||||
import Long from "long";
|
||||
import _m0 from "protobufjs/minimal";
|
||||
export declare const protobufPackage = "cosmos.base.v1beta1";
|
||||
/**
|
||||
* Coin defines a token with a denomination and an amount.
|
||||
*
|
||||
* NOTE: The amount field is an Int which implements the custom method
|
||||
* signatures required by gogoproto.
|
||||
*/
|
||||
export interface Coin {
|
||||
denom: string;
|
||||
amount: string;
|
||||
}
|
||||
/**
|
||||
* DecCoin defines a token with a denomination and a decimal amount.
|
||||
*
|
||||
* NOTE: The amount field is an Dec which implements the custom method
|
||||
* signatures required by gogoproto.
|
||||
*/
|
||||
export interface DecCoin {
|
||||
denom: string;
|
||||
amount: string;
|
||||
}
|
||||
/** IntProto defines a Protobuf wrapper around an Int object. */
|
||||
export interface IntProto {
|
||||
int: string;
|
||||
}
|
||||
/** DecProto defines a Protobuf wrapper around a Dec object. */
|
||||
export interface DecProto {
|
||||
dec: string;
|
||||
}
|
||||
export declare const Coin: {
|
||||
encode(message: Coin, writer?: _m0.Writer): _m0.Writer;
|
||||
decode(input: _m0.Reader | Uint8Array, length?: number | undefined): Coin;
|
||||
fromJSON(object: any): Coin;
|
||||
fromPartial(object: DeepPartial<Coin>): Coin;
|
||||
toJSON(message: Coin): unknown;
|
||||
};
|
||||
export declare const DecCoin: {
|
||||
encode(message: DecCoin, writer?: _m0.Writer): _m0.Writer;
|
||||
decode(input: _m0.Reader | Uint8Array, length?: number | undefined): DecCoin;
|
||||
fromJSON(object: any): DecCoin;
|
||||
fromPartial(object: DeepPartial<DecCoin>): DecCoin;
|
||||
toJSON(message: DecCoin): unknown;
|
||||
};
|
||||
export declare const IntProto: {
|
||||
encode(message: IntProto, writer?: _m0.Writer): _m0.Writer;
|
||||
decode(input: _m0.Reader | Uint8Array, length?: number | undefined): IntProto;
|
||||
fromJSON(object: any): IntProto;
|
||||
fromPartial(object: DeepPartial<IntProto>): IntProto;
|
||||
toJSON(message: IntProto): unknown;
|
||||
};
|
||||
export declare const DecProto: {
|
||||
encode(message: DecProto, writer?: _m0.Writer): _m0.Writer;
|
||||
decode(input: _m0.Reader | Uint8Array, length?: number | undefined): DecProto;
|
||||
fromJSON(object: any): DecProto;
|
||||
fromPartial(object: DeepPartial<DecProto>): DecProto;
|
||||
toJSON(message: DecProto): unknown;
|
||||
};
|
||||
declare type Builtin = Date | Function | Uint8Array | string | number | undefined | Long;
|
||||
export declare type DeepPartial<T> = T extends Builtin
|
||||
? T
|
||||
: T extends Array<infer U>
|
||||
? Array<DeepPartial<U>>
|
||||
: T extends ReadonlyArray<infer U>
|
||||
? ReadonlyArray<DeepPartial<U>>
|
||||
: T extends {}
|
||||
? {
|
||||
[K in keyof T]?: DeepPartial<T[K]>;
|
||||
}
|
||||
: Partial<T>;
|
||||
export {};
|
||||
@ -0,0 +1,290 @@
|
||||
/* eslint-disable */
|
||||
import Long from "long";
|
||||
import _m0 from "protobufjs/minimal";
|
||||
|
||||
export const protobufPackage = "cosmos.base.v1beta1";
|
||||
|
||||
/**
|
||||
* Coin defines a token with a denomination and an amount.
|
||||
*
|
||||
* NOTE: The amount field is an Int which implements the custom method
|
||||
* signatures required by gogoproto.
|
||||
*/
|
||||
export interface Coin {
|
||||
denom: string;
|
||||
amount: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* DecCoin defines a token with a denomination and a decimal amount.
|
||||
*
|
||||
* NOTE: The amount field is an Dec which implements the custom method
|
||||
* signatures required by gogoproto.
|
||||
*/
|
||||
export interface DecCoin {
|
||||
denom: string;
|
||||
amount: string;
|
||||
}
|
||||
|
||||
/** IntProto defines a Protobuf wrapper around an Int object. */
|
||||
export interface IntProto {
|
||||
int: string;
|
||||
}
|
||||
|
||||
/** DecProto defines a Protobuf wrapper around a Dec object. */
|
||||
export interface DecProto {
|
||||
dec: string;
|
||||
}
|
||||
|
||||
const baseCoin: object = { denom: "", amount: "" };
|
||||
|
||||
export const Coin = {
|
||||
encode(message: Coin, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer {
|
||||
writer.uint32(10).string(message.denom);
|
||||
writer.uint32(18).string(message.amount);
|
||||
return writer;
|
||||
},
|
||||
|
||||
decode(input: _m0.Reader | Uint8Array, length?: number): Coin {
|
||||
const reader = input instanceof Uint8Array ? new _m0.Reader(input) : input;
|
||||
let end = length === undefined ? reader.len : reader.pos + length;
|
||||
const message = { ...baseCoin } as Coin;
|
||||
while (reader.pos < end) {
|
||||
const tag = reader.uint32();
|
||||
switch (tag >>> 3) {
|
||||
case 1:
|
||||
message.denom = reader.string();
|
||||
break;
|
||||
case 2:
|
||||
message.amount = reader.string();
|
||||
break;
|
||||
default:
|
||||
reader.skipType(tag & 7);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return message;
|
||||
},
|
||||
|
||||
fromJSON(object: any): Coin {
|
||||
const message = { ...baseCoin } as Coin;
|
||||
if (object.denom !== undefined && object.denom !== null) {
|
||||
message.denom = String(object.denom);
|
||||
} else {
|
||||
message.denom = "";
|
||||
}
|
||||
if (object.amount !== undefined && object.amount !== null) {
|
||||
message.amount = String(object.amount);
|
||||
} else {
|
||||
message.amount = "";
|
||||
}
|
||||
return message;
|
||||
},
|
||||
|
||||
fromPartial(object: DeepPartial<Coin>): Coin {
|
||||
const message = { ...baseCoin } as Coin;
|
||||
if (object.denom !== undefined && object.denom !== null) {
|
||||
message.denom = object.denom;
|
||||
} else {
|
||||
message.denom = "";
|
||||
}
|
||||
if (object.amount !== undefined && object.amount !== null) {
|
||||
message.amount = object.amount;
|
||||
} else {
|
||||
message.amount = "";
|
||||
}
|
||||
return message;
|
||||
},
|
||||
|
||||
toJSON(message: Coin): unknown {
|
||||
const obj: any = {};
|
||||
message.denom !== undefined && (obj.denom = message.denom);
|
||||
message.amount !== undefined && (obj.amount = message.amount);
|
||||
return obj;
|
||||
},
|
||||
};
|
||||
|
||||
const baseDecCoin: object = { denom: "", amount: "" };
|
||||
|
||||
export const DecCoin = {
|
||||
encode(message: DecCoin, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer {
|
||||
writer.uint32(10).string(message.denom);
|
||||
writer.uint32(18).string(message.amount);
|
||||
return writer;
|
||||
},
|
||||
|
||||
decode(input: _m0.Reader | Uint8Array, length?: number): DecCoin {
|
||||
const reader = input instanceof Uint8Array ? new _m0.Reader(input) : input;
|
||||
let end = length === undefined ? reader.len : reader.pos + length;
|
||||
const message = { ...baseDecCoin } as DecCoin;
|
||||
while (reader.pos < end) {
|
||||
const tag = reader.uint32();
|
||||
switch (tag >>> 3) {
|
||||
case 1:
|
||||
message.denom = reader.string();
|
||||
break;
|
||||
case 2:
|
||||
message.amount = reader.string();
|
||||
break;
|
||||
default:
|
||||
reader.skipType(tag & 7);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return message;
|
||||
},
|
||||
|
||||
fromJSON(object: any): DecCoin {
|
||||
const message = { ...baseDecCoin } as DecCoin;
|
||||
if (object.denom !== undefined && object.denom !== null) {
|
||||
message.denom = String(object.denom);
|
||||
} else {
|
||||
message.denom = "";
|
||||
}
|
||||
if (object.amount !== undefined && object.amount !== null) {
|
||||
message.amount = String(object.amount);
|
||||
} else {
|
||||
message.amount = "";
|
||||
}
|
||||
return message;
|
||||
},
|
||||
|
||||
fromPartial(object: DeepPartial<DecCoin>): DecCoin {
|
||||
const message = { ...baseDecCoin } as DecCoin;
|
||||
if (object.denom !== undefined && object.denom !== null) {
|
||||
message.denom = object.denom;
|
||||
} else {
|
||||
message.denom = "";
|
||||
}
|
||||
if (object.amount !== undefined && object.amount !== null) {
|
||||
message.amount = object.amount;
|
||||
} else {
|
||||
message.amount = "";
|
||||
}
|
||||
return message;
|
||||
},
|
||||
|
||||
toJSON(message: DecCoin): unknown {
|
||||
const obj: any = {};
|
||||
message.denom !== undefined && (obj.denom = message.denom);
|
||||
message.amount !== undefined && (obj.amount = message.amount);
|
||||
return obj;
|
||||
},
|
||||
};
|
||||
|
||||
const baseIntProto: object = { int: "" };
|
||||
|
||||
export const IntProto = {
|
||||
encode(message: IntProto, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer {
|
||||
writer.uint32(10).string(message.int);
|
||||
return writer;
|
||||
},
|
||||
|
||||
decode(input: _m0.Reader | Uint8Array, length?: number): IntProto {
|
||||
const reader = input instanceof Uint8Array ? new _m0.Reader(input) : input;
|
||||
let end = length === undefined ? reader.len : reader.pos + length;
|
||||
const message = { ...baseIntProto } as IntProto;
|
||||
while (reader.pos < end) {
|
||||
const tag = reader.uint32();
|
||||
switch (tag >>> 3) {
|
||||
case 1:
|
||||
message.int = reader.string();
|
||||
break;
|
||||
default:
|
||||
reader.skipType(tag & 7);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return message;
|
||||
},
|
||||
|
||||
fromJSON(object: any): IntProto {
|
||||
const message = { ...baseIntProto } as IntProto;
|
||||
if (object.int !== undefined && object.int !== null) {
|
||||
message.int = String(object.int);
|
||||
} else {
|
||||
message.int = "";
|
||||
}
|
||||
return message;
|
||||
},
|
||||
|
||||
fromPartial(object: DeepPartial<IntProto>): IntProto {
|
||||
const message = { ...baseIntProto } as IntProto;
|
||||
if (object.int !== undefined && object.int !== null) {
|
||||
message.int = object.int;
|
||||
} else {
|
||||
message.int = "";
|
||||
}
|
||||
return message;
|
||||
},
|
||||
|
||||
toJSON(message: IntProto): unknown {
|
||||
const obj: any = {};
|
||||
message.int !== undefined && (obj.int = message.int);
|
||||
return obj;
|
||||
},
|
||||
};
|
||||
|
||||
const baseDecProto: object = { dec: "" };
|
||||
|
||||
export const DecProto = {
|
||||
encode(message: DecProto, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer {
|
||||
writer.uint32(10).string(message.dec);
|
||||
return writer;
|
||||
},
|
||||
|
||||
decode(input: _m0.Reader | Uint8Array, length?: number): DecProto {
|
||||
const reader = input instanceof Uint8Array ? new _m0.Reader(input) : input;
|
||||
let end = length === undefined ? reader.len : reader.pos + length;
|
||||
const message = { ...baseDecProto } as DecProto;
|
||||
while (reader.pos < end) {
|
||||
const tag = reader.uint32();
|
||||
switch (tag >>> 3) {
|
||||
case 1:
|
||||
message.dec = reader.string();
|
||||
break;
|
||||
default:
|
||||
reader.skipType(tag & 7);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return message;
|
||||
},
|
||||
|
||||
fromJSON(object: any): DecProto {
|
||||
const message = { ...baseDecProto } as DecProto;
|
||||
if (object.dec !== undefined && object.dec !== null) {
|
||||
message.dec = String(object.dec);
|
||||
} else {
|
||||
message.dec = "";
|
||||
}
|
||||
return message;
|
||||
},
|
||||
|
||||
fromPartial(object: DeepPartial<DecProto>): DecProto {
|
||||
const message = { ...baseDecProto } as DecProto;
|
||||
if (object.dec !== undefined && object.dec !== null) {
|
||||
message.dec = object.dec;
|
||||
} else {
|
||||
message.dec = "";
|
||||
}
|
||||
return message;
|
||||
},
|
||||
|
||||
toJSON(message: DecProto): unknown {
|
||||
const obj: any = {};
|
||||
message.dec !== undefined && (obj.dec = message.dec);
|
||||
return obj;
|
||||
},
|
||||
};
|
||||
|
||||
type Builtin = Date | Function | Uint8Array | string | number | undefined | Long;
|
||||
export type DeepPartial<T> = T extends Builtin
|
||||
? T
|
||||
: T extends Array<infer U>
|
||||
? Array<DeepPartial<U>>
|
||||
: T extends ReadonlyArray<infer U>
|
||||
? ReadonlyArray<DeepPartial<U>>
|
||||
: T extends {}
|
||||
? { [K in keyof T]?: DeepPartial<T[K]> }
|
||||
: Partial<T>;
|
||||
File diff suppressed because it is too large
Load Diff
@ -1 +0,0 @@
|
||||
export { cosmwasm } from "./generated/codecimpl";
|
||||
286
packages/cosmwasm-stargate/types/codec/x/wasm/internal/types/query.d.ts
vendored
Normal file
286
packages/cosmwasm-stargate/types/codec/x/wasm/internal/types/query.d.ts
vendored
Normal file
@ -0,0 +1,286 @@
|
||||
import { ContractInfo, ContractCodeHistoryEntry, Model } from "../../../../x/wasm/internal/types/types";
|
||||
import { PageRequest, PageResponse } from "../../../../cosmos/base/query/v1beta1/pagination";
|
||||
import Long from "long";
|
||||
import _m0 from "protobufjs/minimal";
|
||||
export declare const protobufPackage = "cosmwasm.wasm.v1beta1";
|
||||
/** QueryContractInfoRequest is the request type for the Query/ContractInfo RPC method */
|
||||
export interface QueryContractInfoRequest {
|
||||
/** address is the address of the contract to query */
|
||||
address: string;
|
||||
}
|
||||
/** QueryContractInfoResponse is the response type for the Query/ContractInfo RPC method */
|
||||
export interface QueryContractInfoResponse {
|
||||
/** address is the address of the contract */
|
||||
address: string;
|
||||
contractInfo?: ContractInfo;
|
||||
}
|
||||
/** QueryContractHistoryRequest is the request type for the Query/ContractHistory RPC method */
|
||||
export interface QueryContractHistoryRequest {
|
||||
/** address is the address of the contract to query */
|
||||
address: string;
|
||||
/** pagination defines an optional pagination for the request. */
|
||||
pagination?: PageRequest;
|
||||
}
|
||||
/** QueryContractHistoryResponse is the response type for the Query/ContractHistory RPC method */
|
||||
export interface QueryContractHistoryResponse {
|
||||
entries: ContractCodeHistoryEntry[];
|
||||
/** pagination defines the pagination in the response. */
|
||||
pagination?: PageResponse;
|
||||
}
|
||||
/** QueryContractsByCodeRequest is the request type for the Query/ContractsByCode RPC method */
|
||||
export interface QueryContractsByCodeRequest {
|
||||
/** grpc-gateway_out does not support Go style CodID */
|
||||
codeId: Long;
|
||||
/** pagination defines an optional pagination for the request. */
|
||||
pagination?: PageRequest;
|
||||
}
|
||||
/** ContractInfoWithAddress adds the address (key) to the ContractInfo representation */
|
||||
export interface ContractInfoWithAddress {
|
||||
address: string;
|
||||
contractInfo?: ContractInfo;
|
||||
}
|
||||
/** QueryContractsByCodeResponse is the response type for the Query/ContractsByCode RPC method */
|
||||
export interface QueryContractsByCodeResponse {
|
||||
contractInfos: ContractInfoWithAddress[];
|
||||
/** pagination defines the pagination in the response. */
|
||||
pagination?: PageResponse;
|
||||
}
|
||||
/** QueryAllContractStateRequest is the request type for the Query/AllContractState RPC method */
|
||||
export interface QueryAllContractStateRequest {
|
||||
/** address is the address of the contract */
|
||||
address: string;
|
||||
/** pagination defines an optional pagination for the request. */
|
||||
pagination?: PageRequest;
|
||||
}
|
||||
/** QueryAllContractStateResponse is the response type for the Query/AllContractState RPC method */
|
||||
export interface QueryAllContractStateResponse {
|
||||
models: Model[];
|
||||
/** pagination defines the pagination in the response. */
|
||||
pagination?: PageResponse;
|
||||
}
|
||||
/** QueryRawContractStateRequest is the request type for the Query/RawContractState RPC method */
|
||||
export interface QueryRawContractStateRequest {
|
||||
/** address is the address of the contract */
|
||||
address: string;
|
||||
queryData: Uint8Array;
|
||||
}
|
||||
/** QueryRawContractStateResponse is the response type for the Query/RawContractState RPC method */
|
||||
export interface QueryRawContractStateResponse {
|
||||
/** Data contains the raw store data */
|
||||
data: Uint8Array;
|
||||
}
|
||||
/** QuerySmartContractStateRequest is the request type for the Query/SmartContractState RPC method */
|
||||
export interface QuerySmartContractStateRequest {
|
||||
/** address is the address of the contract */
|
||||
address: string;
|
||||
/** QueryData contains the query data passed to the contract */
|
||||
queryData: Uint8Array;
|
||||
}
|
||||
/** QuerySmartContractStateResponse is the response type for the Query/SmartContractState RPC method */
|
||||
export interface QuerySmartContractStateResponse {
|
||||
/** Data contains the json data returned from the smart contract */
|
||||
data: Uint8Array;
|
||||
}
|
||||
/** QueryCodeRequest is the request type for the Query/Code RPC method */
|
||||
export interface QueryCodeRequest {
|
||||
/** grpc-gateway_out does not support Go style CodID */
|
||||
codeId: Long;
|
||||
}
|
||||
/** CodeInfoResponse contains code meta data from CodeInfo */
|
||||
export interface CodeInfoResponse {
|
||||
/** id for legacy support */
|
||||
codeId: Long;
|
||||
creator: string;
|
||||
dataHash: Uint8Array;
|
||||
source: string;
|
||||
builder: string;
|
||||
}
|
||||
/** QueryCodeResponse is the response type for the Query/Code RPC method */
|
||||
export interface QueryCodeResponse {
|
||||
codeInfo?: CodeInfoResponse;
|
||||
data: Uint8Array;
|
||||
}
|
||||
/** QueryCodesRequest is the request type for the Query/Codes RPC method */
|
||||
export interface QueryCodesRequest {
|
||||
/** pagination defines an optional pagination for the request. */
|
||||
pagination?: PageRequest;
|
||||
}
|
||||
/** QueryCodesResponse is the response type for the Query/Codes RPC method */
|
||||
export interface QueryCodesResponse {
|
||||
codeInfos: CodeInfoResponse[];
|
||||
/** pagination defines the pagination in the response. */
|
||||
pagination?: PageResponse;
|
||||
}
|
||||
export declare const QueryContractInfoRequest: {
|
||||
encode(message: QueryContractInfoRequest, writer?: _m0.Writer): _m0.Writer;
|
||||
decode(input: _m0.Reader | Uint8Array, length?: number | undefined): QueryContractInfoRequest;
|
||||
fromJSON(object: any): QueryContractInfoRequest;
|
||||
fromPartial(object: DeepPartial<QueryContractInfoRequest>): QueryContractInfoRequest;
|
||||
toJSON(message: QueryContractInfoRequest): unknown;
|
||||
};
|
||||
export declare const QueryContractInfoResponse: {
|
||||
encode(message: QueryContractInfoResponse, writer?: _m0.Writer): _m0.Writer;
|
||||
decode(input: _m0.Reader | Uint8Array, length?: number | undefined): QueryContractInfoResponse;
|
||||
fromJSON(object: any): QueryContractInfoResponse;
|
||||
fromPartial(object: DeepPartial<QueryContractInfoResponse>): QueryContractInfoResponse;
|
||||
toJSON(message: QueryContractInfoResponse): unknown;
|
||||
};
|
||||
export declare const QueryContractHistoryRequest: {
|
||||
encode(message: QueryContractHistoryRequest, writer?: _m0.Writer): _m0.Writer;
|
||||
decode(input: _m0.Reader | Uint8Array, length?: number | undefined): QueryContractHistoryRequest;
|
||||
fromJSON(object: any): QueryContractHistoryRequest;
|
||||
fromPartial(object: DeepPartial<QueryContractHistoryRequest>): QueryContractHistoryRequest;
|
||||
toJSON(message: QueryContractHistoryRequest): unknown;
|
||||
};
|
||||
export declare const QueryContractHistoryResponse: {
|
||||
encode(message: QueryContractHistoryResponse, writer?: _m0.Writer): _m0.Writer;
|
||||
decode(input: _m0.Reader | Uint8Array, length?: number | undefined): QueryContractHistoryResponse;
|
||||
fromJSON(object: any): QueryContractHistoryResponse;
|
||||
fromPartial(object: DeepPartial<QueryContractHistoryResponse>): QueryContractHistoryResponse;
|
||||
toJSON(message: QueryContractHistoryResponse): unknown;
|
||||
};
|
||||
export declare const QueryContractsByCodeRequest: {
|
||||
encode(message: QueryContractsByCodeRequest, writer?: _m0.Writer): _m0.Writer;
|
||||
decode(input: _m0.Reader | Uint8Array, length?: number | undefined): QueryContractsByCodeRequest;
|
||||
fromJSON(object: any): QueryContractsByCodeRequest;
|
||||
fromPartial(object: DeepPartial<QueryContractsByCodeRequest>): QueryContractsByCodeRequest;
|
||||
toJSON(message: QueryContractsByCodeRequest): unknown;
|
||||
};
|
||||
export declare const ContractInfoWithAddress: {
|
||||
encode(message: ContractInfoWithAddress, writer?: _m0.Writer): _m0.Writer;
|
||||
decode(input: _m0.Reader | Uint8Array, length?: number | undefined): ContractInfoWithAddress;
|
||||
fromJSON(object: any): ContractInfoWithAddress;
|
||||
fromPartial(object: DeepPartial<ContractInfoWithAddress>): ContractInfoWithAddress;
|
||||
toJSON(message: ContractInfoWithAddress): unknown;
|
||||
};
|
||||
export declare const QueryContractsByCodeResponse: {
|
||||
encode(message: QueryContractsByCodeResponse, writer?: _m0.Writer): _m0.Writer;
|
||||
decode(input: _m0.Reader | Uint8Array, length?: number | undefined): QueryContractsByCodeResponse;
|
||||
fromJSON(object: any): QueryContractsByCodeResponse;
|
||||
fromPartial(object: DeepPartial<QueryContractsByCodeResponse>): QueryContractsByCodeResponse;
|
||||
toJSON(message: QueryContractsByCodeResponse): unknown;
|
||||
};
|
||||
export declare const QueryAllContractStateRequest: {
|
||||
encode(message: QueryAllContractStateRequest, writer?: _m0.Writer): _m0.Writer;
|
||||
decode(input: _m0.Reader | Uint8Array, length?: number | undefined): QueryAllContractStateRequest;
|
||||
fromJSON(object: any): QueryAllContractStateRequest;
|
||||
fromPartial(object: DeepPartial<QueryAllContractStateRequest>): QueryAllContractStateRequest;
|
||||
toJSON(message: QueryAllContractStateRequest): unknown;
|
||||
};
|
||||
export declare const QueryAllContractStateResponse: {
|
||||
encode(message: QueryAllContractStateResponse, writer?: _m0.Writer): _m0.Writer;
|
||||
decode(input: _m0.Reader | Uint8Array, length?: number | undefined): QueryAllContractStateResponse;
|
||||
fromJSON(object: any): QueryAllContractStateResponse;
|
||||
fromPartial(object: DeepPartial<QueryAllContractStateResponse>): QueryAllContractStateResponse;
|
||||
toJSON(message: QueryAllContractStateResponse): unknown;
|
||||
};
|
||||
export declare const QueryRawContractStateRequest: {
|
||||
encode(message: QueryRawContractStateRequest, writer?: _m0.Writer): _m0.Writer;
|
||||
decode(input: _m0.Reader | Uint8Array, length?: number | undefined): QueryRawContractStateRequest;
|
||||
fromJSON(object: any): QueryRawContractStateRequest;
|
||||
fromPartial(object: DeepPartial<QueryRawContractStateRequest>): QueryRawContractStateRequest;
|
||||
toJSON(message: QueryRawContractStateRequest): unknown;
|
||||
};
|
||||
export declare const QueryRawContractStateResponse: {
|
||||
encode(message: QueryRawContractStateResponse, writer?: _m0.Writer): _m0.Writer;
|
||||
decode(input: _m0.Reader | Uint8Array, length?: number | undefined): QueryRawContractStateResponse;
|
||||
fromJSON(object: any): QueryRawContractStateResponse;
|
||||
fromPartial(object: DeepPartial<QueryRawContractStateResponse>): QueryRawContractStateResponse;
|
||||
toJSON(message: QueryRawContractStateResponse): unknown;
|
||||
};
|
||||
export declare const QuerySmartContractStateRequest: {
|
||||
encode(message: QuerySmartContractStateRequest, writer?: _m0.Writer): _m0.Writer;
|
||||
decode(input: _m0.Reader | Uint8Array, length?: number | undefined): QuerySmartContractStateRequest;
|
||||
fromJSON(object: any): QuerySmartContractStateRequest;
|
||||
fromPartial(object: DeepPartial<QuerySmartContractStateRequest>): QuerySmartContractStateRequest;
|
||||
toJSON(message: QuerySmartContractStateRequest): unknown;
|
||||
};
|
||||
export declare const QuerySmartContractStateResponse: {
|
||||
encode(message: QuerySmartContractStateResponse, writer?: _m0.Writer): _m0.Writer;
|
||||
decode(input: _m0.Reader | Uint8Array, length?: number | undefined): QuerySmartContractStateResponse;
|
||||
fromJSON(object: any): QuerySmartContractStateResponse;
|
||||
fromPartial(object: DeepPartial<QuerySmartContractStateResponse>): QuerySmartContractStateResponse;
|
||||
toJSON(message: QuerySmartContractStateResponse): unknown;
|
||||
};
|
||||
export declare const QueryCodeRequest: {
|
||||
encode(message: QueryCodeRequest, writer?: _m0.Writer): _m0.Writer;
|
||||
decode(input: _m0.Reader | Uint8Array, length?: number | undefined): QueryCodeRequest;
|
||||
fromJSON(object: any): QueryCodeRequest;
|
||||
fromPartial(object: DeepPartial<QueryCodeRequest>): QueryCodeRequest;
|
||||
toJSON(message: QueryCodeRequest): unknown;
|
||||
};
|
||||
export declare const CodeInfoResponse: {
|
||||
encode(message: CodeInfoResponse, writer?: _m0.Writer): _m0.Writer;
|
||||
decode(input: _m0.Reader | Uint8Array, length?: number | undefined): CodeInfoResponse;
|
||||
fromJSON(object: any): CodeInfoResponse;
|
||||
fromPartial(object: DeepPartial<CodeInfoResponse>): CodeInfoResponse;
|
||||
toJSON(message: CodeInfoResponse): unknown;
|
||||
};
|
||||
export declare const QueryCodeResponse: {
|
||||
encode(message: QueryCodeResponse, writer?: _m0.Writer): _m0.Writer;
|
||||
decode(input: _m0.Reader | Uint8Array, length?: number | undefined): QueryCodeResponse;
|
||||
fromJSON(object: any): QueryCodeResponse;
|
||||
fromPartial(object: DeepPartial<QueryCodeResponse>): QueryCodeResponse;
|
||||
toJSON(message: QueryCodeResponse): unknown;
|
||||
};
|
||||
export declare const QueryCodesRequest: {
|
||||
encode(message: QueryCodesRequest, writer?: _m0.Writer): _m0.Writer;
|
||||
decode(input: _m0.Reader | Uint8Array, length?: number | undefined): QueryCodesRequest;
|
||||
fromJSON(object: any): QueryCodesRequest;
|
||||
fromPartial(object: DeepPartial<QueryCodesRequest>): QueryCodesRequest;
|
||||
toJSON(message: QueryCodesRequest): unknown;
|
||||
};
|
||||
export declare const QueryCodesResponse: {
|
||||
encode(message: QueryCodesResponse, writer?: _m0.Writer): _m0.Writer;
|
||||
decode(input: _m0.Reader | Uint8Array, length?: number | undefined): QueryCodesResponse;
|
||||
fromJSON(object: any): QueryCodesResponse;
|
||||
fromPartial(object: DeepPartial<QueryCodesResponse>): QueryCodesResponse;
|
||||
toJSON(message: QueryCodesResponse): unknown;
|
||||
};
|
||||
/** Query provides defines the gRPC querier service */
|
||||
export interface Query {
|
||||
/** ContractInfo gets the contract meta data */
|
||||
ContractInfo(request: QueryContractInfoRequest): Promise<QueryContractInfoResponse>;
|
||||
/** ContractHistory gets the contract code history */
|
||||
ContractHistory(request: QueryContractHistoryRequest): Promise<QueryContractHistoryResponse>;
|
||||
/** ContractsByCode lists all smart contracts for a code id */
|
||||
ContractsByCode(request: QueryContractsByCodeRequest): Promise<QueryContractsByCodeResponse>;
|
||||
/** AllContractState gets all raw store data for a single contract */
|
||||
AllContractState(request: QueryAllContractStateRequest): Promise<QueryAllContractStateResponse>;
|
||||
/** RawContractState gets single key from the raw store data of a contract */
|
||||
RawContractState(request: QueryRawContractStateRequest): Promise<QueryRawContractStateResponse>;
|
||||
/** SmartContractState get smart query result from the contract */
|
||||
SmartContractState(request: QuerySmartContractStateRequest): Promise<QuerySmartContractStateResponse>;
|
||||
/** Code gets the binary code and metadata for a singe wasm code */
|
||||
Code(request: QueryCodeRequest): Promise<QueryCodeResponse>;
|
||||
/** Codes gets the metadata for all stored wasm codes */
|
||||
Codes(request: QueryCodesRequest): Promise<QueryCodesResponse>;
|
||||
}
|
||||
export declare class QueryClientImpl implements Query {
|
||||
private readonly rpc;
|
||||
constructor(rpc: Rpc);
|
||||
ContractInfo(request: QueryContractInfoRequest): Promise<QueryContractInfoResponse>;
|
||||
ContractHistory(request: QueryContractHistoryRequest): Promise<QueryContractHistoryResponse>;
|
||||
ContractsByCode(request: QueryContractsByCodeRequest): Promise<QueryContractsByCodeResponse>;
|
||||
AllContractState(request: QueryAllContractStateRequest): Promise<QueryAllContractStateResponse>;
|
||||
RawContractState(request: QueryRawContractStateRequest): Promise<QueryRawContractStateResponse>;
|
||||
SmartContractState(request: QuerySmartContractStateRequest): Promise<QuerySmartContractStateResponse>;
|
||||
Code(request: QueryCodeRequest): Promise<QueryCodeResponse>;
|
||||
Codes(request: QueryCodesRequest): Promise<QueryCodesResponse>;
|
||||
}
|
||||
interface Rpc {
|
||||
request(service: string, method: string, data: Uint8Array): Promise<Uint8Array>;
|
||||
}
|
||||
declare type Builtin = Date | Function | Uint8Array | string | number | undefined | Long;
|
||||
export declare type DeepPartial<T> = T extends Builtin
|
||||
? T
|
||||
: T extends Array<infer U>
|
||||
? Array<DeepPartial<U>>
|
||||
: T extends ReadonlyArray<infer U>
|
||||
? ReadonlyArray<DeepPartial<U>>
|
||||
: T extends {}
|
||||
? {
|
||||
[K in keyof T]?: DeepPartial<T[K]>;
|
||||
}
|
||||
: Partial<T>;
|
||||
export {};
|
||||
File diff suppressed because it is too large
Load Diff
223
packages/cosmwasm-stargate/types/codec/x/wasm/internal/types/tx.d.ts
vendored
Normal file
223
packages/cosmwasm-stargate/types/codec/x/wasm/internal/types/tx.d.ts
vendored
Normal file
@ -0,0 +1,223 @@
|
||||
import { AccessConfig } from "../../../../x/wasm/internal/types/types";
|
||||
import Long from "long";
|
||||
import { Coin } from "../../../../cosmos/base/v1beta1/coin";
|
||||
import _m0 from "protobufjs/minimal";
|
||||
export declare const protobufPackage = "cosmwasm.wasm.v1beta1";
|
||||
/** MsgStoreCode submit Wasm code to the system */
|
||||
export interface MsgStoreCode {
|
||||
/** Sender is the that actor that signed the messages */
|
||||
sender: string;
|
||||
/** WASMByteCode can be raw or gzip compressed */
|
||||
wasmByteCode: Uint8Array;
|
||||
/** Source is a valid absolute HTTPS URI to the contract's source code, optional */
|
||||
source: string;
|
||||
/** Builder is a valid docker image name with tag, optional */
|
||||
builder: string;
|
||||
/** InstantiatePermission access control to apply on contract creation, optional */
|
||||
instantiatePermission?: AccessConfig;
|
||||
}
|
||||
/** MsgStoreCodeResponse returns store result data. */
|
||||
export interface MsgStoreCodeResponse {
|
||||
/** CodeID is the reference to the stored WASM code */
|
||||
codeId: Long;
|
||||
}
|
||||
/** MsgInstantiateContract create a new smart contract instance for the given code id. */
|
||||
export interface MsgInstantiateContract {
|
||||
/** Sender is the that actor that signed the messages */
|
||||
sender: string;
|
||||
/** Admin is an optional address that can execute migrations */
|
||||
admin: string;
|
||||
/** CodeID is the reference to the stored WASM code */
|
||||
codeId: Long;
|
||||
/** Label is optional metadata to be stored with a contract instance. */
|
||||
label: string;
|
||||
/** InitMsg json encoded message to be passed to the contract on instantiation */
|
||||
initMsg: Uint8Array;
|
||||
/** InitFunds coins that are transferred to the contract on instantiation */
|
||||
initFunds: Coin[];
|
||||
}
|
||||
/** MsgInstantiateContractResponse return instantiation result data */
|
||||
export interface MsgInstantiateContractResponse {
|
||||
/** Address is the bech32 address of the new contract instance. */
|
||||
address: string;
|
||||
}
|
||||
/** MsgExecuteContract submits the given message data to a smart contract */
|
||||
export interface MsgExecuteContract {
|
||||
/** Sender is the that actor that signed the messages */
|
||||
sender: string;
|
||||
/** Contract is the address of the smart contract */
|
||||
contract: string;
|
||||
/** Msg json encoded message to be passed to the contract */
|
||||
msg: Uint8Array;
|
||||
/** SentFunds coins that are transferred to the contract on execution */
|
||||
sentFunds: Coin[];
|
||||
}
|
||||
/** MsgExecuteContractResponse returns execution result data. */
|
||||
export interface MsgExecuteContractResponse {
|
||||
/** Data contains base64-encoded bytes to returned from the contract */
|
||||
data: Uint8Array;
|
||||
}
|
||||
/** MsgMigrateContract runs a code upgrade/ downgrade for a smart contract */
|
||||
export interface MsgMigrateContract {
|
||||
/** Sender is the that actor that signed the messages */
|
||||
sender: string;
|
||||
/** Contract is the address of the smart contract */
|
||||
contract: string;
|
||||
/** CodeID references the new WASM code */
|
||||
codeId: Long;
|
||||
/** MigrateMsg json encoded message to be passed to the contract on migration */
|
||||
migrateMsg: Uint8Array;
|
||||
}
|
||||
/** MsgMigrateContractResponse returns contract migration result data. */
|
||||
export interface MsgMigrateContractResponse {
|
||||
/**
|
||||
* Data contains same raw bytes returned as data from the wasm contract.
|
||||
* (May be empty)
|
||||
*/
|
||||
data: Uint8Array;
|
||||
}
|
||||
/** MsgUpdateAdmin sets a new admin for a smart contract */
|
||||
export interface MsgUpdateAdmin {
|
||||
/** Sender is the that actor that signed the messages */
|
||||
sender: string;
|
||||
/** NewAdmin address to be set */
|
||||
newAdmin: string;
|
||||
/** Contract is the address of the smart contract */
|
||||
contract: string;
|
||||
}
|
||||
/** MsgUpdateAdminResponse returns empty data */
|
||||
export interface MsgUpdateAdminResponse {}
|
||||
/** MsgClearAdmin removes any admin stored for a smart contract */
|
||||
export interface MsgClearAdmin {
|
||||
/** Sender is the that actor that signed the messages */
|
||||
sender: string;
|
||||
/** Contract is the address of the smart contract */
|
||||
contract: string;
|
||||
}
|
||||
/** MsgClearAdminResponse returns empty data */
|
||||
export interface MsgClearAdminResponse {}
|
||||
export declare const MsgStoreCode: {
|
||||
encode(message: MsgStoreCode, writer?: _m0.Writer): _m0.Writer;
|
||||
decode(input: _m0.Reader | Uint8Array, length?: number | undefined): MsgStoreCode;
|
||||
fromJSON(object: any): MsgStoreCode;
|
||||
fromPartial(object: DeepPartial<MsgStoreCode>): MsgStoreCode;
|
||||
toJSON(message: MsgStoreCode): unknown;
|
||||
};
|
||||
export declare const MsgStoreCodeResponse: {
|
||||
encode(message: MsgStoreCodeResponse, writer?: _m0.Writer): _m0.Writer;
|
||||
decode(input: _m0.Reader | Uint8Array, length?: number | undefined): MsgStoreCodeResponse;
|
||||
fromJSON(object: any): MsgStoreCodeResponse;
|
||||
fromPartial(object: DeepPartial<MsgStoreCodeResponse>): MsgStoreCodeResponse;
|
||||
toJSON(message: MsgStoreCodeResponse): unknown;
|
||||
};
|
||||
export declare const MsgInstantiateContract: {
|
||||
encode(message: MsgInstantiateContract, writer?: _m0.Writer): _m0.Writer;
|
||||
decode(input: _m0.Reader | Uint8Array, length?: number | undefined): MsgInstantiateContract;
|
||||
fromJSON(object: any): MsgInstantiateContract;
|
||||
fromPartial(object: DeepPartial<MsgInstantiateContract>): MsgInstantiateContract;
|
||||
toJSON(message: MsgInstantiateContract): unknown;
|
||||
};
|
||||
export declare const MsgInstantiateContractResponse: {
|
||||
encode(message: MsgInstantiateContractResponse, writer?: _m0.Writer): _m0.Writer;
|
||||
decode(input: _m0.Reader | Uint8Array, length?: number | undefined): MsgInstantiateContractResponse;
|
||||
fromJSON(object: any): MsgInstantiateContractResponse;
|
||||
fromPartial(object: DeepPartial<MsgInstantiateContractResponse>): MsgInstantiateContractResponse;
|
||||
toJSON(message: MsgInstantiateContractResponse): unknown;
|
||||
};
|
||||
export declare const MsgExecuteContract: {
|
||||
encode(message: MsgExecuteContract, writer?: _m0.Writer): _m0.Writer;
|
||||
decode(input: _m0.Reader | Uint8Array, length?: number | undefined): MsgExecuteContract;
|
||||
fromJSON(object: any): MsgExecuteContract;
|
||||
fromPartial(object: DeepPartial<MsgExecuteContract>): MsgExecuteContract;
|
||||
toJSON(message: MsgExecuteContract): unknown;
|
||||
};
|
||||
export declare const MsgExecuteContractResponse: {
|
||||
encode(message: MsgExecuteContractResponse, writer?: _m0.Writer): _m0.Writer;
|
||||
decode(input: _m0.Reader | Uint8Array, length?: number | undefined): MsgExecuteContractResponse;
|
||||
fromJSON(object: any): MsgExecuteContractResponse;
|
||||
fromPartial(object: DeepPartial<MsgExecuteContractResponse>): MsgExecuteContractResponse;
|
||||
toJSON(message: MsgExecuteContractResponse): unknown;
|
||||
};
|
||||
export declare const MsgMigrateContract: {
|
||||
encode(message: MsgMigrateContract, writer?: _m0.Writer): _m0.Writer;
|
||||
decode(input: _m0.Reader | Uint8Array, length?: number | undefined): MsgMigrateContract;
|
||||
fromJSON(object: any): MsgMigrateContract;
|
||||
fromPartial(object: DeepPartial<MsgMigrateContract>): MsgMigrateContract;
|
||||
toJSON(message: MsgMigrateContract): unknown;
|
||||
};
|
||||
export declare const MsgMigrateContractResponse: {
|
||||
encode(message: MsgMigrateContractResponse, writer?: _m0.Writer): _m0.Writer;
|
||||
decode(input: _m0.Reader | Uint8Array, length?: number | undefined): MsgMigrateContractResponse;
|
||||
fromJSON(object: any): MsgMigrateContractResponse;
|
||||
fromPartial(object: DeepPartial<MsgMigrateContractResponse>): MsgMigrateContractResponse;
|
||||
toJSON(message: MsgMigrateContractResponse): unknown;
|
||||
};
|
||||
export declare const MsgUpdateAdmin: {
|
||||
encode(message: MsgUpdateAdmin, writer?: _m0.Writer): _m0.Writer;
|
||||
decode(input: _m0.Reader | Uint8Array, length?: number | undefined): MsgUpdateAdmin;
|
||||
fromJSON(object: any): MsgUpdateAdmin;
|
||||
fromPartial(object: DeepPartial<MsgUpdateAdmin>): MsgUpdateAdmin;
|
||||
toJSON(message: MsgUpdateAdmin): unknown;
|
||||
};
|
||||
export declare const MsgUpdateAdminResponse: {
|
||||
encode(_: MsgUpdateAdminResponse, writer?: _m0.Writer): _m0.Writer;
|
||||
decode(input: _m0.Reader | Uint8Array, length?: number | undefined): MsgUpdateAdminResponse;
|
||||
fromJSON(_: any): MsgUpdateAdminResponse;
|
||||
fromPartial(_: DeepPartial<MsgUpdateAdminResponse>): MsgUpdateAdminResponse;
|
||||
toJSON(_: MsgUpdateAdminResponse): unknown;
|
||||
};
|
||||
export declare const MsgClearAdmin: {
|
||||
encode(message: MsgClearAdmin, writer?: _m0.Writer): _m0.Writer;
|
||||
decode(input: _m0.Reader | Uint8Array, length?: number | undefined): MsgClearAdmin;
|
||||
fromJSON(object: any): MsgClearAdmin;
|
||||
fromPartial(object: DeepPartial<MsgClearAdmin>): MsgClearAdmin;
|
||||
toJSON(message: MsgClearAdmin): unknown;
|
||||
};
|
||||
export declare const MsgClearAdminResponse: {
|
||||
encode(_: MsgClearAdminResponse, writer?: _m0.Writer): _m0.Writer;
|
||||
decode(input: _m0.Reader | Uint8Array, length?: number | undefined): MsgClearAdminResponse;
|
||||
fromJSON(_: any): MsgClearAdminResponse;
|
||||
fromPartial(_: DeepPartial<MsgClearAdminResponse>): MsgClearAdminResponse;
|
||||
toJSON(_: MsgClearAdminResponse): unknown;
|
||||
};
|
||||
/** Msg defines the wasm Msg service. */
|
||||
export interface Msg {
|
||||
/** StoreCode to submit Wasm code to the system */
|
||||
StoreCode(request: MsgStoreCode): Promise<MsgStoreCodeResponse>;
|
||||
/** Instantiate creates a new smart contract instance for the given code id. */
|
||||
InstantiateContract(request: MsgInstantiateContract): Promise<MsgInstantiateContractResponse>;
|
||||
/** Execute submits the given message data to a smart contract */
|
||||
ExecuteContract(request: MsgExecuteContract): Promise<MsgExecuteContractResponse>;
|
||||
/** Migrate runs a code upgrade/ downgrade for a smart contract */
|
||||
MigrateContract(request: MsgMigrateContract): Promise<MsgMigrateContractResponse>;
|
||||
/** UpdateAdmin sets a new admin for a smart contract */
|
||||
UpdateAdmin(request: MsgUpdateAdmin): Promise<MsgUpdateAdminResponse>;
|
||||
/** ClearAdmin removes any admin stored for a smart contract */
|
||||
ClearAdmin(request: MsgClearAdmin): Promise<MsgClearAdminResponse>;
|
||||
}
|
||||
export declare class MsgClientImpl implements Msg {
|
||||
private readonly rpc;
|
||||
constructor(rpc: Rpc);
|
||||
StoreCode(request: MsgStoreCode): Promise<MsgStoreCodeResponse>;
|
||||
InstantiateContract(request: MsgInstantiateContract): Promise<MsgInstantiateContractResponse>;
|
||||
ExecuteContract(request: MsgExecuteContract): Promise<MsgExecuteContractResponse>;
|
||||
MigrateContract(request: MsgMigrateContract): Promise<MsgMigrateContractResponse>;
|
||||
UpdateAdmin(request: MsgUpdateAdmin): Promise<MsgUpdateAdminResponse>;
|
||||
ClearAdmin(request: MsgClearAdmin): Promise<MsgClearAdminResponse>;
|
||||
}
|
||||
interface Rpc {
|
||||
request(service: string, method: string, data: Uint8Array): Promise<Uint8Array>;
|
||||
}
|
||||
declare type Builtin = Date | Function | Uint8Array | string | number | undefined | Long;
|
||||
export declare type DeepPartial<T> = T extends Builtin
|
||||
? T
|
||||
: T extends Array<infer U>
|
||||
? Array<DeepPartial<U>>
|
||||
: T extends ReadonlyArray<infer U>
|
||||
? ReadonlyArray<DeepPartial<U>>
|
||||
: T extends {}
|
||||
? {
|
||||
[K in keyof T]?: DeepPartial<T[K]>;
|
||||
}
|
||||
: Partial<T>;
|
||||
export {};
|
||||
1113
packages/cosmwasm-stargate/types/codec/x/wasm/internal/types/tx.ts
Normal file
1113
packages/cosmwasm-stargate/types/codec/x/wasm/internal/types/tx.ts
Normal file
File diff suppressed because it is too large
Load Diff
171
packages/cosmwasm-stargate/types/codec/x/wasm/internal/types/types.d.ts
vendored
Normal file
171
packages/cosmwasm-stargate/types/codec/x/wasm/internal/types/types.d.ts
vendored
Normal file
@ -0,0 +1,171 @@
|
||||
import Long from "long";
|
||||
import _m0 from "protobufjs/minimal";
|
||||
export declare const protobufPackage = "cosmwasm.wasm.v1beta1";
|
||||
/** AccessType permission types */
|
||||
export declare enum AccessType {
|
||||
/** ACCESS_TYPE_UNSPECIFIED - AccessTypeUnspecified placeholder for empty value */
|
||||
ACCESS_TYPE_UNSPECIFIED = 0,
|
||||
/** ACCESS_TYPE_NOBODY - AccessTypeNobody forbidden */
|
||||
ACCESS_TYPE_NOBODY = 1,
|
||||
/** ACCESS_TYPE_ONLY_ADDRESS - AccessTypeOnlyAddress restricted to an address */
|
||||
ACCESS_TYPE_ONLY_ADDRESS = 2,
|
||||
/** ACCESS_TYPE_EVERYBODY - AccessTypeEverybody unrestricted */
|
||||
ACCESS_TYPE_EVERYBODY = 3,
|
||||
UNRECOGNIZED = -1,
|
||||
}
|
||||
export declare function accessTypeFromJSON(object: any): AccessType;
|
||||
export declare function accessTypeToJSON(object: AccessType): string;
|
||||
/** ContractCodeHistoryOperationType actions that caused a code change */
|
||||
export declare enum ContractCodeHistoryOperationType {
|
||||
/** CONTRACT_CODE_HISTORY_OPERATION_TYPE_UNSPECIFIED - ContractCodeHistoryOperationTypeUnspecified placeholder for empty value */
|
||||
CONTRACT_CODE_HISTORY_OPERATION_TYPE_UNSPECIFIED = 0,
|
||||
/** CONTRACT_CODE_HISTORY_OPERATION_TYPE_INIT - ContractCodeHistoryOperationTypeInit on chain contract instantiation */
|
||||
CONTRACT_CODE_HISTORY_OPERATION_TYPE_INIT = 1,
|
||||
/** CONTRACT_CODE_HISTORY_OPERATION_TYPE_MIGRATE - ContractCodeHistoryOperationTypeMigrate code migration */
|
||||
CONTRACT_CODE_HISTORY_OPERATION_TYPE_MIGRATE = 2,
|
||||
/** CONTRACT_CODE_HISTORY_OPERATION_TYPE_GENESIS - ContractCodeHistoryOperationTypeGenesis based on genesis data */
|
||||
CONTRACT_CODE_HISTORY_OPERATION_TYPE_GENESIS = 3,
|
||||
UNRECOGNIZED = -1,
|
||||
}
|
||||
export declare function contractCodeHistoryOperationTypeFromJSON(
|
||||
object: any,
|
||||
): ContractCodeHistoryOperationType;
|
||||
export declare function contractCodeHistoryOperationTypeToJSON(
|
||||
object: ContractCodeHistoryOperationType,
|
||||
): string;
|
||||
/** AccessTypeParam */
|
||||
export interface AccessTypeParam {
|
||||
value: AccessType;
|
||||
}
|
||||
/** AccessConfig access control type. */
|
||||
export interface AccessConfig {
|
||||
permission: AccessType;
|
||||
address: string;
|
||||
}
|
||||
/** Params defines the set of wasm parameters. */
|
||||
export interface Params {
|
||||
codeUploadAccess?: AccessConfig;
|
||||
instantiateDefaultPermission: AccessType;
|
||||
maxWasmCodeSize: Long;
|
||||
}
|
||||
/** CodeInfo is data for the uploaded contract WASM code */
|
||||
export interface CodeInfo {
|
||||
/** CodeHash is the unique CodeID */
|
||||
codeHash: Uint8Array;
|
||||
/** Creator address who initially stored the code */
|
||||
creator: string;
|
||||
/** Source is a valid absolute HTTPS URI to the contract's source code, optional */
|
||||
source: string;
|
||||
/** Builder is a valid docker image name with tag, optional */
|
||||
builder: string;
|
||||
/** InstantiateConfig access control to apply on contract creation, optional */
|
||||
instantiateConfig?: AccessConfig;
|
||||
}
|
||||
/** ContractInfo stores a WASM contract instance */
|
||||
export interface ContractInfo {
|
||||
/** CodeID is the reference to the stored Wasm code */
|
||||
codeId: Long;
|
||||
/** Creator address who initially instantiated the contract */
|
||||
creator: string;
|
||||
/** Admin is an optional address that can execute migrations */
|
||||
admin: string;
|
||||
/** Label is optional metadata to be stored with a contract instance. */
|
||||
label: string;
|
||||
/**
|
||||
* Created Tx position when the contract was instantiated.
|
||||
* This data should kept internal and not be exposed via query results. Just use for sorting
|
||||
*/
|
||||
created?: AbsoluteTxPosition;
|
||||
}
|
||||
/** ContractCodeHistoryEntry metadata to a contract. */
|
||||
export interface ContractCodeHistoryEntry {
|
||||
operation: ContractCodeHistoryOperationType;
|
||||
/** CodeID is the reference to the stored WASM code */
|
||||
codeId: Long;
|
||||
/** Updated Tx position when the operation was executed. */
|
||||
updated?: AbsoluteTxPosition;
|
||||
msg: Uint8Array;
|
||||
}
|
||||
/** AbsoluteTxPosition is a unique transaction position that allows for global ordering of transactions. */
|
||||
export interface AbsoluteTxPosition {
|
||||
/** BlockHeight is the block the contract was created at */
|
||||
blockHeight: Long;
|
||||
/** TxIndex is a monotonic counter within the block (actual transaction index, or gas consumed) */
|
||||
txIndex: Long;
|
||||
}
|
||||
/** Model is a struct that holds a KV pair */
|
||||
export interface Model {
|
||||
/** hex-encode key to read it better (this is often ascii) */
|
||||
key: Uint8Array;
|
||||
/** base64-encode raw value */
|
||||
value: Uint8Array;
|
||||
}
|
||||
export declare const AccessTypeParam: {
|
||||
encode(message: AccessTypeParam, writer?: _m0.Writer): _m0.Writer;
|
||||
decode(input: _m0.Reader | Uint8Array, length?: number | undefined): AccessTypeParam;
|
||||
fromJSON(object: any): AccessTypeParam;
|
||||
fromPartial(object: DeepPartial<AccessTypeParam>): AccessTypeParam;
|
||||
toJSON(message: AccessTypeParam): unknown;
|
||||
};
|
||||
export declare const AccessConfig: {
|
||||
encode(message: AccessConfig, writer?: _m0.Writer): _m0.Writer;
|
||||
decode(input: _m0.Reader | Uint8Array, length?: number | undefined): AccessConfig;
|
||||
fromJSON(object: any): AccessConfig;
|
||||
fromPartial(object: DeepPartial<AccessConfig>): AccessConfig;
|
||||
toJSON(message: AccessConfig): unknown;
|
||||
};
|
||||
export declare const Params: {
|
||||
encode(message: Params, writer?: _m0.Writer): _m0.Writer;
|
||||
decode(input: _m0.Reader | Uint8Array, length?: number | undefined): Params;
|
||||
fromJSON(object: any): Params;
|
||||
fromPartial(object: DeepPartial<Params>): Params;
|
||||
toJSON(message: Params): unknown;
|
||||
};
|
||||
export declare const CodeInfo: {
|
||||
encode(message: CodeInfo, writer?: _m0.Writer): _m0.Writer;
|
||||
decode(input: _m0.Reader | Uint8Array, length?: number | undefined): CodeInfo;
|
||||
fromJSON(object: any): CodeInfo;
|
||||
fromPartial(object: DeepPartial<CodeInfo>): CodeInfo;
|
||||
toJSON(message: CodeInfo): unknown;
|
||||
};
|
||||
export declare const ContractInfo: {
|
||||
encode(message: ContractInfo, writer?: _m0.Writer): _m0.Writer;
|
||||
decode(input: _m0.Reader | Uint8Array, length?: number | undefined): ContractInfo;
|
||||
fromJSON(object: any): ContractInfo;
|
||||
fromPartial(object: DeepPartial<ContractInfo>): ContractInfo;
|
||||
toJSON(message: ContractInfo): unknown;
|
||||
};
|
||||
export declare const ContractCodeHistoryEntry: {
|
||||
encode(message: ContractCodeHistoryEntry, writer?: _m0.Writer): _m0.Writer;
|
||||
decode(input: _m0.Reader | Uint8Array, length?: number | undefined): ContractCodeHistoryEntry;
|
||||
fromJSON(object: any): ContractCodeHistoryEntry;
|
||||
fromPartial(object: DeepPartial<ContractCodeHistoryEntry>): ContractCodeHistoryEntry;
|
||||
toJSON(message: ContractCodeHistoryEntry): unknown;
|
||||
};
|
||||
export declare const AbsoluteTxPosition: {
|
||||
encode(message: AbsoluteTxPosition, writer?: _m0.Writer): _m0.Writer;
|
||||
decode(input: _m0.Reader | Uint8Array, length?: number | undefined): AbsoluteTxPosition;
|
||||
fromJSON(object: any): AbsoluteTxPosition;
|
||||
fromPartial(object: DeepPartial<AbsoluteTxPosition>): AbsoluteTxPosition;
|
||||
toJSON(message: AbsoluteTxPosition): unknown;
|
||||
};
|
||||
export declare const Model: {
|
||||
encode(message: Model, writer?: _m0.Writer): _m0.Writer;
|
||||
decode(input: _m0.Reader | Uint8Array, length?: number | undefined): Model;
|
||||
fromJSON(object: any): Model;
|
||||
fromPartial(object: DeepPartial<Model>): Model;
|
||||
toJSON(message: Model): unknown;
|
||||
};
|
||||
declare type Builtin = Date | Function | Uint8Array | string | number | undefined | Long;
|
||||
export declare type DeepPartial<T> = T extends Builtin
|
||||
? T
|
||||
: T extends Array<infer U>
|
||||
? Array<DeepPartial<U>>
|
||||
: T extends ReadonlyArray<infer U>
|
||||
? ReadonlyArray<DeepPartial<U>>
|
||||
: T extends {}
|
||||
? {
|
||||
[K in keyof T]?: DeepPartial<T[K]>;
|
||||
}
|
||||
: Partial<T>;
|
||||
export {};
|
||||
@ -0,0 +1,899 @@
|
||||
/* eslint-disable */
|
||||
import Long from "long";
|
||||
import _m0 from "protobufjs/minimal";
|
||||
|
||||
export const protobufPackage = "cosmwasm.wasm.v1beta1";
|
||||
|
||||
/** AccessType permission types */
|
||||
export enum AccessType {
|
||||
/** ACCESS_TYPE_UNSPECIFIED - AccessTypeUnspecified placeholder for empty value */
|
||||
ACCESS_TYPE_UNSPECIFIED = 0,
|
||||
/** ACCESS_TYPE_NOBODY - AccessTypeNobody forbidden */
|
||||
ACCESS_TYPE_NOBODY = 1,
|
||||
/** ACCESS_TYPE_ONLY_ADDRESS - AccessTypeOnlyAddress restricted to an address */
|
||||
ACCESS_TYPE_ONLY_ADDRESS = 2,
|
||||
/** ACCESS_TYPE_EVERYBODY - AccessTypeEverybody unrestricted */
|
||||
ACCESS_TYPE_EVERYBODY = 3,
|
||||
UNRECOGNIZED = -1,
|
||||
}
|
||||
|
||||
export function accessTypeFromJSON(object: any): AccessType {
|
||||
switch (object) {
|
||||
case 0:
|
||||
case "ACCESS_TYPE_UNSPECIFIED":
|
||||
return AccessType.ACCESS_TYPE_UNSPECIFIED;
|
||||
case 1:
|
||||
case "ACCESS_TYPE_NOBODY":
|
||||
return AccessType.ACCESS_TYPE_NOBODY;
|
||||
case 2:
|
||||
case "ACCESS_TYPE_ONLY_ADDRESS":
|
||||
return AccessType.ACCESS_TYPE_ONLY_ADDRESS;
|
||||
case 3:
|
||||
case "ACCESS_TYPE_EVERYBODY":
|
||||
return AccessType.ACCESS_TYPE_EVERYBODY;
|
||||
case -1:
|
||||
case "UNRECOGNIZED":
|
||||
default:
|
||||
return AccessType.UNRECOGNIZED;
|
||||
}
|
||||
}
|
||||
|
||||
export function accessTypeToJSON(object: AccessType): string {
|
||||
switch (object) {
|
||||
case AccessType.ACCESS_TYPE_UNSPECIFIED:
|
||||
return "ACCESS_TYPE_UNSPECIFIED";
|
||||
case AccessType.ACCESS_TYPE_NOBODY:
|
||||
return "ACCESS_TYPE_NOBODY";
|
||||
case AccessType.ACCESS_TYPE_ONLY_ADDRESS:
|
||||
return "ACCESS_TYPE_ONLY_ADDRESS";
|
||||
case AccessType.ACCESS_TYPE_EVERYBODY:
|
||||
return "ACCESS_TYPE_EVERYBODY";
|
||||
default:
|
||||
return "UNKNOWN";
|
||||
}
|
||||
}
|
||||
|
||||
/** ContractCodeHistoryOperationType actions that caused a code change */
|
||||
export enum ContractCodeHistoryOperationType {
|
||||
/** CONTRACT_CODE_HISTORY_OPERATION_TYPE_UNSPECIFIED - ContractCodeHistoryOperationTypeUnspecified placeholder for empty value */
|
||||
CONTRACT_CODE_HISTORY_OPERATION_TYPE_UNSPECIFIED = 0,
|
||||
/** CONTRACT_CODE_HISTORY_OPERATION_TYPE_INIT - ContractCodeHistoryOperationTypeInit on chain contract instantiation */
|
||||
CONTRACT_CODE_HISTORY_OPERATION_TYPE_INIT = 1,
|
||||
/** CONTRACT_CODE_HISTORY_OPERATION_TYPE_MIGRATE - ContractCodeHistoryOperationTypeMigrate code migration */
|
||||
CONTRACT_CODE_HISTORY_OPERATION_TYPE_MIGRATE = 2,
|
||||
/** CONTRACT_CODE_HISTORY_OPERATION_TYPE_GENESIS - ContractCodeHistoryOperationTypeGenesis based on genesis data */
|
||||
CONTRACT_CODE_HISTORY_OPERATION_TYPE_GENESIS = 3,
|
||||
UNRECOGNIZED = -1,
|
||||
}
|
||||
|
||||
export function contractCodeHistoryOperationTypeFromJSON(object: any): ContractCodeHistoryOperationType {
|
||||
switch (object) {
|
||||
case 0:
|
||||
case "CONTRACT_CODE_HISTORY_OPERATION_TYPE_UNSPECIFIED":
|
||||
return ContractCodeHistoryOperationType.CONTRACT_CODE_HISTORY_OPERATION_TYPE_UNSPECIFIED;
|
||||
case 1:
|
||||
case "CONTRACT_CODE_HISTORY_OPERATION_TYPE_INIT":
|
||||
return ContractCodeHistoryOperationType.CONTRACT_CODE_HISTORY_OPERATION_TYPE_INIT;
|
||||
case 2:
|
||||
case "CONTRACT_CODE_HISTORY_OPERATION_TYPE_MIGRATE":
|
||||
return ContractCodeHistoryOperationType.CONTRACT_CODE_HISTORY_OPERATION_TYPE_MIGRATE;
|
||||
case 3:
|
||||
case "CONTRACT_CODE_HISTORY_OPERATION_TYPE_GENESIS":
|
||||
return ContractCodeHistoryOperationType.CONTRACT_CODE_HISTORY_OPERATION_TYPE_GENESIS;
|
||||
case -1:
|
||||
case "UNRECOGNIZED":
|
||||
default:
|
||||
return ContractCodeHistoryOperationType.UNRECOGNIZED;
|
||||
}
|
||||
}
|
||||
|
||||
export function contractCodeHistoryOperationTypeToJSON(object: ContractCodeHistoryOperationType): string {
|
||||
switch (object) {
|
||||
case ContractCodeHistoryOperationType.CONTRACT_CODE_HISTORY_OPERATION_TYPE_UNSPECIFIED:
|
||||
return "CONTRACT_CODE_HISTORY_OPERATION_TYPE_UNSPECIFIED";
|
||||
case ContractCodeHistoryOperationType.CONTRACT_CODE_HISTORY_OPERATION_TYPE_INIT:
|
||||
return "CONTRACT_CODE_HISTORY_OPERATION_TYPE_INIT";
|
||||
case ContractCodeHistoryOperationType.CONTRACT_CODE_HISTORY_OPERATION_TYPE_MIGRATE:
|
||||
return "CONTRACT_CODE_HISTORY_OPERATION_TYPE_MIGRATE";
|
||||
case ContractCodeHistoryOperationType.CONTRACT_CODE_HISTORY_OPERATION_TYPE_GENESIS:
|
||||
return "CONTRACT_CODE_HISTORY_OPERATION_TYPE_GENESIS";
|
||||
default:
|
||||
return "UNKNOWN";
|
||||
}
|
||||
}
|
||||
|
||||
/** AccessTypeParam */
|
||||
export interface AccessTypeParam {
|
||||
value: AccessType;
|
||||
}
|
||||
|
||||
/** AccessConfig access control type. */
|
||||
export interface AccessConfig {
|
||||
permission: AccessType;
|
||||
address: string;
|
||||
}
|
||||
|
||||
/** Params defines the set of wasm parameters. */
|
||||
export interface Params {
|
||||
codeUploadAccess?: AccessConfig;
|
||||
instantiateDefaultPermission: AccessType;
|
||||
maxWasmCodeSize: Long;
|
||||
}
|
||||
|
||||
/** CodeInfo is data for the uploaded contract WASM code */
|
||||
export interface CodeInfo {
|
||||
/** CodeHash is the unique CodeID */
|
||||
codeHash: Uint8Array;
|
||||
/** Creator address who initially stored the code */
|
||||
creator: string;
|
||||
/** Source is a valid absolute HTTPS URI to the contract's source code, optional */
|
||||
source: string;
|
||||
/** Builder is a valid docker image name with tag, optional */
|
||||
builder: string;
|
||||
/** InstantiateConfig access control to apply on contract creation, optional */
|
||||
instantiateConfig?: AccessConfig;
|
||||
}
|
||||
|
||||
/** ContractInfo stores a WASM contract instance */
|
||||
export interface ContractInfo {
|
||||
/** CodeID is the reference to the stored Wasm code */
|
||||
codeId: Long;
|
||||
/** Creator address who initially instantiated the contract */
|
||||
creator: string;
|
||||
/** Admin is an optional address that can execute migrations */
|
||||
admin: string;
|
||||
/** Label is optional metadata to be stored with a contract instance. */
|
||||
label: string;
|
||||
/**
|
||||
* Created Tx position when the contract was instantiated.
|
||||
* This data should kept internal and not be exposed via query results. Just use for sorting
|
||||
*/
|
||||
created?: AbsoluteTxPosition;
|
||||
}
|
||||
|
||||
/** ContractCodeHistoryEntry metadata to a contract. */
|
||||
export interface ContractCodeHistoryEntry {
|
||||
operation: ContractCodeHistoryOperationType;
|
||||
/** CodeID is the reference to the stored WASM code */
|
||||
codeId: Long;
|
||||
/** Updated Tx position when the operation was executed. */
|
||||
updated?: AbsoluteTxPosition;
|
||||
msg: Uint8Array;
|
||||
}
|
||||
|
||||
/** AbsoluteTxPosition is a unique transaction position that allows for global ordering of transactions. */
|
||||
export interface AbsoluteTxPosition {
|
||||
/** BlockHeight is the block the contract was created at */
|
||||
blockHeight: Long;
|
||||
/** TxIndex is a monotonic counter within the block (actual transaction index, or gas consumed) */
|
||||
txIndex: Long;
|
||||
}
|
||||
|
||||
/** Model is a struct that holds a KV pair */
|
||||
export interface Model {
|
||||
/** hex-encode key to read it better (this is often ascii) */
|
||||
key: Uint8Array;
|
||||
/** base64-encode raw value */
|
||||
value: Uint8Array;
|
||||
}
|
||||
|
||||
const baseAccessTypeParam: object = { value: 0 };
|
||||
|
||||
export const AccessTypeParam = {
|
||||
encode(message: AccessTypeParam, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer {
|
||||
writer.uint32(8).int32(message.value);
|
||||
return writer;
|
||||
},
|
||||
|
||||
decode(input: _m0.Reader | Uint8Array, length?: number): AccessTypeParam {
|
||||
const reader = input instanceof Uint8Array ? new _m0.Reader(input) : input;
|
||||
let end = length === undefined ? reader.len : reader.pos + length;
|
||||
const message = { ...baseAccessTypeParam } as AccessTypeParam;
|
||||
while (reader.pos < end) {
|
||||
const tag = reader.uint32();
|
||||
switch (tag >>> 3) {
|
||||
case 1:
|
||||
message.value = reader.int32() as any;
|
||||
break;
|
||||
default:
|
||||
reader.skipType(tag & 7);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return message;
|
||||
},
|
||||
|
||||
fromJSON(object: any): AccessTypeParam {
|
||||
const message = { ...baseAccessTypeParam } as AccessTypeParam;
|
||||
if (object.value !== undefined && object.value !== null) {
|
||||
message.value = accessTypeFromJSON(object.value);
|
||||
} else {
|
||||
message.value = 0;
|
||||
}
|
||||
return message;
|
||||
},
|
||||
|
||||
fromPartial(object: DeepPartial<AccessTypeParam>): AccessTypeParam {
|
||||
const message = { ...baseAccessTypeParam } as AccessTypeParam;
|
||||
if (object.value !== undefined && object.value !== null) {
|
||||
message.value = object.value;
|
||||
} else {
|
||||
message.value = 0;
|
||||
}
|
||||
return message;
|
||||
},
|
||||
|
||||
toJSON(message: AccessTypeParam): unknown {
|
||||
const obj: any = {};
|
||||
message.value !== undefined && (obj.value = accessTypeToJSON(message.value));
|
||||
return obj;
|
||||
},
|
||||
};
|
||||
|
||||
const baseAccessConfig: object = { permission: 0, address: "" };
|
||||
|
||||
export const AccessConfig = {
|
||||
encode(message: AccessConfig, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer {
|
||||
writer.uint32(8).int32(message.permission);
|
||||
writer.uint32(18).string(message.address);
|
||||
return writer;
|
||||
},
|
||||
|
||||
decode(input: _m0.Reader | Uint8Array, length?: number): AccessConfig {
|
||||
const reader = input instanceof Uint8Array ? new _m0.Reader(input) : input;
|
||||
let end = length === undefined ? reader.len : reader.pos + length;
|
||||
const message = { ...baseAccessConfig } as AccessConfig;
|
||||
while (reader.pos < end) {
|
||||
const tag = reader.uint32();
|
||||
switch (tag >>> 3) {
|
||||
case 1:
|
||||
message.permission = reader.int32() as any;
|
||||
break;
|
||||
case 2:
|
||||
message.address = reader.string();
|
||||
break;
|
||||
default:
|
||||
reader.skipType(tag & 7);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return message;
|
||||
},
|
||||
|
||||
fromJSON(object: any): AccessConfig {
|
||||
const message = { ...baseAccessConfig } as AccessConfig;
|
||||
if (object.permission !== undefined && object.permission !== null) {
|
||||
message.permission = accessTypeFromJSON(object.permission);
|
||||
} else {
|
||||
message.permission = 0;
|
||||
}
|
||||
if (object.address !== undefined && object.address !== null) {
|
||||
message.address = String(object.address);
|
||||
} else {
|
||||
message.address = "";
|
||||
}
|
||||
return message;
|
||||
},
|
||||
|
||||
fromPartial(object: DeepPartial<AccessConfig>): AccessConfig {
|
||||
const message = { ...baseAccessConfig } as AccessConfig;
|
||||
if (object.permission !== undefined && object.permission !== null) {
|
||||
message.permission = object.permission;
|
||||
} else {
|
||||
message.permission = 0;
|
||||
}
|
||||
if (object.address !== undefined && object.address !== null) {
|
||||
message.address = object.address;
|
||||
} else {
|
||||
message.address = "";
|
||||
}
|
||||
return message;
|
||||
},
|
||||
|
||||
toJSON(message: AccessConfig): unknown {
|
||||
const obj: any = {};
|
||||
message.permission !== undefined && (obj.permission = accessTypeToJSON(message.permission));
|
||||
message.address !== undefined && (obj.address = message.address);
|
||||
return obj;
|
||||
},
|
||||
};
|
||||
|
||||
const baseParams: object = { instantiateDefaultPermission: 0, maxWasmCodeSize: Long.UZERO };
|
||||
|
||||
export const Params = {
|
||||
encode(message: Params, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer {
|
||||
if (message.codeUploadAccess !== undefined && message.codeUploadAccess !== undefined) {
|
||||
AccessConfig.encode(message.codeUploadAccess, writer.uint32(10).fork()).ldelim();
|
||||
}
|
||||
writer.uint32(16).int32(message.instantiateDefaultPermission);
|
||||
writer.uint32(24).uint64(message.maxWasmCodeSize);
|
||||
return writer;
|
||||
},
|
||||
|
||||
decode(input: _m0.Reader | Uint8Array, length?: number): Params {
|
||||
const reader = input instanceof Uint8Array ? new _m0.Reader(input) : input;
|
||||
let end = length === undefined ? reader.len : reader.pos + length;
|
||||
const message = { ...baseParams } as Params;
|
||||
while (reader.pos < end) {
|
||||
const tag = reader.uint32();
|
||||
switch (tag >>> 3) {
|
||||
case 1:
|
||||
message.codeUploadAccess = AccessConfig.decode(reader, reader.uint32());
|
||||
break;
|
||||
case 2:
|
||||
message.instantiateDefaultPermission = reader.int32() as any;
|
||||
break;
|
||||
case 3:
|
||||
message.maxWasmCodeSize = reader.uint64() as Long;
|
||||
break;
|
||||
default:
|
||||
reader.skipType(tag & 7);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return message;
|
||||
},
|
||||
|
||||
fromJSON(object: any): Params {
|
||||
const message = { ...baseParams } as Params;
|
||||
if (object.codeUploadAccess !== undefined && object.codeUploadAccess !== null) {
|
||||
message.codeUploadAccess = AccessConfig.fromJSON(object.codeUploadAccess);
|
||||
} else {
|
||||
message.codeUploadAccess = undefined;
|
||||
}
|
||||
if (object.instantiateDefaultPermission !== undefined && object.instantiateDefaultPermission !== null) {
|
||||
message.instantiateDefaultPermission = accessTypeFromJSON(object.instantiateDefaultPermission);
|
||||
} else {
|
||||
message.instantiateDefaultPermission = 0;
|
||||
}
|
||||
if (object.maxWasmCodeSize !== undefined && object.maxWasmCodeSize !== null) {
|
||||
message.maxWasmCodeSize = Long.fromString(object.maxWasmCodeSize);
|
||||
} else {
|
||||
message.maxWasmCodeSize = Long.UZERO;
|
||||
}
|
||||
return message;
|
||||
},
|
||||
|
||||
fromPartial(object: DeepPartial<Params>): Params {
|
||||
const message = { ...baseParams } as Params;
|
||||
if (object.codeUploadAccess !== undefined && object.codeUploadAccess !== null) {
|
||||
message.codeUploadAccess = AccessConfig.fromPartial(object.codeUploadAccess);
|
||||
} else {
|
||||
message.codeUploadAccess = undefined;
|
||||
}
|
||||
if (object.instantiateDefaultPermission !== undefined && object.instantiateDefaultPermission !== null) {
|
||||
message.instantiateDefaultPermission = object.instantiateDefaultPermission;
|
||||
} else {
|
||||
message.instantiateDefaultPermission = 0;
|
||||
}
|
||||
if (object.maxWasmCodeSize !== undefined && object.maxWasmCodeSize !== null) {
|
||||
message.maxWasmCodeSize = object.maxWasmCodeSize as Long;
|
||||
} else {
|
||||
message.maxWasmCodeSize = Long.UZERO;
|
||||
}
|
||||
return message;
|
||||
},
|
||||
|
||||
toJSON(message: Params): unknown {
|
||||
const obj: any = {};
|
||||
message.codeUploadAccess !== undefined &&
|
||||
(obj.codeUploadAccess = message.codeUploadAccess
|
||||
? AccessConfig.toJSON(message.codeUploadAccess)
|
||||
: undefined);
|
||||
message.instantiateDefaultPermission !== undefined &&
|
||||
(obj.instantiateDefaultPermission = accessTypeToJSON(message.instantiateDefaultPermission));
|
||||
message.maxWasmCodeSize !== undefined &&
|
||||
(obj.maxWasmCodeSize = (message.maxWasmCodeSize || Long.UZERO).toString());
|
||||
return obj;
|
||||
},
|
||||
};
|
||||
|
||||
const baseCodeInfo: object = { creator: "", source: "", builder: "" };
|
||||
|
||||
export const CodeInfo = {
|
||||
encode(message: CodeInfo, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer {
|
||||
writer.uint32(10).bytes(message.codeHash);
|
||||
writer.uint32(18).string(message.creator);
|
||||
writer.uint32(26).string(message.source);
|
||||
writer.uint32(34).string(message.builder);
|
||||
if (message.instantiateConfig !== undefined && message.instantiateConfig !== undefined) {
|
||||
AccessConfig.encode(message.instantiateConfig, writer.uint32(42).fork()).ldelim();
|
||||
}
|
||||
return writer;
|
||||
},
|
||||
|
||||
decode(input: _m0.Reader | Uint8Array, length?: number): CodeInfo {
|
||||
const reader = input instanceof Uint8Array ? new _m0.Reader(input) : input;
|
||||
let end = length === undefined ? reader.len : reader.pos + length;
|
||||
const message = { ...baseCodeInfo } as CodeInfo;
|
||||
while (reader.pos < end) {
|
||||
const tag = reader.uint32();
|
||||
switch (tag >>> 3) {
|
||||
case 1:
|
||||
message.codeHash = reader.bytes();
|
||||
break;
|
||||
case 2:
|
||||
message.creator = reader.string();
|
||||
break;
|
||||
case 3:
|
||||
message.source = reader.string();
|
||||
break;
|
||||
case 4:
|
||||
message.builder = reader.string();
|
||||
break;
|
||||
case 5:
|
||||
message.instantiateConfig = AccessConfig.decode(reader, reader.uint32());
|
||||
break;
|
||||
default:
|
||||
reader.skipType(tag & 7);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return message;
|
||||
},
|
||||
|
||||
fromJSON(object: any): CodeInfo {
|
||||
const message = { ...baseCodeInfo } as CodeInfo;
|
||||
if (object.codeHash !== undefined && object.codeHash !== null) {
|
||||
message.codeHash = bytesFromBase64(object.codeHash);
|
||||
}
|
||||
if (object.creator !== undefined && object.creator !== null) {
|
||||
message.creator = String(object.creator);
|
||||
} else {
|
||||
message.creator = "";
|
||||
}
|
||||
if (object.source !== undefined && object.source !== null) {
|
||||
message.source = String(object.source);
|
||||
} else {
|
||||
message.source = "";
|
||||
}
|
||||
if (object.builder !== undefined && object.builder !== null) {
|
||||
message.builder = String(object.builder);
|
||||
} else {
|
||||
message.builder = "";
|
||||
}
|
||||
if (object.instantiateConfig !== undefined && object.instantiateConfig !== null) {
|
||||
message.instantiateConfig = AccessConfig.fromJSON(object.instantiateConfig);
|
||||
} else {
|
||||
message.instantiateConfig = undefined;
|
||||
}
|
||||
return message;
|
||||
},
|
||||
|
||||
fromPartial(object: DeepPartial<CodeInfo>): CodeInfo {
|
||||
const message = { ...baseCodeInfo } as CodeInfo;
|
||||
if (object.codeHash !== undefined && object.codeHash !== null) {
|
||||
message.codeHash = object.codeHash;
|
||||
} else {
|
||||
message.codeHash = new Uint8Array();
|
||||
}
|
||||
if (object.creator !== undefined && object.creator !== null) {
|
||||
message.creator = object.creator;
|
||||
} else {
|
||||
message.creator = "";
|
||||
}
|
||||
if (object.source !== undefined && object.source !== null) {
|
||||
message.source = object.source;
|
||||
} else {
|
||||
message.source = "";
|
||||
}
|
||||
if (object.builder !== undefined && object.builder !== null) {
|
||||
message.builder = object.builder;
|
||||
} else {
|
||||
message.builder = "";
|
||||
}
|
||||
if (object.instantiateConfig !== undefined && object.instantiateConfig !== null) {
|
||||
message.instantiateConfig = AccessConfig.fromPartial(object.instantiateConfig);
|
||||
} else {
|
||||
message.instantiateConfig = undefined;
|
||||
}
|
||||
return message;
|
||||
},
|
||||
|
||||
toJSON(message: CodeInfo): unknown {
|
||||
const obj: any = {};
|
||||
message.codeHash !== undefined &&
|
||||
(obj.codeHash = base64FromBytes(message.codeHash !== undefined ? message.codeHash : new Uint8Array()));
|
||||
message.creator !== undefined && (obj.creator = message.creator);
|
||||
message.source !== undefined && (obj.source = message.source);
|
||||
message.builder !== undefined && (obj.builder = message.builder);
|
||||
message.instantiateConfig !== undefined &&
|
||||
(obj.instantiateConfig = message.instantiateConfig
|
||||
? AccessConfig.toJSON(message.instantiateConfig)
|
||||
: undefined);
|
||||
return obj;
|
||||
},
|
||||
};
|
||||
|
||||
const baseContractInfo: object = { codeId: Long.UZERO, creator: "", admin: "", label: "" };
|
||||
|
||||
export const ContractInfo = {
|
||||
encode(message: ContractInfo, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer {
|
||||
writer.uint32(8).uint64(message.codeId);
|
||||
writer.uint32(18).string(message.creator);
|
||||
writer.uint32(26).string(message.admin);
|
||||
writer.uint32(34).string(message.label);
|
||||
if (message.created !== undefined && message.created !== undefined) {
|
||||
AbsoluteTxPosition.encode(message.created, writer.uint32(42).fork()).ldelim();
|
||||
}
|
||||
return writer;
|
||||
},
|
||||
|
||||
decode(input: _m0.Reader | Uint8Array, length?: number): ContractInfo {
|
||||
const reader = input instanceof Uint8Array ? new _m0.Reader(input) : input;
|
||||
let end = length === undefined ? reader.len : reader.pos + length;
|
||||
const message = { ...baseContractInfo } as ContractInfo;
|
||||
while (reader.pos < end) {
|
||||
const tag = reader.uint32();
|
||||
switch (tag >>> 3) {
|
||||
case 1:
|
||||
message.codeId = reader.uint64() as Long;
|
||||
break;
|
||||
case 2:
|
||||
message.creator = reader.string();
|
||||
break;
|
||||
case 3:
|
||||
message.admin = reader.string();
|
||||
break;
|
||||
case 4:
|
||||
message.label = reader.string();
|
||||
break;
|
||||
case 5:
|
||||
message.created = AbsoluteTxPosition.decode(reader, reader.uint32());
|
||||
break;
|
||||
default:
|
||||
reader.skipType(tag & 7);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return message;
|
||||
},
|
||||
|
||||
fromJSON(object: any): ContractInfo {
|
||||
const message = { ...baseContractInfo } as ContractInfo;
|
||||
if (object.codeId !== undefined && object.codeId !== null) {
|
||||
message.codeId = Long.fromString(object.codeId);
|
||||
} else {
|
||||
message.codeId = Long.UZERO;
|
||||
}
|
||||
if (object.creator !== undefined && object.creator !== null) {
|
||||
message.creator = String(object.creator);
|
||||
} else {
|
||||
message.creator = "";
|
||||
}
|
||||
if (object.admin !== undefined && object.admin !== null) {
|
||||
message.admin = String(object.admin);
|
||||
} else {
|
||||
message.admin = "";
|
||||
}
|
||||
if (object.label !== undefined && object.label !== null) {
|
||||
message.label = String(object.label);
|
||||
} else {
|
||||
message.label = "";
|
||||
}
|
||||
if (object.created !== undefined && object.created !== null) {
|
||||
message.created = AbsoluteTxPosition.fromJSON(object.created);
|
||||
} else {
|
||||
message.created = undefined;
|
||||
}
|
||||
return message;
|
||||
},
|
||||
|
||||
fromPartial(object: DeepPartial<ContractInfo>): ContractInfo {
|
||||
const message = { ...baseContractInfo } as ContractInfo;
|
||||
if (object.codeId !== undefined && object.codeId !== null) {
|
||||
message.codeId = object.codeId as Long;
|
||||
} else {
|
||||
message.codeId = Long.UZERO;
|
||||
}
|
||||
if (object.creator !== undefined && object.creator !== null) {
|
||||
message.creator = object.creator;
|
||||
} else {
|
||||
message.creator = "";
|
||||
}
|
||||
if (object.admin !== undefined && object.admin !== null) {
|
||||
message.admin = object.admin;
|
||||
} else {
|
||||
message.admin = "";
|
||||
}
|
||||
if (object.label !== undefined && object.label !== null) {
|
||||
message.label = object.label;
|
||||
} else {
|
||||
message.label = "";
|
||||
}
|
||||
if (object.created !== undefined && object.created !== null) {
|
||||
message.created = AbsoluteTxPosition.fromPartial(object.created);
|
||||
} else {
|
||||
message.created = undefined;
|
||||
}
|
||||
return message;
|
||||
},
|
||||
|
||||
toJSON(message: ContractInfo): unknown {
|
||||
const obj: any = {};
|
||||
message.codeId !== undefined && (obj.codeId = (message.codeId || Long.UZERO).toString());
|
||||
message.creator !== undefined && (obj.creator = message.creator);
|
||||
message.admin !== undefined && (obj.admin = message.admin);
|
||||
message.label !== undefined && (obj.label = message.label);
|
||||
message.created !== undefined &&
|
||||
(obj.created = message.created ? AbsoluteTxPosition.toJSON(message.created) : undefined);
|
||||
return obj;
|
||||
},
|
||||
};
|
||||
|
||||
const baseContractCodeHistoryEntry: object = { operation: 0, codeId: Long.UZERO };
|
||||
|
||||
export const ContractCodeHistoryEntry = {
|
||||
encode(message: ContractCodeHistoryEntry, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer {
|
||||
writer.uint32(8).int32(message.operation);
|
||||
writer.uint32(16).uint64(message.codeId);
|
||||
if (message.updated !== undefined && message.updated !== undefined) {
|
||||
AbsoluteTxPosition.encode(message.updated, writer.uint32(26).fork()).ldelim();
|
||||
}
|
||||
writer.uint32(34).bytes(message.msg);
|
||||
return writer;
|
||||
},
|
||||
|
||||
decode(input: _m0.Reader | Uint8Array, length?: number): ContractCodeHistoryEntry {
|
||||
const reader = input instanceof Uint8Array ? new _m0.Reader(input) : input;
|
||||
let end = length === undefined ? reader.len : reader.pos + length;
|
||||
const message = { ...baseContractCodeHistoryEntry } as ContractCodeHistoryEntry;
|
||||
while (reader.pos < end) {
|
||||
const tag = reader.uint32();
|
||||
switch (tag >>> 3) {
|
||||
case 1:
|
||||
message.operation = reader.int32() as any;
|
||||
break;
|
||||
case 2:
|
||||
message.codeId = reader.uint64() as Long;
|
||||
break;
|
||||
case 3:
|
||||
message.updated = AbsoluteTxPosition.decode(reader, reader.uint32());
|
||||
break;
|
||||
case 4:
|
||||
message.msg = reader.bytes();
|
||||
break;
|
||||
default:
|
||||
reader.skipType(tag & 7);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return message;
|
||||
},
|
||||
|
||||
fromJSON(object: any): ContractCodeHistoryEntry {
|
||||
const message = { ...baseContractCodeHistoryEntry } as ContractCodeHistoryEntry;
|
||||
if (object.operation !== undefined && object.operation !== null) {
|
||||
message.operation = contractCodeHistoryOperationTypeFromJSON(object.operation);
|
||||
} else {
|
||||
message.operation = 0;
|
||||
}
|
||||
if (object.codeId !== undefined && object.codeId !== null) {
|
||||
message.codeId = Long.fromString(object.codeId);
|
||||
} else {
|
||||
message.codeId = Long.UZERO;
|
||||
}
|
||||
if (object.updated !== undefined && object.updated !== null) {
|
||||
message.updated = AbsoluteTxPosition.fromJSON(object.updated);
|
||||
} else {
|
||||
message.updated = undefined;
|
||||
}
|
||||
if (object.msg !== undefined && object.msg !== null) {
|
||||
message.msg = bytesFromBase64(object.msg);
|
||||
}
|
||||
return message;
|
||||
},
|
||||
|
||||
fromPartial(object: DeepPartial<ContractCodeHistoryEntry>): ContractCodeHistoryEntry {
|
||||
const message = { ...baseContractCodeHistoryEntry } as ContractCodeHistoryEntry;
|
||||
if (object.operation !== undefined && object.operation !== null) {
|
||||
message.operation = object.operation;
|
||||
} else {
|
||||
message.operation = 0;
|
||||
}
|
||||
if (object.codeId !== undefined && object.codeId !== null) {
|
||||
message.codeId = object.codeId as Long;
|
||||
} else {
|
||||
message.codeId = Long.UZERO;
|
||||
}
|
||||
if (object.updated !== undefined && object.updated !== null) {
|
||||
message.updated = AbsoluteTxPosition.fromPartial(object.updated);
|
||||
} else {
|
||||
message.updated = undefined;
|
||||
}
|
||||
if (object.msg !== undefined && object.msg !== null) {
|
||||
message.msg = object.msg;
|
||||
} else {
|
||||
message.msg = new Uint8Array();
|
||||
}
|
||||
return message;
|
||||
},
|
||||
|
||||
toJSON(message: ContractCodeHistoryEntry): unknown {
|
||||
const obj: any = {};
|
||||
message.operation !== undefined &&
|
||||
(obj.operation = contractCodeHistoryOperationTypeToJSON(message.operation));
|
||||
message.codeId !== undefined && (obj.codeId = (message.codeId || Long.UZERO).toString());
|
||||
message.updated !== undefined &&
|
||||
(obj.updated = message.updated ? AbsoluteTxPosition.toJSON(message.updated) : undefined);
|
||||
message.msg !== undefined &&
|
||||
(obj.msg = base64FromBytes(message.msg !== undefined ? message.msg : new Uint8Array()));
|
||||
return obj;
|
||||
},
|
||||
};
|
||||
|
||||
const baseAbsoluteTxPosition: object = { blockHeight: Long.UZERO, txIndex: Long.UZERO };
|
||||
|
||||
export const AbsoluteTxPosition = {
|
||||
encode(message: AbsoluteTxPosition, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer {
|
||||
writer.uint32(8).uint64(message.blockHeight);
|
||||
writer.uint32(16).uint64(message.txIndex);
|
||||
return writer;
|
||||
},
|
||||
|
||||
decode(input: _m0.Reader | Uint8Array, length?: number): AbsoluteTxPosition {
|
||||
const reader = input instanceof Uint8Array ? new _m0.Reader(input) : input;
|
||||
let end = length === undefined ? reader.len : reader.pos + length;
|
||||
const message = { ...baseAbsoluteTxPosition } as AbsoluteTxPosition;
|
||||
while (reader.pos < end) {
|
||||
const tag = reader.uint32();
|
||||
switch (tag >>> 3) {
|
||||
case 1:
|
||||
message.blockHeight = reader.uint64() as Long;
|
||||
break;
|
||||
case 2:
|
||||
message.txIndex = reader.uint64() as Long;
|
||||
break;
|
||||
default:
|
||||
reader.skipType(tag & 7);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return message;
|
||||
},
|
||||
|
||||
fromJSON(object: any): AbsoluteTxPosition {
|
||||
const message = { ...baseAbsoluteTxPosition } as AbsoluteTxPosition;
|
||||
if (object.blockHeight !== undefined && object.blockHeight !== null) {
|
||||
message.blockHeight = Long.fromString(object.blockHeight);
|
||||
} else {
|
||||
message.blockHeight = Long.UZERO;
|
||||
}
|
||||
if (object.txIndex !== undefined && object.txIndex !== null) {
|
||||
message.txIndex = Long.fromString(object.txIndex);
|
||||
} else {
|
||||
message.txIndex = Long.UZERO;
|
||||
}
|
||||
return message;
|
||||
},
|
||||
|
||||
fromPartial(object: DeepPartial<AbsoluteTxPosition>): AbsoluteTxPosition {
|
||||
const message = { ...baseAbsoluteTxPosition } as AbsoluteTxPosition;
|
||||
if (object.blockHeight !== undefined && object.blockHeight !== null) {
|
||||
message.blockHeight = object.blockHeight as Long;
|
||||
} else {
|
||||
message.blockHeight = Long.UZERO;
|
||||
}
|
||||
if (object.txIndex !== undefined && object.txIndex !== null) {
|
||||
message.txIndex = object.txIndex as Long;
|
||||
} else {
|
||||
message.txIndex = Long.UZERO;
|
||||
}
|
||||
return message;
|
||||
},
|
||||
|
||||
toJSON(message: AbsoluteTxPosition): unknown {
|
||||
const obj: any = {};
|
||||
message.blockHeight !== undefined && (obj.blockHeight = (message.blockHeight || Long.UZERO).toString());
|
||||
message.txIndex !== undefined && (obj.txIndex = (message.txIndex || Long.UZERO).toString());
|
||||
return obj;
|
||||
},
|
||||
};
|
||||
|
||||
const baseModel: object = {};
|
||||
|
||||
export const Model = {
|
||||
encode(message: Model, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer {
|
||||
writer.uint32(10).bytes(message.key);
|
||||
writer.uint32(18).bytes(message.value);
|
||||
return writer;
|
||||
},
|
||||
|
||||
decode(input: _m0.Reader | Uint8Array, length?: number): Model {
|
||||
const reader = input instanceof Uint8Array ? new _m0.Reader(input) : input;
|
||||
let end = length === undefined ? reader.len : reader.pos + length;
|
||||
const message = { ...baseModel } as Model;
|
||||
while (reader.pos < end) {
|
||||
const tag = reader.uint32();
|
||||
switch (tag >>> 3) {
|
||||
case 1:
|
||||
message.key = reader.bytes();
|
||||
break;
|
||||
case 2:
|
||||
message.value = reader.bytes();
|
||||
break;
|
||||
default:
|
||||
reader.skipType(tag & 7);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return message;
|
||||
},
|
||||
|
||||
fromJSON(object: any): Model {
|
||||
const message = { ...baseModel } as Model;
|
||||
if (object.key !== undefined && object.key !== null) {
|
||||
message.key = bytesFromBase64(object.key);
|
||||
}
|
||||
if (object.value !== undefined && object.value !== null) {
|
||||
message.value = bytesFromBase64(object.value);
|
||||
}
|
||||
return message;
|
||||
},
|
||||
|
||||
fromPartial(object: DeepPartial<Model>): Model {
|
||||
const message = { ...baseModel } as Model;
|
||||
if (object.key !== undefined && object.key !== null) {
|
||||
message.key = object.key;
|
||||
} else {
|
||||
message.key = new Uint8Array();
|
||||
}
|
||||
if (object.value !== undefined && object.value !== null) {
|
||||
message.value = object.value;
|
||||
} else {
|
||||
message.value = new Uint8Array();
|
||||
}
|
||||
return message;
|
||||
},
|
||||
|
||||
toJSON(message: Model): unknown {
|
||||
const obj: any = {};
|
||||
message.key !== undefined &&
|
||||
(obj.key = base64FromBytes(message.key !== undefined ? message.key : new Uint8Array()));
|
||||
message.value !== undefined &&
|
||||
(obj.value = base64FromBytes(message.value !== undefined ? message.value : new Uint8Array()));
|
||||
return obj;
|
||||
},
|
||||
};
|
||||
|
||||
declare var self: any | undefined;
|
||||
declare var window: any | undefined;
|
||||
var globalThis: any = (() => {
|
||||
if (typeof globalThis !== "undefined") return globalThis;
|
||||
if (typeof self !== "undefined") return self;
|
||||
if (typeof window !== "undefined") return window;
|
||||
if (typeof global !== "undefined") return global;
|
||||
throw new Error("Unable to locate global object");
|
||||
})();
|
||||
|
||||
const atob: (b64: string) => string =
|
||||
globalThis.atob || ((b64) => globalThis.Buffer.from(b64, "base64").toString("binary"));
|
||||
function bytesFromBase64(b64: string): Uint8Array {
|
||||
const bin = atob(b64);
|
||||
const arr = new Uint8Array(bin.length);
|
||||
for (let i = 0; i < bin.length; ++i) {
|
||||
arr[i] = bin.charCodeAt(i);
|
||||
}
|
||||
return arr;
|
||||
}
|
||||
|
||||
const btoa: (bin: string) => string =
|
||||
globalThis.btoa || ((bin) => globalThis.Buffer.from(bin, "binary").toString("base64"));
|
||||
function base64FromBytes(arr: Uint8Array): string {
|
||||
const bin: string[] = [];
|
||||
for (let i = 0; i < arr.byteLength; ++i) {
|
||||
bin.push(String.fromCharCode(arr[i]));
|
||||
}
|
||||
return btoa(bin.join(""));
|
||||
}
|
||||
|
||||
type Builtin = Date | Function | Uint8Array | string | number | undefined | Long;
|
||||
export type DeepPartial<T> = T extends Builtin
|
||||
? T
|
||||
: T extends Array<infer U>
|
||||
? Array<DeepPartial<U>>
|
||||
: T extends ReadonlyArray<infer U>
|
||||
? ReadonlyArray<DeepPartial<U>>
|
||||
: T extends {}
|
||||
? { [K in keyof T]?: DeepPartial<T[K]> }
|
||||
: Partial<T>;
|
||||
1
packages/cosmwasm-stargate/types/index.d.ts
vendored
1
packages/cosmwasm-stargate/types/index.d.ts
vendored
@ -1,4 +1,3 @@
|
||||
export * as codec from "./codec";
|
||||
export { cosmWasmTypes } from "./aminotypes";
|
||||
export { CosmWasmClient } from "./cosmwasmclient";
|
||||
export { SigningCosmWasmClient, SigningCosmWasmClientOptions } from "./signingcosmwasmclient";
|
||||
|
||||
@ -1,38 +1,39 @@
|
||||
import { JsonObject } from "@cosmjs/cosmwasm-launchpad";
|
||||
import { QueryClient } from "@cosmjs/stargate";
|
||||
import { cosmwasm } from "../codec";
|
||||
declare type IQueryAllContractStateResponse = cosmwasm.wasm.v1beta1.IQueryAllContractStateResponse;
|
||||
declare type IQueryCodesResponse = cosmwasm.wasm.v1beta1.IQueryCodesResponse;
|
||||
declare type IQueryCodeResponse = cosmwasm.wasm.v1beta1.IQueryCodeResponse;
|
||||
declare type IQueryContractHistoryResponse = cosmwasm.wasm.v1beta1.IQueryContractHistoryResponse;
|
||||
declare type IQueryContractInfoResponse = cosmwasm.wasm.v1beta1.IQueryContractInfoResponse;
|
||||
declare type IQueryContractsByCodeResponse = cosmwasm.wasm.v1beta1.IQueryContractsByCodeResponse;
|
||||
declare type IQueryRawContractStateResponse = cosmwasm.wasm.v1beta1.IQueryRawContractStateResponse;
|
||||
import {
|
||||
QueryAllContractStateResponse,
|
||||
QueryCodeResponse,
|
||||
QueryCodesResponse,
|
||||
QueryContractHistoryResponse,
|
||||
QueryContractInfoResponse,
|
||||
QueryContractsByCodeResponse,
|
||||
QueryRawContractStateResponse,
|
||||
} from "../codec/x/wasm/internal/types/query";
|
||||
export interface WasmExtension {
|
||||
readonly unverified: {
|
||||
readonly wasm: {
|
||||
readonly listCodeInfo: (paginationKey?: Uint8Array) => Promise<IQueryCodesResponse>;
|
||||
readonly listCodeInfo: (paginationKey?: Uint8Array) => Promise<QueryCodesResponse>;
|
||||
/**
|
||||
* Downloads the original wasm bytecode by code ID.
|
||||
*
|
||||
* Throws an error if no code with this id
|
||||
*/
|
||||
readonly getCode: (id: number) => Promise<IQueryCodeResponse>;
|
||||
readonly getCode: (id: number) => Promise<QueryCodeResponse>;
|
||||
readonly listContractsByCodeId: (
|
||||
id: number,
|
||||
paginationKey?: Uint8Array,
|
||||
) => Promise<IQueryContractsByCodeResponse>;
|
||||
) => Promise<QueryContractsByCodeResponse>;
|
||||
/**
|
||||
* Returns null when contract was not found at this address.
|
||||
*/
|
||||
readonly getContractInfo: (address: string) => Promise<IQueryContractInfoResponse>;
|
||||
readonly getContractInfo: (address: string) => Promise<QueryContractInfoResponse>;
|
||||
/**
|
||||
* Returns null when contract history was not found for this address.
|
||||
*/
|
||||
readonly getContractCodeHistory: (
|
||||
address: string,
|
||||
paginationKey?: Uint8Array,
|
||||
) => Promise<IQueryContractHistoryResponse>;
|
||||
) => Promise<QueryContractHistoryResponse>;
|
||||
/**
|
||||
* Returns all contract state.
|
||||
* This is an empty array if no such contract, or contract has no data.
|
||||
@ -40,15 +41,12 @@ export interface WasmExtension {
|
||||
readonly getAllContractState: (
|
||||
address: string,
|
||||
paginationKey?: Uint8Array,
|
||||
) => Promise<IQueryAllContractStateResponse>;
|
||||
) => Promise<QueryAllContractStateResponse>;
|
||||
/**
|
||||
* Returns the data at the key if present (unknown decoded json),
|
||||
* or null if no data at this (contract address, key) pair
|
||||
*/
|
||||
readonly queryContractRaw: (
|
||||
address: string,
|
||||
key: Uint8Array,
|
||||
) => Promise<IQueryRawContractStateResponse>;
|
||||
readonly queryContractRaw: (address: string, key: Uint8Array) => Promise<QueryRawContractStateResponse>;
|
||||
/**
|
||||
* Makes a smart query on the contract and parses the response as JSON.
|
||||
* Throws error if no such contract exists, the query format is invalid or the response is invalid.
|
||||
@ -58,4 +56,3 @@ export interface WasmExtension {
|
||||
};
|
||||
}
|
||||
export declare function setupWasmExtension(base: QueryClient): WasmExtension;
|
||||
export {};
|
||||
|
||||
@ -48,6 +48,7 @@
|
||||
"semver": "^7.3.2"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@cosmjs/stargate": "^0.24.0-alpha.22",
|
||||
"@ledgerhq/hw-transport": "^5.25.0",
|
||||
"@ledgerhq/hw-transport-node-hid": "^5.25.0",
|
||||
"@ledgerhq/hw-transport-webusb": "^5.25.0",
|
||||
|
||||
@ -29,10 +29,10 @@
|
||||
"format-text": "prettier --write --prose-wrap always --print-width 80 \"./*.md\"",
|
||||
"lint": "eslint --max-warnings 0 \"**/*.{js,ts}\"",
|
||||
"lint-fix": "eslint --max-warnings 0 \"**/*.{js,ts}\" --fix",
|
||||
"move-types": "shx rm -rf ./types/* && shx mv build/types/* ./types && shx rm -rf ./types/testdata ./types/*.spec.d.ts",
|
||||
"move-types": "shx rm -rf ./types/* && shx mv build/types/* ./types && shx rm -rf ./types/testdata ./types/*.spec.d.ts \"./types/codec/**/*[!.d].ts\"",
|
||||
"format-types": "prettier --write --loglevel warn \"./types/**/*.d.ts\"",
|
||||
"prebuild": "shx rm -rf ./build",
|
||||
"build": "tsc && shx mkdir -p build/codec/generated && shx cp ./src/codec/generated/*.js ./build/codec/generated/ && shx mkdir -p ./build/types/codec/generated && shx cp ./src/codec/generated/*.d.ts ./build/types/codec/generated",
|
||||
"build": "tsc && shx cp -R ./src/codec ./build/ && shx mkdir -p ./build/types/codec && shx cp -R ./src/codec ./build/types/",
|
||||
"postbuild": "yarn move-types && yarn format-types",
|
||||
"build-or-skip": "[ -n \"$SKIP_BUILD\" ] || yarn build",
|
||||
"test-node": "node jasmine-testrunner.js",
|
||||
@ -43,9 +43,8 @@
|
||||
"pack-web": "yarn build-or-skip && webpack --mode development --config webpack.web.config.js",
|
||||
"preget-proto": "shx rm -rf proto",
|
||||
"get-proto": "REF=v0.40.0 ./scripts/get-proto.sh",
|
||||
"predefine-proto": "./scripts/predefine-proto.sh",
|
||||
"define-proto": "./scripts/define-proto.sh",
|
||||
"postdefine-proto": "prettier --write \"src/codec/generated/codecimpl.*\""
|
||||
"postdefine-proto": "prettier --write \"src/codec/**/*.ts\""
|
||||
},
|
||||
"dependencies": {
|
||||
"@cosmjs/launchpad": "^0.24.0-alpha.22",
|
||||
|
||||
@ -2,15 +2,25 @@
|
||||
set -o errexit -o nounset -o pipefail
|
||||
command -v shellcheck >/dev/null && shellcheck "$0"
|
||||
|
||||
TMP_DIR="./tmp"
|
||||
JS_SOURCE_FILE="$TMP_DIR/codecimpl.js"
|
||||
DEFINITIONS_FILE="$TMP_DIR/codecimpl.d.ts"
|
||||
OUTPUT_DIR="./src/codec/generated/"
|
||||
ROOT_PROTO_DIR="./proto/cosmos/cosmos-sdk"
|
||||
THIRD_PARTY_PROTO_DIR="$ROOT_PROTO_DIR/third_party/proto"
|
||||
COSMOS_PROTO_DIR="$ROOT_PROTO_DIR/proto"
|
||||
OUT_DIR="./src/codec/"
|
||||
|
||||
yarn pbts "$JS_SOURCE_FILE" -o "$DEFINITIONS_FILE"
|
||||
# Remove comments after using them for the .d.ts
|
||||
# Note "When input files are specified on the command line, tsconfig.json files are ignored." (https://www.typescriptlang.org/docs/handbook/tsconfig-json.html)
|
||||
yarn tsc --removeComments --target es2017 --module commonjs --outDir "$OUTPUT_DIR" --allowJs "$JS_SOURCE_FILE"
|
||||
mkdir -p "$OUT_DIR"
|
||||
|
||||
cp "$DEFINITIONS_FILE" "$OUTPUT_DIR"
|
||||
rm "$DEFINITIONS_FILE" "$JS_SOURCE_FILE"
|
||||
protoc \
|
||||
--plugin="$(yarn bin protoc-gen-ts_proto)" \
|
||||
--ts_proto_out="$OUT_DIR" \
|
||||
--proto_path="$COSMOS_PROTO_DIR" \
|
||||
--proto_path="$THIRD_PARTY_PROTO_DIR" \
|
||||
--ts_proto_opt="esModuleInterop=true,forceLong=long,useOptionals=true" \
|
||||
"$THIRD_PARTY_PROTO_DIR/gogoproto/gogo.proto" \
|
||||
"$COSMOS_PROTO_DIR/cosmos/base/v1beta1/coin.proto" \
|
||||
"$COSMOS_PROTO_DIR/cosmos/bank/v1beta1/bank.proto" \
|
||||
"$COSMOS_PROTO_DIR/cosmos/bank/v1beta1/tx.proto" \
|
||||
"$COSMOS_PROTO_DIR/cosmos/crypto/multisig/v1beta1/multisig.proto" \
|
||||
"$COSMOS_PROTO_DIR/cosmos/crypto/secp256k1/keys.proto" \
|
||||
"$COSMOS_PROTO_DIR/cosmos/tx/v1beta1/tx.proto" \
|
||||
"$COSMOS_PROTO_DIR/cosmos/tx/signing/v1beta1/signing.proto" \
|
||||
"$THIRD_PARTY_PROTO_DIR/tendermint/crypto/keys.proto"
|
||||
|
||||
@ -1,33 +0,0 @@
|
||||
#!/bin/bash
|
||||
set -o errexit -o nounset -o pipefail
|
||||
command -v shellcheck >/dev/null && shellcheck "$0"
|
||||
|
||||
GENERATED_DIR="./tmp"
|
||||
ROOT_PROTO_DIR="./proto/cosmos/cosmos-sdk"
|
||||
COSMOS_PROTO_DIR="$ROOT_PROTO_DIR/proto/cosmos"
|
||||
TENDERMINT_PROTO_DIR="$ROOT_PROTO_DIR/third_party/proto/tendermint"
|
||||
|
||||
mkdir -p "$GENERATED_DIR"
|
||||
yarn pbjs \
|
||||
-t static-module \
|
||||
--es6 \
|
||||
-w commonjs \
|
||||
-o "$GENERATED_DIR/codecimpl.js" \
|
||||
--sparse \
|
||||
--no-beautify \
|
||||
--no-delimited \
|
||||
--no-verify \
|
||||
--no-convert \
|
||||
--force-long \
|
||||
"$COSMOS_PROTO_DIR/bank/v1beta1/bank.proto" \
|
||||
"$COSMOS_PROTO_DIR/bank/v1beta1/tx.proto" \
|
||||
"$COSMOS_PROTO_DIR/base/v1beta1/coin.proto" \
|
||||
"$COSMOS_PROTO_DIR/crypto/multisig/v1beta1/multisig.proto" \
|
||||
"$COSMOS_PROTO_DIR/crypto/secp256k1/keys.proto" \
|
||||
"$COSMOS_PROTO_DIR/tx/v1beta1/tx.proto" \
|
||||
"$COSMOS_PROTO_DIR/tx/signing/v1beta1/signing.proto" \
|
||||
"$TENDERMINT_PROTO_DIR/crypto/keys.proto"
|
||||
|
||||
# Work around https://github.com/protobufjs/protobuf.js/issues/1477
|
||||
# shellcheck disable=SC2016
|
||||
sed -i "" -e 's/^const \$root =.*$/const \$root = {};/' "$GENERATED_DIR/codecimpl.js"
|
||||
648
packages/proto-signing/src/codec/cosmos/bank/v1beta1/bank.ts
Normal file
648
packages/proto-signing/src/codec/cosmos/bank/v1beta1/bank.ts
Normal file
@ -0,0 +1,648 @@
|
||||
/* eslint-disable */
|
||||
import { Coin } from "../../../cosmos/base/v1beta1/coin";
|
||||
import Long from "long";
|
||||
import _m0 from "protobufjs/minimal";
|
||||
|
||||
export const protobufPackage = "cosmos.bank.v1beta1";
|
||||
|
||||
/** Params defines the parameters for the bank module. */
|
||||
export interface Params {
|
||||
sendEnabled: SendEnabled[];
|
||||
defaultSendEnabled: boolean;
|
||||
}
|
||||
|
||||
/**
|
||||
* SendEnabled maps coin denom to a send_enabled status (whether a denom is
|
||||
* sendable).
|
||||
*/
|
||||
export interface SendEnabled {
|
||||
denom: string;
|
||||
enabled: boolean;
|
||||
}
|
||||
|
||||
/** Input models transaction input. */
|
||||
export interface Input {
|
||||
address: string;
|
||||
coins: Coin[];
|
||||
}
|
||||
|
||||
/** Output models transaction outputs. */
|
||||
export interface Output {
|
||||
address: string;
|
||||
coins: Coin[];
|
||||
}
|
||||
|
||||
/**
|
||||
* Supply represents a struct that passively keeps track of the total supply
|
||||
* amounts in the network.
|
||||
*/
|
||||
export interface Supply {
|
||||
total: Coin[];
|
||||
}
|
||||
|
||||
/**
|
||||
* DenomUnit represents a struct that describes a given
|
||||
* denomination unit of the basic token.
|
||||
*/
|
||||
export interface DenomUnit {
|
||||
/** denom represents the string name of the given denom unit (e.g uatom). */
|
||||
denom: string;
|
||||
/**
|
||||
* exponent represents power of 10 exponent that one must
|
||||
* raise the base_denom to in order to equal the given DenomUnit's denom
|
||||
* 1 denom = 1^exponent base_denom
|
||||
* (e.g. with a base_denom of uatom, one can create a DenomUnit of 'atom' with
|
||||
* exponent = 6, thus: 1 atom = 10^6 uatom).
|
||||
*/
|
||||
exponent: number;
|
||||
/** aliases is a list of string aliases for the given denom */
|
||||
aliases: string[];
|
||||
}
|
||||
|
||||
/**
|
||||
* Metadata represents a struct that describes
|
||||
* a basic token.
|
||||
*/
|
||||
export interface Metadata {
|
||||
description: string;
|
||||
/** denom_units represents the list of DenomUnit's for a given coin */
|
||||
denomUnits: DenomUnit[];
|
||||
/** base represents the base denom (should be the DenomUnit with exponent = 0). */
|
||||
base: string;
|
||||
/**
|
||||
* display indicates the suggested denom that should be
|
||||
* displayed in clients.
|
||||
*/
|
||||
display: string;
|
||||
}
|
||||
|
||||
const baseParams: object = { defaultSendEnabled: false };
|
||||
|
||||
export const Params = {
|
||||
encode(message: Params, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer {
|
||||
for (const v of message.sendEnabled) {
|
||||
SendEnabled.encode(v!, writer.uint32(10).fork()).ldelim();
|
||||
}
|
||||
writer.uint32(16).bool(message.defaultSendEnabled);
|
||||
return writer;
|
||||
},
|
||||
|
||||
decode(input: _m0.Reader | Uint8Array, length?: number): Params {
|
||||
const reader = input instanceof Uint8Array ? new _m0.Reader(input) : input;
|
||||
let end = length === undefined ? reader.len : reader.pos + length;
|
||||
const message = { ...baseParams } as Params;
|
||||
message.sendEnabled = [];
|
||||
while (reader.pos < end) {
|
||||
const tag = reader.uint32();
|
||||
switch (tag >>> 3) {
|
||||
case 1:
|
||||
message.sendEnabled.push(SendEnabled.decode(reader, reader.uint32()));
|
||||
break;
|
||||
case 2:
|
||||
message.defaultSendEnabled = reader.bool();
|
||||
break;
|
||||
default:
|
||||
reader.skipType(tag & 7);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return message;
|
||||
},
|
||||
|
||||
fromJSON(object: any): Params {
|
||||
const message = { ...baseParams } as Params;
|
||||
message.sendEnabled = [];
|
||||
if (object.sendEnabled !== undefined && object.sendEnabled !== null) {
|
||||
for (const e of object.sendEnabled) {
|
||||
message.sendEnabled.push(SendEnabled.fromJSON(e));
|
||||
}
|
||||
}
|
||||
if (object.defaultSendEnabled !== undefined && object.defaultSendEnabled !== null) {
|
||||
message.defaultSendEnabled = Boolean(object.defaultSendEnabled);
|
||||
} else {
|
||||
message.defaultSendEnabled = false;
|
||||
}
|
||||
return message;
|
||||
},
|
||||
|
||||
fromPartial(object: DeepPartial<Params>): Params {
|
||||
const message = { ...baseParams } as Params;
|
||||
message.sendEnabled = [];
|
||||
if (object.sendEnabled !== undefined && object.sendEnabled !== null) {
|
||||
for (const e of object.sendEnabled) {
|
||||
message.sendEnabled.push(SendEnabled.fromPartial(e));
|
||||
}
|
||||
}
|
||||
if (object.defaultSendEnabled !== undefined && object.defaultSendEnabled !== null) {
|
||||
message.defaultSendEnabled = object.defaultSendEnabled;
|
||||
} else {
|
||||
message.defaultSendEnabled = false;
|
||||
}
|
||||
return message;
|
||||
},
|
||||
|
||||
toJSON(message: Params): unknown {
|
||||
const obj: any = {};
|
||||
if (message.sendEnabled) {
|
||||
obj.sendEnabled = message.sendEnabled.map((e) => (e ? SendEnabled.toJSON(e) : undefined));
|
||||
} else {
|
||||
obj.sendEnabled = [];
|
||||
}
|
||||
message.defaultSendEnabled !== undefined && (obj.defaultSendEnabled = message.defaultSendEnabled);
|
||||
return obj;
|
||||
},
|
||||
};
|
||||
|
||||
const baseSendEnabled: object = { denom: "", enabled: false };
|
||||
|
||||
export const SendEnabled = {
|
||||
encode(message: SendEnabled, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer {
|
||||
writer.uint32(10).string(message.denom);
|
||||
writer.uint32(16).bool(message.enabled);
|
||||
return writer;
|
||||
},
|
||||
|
||||
decode(input: _m0.Reader | Uint8Array, length?: number): SendEnabled {
|
||||
const reader = input instanceof Uint8Array ? new _m0.Reader(input) : input;
|
||||
let end = length === undefined ? reader.len : reader.pos + length;
|
||||
const message = { ...baseSendEnabled } as SendEnabled;
|
||||
while (reader.pos < end) {
|
||||
const tag = reader.uint32();
|
||||
switch (tag >>> 3) {
|
||||
case 1:
|
||||
message.denom = reader.string();
|
||||
break;
|
||||
case 2:
|
||||
message.enabled = reader.bool();
|
||||
break;
|
||||
default:
|
||||
reader.skipType(tag & 7);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return message;
|
||||
},
|
||||
|
||||
fromJSON(object: any): SendEnabled {
|
||||
const message = { ...baseSendEnabled } as SendEnabled;
|
||||
if (object.denom !== undefined && object.denom !== null) {
|
||||
message.denom = String(object.denom);
|
||||
} else {
|
||||
message.denom = "";
|
||||
}
|
||||
if (object.enabled !== undefined && object.enabled !== null) {
|
||||
message.enabled = Boolean(object.enabled);
|
||||
} else {
|
||||
message.enabled = false;
|
||||
}
|
||||
return message;
|
||||
},
|
||||
|
||||
fromPartial(object: DeepPartial<SendEnabled>): SendEnabled {
|
||||
const message = { ...baseSendEnabled } as SendEnabled;
|
||||
if (object.denom !== undefined && object.denom !== null) {
|
||||
message.denom = object.denom;
|
||||
} else {
|
||||
message.denom = "";
|
||||
}
|
||||
if (object.enabled !== undefined && object.enabled !== null) {
|
||||
message.enabled = object.enabled;
|
||||
} else {
|
||||
message.enabled = false;
|
||||
}
|
||||
return message;
|
||||
},
|
||||
|
||||
toJSON(message: SendEnabled): unknown {
|
||||
const obj: any = {};
|
||||
message.denom !== undefined && (obj.denom = message.denom);
|
||||
message.enabled !== undefined && (obj.enabled = message.enabled);
|
||||
return obj;
|
||||
},
|
||||
};
|
||||
|
||||
const baseInput: object = { address: "" };
|
||||
|
||||
export const Input = {
|
||||
encode(message: Input, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer {
|
||||
writer.uint32(10).string(message.address);
|
||||
for (const v of message.coins) {
|
||||
Coin.encode(v!, writer.uint32(18).fork()).ldelim();
|
||||
}
|
||||
return writer;
|
||||
},
|
||||
|
||||
decode(input: _m0.Reader | Uint8Array, length?: number): Input {
|
||||
const reader = input instanceof Uint8Array ? new _m0.Reader(input) : input;
|
||||
let end = length === undefined ? reader.len : reader.pos + length;
|
||||
const message = { ...baseInput } as Input;
|
||||
message.coins = [];
|
||||
while (reader.pos < end) {
|
||||
const tag = reader.uint32();
|
||||
switch (tag >>> 3) {
|
||||
case 1:
|
||||
message.address = reader.string();
|
||||
break;
|
||||
case 2:
|
||||
message.coins.push(Coin.decode(reader, reader.uint32()));
|
||||
break;
|
||||
default:
|
||||
reader.skipType(tag & 7);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return message;
|
||||
},
|
||||
|
||||
fromJSON(object: any): Input {
|
||||
const message = { ...baseInput } as Input;
|
||||
message.coins = [];
|
||||
if (object.address !== undefined && object.address !== null) {
|
||||
message.address = String(object.address);
|
||||
} else {
|
||||
message.address = "";
|
||||
}
|
||||
if (object.coins !== undefined && object.coins !== null) {
|
||||
for (const e of object.coins) {
|
||||
message.coins.push(Coin.fromJSON(e));
|
||||
}
|
||||
}
|
||||
return message;
|
||||
},
|
||||
|
||||
fromPartial(object: DeepPartial<Input>): Input {
|
||||
const message = { ...baseInput } as Input;
|
||||
message.coins = [];
|
||||
if (object.address !== undefined && object.address !== null) {
|
||||
message.address = object.address;
|
||||
} else {
|
||||
message.address = "";
|
||||
}
|
||||
if (object.coins !== undefined && object.coins !== null) {
|
||||
for (const e of object.coins) {
|
||||
message.coins.push(Coin.fromPartial(e));
|
||||
}
|
||||
}
|
||||
return message;
|
||||
},
|
||||
|
||||
toJSON(message: Input): unknown {
|
||||
const obj: any = {};
|
||||
message.address !== undefined && (obj.address = message.address);
|
||||
if (message.coins) {
|
||||
obj.coins = message.coins.map((e) => (e ? Coin.toJSON(e) : undefined));
|
||||
} else {
|
||||
obj.coins = [];
|
||||
}
|
||||
return obj;
|
||||
},
|
||||
};
|
||||
|
||||
const baseOutput: object = { address: "" };
|
||||
|
||||
export const Output = {
|
||||
encode(message: Output, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer {
|
||||
writer.uint32(10).string(message.address);
|
||||
for (const v of message.coins) {
|
||||
Coin.encode(v!, writer.uint32(18).fork()).ldelim();
|
||||
}
|
||||
return writer;
|
||||
},
|
||||
|
||||
decode(input: _m0.Reader | Uint8Array, length?: number): Output {
|
||||
const reader = input instanceof Uint8Array ? new _m0.Reader(input) : input;
|
||||
let end = length === undefined ? reader.len : reader.pos + length;
|
||||
const message = { ...baseOutput } as Output;
|
||||
message.coins = [];
|
||||
while (reader.pos < end) {
|
||||
const tag = reader.uint32();
|
||||
switch (tag >>> 3) {
|
||||
case 1:
|
||||
message.address = reader.string();
|
||||
break;
|
||||
case 2:
|
||||
message.coins.push(Coin.decode(reader, reader.uint32()));
|
||||
break;
|
||||
default:
|
||||
reader.skipType(tag & 7);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return message;
|
||||
},
|
||||
|
||||
fromJSON(object: any): Output {
|
||||
const message = { ...baseOutput } as Output;
|
||||
message.coins = [];
|
||||
if (object.address !== undefined && object.address !== null) {
|
||||
message.address = String(object.address);
|
||||
} else {
|
||||
message.address = "";
|
||||
}
|
||||
if (object.coins !== undefined && object.coins !== null) {
|
||||
for (const e of object.coins) {
|
||||
message.coins.push(Coin.fromJSON(e));
|
||||
}
|
||||
}
|
||||
return message;
|
||||
},
|
||||
|
||||
fromPartial(object: DeepPartial<Output>): Output {
|
||||
const message = { ...baseOutput } as Output;
|
||||
message.coins = [];
|
||||
if (object.address !== undefined && object.address !== null) {
|
||||
message.address = object.address;
|
||||
} else {
|
||||
message.address = "";
|
||||
}
|
||||
if (object.coins !== undefined && object.coins !== null) {
|
||||
for (const e of object.coins) {
|
||||
message.coins.push(Coin.fromPartial(e));
|
||||
}
|
||||
}
|
||||
return message;
|
||||
},
|
||||
|
||||
toJSON(message: Output): unknown {
|
||||
const obj: any = {};
|
||||
message.address !== undefined && (obj.address = message.address);
|
||||
if (message.coins) {
|
||||
obj.coins = message.coins.map((e) => (e ? Coin.toJSON(e) : undefined));
|
||||
} else {
|
||||
obj.coins = [];
|
||||
}
|
||||
return obj;
|
||||
},
|
||||
};
|
||||
|
||||
const baseSupply: object = {};
|
||||
|
||||
export const Supply = {
|
||||
encode(message: Supply, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer {
|
||||
for (const v of message.total) {
|
||||
Coin.encode(v!, writer.uint32(10).fork()).ldelim();
|
||||
}
|
||||
return writer;
|
||||
},
|
||||
|
||||
decode(input: _m0.Reader | Uint8Array, length?: number): Supply {
|
||||
const reader = input instanceof Uint8Array ? new _m0.Reader(input) : input;
|
||||
let end = length === undefined ? reader.len : reader.pos + length;
|
||||
const message = { ...baseSupply } as Supply;
|
||||
message.total = [];
|
||||
while (reader.pos < end) {
|
||||
const tag = reader.uint32();
|
||||
switch (tag >>> 3) {
|
||||
case 1:
|
||||
message.total.push(Coin.decode(reader, reader.uint32()));
|
||||
break;
|
||||
default:
|
||||
reader.skipType(tag & 7);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return message;
|
||||
},
|
||||
|
||||
fromJSON(object: any): Supply {
|
||||
const message = { ...baseSupply } as Supply;
|
||||
message.total = [];
|
||||
if (object.total !== undefined && object.total !== null) {
|
||||
for (const e of object.total) {
|
||||
message.total.push(Coin.fromJSON(e));
|
||||
}
|
||||
}
|
||||
return message;
|
||||
},
|
||||
|
||||
fromPartial(object: DeepPartial<Supply>): Supply {
|
||||
const message = { ...baseSupply } as Supply;
|
||||
message.total = [];
|
||||
if (object.total !== undefined && object.total !== null) {
|
||||
for (const e of object.total) {
|
||||
message.total.push(Coin.fromPartial(e));
|
||||
}
|
||||
}
|
||||
return message;
|
||||
},
|
||||
|
||||
toJSON(message: Supply): unknown {
|
||||
const obj: any = {};
|
||||
if (message.total) {
|
||||
obj.total = message.total.map((e) => (e ? Coin.toJSON(e) : undefined));
|
||||
} else {
|
||||
obj.total = [];
|
||||
}
|
||||
return obj;
|
||||
},
|
||||
};
|
||||
|
||||
const baseDenomUnit: object = { denom: "", exponent: 0, aliases: "" };
|
||||
|
||||
export const DenomUnit = {
|
||||
encode(message: DenomUnit, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer {
|
||||
writer.uint32(10).string(message.denom);
|
||||
writer.uint32(16).uint32(message.exponent);
|
||||
for (const v of message.aliases) {
|
||||
writer.uint32(26).string(v!);
|
||||
}
|
||||
return writer;
|
||||
},
|
||||
|
||||
decode(input: _m0.Reader | Uint8Array, length?: number): DenomUnit {
|
||||
const reader = input instanceof Uint8Array ? new _m0.Reader(input) : input;
|
||||
let end = length === undefined ? reader.len : reader.pos + length;
|
||||
const message = { ...baseDenomUnit } as DenomUnit;
|
||||
message.aliases = [];
|
||||
while (reader.pos < end) {
|
||||
const tag = reader.uint32();
|
||||
switch (tag >>> 3) {
|
||||
case 1:
|
||||
message.denom = reader.string();
|
||||
break;
|
||||
case 2:
|
||||
message.exponent = reader.uint32();
|
||||
break;
|
||||
case 3:
|
||||
message.aliases.push(reader.string());
|
||||
break;
|
||||
default:
|
||||
reader.skipType(tag & 7);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return message;
|
||||
},
|
||||
|
||||
fromJSON(object: any): DenomUnit {
|
||||
const message = { ...baseDenomUnit } as DenomUnit;
|
||||
message.aliases = [];
|
||||
if (object.denom !== undefined && object.denom !== null) {
|
||||
message.denom = String(object.denom);
|
||||
} else {
|
||||
message.denom = "";
|
||||
}
|
||||
if (object.exponent !== undefined && object.exponent !== null) {
|
||||
message.exponent = Number(object.exponent);
|
||||
} else {
|
||||
message.exponent = 0;
|
||||
}
|
||||
if (object.aliases !== undefined && object.aliases !== null) {
|
||||
for (const e of object.aliases) {
|
||||
message.aliases.push(String(e));
|
||||
}
|
||||
}
|
||||
return message;
|
||||
},
|
||||
|
||||
fromPartial(object: DeepPartial<DenomUnit>): DenomUnit {
|
||||
const message = { ...baseDenomUnit } as DenomUnit;
|
||||
message.aliases = [];
|
||||
if (object.denom !== undefined && object.denom !== null) {
|
||||
message.denom = object.denom;
|
||||
} else {
|
||||
message.denom = "";
|
||||
}
|
||||
if (object.exponent !== undefined && object.exponent !== null) {
|
||||
message.exponent = object.exponent;
|
||||
} else {
|
||||
message.exponent = 0;
|
||||
}
|
||||
if (object.aliases !== undefined && object.aliases !== null) {
|
||||
for (const e of object.aliases) {
|
||||
message.aliases.push(e);
|
||||
}
|
||||
}
|
||||
return message;
|
||||
},
|
||||
|
||||
toJSON(message: DenomUnit): unknown {
|
||||
const obj: any = {};
|
||||
message.denom !== undefined && (obj.denom = message.denom);
|
||||
message.exponent !== undefined && (obj.exponent = message.exponent);
|
||||
if (message.aliases) {
|
||||
obj.aliases = message.aliases.map((e) => e);
|
||||
} else {
|
||||
obj.aliases = [];
|
||||
}
|
||||
return obj;
|
||||
},
|
||||
};
|
||||
|
||||
const baseMetadata: object = { description: "", base: "", display: "" };
|
||||
|
||||
export const Metadata = {
|
||||
encode(message: Metadata, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer {
|
||||
writer.uint32(10).string(message.description);
|
||||
for (const v of message.denomUnits) {
|
||||
DenomUnit.encode(v!, writer.uint32(18).fork()).ldelim();
|
||||
}
|
||||
writer.uint32(26).string(message.base);
|
||||
writer.uint32(34).string(message.display);
|
||||
return writer;
|
||||
},
|
||||
|
||||
decode(input: _m0.Reader | Uint8Array, length?: number): Metadata {
|
||||
const reader = input instanceof Uint8Array ? new _m0.Reader(input) : input;
|
||||
let end = length === undefined ? reader.len : reader.pos + length;
|
||||
const message = { ...baseMetadata } as Metadata;
|
||||
message.denomUnits = [];
|
||||
while (reader.pos < end) {
|
||||
const tag = reader.uint32();
|
||||
switch (tag >>> 3) {
|
||||
case 1:
|
||||
message.description = reader.string();
|
||||
break;
|
||||
case 2:
|
||||
message.denomUnits.push(DenomUnit.decode(reader, reader.uint32()));
|
||||
break;
|
||||
case 3:
|
||||
message.base = reader.string();
|
||||
break;
|
||||
case 4:
|
||||
message.display = reader.string();
|
||||
break;
|
||||
default:
|
||||
reader.skipType(tag & 7);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return message;
|
||||
},
|
||||
|
||||
fromJSON(object: any): Metadata {
|
||||
const message = { ...baseMetadata } as Metadata;
|
||||
message.denomUnits = [];
|
||||
if (object.description !== undefined && object.description !== null) {
|
||||
message.description = String(object.description);
|
||||
} else {
|
||||
message.description = "";
|
||||
}
|
||||
if (object.denomUnits !== undefined && object.denomUnits !== null) {
|
||||
for (const e of object.denomUnits) {
|
||||
message.denomUnits.push(DenomUnit.fromJSON(e));
|
||||
}
|
||||
}
|
||||
if (object.base !== undefined && object.base !== null) {
|
||||
message.base = String(object.base);
|
||||
} else {
|
||||
message.base = "";
|
||||
}
|
||||
if (object.display !== undefined && object.display !== null) {
|
||||
message.display = String(object.display);
|
||||
} else {
|
||||
message.display = "";
|
||||
}
|
||||
return message;
|
||||
},
|
||||
|
||||
fromPartial(object: DeepPartial<Metadata>): Metadata {
|
||||
const message = { ...baseMetadata } as Metadata;
|
||||
message.denomUnits = [];
|
||||
if (object.description !== undefined && object.description !== null) {
|
||||
message.description = object.description;
|
||||
} else {
|
||||
message.description = "";
|
||||
}
|
||||
if (object.denomUnits !== undefined && object.denomUnits !== null) {
|
||||
for (const e of object.denomUnits) {
|
||||
message.denomUnits.push(DenomUnit.fromPartial(e));
|
||||
}
|
||||
}
|
||||
if (object.base !== undefined && object.base !== null) {
|
||||
message.base = object.base;
|
||||
} else {
|
||||
message.base = "";
|
||||
}
|
||||
if (object.display !== undefined && object.display !== null) {
|
||||
message.display = object.display;
|
||||
} else {
|
||||
message.display = "";
|
||||
}
|
||||
return message;
|
||||
},
|
||||
|
||||
toJSON(message: Metadata): unknown {
|
||||
const obj: any = {};
|
||||
message.description !== undefined && (obj.description = message.description);
|
||||
if (message.denomUnits) {
|
||||
obj.denomUnits = message.denomUnits.map((e) => (e ? DenomUnit.toJSON(e) : undefined));
|
||||
} else {
|
||||
obj.denomUnits = [];
|
||||
}
|
||||
message.base !== undefined && (obj.base = message.base);
|
||||
message.display !== undefined && (obj.display = message.display);
|
||||
return obj;
|
||||
},
|
||||
};
|
||||
|
||||
type Builtin = Date | Function | Uint8Array | string | number | undefined | Long;
|
||||
export type DeepPartial<T> = T extends Builtin
|
||||
? T
|
||||
: T extends Array<infer U>
|
||||
? Array<DeepPartial<U>>
|
||||
: T extends ReadonlyArray<infer U>
|
||||
? ReadonlyArray<DeepPartial<U>>
|
||||
: T extends {}
|
||||
? { [K in keyof T]?: DeepPartial<T[K]> }
|
||||
: Partial<T>;
|
||||
321
packages/proto-signing/src/codec/cosmos/bank/v1beta1/tx.ts
Normal file
321
packages/proto-signing/src/codec/cosmos/bank/v1beta1/tx.ts
Normal file
@ -0,0 +1,321 @@
|
||||
/* eslint-disable */
|
||||
import { Coin } from "../../../cosmos/base/v1beta1/coin";
|
||||
import { Input, Output } from "../../../cosmos/bank/v1beta1/bank";
|
||||
import _m0 from "protobufjs/minimal";
|
||||
import Long from "long";
|
||||
|
||||
export const protobufPackage = "cosmos.bank.v1beta1";
|
||||
|
||||
/** MsgSend represents a message to send coins from one account to another. */
|
||||
export interface MsgSend {
|
||||
fromAddress: string;
|
||||
toAddress: string;
|
||||
amount: Coin[];
|
||||
}
|
||||
|
||||
/** MsgSendResponse defines the Msg/Send response type. */
|
||||
export interface MsgSendResponse {}
|
||||
|
||||
/** MsgMultiSend represents an arbitrary multi-in, multi-out send message. */
|
||||
export interface MsgMultiSend {
|
||||
inputs: Input[];
|
||||
outputs: Output[];
|
||||
}
|
||||
|
||||
/** MsgMultiSendResponse defines the Msg/MultiSend response type. */
|
||||
export interface MsgMultiSendResponse {}
|
||||
|
||||
const baseMsgSend: object = { fromAddress: "", toAddress: "" };
|
||||
|
||||
export const MsgSend = {
|
||||
encode(message: MsgSend, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer {
|
||||
writer.uint32(10).string(message.fromAddress);
|
||||
writer.uint32(18).string(message.toAddress);
|
||||
for (const v of message.amount) {
|
||||
Coin.encode(v!, writer.uint32(26).fork()).ldelim();
|
||||
}
|
||||
return writer;
|
||||
},
|
||||
|
||||
decode(input: _m0.Reader | Uint8Array, length?: number): MsgSend {
|
||||
const reader = input instanceof Uint8Array ? new _m0.Reader(input) : input;
|
||||
let end = length === undefined ? reader.len : reader.pos + length;
|
||||
const message = { ...baseMsgSend } as MsgSend;
|
||||
message.amount = [];
|
||||
while (reader.pos < end) {
|
||||
const tag = reader.uint32();
|
||||
switch (tag >>> 3) {
|
||||
case 1:
|
||||
message.fromAddress = reader.string();
|
||||
break;
|
||||
case 2:
|
||||
message.toAddress = reader.string();
|
||||
break;
|
||||
case 3:
|
||||
message.amount.push(Coin.decode(reader, reader.uint32()));
|
||||
break;
|
||||
default:
|
||||
reader.skipType(tag & 7);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return message;
|
||||
},
|
||||
|
||||
fromJSON(object: any): MsgSend {
|
||||
const message = { ...baseMsgSend } as MsgSend;
|
||||
message.amount = [];
|
||||
if (object.fromAddress !== undefined && object.fromAddress !== null) {
|
||||
message.fromAddress = String(object.fromAddress);
|
||||
} else {
|
||||
message.fromAddress = "";
|
||||
}
|
||||
if (object.toAddress !== undefined && object.toAddress !== null) {
|
||||
message.toAddress = String(object.toAddress);
|
||||
} else {
|
||||
message.toAddress = "";
|
||||
}
|
||||
if (object.amount !== undefined && object.amount !== null) {
|
||||
for (const e of object.amount) {
|
||||
message.amount.push(Coin.fromJSON(e));
|
||||
}
|
||||
}
|
||||
return message;
|
||||
},
|
||||
|
||||
fromPartial(object: DeepPartial<MsgSend>): MsgSend {
|
||||
const message = { ...baseMsgSend } as MsgSend;
|
||||
message.amount = [];
|
||||
if (object.fromAddress !== undefined && object.fromAddress !== null) {
|
||||
message.fromAddress = object.fromAddress;
|
||||
} else {
|
||||
message.fromAddress = "";
|
||||
}
|
||||
if (object.toAddress !== undefined && object.toAddress !== null) {
|
||||
message.toAddress = object.toAddress;
|
||||
} else {
|
||||
message.toAddress = "";
|
||||
}
|
||||
if (object.amount !== undefined && object.amount !== null) {
|
||||
for (const e of object.amount) {
|
||||
message.amount.push(Coin.fromPartial(e));
|
||||
}
|
||||
}
|
||||
return message;
|
||||
},
|
||||
|
||||
toJSON(message: MsgSend): unknown {
|
||||
const obj: any = {};
|
||||
message.fromAddress !== undefined && (obj.fromAddress = message.fromAddress);
|
||||
message.toAddress !== undefined && (obj.toAddress = message.toAddress);
|
||||
if (message.amount) {
|
||||
obj.amount = message.amount.map((e) => (e ? Coin.toJSON(e) : undefined));
|
||||
} else {
|
||||
obj.amount = [];
|
||||
}
|
||||
return obj;
|
||||
},
|
||||
};
|
||||
|
||||
const baseMsgSendResponse: object = {};
|
||||
|
||||
export const MsgSendResponse = {
|
||||
encode(_: MsgSendResponse, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer {
|
||||
return writer;
|
||||
},
|
||||
|
||||
decode(input: _m0.Reader | Uint8Array, length?: number): MsgSendResponse {
|
||||
const reader = input instanceof Uint8Array ? new _m0.Reader(input) : input;
|
||||
let end = length === undefined ? reader.len : reader.pos + length;
|
||||
const message = { ...baseMsgSendResponse } as MsgSendResponse;
|
||||
while (reader.pos < end) {
|
||||
const tag = reader.uint32();
|
||||
switch (tag >>> 3) {
|
||||
default:
|
||||
reader.skipType(tag & 7);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return message;
|
||||
},
|
||||
|
||||
fromJSON(_: any): MsgSendResponse {
|
||||
const message = { ...baseMsgSendResponse } as MsgSendResponse;
|
||||
return message;
|
||||
},
|
||||
|
||||
fromPartial(_: DeepPartial<MsgSendResponse>): MsgSendResponse {
|
||||
const message = { ...baseMsgSendResponse } as MsgSendResponse;
|
||||
return message;
|
||||
},
|
||||
|
||||
toJSON(_: MsgSendResponse): unknown {
|
||||
const obj: any = {};
|
||||
return obj;
|
||||
},
|
||||
};
|
||||
|
||||
const baseMsgMultiSend: object = {};
|
||||
|
||||
export const MsgMultiSend = {
|
||||
encode(message: MsgMultiSend, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer {
|
||||
for (const v of message.inputs) {
|
||||
Input.encode(v!, writer.uint32(10).fork()).ldelim();
|
||||
}
|
||||
for (const v of message.outputs) {
|
||||
Output.encode(v!, writer.uint32(18).fork()).ldelim();
|
||||
}
|
||||
return writer;
|
||||
},
|
||||
|
||||
decode(input: _m0.Reader | Uint8Array, length?: number): MsgMultiSend {
|
||||
const reader = input instanceof Uint8Array ? new _m0.Reader(input) : input;
|
||||
let end = length === undefined ? reader.len : reader.pos + length;
|
||||
const message = { ...baseMsgMultiSend } as MsgMultiSend;
|
||||
message.inputs = [];
|
||||
message.outputs = [];
|
||||
while (reader.pos < end) {
|
||||
const tag = reader.uint32();
|
||||
switch (tag >>> 3) {
|
||||
case 1:
|
||||
message.inputs.push(Input.decode(reader, reader.uint32()));
|
||||
break;
|
||||
case 2:
|
||||
message.outputs.push(Output.decode(reader, reader.uint32()));
|
||||
break;
|
||||
default:
|
||||
reader.skipType(tag & 7);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return message;
|
||||
},
|
||||
|
||||
fromJSON(object: any): MsgMultiSend {
|
||||
const message = { ...baseMsgMultiSend } as MsgMultiSend;
|
||||
message.inputs = [];
|
||||
message.outputs = [];
|
||||
if (object.inputs !== undefined && object.inputs !== null) {
|
||||
for (const e of object.inputs) {
|
||||
message.inputs.push(Input.fromJSON(e));
|
||||
}
|
||||
}
|
||||
if (object.outputs !== undefined && object.outputs !== null) {
|
||||
for (const e of object.outputs) {
|
||||
message.outputs.push(Output.fromJSON(e));
|
||||
}
|
||||
}
|
||||
return message;
|
||||
},
|
||||
|
||||
fromPartial(object: DeepPartial<MsgMultiSend>): MsgMultiSend {
|
||||
const message = { ...baseMsgMultiSend } as MsgMultiSend;
|
||||
message.inputs = [];
|
||||
message.outputs = [];
|
||||
if (object.inputs !== undefined && object.inputs !== null) {
|
||||
for (const e of object.inputs) {
|
||||
message.inputs.push(Input.fromPartial(e));
|
||||
}
|
||||
}
|
||||
if (object.outputs !== undefined && object.outputs !== null) {
|
||||
for (const e of object.outputs) {
|
||||
message.outputs.push(Output.fromPartial(e));
|
||||
}
|
||||
}
|
||||
return message;
|
||||
},
|
||||
|
||||
toJSON(message: MsgMultiSend): unknown {
|
||||
const obj: any = {};
|
||||
if (message.inputs) {
|
||||
obj.inputs = message.inputs.map((e) => (e ? Input.toJSON(e) : undefined));
|
||||
} else {
|
||||
obj.inputs = [];
|
||||
}
|
||||
if (message.outputs) {
|
||||
obj.outputs = message.outputs.map((e) => (e ? Output.toJSON(e) : undefined));
|
||||
} else {
|
||||
obj.outputs = [];
|
||||
}
|
||||
return obj;
|
||||
},
|
||||
};
|
||||
|
||||
const baseMsgMultiSendResponse: object = {};
|
||||
|
||||
export const MsgMultiSendResponse = {
|
||||
encode(_: MsgMultiSendResponse, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer {
|
||||
return writer;
|
||||
},
|
||||
|
||||
decode(input: _m0.Reader | Uint8Array, length?: number): MsgMultiSendResponse {
|
||||
const reader = input instanceof Uint8Array ? new _m0.Reader(input) : input;
|
||||
let end = length === undefined ? reader.len : reader.pos + length;
|
||||
const message = { ...baseMsgMultiSendResponse } as MsgMultiSendResponse;
|
||||
while (reader.pos < end) {
|
||||
const tag = reader.uint32();
|
||||
switch (tag >>> 3) {
|
||||
default:
|
||||
reader.skipType(tag & 7);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return message;
|
||||
},
|
||||
|
||||
fromJSON(_: any): MsgMultiSendResponse {
|
||||
const message = { ...baseMsgMultiSendResponse } as MsgMultiSendResponse;
|
||||
return message;
|
||||
},
|
||||
|
||||
fromPartial(_: DeepPartial<MsgMultiSendResponse>): MsgMultiSendResponse {
|
||||
const message = { ...baseMsgMultiSendResponse } as MsgMultiSendResponse;
|
||||
return message;
|
||||
},
|
||||
|
||||
toJSON(_: MsgMultiSendResponse): unknown {
|
||||
const obj: any = {};
|
||||
return obj;
|
||||
},
|
||||
};
|
||||
|
||||
/** Msg defines the bank Msg service. */
|
||||
export interface Msg {
|
||||
/** Send defines a method for sending coins from one account to another account. */
|
||||
Send(request: MsgSend): Promise<MsgSendResponse>;
|
||||
/** MultiSend defines a method for sending coins from some accounts to other accounts. */
|
||||
MultiSend(request: MsgMultiSend): Promise<MsgMultiSendResponse>;
|
||||
}
|
||||
|
||||
export class MsgClientImpl implements Msg {
|
||||
private readonly rpc: Rpc;
|
||||
constructor(rpc: Rpc) {
|
||||
this.rpc = rpc;
|
||||
}
|
||||
Send(request: MsgSend): Promise<MsgSendResponse> {
|
||||
const data = MsgSend.encode(request).finish();
|
||||
const promise = this.rpc.request("cosmos.bank.v1beta1.Msg", "methodDesc.name", data);
|
||||
return promise.then((data) => MsgSendResponse.decode(new _m0.Reader(data)));
|
||||
}
|
||||
|
||||
MultiSend(request: MsgMultiSend): Promise<MsgMultiSendResponse> {
|
||||
const data = MsgMultiSend.encode(request).finish();
|
||||
const promise = this.rpc.request("cosmos.bank.v1beta1.Msg", "methodDesc.name", data);
|
||||
return promise.then((data) => MsgMultiSendResponse.decode(new _m0.Reader(data)));
|
||||
}
|
||||
}
|
||||
|
||||
interface Rpc {
|
||||
request(service: string, method: string, data: Uint8Array): Promise<Uint8Array>;
|
||||
}
|
||||
|
||||
type Builtin = Date | Function | Uint8Array | string | number | undefined | Long;
|
||||
export type DeepPartial<T> = T extends Builtin
|
||||
? T
|
||||
: T extends Array<infer U>
|
||||
? Array<DeepPartial<U>>
|
||||
: T extends ReadonlyArray<infer U>
|
||||
? ReadonlyArray<DeepPartial<U>>
|
||||
: T extends {}
|
||||
? { [K in keyof T]?: DeepPartial<T[K]> }
|
||||
: Partial<T>;
|
||||
290
packages/proto-signing/src/codec/cosmos/base/v1beta1/coin.ts
Normal file
290
packages/proto-signing/src/codec/cosmos/base/v1beta1/coin.ts
Normal file
@ -0,0 +1,290 @@
|
||||
/* eslint-disable */
|
||||
import Long from "long";
|
||||
import _m0 from "protobufjs/minimal";
|
||||
|
||||
export const protobufPackage = "cosmos.base.v1beta1";
|
||||
|
||||
/**
|
||||
* Coin defines a token with a denomination and an amount.
|
||||
*
|
||||
* NOTE: The amount field is an Int which implements the custom method
|
||||
* signatures required by gogoproto.
|
||||
*/
|
||||
export interface Coin {
|
||||
denom: string;
|
||||
amount: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* DecCoin defines a token with a denomination and a decimal amount.
|
||||
*
|
||||
* NOTE: The amount field is an Dec which implements the custom method
|
||||
* signatures required by gogoproto.
|
||||
*/
|
||||
export interface DecCoin {
|
||||
denom: string;
|
||||
amount: string;
|
||||
}
|
||||
|
||||
/** IntProto defines a Protobuf wrapper around an Int object. */
|
||||
export interface IntProto {
|
||||
int: string;
|
||||
}
|
||||
|
||||
/** DecProto defines a Protobuf wrapper around a Dec object. */
|
||||
export interface DecProto {
|
||||
dec: string;
|
||||
}
|
||||
|
||||
const baseCoin: object = { denom: "", amount: "" };
|
||||
|
||||
export const Coin = {
|
||||
encode(message: Coin, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer {
|
||||
writer.uint32(10).string(message.denom);
|
||||
writer.uint32(18).string(message.amount);
|
||||
return writer;
|
||||
},
|
||||
|
||||
decode(input: _m0.Reader | Uint8Array, length?: number): Coin {
|
||||
const reader = input instanceof Uint8Array ? new _m0.Reader(input) : input;
|
||||
let end = length === undefined ? reader.len : reader.pos + length;
|
||||
const message = { ...baseCoin } as Coin;
|
||||
while (reader.pos < end) {
|
||||
const tag = reader.uint32();
|
||||
switch (tag >>> 3) {
|
||||
case 1:
|
||||
message.denom = reader.string();
|
||||
break;
|
||||
case 2:
|
||||
message.amount = reader.string();
|
||||
break;
|
||||
default:
|
||||
reader.skipType(tag & 7);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return message;
|
||||
},
|
||||
|
||||
fromJSON(object: any): Coin {
|
||||
const message = { ...baseCoin } as Coin;
|
||||
if (object.denom !== undefined && object.denom !== null) {
|
||||
message.denom = String(object.denom);
|
||||
} else {
|
||||
message.denom = "";
|
||||
}
|
||||
if (object.amount !== undefined && object.amount !== null) {
|
||||
message.amount = String(object.amount);
|
||||
} else {
|
||||
message.amount = "";
|
||||
}
|
||||
return message;
|
||||
},
|
||||
|
||||
fromPartial(object: DeepPartial<Coin>): Coin {
|
||||
const message = { ...baseCoin } as Coin;
|
||||
if (object.denom !== undefined && object.denom !== null) {
|
||||
message.denom = object.denom;
|
||||
} else {
|
||||
message.denom = "";
|
||||
}
|
||||
if (object.amount !== undefined && object.amount !== null) {
|
||||
message.amount = object.amount;
|
||||
} else {
|
||||
message.amount = "";
|
||||
}
|
||||
return message;
|
||||
},
|
||||
|
||||
toJSON(message: Coin): unknown {
|
||||
const obj: any = {};
|
||||
message.denom !== undefined && (obj.denom = message.denom);
|
||||
message.amount !== undefined && (obj.amount = message.amount);
|
||||
return obj;
|
||||
},
|
||||
};
|
||||
|
||||
const baseDecCoin: object = { denom: "", amount: "" };
|
||||
|
||||
export const DecCoin = {
|
||||
encode(message: DecCoin, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer {
|
||||
writer.uint32(10).string(message.denom);
|
||||
writer.uint32(18).string(message.amount);
|
||||
return writer;
|
||||
},
|
||||
|
||||
decode(input: _m0.Reader | Uint8Array, length?: number): DecCoin {
|
||||
const reader = input instanceof Uint8Array ? new _m0.Reader(input) : input;
|
||||
let end = length === undefined ? reader.len : reader.pos + length;
|
||||
const message = { ...baseDecCoin } as DecCoin;
|
||||
while (reader.pos < end) {
|
||||
const tag = reader.uint32();
|
||||
switch (tag >>> 3) {
|
||||
case 1:
|
||||
message.denom = reader.string();
|
||||
break;
|
||||
case 2:
|
||||
message.amount = reader.string();
|
||||
break;
|
||||
default:
|
||||
reader.skipType(tag & 7);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return message;
|
||||
},
|
||||
|
||||
fromJSON(object: any): DecCoin {
|
||||
const message = { ...baseDecCoin } as DecCoin;
|
||||
if (object.denom !== undefined && object.denom !== null) {
|
||||
message.denom = String(object.denom);
|
||||
} else {
|
||||
message.denom = "";
|
||||
}
|
||||
if (object.amount !== undefined && object.amount !== null) {
|
||||
message.amount = String(object.amount);
|
||||
} else {
|
||||
message.amount = "";
|
||||
}
|
||||
return message;
|
||||
},
|
||||
|
||||
fromPartial(object: DeepPartial<DecCoin>): DecCoin {
|
||||
const message = { ...baseDecCoin } as DecCoin;
|
||||
if (object.denom !== undefined && object.denom !== null) {
|
||||
message.denom = object.denom;
|
||||
} else {
|
||||
message.denom = "";
|
||||
}
|
||||
if (object.amount !== undefined && object.amount !== null) {
|
||||
message.amount = object.amount;
|
||||
} else {
|
||||
message.amount = "";
|
||||
}
|
||||
return message;
|
||||
},
|
||||
|
||||
toJSON(message: DecCoin): unknown {
|
||||
const obj: any = {};
|
||||
message.denom !== undefined && (obj.denom = message.denom);
|
||||
message.amount !== undefined && (obj.amount = message.amount);
|
||||
return obj;
|
||||
},
|
||||
};
|
||||
|
||||
const baseIntProto: object = { int: "" };
|
||||
|
||||
export const IntProto = {
|
||||
encode(message: IntProto, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer {
|
||||
writer.uint32(10).string(message.int);
|
||||
return writer;
|
||||
},
|
||||
|
||||
decode(input: _m0.Reader | Uint8Array, length?: number): IntProto {
|
||||
const reader = input instanceof Uint8Array ? new _m0.Reader(input) : input;
|
||||
let end = length === undefined ? reader.len : reader.pos + length;
|
||||
const message = { ...baseIntProto } as IntProto;
|
||||
while (reader.pos < end) {
|
||||
const tag = reader.uint32();
|
||||
switch (tag >>> 3) {
|
||||
case 1:
|
||||
message.int = reader.string();
|
||||
break;
|
||||
default:
|
||||
reader.skipType(tag & 7);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return message;
|
||||
},
|
||||
|
||||
fromJSON(object: any): IntProto {
|
||||
const message = { ...baseIntProto } as IntProto;
|
||||
if (object.int !== undefined && object.int !== null) {
|
||||
message.int = String(object.int);
|
||||
} else {
|
||||
message.int = "";
|
||||
}
|
||||
return message;
|
||||
},
|
||||
|
||||
fromPartial(object: DeepPartial<IntProto>): IntProto {
|
||||
const message = { ...baseIntProto } as IntProto;
|
||||
if (object.int !== undefined && object.int !== null) {
|
||||
message.int = object.int;
|
||||
} else {
|
||||
message.int = "";
|
||||
}
|
||||
return message;
|
||||
},
|
||||
|
||||
toJSON(message: IntProto): unknown {
|
||||
const obj: any = {};
|
||||
message.int !== undefined && (obj.int = message.int);
|
||||
return obj;
|
||||
},
|
||||
};
|
||||
|
||||
const baseDecProto: object = { dec: "" };
|
||||
|
||||
export const DecProto = {
|
||||
encode(message: DecProto, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer {
|
||||
writer.uint32(10).string(message.dec);
|
||||
return writer;
|
||||
},
|
||||
|
||||
decode(input: _m0.Reader | Uint8Array, length?: number): DecProto {
|
||||
const reader = input instanceof Uint8Array ? new _m0.Reader(input) : input;
|
||||
let end = length === undefined ? reader.len : reader.pos + length;
|
||||
const message = { ...baseDecProto } as DecProto;
|
||||
while (reader.pos < end) {
|
||||
const tag = reader.uint32();
|
||||
switch (tag >>> 3) {
|
||||
case 1:
|
||||
message.dec = reader.string();
|
||||
break;
|
||||
default:
|
||||
reader.skipType(tag & 7);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return message;
|
||||
},
|
||||
|
||||
fromJSON(object: any): DecProto {
|
||||
const message = { ...baseDecProto } as DecProto;
|
||||
if (object.dec !== undefined && object.dec !== null) {
|
||||
message.dec = String(object.dec);
|
||||
} else {
|
||||
message.dec = "";
|
||||
}
|
||||
return message;
|
||||
},
|
||||
|
||||
fromPartial(object: DeepPartial<DecProto>): DecProto {
|
||||
const message = { ...baseDecProto } as DecProto;
|
||||
if (object.dec !== undefined && object.dec !== null) {
|
||||
message.dec = object.dec;
|
||||
} else {
|
||||
message.dec = "";
|
||||
}
|
||||
return message;
|
||||
},
|
||||
|
||||
toJSON(message: DecProto): unknown {
|
||||
const obj: any = {};
|
||||
message.dec !== undefined && (obj.dec = message.dec);
|
||||
return obj;
|
||||
},
|
||||
};
|
||||
|
||||
type Builtin = Date | Function | Uint8Array | string | number | undefined | Long;
|
||||
export type DeepPartial<T> = T extends Builtin
|
||||
? T
|
||||
: T extends Array<infer U>
|
||||
? Array<DeepPartial<U>>
|
||||
: T extends ReadonlyArray<infer U>
|
||||
? ReadonlyArray<DeepPartial<U>>
|
||||
: T extends {}
|
||||
? { [K in keyof T]?: DeepPartial<T[K]> }
|
||||
: Partial<T>;
|
||||
@ -0,0 +1,196 @@
|
||||
/* eslint-disable */
|
||||
import Long from "long";
|
||||
import _m0 from "protobufjs/minimal";
|
||||
|
||||
export const protobufPackage = "cosmos.crypto.multisig.v1beta1";
|
||||
|
||||
/**
|
||||
* MultiSignature wraps the signatures from a multisig.LegacyAminoPubKey.
|
||||
* See cosmos.tx.v1betata1.ModeInfo.Multi for how to specify which signers
|
||||
* signed and with which modes.
|
||||
*/
|
||||
export interface MultiSignature {
|
||||
signatures: Uint8Array[];
|
||||
}
|
||||
|
||||
/**
|
||||
* CompactBitArray is an implementation of a space efficient bit array.
|
||||
* This is used to ensure that the encoded data takes up a minimal amount of
|
||||
* space after proto encoding.
|
||||
* This is not thread safe, and is not intended for concurrent usage.
|
||||
*/
|
||||
export interface CompactBitArray {
|
||||
extraBitsStored: number;
|
||||
elems: Uint8Array;
|
||||
}
|
||||
|
||||
const baseMultiSignature: object = {};
|
||||
|
||||
export const MultiSignature = {
|
||||
encode(message: MultiSignature, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer {
|
||||
for (const v of message.signatures) {
|
||||
writer.uint32(10).bytes(v!);
|
||||
}
|
||||
return writer;
|
||||
},
|
||||
|
||||
decode(input: _m0.Reader | Uint8Array, length?: number): MultiSignature {
|
||||
const reader = input instanceof Uint8Array ? new _m0.Reader(input) : input;
|
||||
let end = length === undefined ? reader.len : reader.pos + length;
|
||||
const message = { ...baseMultiSignature } as MultiSignature;
|
||||
message.signatures = [];
|
||||
while (reader.pos < end) {
|
||||
const tag = reader.uint32();
|
||||
switch (tag >>> 3) {
|
||||
case 1:
|
||||
message.signatures.push(reader.bytes());
|
||||
break;
|
||||
default:
|
||||
reader.skipType(tag & 7);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return message;
|
||||
},
|
||||
|
||||
fromJSON(object: any): MultiSignature {
|
||||
const message = { ...baseMultiSignature } as MultiSignature;
|
||||
message.signatures = [];
|
||||
if (object.signatures !== undefined && object.signatures !== null) {
|
||||
for (const e of object.signatures) {
|
||||
message.signatures.push(bytesFromBase64(e));
|
||||
}
|
||||
}
|
||||
return message;
|
||||
},
|
||||
|
||||
fromPartial(object: DeepPartial<MultiSignature>): MultiSignature {
|
||||
const message = { ...baseMultiSignature } as MultiSignature;
|
||||
message.signatures = [];
|
||||
if (object.signatures !== undefined && object.signatures !== null) {
|
||||
for (const e of object.signatures) {
|
||||
message.signatures.push(e);
|
||||
}
|
||||
}
|
||||
return message;
|
||||
},
|
||||
|
||||
toJSON(message: MultiSignature): unknown {
|
||||
const obj: any = {};
|
||||
if (message.signatures) {
|
||||
obj.signatures = message.signatures.map((e) => base64FromBytes(e !== undefined ? e : new Uint8Array()));
|
||||
} else {
|
||||
obj.signatures = [];
|
||||
}
|
||||
return obj;
|
||||
},
|
||||
};
|
||||
|
||||
const baseCompactBitArray: object = { extraBitsStored: 0 };
|
||||
|
||||
export const CompactBitArray = {
|
||||
encode(message: CompactBitArray, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer {
|
||||
writer.uint32(8).uint32(message.extraBitsStored);
|
||||
writer.uint32(18).bytes(message.elems);
|
||||
return writer;
|
||||
},
|
||||
|
||||
decode(input: _m0.Reader | Uint8Array, length?: number): CompactBitArray {
|
||||
const reader = input instanceof Uint8Array ? new _m0.Reader(input) : input;
|
||||
let end = length === undefined ? reader.len : reader.pos + length;
|
||||
const message = { ...baseCompactBitArray } as CompactBitArray;
|
||||
while (reader.pos < end) {
|
||||
const tag = reader.uint32();
|
||||
switch (tag >>> 3) {
|
||||
case 1:
|
||||
message.extraBitsStored = reader.uint32();
|
||||
break;
|
||||
case 2:
|
||||
message.elems = reader.bytes();
|
||||
break;
|
||||
default:
|
||||
reader.skipType(tag & 7);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return message;
|
||||
},
|
||||
|
||||
fromJSON(object: any): CompactBitArray {
|
||||
const message = { ...baseCompactBitArray } as CompactBitArray;
|
||||
if (object.extraBitsStored !== undefined && object.extraBitsStored !== null) {
|
||||
message.extraBitsStored = Number(object.extraBitsStored);
|
||||
} else {
|
||||
message.extraBitsStored = 0;
|
||||
}
|
||||
if (object.elems !== undefined && object.elems !== null) {
|
||||
message.elems = bytesFromBase64(object.elems);
|
||||
}
|
||||
return message;
|
||||
},
|
||||
|
||||
fromPartial(object: DeepPartial<CompactBitArray>): CompactBitArray {
|
||||
const message = { ...baseCompactBitArray } as CompactBitArray;
|
||||
if (object.extraBitsStored !== undefined && object.extraBitsStored !== null) {
|
||||
message.extraBitsStored = object.extraBitsStored;
|
||||
} else {
|
||||
message.extraBitsStored = 0;
|
||||
}
|
||||
if (object.elems !== undefined && object.elems !== null) {
|
||||
message.elems = object.elems;
|
||||
} else {
|
||||
message.elems = new Uint8Array();
|
||||
}
|
||||
return message;
|
||||
},
|
||||
|
||||
toJSON(message: CompactBitArray): unknown {
|
||||
const obj: any = {};
|
||||
message.extraBitsStored !== undefined && (obj.extraBitsStored = message.extraBitsStored);
|
||||
message.elems !== undefined &&
|
||||
(obj.elems = base64FromBytes(message.elems !== undefined ? message.elems : new Uint8Array()));
|
||||
return obj;
|
||||
},
|
||||
};
|
||||
|
||||
declare var self: any | undefined;
|
||||
declare var window: any | undefined;
|
||||
var globalThis: any = (() => {
|
||||
if (typeof globalThis !== "undefined") return globalThis;
|
||||
if (typeof self !== "undefined") return self;
|
||||
if (typeof window !== "undefined") return window;
|
||||
if (typeof global !== "undefined") return global;
|
||||
throw new Error("Unable to locate global object");
|
||||
})();
|
||||
|
||||
const atob: (b64: string) => string =
|
||||
globalThis.atob || ((b64) => globalThis.Buffer.from(b64, "base64").toString("binary"));
|
||||
function bytesFromBase64(b64: string): Uint8Array {
|
||||
const bin = atob(b64);
|
||||
const arr = new Uint8Array(bin.length);
|
||||
for (let i = 0; i < bin.length; ++i) {
|
||||
arr[i] = bin.charCodeAt(i);
|
||||
}
|
||||
return arr;
|
||||
}
|
||||
|
||||
const btoa: (bin: string) => string =
|
||||
globalThis.btoa || ((bin) => globalThis.Buffer.from(bin, "binary").toString("base64"));
|
||||
function base64FromBytes(arr: Uint8Array): string {
|
||||
const bin: string[] = [];
|
||||
for (let i = 0; i < arr.byteLength; ++i) {
|
||||
bin.push(String.fromCharCode(arr[i]));
|
||||
}
|
||||
return btoa(bin.join(""));
|
||||
}
|
||||
|
||||
type Builtin = Date | Function | Uint8Array | string | number | undefined | Long;
|
||||
export type DeepPartial<T> = T extends Builtin
|
||||
? T
|
||||
: T extends Array<infer U>
|
||||
? Array<DeepPartial<U>>
|
||||
: T extends ReadonlyArray<infer U>
|
||||
? ReadonlyArray<DeepPartial<U>>
|
||||
: T extends {}
|
||||
? { [K in keyof T]?: DeepPartial<T[K]> }
|
||||
: Partial<T>;
|
||||
167
packages/proto-signing/src/codec/cosmos/crypto/secp256k1/keys.ts
Normal file
167
packages/proto-signing/src/codec/cosmos/crypto/secp256k1/keys.ts
Normal file
@ -0,0 +1,167 @@
|
||||
/* eslint-disable */
|
||||
import Long from "long";
|
||||
import _m0 from "protobufjs/minimal";
|
||||
|
||||
export const protobufPackage = "cosmos.crypto.secp256k1";
|
||||
|
||||
/**
|
||||
* PubKey defines a secp256k1 public key
|
||||
* Key is the compressed form of the pubkey. The first byte depends is a 0x02 byte
|
||||
* if the y-coordinate is the lexicographically largest of the two associated with
|
||||
* the x-coordinate. Otherwise the first byte is a 0x03.
|
||||
* This prefix is followed with the x-coordinate.
|
||||
*/
|
||||
export interface PubKey {
|
||||
key: Uint8Array;
|
||||
}
|
||||
|
||||
/** PrivKey defines a secp256k1 private key. */
|
||||
export interface PrivKey {
|
||||
key: Uint8Array;
|
||||
}
|
||||
|
||||
const basePubKey: object = {};
|
||||
|
||||
export const PubKey = {
|
||||
encode(message: PubKey, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer {
|
||||
writer.uint32(10).bytes(message.key);
|
||||
return writer;
|
||||
},
|
||||
|
||||
decode(input: _m0.Reader | Uint8Array, length?: number): PubKey {
|
||||
const reader = input instanceof Uint8Array ? new _m0.Reader(input) : input;
|
||||
let end = length === undefined ? reader.len : reader.pos + length;
|
||||
const message = { ...basePubKey } as PubKey;
|
||||
while (reader.pos < end) {
|
||||
const tag = reader.uint32();
|
||||
switch (tag >>> 3) {
|
||||
case 1:
|
||||
message.key = reader.bytes();
|
||||
break;
|
||||
default:
|
||||
reader.skipType(tag & 7);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return message;
|
||||
},
|
||||
|
||||
fromJSON(object: any): PubKey {
|
||||
const message = { ...basePubKey } as PubKey;
|
||||
if (object.key !== undefined && object.key !== null) {
|
||||
message.key = bytesFromBase64(object.key);
|
||||
}
|
||||
return message;
|
||||
},
|
||||
|
||||
fromPartial(object: DeepPartial<PubKey>): PubKey {
|
||||
const message = { ...basePubKey } as PubKey;
|
||||
if (object.key !== undefined && object.key !== null) {
|
||||
message.key = object.key;
|
||||
} else {
|
||||
message.key = new Uint8Array();
|
||||
}
|
||||
return message;
|
||||
},
|
||||
|
||||
toJSON(message: PubKey): unknown {
|
||||
const obj: any = {};
|
||||
message.key !== undefined &&
|
||||
(obj.key = base64FromBytes(message.key !== undefined ? message.key : new Uint8Array()));
|
||||
return obj;
|
||||
},
|
||||
};
|
||||
|
||||
const basePrivKey: object = {};
|
||||
|
||||
export const PrivKey = {
|
||||
encode(message: PrivKey, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer {
|
||||
writer.uint32(10).bytes(message.key);
|
||||
return writer;
|
||||
},
|
||||
|
||||
decode(input: _m0.Reader | Uint8Array, length?: number): PrivKey {
|
||||
const reader = input instanceof Uint8Array ? new _m0.Reader(input) : input;
|
||||
let end = length === undefined ? reader.len : reader.pos + length;
|
||||
const message = { ...basePrivKey } as PrivKey;
|
||||
while (reader.pos < end) {
|
||||
const tag = reader.uint32();
|
||||
switch (tag >>> 3) {
|
||||
case 1:
|
||||
message.key = reader.bytes();
|
||||
break;
|
||||
default:
|
||||
reader.skipType(tag & 7);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return message;
|
||||
},
|
||||
|
||||
fromJSON(object: any): PrivKey {
|
||||
const message = { ...basePrivKey } as PrivKey;
|
||||
if (object.key !== undefined && object.key !== null) {
|
||||
message.key = bytesFromBase64(object.key);
|
||||
}
|
||||
return message;
|
||||
},
|
||||
|
||||
fromPartial(object: DeepPartial<PrivKey>): PrivKey {
|
||||
const message = { ...basePrivKey } as PrivKey;
|
||||
if (object.key !== undefined && object.key !== null) {
|
||||
message.key = object.key;
|
||||
} else {
|
||||
message.key = new Uint8Array();
|
||||
}
|
||||
return message;
|
||||
},
|
||||
|
||||
toJSON(message: PrivKey): unknown {
|
||||
const obj: any = {};
|
||||
message.key !== undefined &&
|
||||
(obj.key = base64FromBytes(message.key !== undefined ? message.key : new Uint8Array()));
|
||||
return obj;
|
||||
},
|
||||
};
|
||||
|
||||
declare var self: any | undefined;
|
||||
declare var window: any | undefined;
|
||||
var globalThis: any = (() => {
|
||||
if (typeof globalThis !== "undefined") return globalThis;
|
||||
if (typeof self !== "undefined") return self;
|
||||
if (typeof window !== "undefined") return window;
|
||||
if (typeof global !== "undefined") return global;
|
||||
throw new Error("Unable to locate global object");
|
||||
})();
|
||||
|
||||
const atob: (b64: string) => string =
|
||||
globalThis.atob || ((b64) => globalThis.Buffer.from(b64, "base64").toString("binary"));
|
||||
function bytesFromBase64(b64: string): Uint8Array {
|
||||
const bin = atob(b64);
|
||||
const arr = new Uint8Array(bin.length);
|
||||
for (let i = 0; i < bin.length; ++i) {
|
||||
arr[i] = bin.charCodeAt(i);
|
||||
}
|
||||
return arr;
|
||||
}
|
||||
|
||||
const btoa: (bin: string) => string =
|
||||
globalThis.btoa || ((bin) => globalThis.Buffer.from(bin, "binary").toString("base64"));
|
||||
function base64FromBytes(arr: Uint8Array): string {
|
||||
const bin: string[] = [];
|
||||
for (let i = 0; i < arr.byteLength; ++i) {
|
||||
bin.push(String.fromCharCode(arr[i]));
|
||||
}
|
||||
return btoa(bin.join(""));
|
||||
}
|
||||
|
||||
type Builtin = Date | Function | Uint8Array | string | number | undefined | Long;
|
||||
export type DeepPartial<T> = T extends Builtin
|
||||
? T
|
||||
: T extends Array<infer U>
|
||||
? Array<DeepPartial<U>>
|
||||
: T extends ReadonlyArray<infer U>
|
||||
? ReadonlyArray<DeepPartial<U>>
|
||||
: T extends {}
|
||||
? { [K in keyof T]?: DeepPartial<T[K]> }
|
||||
: Partial<T>;
|
||||
@ -0,0 +1,533 @@
|
||||
/* eslint-disable */
|
||||
import { Any } from "../../../../google/protobuf/any";
|
||||
import Long from "long";
|
||||
import { CompactBitArray } from "../../../../cosmos/crypto/multisig/v1beta1/multisig";
|
||||
import _m0 from "protobufjs/minimal";
|
||||
|
||||
export const protobufPackage = "cosmos.tx.signing.v1beta1";
|
||||
|
||||
/** SignMode represents a signing mode with its own security guarantees. */
|
||||
export enum SignMode {
|
||||
/**
|
||||
* SIGN_MODE_UNSPECIFIED - SIGN_MODE_UNSPECIFIED specifies an unknown signing mode and will be
|
||||
* rejected
|
||||
*/
|
||||
SIGN_MODE_UNSPECIFIED = 0,
|
||||
/**
|
||||
* SIGN_MODE_DIRECT - SIGN_MODE_DIRECT specifies a signing mode which uses SignDoc and is
|
||||
* verified with raw bytes from Tx
|
||||
*/
|
||||
SIGN_MODE_DIRECT = 1,
|
||||
/**
|
||||
* SIGN_MODE_TEXTUAL - SIGN_MODE_TEXTUAL is a future signing mode that will verify some
|
||||
* human-readable textual representation on top of the binary representation
|
||||
* from SIGN_MODE_DIRECT
|
||||
*/
|
||||
SIGN_MODE_TEXTUAL = 2,
|
||||
/**
|
||||
* SIGN_MODE_LEGACY_AMINO_JSON - SIGN_MODE_LEGACY_AMINO_JSON is a backwards compatibility mode which uses
|
||||
* Amino JSON and will be removed in the future
|
||||
*/
|
||||
SIGN_MODE_LEGACY_AMINO_JSON = 127,
|
||||
UNRECOGNIZED = -1,
|
||||
}
|
||||
|
||||
export function signModeFromJSON(object: any): SignMode {
|
||||
switch (object) {
|
||||
case 0:
|
||||
case "SIGN_MODE_UNSPECIFIED":
|
||||
return SignMode.SIGN_MODE_UNSPECIFIED;
|
||||
case 1:
|
||||
case "SIGN_MODE_DIRECT":
|
||||
return SignMode.SIGN_MODE_DIRECT;
|
||||
case 2:
|
||||
case "SIGN_MODE_TEXTUAL":
|
||||
return SignMode.SIGN_MODE_TEXTUAL;
|
||||
case 127:
|
||||
case "SIGN_MODE_LEGACY_AMINO_JSON":
|
||||
return SignMode.SIGN_MODE_LEGACY_AMINO_JSON;
|
||||
case -1:
|
||||
case "UNRECOGNIZED":
|
||||
default:
|
||||
return SignMode.UNRECOGNIZED;
|
||||
}
|
||||
}
|
||||
|
||||
export function signModeToJSON(object: SignMode): string {
|
||||
switch (object) {
|
||||
case SignMode.SIGN_MODE_UNSPECIFIED:
|
||||
return "SIGN_MODE_UNSPECIFIED";
|
||||
case SignMode.SIGN_MODE_DIRECT:
|
||||
return "SIGN_MODE_DIRECT";
|
||||
case SignMode.SIGN_MODE_TEXTUAL:
|
||||
return "SIGN_MODE_TEXTUAL";
|
||||
case SignMode.SIGN_MODE_LEGACY_AMINO_JSON:
|
||||
return "SIGN_MODE_LEGACY_AMINO_JSON";
|
||||
default:
|
||||
return "UNKNOWN";
|
||||
}
|
||||
}
|
||||
|
||||
/** SignatureDescriptors wraps multiple SignatureDescriptor's. */
|
||||
export interface SignatureDescriptors {
|
||||
/** signatures are the signature descriptors */
|
||||
signatures: SignatureDescriptor[];
|
||||
}
|
||||
|
||||
/**
|
||||
* SignatureDescriptor is a convenience type which represents the full data for
|
||||
* a signature including the public key of the signer, signing modes and the
|
||||
* signature itself. It is primarily used for coordinating signatures between
|
||||
* clients.
|
||||
*/
|
||||
export interface SignatureDescriptor {
|
||||
/** public_key is the public key of the signer */
|
||||
publicKey?: Any;
|
||||
data?: SignatureDescriptor_Data;
|
||||
/**
|
||||
* sequence is the sequence of the account, which describes the
|
||||
* number of committed transactions signed by a given address. It is used to prevent
|
||||
* replay attacks.
|
||||
*/
|
||||
sequence: Long;
|
||||
}
|
||||
|
||||
/** Data represents signature data */
|
||||
export interface SignatureDescriptor_Data {
|
||||
/** single represents a single signer */
|
||||
single?: SignatureDescriptor_Data_Single | undefined;
|
||||
/** multi represents a multisig signer */
|
||||
multi?: SignatureDescriptor_Data_Multi | undefined;
|
||||
}
|
||||
|
||||
/** Single is the signature data for a single signer */
|
||||
export interface SignatureDescriptor_Data_Single {
|
||||
/** mode is the signing mode of the single signer */
|
||||
mode: SignMode;
|
||||
/** signature is the raw signature bytes */
|
||||
signature: Uint8Array;
|
||||
}
|
||||
|
||||
/** Multi is the signature data for a multisig public key */
|
||||
export interface SignatureDescriptor_Data_Multi {
|
||||
/** bitarray specifies which keys within the multisig are signing */
|
||||
bitarray?: CompactBitArray;
|
||||
/** signatures is the signatures of the multi-signature */
|
||||
signatures: SignatureDescriptor_Data[];
|
||||
}
|
||||
|
||||
const baseSignatureDescriptors: object = {};
|
||||
|
||||
export const SignatureDescriptors = {
|
||||
encode(message: SignatureDescriptors, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer {
|
||||
for (const v of message.signatures) {
|
||||
SignatureDescriptor.encode(v!, writer.uint32(10).fork()).ldelim();
|
||||
}
|
||||
return writer;
|
||||
},
|
||||
|
||||
decode(input: _m0.Reader | Uint8Array, length?: number): SignatureDescriptors {
|
||||
const reader = input instanceof Uint8Array ? new _m0.Reader(input) : input;
|
||||
let end = length === undefined ? reader.len : reader.pos + length;
|
||||
const message = { ...baseSignatureDescriptors } as SignatureDescriptors;
|
||||
message.signatures = [];
|
||||
while (reader.pos < end) {
|
||||
const tag = reader.uint32();
|
||||
switch (tag >>> 3) {
|
||||
case 1:
|
||||
message.signatures.push(SignatureDescriptor.decode(reader, reader.uint32()));
|
||||
break;
|
||||
default:
|
||||
reader.skipType(tag & 7);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return message;
|
||||
},
|
||||
|
||||
fromJSON(object: any): SignatureDescriptors {
|
||||
const message = { ...baseSignatureDescriptors } as SignatureDescriptors;
|
||||
message.signatures = [];
|
||||
if (object.signatures !== undefined && object.signatures !== null) {
|
||||
for (const e of object.signatures) {
|
||||
message.signatures.push(SignatureDescriptor.fromJSON(e));
|
||||
}
|
||||
}
|
||||
return message;
|
||||
},
|
||||
|
||||
fromPartial(object: DeepPartial<SignatureDescriptors>): SignatureDescriptors {
|
||||
const message = { ...baseSignatureDescriptors } as SignatureDescriptors;
|
||||
message.signatures = [];
|
||||
if (object.signatures !== undefined && object.signatures !== null) {
|
||||
for (const e of object.signatures) {
|
||||
message.signatures.push(SignatureDescriptor.fromPartial(e));
|
||||
}
|
||||
}
|
||||
return message;
|
||||
},
|
||||
|
||||
toJSON(message: SignatureDescriptors): unknown {
|
||||
const obj: any = {};
|
||||
if (message.signatures) {
|
||||
obj.signatures = message.signatures.map((e) => (e ? SignatureDescriptor.toJSON(e) : undefined));
|
||||
} else {
|
||||
obj.signatures = [];
|
||||
}
|
||||
return obj;
|
||||
},
|
||||
};
|
||||
|
||||
const baseSignatureDescriptor: object = { sequence: Long.UZERO };
|
||||
|
||||
export const SignatureDescriptor = {
|
||||
encode(message: SignatureDescriptor, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer {
|
||||
if (message.publicKey !== undefined && message.publicKey !== undefined) {
|
||||
Any.encode(message.publicKey, writer.uint32(10).fork()).ldelim();
|
||||
}
|
||||
if (message.data !== undefined && message.data !== undefined) {
|
||||
SignatureDescriptor_Data.encode(message.data, writer.uint32(18).fork()).ldelim();
|
||||
}
|
||||
writer.uint32(24).uint64(message.sequence);
|
||||
return writer;
|
||||
},
|
||||
|
||||
decode(input: _m0.Reader | Uint8Array, length?: number): SignatureDescriptor {
|
||||
const reader = input instanceof Uint8Array ? new _m0.Reader(input) : input;
|
||||
let end = length === undefined ? reader.len : reader.pos + length;
|
||||
const message = { ...baseSignatureDescriptor } as SignatureDescriptor;
|
||||
while (reader.pos < end) {
|
||||
const tag = reader.uint32();
|
||||
switch (tag >>> 3) {
|
||||
case 1:
|
||||
message.publicKey = Any.decode(reader, reader.uint32());
|
||||
break;
|
||||
case 2:
|
||||
message.data = SignatureDescriptor_Data.decode(reader, reader.uint32());
|
||||
break;
|
||||
case 3:
|
||||
message.sequence = reader.uint64() as Long;
|
||||
break;
|
||||
default:
|
||||
reader.skipType(tag & 7);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return message;
|
||||
},
|
||||
|
||||
fromJSON(object: any): SignatureDescriptor {
|
||||
const message = { ...baseSignatureDescriptor } as SignatureDescriptor;
|
||||
if (object.publicKey !== undefined && object.publicKey !== null) {
|
||||
message.publicKey = Any.fromPartial(object.publicKey);
|
||||
} else {
|
||||
message.publicKey = undefined;
|
||||
}
|
||||
if (object.data !== undefined && object.data !== null) {
|
||||
message.data = SignatureDescriptor_Data.fromJSON(object.data);
|
||||
} else {
|
||||
message.data = undefined;
|
||||
}
|
||||
if (object.sequence !== undefined && object.sequence !== null) {
|
||||
message.sequence = Long.fromString(object.sequence);
|
||||
} else {
|
||||
message.sequence = Long.UZERO;
|
||||
}
|
||||
return message;
|
||||
},
|
||||
|
||||
fromPartial(object: DeepPartial<SignatureDescriptor>): SignatureDescriptor {
|
||||
const message = { ...baseSignatureDescriptor } as SignatureDescriptor;
|
||||
if (object.publicKey !== undefined && object.publicKey !== null) {
|
||||
message.publicKey = Any.fromPartial(object.publicKey);
|
||||
} else {
|
||||
message.publicKey = undefined;
|
||||
}
|
||||
if (object.data !== undefined && object.data !== null) {
|
||||
message.data = SignatureDescriptor_Data.fromPartial(object.data);
|
||||
} else {
|
||||
message.data = undefined;
|
||||
}
|
||||
if (object.sequence !== undefined && object.sequence !== null) {
|
||||
message.sequence = object.sequence as Long;
|
||||
} else {
|
||||
message.sequence = Long.UZERO;
|
||||
}
|
||||
return message;
|
||||
},
|
||||
|
||||
toJSON(message: SignatureDescriptor): unknown {
|
||||
const obj: any = {};
|
||||
message.publicKey !== undefined &&
|
||||
(obj.publicKey = message.publicKey ? Any.toJSON(message.publicKey) : undefined);
|
||||
message.data !== undefined &&
|
||||
(obj.data = message.data ? SignatureDescriptor_Data.toJSON(message.data) : undefined);
|
||||
message.sequence !== undefined && (obj.sequence = (message.sequence || Long.UZERO).toString());
|
||||
return obj;
|
||||
},
|
||||
};
|
||||
|
||||
const baseSignatureDescriptor_Data: object = {};
|
||||
|
||||
export const SignatureDescriptor_Data = {
|
||||
encode(message: SignatureDescriptor_Data, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer {
|
||||
if (message.single !== undefined) {
|
||||
SignatureDescriptor_Data_Single.encode(message.single, writer.uint32(10).fork()).ldelim();
|
||||
}
|
||||
if (message.multi !== undefined) {
|
||||
SignatureDescriptor_Data_Multi.encode(message.multi, writer.uint32(18).fork()).ldelim();
|
||||
}
|
||||
return writer;
|
||||
},
|
||||
|
||||
decode(input: _m0.Reader | Uint8Array, length?: number): SignatureDescriptor_Data {
|
||||
const reader = input instanceof Uint8Array ? new _m0.Reader(input) : input;
|
||||
let end = length === undefined ? reader.len : reader.pos + length;
|
||||
const message = { ...baseSignatureDescriptor_Data } as SignatureDescriptor_Data;
|
||||
while (reader.pos < end) {
|
||||
const tag = reader.uint32();
|
||||
switch (tag >>> 3) {
|
||||
case 1:
|
||||
message.single = SignatureDescriptor_Data_Single.decode(reader, reader.uint32());
|
||||
break;
|
||||
case 2:
|
||||
message.multi = SignatureDescriptor_Data_Multi.decode(reader, reader.uint32());
|
||||
break;
|
||||
default:
|
||||
reader.skipType(tag & 7);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return message;
|
||||
},
|
||||
|
||||
fromJSON(object: any): SignatureDescriptor_Data {
|
||||
const message = { ...baseSignatureDescriptor_Data } as SignatureDescriptor_Data;
|
||||
if (object.single !== undefined && object.single !== null) {
|
||||
message.single = SignatureDescriptor_Data_Single.fromJSON(object.single);
|
||||
} else {
|
||||
message.single = undefined;
|
||||
}
|
||||
if (object.multi !== undefined && object.multi !== null) {
|
||||
message.multi = SignatureDescriptor_Data_Multi.fromJSON(object.multi);
|
||||
} else {
|
||||
message.multi = undefined;
|
||||
}
|
||||
return message;
|
||||
},
|
||||
|
||||
fromPartial(object: DeepPartial<SignatureDescriptor_Data>): SignatureDescriptor_Data {
|
||||
const message = { ...baseSignatureDescriptor_Data } as SignatureDescriptor_Data;
|
||||
if (object.single !== undefined && object.single !== null) {
|
||||
message.single = SignatureDescriptor_Data_Single.fromPartial(object.single);
|
||||
} else {
|
||||
message.single = undefined;
|
||||
}
|
||||
if (object.multi !== undefined && object.multi !== null) {
|
||||
message.multi = SignatureDescriptor_Data_Multi.fromPartial(object.multi);
|
||||
} else {
|
||||
message.multi = undefined;
|
||||
}
|
||||
return message;
|
||||
},
|
||||
|
||||
toJSON(message: SignatureDescriptor_Data): unknown {
|
||||
const obj: any = {};
|
||||
message.single !== undefined &&
|
||||
(obj.single = message.single ? SignatureDescriptor_Data_Single.toJSON(message.single) : undefined);
|
||||
message.multi !== undefined &&
|
||||
(obj.multi = message.multi ? SignatureDescriptor_Data_Multi.toJSON(message.multi) : undefined);
|
||||
return obj;
|
||||
},
|
||||
};
|
||||
|
||||
const baseSignatureDescriptor_Data_Single: object = { mode: 0 };
|
||||
|
||||
export const SignatureDescriptor_Data_Single = {
|
||||
encode(message: SignatureDescriptor_Data_Single, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer {
|
||||
writer.uint32(8).int32(message.mode);
|
||||
writer.uint32(18).bytes(message.signature);
|
||||
return writer;
|
||||
},
|
||||
|
||||
decode(input: _m0.Reader | Uint8Array, length?: number): SignatureDescriptor_Data_Single {
|
||||
const reader = input instanceof Uint8Array ? new _m0.Reader(input) : input;
|
||||
let end = length === undefined ? reader.len : reader.pos + length;
|
||||
const message = { ...baseSignatureDescriptor_Data_Single } as SignatureDescriptor_Data_Single;
|
||||
while (reader.pos < end) {
|
||||
const tag = reader.uint32();
|
||||
switch (tag >>> 3) {
|
||||
case 1:
|
||||
message.mode = reader.int32() as any;
|
||||
break;
|
||||
case 2:
|
||||
message.signature = reader.bytes();
|
||||
break;
|
||||
default:
|
||||
reader.skipType(tag & 7);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return message;
|
||||
},
|
||||
|
||||
fromJSON(object: any): SignatureDescriptor_Data_Single {
|
||||
const message = { ...baseSignatureDescriptor_Data_Single } as SignatureDescriptor_Data_Single;
|
||||
if (object.mode !== undefined && object.mode !== null) {
|
||||
message.mode = signModeFromJSON(object.mode);
|
||||
} else {
|
||||
message.mode = 0;
|
||||
}
|
||||
if (object.signature !== undefined && object.signature !== null) {
|
||||
message.signature = bytesFromBase64(object.signature);
|
||||
}
|
||||
return message;
|
||||
},
|
||||
|
||||
fromPartial(object: DeepPartial<SignatureDescriptor_Data_Single>): SignatureDescriptor_Data_Single {
|
||||
const message = { ...baseSignatureDescriptor_Data_Single } as SignatureDescriptor_Data_Single;
|
||||
if (object.mode !== undefined && object.mode !== null) {
|
||||
message.mode = object.mode;
|
||||
} else {
|
||||
message.mode = 0;
|
||||
}
|
||||
if (object.signature !== undefined && object.signature !== null) {
|
||||
message.signature = object.signature;
|
||||
} else {
|
||||
message.signature = new Uint8Array();
|
||||
}
|
||||
return message;
|
||||
},
|
||||
|
||||
toJSON(message: SignatureDescriptor_Data_Single): unknown {
|
||||
const obj: any = {};
|
||||
message.mode !== undefined && (obj.mode = signModeToJSON(message.mode));
|
||||
message.signature !== undefined &&
|
||||
(obj.signature = base64FromBytes(
|
||||
message.signature !== undefined ? message.signature : new Uint8Array(),
|
||||
));
|
||||
return obj;
|
||||
},
|
||||
};
|
||||
|
||||
const baseSignatureDescriptor_Data_Multi: object = {};
|
||||
|
||||
export const SignatureDescriptor_Data_Multi = {
|
||||
encode(message: SignatureDescriptor_Data_Multi, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer {
|
||||
if (message.bitarray !== undefined && message.bitarray !== undefined) {
|
||||
CompactBitArray.encode(message.bitarray, writer.uint32(10).fork()).ldelim();
|
||||
}
|
||||
for (const v of message.signatures) {
|
||||
SignatureDescriptor_Data.encode(v!, writer.uint32(18).fork()).ldelim();
|
||||
}
|
||||
return writer;
|
||||
},
|
||||
|
||||
decode(input: _m0.Reader | Uint8Array, length?: number): SignatureDescriptor_Data_Multi {
|
||||
const reader = input instanceof Uint8Array ? new _m0.Reader(input) : input;
|
||||
let end = length === undefined ? reader.len : reader.pos + length;
|
||||
const message = { ...baseSignatureDescriptor_Data_Multi } as SignatureDescriptor_Data_Multi;
|
||||
message.signatures = [];
|
||||
while (reader.pos < end) {
|
||||
const tag = reader.uint32();
|
||||
switch (tag >>> 3) {
|
||||
case 1:
|
||||
message.bitarray = CompactBitArray.decode(reader, reader.uint32());
|
||||
break;
|
||||
case 2:
|
||||
message.signatures.push(SignatureDescriptor_Data.decode(reader, reader.uint32()));
|
||||
break;
|
||||
default:
|
||||
reader.skipType(tag & 7);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return message;
|
||||
},
|
||||
|
||||
fromJSON(object: any): SignatureDescriptor_Data_Multi {
|
||||
const message = { ...baseSignatureDescriptor_Data_Multi } as SignatureDescriptor_Data_Multi;
|
||||
message.signatures = [];
|
||||
if (object.bitarray !== undefined && object.bitarray !== null) {
|
||||
message.bitarray = CompactBitArray.fromJSON(object.bitarray);
|
||||
} else {
|
||||
message.bitarray = undefined;
|
||||
}
|
||||
if (object.signatures !== undefined && object.signatures !== null) {
|
||||
for (const e of object.signatures) {
|
||||
message.signatures.push(SignatureDescriptor_Data.fromJSON(e));
|
||||
}
|
||||
}
|
||||
return message;
|
||||
},
|
||||
|
||||
fromPartial(object: DeepPartial<SignatureDescriptor_Data_Multi>): SignatureDescriptor_Data_Multi {
|
||||
const message = { ...baseSignatureDescriptor_Data_Multi } as SignatureDescriptor_Data_Multi;
|
||||
message.signatures = [];
|
||||
if (object.bitarray !== undefined && object.bitarray !== null) {
|
||||
message.bitarray = CompactBitArray.fromPartial(object.bitarray);
|
||||
} else {
|
||||
message.bitarray = undefined;
|
||||
}
|
||||
if (object.signatures !== undefined && object.signatures !== null) {
|
||||
for (const e of object.signatures) {
|
||||
message.signatures.push(SignatureDescriptor_Data.fromPartial(e));
|
||||
}
|
||||
}
|
||||
return message;
|
||||
},
|
||||
|
||||
toJSON(message: SignatureDescriptor_Data_Multi): unknown {
|
||||
const obj: any = {};
|
||||
message.bitarray !== undefined &&
|
||||
(obj.bitarray = message.bitarray ? CompactBitArray.toJSON(message.bitarray) : undefined);
|
||||
if (message.signatures) {
|
||||
obj.signatures = message.signatures.map((e) => (e ? SignatureDescriptor_Data.toJSON(e) : undefined));
|
||||
} else {
|
||||
obj.signatures = [];
|
||||
}
|
||||
return obj;
|
||||
},
|
||||
};
|
||||
|
||||
declare var self: any | undefined;
|
||||
declare var window: any | undefined;
|
||||
var globalThis: any = (() => {
|
||||
if (typeof globalThis !== "undefined") return globalThis;
|
||||
if (typeof self !== "undefined") return self;
|
||||
if (typeof window !== "undefined") return window;
|
||||
if (typeof global !== "undefined") return global;
|
||||
throw new Error("Unable to locate global object");
|
||||
})();
|
||||
|
||||
const atob: (b64: string) => string =
|
||||
globalThis.atob || ((b64) => globalThis.Buffer.from(b64, "base64").toString("binary"));
|
||||
function bytesFromBase64(b64: string): Uint8Array {
|
||||
const bin = atob(b64);
|
||||
const arr = new Uint8Array(bin.length);
|
||||
for (let i = 0; i < bin.length; ++i) {
|
||||
arr[i] = bin.charCodeAt(i);
|
||||
}
|
||||
return arr;
|
||||
}
|
||||
|
||||
const btoa: (bin: string) => string =
|
||||
globalThis.btoa || ((bin) => globalThis.Buffer.from(bin, "binary").toString("base64"));
|
||||
function base64FromBytes(arr: Uint8Array): string {
|
||||
const bin: string[] = [];
|
||||
for (let i = 0; i < arr.byteLength; ++i) {
|
||||
bin.push(String.fromCharCode(arr[i]));
|
||||
}
|
||||
return btoa(bin.join(""));
|
||||
}
|
||||
|
||||
type Builtin = Date | Function | Uint8Array | string | number | undefined | Long;
|
||||
export type DeepPartial<T> = T extends Builtin
|
||||
? T
|
||||
: T extends Array<infer U>
|
||||
? Array<DeepPartial<U>>
|
||||
: T extends ReadonlyArray<infer U>
|
||||
? ReadonlyArray<DeepPartial<U>>
|
||||
: T extends {}
|
||||
? { [K in keyof T]?: DeepPartial<T[K]> }
|
||||
: Partial<T>;
|
||||
1167
packages/proto-signing/src/codec/cosmos/tx/v1beta1/tx.ts
Normal file
1167
packages/proto-signing/src/codec/cosmos/tx/v1beta1/tx.ts
Normal file
File diff suppressed because it is too large
Load Diff
2
packages/proto-signing/src/codec/cosmos_proto/cosmos.ts
Normal file
2
packages/proto-signing/src/codec/cosmos_proto/cosmos.ts
Normal file
@ -0,0 +1,2 @@
|
||||
/* eslint-disable */
|
||||
export const protobufPackage = "cosmos_proto";
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
2
packages/proto-signing/src/codec/gogoproto/gogo.ts
Normal file
2
packages/proto-signing/src/codec/gogoproto/gogo.ts
Normal file
@ -0,0 +1,2 @@
|
||||
/* eslint-disable */
|
||||
export const protobufPackage = "gogoproto";
|
||||
230
packages/proto-signing/src/codec/google/protobuf/any.ts
Normal file
230
packages/proto-signing/src/codec/google/protobuf/any.ts
Normal file
@ -0,0 +1,230 @@
|
||||
/* eslint-disable */
|
||||
import Long from "long";
|
||||
import _m0 from "protobufjs/minimal";
|
||||
|
||||
export const protobufPackage = "google.protobuf";
|
||||
|
||||
/**
|
||||
* `Any` contains an arbitrary serialized protocol buffer message along with a
|
||||
* URL that describes the type of the serialized message.
|
||||
*
|
||||
* Protobuf library provides support to pack/unpack Any values in the form
|
||||
* of utility functions or additional generated methods of the Any type.
|
||||
*
|
||||
* Example 1: Pack and unpack a message in C++.
|
||||
*
|
||||
* Foo foo = ...;
|
||||
* Any any;
|
||||
* any.PackFrom(foo);
|
||||
* ...
|
||||
* if (any.UnpackTo(&foo)) {
|
||||
* ...
|
||||
* }
|
||||
*
|
||||
* Example 2: Pack and unpack a message in Java.
|
||||
*
|
||||
* Foo foo = ...;
|
||||
* Any any = Any.pack(foo);
|
||||
* ...
|
||||
* if (any.is(Foo.class)) {
|
||||
* foo = any.unpack(Foo.class);
|
||||
* }
|
||||
*
|
||||
* Example 3: Pack and unpack a message in Python.
|
||||
*
|
||||
* foo = Foo(...)
|
||||
* any = Any()
|
||||
* any.Pack(foo)
|
||||
* ...
|
||||
* if any.Is(Foo.DESCRIPTOR):
|
||||
* any.Unpack(foo)
|
||||
* ...
|
||||
*
|
||||
* Example 4: Pack and unpack a message in Go
|
||||
*
|
||||
* foo := &pb.Foo{...}
|
||||
* any, err := ptypes.MarshalAny(foo)
|
||||
* ...
|
||||
* foo := &pb.Foo{}
|
||||
* if err := ptypes.UnmarshalAny(any, foo); err != nil {
|
||||
* ...
|
||||
* }
|
||||
*
|
||||
* The pack methods provided by protobuf library will by default use
|
||||
* 'type.googleapis.com/full.type.name' as the type URL and the unpack
|
||||
* methods only use the fully qualified type name after the last '/'
|
||||
* in the type URL, for example "foo.bar.com/x/y.z" will yield type
|
||||
* name "y.z".
|
||||
*
|
||||
*
|
||||
* JSON
|
||||
* ====
|
||||
* The JSON representation of an `Any` value uses the regular
|
||||
* representation of the deserialized, embedded message, with an
|
||||
* additional field `@type` which contains the type URL. Example:
|
||||
*
|
||||
* package google.profile;
|
||||
* message Person {
|
||||
* string first_name = 1;
|
||||
* string last_name = 2;
|
||||
* }
|
||||
*
|
||||
* {
|
||||
* "@type": "type.googleapis.com/google.profile.Person",
|
||||
* "firstName": <string>,
|
||||
* "lastName": <string>
|
||||
* }
|
||||
*
|
||||
* If the embedded message type is well-known and has a custom JSON
|
||||
* representation, that representation will be embedded adding a field
|
||||
* `value` which holds the custom JSON in addition to the `@type`
|
||||
* field. Example (for message [google.protobuf.Duration][]):
|
||||
*
|
||||
* {
|
||||
* "@type": "type.googleapis.com/google.protobuf.Duration",
|
||||
* "value": "1.212s"
|
||||
* }
|
||||
*/
|
||||
export interface Any {
|
||||
/**
|
||||
* A URL/resource name that uniquely identifies the type of the serialized
|
||||
* protocol buffer message. This string must contain at least
|
||||
* one "/" character. The last segment of the URL's path must represent
|
||||
* the fully qualified name of the type (as in
|
||||
* `path/google.protobuf.Duration`). The name should be in a canonical form
|
||||
* (e.g., leading "." is not accepted).
|
||||
*
|
||||
* In practice, teams usually precompile into the binary all types that they
|
||||
* expect it to use in the context of Any. However, for URLs which use the
|
||||
* scheme `http`, `https`, or no scheme, one can optionally set up a type
|
||||
* server that maps type URLs to message definitions as follows:
|
||||
*
|
||||
* * If no scheme is provided, `https` is assumed.
|
||||
* * An HTTP GET on the URL must yield a [google.protobuf.Type][]
|
||||
* value in binary format, or produce an error.
|
||||
* * Applications are allowed to cache lookup results based on the
|
||||
* URL, or have them precompiled into a binary to avoid any
|
||||
* lookup. Therefore, binary compatibility needs to be preserved
|
||||
* on changes to types. (Use versioned type names to manage
|
||||
* breaking changes.)
|
||||
*
|
||||
* Note: this functionality is not currently available in the official
|
||||
* protobuf release, and it is not used for type URLs beginning with
|
||||
* type.googleapis.com.
|
||||
*
|
||||
* Schemes other than `http`, `https` (or the empty scheme) might be
|
||||
* used with implementation specific semantics.
|
||||
*/
|
||||
typeUrl: string;
|
||||
/** Must be a valid serialized protocol buffer of the above specified type. */
|
||||
value: Uint8Array;
|
||||
}
|
||||
|
||||
const baseAny: object = { typeUrl: "" };
|
||||
|
||||
export const Any = {
|
||||
encode(message: Any, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer {
|
||||
writer.uint32(10).string(message.typeUrl);
|
||||
writer.uint32(18).bytes(message.value);
|
||||
return writer;
|
||||
},
|
||||
|
||||
decode(input: _m0.Reader | Uint8Array, length?: number): Any {
|
||||
const reader = input instanceof Uint8Array ? new _m0.Reader(input) : input;
|
||||
let end = length === undefined ? reader.len : reader.pos + length;
|
||||
const message = { ...baseAny } as Any;
|
||||
while (reader.pos < end) {
|
||||
const tag = reader.uint32();
|
||||
switch (tag >>> 3) {
|
||||
case 1:
|
||||
message.typeUrl = reader.string();
|
||||
break;
|
||||
case 2:
|
||||
message.value = reader.bytes();
|
||||
break;
|
||||
default:
|
||||
reader.skipType(tag & 7);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return message;
|
||||
},
|
||||
|
||||
fromJSON(object: any): Any {
|
||||
const message = { ...baseAny } as Any;
|
||||
if (object.typeUrl !== undefined && object.typeUrl !== null) {
|
||||
message.typeUrl = String(object.typeUrl);
|
||||
} else {
|
||||
message.typeUrl = "";
|
||||
}
|
||||
if (object.value !== undefined && object.value !== null) {
|
||||
message.value = bytesFromBase64(object.value);
|
||||
}
|
||||
return message;
|
||||
},
|
||||
|
||||
fromPartial(object: DeepPartial<Any>): Any {
|
||||
const message = { ...baseAny } as Any;
|
||||
if (object.typeUrl !== undefined && object.typeUrl !== null) {
|
||||
message.typeUrl = object.typeUrl;
|
||||
} else {
|
||||
message.typeUrl = "";
|
||||
}
|
||||
if (object.value !== undefined && object.value !== null) {
|
||||
message.value = object.value;
|
||||
} else {
|
||||
message.value = new Uint8Array();
|
||||
}
|
||||
return message;
|
||||
},
|
||||
|
||||
toJSON(message: Any): unknown {
|
||||
const obj: any = {};
|
||||
message.typeUrl !== undefined && (obj.typeUrl = message.typeUrl);
|
||||
message.value !== undefined &&
|
||||
(obj.value = base64FromBytes(message.value !== undefined ? message.value : new Uint8Array()));
|
||||
return obj;
|
||||
},
|
||||
};
|
||||
|
||||
declare var self: any | undefined;
|
||||
declare var window: any | undefined;
|
||||
var globalThis: any = (() => {
|
||||
if (typeof globalThis !== "undefined") return globalThis;
|
||||
if (typeof self !== "undefined") return self;
|
||||
if (typeof window !== "undefined") return window;
|
||||
if (typeof global !== "undefined") return global;
|
||||
throw new Error("Unable to locate global object");
|
||||
})();
|
||||
|
||||
const atob: (b64: string) => string =
|
||||
globalThis.atob || ((b64) => globalThis.Buffer.from(b64, "base64").toString("binary"));
|
||||
function bytesFromBase64(b64: string): Uint8Array {
|
||||
const bin = atob(b64);
|
||||
const arr = new Uint8Array(bin.length);
|
||||
for (let i = 0; i < bin.length; ++i) {
|
||||
arr[i] = bin.charCodeAt(i);
|
||||
}
|
||||
return arr;
|
||||
}
|
||||
|
||||
const btoa: (bin: string) => string =
|
||||
globalThis.btoa || ((bin) => globalThis.Buffer.from(bin, "binary").toString("base64"));
|
||||
function base64FromBytes(arr: Uint8Array): string {
|
||||
const bin: string[] = [];
|
||||
for (let i = 0; i < arr.byteLength; ++i) {
|
||||
bin.push(String.fromCharCode(arr[i]));
|
||||
}
|
||||
return btoa(bin.join(""));
|
||||
}
|
||||
|
||||
type Builtin = Date | Function | Uint8Array | string | number | undefined | Long;
|
||||
export type DeepPartial<T> = T extends Builtin
|
||||
? T
|
||||
: T extends Array<infer U>
|
||||
? Array<DeepPartial<U>>
|
||||
: T extends ReadonlyArray<infer U>
|
||||
? ReadonlyArray<DeepPartial<U>>
|
||||
: T extends {}
|
||||
? { [K in keyof T]?: DeepPartial<T[K]> }
|
||||
: Partial<T>;
|
||||
4564
packages/proto-signing/src/codec/google/protobuf/descriptor.ts
Normal file
4564
packages/proto-signing/src/codec/google/protobuf/descriptor.ts
Normal file
File diff suppressed because it is too large
Load Diff
@ -1,9 +0,0 @@
|
||||
import Long from "long";
|
||||
import protobuf from "protobufjs/minimal";
|
||||
|
||||
// Ensure the protobuf module has a Long implementation, which otherwise only works
|
||||
// in Node.js (see https://github.com/protobufjs/protobuf.js/issues/921#issuecomment-334925145)
|
||||
protobuf.util.Long = Long;
|
||||
protobuf.configure();
|
||||
|
||||
export * from "./generated/codecimpl";
|
||||
123
packages/proto-signing/src/codec/tendermint/crypto/keys.ts
Normal file
123
packages/proto-signing/src/codec/tendermint/crypto/keys.ts
Normal file
@ -0,0 +1,123 @@
|
||||
/* eslint-disable */
|
||||
import Long from "long";
|
||||
import _m0 from "protobufjs/minimal";
|
||||
|
||||
export const protobufPackage = "tendermint.crypto";
|
||||
|
||||
/** PublicKey defines the keys available for use with Tendermint Validators */
|
||||
export interface PublicKey {
|
||||
ed25519: Uint8Array | undefined;
|
||||
secp256k1: Uint8Array | undefined;
|
||||
}
|
||||
|
||||
const basePublicKey: object = {};
|
||||
|
||||
export const PublicKey = {
|
||||
encode(message: PublicKey, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer {
|
||||
if (message.ed25519 !== undefined) {
|
||||
writer.uint32(10).bytes(message.ed25519);
|
||||
}
|
||||
if (message.secp256k1 !== undefined) {
|
||||
writer.uint32(18).bytes(message.secp256k1);
|
||||
}
|
||||
return writer;
|
||||
},
|
||||
|
||||
decode(input: _m0.Reader | Uint8Array, length?: number): PublicKey {
|
||||
const reader = input instanceof Uint8Array ? new _m0.Reader(input) : input;
|
||||
let end = length === undefined ? reader.len : reader.pos + length;
|
||||
const message = { ...basePublicKey } as PublicKey;
|
||||
while (reader.pos < end) {
|
||||
const tag = reader.uint32();
|
||||
switch (tag >>> 3) {
|
||||
case 1:
|
||||
message.ed25519 = reader.bytes();
|
||||
break;
|
||||
case 2:
|
||||
message.secp256k1 = reader.bytes();
|
||||
break;
|
||||
default:
|
||||
reader.skipType(tag & 7);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return message;
|
||||
},
|
||||
|
||||
fromJSON(object: any): PublicKey {
|
||||
const message = { ...basePublicKey } as PublicKey;
|
||||
if (object.ed25519 !== undefined && object.ed25519 !== null) {
|
||||
message.ed25519 = bytesFromBase64(object.ed25519);
|
||||
}
|
||||
if (object.secp256k1 !== undefined && object.secp256k1 !== null) {
|
||||
message.secp256k1 = bytesFromBase64(object.secp256k1);
|
||||
}
|
||||
return message;
|
||||
},
|
||||
|
||||
fromPartial(object: DeepPartial<PublicKey>): PublicKey {
|
||||
const message = { ...basePublicKey } as PublicKey;
|
||||
if (object.ed25519 !== undefined && object.ed25519 !== null) {
|
||||
message.ed25519 = object.ed25519;
|
||||
} else {
|
||||
message.ed25519 = undefined;
|
||||
}
|
||||
if (object.secp256k1 !== undefined && object.secp256k1 !== null) {
|
||||
message.secp256k1 = object.secp256k1;
|
||||
} else {
|
||||
message.secp256k1 = undefined;
|
||||
}
|
||||
return message;
|
||||
},
|
||||
|
||||
toJSON(message: PublicKey): unknown {
|
||||
const obj: any = {};
|
||||
message.ed25519 !== undefined &&
|
||||
(obj.ed25519 = message.ed25519 !== undefined ? base64FromBytes(message.ed25519) : undefined);
|
||||
message.secp256k1 !== undefined &&
|
||||
(obj.secp256k1 = message.secp256k1 !== undefined ? base64FromBytes(message.secp256k1) : undefined);
|
||||
return obj;
|
||||
},
|
||||
};
|
||||
|
||||
declare var self: any | undefined;
|
||||
declare var window: any | undefined;
|
||||
var globalThis: any = (() => {
|
||||
if (typeof globalThis !== "undefined") return globalThis;
|
||||
if (typeof self !== "undefined") return self;
|
||||
if (typeof window !== "undefined") return window;
|
||||
if (typeof global !== "undefined") return global;
|
||||
throw new Error("Unable to locate global object");
|
||||
})();
|
||||
|
||||
const atob: (b64: string) => string =
|
||||
globalThis.atob || ((b64) => globalThis.Buffer.from(b64, "base64").toString("binary"));
|
||||
function bytesFromBase64(b64: string): Uint8Array {
|
||||
const bin = atob(b64);
|
||||
const arr = new Uint8Array(bin.length);
|
||||
for (let i = 0; i < bin.length; ++i) {
|
||||
arr[i] = bin.charCodeAt(i);
|
||||
}
|
||||
return arr;
|
||||
}
|
||||
|
||||
const btoa: (bin: string) => string =
|
||||
globalThis.btoa || ((bin) => globalThis.Buffer.from(bin, "binary").toString("base64"));
|
||||
function base64FromBytes(arr: Uint8Array): string {
|
||||
const bin: string[] = [];
|
||||
for (let i = 0; i < arr.byteLength; ++i) {
|
||||
bin.push(String.fromCharCode(arr[i]));
|
||||
}
|
||||
return btoa(bin.join(""));
|
||||
}
|
||||
|
||||
type Builtin = Date | Function | Uint8Array | string | number | undefined | Long;
|
||||
export type DeepPartial<T> = T extends Builtin
|
||||
? T
|
||||
: T extends Array<infer U>
|
||||
? Array<DeepPartial<U>>
|
||||
: T extends ReadonlyArray<infer U>
|
||||
? ReadonlyArray<DeepPartial<U>>
|
||||
: T extends {}
|
||||
? { [K in keyof T]?: DeepPartial<T[K]> }
|
||||
: Partial<T>;
|
||||
@ -1,98 +0,0 @@
|
||||
/* eslint-disable @typescript-eslint/naming-convention */
|
||||
import { assert } from "@cosmjs/utils";
|
||||
import Long from "long";
|
||||
import { Message } from "protobufjs";
|
||||
|
||||
import { cosmos, google } from "./codec";
|
||||
import { cosmosField, registered } from "./decorator";
|
||||
import { Registry } from "./registry";
|
||||
|
||||
const { TxBody } = cosmos.tx.v1beta1;
|
||||
const { Any } = google.protobuf;
|
||||
|
||||
describe("decorator demo", () => {
|
||||
it("works with a custom msg", () => {
|
||||
const nestedTypeUrl = "/demo.MsgNestedDemo";
|
||||
const typeUrl = "/demo.MsgDemo";
|
||||
const myRegistry = new Registry();
|
||||
|
||||
@registered(myRegistry, nestedTypeUrl)
|
||||
class MsgNestedDemo extends Message {
|
||||
@cosmosField.string(1)
|
||||
public readonly foo?: string;
|
||||
}
|
||||
|
||||
@registered(myRegistry, typeUrl)
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
class MsgDemo extends Message {
|
||||
@cosmosField.boolean(1)
|
||||
public readonly booleanDemo?: boolean;
|
||||
|
||||
@cosmosField.string(2)
|
||||
public readonly stringDemo?: string;
|
||||
|
||||
@cosmosField.bytes(3)
|
||||
public readonly bytesDemo?: Uint8Array;
|
||||
|
||||
@cosmosField.int64(4)
|
||||
public readonly int64Demo?: number;
|
||||
|
||||
@cosmosField.uint64(5)
|
||||
public readonly uint64Demo?: number;
|
||||
|
||||
@cosmosField.repeatedString(6)
|
||||
public readonly listDemo?: readonly string[];
|
||||
|
||||
@cosmosField.message(7, MsgNestedDemo)
|
||||
public readonly nestedDemo?: MsgNestedDemo;
|
||||
}
|
||||
|
||||
const MsgNestedDemoT = myRegistry.lookupType(nestedTypeUrl)!;
|
||||
const MsgDemoT = myRegistry.lookupType(typeUrl)!;
|
||||
|
||||
const msgNestedDemoFields = {
|
||||
foo: "bar",
|
||||
};
|
||||
const msgNestedDemo = MsgNestedDemoT.create(msgNestedDemoFields);
|
||||
|
||||
const msgDemoFields = {
|
||||
booleanDemo: true,
|
||||
stringDemo: "example text",
|
||||
bytesDemo: Uint8Array.from([1, 2, 3, 4, 5, 6, 7, 8]),
|
||||
int64Demo: -123,
|
||||
uint64Demo: 123,
|
||||
listDemo: ["this", "is", "a", "list"],
|
||||
nestedDemo: msgNestedDemo,
|
||||
};
|
||||
const msgDemo = MsgDemoT.create(msgDemoFields);
|
||||
const msgDemoBytes = MsgDemoT.encode(msgDemo).finish();
|
||||
const msgDemoWrapped = Any.create({
|
||||
type_url: typeUrl,
|
||||
value: msgDemoBytes,
|
||||
});
|
||||
const txBody = TxBody.create({
|
||||
messages: [msgDemoWrapped],
|
||||
memo: "Some memo",
|
||||
timeoutHeight: Long.fromNumber(9999),
|
||||
extensionOptions: [],
|
||||
});
|
||||
const txBodyBytes = TxBody.encode(txBody).finish();
|
||||
|
||||
const txBodyDecoded = TxBody.decode(txBodyBytes);
|
||||
const msg = txBodyDecoded.messages[0];
|
||||
assert(msg.type_url);
|
||||
assert(msg.value);
|
||||
|
||||
const msgDemoDecoded = MsgDemoT.decode(msg.value);
|
||||
expect(msgDemoDecoded.booleanDemo).toEqual(msgDemoFields.booleanDemo);
|
||||
expect(msgDemoDecoded.stringDemo).toEqual(msgDemoFields.stringDemo);
|
||||
// bytesDemo decodes to a Buffer in Node
|
||||
expect(Uint8Array.from(msgDemoDecoded.bytesDemo)).toEqual(msgDemoFields.bytesDemo);
|
||||
// int64Demo and uint64Demo decode to Long in Node
|
||||
expect(Number(msgDemoDecoded.int64Demo)).toEqual(msgDemoFields.int64Demo);
|
||||
expect(Number(msgDemoDecoded.uint64Demo)).toEqual(msgDemoFields.uint64Demo);
|
||||
|
||||
expect(msgDemoDecoded.listDemo).toEqual(msgDemoFields.listDemo);
|
||||
expect(msgDemoDecoded.nestedDemo).toEqual(msgDemoFields.nestedDemo);
|
||||
});
|
||||
});
|
||||
@ -1,40 +0,0 @@
|
||||
import { Constructor, Field, Message, TypeDecorator, util } from "protobufjs";
|
||||
|
||||
import { Registry } from "./registry";
|
||||
|
||||
function getTypeName(typeUrl: string): string {
|
||||
const parts = typeUrl.split(".");
|
||||
return parts[parts.length - 1];
|
||||
}
|
||||
|
||||
/**
|
||||
* A class decorator to register this type under the given type URL
|
||||
* in the given registry.
|
||||
*/
|
||||
export function registered(registry: Registry, typeUrl: string): TypeDecorator<any> {
|
||||
return (ctor: Constructor<Message<any>>) => {
|
||||
const typeName = getTypeName(typeUrl);
|
||||
const generatedType = util.decorateType(ctor, typeName);
|
||||
registry.register(typeUrl, generatedType);
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Like PropertyDecorator from lib.es5.d.ts but without symbol support in propertyKey.
|
||||
*/
|
||||
export type FieldDecorator = (target: any, propertyKey: string) => void;
|
||||
|
||||
export const cosmosField = {
|
||||
boolean: (id: number): FieldDecorator => Field.d<boolean>(id, "bool"),
|
||||
|
||||
string: (id: number): FieldDecorator => Field.d<string>(id, "string"),
|
||||
bytes: (id: number): FieldDecorator => Field.d<Uint8Array>(id, "bytes"),
|
||||
|
||||
int64: (id: number): FieldDecorator => Field.d<number>(id, "int64"),
|
||||
uint64: (id: number): FieldDecorator => Field.d<number>(id, "uint64"),
|
||||
|
||||
message: (id: number, ctor: Constructor<Message>): FieldDecorator => Field.d(id, ctor),
|
||||
|
||||
repeatedString: (id: number): FieldDecorator => Field.d<string[]>(id, "string", "repeated"),
|
||||
repeatedMessage: (id: number, ctor: Constructor<Message>): FieldDecorator => Field.d(id, ctor, "repeated"),
|
||||
};
|
||||
@ -3,7 +3,10 @@ import { assert } from "@cosmjs/utils";
|
||||
import Long from "long";
|
||||
import protobuf from "protobufjs";
|
||||
|
||||
import { cosmos, google } from "./codec";
|
||||
import { MsgSend } from "./codec/cosmos/bank/v1beta1/tx";
|
||||
import { Coin } from "./codec/cosmos/base/v1beta1/coin";
|
||||
import { TxBody } from "./codec/cosmos/tx/v1beta1/tx";
|
||||
import { Any } from "./codec/google/protobuf/any";
|
||||
import reflectionRoot from "./demo";
|
||||
import demoJson from "./demo.json";
|
||||
import demoProto from "./demo.proto";
|
||||
@ -12,11 +15,6 @@ type MsgDemo = {
|
||||
readonly example: string;
|
||||
};
|
||||
|
||||
const { Coin } = cosmos.base.v1beta1;
|
||||
const { TxBody } = cosmos.tx.v1beta1;
|
||||
const { MsgSend } = cosmos.bank.v1beta1;
|
||||
const { Any } = google.protobuf;
|
||||
|
||||
function getTypeName(typeUrl: string): string {
|
||||
const parts = typeUrl.split(".");
|
||||
return parts[parts.length - 1];
|
||||
@ -24,21 +22,21 @@ function getTypeName(typeUrl: string): string {
|
||||
|
||||
describe("protobuf demo", () => {
|
||||
it("works with generated static code", () => {
|
||||
const coin = Coin.create({
|
||||
const coin = Coin.fromJSON({
|
||||
denom: "ucosm",
|
||||
amount: "1234567890",
|
||||
});
|
||||
const msgSend = MsgSend.create({
|
||||
const msgSend = MsgSend.fromJSON({
|
||||
fromAddress: "cosmos1pkptre7fdkl6gfrzlesjjvhxhlc3r4gmmk8rs6",
|
||||
toAddress: "cosmos1qypqxpq9qcrsszg2pvxq6rs0zqg3yyc5lzv7xu",
|
||||
amount: [coin],
|
||||
});
|
||||
const msgSendBytes = MsgSend.encode(msgSend).finish();
|
||||
const msgSendWrapped = Any.create({
|
||||
type_url: "/cosmos.bank.v1beta1.MsgSend",
|
||||
const msgSendWrapped = Any.fromPartial({
|
||||
typeUrl: "/cosmos.bank.v1beta1.MsgSend",
|
||||
value: msgSendBytes,
|
||||
});
|
||||
const txBody = TxBody.create({
|
||||
const txBody = TxBody.fromPartial({
|
||||
messages: [msgSendWrapped],
|
||||
memo: "Some memo",
|
||||
timeoutHeight: Long.fromNumber(9999),
|
||||
@ -66,11 +64,11 @@ describe("protobuf demo", () => {
|
||||
example: "Some example text",
|
||||
}) as unknown) as MsgDemo;
|
||||
const msgDemoBytes = encoder.encode(msgDemo).finish();
|
||||
const msgDemoWrapped = Any.create({
|
||||
type_url: typeUrl,
|
||||
const msgDemoWrapped = Any.fromPartial({
|
||||
typeUrl: typeUrl,
|
||||
value: msgDemoBytes,
|
||||
});
|
||||
const txBody = TxBody.create({
|
||||
const txBody = TxBody.fromPartial({
|
||||
messages: [msgDemoWrapped],
|
||||
memo: "Some memo",
|
||||
timeoutHeight: Long.fromNumber(9999),
|
||||
@ -81,10 +79,10 @@ describe("protobuf demo", () => {
|
||||
// Deserialization
|
||||
const txBodyDecoded = TxBody.decode(txBodyBytes);
|
||||
const msg = txBodyDecoded.messages[0];
|
||||
assert(msg.type_url);
|
||||
assert(msg.typeUrl);
|
||||
assert(msg.value);
|
||||
|
||||
const decoder = root.lookupType(getTypeName(msg.type_url));
|
||||
const decoder = root.lookupType(getTypeName(msg.typeUrl));
|
||||
const msgDemoDecoded = (decoder.decode(msg.value) as unknown) as MsgDemo;
|
||||
expect(msgDemoDecoded.example).toEqual(msgDemo.example);
|
||||
});
|
||||
@ -97,11 +95,11 @@ describe("protobuf demo", () => {
|
||||
example: "Some example text",
|
||||
}) as unknown) as MsgDemo;
|
||||
const msgDemoBytes = encoder.encode(msgDemo).finish();
|
||||
const msgDemoWrapped = Any.create({
|
||||
type_url: typeUrl,
|
||||
const msgDemoWrapped = Any.fromPartial({
|
||||
typeUrl: typeUrl,
|
||||
value: msgDemoBytes,
|
||||
});
|
||||
const txBody = TxBody.create({
|
||||
const txBody = TxBody.fromPartial({
|
||||
messages: [msgDemoWrapped],
|
||||
memo: "Some memo",
|
||||
timeoutHeight: Long.fromNumber(9999),
|
||||
@ -112,10 +110,10 @@ describe("protobuf demo", () => {
|
||||
// Deserialization
|
||||
const txBodyDecoded = TxBody.decode(txBodyBytes);
|
||||
const msg = txBodyDecoded.messages[0];
|
||||
assert(msg.type_url);
|
||||
assert(msg.typeUrl);
|
||||
assert(msg.value);
|
||||
|
||||
const decoder = root.lookupType(getTypeName(msg.type_url));
|
||||
const decoder = root.lookupType(getTypeName(msg.typeUrl));
|
||||
const msgDemoDecoded = (decoder.decode(msg.value) as unknown) as MsgDemo;
|
||||
expect(msgDemoDecoded.example).toEqual(msgDemo.example);
|
||||
});
|
||||
@ -127,11 +125,11 @@ describe("protobuf demo", () => {
|
||||
example: "Some example text",
|
||||
}) as unknown) as MsgDemo;
|
||||
const msgDemoBytes = encoder.encode(msgDemo).finish();
|
||||
const msgDemoWrapped = Any.create({
|
||||
type_url: typeUrl,
|
||||
const msgDemoWrapped = Any.fromPartial({
|
||||
typeUrl: typeUrl,
|
||||
value: msgDemoBytes,
|
||||
});
|
||||
const txBody = TxBody.create({
|
||||
const txBody = TxBody.fromPartial({
|
||||
messages: [msgDemoWrapped],
|
||||
memo: "Some memo",
|
||||
timeoutHeight: Long.fromNumber(9999),
|
||||
@ -142,10 +140,10 @@ describe("protobuf demo", () => {
|
||||
// Deserialization
|
||||
const txBodyDecoded = TxBody.decode(txBodyBytes);
|
||||
const msg = txBodyDecoded.messages[0];
|
||||
assert(msg.type_url);
|
||||
assert(msg.typeUrl);
|
||||
assert(msg.value);
|
||||
|
||||
const decoder = reflectionRoot.lookupType(getTypeName(msg.type_url));
|
||||
const decoder = reflectionRoot.lookupType(getTypeName(msg.typeUrl));
|
||||
const msgDemoDecoded = (decoder.decode(msg.value) as unknown) as MsgDemo;
|
||||
expect(msgDemoDecoded.example).toEqual(msgDemo.example);
|
||||
});
|
||||
|
||||
@ -15,7 +15,7 @@ import {
|
||||
rawSecp256k1PubkeyToAddress,
|
||||
} from "@cosmjs/launchpad";
|
||||
|
||||
import { cosmos } from "./codec";
|
||||
import { SignDoc } from "./codec/cosmos/tx/v1beta1/tx";
|
||||
import { DirectSignResponse, OfflineDirectSigner } from "./signer";
|
||||
import { makeSignBytes } from "./signing";
|
||||
|
||||
@ -116,7 +116,7 @@ export class DirectSecp256k1HdWallet implements OfflineDirectSigner {
|
||||
];
|
||||
}
|
||||
|
||||
public async signDirect(address: string, signDoc: cosmos.tx.v1beta1.ISignDoc): Promise<DirectSignResponse> {
|
||||
public async signDirect(address: string, signDoc: SignDoc): Promise<DirectSignResponse> {
|
||||
const signBytes = makeSignBytes(signDoc);
|
||||
if (address !== this.address) {
|
||||
throw new Error(`Address ${address} not found in wallet`);
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
import { Secp256k1, sha256 } from "@cosmjs/crypto";
|
||||
import { AccountData, encodeSecp256k1Signature, rawSecp256k1PubkeyToAddress } from "@cosmjs/launchpad";
|
||||
|
||||
import { cosmos } from "./codec";
|
||||
import { SignDoc } from "./codec/cosmos/tx/v1beta1/tx";
|
||||
import { DirectSignResponse, OfflineDirectSigner } from "./signer";
|
||||
import { makeSignBytes } from "./signing";
|
||||
|
||||
@ -46,7 +46,7 @@ export class DirectSecp256k1Wallet implements OfflineDirectSigner {
|
||||
];
|
||||
}
|
||||
|
||||
public async signDirect(address: string, signDoc: cosmos.tx.v1beta1.ISignDoc): Promise<DirectSignResponse> {
|
||||
public async signDirect(address: string, signDoc: SignDoc): Promise<DirectSignResponse> {
|
||||
const signBytes = makeSignBytes(signDoc);
|
||||
if (address !== this.address) {
|
||||
throw new Error(`Address ${address} not found in wallet`);
|
||||
|
||||
@ -1,5 +1,3 @@
|
||||
export { Coin } from "./msgs";
|
||||
export { cosmosField, registered } from "./decorator";
|
||||
export { EncodeObject, GeneratedType, Registry } from "./registry";
|
||||
export { DirectSecp256k1HdWallet } from "./directsecp256k1hdwallet";
|
||||
export { DirectSecp256k1Wallet } from "./directsecp256k1wallet";
|
||||
|
||||
@ -1,89 +0,0 @@
|
||||
/* eslint-disable @typescript-eslint/naming-convention */
|
||||
import Long from "long";
|
||||
import { Message } from "protobufjs";
|
||||
|
||||
import { cosmosField, registered } from "./decorator";
|
||||
import { Registry } from "./registry";
|
||||
|
||||
describe("registry magic demo", () => {
|
||||
it("works with a custom msg", () => {
|
||||
const nestedTypeUrl = "/demo.MsgNestedMagic";
|
||||
const typeUrl = "/demo.MsgMagic";
|
||||
const myRegistry = new Registry();
|
||||
|
||||
@registered(myRegistry, nestedTypeUrl)
|
||||
class MsgNestedMagic extends Message {
|
||||
@cosmosField.string(1)
|
||||
public readonly foo?: string;
|
||||
}
|
||||
|
||||
@registered(myRegistry, typeUrl)
|
||||
class MsgMagic extends Message {
|
||||
@cosmosField.boolean(1)
|
||||
public readonly booleanDemo?: boolean;
|
||||
|
||||
@cosmosField.string(2)
|
||||
public readonly stringDemo?: string;
|
||||
|
||||
@cosmosField.bytes(3)
|
||||
public readonly bytesDemo?: Uint8Array;
|
||||
|
||||
@cosmosField.int64(4)
|
||||
public readonly int64Demo?: Long;
|
||||
|
||||
@cosmosField.uint64(5)
|
||||
public readonly uint64Demo?: Long;
|
||||
|
||||
@cosmosField.repeatedString(6)
|
||||
public readonly listDemo?: readonly string[];
|
||||
|
||||
@cosmosField.message(7, MsgNestedMagic)
|
||||
public readonly nestedDemo?: MsgNestedMagic;
|
||||
}
|
||||
|
||||
const msgNestedDemoFields = {
|
||||
foo: "bar",
|
||||
};
|
||||
const msgDemoFields = {
|
||||
booleanDemo: true,
|
||||
stringDemo: "example text",
|
||||
bytesDemo: Uint8Array.from([1, 2, 3, 4, 5, 6, 7, 8]),
|
||||
int64Demo: -123,
|
||||
uint64Demo: 123,
|
||||
listDemo: ["this", "is", "a", "list"],
|
||||
nestedDemo: msgNestedDemoFields,
|
||||
};
|
||||
const txBodyFields = {
|
||||
messages: [{ typeUrl: typeUrl, value: msgDemoFields }],
|
||||
memo: "Some memo",
|
||||
timeoutHeight: 9999,
|
||||
extensionOptions: [],
|
||||
};
|
||||
const txBodyBytes = myRegistry.encode({
|
||||
typeUrl: "/cosmos.tx.v1beta1.TxBody",
|
||||
value: txBodyFields,
|
||||
});
|
||||
|
||||
const txBodyDecoded = myRegistry.decode({
|
||||
typeUrl: "/cosmos.tx.v1beta1.TxBody",
|
||||
value: txBodyBytes,
|
||||
});
|
||||
expect(txBodyDecoded.memo).toEqual(txBodyFields.memo);
|
||||
// int64Demo and uint64Demo decode to Long
|
||||
expect(txBodyDecoded.timeoutHeight).toEqual(Long.fromNumber(txBodyFields.timeoutHeight, true));
|
||||
expect(txBodyDecoded.extensionOptions).toEqual(txBodyFields.extensionOptions);
|
||||
|
||||
const msgDemoDecoded = txBodyDecoded.messages[0] as MsgMagic;
|
||||
expect(msgDemoDecoded).toBeInstanceOf(MsgMagic);
|
||||
expect(msgDemoDecoded.booleanDemo).toEqual(msgDemoFields.booleanDemo);
|
||||
expect(msgDemoDecoded.stringDemo).toEqual(msgDemoFields.stringDemo);
|
||||
expect(msgDemoDecoded.bytesDemo).toEqual(msgDemoFields.bytesDemo);
|
||||
// int64Demo and uint64Demo decode to Long
|
||||
expect(msgDemoDecoded.int64Demo).toEqual(Long.fromNumber(msgDemoFields.int64Demo));
|
||||
expect(msgDemoDecoded.uint64Demo).toEqual(Long.fromNumber(msgDemoFields.uint64Demo, true));
|
||||
expect(msgDemoDecoded.listDemo).toEqual(msgDemoFields.listDemo);
|
||||
|
||||
expect(msgDemoDecoded.nestedDemo).toBeInstanceOf(MsgNestedMagic);
|
||||
expect(msgDemoDecoded.nestedDemo!.foo).toEqual(msgDemoFields.nestedDemo.foo);
|
||||
});
|
||||
});
|
||||
@ -1,35 +0,0 @@
|
||||
/* eslint-disable @typescript-eslint/naming-convention */
|
||||
import { cosmos } from "./codec";
|
||||
import { Coin, MsgSend } from "./msgs";
|
||||
|
||||
describe("msgs", () => {
|
||||
it("encodes decorated MsgSend equally to static code", () => {
|
||||
const alice = "cosmos1pkptre7fdkl6gfrzlesjjvhxhlc3r4gmmk8rs6";
|
||||
const bob = "cosmos1qypqxpq9qcrsszg2pvxq6rs0zqg3yyc5lzv7xu";
|
||||
const amount = [
|
||||
new Coin({ denom: "utoken", amount: "123" }),
|
||||
new Coin({ denom: "ustake", amount: "654" }),
|
||||
];
|
||||
const donation = new MsgSend({ from_address: alice, to_address: bob, amount });
|
||||
|
||||
const expected = cosmos.bank.v1beta1.MsgSend.encode(
|
||||
cosmos.bank.v1beta1.MsgSend.create({
|
||||
fromAddress: alice,
|
||||
toAddress: bob,
|
||||
amount: [
|
||||
cosmos.base.v1beta1.Coin.create({
|
||||
denom: "utoken",
|
||||
amount: "123",
|
||||
}),
|
||||
cosmos.base.v1beta1.Coin.create({
|
||||
denom: "ustake",
|
||||
amount: "654",
|
||||
}),
|
||||
],
|
||||
}),
|
||||
).finish();
|
||||
|
||||
const encoded = MsgSend.encode(donation).finish();
|
||||
expect(encoded).toEqual(expected);
|
||||
});
|
||||
});
|
||||
@ -1,28 +0,0 @@
|
||||
/* eslint-disable @typescript-eslint/naming-convention */
|
||||
import { Message } from "protobufjs";
|
||||
|
||||
import { cosmosField, registered } from "./decorator";
|
||||
import { Registry } from "./registry";
|
||||
|
||||
export const defaultRegistry = new Registry();
|
||||
|
||||
@registered(defaultRegistry, "/cosmos.base.v1beta1.Coin")
|
||||
export class Coin extends Message {
|
||||
@cosmosField.string(1)
|
||||
public readonly denom?: string;
|
||||
|
||||
@cosmosField.string(2)
|
||||
public readonly amount?: string;
|
||||
}
|
||||
|
||||
@registered(defaultRegistry, "/cosmos.bank.v1beta1.MsgSend")
|
||||
export class MsgSend extends Message {
|
||||
@cosmosField.string(1)
|
||||
public readonly from_address?: string;
|
||||
|
||||
@cosmosField.string(2)
|
||||
public readonly to_address?: string;
|
||||
|
||||
@cosmosField.repeatedMessage(3, Coin)
|
||||
public readonly amount?: readonly Coin[];
|
||||
}
|
||||
@ -1,11 +1,9 @@
|
||||
/* eslint-disable @typescript-eslint/naming-convention */
|
||||
import { fromBase64 } from "@cosmjs/encoding";
|
||||
|
||||
import { google } from "./codec";
|
||||
import { Any } from "./codec/google/protobuf/any";
|
||||
import { decodePubkey, encodePubkey } from "./pubkey";
|
||||
|
||||
const { Any } = google.protobuf;
|
||||
|
||||
describe("pubkey", () => {
|
||||
const defaultPubkeyBase64 = "AtQaCqFnshaZQp6rIkvAPyzThvCvXSDO+9AzbxVErqJP";
|
||||
const defaultPubkeyBytes = fromBase64(defaultPubkeyBase64);
|
||||
@ -15,8 +13,8 @@ describe("pubkey", () => {
|
||||
it("works for secp256k1", () => {
|
||||
const pubkey = { type: "tendermint/PubKeySecp256k1", value: defaultPubkeyBase64 };
|
||||
expect(encodePubkey(pubkey)).toEqual(
|
||||
Any.create({
|
||||
type_url: "/cosmos.crypto.secp256k1.PubKey",
|
||||
Any.fromPartial({
|
||||
typeUrl: "/cosmos.crypto.secp256k1.PubKey",
|
||||
value: defaultPubkeyProtoBytes,
|
||||
}),
|
||||
);
|
||||
@ -34,7 +32,7 @@ describe("pubkey", () => {
|
||||
describe("decodePubkey", () => {
|
||||
it("works for secp256k1", () => {
|
||||
const pubkey = {
|
||||
type_url: "/cosmos.crypto.secp256k1.PubKey",
|
||||
typeUrl: "/cosmos.crypto.secp256k1.PubKey",
|
||||
value: defaultPubkeyProtoBytes,
|
||||
};
|
||||
expect(decodePubkey(pubkey)).toEqual({
|
||||
@ -45,7 +43,7 @@ describe("pubkey", () => {
|
||||
|
||||
it("throws for unsupported pubkey types", () => {
|
||||
const pubkey = {
|
||||
type_url: "/cosmos.crypto.unknown.PubKey",
|
||||
typeUrl: "/cosmos.crypto.unknown.PubKey",
|
||||
value: defaultPubkeyProtoBytes,
|
||||
};
|
||||
expect(() => decodePubkey(pubkey)).toThrowError(/not recognized/i);
|
||||
|
||||
@ -1,20 +1,19 @@
|
||||
/* eslint-disable @typescript-eslint/naming-convention */
|
||||
import { fromBase64 } from "@cosmjs/encoding";
|
||||
import { encodeSecp256k1Pubkey, PubKey } from "@cosmjs/launchpad";
|
||||
import { encodeSecp256k1Pubkey, PubKey as LaunchpadPubKey } from "@cosmjs/launchpad";
|
||||
|
||||
import { cosmos, google } from "./codec";
|
||||
import { PubKey } from "./codec/cosmos/crypto/secp256k1/keys";
|
||||
import { Any } from "./codec/google/protobuf/any";
|
||||
|
||||
const { Any } = google.protobuf;
|
||||
|
||||
export function encodePubkey(pubkey: PubKey): google.protobuf.IAny {
|
||||
export function encodePubkey(pubkey: LaunchpadPubKey): Any {
|
||||
switch (pubkey.type) {
|
||||
case "tendermint/PubKeySecp256k1": {
|
||||
const pubkeyProto = cosmos.crypto.secp256k1.PubKey.create({
|
||||
const pubkeyProto = PubKey.fromPartial({
|
||||
key: fromBase64(pubkey.value),
|
||||
});
|
||||
return Any.create({
|
||||
type_url: "/cosmos.crypto.secp256k1.PubKey",
|
||||
value: Uint8Array.from(cosmos.crypto.secp256k1.PubKey.encode(pubkeyProto).finish()),
|
||||
return Any.fromPartial({
|
||||
typeUrl: "/cosmos.crypto.secp256k1.PubKey",
|
||||
value: Uint8Array.from(PubKey.encode(pubkeyProto).finish()),
|
||||
});
|
||||
}
|
||||
default:
|
||||
@ -22,17 +21,17 @@ export function encodePubkey(pubkey: PubKey): google.protobuf.IAny {
|
||||
}
|
||||
}
|
||||
|
||||
export function decodePubkey(pubkey?: google.protobuf.IAny | null): PubKey | null {
|
||||
export function decodePubkey(pubkey?: Any | null): LaunchpadPubKey | null {
|
||||
if (!pubkey || !pubkey.value) {
|
||||
return null;
|
||||
}
|
||||
|
||||
switch (pubkey.type_url) {
|
||||
switch (pubkey.typeUrl) {
|
||||
case "/cosmos.crypto.secp256k1.PubKey": {
|
||||
const { key } = cosmos.crypto.secp256k1.PubKey.decode(pubkey.value);
|
||||
const { key } = PubKey.decode(pubkey.value);
|
||||
return encodeSecp256k1Pubkey(key);
|
||||
}
|
||||
default:
|
||||
throw new Error(`Pubkey type_url ${pubkey.type_url} not recognized`);
|
||||
throw new Error(`Pubkey type_url ${pubkey.typeUrl} not recognized`);
|
||||
}
|
||||
}
|
||||
|
||||
@ -2,34 +2,32 @@
|
||||
import { assert } from "@cosmjs/utils";
|
||||
import Long from "long";
|
||||
|
||||
import { cosmos, google } from "./codec";
|
||||
import { MsgDemo as MsgDemoType } from "./demo";
|
||||
import { MsgSend as IMsgSend } from "./codec/cosmos/bank/v1beta1/tx";
|
||||
import { TxBody } from "./codec/cosmos/tx/v1beta1/tx";
|
||||
import { Any } from "./codec/google/protobuf/any";
|
||||
import { Registry } from "./registry";
|
||||
|
||||
const { TxBody } = cosmos.tx.v1beta1;
|
||||
const { Any } = google.protobuf;
|
||||
|
||||
describe("registry demo", () => {
|
||||
it("works with a default msg", () => {
|
||||
const registry = new Registry();
|
||||
const Coin = registry.lookupType("/cosmos.base.v1beta1.Coin")!;
|
||||
const MsgSend = registry.lookupType("/cosmos.bank.v1beta1.MsgSend")!;
|
||||
|
||||
const coin = Coin.create({
|
||||
const coin = Coin.fromPartial({
|
||||
denom: "ucosm",
|
||||
amount: "1234567890",
|
||||
});
|
||||
const msgSend = (MsgSend.create({
|
||||
const msgSend = (MsgSend.fromPartial({
|
||||
fromAddress: "cosmos1pkptre7fdkl6gfrzlesjjvhxhlc3r4gmmk8rs6",
|
||||
toAddress: "cosmos1qypqxpq9qcrsszg2pvxq6rs0zqg3yyc5lzv7xu",
|
||||
amount: [coin],
|
||||
}) as unknown) as cosmos.bank.v1beta1.MsgSend;
|
||||
}) as unknown) as IMsgSend;
|
||||
const msgSendBytes = MsgSend.encode(msgSend).finish();
|
||||
const msgSendWrapped = Any.create({
|
||||
type_url: "/cosmos.bank.v1beta1.MsgSend",
|
||||
const msgSendWrapped = Any.fromPartial({
|
||||
typeUrl: "/cosmos.bank.v1beta1.MsgSend",
|
||||
value: msgSendBytes,
|
||||
});
|
||||
const txBody = TxBody.create({
|
||||
const txBody = TxBody.fromPartial({
|
||||
messages: [msgSendWrapped],
|
||||
memo: "Some memo",
|
||||
timeoutHeight: Long.fromNumber(9999),
|
||||
@ -39,10 +37,10 @@ describe("registry demo", () => {
|
||||
|
||||
const txBodyDecoded = TxBody.decode(txBodyBytes);
|
||||
const msg = txBodyDecoded.messages[0];
|
||||
assert(msg.type_url);
|
||||
assert(msg.typeUrl);
|
||||
assert(msg.value);
|
||||
|
||||
const decoder = registry.lookupType(msg.type_url)!;
|
||||
const decoder = registry.lookupType(msg.typeUrl)!;
|
||||
const msgSendDecoded = decoder.decode(msg.value);
|
||||
|
||||
// fromAddress and toAddress are now Buffers
|
||||
@ -51,34 +49,35 @@ describe("registry demo", () => {
|
||||
expect(msgSendDecoded.amount).toEqual(msgSend.amount);
|
||||
});
|
||||
|
||||
it("works with a custom msg", () => {
|
||||
const typeUrl = "/demo.MsgDemo";
|
||||
const registry = new Registry([[typeUrl, MsgDemoType]]);
|
||||
const MsgDemo = registry.lookupType(typeUrl)!;
|
||||
// TODO: Can't autogenerate types from TS code using ts-proto
|
||||
// it("works with a custom msg", () => {
|
||||
// const typeUrl = "/demo.MsgDemo";
|
||||
// const registry = new Registry([[typeUrl, MsgDemoType]]);
|
||||
// const MsgDemo = registry.lookupType(typeUrl)!;
|
||||
|
||||
const msgDemo = MsgDemo.create({
|
||||
example: "Some example text",
|
||||
});
|
||||
const msgDemoBytes = MsgDemo.encode(msgDemo).finish();
|
||||
const msgDemoWrapped = Any.create({
|
||||
type_url: typeUrl,
|
||||
value: msgDemoBytes,
|
||||
});
|
||||
const txBody = TxBody.create({
|
||||
messages: [msgDemoWrapped],
|
||||
memo: "Some memo",
|
||||
timeoutHeight: Long.fromNumber(9999),
|
||||
extensionOptions: [],
|
||||
});
|
||||
const txBodyBytes = TxBody.encode(txBody).finish();
|
||||
// const msgDemo = MsgDemo.fromPartial({
|
||||
// example: "Some example text",
|
||||
// });
|
||||
// const msgDemoBytes = MsgDemo.encode(msgDemo).finish();
|
||||
// const msgDemoWrapped = Any.create({
|
||||
// type_url: typeUrl,
|
||||
// value: msgDemoBytes,
|
||||
// });
|
||||
// const txBody = TxBody.create({
|
||||
// messages: [msgDemoWrapped],
|
||||
// memo: "Some memo",
|
||||
// timeoutHeight: Long.fromNumber(9999),
|
||||
// extensionOptions: [],
|
||||
// });
|
||||
// const txBodyBytes = TxBody.encode(txBody).finish();
|
||||
|
||||
const txBodyDecoded = TxBody.decode(txBodyBytes);
|
||||
const msg = txBodyDecoded.messages[0];
|
||||
assert(msg.type_url);
|
||||
assert(msg.value);
|
||||
// const txBodyDecoded = TxBody.decode(txBodyBytes);
|
||||
// const msg = txBodyDecoded.messages[0];
|
||||
// assert(msg.type_url);
|
||||
// assert(msg.value);
|
||||
|
||||
const decoder = registry.lookupType(msg.type_url)!;
|
||||
const msgDemoDecoded = decoder.decode(msg.value);
|
||||
expect(msgDemoDecoded.example).toEqual(msgDemo.example);
|
||||
});
|
||||
// const decoder = registry.lookupType(msg.type_url)!;
|
||||
// const msgDemoDecoded = decoder.decode(msg.value);
|
||||
// expect(msgDemoDecoded.example).toEqual(msgDemo.example);
|
||||
// });
|
||||
});
|
||||
|
||||
@ -2,12 +2,17 @@
|
||||
import Long from "long";
|
||||
import protobuf from "protobufjs";
|
||||
|
||||
import { cosmos, google } from "./codec";
|
||||
import { MsgSend } from "./codec/cosmos/bank/v1beta1/tx";
|
||||
import { Coin } from "./codec/cosmos/base/v1beta1/coin";
|
||||
import { TxBody } from "./codec/cosmos/tx/v1beta1/tx";
|
||||
import { Any } from "./codec/google/protobuf/any";
|
||||
|
||||
export interface GeneratedType {
|
||||
readonly create: (properties?: { [k: string]: any }) => any;
|
||||
readonly encode: (message: any | { [k: string]: any }, writer?: protobuf.Writer) => protobuf.Writer;
|
||||
readonly decode: (reader: protobuf.Reader | Uint8Array, length?: number) => any;
|
||||
readonly decode: (input: Uint8Array | protobuf.Reader, length?: number) => any;
|
||||
readonly fromJSON: (object: { [k: string]: any }) => any;
|
||||
readonly fromPartial: (object: { [k: string]: any }) => any;
|
||||
readonly toJSON: (message: any | { [k: string]: any }) => unknown;
|
||||
}
|
||||
|
||||
export interface EncodeObject {
|
||||
@ -24,8 +29,8 @@ export interface TxBodyValue {
|
||||
readonly messages: readonly EncodeObject[];
|
||||
readonly memo?: string;
|
||||
readonly timeoutHeight?: Long;
|
||||
readonly extensionOptions?: google.protobuf.IAny[];
|
||||
readonly nonCriticalExtensionOptions?: google.protobuf.IAny[];
|
||||
readonly extensionOptions?: Any[];
|
||||
readonly nonCriticalExtensionOptions?: Any[];
|
||||
}
|
||||
|
||||
const defaultTypeUrls = {
|
||||
@ -41,8 +46,8 @@ export class Registry {
|
||||
public constructor(customTypes: Iterable<[string, GeneratedType]> = []) {
|
||||
const { cosmosCoin, cosmosMsgSend } = defaultTypeUrls;
|
||||
this.types = new Map<string, GeneratedType>([
|
||||
[cosmosCoin, cosmos.base.v1beta1.Coin],
|
||||
[cosmosMsgSend, cosmos.bank.v1beta1.MsgSend],
|
||||
[cosmosCoin, Coin],
|
||||
[cosmosMsgSend, MsgSend],
|
||||
...customTypes,
|
||||
]);
|
||||
}
|
||||
@ -68,22 +73,19 @@ export class Registry {
|
||||
return this.encodeTxBody(value);
|
||||
}
|
||||
const type = this.lookupTypeWithError(typeUrl);
|
||||
const created = type.create(value);
|
||||
const created = type.fromPartial(value);
|
||||
return Uint8Array.from(type.encode(created).finish());
|
||||
}
|
||||
|
||||
public encodeTxBody(txBodyFields: TxBodyValue): Uint8Array {
|
||||
const { TxBody } = cosmos.tx.v1beta1;
|
||||
const { Any } = google.protobuf;
|
||||
|
||||
const wrappedMessages = txBodyFields.messages.map((message) => {
|
||||
const messageBytes = this.encode(message);
|
||||
return Any.create({
|
||||
type_url: message.typeUrl,
|
||||
return Any.fromPartial({
|
||||
typeUrl: message.typeUrl,
|
||||
value: messageBytes,
|
||||
});
|
||||
});
|
||||
const txBody = TxBody.create({
|
||||
const txBody = TxBody.fromPartial({
|
||||
...txBodyFields,
|
||||
messages: wrappedMessages,
|
||||
});
|
||||
@ -104,13 +106,12 @@ export class Registry {
|
||||
return decoded;
|
||||
}
|
||||
|
||||
public decodeTxBody(txBody: Uint8Array): cosmos.tx.v1beta1.TxBody {
|
||||
const { TxBody } = cosmos.tx.v1beta1;
|
||||
public decodeTxBody(txBody: Uint8Array): TxBody {
|
||||
const decodedTxBody = TxBody.decode(txBody);
|
||||
|
||||
return {
|
||||
...decodedTxBody,
|
||||
messages: decodedTxBody.messages.map(({ type_url: typeUrl, value }: google.protobuf.IAny) => {
|
||||
messages: decodedTxBody.messages.map(({ typeUrl: typeUrl, value }: Any) => {
|
||||
if (!typeUrl) {
|
||||
throw new Error("Missing type_url in Any");
|
||||
}
|
||||
|
||||
@ -1,22 +1,19 @@
|
||||
import { AccountData, OfflineSigner as OfflineAminoSigner, StdSignature } from "@cosmjs/launchpad";
|
||||
|
||||
import { cosmos } from "./codec";
|
||||
import { SignDoc } from "./codec/cosmos/tx/v1beta1/tx";
|
||||
|
||||
export interface DirectSignResponse {
|
||||
/**
|
||||
* The sign doc that was signed.
|
||||
* This may be different from the input signDoc when the signer modifies it as part of the signing process.
|
||||
*/
|
||||
readonly signed: cosmos.tx.v1beta1.ISignDoc;
|
||||
readonly signed: SignDoc;
|
||||
readonly signature: StdSignature;
|
||||
}
|
||||
|
||||
export interface OfflineDirectSigner {
|
||||
readonly getAccounts: () => Promise<readonly AccountData[]>;
|
||||
readonly signDirect: (
|
||||
signerAddress: string,
|
||||
signDoc: cosmos.tx.v1beta1.ISignDoc,
|
||||
) => Promise<DirectSignResponse>;
|
||||
readonly signDirect: (signerAddress: string, signDoc: SignDoc) => Promise<DirectSignResponse>;
|
||||
}
|
||||
|
||||
export type OfflineSigner = OfflineAminoSigner | OfflineDirectSigner;
|
||||
|
||||
@ -1,17 +1,15 @@
|
||||
/* eslint-disable @typescript-eslint/naming-convention */
|
||||
import { fromBase64, fromHex, toHex } from "@cosmjs/encoding";
|
||||
|
||||
import { cosmos, google } from "./codec";
|
||||
import { PubKey } from "./codec/cosmos/crypto/secp256k1/keys";
|
||||
import { SignMode } from "./codec/cosmos/tx/signing/v1beta1/signing";
|
||||
import { Tx, TxRaw } from "./codec/cosmos/tx/v1beta1/tx";
|
||||
import { Any } from "./codec/google/protobuf/any";
|
||||
import { DirectSecp256k1HdWallet } from "./directsecp256k1hdwallet";
|
||||
import { defaultRegistry } from "./msgs";
|
||||
import { Registry, TxBodyValue } from "./registry";
|
||||
import { makeAuthInfoBytes, makeSignBytes, makeSignDoc } from "./signing";
|
||||
import { faucet, testVectors } from "./testutils.spec";
|
||||
|
||||
const { Tx, TxRaw } = cosmos.tx.v1beta1;
|
||||
const { PubKey } = cosmos.crypto.secp256k1;
|
||||
const { Any } = google.protobuf;
|
||||
|
||||
describe("signing", () => {
|
||||
const chainId = "simd-testing";
|
||||
const toAddress = "cosmos1qypqxpq9qcrsszg2pvxq6rs0zqg3yyc5lzv7xu";
|
||||
@ -34,25 +32,26 @@ describe("signing", () => {
|
||||
testVectors.forEach(({ signedTxBytes }) => {
|
||||
const parsedTestTx = Tx.decode(fromHex(signedTxBytes));
|
||||
expect(parsedTestTx.signatures.length).toEqual(1);
|
||||
expect(parsedTestTx.authInfo!.signerInfos!.length).toEqual(1);
|
||||
expect(Uint8Array.from(parsedTestTx.authInfo!.signerInfos![0].publicKey!.value ?? [])).toEqual(
|
||||
expect(parsedTestTx.authInfo!.signerInfos.length).toEqual(1);
|
||||
expect(Uint8Array.from(parsedTestTx.authInfo!.signerInfos[0].publicKey!.value ?? [])).toEqual(
|
||||
prefixedPubkeyBytes,
|
||||
);
|
||||
expect(parsedTestTx.authInfo?.signerInfos![0].modeInfo!.single!.mode).toEqual(
|
||||
cosmos.tx.signing.v1beta1.SignMode.SIGN_MODE_DIRECT,
|
||||
SignMode.SIGN_MODE_DIRECT,
|
||||
);
|
||||
expect({ ...parsedTestTx.authInfo!.fee!.amount![0] }).toEqual({ denom: "ucosm", amount: "2000" });
|
||||
expect(parsedTestTx.authInfo!.fee!.gasLimit!.toString()).toEqual(gasLimit.toString());
|
||||
expect({ ...parsedTestTx.authInfo!.fee!.amount[0] }).toEqual({ denom: "ucosm", amount: "2000" });
|
||||
expect(parsedTestTx.authInfo!.fee!.gasLimit.toString()).toEqual(gasLimit.toString());
|
||||
expect(parsedTestTx.body!.extensionOptions).toEqual([]);
|
||||
expect(parsedTestTx.body!.nonCriticalExtensionOptions).toEqual([]);
|
||||
expect(parsedTestTx.body!.messages!.length).toEqual(1);
|
||||
expect(parsedTestTx.body!.messages.length).toEqual(1);
|
||||
|
||||
const parsedTestTxMsg = defaultRegistry.decode({
|
||||
typeUrl: parsedTestTx.body!.messages![0].type_url!,
|
||||
value: parsedTestTx.body!.messages![0].value!,
|
||||
const registry = new Registry();
|
||||
const parsedTestTxMsg = registry.decode({
|
||||
typeUrl: parsedTestTx.body!.messages[0].typeUrl,
|
||||
value: parsedTestTx.body!.messages[0].value,
|
||||
});
|
||||
expect(parsedTestTxMsg.from_address).toEqual(address);
|
||||
expect(parsedTestTxMsg.to_address).toEqual(toAddress);
|
||||
expect(parsedTestTxMsg.fromAddress).toEqual(address);
|
||||
expect(parsedTestTxMsg.toAddress).toEqual(toAddress);
|
||||
expect(parsedTestTxMsg.amount.length).toEqual(1);
|
||||
expect(parsedTestTxMsg.amount[0].denom).toEqual(sendDenom);
|
||||
expect(parsedTestTxMsg.amount[0].amount).toEqual(sendAmount);
|
||||
@ -63,7 +62,7 @@ describe("signing", () => {
|
||||
const myRegistry = new Registry();
|
||||
const wallet = await DirectSecp256k1HdWallet.fromMnemonic(faucet.mnemonic);
|
||||
const [{ address, pubkey: pubkeyBytes }] = await wallet.getAccounts();
|
||||
const publicKey = PubKey.create({
|
||||
const publicKey = PubKey.fromPartial({
|
||||
key: pubkeyBytes,
|
||||
});
|
||||
const publicKeyBytes = PubKey.encode(publicKey).finish();
|
||||
@ -90,7 +89,10 @@ describe("signing", () => {
|
||||
value: txBodyFields,
|
||||
});
|
||||
|
||||
const publicKeyAny = Any.create({ type_url: "/cosmos.crypto.secp256k1.PubKey", value: publicKeyBytes });
|
||||
const publicKeyAny = Any.fromPartial({
|
||||
typeUrl: "/cosmos.crypto.secp256k1.PubKey",
|
||||
value: publicKeyBytes,
|
||||
});
|
||||
const accountNumber = 1;
|
||||
|
||||
await Promise.all(
|
||||
@ -101,7 +103,7 @@ describe("signing", () => {
|
||||
expect(toHex(signDocBytes)).toEqual(signBytes);
|
||||
|
||||
const { signature } = await wallet.signDirect(address, signDoc);
|
||||
const txRaw = TxRaw.create({
|
||||
const txRaw = TxRaw.fromPartial({
|
||||
bodyBytes: txBodyBytes,
|
||||
authInfoBytes: authInfoBytes,
|
||||
signatures: [fromBase64(signature.signature)],
|
||||
|
||||
@ -1,34 +1,37 @@
|
||||
/* eslint-disable @typescript-eslint/naming-convention */
|
||||
import Long from "long";
|
||||
|
||||
import { omitDefaults } from "./adr27";
|
||||
import { cosmos, google } from "./codec";
|
||||
|
||||
const { SignDoc, AuthInfo } = cosmos.tx.v1beta1;
|
||||
import { Coin } from "./codec/cosmos/base/v1beta1/coin";
|
||||
import { SignMode } from "./codec/cosmos/tx/signing/v1beta1/signing";
|
||||
import { AuthInfo, SignDoc, SignerInfo } from "./codec/cosmos/tx/v1beta1/tx";
|
||||
import { Any } from "./codec/google/protobuf/any";
|
||||
|
||||
/**
|
||||
* Creates and serializes an AuthInfo document using SIGN_MODE_DIRECT.
|
||||
*/
|
||||
export function makeAuthInfoBytes(
|
||||
pubkeys: readonly google.protobuf.IAny[],
|
||||
feeAmount: readonly cosmos.base.v1beta1.Coin[],
|
||||
pubkeys: readonly Any[],
|
||||
feeAmount: readonly Coin[],
|
||||
gasLimit: number,
|
||||
sequence: number,
|
||||
signMode = cosmos.tx.signing.v1beta1.SignMode.SIGN_MODE_DIRECT,
|
||||
signMode = SignMode.SIGN_MODE_DIRECT,
|
||||
): Uint8Array {
|
||||
const authInfo = {
|
||||
signerInfos: pubkeys.map(
|
||||
(pubkey): cosmos.tx.v1beta1.ISignerInfo => ({
|
||||
(pubkey): SignerInfo => ({
|
||||
publicKey: pubkey,
|
||||
modeInfo: {
|
||||
single: { mode: signMode },
|
||||
},
|
||||
sequence: sequence ? Long.fromNumber(sequence) : undefined,
|
||||
sequence: Long.fromNumber(sequence),
|
||||
}),
|
||||
),
|
||||
fee: { amount: [...feeAmount], gasLimit: Long.fromNumber(gasLimit) },
|
||||
fee: {
|
||||
amount: [...feeAmount],
|
||||
gasLimit: Long.fromNumber(gasLimit),
|
||||
},
|
||||
};
|
||||
return Uint8Array.from(AuthInfo.encode(authInfo).finish());
|
||||
return AuthInfo.encode(AuthInfo.fromPartial(authInfo)).finish();
|
||||
}
|
||||
|
||||
export function makeSignDoc(
|
||||
@ -36,7 +39,7 @@ export function makeSignDoc(
|
||||
authInfoBytes: Uint8Array,
|
||||
chainId: string,
|
||||
accountNumber: number,
|
||||
): cosmos.tx.v1beta1.ISignDoc {
|
||||
): SignDoc {
|
||||
return {
|
||||
bodyBytes: bodyBytes,
|
||||
authInfoBytes: authInfoBytes,
|
||||
@ -45,19 +48,12 @@ export function makeSignDoc(
|
||||
};
|
||||
}
|
||||
|
||||
export function makeSignBytes({
|
||||
accountNumber,
|
||||
authInfoBytes,
|
||||
bodyBytes,
|
||||
chainId,
|
||||
}: cosmos.tx.v1beta1.ISignDoc): Uint8Array {
|
||||
const signDoc = SignDoc.create(
|
||||
omitDefaults({
|
||||
accountNumber: accountNumber,
|
||||
authInfoBytes: authInfoBytes,
|
||||
bodyBytes: bodyBytes,
|
||||
chainId: chainId,
|
||||
}),
|
||||
);
|
||||
return Uint8Array.from(SignDoc.encode(signDoc).finish());
|
||||
export function makeSignBytes({ accountNumber, authInfoBytes, bodyBytes, chainId }: SignDoc): Uint8Array {
|
||||
const signDoc = SignDoc.fromPartial({
|
||||
accountNumber: accountNumber,
|
||||
authInfoBytes: authInfoBytes,
|
||||
bodyBytes: bodyBytes,
|
||||
chainId: chainId,
|
||||
});
|
||||
return SignDoc.encode(signDoc).finish();
|
||||
}
|
||||
|
||||
@ -15,33 +15,33 @@ export const testVectors = [
|
||||
{
|
||||
sequence: 0,
|
||||
signedTxBytes:
|
||||
"0a93010a90010a1c2f636f736d6f732e62616e6b2e763162657461312e4d736753656e6412700a2d636f736d6f7331706b707472653766646b6c366766727a6c65736a6a766878686c63337234676d6d6b38727336122d636f736d6f7331717970717870713971637273737a673270767871367273307a716733797963356c7a763778751a100a0575636f736d12073132333435363712650a4e0a460a1f2f636f736d6f732e63727970746f2e736563703235366b312e5075624b657912230a21034f04181eeba35391b858633a765c4a0c189697b40d216354d50890d350c7029012040a02080112130a0d0a0575636f736d12043230303010c09a0c1a40c9dd20e07464d3a688ff4b710b1fbc027e495e797cfa0b4804da2ed117959227772de059808f765aa29b8f92edf30f4c2c5a438e30d3fe6897daa7141e3ce6f9",
|
||||
"0a97010a90010a1c2f636f736d6f732e62616e6b2e763162657461312e4d736753656e6412700a2d636f736d6f7331706b707472653766646b6c366766727a6c65736a6a766878686c63337234676d6d6b38727336122d636f736d6f7331717970717870713971637273737a673270767871367273307a716733797963356c7a763778751a100a0575636f736d12073132333435363712001800126b0a500a460a1f2f636f736d6f732e63727970746f2e736563703235366b312e5075624b657912230a21034f04181eeba35391b858633a765c4a0c189697b40d216354d50890d350c7029012040a020801180012170a0d0a0575636f736d12043230303010c09a0c1a0022001a40d1bb55b0f3e5f9c260a20c8ccf2cb44f19bafccba84c7fb6e2b77fac401b15c9228c33236a701dd7a7c4a481aa5dedb902c982fe565504c4f4e7f39ccfcd73d6",
|
||||
bodyBytes:
|
||||
"0a90010a1c2f636f736d6f732e62616e6b2e763162657461312e4d736753656e6412700a2d636f736d6f7331706b707472653766646b6c366766727a6c65736a6a766878686c63337234676d6d6b38727336122d636f736d6f7331717970717870713971637273737a673270767871367273307a716733797963356c7a763778751a100a0575636f736d120731323334353637",
|
||||
signBytes:
|
||||
"0a93010a90010a1c2f636f736d6f732e62616e6b2e763162657461312e4d736753656e6412700a2d636f736d6f7331706b707472653766646b6c366766727a6c65736a6a766878686c63337234676d6d6b38727336122d636f736d6f7331717970717870713971637273737a673270767871367273307a716733797963356c7a763778751a100a0575636f736d12073132333435363712650a4e0a460a1f2f636f736d6f732e63727970746f2e736563703235366b312e5075624b657912230a21034f04181eeba35391b858633a765c4a0c189697b40d216354d50890d350c7029012040a02080112130a0d0a0575636f736d12043230303010c09a0c1a0c73696d642d74657374696e672001",
|
||||
"0a97010a90010a1c2f636f736d6f732e62616e6b2e763162657461312e4d736753656e6412700a2d636f736d6f7331706b707472653766646b6c366766727a6c65736a6a766878686c63337234676d6d6b38727336122d636f736d6f7331717970717870713971637273737a673270767871367273307a716733797963356c7a763778751a100a0575636f736d12073132333435363712001800126b0a500a460a1f2f636f736d6f732e63727970746f2e736563703235366b312e5075624b657912230a21034f04181eeba35391b858633a765c4a0c189697b40d216354d50890d350c7029012040a020801180012170a0d0a0575636f736d12043230303010c09a0c1a0022001a0c73696d642d74657374696e672001",
|
||||
signature:
|
||||
"c9dd20e07464d3a688ff4b710b1fbc027e495e797cfa0b4804da2ed117959227772de059808f765aa29b8f92edf30f4c2c5a438e30d3fe6897daa7141e3ce6f9",
|
||||
},
|
||||
{
|
||||
sequence: 1,
|
||||
signedTxBytes:
|
||||
"0a93010a90010a1c2f636f736d6f732e62616e6b2e763162657461312e4d736753656e6412700a2d636f736d6f7331706b707472653766646b6c366766727a6c65736a6a766878686c63337234676d6d6b38727336122d636f736d6f7331717970717870713971637273737a673270767871367273307a716733797963356c7a763778751a100a0575636f736d12073132333435363712670a500a460a1f2f636f736d6f732e63727970746f2e736563703235366b312e5075624b657912230a21034f04181eeba35391b858633a765c4a0c189697b40d216354d50890d350c7029012040a020801180112130a0d0a0575636f736d12043230303010c09a0c1a40525adc7e61565a509c60497b798c549fbf217bb5cd31b24cc9b419d098cc95330c99ecc4bc72448f85c365a4e3f91299a3d40412fb3751bab82f1940a83a0a4c",
|
||||
signBytes:
|
||||
"0a93010a90010a1c2f636f736d6f732e62616e6b2e763162657461312e4d736753656e6412700a2d636f736d6f7331706b707472653766646b6c366766727a6c65736a6a766878686c63337234676d6d6b38727336122d636f736d6f7331717970717870713971637273737a673270767871367273307a716733797963356c7a763778751a100a0575636f736d12073132333435363712670a500a460a1f2f636f736d6f732e63727970746f2e736563703235366b312e5075624b657912230a21034f04181eeba35391b858633a765c4a0c189697b40d216354d50890d350c7029012040a020801180112130a0d0a0575636f736d12043230303010c09a0c1a0c73696d642d74657374696e672001",
|
||||
"0a97010a90010a1c2f636f736d6f732e62616e6b2e763162657461312e4d736753656e6412700a2d636f736d6f7331706b707472653766646b6c366766727a6c65736a6a766878686c63337234676d6d6b38727336122d636f736d6f7331717970717870713971637273737a673270767871367273307a716733797963356c7a763778751a100a0575636f736d12073132333435363712001800126b0a500a460a1f2f636f736d6f732e63727970746f2e736563703235366b312e5075624b657912230a21034f04181eeba35391b858633a765c4a0c189697b40d216354d50890d350c7029012040a020801180112170a0d0a0575636f736d12043230303010c09a0c1a0022001a40d6d876ec9c01d03b025443822b1385e29ed559341ec71853ac310219b4bcb4112bf24265a19d805f0cbb1cb39f4ac4fe75235445070aa14845733117a746c248",
|
||||
bodyBytes:
|
||||
"0a90010a1c2f636f736d6f732e62616e6b2e763162657461312e4d736753656e6412700a2d636f736d6f7331706b707472653766646b6c366766727a6c65736a6a766878686c63337234676d6d6b38727336122d636f736d6f7331717970717870713971637273737a673270767871367273307a716733797963356c7a763778751a100a0575636f736d120731323334353637",
|
||||
signBytes:
|
||||
"0a97010a90010a1c2f636f736d6f732e62616e6b2e763162657461312e4d736753656e6412700a2d636f736d6f7331706b707472653766646b6c366766727a6c65736a6a766878686c63337234676d6d6b38727336122d636f736d6f7331717970717870713971637273737a673270767871367273307a716733797963356c7a763778751a100a0575636f736d12073132333435363712001800126b0a500a460a1f2f636f736d6f732e63727970746f2e736563703235366b312e5075624b657912230a21034f04181eeba35391b858633a765c4a0c189697b40d216354d50890d350c7029012040a020801180112170a0d0a0575636f736d12043230303010c09a0c1a0022001a0c73696d642d74657374696e672001",
|
||||
signature:
|
||||
"525adc7e61565a509c60497b798c549fbf217bb5cd31b24cc9b419d098cc95330c99ecc4bc72448f85c365a4e3f91299a3d40412fb3751bab82f1940a83a0a4c",
|
||||
},
|
||||
{
|
||||
sequence: 2,
|
||||
signedTxBytes:
|
||||
"0a93010a90010a1c2f636f736d6f732e62616e6b2e763162657461312e4d736753656e6412700a2d636f736d6f7331706b707472653766646b6c366766727a6c65736a6a766878686c63337234676d6d6b38727336122d636f736d6f7331717970717870713971637273737a673270767871367273307a716733797963356c7a763778751a100a0575636f736d12073132333435363712670a500a460a1f2f636f736d6f732e63727970746f2e736563703235366b312e5075624b657912230a21034f04181eeba35391b858633a765c4a0c189697b40d216354d50890d350c7029012040a020801180212130a0d0a0575636f736d12043230303010c09a0c1a40f3f2ca73806f2abbf6e0fe85f9b8af66f0e9f7f79051fdb8abe5bb8633b17da132e82d577b9d5f7a6dae57a144efc9ccc6eef15167b44b3b22a57240109762af",
|
||||
"0a97010a90010a1c2f636f736d6f732e62616e6b2e763162657461312e4d736753656e6412700a2d636f736d6f7331706b707472653766646b6c366766727a6c65736a6a766878686c63337234676d6d6b38727336122d636f736d6f7331717970717870713971637273737a673270767871367273307a716733797963356c7a763778751a100a0575636f736d12073132333435363712001800126b0a500a460a1f2f636f736d6f732e63727970746f2e736563703235366b312e5075624b657912230a21034f04181eeba35391b858633a765c4a0c189697b40d216354d50890d350c7029012040a020801180212170a0d0a0575636f736d12043230303010c09a0c1a0022001a40c62931c5f283dc72774cb34165ad98169c40de14c13e9c11c696cb439c7c58ab0c2017c95cb9ed874ace06460b61f1296dddb20c9e0609e364d1f38e163b7c7b",
|
||||
bodyBytes:
|
||||
"0a90010a1c2f636f736d6f732e62616e6b2e763162657461312e4d736753656e6412700a2d636f736d6f7331706b707472653766646b6c366766727a6c65736a6a766878686c63337234676d6d6b38727336122d636f736d6f7331717970717870713971637273737a673270767871367273307a716733797963356c7a763778751a100a0575636f736d120731323334353637",
|
||||
signBytes:
|
||||
"0a93010a90010a1c2f636f736d6f732e62616e6b2e763162657461312e4d736753656e6412700a2d636f736d6f7331706b707472653766646b6c366766727a6c65736a6a766878686c63337234676d6d6b38727336122d636f736d6f7331717970717870713971637273737a673270767871367273307a716733797963356c7a763778751a100a0575636f736d12073132333435363712670a500a460a1f2f636f736d6f732e63727970746f2e736563703235366b312e5075624b657912230a21034f04181eeba35391b858633a765c4a0c189697b40d216354d50890d350c7029012040a020801180212130a0d0a0575636f736d12043230303010c09a0c1a0c73696d642d74657374696e672001",
|
||||
"0a97010a90010a1c2f636f736d6f732e62616e6b2e763162657461312e4d736753656e6412700a2d636f736d6f7331706b707472653766646b6c366766727a6c65736a6a766878686c63337234676d6d6b38727336122d636f736d6f7331717970717870713971637273737a673270767871367273307a716733797963356c7a763778751a100a0575636f736d12073132333435363712001800126b0a500a460a1f2f636f736d6f732e63727970746f2e736563703235366b312e5075624b657912230a21034f04181eeba35391b858633a765c4a0c189697b40d216354d50890d350c7029012040a020801180212170a0d0a0575636f736d12043230303010c09a0c1a0022001a0c73696d642d74657374696e672001",
|
||||
signature:
|
||||
"f3f2ca73806f2abbf6e0fe85f9b8af66f0e9f7f79051fdb8abe5bb8633b17da132e82d577b9d5f7a6dae57a144efc9ccc6eef15167b44b3b22a57240109762af",
|
||||
},
|
||||
|
||||
130
packages/proto-signing/types/codec/cosmos/bank/v1beta1/bank.d.ts
vendored
Normal file
130
packages/proto-signing/types/codec/cosmos/bank/v1beta1/bank.d.ts
vendored
Normal file
@ -0,0 +1,130 @@
|
||||
import { Coin } from "../../../cosmos/base/v1beta1/coin";
|
||||
import Long from "long";
|
||||
import _m0 from "protobufjs/minimal";
|
||||
export declare const protobufPackage = "cosmos.bank.v1beta1";
|
||||
/** Params defines the parameters for the bank module. */
|
||||
export interface Params {
|
||||
sendEnabled: SendEnabled[];
|
||||
defaultSendEnabled: boolean;
|
||||
}
|
||||
/**
|
||||
* SendEnabled maps coin denom to a send_enabled status (whether a denom is
|
||||
* sendable).
|
||||
*/
|
||||
export interface SendEnabled {
|
||||
denom: string;
|
||||
enabled: boolean;
|
||||
}
|
||||
/** Input models transaction input. */
|
||||
export interface Input {
|
||||
address: string;
|
||||
coins: Coin[];
|
||||
}
|
||||
/** Output models transaction outputs. */
|
||||
export interface Output {
|
||||
address: string;
|
||||
coins: Coin[];
|
||||
}
|
||||
/**
|
||||
* Supply represents a struct that passively keeps track of the total supply
|
||||
* amounts in the network.
|
||||
*/
|
||||
export interface Supply {
|
||||
total: Coin[];
|
||||
}
|
||||
/**
|
||||
* DenomUnit represents a struct that describes a given
|
||||
* denomination unit of the basic token.
|
||||
*/
|
||||
export interface DenomUnit {
|
||||
/** denom represents the string name of the given denom unit (e.g uatom). */
|
||||
denom: string;
|
||||
/**
|
||||
* exponent represents power of 10 exponent that one must
|
||||
* raise the base_denom to in order to equal the given DenomUnit's denom
|
||||
* 1 denom = 1^exponent base_denom
|
||||
* (e.g. with a base_denom of uatom, one can create a DenomUnit of 'atom' with
|
||||
* exponent = 6, thus: 1 atom = 10^6 uatom).
|
||||
*/
|
||||
exponent: number;
|
||||
/** aliases is a list of string aliases for the given denom */
|
||||
aliases: string[];
|
||||
}
|
||||
/**
|
||||
* Metadata represents a struct that describes
|
||||
* a basic token.
|
||||
*/
|
||||
export interface Metadata {
|
||||
description: string;
|
||||
/** denom_units represents the list of DenomUnit's for a given coin */
|
||||
denomUnits: DenomUnit[];
|
||||
/** base represents the base denom (should be the DenomUnit with exponent = 0). */
|
||||
base: string;
|
||||
/**
|
||||
* display indicates the suggested denom that should be
|
||||
* displayed in clients.
|
||||
*/
|
||||
display: string;
|
||||
}
|
||||
export declare const Params: {
|
||||
encode(message: Params, writer?: _m0.Writer): _m0.Writer;
|
||||
decode(input: _m0.Reader | Uint8Array, length?: number | undefined): Params;
|
||||
fromJSON(object: any): Params;
|
||||
fromPartial(object: DeepPartial<Params>): Params;
|
||||
toJSON(message: Params): unknown;
|
||||
};
|
||||
export declare const SendEnabled: {
|
||||
encode(message: SendEnabled, writer?: _m0.Writer): _m0.Writer;
|
||||
decode(input: _m0.Reader | Uint8Array, length?: number | undefined): SendEnabled;
|
||||
fromJSON(object: any): SendEnabled;
|
||||
fromPartial(object: DeepPartial<SendEnabled>): SendEnabled;
|
||||
toJSON(message: SendEnabled): unknown;
|
||||
};
|
||||
export declare const Input: {
|
||||
encode(message: Input, writer?: _m0.Writer): _m0.Writer;
|
||||
decode(input: _m0.Reader | Uint8Array, length?: number | undefined): Input;
|
||||
fromJSON(object: any): Input;
|
||||
fromPartial(object: DeepPartial<Input>): Input;
|
||||
toJSON(message: Input): unknown;
|
||||
};
|
||||
export declare const Output: {
|
||||
encode(message: Output, writer?: _m0.Writer): _m0.Writer;
|
||||
decode(input: _m0.Reader | Uint8Array, length?: number | undefined): Output;
|
||||
fromJSON(object: any): Output;
|
||||
fromPartial(object: DeepPartial<Output>): Output;
|
||||
toJSON(message: Output): unknown;
|
||||
};
|
||||
export declare const Supply: {
|
||||
encode(message: Supply, writer?: _m0.Writer): _m0.Writer;
|
||||
decode(input: _m0.Reader | Uint8Array, length?: number | undefined): Supply;
|
||||
fromJSON(object: any): Supply;
|
||||
fromPartial(object: DeepPartial<Supply>): Supply;
|
||||
toJSON(message: Supply): unknown;
|
||||
};
|
||||
export declare const DenomUnit: {
|
||||
encode(message: DenomUnit, writer?: _m0.Writer): _m0.Writer;
|
||||
decode(input: _m0.Reader | Uint8Array, length?: number | undefined): DenomUnit;
|
||||
fromJSON(object: any): DenomUnit;
|
||||
fromPartial(object: DeepPartial<DenomUnit>): DenomUnit;
|
||||
toJSON(message: DenomUnit): unknown;
|
||||
};
|
||||
export declare const Metadata: {
|
||||
encode(message: Metadata, writer?: _m0.Writer): _m0.Writer;
|
||||
decode(input: _m0.Reader | Uint8Array, length?: number | undefined): Metadata;
|
||||
fromJSON(object: any): Metadata;
|
||||
fromPartial(object: DeepPartial<Metadata>): Metadata;
|
||||
toJSON(message: Metadata): unknown;
|
||||
};
|
||||
declare type Builtin = Date | Function | Uint8Array | string | number | undefined | Long;
|
||||
export declare type DeepPartial<T> = T extends Builtin
|
||||
? T
|
||||
: T extends Array<infer U>
|
||||
? Array<DeepPartial<U>>
|
||||
: T extends ReadonlyArray<infer U>
|
||||
? ReadonlyArray<DeepPartial<U>>
|
||||
: T extends {}
|
||||
? {
|
||||
[K in keyof T]?: DeepPartial<T[K]>;
|
||||
}
|
||||
: Partial<T>;
|
||||
export {};
|
||||
77
packages/proto-signing/types/codec/cosmos/bank/v1beta1/tx.d.ts
vendored
Normal file
77
packages/proto-signing/types/codec/cosmos/bank/v1beta1/tx.d.ts
vendored
Normal file
@ -0,0 +1,77 @@
|
||||
import { Coin } from "../../../cosmos/base/v1beta1/coin";
|
||||
import { Input, Output } from "../../../cosmos/bank/v1beta1/bank";
|
||||
import _m0 from "protobufjs/minimal";
|
||||
import Long from "long";
|
||||
export declare const protobufPackage = "cosmos.bank.v1beta1";
|
||||
/** MsgSend represents a message to send coins from one account to another. */
|
||||
export interface MsgSend {
|
||||
fromAddress: string;
|
||||
toAddress: string;
|
||||
amount: Coin[];
|
||||
}
|
||||
/** MsgSendResponse defines the Msg/Send response type. */
|
||||
export interface MsgSendResponse {}
|
||||
/** MsgMultiSend represents an arbitrary multi-in, multi-out send message. */
|
||||
export interface MsgMultiSend {
|
||||
inputs: Input[];
|
||||
outputs: Output[];
|
||||
}
|
||||
/** MsgMultiSendResponse defines the Msg/MultiSend response type. */
|
||||
export interface MsgMultiSendResponse {}
|
||||
export declare const MsgSend: {
|
||||
encode(message: MsgSend, writer?: _m0.Writer): _m0.Writer;
|
||||
decode(input: _m0.Reader | Uint8Array, length?: number | undefined): MsgSend;
|
||||
fromJSON(object: any): MsgSend;
|
||||
fromPartial(object: DeepPartial<MsgSend>): MsgSend;
|
||||
toJSON(message: MsgSend): unknown;
|
||||
};
|
||||
export declare const MsgSendResponse: {
|
||||
encode(_: MsgSendResponse, writer?: _m0.Writer): _m0.Writer;
|
||||
decode(input: _m0.Reader | Uint8Array, length?: number | undefined): MsgSendResponse;
|
||||
fromJSON(_: any): MsgSendResponse;
|
||||
fromPartial(_: DeepPartial<MsgSendResponse>): MsgSendResponse;
|
||||
toJSON(_: MsgSendResponse): unknown;
|
||||
};
|
||||
export declare const MsgMultiSend: {
|
||||
encode(message: MsgMultiSend, writer?: _m0.Writer): _m0.Writer;
|
||||
decode(input: _m0.Reader | Uint8Array, length?: number | undefined): MsgMultiSend;
|
||||
fromJSON(object: any): MsgMultiSend;
|
||||
fromPartial(object: DeepPartial<MsgMultiSend>): MsgMultiSend;
|
||||
toJSON(message: MsgMultiSend): unknown;
|
||||
};
|
||||
export declare const MsgMultiSendResponse: {
|
||||
encode(_: MsgMultiSendResponse, writer?: _m0.Writer): _m0.Writer;
|
||||
decode(input: _m0.Reader | Uint8Array, length?: number | undefined): MsgMultiSendResponse;
|
||||
fromJSON(_: any): MsgMultiSendResponse;
|
||||
fromPartial(_: DeepPartial<MsgMultiSendResponse>): MsgMultiSendResponse;
|
||||
toJSON(_: MsgMultiSendResponse): unknown;
|
||||
};
|
||||
/** Msg defines the bank Msg service. */
|
||||
export interface Msg {
|
||||
/** Send defines a method for sending coins from one account to another account. */
|
||||
Send(request: MsgSend): Promise<MsgSendResponse>;
|
||||
/** MultiSend defines a method for sending coins from some accounts to other accounts. */
|
||||
MultiSend(request: MsgMultiSend): Promise<MsgMultiSendResponse>;
|
||||
}
|
||||
export declare class MsgClientImpl implements Msg {
|
||||
private readonly rpc;
|
||||
constructor(rpc: Rpc);
|
||||
Send(request: MsgSend): Promise<MsgSendResponse>;
|
||||
MultiSend(request: MsgMultiSend): Promise<MsgMultiSendResponse>;
|
||||
}
|
||||
interface Rpc {
|
||||
request(service: string, method: string, data: Uint8Array): Promise<Uint8Array>;
|
||||
}
|
||||
declare type Builtin = Date | Function | Uint8Array | string | number | undefined | Long;
|
||||
export declare type DeepPartial<T> = T extends Builtin
|
||||
? T
|
||||
: T extends Array<infer U>
|
||||
? Array<DeepPartial<U>>
|
||||
: T extends ReadonlyArray<infer U>
|
||||
? ReadonlyArray<DeepPartial<U>>
|
||||
: T extends {}
|
||||
? {
|
||||
[K in keyof T]?: DeepPartial<T[K]>;
|
||||
}
|
||||
: Partial<T>;
|
||||
export {};
|
||||
72
packages/proto-signing/types/codec/cosmos/base/v1beta1/coin.d.ts
vendored
Normal file
72
packages/proto-signing/types/codec/cosmos/base/v1beta1/coin.d.ts
vendored
Normal file
@ -0,0 +1,72 @@
|
||||
import Long from "long";
|
||||
import _m0 from "protobufjs/minimal";
|
||||
export declare const protobufPackage = "cosmos.base.v1beta1";
|
||||
/**
|
||||
* Coin defines a token with a denomination and an amount.
|
||||
*
|
||||
* NOTE: The amount field is an Int which implements the custom method
|
||||
* signatures required by gogoproto.
|
||||
*/
|
||||
export interface Coin {
|
||||
denom: string;
|
||||
amount: string;
|
||||
}
|
||||
/**
|
||||
* DecCoin defines a token with a denomination and a decimal amount.
|
||||
*
|
||||
* NOTE: The amount field is an Dec which implements the custom method
|
||||
* signatures required by gogoproto.
|
||||
*/
|
||||
export interface DecCoin {
|
||||
denom: string;
|
||||
amount: string;
|
||||
}
|
||||
/** IntProto defines a Protobuf wrapper around an Int object. */
|
||||
export interface IntProto {
|
||||
int: string;
|
||||
}
|
||||
/** DecProto defines a Protobuf wrapper around a Dec object. */
|
||||
export interface DecProto {
|
||||
dec: string;
|
||||
}
|
||||
export declare const Coin: {
|
||||
encode(message: Coin, writer?: _m0.Writer): _m0.Writer;
|
||||
decode(input: _m0.Reader | Uint8Array, length?: number | undefined): Coin;
|
||||
fromJSON(object: any): Coin;
|
||||
fromPartial(object: DeepPartial<Coin>): Coin;
|
||||
toJSON(message: Coin): unknown;
|
||||
};
|
||||
export declare const DecCoin: {
|
||||
encode(message: DecCoin, writer?: _m0.Writer): _m0.Writer;
|
||||
decode(input: _m0.Reader | Uint8Array, length?: number | undefined): DecCoin;
|
||||
fromJSON(object: any): DecCoin;
|
||||
fromPartial(object: DeepPartial<DecCoin>): DecCoin;
|
||||
toJSON(message: DecCoin): unknown;
|
||||
};
|
||||
export declare const IntProto: {
|
||||
encode(message: IntProto, writer?: _m0.Writer): _m0.Writer;
|
||||
decode(input: _m0.Reader | Uint8Array, length?: number | undefined): IntProto;
|
||||
fromJSON(object: any): IntProto;
|
||||
fromPartial(object: DeepPartial<IntProto>): IntProto;
|
||||
toJSON(message: IntProto): unknown;
|
||||
};
|
||||
export declare const DecProto: {
|
||||
encode(message: DecProto, writer?: _m0.Writer): _m0.Writer;
|
||||
decode(input: _m0.Reader | Uint8Array, length?: number | undefined): DecProto;
|
||||
fromJSON(object: any): DecProto;
|
||||
fromPartial(object: DeepPartial<DecProto>): DecProto;
|
||||
toJSON(message: DecProto): unknown;
|
||||
};
|
||||
declare type Builtin = Date | Function | Uint8Array | string | number | undefined | Long;
|
||||
export declare type DeepPartial<T> = T extends Builtin
|
||||
? T
|
||||
: T extends Array<infer U>
|
||||
? Array<DeepPartial<U>>
|
||||
: T extends ReadonlyArray<infer U>
|
||||
? ReadonlyArray<DeepPartial<U>>
|
||||
: T extends {}
|
||||
? {
|
||||
[K in keyof T]?: DeepPartial<T[K]>;
|
||||
}
|
||||
: Partial<T>;
|
||||
export {};
|
||||
48
packages/proto-signing/types/codec/cosmos/crypto/multisig/v1beta1/multisig.d.ts
vendored
Normal file
48
packages/proto-signing/types/codec/cosmos/crypto/multisig/v1beta1/multisig.d.ts
vendored
Normal file
@ -0,0 +1,48 @@
|
||||
import Long from "long";
|
||||
import _m0 from "protobufjs/minimal";
|
||||
export declare const protobufPackage = "cosmos.crypto.multisig.v1beta1";
|
||||
/**
|
||||
* MultiSignature wraps the signatures from a multisig.LegacyAminoPubKey.
|
||||
* See cosmos.tx.v1betata1.ModeInfo.Multi for how to specify which signers
|
||||
* signed and with which modes.
|
||||
*/
|
||||
export interface MultiSignature {
|
||||
signatures: Uint8Array[];
|
||||
}
|
||||
/**
|
||||
* CompactBitArray is an implementation of a space efficient bit array.
|
||||
* This is used to ensure that the encoded data takes up a minimal amount of
|
||||
* space after proto encoding.
|
||||
* This is not thread safe, and is not intended for concurrent usage.
|
||||
*/
|
||||
export interface CompactBitArray {
|
||||
extraBitsStored: number;
|
||||
elems: Uint8Array;
|
||||
}
|
||||
export declare const MultiSignature: {
|
||||
encode(message: MultiSignature, writer?: _m0.Writer): _m0.Writer;
|
||||
decode(input: _m0.Reader | Uint8Array, length?: number | undefined): MultiSignature;
|
||||
fromJSON(object: any): MultiSignature;
|
||||
fromPartial(object: DeepPartial<MultiSignature>): MultiSignature;
|
||||
toJSON(message: MultiSignature): unknown;
|
||||
};
|
||||
export declare const CompactBitArray: {
|
||||
encode(message: CompactBitArray, writer?: _m0.Writer): _m0.Writer;
|
||||
decode(input: _m0.Reader | Uint8Array, length?: number | undefined): CompactBitArray;
|
||||
fromJSON(object: any): CompactBitArray;
|
||||
fromPartial(object: DeepPartial<CompactBitArray>): CompactBitArray;
|
||||
toJSON(message: CompactBitArray): unknown;
|
||||
};
|
||||
declare type Builtin = Date | Function | Uint8Array | string | number | undefined | Long;
|
||||
export declare type DeepPartial<T> = T extends Builtin
|
||||
? T
|
||||
: T extends Array<infer U>
|
||||
? Array<DeepPartial<U>>
|
||||
: T extends ReadonlyArray<infer U>
|
||||
? ReadonlyArray<DeepPartial<U>>
|
||||
: T extends {}
|
||||
? {
|
||||
[K in keyof T]?: DeepPartial<T[K]>;
|
||||
}
|
||||
: Partial<T>;
|
||||
export {};
|
||||
44
packages/proto-signing/types/codec/cosmos/crypto/secp256k1/keys.d.ts
vendored
Normal file
44
packages/proto-signing/types/codec/cosmos/crypto/secp256k1/keys.d.ts
vendored
Normal file
@ -0,0 +1,44 @@
|
||||
import Long from "long";
|
||||
import _m0 from "protobufjs/minimal";
|
||||
export declare const protobufPackage = "cosmos.crypto.secp256k1";
|
||||
/**
|
||||
* PubKey defines a secp256k1 public key
|
||||
* Key is the compressed form of the pubkey. The first byte depends is a 0x02 byte
|
||||
* if the y-coordinate is the lexicographically largest of the two associated with
|
||||
* the x-coordinate. Otherwise the first byte is a 0x03.
|
||||
* This prefix is followed with the x-coordinate.
|
||||
*/
|
||||
export interface PubKey {
|
||||
key: Uint8Array;
|
||||
}
|
||||
/** PrivKey defines a secp256k1 private key. */
|
||||
export interface PrivKey {
|
||||
key: Uint8Array;
|
||||
}
|
||||
export declare const PubKey: {
|
||||
encode(message: PubKey, writer?: _m0.Writer): _m0.Writer;
|
||||
decode(input: _m0.Reader | Uint8Array, length?: number | undefined): PubKey;
|
||||
fromJSON(object: any): PubKey;
|
||||
fromPartial(object: DeepPartial<PubKey>): PubKey;
|
||||
toJSON(message: PubKey): unknown;
|
||||
};
|
||||
export declare const PrivKey: {
|
||||
encode(message: PrivKey, writer?: _m0.Writer): _m0.Writer;
|
||||
decode(input: _m0.Reader | Uint8Array, length?: number | undefined): PrivKey;
|
||||
fromJSON(object: any): PrivKey;
|
||||
fromPartial(object: DeepPartial<PrivKey>): PrivKey;
|
||||
toJSON(message: PrivKey): unknown;
|
||||
};
|
||||
declare type Builtin = Date | Function | Uint8Array | string | number | undefined | Long;
|
||||
export declare type DeepPartial<T> = T extends Builtin
|
||||
? T
|
||||
: T extends Array<infer U>
|
||||
? Array<DeepPartial<U>>
|
||||
: T extends ReadonlyArray<infer U>
|
||||
? ReadonlyArray<DeepPartial<U>>
|
||||
: T extends {}
|
||||
? {
|
||||
[K in keyof T]?: DeepPartial<T[K]>;
|
||||
}
|
||||
: Partial<T>;
|
||||
export {};
|
||||
123
packages/proto-signing/types/codec/cosmos/tx/signing/v1beta1/signing.d.ts
vendored
Normal file
123
packages/proto-signing/types/codec/cosmos/tx/signing/v1beta1/signing.d.ts
vendored
Normal file
@ -0,0 +1,123 @@
|
||||
import { Any } from "../../../../google/protobuf/any";
|
||||
import Long from "long";
|
||||
import { CompactBitArray } from "../../../../cosmos/crypto/multisig/v1beta1/multisig";
|
||||
import _m0 from "protobufjs/minimal";
|
||||
export declare const protobufPackage = "cosmos.tx.signing.v1beta1";
|
||||
/** SignMode represents a signing mode with its own security guarantees. */
|
||||
export declare enum SignMode {
|
||||
/**
|
||||
* SIGN_MODE_UNSPECIFIED - SIGN_MODE_UNSPECIFIED specifies an unknown signing mode and will be
|
||||
* rejected
|
||||
*/
|
||||
SIGN_MODE_UNSPECIFIED = 0,
|
||||
/**
|
||||
* SIGN_MODE_DIRECT - SIGN_MODE_DIRECT specifies a signing mode which uses SignDoc and is
|
||||
* verified with raw bytes from Tx
|
||||
*/
|
||||
SIGN_MODE_DIRECT = 1,
|
||||
/**
|
||||
* SIGN_MODE_TEXTUAL - SIGN_MODE_TEXTUAL is a future signing mode that will verify some
|
||||
* human-readable textual representation on top of the binary representation
|
||||
* from SIGN_MODE_DIRECT
|
||||
*/
|
||||
SIGN_MODE_TEXTUAL = 2,
|
||||
/**
|
||||
* SIGN_MODE_LEGACY_AMINO_JSON - SIGN_MODE_LEGACY_AMINO_JSON is a backwards compatibility mode which uses
|
||||
* Amino JSON and will be removed in the future
|
||||
*/
|
||||
SIGN_MODE_LEGACY_AMINO_JSON = 127,
|
||||
UNRECOGNIZED = -1,
|
||||
}
|
||||
export declare function signModeFromJSON(object: any): SignMode;
|
||||
export declare function signModeToJSON(object: SignMode): string;
|
||||
/** SignatureDescriptors wraps multiple SignatureDescriptor's. */
|
||||
export interface SignatureDescriptors {
|
||||
/** signatures are the signature descriptors */
|
||||
signatures: SignatureDescriptor[];
|
||||
}
|
||||
/**
|
||||
* SignatureDescriptor is a convenience type which represents the full data for
|
||||
* a signature including the public key of the signer, signing modes and the
|
||||
* signature itself. It is primarily used for coordinating signatures between
|
||||
* clients.
|
||||
*/
|
||||
export interface SignatureDescriptor {
|
||||
/** public_key is the public key of the signer */
|
||||
publicKey?: Any;
|
||||
data?: SignatureDescriptor_Data;
|
||||
/**
|
||||
* sequence is the sequence of the account, which describes the
|
||||
* number of committed transactions signed by a given address. It is used to prevent
|
||||
* replay attacks.
|
||||
*/
|
||||
sequence: Long;
|
||||
}
|
||||
/** Data represents signature data */
|
||||
export interface SignatureDescriptor_Data {
|
||||
/** single represents a single signer */
|
||||
single?: SignatureDescriptor_Data_Single | undefined;
|
||||
/** multi represents a multisig signer */
|
||||
multi?: SignatureDescriptor_Data_Multi | undefined;
|
||||
}
|
||||
/** Single is the signature data for a single signer */
|
||||
export interface SignatureDescriptor_Data_Single {
|
||||
/** mode is the signing mode of the single signer */
|
||||
mode: SignMode;
|
||||
/** signature is the raw signature bytes */
|
||||
signature: Uint8Array;
|
||||
}
|
||||
/** Multi is the signature data for a multisig public key */
|
||||
export interface SignatureDescriptor_Data_Multi {
|
||||
/** bitarray specifies which keys within the multisig are signing */
|
||||
bitarray?: CompactBitArray;
|
||||
/** signatures is the signatures of the multi-signature */
|
||||
signatures: SignatureDescriptor_Data[];
|
||||
}
|
||||
export declare const SignatureDescriptors: {
|
||||
encode(message: SignatureDescriptors, writer?: _m0.Writer): _m0.Writer;
|
||||
decode(input: _m0.Reader | Uint8Array, length?: number | undefined): SignatureDescriptors;
|
||||
fromJSON(object: any): SignatureDescriptors;
|
||||
fromPartial(object: DeepPartial<SignatureDescriptors>): SignatureDescriptors;
|
||||
toJSON(message: SignatureDescriptors): unknown;
|
||||
};
|
||||
export declare const SignatureDescriptor: {
|
||||
encode(message: SignatureDescriptor, writer?: _m0.Writer): _m0.Writer;
|
||||
decode(input: _m0.Reader | Uint8Array, length?: number | undefined): SignatureDescriptor;
|
||||
fromJSON(object: any): SignatureDescriptor;
|
||||
fromPartial(object: DeepPartial<SignatureDescriptor>): SignatureDescriptor;
|
||||
toJSON(message: SignatureDescriptor): unknown;
|
||||
};
|
||||
export declare const SignatureDescriptor_Data: {
|
||||
encode(message: SignatureDescriptor_Data, writer?: _m0.Writer): _m0.Writer;
|
||||
decode(input: _m0.Reader | Uint8Array, length?: number | undefined): SignatureDescriptor_Data;
|
||||
fromJSON(object: any): SignatureDescriptor_Data;
|
||||
fromPartial(object: DeepPartial<SignatureDescriptor_Data>): SignatureDescriptor_Data;
|
||||
toJSON(message: SignatureDescriptor_Data): unknown;
|
||||
};
|
||||
export declare const SignatureDescriptor_Data_Single: {
|
||||
encode(message: SignatureDescriptor_Data_Single, writer?: _m0.Writer): _m0.Writer;
|
||||
decode(input: _m0.Reader | Uint8Array, length?: number | undefined): SignatureDescriptor_Data_Single;
|
||||
fromJSON(object: any): SignatureDescriptor_Data_Single;
|
||||
fromPartial(object: DeepPartial<SignatureDescriptor_Data_Single>): SignatureDescriptor_Data_Single;
|
||||
toJSON(message: SignatureDescriptor_Data_Single): unknown;
|
||||
};
|
||||
export declare const SignatureDescriptor_Data_Multi: {
|
||||
encode(message: SignatureDescriptor_Data_Multi, writer?: _m0.Writer): _m0.Writer;
|
||||
decode(input: _m0.Reader | Uint8Array, length?: number | undefined): SignatureDescriptor_Data_Multi;
|
||||
fromJSON(object: any): SignatureDescriptor_Data_Multi;
|
||||
fromPartial(object: DeepPartial<SignatureDescriptor_Data_Multi>): SignatureDescriptor_Data_Multi;
|
||||
toJSON(message: SignatureDescriptor_Data_Multi): unknown;
|
||||
};
|
||||
declare type Builtin = Date | Function | Uint8Array | string | number | undefined | Long;
|
||||
export declare type DeepPartial<T> = T extends Builtin
|
||||
? T
|
||||
: T extends Array<infer U>
|
||||
? Array<DeepPartial<U>>
|
||||
: T extends ReadonlyArray<infer U>
|
||||
? ReadonlyArray<DeepPartial<U>>
|
||||
: T extends {}
|
||||
? {
|
||||
[K in keyof T]?: DeepPartial<T[K]>;
|
||||
}
|
||||
: Partial<T>;
|
||||
export {};
|
||||
279
packages/proto-signing/types/codec/cosmos/tx/v1beta1/tx.d.ts
vendored
Normal file
279
packages/proto-signing/types/codec/cosmos/tx/v1beta1/tx.d.ts
vendored
Normal file
@ -0,0 +1,279 @@
|
||||
import Long from "long";
|
||||
import { Any } from "../../../google/protobuf/any";
|
||||
import { SignMode } from "../../../cosmos/tx/signing/v1beta1/signing";
|
||||
import { CompactBitArray } from "../../../cosmos/crypto/multisig/v1beta1/multisig";
|
||||
import { Coin } from "../../../cosmos/base/v1beta1/coin";
|
||||
import _m0 from "protobufjs/minimal";
|
||||
export declare const protobufPackage = "cosmos.tx.v1beta1";
|
||||
/** Tx is the standard type used for broadcasting transactions. */
|
||||
export interface Tx {
|
||||
/** body is the processable content of the transaction */
|
||||
body?: TxBody;
|
||||
/**
|
||||
* auth_info is the authorization related content of the transaction,
|
||||
* specifically signers, signer modes and fee
|
||||
*/
|
||||
authInfo?: AuthInfo;
|
||||
/**
|
||||
* signatures is a list of signatures that matches the length and order of
|
||||
* AuthInfo's signer_infos to allow connecting signature meta information like
|
||||
* public key and signing mode by position.
|
||||
*/
|
||||
signatures: Uint8Array[];
|
||||
}
|
||||
/**
|
||||
* TxRaw is a variant of Tx that pins the signer's exact binary representation
|
||||
* of body and auth_info. This is used for signing, broadcasting and
|
||||
* verification. The binary `serialize(tx: TxRaw)` is stored in Tendermint and
|
||||
* the hash `sha256(serialize(tx: TxRaw))` becomes the "txhash", commonly used
|
||||
* as the transaction ID.
|
||||
*/
|
||||
export interface TxRaw {
|
||||
/**
|
||||
* body_bytes is a protobuf serialization of a TxBody that matches the
|
||||
* representation in SignDoc.
|
||||
*/
|
||||
bodyBytes: Uint8Array;
|
||||
/**
|
||||
* auth_info_bytes is a protobuf serialization of an AuthInfo that matches the
|
||||
* representation in SignDoc.
|
||||
*/
|
||||
authInfoBytes: Uint8Array;
|
||||
/**
|
||||
* signatures is a list of signatures that matches the length and order of
|
||||
* AuthInfo's signer_infos to allow connecting signature meta information like
|
||||
* public key and signing mode by position.
|
||||
*/
|
||||
signatures: Uint8Array[];
|
||||
}
|
||||
/** SignDoc is the type used for generating sign bytes for SIGN_MODE_DIRECT. */
|
||||
export interface SignDoc {
|
||||
/**
|
||||
* body_bytes is protobuf serialization of a TxBody that matches the
|
||||
* representation in TxRaw.
|
||||
*/
|
||||
bodyBytes: Uint8Array;
|
||||
/**
|
||||
* auth_info_bytes is a protobuf serialization of an AuthInfo that matches the
|
||||
* representation in TxRaw.
|
||||
*/
|
||||
authInfoBytes: Uint8Array;
|
||||
/**
|
||||
* chain_id is the unique identifier of the chain this transaction targets.
|
||||
* It prevents signed transactions from being used on another chain by an
|
||||
* attacker
|
||||
*/
|
||||
chainId: string;
|
||||
/** account_number is the account number of the account in state */
|
||||
accountNumber: Long;
|
||||
}
|
||||
/** TxBody is the body of a transaction that all signers sign over. */
|
||||
export interface TxBody {
|
||||
/**
|
||||
* messages is a list of messages to be executed. The required signers of
|
||||
* those messages define the number and order of elements in AuthInfo's
|
||||
* signer_infos and Tx's signatures. Each required signer address is added to
|
||||
* the list only the first time it occurs.
|
||||
* By convention, the first required signer (usually from the first message)
|
||||
* is referred to as the primary signer and pays the fee for the whole
|
||||
* transaction.
|
||||
*/
|
||||
messages: Any[];
|
||||
/** memo is any arbitrary memo to be added to the transaction */
|
||||
memo: string;
|
||||
/**
|
||||
* timeout is the block height after which this transaction will not
|
||||
* be processed by the chain
|
||||
*/
|
||||
timeoutHeight: Long;
|
||||
/**
|
||||
* extension_options are arbitrary options that can be added by chains
|
||||
* when the default options are not sufficient. If any of these are present
|
||||
* and can't be handled, the transaction will be rejected
|
||||
*/
|
||||
extensionOptions: Any[];
|
||||
/**
|
||||
* extension_options are arbitrary options that can be added by chains
|
||||
* when the default options are not sufficient. If any of these are present
|
||||
* and can't be handled, they will be ignored
|
||||
*/
|
||||
nonCriticalExtensionOptions: Any[];
|
||||
}
|
||||
/**
|
||||
* AuthInfo describes the fee and signer modes that are used to sign a
|
||||
* transaction.
|
||||
*/
|
||||
export interface AuthInfo {
|
||||
/**
|
||||
* signer_infos defines the signing modes for the required signers. The number
|
||||
* and order of elements must match the required signers from TxBody's
|
||||
* messages. The first element is the primary signer and the one which pays
|
||||
* the fee.
|
||||
*/
|
||||
signerInfos: SignerInfo[];
|
||||
/**
|
||||
* Fee is the fee and gas limit for the transaction. The first signer is the
|
||||
* primary signer and the one which pays the fee. The fee can be calculated
|
||||
* based on the cost of evaluating the body and doing signature verification
|
||||
* of the signers. This can be estimated via simulation.
|
||||
*/
|
||||
fee?: Fee;
|
||||
}
|
||||
/**
|
||||
* SignerInfo describes the public key and signing mode of a single top-level
|
||||
* signer.
|
||||
*/
|
||||
export interface SignerInfo {
|
||||
/**
|
||||
* public_key is the public key of the signer. It is optional for accounts
|
||||
* that already exist in state. If unset, the verifier can use the required \
|
||||
* signer address for this position and lookup the public key.
|
||||
*/
|
||||
publicKey?: Any;
|
||||
/**
|
||||
* mode_info describes the signing mode of the signer and is a nested
|
||||
* structure to support nested multisig pubkey's
|
||||
*/
|
||||
modeInfo?: ModeInfo;
|
||||
/**
|
||||
* sequence is the sequence of the account, which describes the
|
||||
* number of committed transactions signed by a given address. It is used to
|
||||
* prevent replay attacks.
|
||||
*/
|
||||
sequence: Long;
|
||||
}
|
||||
/** ModeInfo describes the signing mode of a single or nested multisig signer. */
|
||||
export interface ModeInfo {
|
||||
/** single represents a single signer */
|
||||
single?: ModeInfo_Single | undefined;
|
||||
/** multi represents a nested multisig signer */
|
||||
multi?: ModeInfo_Multi | undefined;
|
||||
}
|
||||
/**
|
||||
* Single is the mode info for a single signer. It is structured as a message
|
||||
* to allow for additional fields such as locale for SIGN_MODE_TEXTUAL in the
|
||||
* future
|
||||
*/
|
||||
export interface ModeInfo_Single {
|
||||
/** mode is the signing mode of the single signer */
|
||||
mode: SignMode;
|
||||
}
|
||||
/** Multi is the mode info for a multisig public key */
|
||||
export interface ModeInfo_Multi {
|
||||
/** bitarray specifies which keys within the multisig are signing */
|
||||
bitarray?: CompactBitArray;
|
||||
/**
|
||||
* mode_infos is the corresponding modes of the signers of the multisig
|
||||
* which could include nested multisig public keys
|
||||
*/
|
||||
modeInfos: ModeInfo[];
|
||||
}
|
||||
/**
|
||||
* Fee includes the amount of coins paid in fees and the maximum
|
||||
* gas to be used by the transaction. The ratio yields an effective "gasprice",
|
||||
* which must be above some miminum to be accepted into the mempool.
|
||||
*/
|
||||
export interface Fee {
|
||||
/** amount is the amount of coins to be paid as a fee */
|
||||
amount: Coin[];
|
||||
/**
|
||||
* gas_limit is the maximum gas that can be used in transaction processing
|
||||
* before an out of gas error occurs
|
||||
*/
|
||||
gasLimit: Long;
|
||||
/**
|
||||
* if unset, the first signer is responsible for paying the fees. If set, the specified account must pay the fees.
|
||||
* the payer must be a tx signer (and thus have signed this field in AuthInfo).
|
||||
* setting this field does *not* change the ordering of required signers for the transaction.
|
||||
*/
|
||||
payer: string;
|
||||
/**
|
||||
* if set, the fee payer (either the first signer or the value of the payer field) requests that a fee grant be used
|
||||
* to pay fees instead of the fee payer's own balance. If an appropriate fee grant does not exist or the chain does
|
||||
* not support fee grants, this will fail
|
||||
*/
|
||||
granter: string;
|
||||
}
|
||||
export declare const Tx: {
|
||||
encode(message: Tx, writer?: _m0.Writer): _m0.Writer;
|
||||
decode(input: _m0.Reader | Uint8Array, length?: number | undefined): Tx;
|
||||
fromJSON(object: any): Tx;
|
||||
fromPartial(object: DeepPartial<Tx>): Tx;
|
||||
toJSON(message: Tx): unknown;
|
||||
};
|
||||
export declare const TxRaw: {
|
||||
encode(message: TxRaw, writer?: _m0.Writer): _m0.Writer;
|
||||
decode(input: _m0.Reader | Uint8Array, length?: number | undefined): TxRaw;
|
||||
fromJSON(object: any): TxRaw;
|
||||
fromPartial(object: DeepPartial<TxRaw>): TxRaw;
|
||||
toJSON(message: TxRaw): unknown;
|
||||
};
|
||||
export declare const SignDoc: {
|
||||
encode(message: SignDoc, writer?: _m0.Writer): _m0.Writer;
|
||||
decode(input: _m0.Reader | Uint8Array, length?: number | undefined): SignDoc;
|
||||
fromJSON(object: any): SignDoc;
|
||||
fromPartial(object: DeepPartial<SignDoc>): SignDoc;
|
||||
toJSON(message: SignDoc): unknown;
|
||||
};
|
||||
export declare const TxBody: {
|
||||
encode(message: TxBody, writer?: _m0.Writer): _m0.Writer;
|
||||
decode(input: _m0.Reader | Uint8Array, length?: number | undefined): TxBody;
|
||||
fromJSON(object: any): TxBody;
|
||||
fromPartial(object: DeepPartial<TxBody>): TxBody;
|
||||
toJSON(message: TxBody): unknown;
|
||||
};
|
||||
export declare const AuthInfo: {
|
||||
encode(message: AuthInfo, writer?: _m0.Writer): _m0.Writer;
|
||||
decode(input: _m0.Reader | Uint8Array, length?: number | undefined): AuthInfo;
|
||||
fromJSON(object: any): AuthInfo;
|
||||
fromPartial(object: DeepPartial<AuthInfo>): AuthInfo;
|
||||
toJSON(message: AuthInfo): unknown;
|
||||
};
|
||||
export declare const SignerInfo: {
|
||||
encode(message: SignerInfo, writer?: _m0.Writer): _m0.Writer;
|
||||
decode(input: _m0.Reader | Uint8Array, length?: number | undefined): SignerInfo;
|
||||
fromJSON(object: any): SignerInfo;
|
||||
fromPartial(object: DeepPartial<SignerInfo>): SignerInfo;
|
||||
toJSON(message: SignerInfo): unknown;
|
||||
};
|
||||
export declare const ModeInfo: {
|
||||
encode(message: ModeInfo, writer?: _m0.Writer): _m0.Writer;
|
||||
decode(input: _m0.Reader | Uint8Array, length?: number | undefined): ModeInfo;
|
||||
fromJSON(object: any): ModeInfo;
|
||||
fromPartial(object: DeepPartial<ModeInfo>): ModeInfo;
|
||||
toJSON(message: ModeInfo): unknown;
|
||||
};
|
||||
export declare const ModeInfo_Single: {
|
||||
encode(message: ModeInfo_Single, writer?: _m0.Writer): _m0.Writer;
|
||||
decode(input: _m0.Reader | Uint8Array, length?: number | undefined): ModeInfo_Single;
|
||||
fromJSON(object: any): ModeInfo_Single;
|
||||
fromPartial(object: DeepPartial<ModeInfo_Single>): ModeInfo_Single;
|
||||
toJSON(message: ModeInfo_Single): unknown;
|
||||
};
|
||||
export declare const ModeInfo_Multi: {
|
||||
encode(message: ModeInfo_Multi, writer?: _m0.Writer): _m0.Writer;
|
||||
decode(input: _m0.Reader | Uint8Array, length?: number | undefined): ModeInfo_Multi;
|
||||
fromJSON(object: any): ModeInfo_Multi;
|
||||
fromPartial(object: DeepPartial<ModeInfo_Multi>): ModeInfo_Multi;
|
||||
toJSON(message: ModeInfo_Multi): unknown;
|
||||
};
|
||||
export declare const Fee: {
|
||||
encode(message: Fee, writer?: _m0.Writer): _m0.Writer;
|
||||
decode(input: _m0.Reader | Uint8Array, length?: number | undefined): Fee;
|
||||
fromJSON(object: any): Fee;
|
||||
fromPartial(object: DeepPartial<Fee>): Fee;
|
||||
toJSON(message: Fee): unknown;
|
||||
};
|
||||
declare type Builtin = Date | Function | Uint8Array | string | number | undefined | Long;
|
||||
export declare type DeepPartial<T> = T extends Builtin
|
||||
? T
|
||||
: T extends Array<infer U>
|
||||
? Array<DeepPartial<U>>
|
||||
: T extends ReadonlyArray<infer U>
|
||||
? ReadonlyArray<DeepPartial<U>>
|
||||
: T extends {}
|
||||
? {
|
||||
[K in keyof T]?: DeepPartial<T[K]>;
|
||||
}
|
||||
: Partial<T>;
|
||||
export {};
|
||||
1
packages/proto-signing/types/codec/cosmos_proto/cosmos.d.ts
vendored
Normal file
1
packages/proto-signing/types/codec/cosmos_proto/cosmos.d.ts
vendored
Normal file
@ -0,0 +1 @@
|
||||
export declare const protobufPackage = "cosmos_proto";
|
||||
File diff suppressed because it is too large
Load Diff
1
packages/proto-signing/types/codec/gogoproto/gogo.d.ts
vendored
Normal file
1
packages/proto-signing/types/codec/gogoproto/gogo.d.ts
vendored
Normal file
@ -0,0 +1 @@
|
||||
export declare const protobufPackage = "gogoproto";
|
||||
138
packages/proto-signing/types/codec/google/protobuf/any.d.ts
vendored
Normal file
138
packages/proto-signing/types/codec/google/protobuf/any.d.ts
vendored
Normal file
@ -0,0 +1,138 @@
|
||||
import Long from "long";
|
||||
import _m0 from "protobufjs/minimal";
|
||||
export declare const protobufPackage = "google.protobuf";
|
||||
/**
|
||||
* `Any` contains an arbitrary serialized protocol buffer message along with a
|
||||
* URL that describes the type of the serialized message.
|
||||
*
|
||||
* Protobuf library provides support to pack/unpack Any values in the form
|
||||
* of utility functions or additional generated methods of the Any type.
|
||||
*
|
||||
* Example 1: Pack and unpack a message in C++.
|
||||
*
|
||||
* Foo foo = ...;
|
||||
* Any any;
|
||||
* any.PackFrom(foo);
|
||||
* ...
|
||||
* if (any.UnpackTo(&foo)) {
|
||||
* ...
|
||||
* }
|
||||
*
|
||||
* Example 2: Pack and unpack a message in Java.
|
||||
*
|
||||
* Foo foo = ...;
|
||||
* Any any = Any.pack(foo);
|
||||
* ...
|
||||
* if (any.is(Foo.class)) {
|
||||
* foo = any.unpack(Foo.class);
|
||||
* }
|
||||
*
|
||||
* Example 3: Pack and unpack a message in Python.
|
||||
*
|
||||
* foo = Foo(...)
|
||||
* any = Any()
|
||||
* any.Pack(foo)
|
||||
* ...
|
||||
* if any.Is(Foo.DESCRIPTOR):
|
||||
* any.Unpack(foo)
|
||||
* ...
|
||||
*
|
||||
* Example 4: Pack and unpack a message in Go
|
||||
*
|
||||
* foo := &pb.Foo{...}
|
||||
* any, err := ptypes.MarshalAny(foo)
|
||||
* ...
|
||||
* foo := &pb.Foo{}
|
||||
* if err := ptypes.UnmarshalAny(any, foo); err != nil {
|
||||
* ...
|
||||
* }
|
||||
*
|
||||
* The pack methods provided by protobuf library will by default use
|
||||
* 'type.googleapis.com/full.type.name' as the type URL and the unpack
|
||||
* methods only use the fully qualified type name after the last '/'
|
||||
* in the type URL, for example "foo.bar.com/x/y.z" will yield type
|
||||
* name "y.z".
|
||||
*
|
||||
*
|
||||
* JSON
|
||||
* ====
|
||||
* The JSON representation of an `Any` value uses the regular
|
||||
* representation of the deserialized, embedded message, with an
|
||||
* additional field `@type` which contains the type URL. Example:
|
||||
*
|
||||
* package google.profile;
|
||||
* message Person {
|
||||
* string first_name = 1;
|
||||
* string last_name = 2;
|
||||
* }
|
||||
*
|
||||
* {
|
||||
* "@type": "type.googleapis.com/google.profile.Person",
|
||||
* "firstName": <string>,
|
||||
* "lastName": <string>
|
||||
* }
|
||||
*
|
||||
* If the embedded message type is well-known and has a custom JSON
|
||||
* representation, that representation will be embedded adding a field
|
||||
* `value` which holds the custom JSON in addition to the `@type`
|
||||
* field. Example (for message [google.protobuf.Duration][]):
|
||||
*
|
||||
* {
|
||||
* "@type": "type.googleapis.com/google.protobuf.Duration",
|
||||
* "value": "1.212s"
|
||||
* }
|
||||
*/
|
||||
export interface Any {
|
||||
/**
|
||||
* A URL/resource name that uniquely identifies the type of the serialized
|
||||
* protocol buffer message. This string must contain at least
|
||||
* one "/" character. The last segment of the URL's path must represent
|
||||
* the fully qualified name of the type (as in
|
||||
* `path/google.protobuf.Duration`). The name should be in a canonical form
|
||||
* (e.g., leading "." is not accepted).
|
||||
*
|
||||
* In practice, teams usually precompile into the binary all types that they
|
||||
* expect it to use in the context of Any. However, for URLs which use the
|
||||
* scheme `http`, `https`, or no scheme, one can optionally set up a type
|
||||
* server that maps type URLs to message definitions as follows:
|
||||
*
|
||||
* * If no scheme is provided, `https` is assumed.
|
||||
* * An HTTP GET on the URL must yield a [google.protobuf.Type][]
|
||||
* value in binary format, or produce an error.
|
||||
* * Applications are allowed to cache lookup results based on the
|
||||
* URL, or have them precompiled into a binary to avoid any
|
||||
* lookup. Therefore, binary compatibility needs to be preserved
|
||||
* on changes to types. (Use versioned type names to manage
|
||||
* breaking changes.)
|
||||
*
|
||||
* Note: this functionality is not currently available in the official
|
||||
* protobuf release, and it is not used for type URLs beginning with
|
||||
* type.googleapis.com.
|
||||
*
|
||||
* Schemes other than `http`, `https` (or the empty scheme) might be
|
||||
* used with implementation specific semantics.
|
||||
*/
|
||||
typeUrl: string;
|
||||
/** Must be a valid serialized protocol buffer of the above specified type. */
|
||||
value: Uint8Array;
|
||||
}
|
||||
export declare const Any: {
|
||||
encode(message: Any, writer?: _m0.Writer): _m0.Writer;
|
||||
decode(input: _m0.Reader | Uint8Array, length?: number | undefined): Any;
|
||||
fromJSON(object: any): Any;
|
||||
fromPartial(object: DeepPartial<Any>): Any;
|
||||
toJSON(message: Any): unknown;
|
||||
};
|
||||
declare type Builtin = Date | Function | Uint8Array | string | number | undefined | Long;
|
||||
export declare type DeepPartial<T> = T extends Builtin
|
||||
? T
|
||||
: T extends Array<infer U>
|
||||
? Array<DeepPartial<U>>
|
||||
: T extends ReadonlyArray<infer U>
|
||||
? ReadonlyArray<DeepPartial<U>>
|
||||
: T extends {}
|
||||
? {
|
||||
[K in keyof T]?: DeepPartial<T[K]>;
|
||||
}
|
||||
: Partial<T>;
|
||||
export {};
|
||||
1033
packages/proto-signing/types/codec/google/protobuf/descriptor.d.ts
vendored
Normal file
1033
packages/proto-signing/types/codec/google/protobuf/descriptor.d.ts
vendored
Normal file
File diff suppressed because it is too large
Load Diff
@ -1 +0,0 @@
|
||||
export * from "./generated/codecimpl";
|
||||
28
packages/proto-signing/types/codec/tendermint/crypto/keys.d.ts
vendored
Normal file
28
packages/proto-signing/types/codec/tendermint/crypto/keys.d.ts
vendored
Normal file
@ -0,0 +1,28 @@
|
||||
import Long from "long";
|
||||
import _m0 from "protobufjs/minimal";
|
||||
export declare const protobufPackage = "tendermint.crypto";
|
||||
/** PublicKey defines the keys available for use with Tendermint Validators */
|
||||
export interface PublicKey {
|
||||
ed25519: Uint8Array | undefined;
|
||||
secp256k1: Uint8Array | undefined;
|
||||
}
|
||||
export declare const PublicKey: {
|
||||
encode(message: PublicKey, writer?: _m0.Writer): _m0.Writer;
|
||||
decode(input: _m0.Reader | Uint8Array, length?: number | undefined): PublicKey;
|
||||
fromJSON(object: any): PublicKey;
|
||||
fromPartial(object: DeepPartial<PublicKey>): PublicKey;
|
||||
toJSON(message: PublicKey): unknown;
|
||||
};
|
||||
declare type Builtin = Date | Function | Uint8Array | string | number | undefined | Long;
|
||||
export declare type DeepPartial<T> = T extends Builtin
|
||||
? T
|
||||
: T extends Array<infer U>
|
||||
? Array<DeepPartial<U>>
|
||||
: T extends ReadonlyArray<infer U>
|
||||
? ReadonlyArray<DeepPartial<U>>
|
||||
: T extends {}
|
||||
? {
|
||||
[K in keyof T]?: DeepPartial<T[K]>;
|
||||
}
|
||||
: Partial<T>;
|
||||
export {};
|
||||
21
packages/proto-signing/types/decorator.d.ts
vendored
21
packages/proto-signing/types/decorator.d.ts
vendored
@ -1,21 +0,0 @@
|
||||
import { Constructor, Message, TypeDecorator } from "protobufjs";
|
||||
import { Registry } from "./registry";
|
||||
/**
|
||||
* A class decorator to register this type under the given type URL
|
||||
* in the given registry.
|
||||
*/
|
||||
export declare function registered(registry: Registry, typeUrl: string): TypeDecorator<any>;
|
||||
/**
|
||||
* Like PropertyDecorator from lib.es5.d.ts but without symbol support in propertyKey.
|
||||
*/
|
||||
export declare type FieldDecorator = (target: any, propertyKey: string) => void;
|
||||
export declare const cosmosField: {
|
||||
boolean: (id: number) => FieldDecorator;
|
||||
string: (id: number) => FieldDecorator;
|
||||
bytes: (id: number) => FieldDecorator;
|
||||
int64: (id: number) => FieldDecorator;
|
||||
uint64: (id: number) => FieldDecorator;
|
||||
message: (id: number, ctor: Constructor<Message>) => FieldDecorator;
|
||||
repeatedString: (id: number) => FieldDecorator;
|
||||
repeatedMessage: (id: number, ctor: Constructor<Message>) => FieldDecorator;
|
||||
};
|
||||
@ -1,6 +1,6 @@
|
||||
import { EnglishMnemonic, HdPath } from "@cosmjs/crypto";
|
||||
import { AccountData } from "@cosmjs/launchpad";
|
||||
import { cosmos } from "./codec";
|
||||
import { SignDoc } from "./codec/cosmos/tx/v1beta1/tx";
|
||||
import { DirectSignResponse, OfflineDirectSigner } from "./signer";
|
||||
/** A wallet for protobuf based signing using SIGN_MODE_DIRECT */
|
||||
export declare class DirectSecp256k1HdWallet implements OfflineDirectSigner {
|
||||
@ -41,5 +41,5 @@ export declare class DirectSecp256k1HdWallet implements OfflineDirectSigner {
|
||||
get mnemonic(): string;
|
||||
private get address();
|
||||
getAccounts(): Promise<readonly AccountData[]>;
|
||||
signDirect(address: string, signDoc: cosmos.tx.v1beta1.ISignDoc): Promise<DirectSignResponse>;
|
||||
signDirect(address: string, signDoc: SignDoc): Promise<DirectSignResponse>;
|
||||
}
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
import { AccountData } from "@cosmjs/launchpad";
|
||||
import { cosmos } from "./codec";
|
||||
import { SignDoc } from "./codec/cosmos/tx/v1beta1/tx";
|
||||
import { DirectSignResponse, OfflineDirectSigner } from "./signer";
|
||||
/**
|
||||
* A wallet that holds a single secp256k1 keypair.
|
||||
@ -20,5 +20,5 @@ export declare class DirectSecp256k1Wallet implements OfflineDirectSigner {
|
||||
private constructor();
|
||||
private get address();
|
||||
getAccounts(): Promise<readonly AccountData[]>;
|
||||
signDirect(address: string, signDoc: cosmos.tx.v1beta1.ISignDoc): Promise<DirectSignResponse>;
|
||||
signDirect(address: string, signDoc: SignDoc): Promise<DirectSignResponse>;
|
||||
}
|
||||
|
||||
2
packages/proto-signing/types/index.d.ts
vendored
2
packages/proto-signing/types/index.d.ts
vendored
@ -1,5 +1,3 @@
|
||||
export { Coin } from "./msgs";
|
||||
export { cosmosField, registered } from "./decorator";
|
||||
export { EncodeObject, GeneratedType, Registry } from "./registry";
|
||||
export { DirectSecp256k1HdWallet } from "./directsecp256k1hdwallet";
|
||||
export { DirectSecp256k1Wallet } from "./directsecp256k1wallet";
|
||||
|
||||
12
packages/proto-signing/types/msgs.d.ts
vendored
12
packages/proto-signing/types/msgs.d.ts
vendored
@ -1,12 +0,0 @@
|
||||
import { Message } from "protobufjs";
|
||||
import { Registry } from "./registry";
|
||||
export declare const defaultRegistry: Registry;
|
||||
export declare class Coin extends Message {
|
||||
readonly denom?: string;
|
||||
readonly amount?: string;
|
||||
}
|
||||
export declare class MsgSend extends Message {
|
||||
readonly from_address?: string;
|
||||
readonly to_address?: string;
|
||||
readonly amount?: readonly Coin[];
|
||||
}
|
||||
8
packages/proto-signing/types/pubkey.d.ts
vendored
8
packages/proto-signing/types/pubkey.d.ts
vendored
@ -1,4 +1,4 @@
|
||||
import { PubKey } from "@cosmjs/launchpad";
|
||||
import { google } from "./codec";
|
||||
export declare function encodePubkey(pubkey: PubKey): google.protobuf.IAny;
|
||||
export declare function decodePubkey(pubkey?: google.protobuf.IAny | null): PubKey | null;
|
||||
import { PubKey as LaunchpadPubKey } from "@cosmjs/launchpad";
|
||||
import { Any } from "./codec/google/protobuf/any";
|
||||
export declare function encodePubkey(pubkey: LaunchpadPubKey): Any;
|
||||
export declare function decodePubkey(pubkey?: Any | null): LaunchpadPubKey | null;
|
||||
|
||||
21
packages/proto-signing/types/registry.d.ts
vendored
21
packages/proto-signing/types/registry.d.ts
vendored
@ -1,8 +1,8 @@
|
||||
import Long from "long";
|
||||
import protobuf from "protobufjs";
|
||||
import { cosmos, google } from "./codec";
|
||||
import { TxBody } from "./codec/cosmos/tx/v1beta1/tx";
|
||||
import { Any } from "./codec/google/protobuf/any";
|
||||
export interface GeneratedType {
|
||||
readonly create: (properties?: { [k: string]: any }) => any;
|
||||
readonly encode: (
|
||||
message:
|
||||
| any
|
||||
@ -11,7 +11,16 @@ export interface GeneratedType {
|
||||
},
|
||||
writer?: protobuf.Writer,
|
||||
) => protobuf.Writer;
|
||||
readonly decode: (reader: protobuf.Reader | Uint8Array, length?: number) => any;
|
||||
readonly decode: (input: Uint8Array | protobuf.Reader, length?: number) => any;
|
||||
readonly fromJSON: (object: { [k: string]: any }) => any;
|
||||
readonly fromPartial: (object: { [k: string]: any }) => any;
|
||||
readonly toJSON: (
|
||||
message:
|
||||
| any
|
||||
| {
|
||||
[k: string]: any;
|
||||
},
|
||||
) => unknown;
|
||||
}
|
||||
export interface EncodeObject {
|
||||
readonly typeUrl: string;
|
||||
@ -25,8 +34,8 @@ export interface TxBodyValue {
|
||||
readonly messages: readonly EncodeObject[];
|
||||
readonly memo?: string;
|
||||
readonly timeoutHeight?: Long;
|
||||
readonly extensionOptions?: google.protobuf.IAny[];
|
||||
readonly nonCriticalExtensionOptions?: google.protobuf.IAny[];
|
||||
readonly extensionOptions?: Any[];
|
||||
readonly nonCriticalExtensionOptions?: Any[];
|
||||
}
|
||||
export declare class Registry {
|
||||
private readonly types;
|
||||
@ -37,5 +46,5 @@ export declare class Registry {
|
||||
encode({ typeUrl, value }: EncodeObject): Uint8Array;
|
||||
encodeTxBody(txBodyFields: TxBodyValue): Uint8Array;
|
||||
decode({ typeUrl, value }: DecodeObject): any;
|
||||
decodeTxBody(txBody: Uint8Array): cosmos.tx.v1beta1.TxBody;
|
||||
decodeTxBody(txBody: Uint8Array): TxBody;
|
||||
}
|
||||
|
||||
9
packages/proto-signing/types/signer.d.ts
vendored
9
packages/proto-signing/types/signer.d.ts
vendored
@ -1,19 +1,16 @@
|
||||
import { AccountData, OfflineSigner as OfflineAminoSigner, StdSignature } from "@cosmjs/launchpad";
|
||||
import { cosmos } from "./codec";
|
||||
import { SignDoc } from "./codec/cosmos/tx/v1beta1/tx";
|
||||
export interface DirectSignResponse {
|
||||
/**
|
||||
* The sign doc that was signed.
|
||||
* This may be different from the input signDoc when the signer modifies it as part of the signing process.
|
||||
*/
|
||||
readonly signed: cosmos.tx.v1beta1.ISignDoc;
|
||||
readonly signed: SignDoc;
|
||||
readonly signature: StdSignature;
|
||||
}
|
||||
export interface OfflineDirectSigner {
|
||||
readonly getAccounts: () => Promise<readonly AccountData[]>;
|
||||
readonly signDirect: (
|
||||
signerAddress: string,
|
||||
signDoc: cosmos.tx.v1beta1.ISignDoc,
|
||||
) => Promise<DirectSignResponse>;
|
||||
readonly signDirect: (signerAddress: string, signDoc: SignDoc) => Promise<DirectSignResponse>;
|
||||
}
|
||||
export declare type OfflineSigner = OfflineAminoSigner | OfflineDirectSigner;
|
||||
export declare function isOfflineDirectSigner(signer: OfflineSigner): signer is OfflineDirectSigner;
|
||||
|
||||
15
packages/proto-signing/types/signing.d.ts
vendored
15
packages/proto-signing/types/signing.d.ts
vendored
@ -1,23 +1,26 @@
|
||||
import { cosmos, google } from "./codec";
|
||||
import { Coin } from "./codec/cosmos/base/v1beta1/coin";
|
||||
import { SignMode } from "./codec/cosmos/tx/signing/v1beta1/signing";
|
||||
import { SignDoc } from "./codec/cosmos/tx/v1beta1/tx";
|
||||
import { Any } from "./codec/google/protobuf/any";
|
||||
/**
|
||||
* Creates and serializes an AuthInfo document using SIGN_MODE_DIRECT.
|
||||
*/
|
||||
export declare function makeAuthInfoBytes(
|
||||
pubkeys: readonly google.protobuf.IAny[],
|
||||
feeAmount: readonly cosmos.base.v1beta1.Coin[],
|
||||
pubkeys: readonly Any[],
|
||||
feeAmount: readonly Coin[],
|
||||
gasLimit: number,
|
||||
sequence: number,
|
||||
signMode?: cosmos.tx.signing.v1beta1.SignMode,
|
||||
signMode?: SignMode,
|
||||
): Uint8Array;
|
||||
export declare function makeSignDoc(
|
||||
bodyBytes: Uint8Array,
|
||||
authInfoBytes: Uint8Array,
|
||||
chainId: string,
|
||||
accountNumber: number,
|
||||
): cosmos.tx.v1beta1.ISignDoc;
|
||||
): SignDoc;
|
||||
export declare function makeSignBytes({
|
||||
accountNumber,
|
||||
authInfoBytes,
|
||||
bodyBytes,
|
||||
chainId,
|
||||
}: cosmos.tx.v1beta1.ISignDoc): Uint8Array;
|
||||
}: SignDoc): Uint8Array;
|
||||
|
||||
2
packages/stargate/.gitignore
vendored
2
packages/stargate/.gitignore
vendored
@ -1,4 +1,4 @@
|
||||
build/
|
||||
build/**/*
|
||||
dist/
|
||||
docs/
|
||||
|
||||
|
||||
@ -7,7 +7,7 @@
|
||||
],
|
||||
"license": "Apache-2.0",
|
||||
"main": "build/index.js",
|
||||
"types": "types/index.d.ts",
|
||||
"types": "build/index.d.ts",
|
||||
"files": [
|
||||
"build/",
|
||||
"types/",
|
||||
@ -28,11 +28,11 @@
|
||||
"format-text": "prettier --write --prose-wrap always --print-width 80 \"./*.md\"",
|
||||
"lint": "eslint --max-warnings 0 \"**/*.{js,ts}\"",
|
||||
"lint-fix": "eslint --max-warnings 0 \"**/*.{js,ts}\" --fix",
|
||||
"move-types": "shx rm -rf ./types/* && shx mv build/types/* ./types && shx rm -rf ./types/testdata ./types/*.spec.d.ts ./types/*/*.spec.d.ts",
|
||||
"format-types": "prettier --write --loglevel warn \"./types/**/*.d.ts\"",
|
||||
"remove-test-types": "shx rm -rf build/*.spec.d.ts build/*/*.spec.d.ts",
|
||||
"format-types": "prettier --write --loglevel warn \"./build/**/*.d.ts\"",
|
||||
"prebuild": "shx rm -rf ./build",
|
||||
"build": "tsc && shx mkdir -p build/codec/generated && shx cp ./src/codec/generated/*.js ./build/codec/generated",
|
||||
"postbuild": "shx mkdir -p ./build/types/codec/generated && shx cp ./src/codec/generated/*.d.ts ./build/types/codec/generated && yarn move-types && yarn format-types",
|
||||
"build": "tsc",
|
||||
"postbuild": "yarn remove-test-types && yarn format-types",
|
||||
"build-or-skip": "[ -n \"$SKIP_BUILD\" ] || yarn build",
|
||||
"test-node": "node jasmine-testrunner.js",
|
||||
"test-firefox": "yarn pack-web && karma start --single-run --browsers Firefox",
|
||||
@ -42,9 +42,8 @@
|
||||
"pack-web": "yarn build-or-skip && webpack --mode development --config webpack.web.config.js",
|
||||
"preget-proto": "shx rm -rf proto",
|
||||
"get-proto": "REF=v0.40.0 ./scripts/get-proto.sh",
|
||||
"predefine-proto": "./scripts/predefine-proto.sh",
|
||||
"define-proto": "./scripts/define-proto.sh",
|
||||
"postdefine-proto": "prettier --write \"src/codec/generated/codecimpl.*\""
|
||||
"postdefine-proto": "prettier --write \"src/codec/**/*.ts\""
|
||||
},
|
||||
"dependencies": {
|
||||
"@confio/ics23": "^0.6.3",
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user