mirror of
https://github.com/cosmos/cosmjs.git
synced 2025-03-10 21:49:15 +00:00
Merge pull request #351 from CosmWasm/212-sign-mode-direct-parse-and-generate
SIGN_MODE_DIRECT
This commit is contained in:
commit
4a14129ab5
@ -48,6 +48,7 @@
|
||||
},
|
||||
"devDependencies": {
|
||||
"@cosmjs/encoding": "^0.22.1",
|
||||
"@cosmjs/launchpad": "^0.22.1",
|
||||
"@cosmjs/utils": "^0.22.1"
|
||||
}
|
||||
}
|
||||
|
222
packages/proto-signing/src/adr27.spec.ts
Normal file
222
packages/proto-signing/src/adr27.spec.ts
Normal file
@ -0,0 +1,222 @@
|
||||
import { fromHex } from "@cosmjs/encoding";
|
||||
import { parse } from "protobufjs";
|
||||
|
||||
import { omitDefault, omitDefaults } from "./adr27";
|
||||
|
||||
describe("adr27", () => {
|
||||
describe("omitDefault", () => {
|
||||
it("works for strings", () => {
|
||||
expect(omitDefault("abc")).toEqual("abc");
|
||||
expect(omitDefault("")).toEqual(null);
|
||||
});
|
||||
|
||||
it("works for bytes", () => {
|
||||
expect(omitDefault(fromHex("ab"))).toEqual(fromHex("ab"));
|
||||
expect(omitDefault(fromHex(""))).toEqual(null);
|
||||
});
|
||||
|
||||
it("works for integers", () => {
|
||||
expect(omitDefault(123)).toEqual(123);
|
||||
expect(omitDefault(0)).toEqual(null);
|
||||
});
|
||||
|
||||
it("works for floats", () => {
|
||||
expect(omitDefault(1.234)).toEqual(1.234);
|
||||
expect(omitDefault(0.0)).toEqual(null);
|
||||
});
|
||||
|
||||
it("works for booleans", () => {
|
||||
expect(omitDefault(true)).toEqual(true);
|
||||
expect(omitDefault(false)).toEqual(null);
|
||||
});
|
||||
|
||||
it("works for repeated", () => {
|
||||
expect(omitDefault(["a", "b", "c"])).toEqual(["a", "b", "c"]);
|
||||
expect(omitDefault([])).toEqual(null);
|
||||
});
|
||||
|
||||
it("works for enums", () => {
|
||||
const proto = `
|
||||
package blog;
|
||||
syntax = "proto3";
|
||||
|
||||
enum Review {
|
||||
UNSPECIFIED = 0;
|
||||
ACCEPTED = 1;
|
||||
REJECTED = 2;
|
||||
};
|
||||
`;
|
||||
// eslint-disable-next-line @typescript-eslint/naming-convention
|
||||
const Review = parse(proto).root.lookupEnum("blog.Review");
|
||||
expect(omitDefault(Review.values["ACCEPTED"])).toEqual(Review.values["ACCEPTED"]);
|
||||
expect(omitDefault(Review.values["UNSPECIFIED"])).toEqual(null);
|
||||
});
|
||||
|
||||
it("works for unset", () => {
|
||||
// null and undefined both represent unset in protobuf.js serialization
|
||||
expect(omitDefault(undefined)).toEqual(null);
|
||||
expect(omitDefault(null)).toEqual(null);
|
||||
});
|
||||
});
|
||||
|
||||
describe("omitDefaults", () => {
|
||||
it("works for scalars", () => {
|
||||
expect(omitDefaults("abc")).toEqual("abc");
|
||||
expect(omitDefaults("")).toEqual(null);
|
||||
|
||||
expect(omitDefaults(fromHex("ab"))).toEqual(fromHex("ab"));
|
||||
expect(omitDefaults(fromHex(""))).toEqual(null);
|
||||
|
||||
expect(omitDefaults(123)).toEqual(123);
|
||||
expect(omitDefaults(0)).toEqual(null);
|
||||
|
||||
expect(omitDefaults(1.234)).toEqual(1.234);
|
||||
expect(omitDefaults(0.0)).toEqual(null);
|
||||
|
||||
expect(omitDefaults(true)).toEqual(true);
|
||||
expect(omitDefaults(false)).toEqual(null);
|
||||
});
|
||||
|
||||
it("works for repeated", () => {
|
||||
expect(omitDefaults(["a", "b", "c"])).toEqual(["a", "b", "c"]);
|
||||
expect(omitDefaults([])).toEqual(null);
|
||||
});
|
||||
|
||||
it("works for enums", () => {
|
||||
const proto = `
|
||||
package blog;
|
||||
syntax = "proto3";
|
||||
|
||||
enum Review {
|
||||
UNSPECIFIED = 0;
|
||||
ACCEPTED = 1;
|
||||
REJECTED = 2;
|
||||
};
|
||||
`;
|
||||
// eslint-disable-next-line @typescript-eslint/naming-convention
|
||||
const Review = parse(proto).root.lookupEnum("blog.Review");
|
||||
expect(omitDefaults(Review.values["ACCEPTED"])).toEqual(Review.values["ACCEPTED"]);
|
||||
expect(omitDefaults(Review.values["UNSPECIFIED"])).toEqual(null);
|
||||
});
|
||||
|
||||
it("works for unset", () => {
|
||||
// null and undefined both represent unset in protobuf.js serialization
|
||||
expect(omitDefaults(undefined)).toEqual(null);
|
||||
expect(omitDefaults(null)).toEqual(null);
|
||||
});
|
||||
|
||||
it("works for objects", () => {
|
||||
// empty
|
||||
expect(omitDefaults({})).toEqual({});
|
||||
|
||||
// simple
|
||||
expect(
|
||||
omitDefaults({
|
||||
a: "foo",
|
||||
b: "",
|
||||
c: 100,
|
||||
d: 0,
|
||||
}),
|
||||
).toEqual({
|
||||
a: "foo",
|
||||
b: null,
|
||||
c: 100,
|
||||
d: null,
|
||||
});
|
||||
|
||||
// nested
|
||||
|
||||
expect(
|
||||
omitDefaults({
|
||||
a: {
|
||||
x: "foo",
|
||||
y: "",
|
||||
},
|
||||
b: {
|
||||
x: {
|
||||
o: 1.2,
|
||||
p: false,
|
||||
q: 0,
|
||||
},
|
||||
},
|
||||
}),
|
||||
).toEqual({
|
||||
a: {
|
||||
x: "foo",
|
||||
y: null,
|
||||
},
|
||||
b: {
|
||||
x: {
|
||||
o: 1.2,
|
||||
p: null,
|
||||
q: null,
|
||||
},
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
it("can be used to reproduce ADR 027 test vector", () => {
|
||||
const proto = `
|
||||
// Article.proto
|
||||
|
||||
package blog;
|
||||
syntax = "proto3";
|
||||
|
||||
enum Type {
|
||||
UNSPECIFIED = 0;
|
||||
IMAGES = 1;
|
||||
NEWS = 2;
|
||||
};
|
||||
|
||||
enum Review {
|
||||
UNSPECIFIED = 0;
|
||||
ACCEPTED = 1;
|
||||
REJECTED = 2;
|
||||
};
|
||||
|
||||
message Article {
|
||||
string title = 1;
|
||||
string description = 2;
|
||||
uint64 created = 3;
|
||||
uint64 updated = 4;
|
||||
bool public = 5;
|
||||
bool promoted = 6;
|
||||
Type type = 7;
|
||||
Review review = 8;
|
||||
repeated string comments = 9;
|
||||
repeated string backlinks = 10;
|
||||
};
|
||||
`;
|
||||
const root = parse(proto).root;
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/naming-convention
|
||||
const Article = root.lookupType("blog.Article");
|
||||
// eslint-disable-next-line @typescript-eslint/naming-convention
|
||||
const Type = root.lookupEnum("blog.Type");
|
||||
// eslint-disable-next-line @typescript-eslint/naming-convention
|
||||
const Review = root.lookupEnum("blog.Review");
|
||||
|
||||
const expected = fromHex(
|
||||
"0a1654686520776f726c64206e65656473206368616e676518e8bebec8bc2e280138024a084e696365206f6e654a095468616e6b20796f75",
|
||||
);
|
||||
|
||||
const serialization = Uint8Array.from(
|
||||
Article.encode(
|
||||
omitDefaults({
|
||||
title: "The world needs change",
|
||||
description: "",
|
||||
created: 1596806111080,
|
||||
updated: 0,
|
||||
public: true,
|
||||
promoted: false,
|
||||
type: Type.values["NEWS"],
|
||||
review: Review.values["UNSPECIFIED"],
|
||||
comments: ["Nice one", "Thank you"],
|
||||
backlinks: [],
|
||||
}),
|
||||
).finish(),
|
||||
);
|
||||
expect(serialization).toEqual(expected);
|
||||
});
|
||||
});
|
||||
});
|
54
packages/proto-signing/src/adr27.ts
Normal file
54
packages/proto-signing/src/adr27.ts
Normal file
@ -0,0 +1,54 @@
|
||||
import { isNonNullObject, isUint8Array } from "@cosmjs/utils";
|
||||
|
||||
/**
|
||||
* Converts default values to null in order to tell protobuf.js
|
||||
* to not serialize them.
|
||||
*
|
||||
* @see https://github.com/cosmos/cosmos-sdk/pull/6979
|
||||
*/
|
||||
export function omitDefault<T>(input: T): T | null {
|
||||
if (input === undefined || input === null) return null;
|
||||
|
||||
if (typeof input === "number" || typeof input === "boolean" || typeof input === "string") {
|
||||
return input || null;
|
||||
}
|
||||
|
||||
if (Array.isArray(input) || isUint8Array(input)) {
|
||||
return input.length ? input : null;
|
||||
}
|
||||
|
||||
throw new Error("Input type not supported");
|
||||
}
|
||||
|
||||
/**
|
||||
* Walks through a potentially nested object and calls omitDefault on each element.
|
||||
*/
|
||||
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
|
||||
export function omitDefaults(input: any): any {
|
||||
// Unset
|
||||
if (input === undefined || input === null) return null;
|
||||
|
||||
// Protobuf element
|
||||
if (
|
||||
typeof input === "number" ||
|
||||
typeof input === "boolean" ||
|
||||
typeof input === "string" ||
|
||||
Array.isArray(input) ||
|
||||
isUint8Array(input)
|
||||
) {
|
||||
return omitDefault(input);
|
||||
}
|
||||
|
||||
// Object
|
||||
if (isNonNullObject(input)) {
|
||||
return Object.entries(input).reduce(
|
||||
(accumulator, [key, value]) => ({
|
||||
...accumulator,
|
||||
[key]: omitDefaults(value),
|
||||
}),
|
||||
{},
|
||||
);
|
||||
}
|
||||
|
||||
throw new Error(`Input type not supported: ${typeof input}`);
|
||||
}
|
664
packages/proto-signing/src/generated/codecimpl.d.ts
vendored
664
packages/proto-signing/src/generated/codecimpl.d.ts
vendored
@ -473,6 +473,268 @@ export namespace cosmos {
|
||||
public static decode(r: $protobuf.Reader | Uint8Array, l?: number): cosmos.TxData;
|
||||
}
|
||||
|
||||
/** Properties of a TxResponse. */
|
||||
interface ITxResponse {
|
||||
/** TxResponse height */
|
||||
height?: number | Long | null;
|
||||
|
||||
/** TxResponse txhash */
|
||||
txhash?: string | null;
|
||||
|
||||
/** TxResponse codespace */
|
||||
codespace?: string | null;
|
||||
|
||||
/** TxResponse code */
|
||||
code?: number | null;
|
||||
|
||||
/** TxResponse data */
|
||||
data?: string | null;
|
||||
|
||||
/** TxResponse rawLog */
|
||||
rawLog?: string | null;
|
||||
|
||||
/** TxResponse logs */
|
||||
logs?: cosmos.IABCIMessageLog[] | null;
|
||||
|
||||
/** TxResponse info */
|
||||
info?: string | null;
|
||||
|
||||
/** TxResponse gasWanted */
|
||||
gasWanted?: number | Long | null;
|
||||
|
||||
/** TxResponse gasUsed */
|
||||
gasUsed?: number | Long | null;
|
||||
|
||||
/** TxResponse tx */
|
||||
tx?: google.protobuf.IAny | null;
|
||||
|
||||
/** TxResponse timestamp */
|
||||
timestamp?: string | null;
|
||||
}
|
||||
|
||||
/** Represents a TxResponse. */
|
||||
class TxResponse implements ITxResponse {
|
||||
/**
|
||||
* Constructs a new TxResponse.
|
||||
* @param [p] Properties to set
|
||||
*/
|
||||
constructor(p?: cosmos.ITxResponse);
|
||||
|
||||
/** TxResponse height. */
|
||||
public height: number | Long;
|
||||
|
||||
/** TxResponse txhash. */
|
||||
public txhash: string;
|
||||
|
||||
/** TxResponse codespace. */
|
||||
public codespace: string;
|
||||
|
||||
/** TxResponse code. */
|
||||
public code: number;
|
||||
|
||||
/** TxResponse data. */
|
||||
public data: string;
|
||||
|
||||
/** TxResponse rawLog. */
|
||||
public rawLog: string;
|
||||
|
||||
/** TxResponse logs. */
|
||||
public logs: cosmos.IABCIMessageLog[];
|
||||
|
||||
/** TxResponse info. */
|
||||
public info: string;
|
||||
|
||||
/** TxResponse gasWanted. */
|
||||
public gasWanted: number | Long;
|
||||
|
||||
/** TxResponse gasUsed. */
|
||||
public gasUsed: number | Long;
|
||||
|
||||
/** TxResponse tx. */
|
||||
public tx?: google.protobuf.IAny | null;
|
||||
|
||||
/** TxResponse timestamp. */
|
||||
public timestamp: string;
|
||||
|
||||
/**
|
||||
* Creates a new TxResponse instance using the specified properties.
|
||||
* @param [properties] Properties to set
|
||||
* @returns TxResponse instance
|
||||
*/
|
||||
public static create(properties?: cosmos.ITxResponse): cosmos.TxResponse;
|
||||
|
||||
/**
|
||||
* Encodes the specified TxResponse message. Does not implicitly {@link cosmos.TxResponse.verify|verify} messages.
|
||||
* @param m TxResponse message or plain object to encode
|
||||
* @param [w] Writer to encode to
|
||||
* @returns Writer
|
||||
*/
|
||||
public static encode(m: cosmos.ITxResponse, w?: $protobuf.Writer): $protobuf.Writer;
|
||||
|
||||
/**
|
||||
* Decodes a TxResponse message from the specified reader or buffer.
|
||||
* @param r Reader or buffer to decode from
|
||||
* @param [l] Message length if known beforehand
|
||||
* @returns TxResponse
|
||||
* @throws {Error} If the payload is not a reader or valid buffer
|
||||
* @throws {$protobuf.util.ProtocolError} If required fields are missing
|
||||
*/
|
||||
public static decode(r: $protobuf.Reader | Uint8Array, l?: number): cosmos.TxResponse;
|
||||
}
|
||||
|
||||
/** Properties of a ABCIMessageLog. */
|
||||
interface IABCIMessageLog {
|
||||
/** ABCIMessageLog msgIndex */
|
||||
msgIndex?: number | null;
|
||||
|
||||
/** ABCIMessageLog log */
|
||||
log?: string | null;
|
||||
|
||||
/** ABCIMessageLog events */
|
||||
events?: cosmos.IStringEvent[] | null;
|
||||
}
|
||||
|
||||
/** Represents a ABCIMessageLog. */
|
||||
class ABCIMessageLog implements IABCIMessageLog {
|
||||
/**
|
||||
* Constructs a new ABCIMessageLog.
|
||||
* @param [p] Properties to set
|
||||
*/
|
||||
constructor(p?: cosmos.IABCIMessageLog);
|
||||
|
||||
/** ABCIMessageLog msgIndex. */
|
||||
public msgIndex: number;
|
||||
|
||||
/** ABCIMessageLog log. */
|
||||
public log: string;
|
||||
|
||||
/** ABCIMessageLog events. */
|
||||
public events: cosmos.IStringEvent[];
|
||||
|
||||
/**
|
||||
* Creates a new ABCIMessageLog instance using the specified properties.
|
||||
* @param [properties] Properties to set
|
||||
* @returns ABCIMessageLog instance
|
||||
*/
|
||||
public static create(properties?: cosmos.IABCIMessageLog): cosmos.ABCIMessageLog;
|
||||
|
||||
/**
|
||||
* Encodes the specified ABCIMessageLog message. Does not implicitly {@link cosmos.ABCIMessageLog.verify|verify} messages.
|
||||
* @param m ABCIMessageLog message or plain object to encode
|
||||
* @param [w] Writer to encode to
|
||||
* @returns Writer
|
||||
*/
|
||||
public static encode(m: cosmos.IABCIMessageLog, w?: $protobuf.Writer): $protobuf.Writer;
|
||||
|
||||
/**
|
||||
* Decodes a ABCIMessageLog message from the specified reader or buffer.
|
||||
* @param r Reader or buffer to decode from
|
||||
* @param [l] Message length if known beforehand
|
||||
* @returns ABCIMessageLog
|
||||
* @throws {Error} If the payload is not a reader or valid buffer
|
||||
* @throws {$protobuf.util.ProtocolError} If required fields are missing
|
||||
*/
|
||||
public static decode(r: $protobuf.Reader | Uint8Array, l?: number): cosmos.ABCIMessageLog;
|
||||
}
|
||||
|
||||
/** Properties of a StringEvent. */
|
||||
interface IStringEvent {
|
||||
/** StringEvent type */
|
||||
type?: string | null;
|
||||
|
||||
/** StringEvent attributes */
|
||||
attributes?: cosmos.IAttribute[] | null;
|
||||
}
|
||||
|
||||
/** Represents a StringEvent. */
|
||||
class StringEvent implements IStringEvent {
|
||||
/**
|
||||
* Constructs a new StringEvent.
|
||||
* @param [p] Properties to set
|
||||
*/
|
||||
constructor(p?: cosmos.IStringEvent);
|
||||
|
||||
/** StringEvent type. */
|
||||
public type: string;
|
||||
|
||||
/** StringEvent attributes. */
|
||||
public attributes: cosmos.IAttribute[];
|
||||
|
||||
/**
|
||||
* Creates a new StringEvent instance using the specified properties.
|
||||
* @param [properties] Properties to set
|
||||
* @returns StringEvent instance
|
||||
*/
|
||||
public static create(properties?: cosmos.IStringEvent): cosmos.StringEvent;
|
||||
|
||||
/**
|
||||
* Encodes the specified StringEvent message. Does not implicitly {@link cosmos.StringEvent.verify|verify} messages.
|
||||
* @param m StringEvent message or plain object to encode
|
||||
* @param [w] Writer to encode to
|
||||
* @returns Writer
|
||||
*/
|
||||
public static encode(m: cosmos.IStringEvent, w?: $protobuf.Writer): $protobuf.Writer;
|
||||
|
||||
/**
|
||||
* Decodes a StringEvent message from the specified reader or buffer.
|
||||
* @param r Reader or buffer to decode from
|
||||
* @param [l] Message length if known beforehand
|
||||
* @returns StringEvent
|
||||
* @throws {Error} If the payload is not a reader or valid buffer
|
||||
* @throws {$protobuf.util.ProtocolError} If required fields are missing
|
||||
*/
|
||||
public static decode(r: $protobuf.Reader | Uint8Array, l?: number): cosmos.StringEvent;
|
||||
}
|
||||
|
||||
/** Properties of an Attribute. */
|
||||
interface IAttribute {
|
||||
/** Attribute key */
|
||||
key?: string | null;
|
||||
|
||||
/** Attribute value */
|
||||
value?: string | null;
|
||||
}
|
||||
|
||||
/** Represents an Attribute. */
|
||||
class Attribute implements IAttribute {
|
||||
/**
|
||||
* Constructs a new Attribute.
|
||||
* @param [p] Properties to set
|
||||
*/
|
||||
constructor(p?: cosmos.IAttribute);
|
||||
|
||||
/** Attribute key. */
|
||||
public key: string;
|
||||
|
||||
/** Attribute value. */
|
||||
public value: string;
|
||||
|
||||
/**
|
||||
* Creates a new Attribute instance using the specified properties.
|
||||
* @param [properties] Properties to set
|
||||
* @returns Attribute instance
|
||||
*/
|
||||
public static create(properties?: cosmos.IAttribute): cosmos.Attribute;
|
||||
|
||||
/**
|
||||
* Encodes the specified Attribute message. Does not implicitly {@link cosmos.Attribute.verify|verify} messages.
|
||||
* @param m Attribute message or plain object to encode
|
||||
* @param [w] Writer to encode to
|
||||
* @returns Writer
|
||||
*/
|
||||
public static encode(m: cosmos.IAttribute, w?: $protobuf.Writer): $protobuf.Writer;
|
||||
|
||||
/**
|
||||
* Decodes an Attribute message from the specified reader or buffer.
|
||||
* @param r Reader or buffer to decode from
|
||||
* @param [l] Message length if known beforehand
|
||||
* @returns Attribute
|
||||
* @throws {Error} If the payload is not a reader or valid buffer
|
||||
* @throws {$protobuf.util.ProtocolError} If required fields are missing
|
||||
*/
|
||||
public static decode(r: $protobuf.Reader | Uint8Array, l?: number): cosmos.Attribute;
|
||||
}
|
||||
|
||||
/** Namespace bank. */
|
||||
namespace bank {
|
||||
/** Properties of a Params. */
|
||||
@ -817,6 +1079,122 @@ export namespace cosmos {
|
||||
*/
|
||||
public static decode(r: $protobuf.Reader | Uint8Array, l?: number): cosmos.bank.Supply;
|
||||
}
|
||||
|
||||
/** Properties of a DenomUnits. */
|
||||
interface IDenomUnits {
|
||||
/** DenomUnits denom */
|
||||
denom?: string | null;
|
||||
|
||||
/** DenomUnits exponent */
|
||||
exponent?: number | null;
|
||||
|
||||
/** DenomUnits aliases */
|
||||
aliases?: string[] | null;
|
||||
}
|
||||
|
||||
/** Represents a DenomUnits. */
|
||||
class DenomUnits implements IDenomUnits {
|
||||
/**
|
||||
* Constructs a new DenomUnits.
|
||||
* @param [p] Properties to set
|
||||
*/
|
||||
constructor(p?: cosmos.bank.IDenomUnits);
|
||||
|
||||
/** DenomUnits denom. */
|
||||
public denom: string;
|
||||
|
||||
/** DenomUnits exponent. */
|
||||
public exponent: number;
|
||||
|
||||
/** DenomUnits aliases. */
|
||||
public aliases: string[];
|
||||
|
||||
/**
|
||||
* Creates a new DenomUnits instance using the specified properties.
|
||||
* @param [properties] Properties to set
|
||||
* @returns DenomUnits instance
|
||||
*/
|
||||
public static create(properties?: cosmos.bank.IDenomUnits): cosmos.bank.DenomUnits;
|
||||
|
||||
/**
|
||||
* Encodes the specified DenomUnits message. Does not implicitly {@link cosmos.bank.DenomUnits.verify|verify} messages.
|
||||
* @param m DenomUnits message or plain object to encode
|
||||
* @param [w] Writer to encode to
|
||||
* @returns Writer
|
||||
*/
|
||||
public static encode(m: cosmos.bank.IDenomUnits, w?: $protobuf.Writer): $protobuf.Writer;
|
||||
|
||||
/**
|
||||
* Decodes a DenomUnits message from the specified reader or buffer.
|
||||
* @param r Reader or buffer to decode from
|
||||
* @param [l] Message length if known beforehand
|
||||
* @returns DenomUnits
|
||||
* @throws {Error} If the payload is not a reader or valid buffer
|
||||
* @throws {$protobuf.util.ProtocolError} If required fields are missing
|
||||
*/
|
||||
public static decode(r: $protobuf.Reader | Uint8Array, l?: number): cosmos.bank.DenomUnits;
|
||||
}
|
||||
|
||||
/** Properties of a Metadata. */
|
||||
interface IMetadata {
|
||||
/** Metadata description */
|
||||
description?: string | null;
|
||||
|
||||
/** Metadata denomUnits */
|
||||
denomUnits?: cosmos.bank.IDenomUnits[] | null;
|
||||
|
||||
/** Metadata base */
|
||||
base?: string | null;
|
||||
|
||||
/** Metadata display */
|
||||
display?: string | null;
|
||||
}
|
||||
|
||||
/** Represents a Metadata. */
|
||||
class Metadata implements IMetadata {
|
||||
/**
|
||||
* Constructs a new Metadata.
|
||||
* @param [p] Properties to set
|
||||
*/
|
||||
constructor(p?: cosmos.bank.IMetadata);
|
||||
|
||||
/** Metadata description. */
|
||||
public description: string;
|
||||
|
||||
/** Metadata denomUnits. */
|
||||
public denomUnits: cosmos.bank.IDenomUnits[];
|
||||
|
||||
/** Metadata base. */
|
||||
public base: string;
|
||||
|
||||
/** Metadata display. */
|
||||
public display: string;
|
||||
|
||||
/**
|
||||
* Creates a new Metadata instance using the specified properties.
|
||||
* @param [properties] Properties to set
|
||||
* @returns Metadata instance
|
||||
*/
|
||||
public static create(properties?: cosmos.bank.IMetadata): cosmos.bank.Metadata;
|
||||
|
||||
/**
|
||||
* Encodes the specified Metadata message. Does not implicitly {@link cosmos.bank.Metadata.verify|verify} messages.
|
||||
* @param m Metadata message or plain object to encode
|
||||
* @param [w] Writer to encode to
|
||||
* @returns Writer
|
||||
*/
|
||||
public static encode(m: cosmos.bank.IMetadata, w?: $protobuf.Writer): $protobuf.Writer;
|
||||
|
||||
/**
|
||||
* Decodes a Metadata message from the specified reader or buffer.
|
||||
* @param r Reader or buffer to decode from
|
||||
* @param [l] Message length if known beforehand
|
||||
* @returns Metadata
|
||||
* @throws {Error} If the payload is not a reader or valid buffer
|
||||
* @throws {$protobuf.util.ProtocolError} If required fields are missing
|
||||
*/
|
||||
public static decode(r: $protobuf.Reader | Uint8Array, l?: number): cosmos.bank.Metadata;
|
||||
}
|
||||
}
|
||||
|
||||
/** Namespace crypto. */
|
||||
@ -1592,6 +1970,292 @@ export namespace cosmos {
|
||||
SIGN_MODE_TEXTUAL = 2,
|
||||
SIGN_MODE_LEGACY_AMINO_JSON = 127,
|
||||
}
|
||||
|
||||
/** Properties of a SignatureDescriptors. */
|
||||
interface ISignatureDescriptors {
|
||||
/** SignatureDescriptors signatures */
|
||||
signatures?: cosmos.tx.signing.ISignatureDescriptor[] | null;
|
||||
}
|
||||
|
||||
/** Represents a SignatureDescriptors. */
|
||||
class SignatureDescriptors implements ISignatureDescriptors {
|
||||
/**
|
||||
* Constructs a new SignatureDescriptors.
|
||||
* @param [p] Properties to set
|
||||
*/
|
||||
constructor(p?: cosmos.tx.signing.ISignatureDescriptors);
|
||||
|
||||
/** SignatureDescriptors signatures. */
|
||||
public signatures: cosmos.tx.signing.ISignatureDescriptor[];
|
||||
|
||||
/**
|
||||
* Creates a new SignatureDescriptors instance using the specified properties.
|
||||
* @param [properties] Properties to set
|
||||
* @returns SignatureDescriptors instance
|
||||
*/
|
||||
public static create(
|
||||
properties?: cosmos.tx.signing.ISignatureDescriptors,
|
||||
): cosmos.tx.signing.SignatureDescriptors;
|
||||
|
||||
/**
|
||||
* Encodes the specified SignatureDescriptors message. Does not implicitly {@link cosmos.tx.signing.SignatureDescriptors.verify|verify} messages.
|
||||
* @param m SignatureDescriptors message or plain object to encode
|
||||
* @param [w] Writer to encode to
|
||||
* @returns Writer
|
||||
*/
|
||||
public static encode(
|
||||
m: cosmos.tx.signing.ISignatureDescriptors,
|
||||
w?: $protobuf.Writer,
|
||||
): $protobuf.Writer;
|
||||
|
||||
/**
|
||||
* Decodes a SignatureDescriptors message from the specified reader or buffer.
|
||||
* @param r Reader or buffer to decode from
|
||||
* @param [l] Message length if known beforehand
|
||||
* @returns SignatureDescriptors
|
||||
* @throws {Error} If the payload is not a reader or valid buffer
|
||||
* @throws {$protobuf.util.ProtocolError} If required fields are missing
|
||||
*/
|
||||
public static decode(
|
||||
r: $protobuf.Reader | Uint8Array,
|
||||
l?: number,
|
||||
): cosmos.tx.signing.SignatureDescriptors;
|
||||
}
|
||||
|
||||
/** Properties of a SignatureDescriptor. */
|
||||
interface ISignatureDescriptor {
|
||||
/** SignatureDescriptor publicKey */
|
||||
publicKey?: cosmos.crypto.IPublicKey | null;
|
||||
|
||||
/** SignatureDescriptor data */
|
||||
data?: cosmos.tx.signing.SignatureDescriptor.IData | null;
|
||||
}
|
||||
|
||||
/** Represents a SignatureDescriptor. */
|
||||
class SignatureDescriptor implements ISignatureDescriptor {
|
||||
/**
|
||||
* Constructs a new SignatureDescriptor.
|
||||
* @param [p] Properties to set
|
||||
*/
|
||||
constructor(p?: cosmos.tx.signing.ISignatureDescriptor);
|
||||
|
||||
/** SignatureDescriptor publicKey. */
|
||||
public publicKey?: cosmos.crypto.IPublicKey | null;
|
||||
|
||||
/** SignatureDescriptor data. */
|
||||
public data?: cosmos.tx.signing.SignatureDescriptor.IData | null;
|
||||
|
||||
/**
|
||||
* Creates a new SignatureDescriptor instance using the specified properties.
|
||||
* @param [properties] Properties to set
|
||||
* @returns SignatureDescriptor instance
|
||||
*/
|
||||
public static create(
|
||||
properties?: cosmos.tx.signing.ISignatureDescriptor,
|
||||
): cosmos.tx.signing.SignatureDescriptor;
|
||||
|
||||
/**
|
||||
* Encodes the specified SignatureDescriptor message. Does not implicitly {@link cosmos.tx.signing.SignatureDescriptor.verify|verify} messages.
|
||||
* @param m SignatureDescriptor message or plain object to encode
|
||||
* @param [w] Writer to encode to
|
||||
* @returns Writer
|
||||
*/
|
||||
public static encode(
|
||||
m: cosmos.tx.signing.ISignatureDescriptor,
|
||||
w?: $protobuf.Writer,
|
||||
): $protobuf.Writer;
|
||||
|
||||
/**
|
||||
* Decodes a SignatureDescriptor message from the specified reader or buffer.
|
||||
* @param r Reader or buffer to decode from
|
||||
* @param [l] Message length if known beforehand
|
||||
* @returns SignatureDescriptor
|
||||
* @throws {Error} If the payload is not a reader or valid buffer
|
||||
* @throws {$protobuf.util.ProtocolError} If required fields are missing
|
||||
*/
|
||||
public static decode(
|
||||
r: $protobuf.Reader | Uint8Array,
|
||||
l?: number,
|
||||
): cosmos.tx.signing.SignatureDescriptor;
|
||||
}
|
||||
|
||||
namespace SignatureDescriptor {
|
||||
/** Properties of a Data. */
|
||||
interface IData {
|
||||
/** Data single */
|
||||
single?: cosmos.tx.signing.SignatureDescriptor.Data.ISingle | null;
|
||||
|
||||
/** Data multi */
|
||||
multi?: cosmos.tx.signing.SignatureDescriptor.Data.IMulti | null;
|
||||
}
|
||||
|
||||
/** Represents a Data. */
|
||||
class Data implements IData {
|
||||
/**
|
||||
* Constructs a new Data.
|
||||
* @param [p] Properties to set
|
||||
*/
|
||||
constructor(p?: cosmos.tx.signing.SignatureDescriptor.IData);
|
||||
|
||||
/** Data single. */
|
||||
public single?: cosmos.tx.signing.SignatureDescriptor.Data.ISingle | null;
|
||||
|
||||
/** Data multi. */
|
||||
public multi?: cosmos.tx.signing.SignatureDescriptor.Data.IMulti | null;
|
||||
|
||||
/** Data sum. */
|
||||
public sum?: "single" | "multi";
|
||||
|
||||
/**
|
||||
* Creates a new Data instance using the specified properties.
|
||||
* @param [properties] Properties to set
|
||||
* @returns Data instance
|
||||
*/
|
||||
public static create(
|
||||
properties?: cosmos.tx.signing.SignatureDescriptor.IData,
|
||||
): cosmos.tx.signing.SignatureDescriptor.Data;
|
||||
|
||||
/**
|
||||
* Encodes the specified Data message. Does not implicitly {@link cosmos.tx.signing.SignatureDescriptor.Data.verify|verify} messages.
|
||||
* @param m Data message or plain object to encode
|
||||
* @param [w] Writer to encode to
|
||||
* @returns Writer
|
||||
*/
|
||||
public static encode(
|
||||
m: cosmos.tx.signing.SignatureDescriptor.IData,
|
||||
w?: $protobuf.Writer,
|
||||
): $protobuf.Writer;
|
||||
|
||||
/**
|
||||
* Decodes a Data message from the specified reader or buffer.
|
||||
* @param r Reader or buffer to decode from
|
||||
* @param [l] Message length if known beforehand
|
||||
* @returns Data
|
||||
* @throws {Error} If the payload is not a reader or valid buffer
|
||||
* @throws {$protobuf.util.ProtocolError} If required fields are missing
|
||||
*/
|
||||
public static decode(
|
||||
r: $protobuf.Reader | Uint8Array,
|
||||
l?: number,
|
||||
): cosmos.tx.signing.SignatureDescriptor.Data;
|
||||
}
|
||||
|
||||
namespace Data {
|
||||
/** Properties of a Single. */
|
||||
interface ISingle {
|
||||
/** Single mode */
|
||||
mode?: cosmos.tx.signing.SignMode | null;
|
||||
|
||||
/** Single signature */
|
||||
signature?: Uint8Array | null;
|
||||
}
|
||||
|
||||
/** Represents a Single. */
|
||||
class Single implements ISingle {
|
||||
/**
|
||||
* Constructs a new Single.
|
||||
* @param [p] Properties to set
|
||||
*/
|
||||
constructor(p?: cosmos.tx.signing.SignatureDescriptor.Data.ISingle);
|
||||
|
||||
/** Single mode. */
|
||||
public mode: cosmos.tx.signing.SignMode;
|
||||
|
||||
/** Single signature. */
|
||||
public signature: Uint8Array;
|
||||
|
||||
/**
|
||||
* Creates a new Single instance using the specified properties.
|
||||
* @param [properties] Properties to set
|
||||
* @returns Single instance
|
||||
*/
|
||||
public static create(
|
||||
properties?: cosmos.tx.signing.SignatureDescriptor.Data.ISingle,
|
||||
): cosmos.tx.signing.SignatureDescriptor.Data.Single;
|
||||
|
||||
/**
|
||||
* Encodes the specified Single message. Does not implicitly {@link cosmos.tx.signing.SignatureDescriptor.Data.Single.verify|verify} messages.
|
||||
* @param m Single message or plain object to encode
|
||||
* @param [w] Writer to encode to
|
||||
* @returns Writer
|
||||
*/
|
||||
public static encode(
|
||||
m: cosmos.tx.signing.SignatureDescriptor.Data.ISingle,
|
||||
w?: $protobuf.Writer,
|
||||
): $protobuf.Writer;
|
||||
|
||||
/**
|
||||
* Decodes a Single message from the specified reader or buffer.
|
||||
* @param r Reader or buffer to decode from
|
||||
* @param [l] Message length if known beforehand
|
||||
* @returns Single
|
||||
* @throws {Error} If the payload is not a reader or valid buffer
|
||||
* @throws {$protobuf.util.ProtocolError} If required fields are missing
|
||||
*/
|
||||
public static decode(
|
||||
r: $protobuf.Reader | Uint8Array,
|
||||
l?: number,
|
||||
): cosmos.tx.signing.SignatureDescriptor.Data.Single;
|
||||
}
|
||||
|
||||
/** Properties of a Multi. */
|
||||
interface IMulti {
|
||||
/** Multi bitarray */
|
||||
bitarray?: cosmos.crypto.ICompactBitArray | null;
|
||||
|
||||
/** Multi signatures */
|
||||
signatures?: cosmos.tx.signing.SignatureDescriptor.IData[] | null;
|
||||
}
|
||||
|
||||
/** Represents a Multi. */
|
||||
class Multi implements IMulti {
|
||||
/**
|
||||
* Constructs a new Multi.
|
||||
* @param [p] Properties to set
|
||||
*/
|
||||
constructor(p?: cosmos.tx.signing.SignatureDescriptor.Data.IMulti);
|
||||
|
||||
/** Multi bitarray. */
|
||||
public bitarray?: cosmos.crypto.ICompactBitArray | null;
|
||||
|
||||
/** Multi signatures. */
|
||||
public signatures: cosmos.tx.signing.SignatureDescriptor.IData[];
|
||||
|
||||
/**
|
||||
* Creates a new Multi instance using the specified properties.
|
||||
* @param [properties] Properties to set
|
||||
* @returns Multi instance
|
||||
*/
|
||||
public static create(
|
||||
properties?: cosmos.tx.signing.SignatureDescriptor.Data.IMulti,
|
||||
): cosmos.tx.signing.SignatureDescriptor.Data.Multi;
|
||||
|
||||
/**
|
||||
* Encodes the specified Multi message. Does not implicitly {@link cosmos.tx.signing.SignatureDescriptor.Data.Multi.verify|verify} messages.
|
||||
* @param m Multi message or plain object to encode
|
||||
* @param [w] Writer to encode to
|
||||
* @returns Writer
|
||||
*/
|
||||
public static encode(
|
||||
m: cosmos.tx.signing.SignatureDescriptor.Data.IMulti,
|
||||
w?: $protobuf.Writer,
|
||||
): $protobuf.Writer;
|
||||
|
||||
/**
|
||||
* Decodes a Multi message from the specified reader or buffer.
|
||||
* @param r Reader or buffer to decode from
|
||||
* @param [l] Message length if known beforehand
|
||||
* @returns Multi
|
||||
* @throws {Error} If the payload is not a reader or valid buffer
|
||||
* @throws {$protobuf.util.ProtocolError} If required fields are missing
|
||||
*/
|
||||
public static decode(
|
||||
r: $protobuf.Reader | Uint8Array,
|
||||
l?: number,
|
||||
): cosmos.tx.signing.SignatureDescriptor.Data.Multi;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -389,6 +389,229 @@ exports.cosmos = $root.cosmos = (function () {
|
||||
};
|
||||
return TxData;
|
||||
})();
|
||||
cosmos.TxResponse = (function () {
|
||||
function TxResponse(p) {
|
||||
this.logs = [];
|
||||
if (p)
|
||||
for (var ks = Object.keys(p), i = 0; i < ks.length; ++i) if (p[ks[i]] != null) this[ks[i]] = p[ks[i]];
|
||||
}
|
||||
TxResponse.prototype.height = $util.Long ? $util.Long.fromBits(0, 0, false) : 0;
|
||||
TxResponse.prototype.txhash = "";
|
||||
TxResponse.prototype.codespace = "";
|
||||
TxResponse.prototype.code = 0;
|
||||
TxResponse.prototype.data = "";
|
||||
TxResponse.prototype.rawLog = "";
|
||||
TxResponse.prototype.logs = $util.emptyArray;
|
||||
TxResponse.prototype.info = "";
|
||||
TxResponse.prototype.gasWanted = $util.Long ? $util.Long.fromBits(0, 0, false) : 0;
|
||||
TxResponse.prototype.gasUsed = $util.Long ? $util.Long.fromBits(0, 0, false) : 0;
|
||||
TxResponse.prototype.tx = null;
|
||||
TxResponse.prototype.timestamp = "";
|
||||
TxResponse.create = function create(properties) {
|
||||
return new TxResponse(properties);
|
||||
};
|
||||
TxResponse.encode = function encode(m, w) {
|
||||
if (!w) w = $Writer.create();
|
||||
if (m.height != null && Object.hasOwnProperty.call(m, "height")) w.uint32(8).int64(m.height);
|
||||
if (m.txhash != null && Object.hasOwnProperty.call(m, "txhash")) w.uint32(18).string(m.txhash);
|
||||
if (m.codespace != null && Object.hasOwnProperty.call(m, "codespace")) w.uint32(26).string(m.codespace);
|
||||
if (m.code != null && Object.hasOwnProperty.call(m, "code")) w.uint32(32).uint32(m.code);
|
||||
if (m.data != null && Object.hasOwnProperty.call(m, "data")) w.uint32(42).string(m.data);
|
||||
if (m.rawLog != null && Object.hasOwnProperty.call(m, "rawLog")) w.uint32(50).string(m.rawLog);
|
||||
if (m.logs != null && m.logs.length) {
|
||||
for (var i = 0; i < m.logs.length; ++i)
|
||||
$root.cosmos.ABCIMessageLog.encode(m.logs[i], w.uint32(58).fork()).ldelim();
|
||||
}
|
||||
if (m.info != null && Object.hasOwnProperty.call(m, "info")) w.uint32(66).string(m.info);
|
||||
if (m.gasWanted != null && Object.hasOwnProperty.call(m, "gasWanted")) w.uint32(72).int64(m.gasWanted);
|
||||
if (m.gasUsed != null && Object.hasOwnProperty.call(m, "gasUsed")) w.uint32(80).int64(m.gasUsed);
|
||||
if (m.tx != null && Object.hasOwnProperty.call(m, "tx"))
|
||||
$root.google.protobuf.Any.encode(m.tx, w.uint32(90).fork()).ldelim();
|
||||
if (m.timestamp != null && Object.hasOwnProperty.call(m, "timestamp")) w.uint32(98).string(m.timestamp);
|
||||
return w;
|
||||
};
|
||||
TxResponse.decode = function decode(r, l) {
|
||||
if (!(r instanceof $Reader)) r = $Reader.create(r);
|
||||
var c = l === undefined ? r.len : r.pos + l,
|
||||
m = new $root.cosmos.TxResponse();
|
||||
while (r.pos < c) {
|
||||
var t = r.uint32();
|
||||
switch (t >>> 3) {
|
||||
case 1:
|
||||
m.height = r.int64();
|
||||
break;
|
||||
case 2:
|
||||
m.txhash = r.string();
|
||||
break;
|
||||
case 3:
|
||||
m.codespace = r.string();
|
||||
break;
|
||||
case 4:
|
||||
m.code = r.uint32();
|
||||
break;
|
||||
case 5:
|
||||
m.data = r.string();
|
||||
break;
|
||||
case 6:
|
||||
m.rawLog = r.string();
|
||||
break;
|
||||
case 7:
|
||||
if (!(m.logs && m.logs.length)) m.logs = [];
|
||||
m.logs.push($root.cosmos.ABCIMessageLog.decode(r, r.uint32()));
|
||||
break;
|
||||
case 8:
|
||||
m.info = r.string();
|
||||
break;
|
||||
case 9:
|
||||
m.gasWanted = r.int64();
|
||||
break;
|
||||
case 10:
|
||||
m.gasUsed = r.int64();
|
||||
break;
|
||||
case 11:
|
||||
m.tx = $root.google.protobuf.Any.decode(r, r.uint32());
|
||||
break;
|
||||
case 12:
|
||||
m.timestamp = r.string();
|
||||
break;
|
||||
default:
|
||||
r.skipType(t & 7);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return m;
|
||||
};
|
||||
return TxResponse;
|
||||
})();
|
||||
cosmos.ABCIMessageLog = (function () {
|
||||
function ABCIMessageLog(p) {
|
||||
this.events = [];
|
||||
if (p)
|
||||
for (var ks = Object.keys(p), i = 0; i < ks.length; ++i) if (p[ks[i]] != null) this[ks[i]] = p[ks[i]];
|
||||
}
|
||||
ABCIMessageLog.prototype.msgIndex = 0;
|
||||
ABCIMessageLog.prototype.log = "";
|
||||
ABCIMessageLog.prototype.events = $util.emptyArray;
|
||||
ABCIMessageLog.create = function create(properties) {
|
||||
return new ABCIMessageLog(properties);
|
||||
};
|
||||
ABCIMessageLog.encode = function encode(m, w) {
|
||||
if (!w) w = $Writer.create();
|
||||
if (m.msgIndex != null && Object.hasOwnProperty.call(m, "msgIndex")) w.uint32(8).uint32(m.msgIndex);
|
||||
if (m.log != null && Object.hasOwnProperty.call(m, "log")) w.uint32(18).string(m.log);
|
||||
if (m.events != null && m.events.length) {
|
||||
for (var i = 0; i < m.events.length; ++i)
|
||||
$root.cosmos.StringEvent.encode(m.events[i], w.uint32(26).fork()).ldelim();
|
||||
}
|
||||
return w;
|
||||
};
|
||||
ABCIMessageLog.decode = function decode(r, l) {
|
||||
if (!(r instanceof $Reader)) r = $Reader.create(r);
|
||||
var c = l === undefined ? r.len : r.pos + l,
|
||||
m = new $root.cosmos.ABCIMessageLog();
|
||||
while (r.pos < c) {
|
||||
var t = r.uint32();
|
||||
switch (t >>> 3) {
|
||||
case 1:
|
||||
m.msgIndex = r.uint32();
|
||||
break;
|
||||
case 2:
|
||||
m.log = r.string();
|
||||
break;
|
||||
case 3:
|
||||
if (!(m.events && m.events.length)) m.events = [];
|
||||
m.events.push($root.cosmos.StringEvent.decode(r, r.uint32()));
|
||||
break;
|
||||
default:
|
||||
r.skipType(t & 7);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return m;
|
||||
};
|
||||
return ABCIMessageLog;
|
||||
})();
|
||||
cosmos.StringEvent = (function () {
|
||||
function StringEvent(p) {
|
||||
this.attributes = [];
|
||||
if (p)
|
||||
for (var ks = Object.keys(p), i = 0; i < ks.length; ++i) if (p[ks[i]] != null) this[ks[i]] = p[ks[i]];
|
||||
}
|
||||
StringEvent.prototype.type = "";
|
||||
StringEvent.prototype.attributes = $util.emptyArray;
|
||||
StringEvent.create = function create(properties) {
|
||||
return new StringEvent(properties);
|
||||
};
|
||||
StringEvent.encode = function encode(m, w) {
|
||||
if (!w) w = $Writer.create();
|
||||
if (m.type != null && Object.hasOwnProperty.call(m, "type")) w.uint32(10).string(m.type);
|
||||
if (m.attributes != null && m.attributes.length) {
|
||||
for (var i = 0; i < m.attributes.length; ++i)
|
||||
$root.cosmos.Attribute.encode(m.attributes[i], w.uint32(18).fork()).ldelim();
|
||||
}
|
||||
return w;
|
||||
};
|
||||
StringEvent.decode = function decode(r, l) {
|
||||
if (!(r instanceof $Reader)) r = $Reader.create(r);
|
||||
var c = l === undefined ? r.len : r.pos + l,
|
||||
m = new $root.cosmos.StringEvent();
|
||||
while (r.pos < c) {
|
||||
var t = r.uint32();
|
||||
switch (t >>> 3) {
|
||||
case 1:
|
||||
m.type = r.string();
|
||||
break;
|
||||
case 2:
|
||||
if (!(m.attributes && m.attributes.length)) m.attributes = [];
|
||||
m.attributes.push($root.cosmos.Attribute.decode(r, r.uint32()));
|
||||
break;
|
||||
default:
|
||||
r.skipType(t & 7);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return m;
|
||||
};
|
||||
return StringEvent;
|
||||
})();
|
||||
cosmos.Attribute = (function () {
|
||||
function Attribute(p) {
|
||||
if (p)
|
||||
for (var ks = Object.keys(p), i = 0; i < ks.length; ++i) if (p[ks[i]] != null) this[ks[i]] = p[ks[i]];
|
||||
}
|
||||
Attribute.prototype.key = "";
|
||||
Attribute.prototype.value = "";
|
||||
Attribute.create = function create(properties) {
|
||||
return new Attribute(properties);
|
||||
};
|
||||
Attribute.encode = function encode(m, w) {
|
||||
if (!w) w = $Writer.create();
|
||||
if (m.key != null && Object.hasOwnProperty.call(m, "key")) w.uint32(10).string(m.key);
|
||||
if (m.value != null && Object.hasOwnProperty.call(m, "value")) w.uint32(18).string(m.value);
|
||||
return w;
|
||||
};
|
||||
Attribute.decode = function decode(r, l) {
|
||||
if (!(r instanceof $Reader)) r = $Reader.create(r);
|
||||
var c = l === undefined ? r.len : r.pos + l,
|
||||
m = new $root.cosmos.Attribute();
|
||||
while (r.pos < c) {
|
||||
var t = r.uint32();
|
||||
switch (t >>> 3) {
|
||||
case 1:
|
||||
m.key = r.string();
|
||||
break;
|
||||
case 2:
|
||||
m.value = r.string();
|
||||
break;
|
||||
default:
|
||||
r.skipType(t & 7);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return m;
|
||||
};
|
||||
return Attribute;
|
||||
})();
|
||||
cosmos.bank = (function () {
|
||||
var bank = {};
|
||||
bank.Params = (function () {
|
||||
@ -702,6 +925,109 @@ exports.cosmos = $root.cosmos = (function () {
|
||||
};
|
||||
return Supply;
|
||||
})();
|
||||
bank.DenomUnits = (function () {
|
||||
function DenomUnits(p) {
|
||||
this.aliases = [];
|
||||
if (p)
|
||||
for (var ks = Object.keys(p), i = 0; i < ks.length; ++i)
|
||||
if (p[ks[i]] != null) this[ks[i]] = p[ks[i]];
|
||||
}
|
||||
DenomUnits.prototype.denom = "";
|
||||
DenomUnits.prototype.exponent = 0;
|
||||
DenomUnits.prototype.aliases = $util.emptyArray;
|
||||
DenomUnits.create = function create(properties) {
|
||||
return new DenomUnits(properties);
|
||||
};
|
||||
DenomUnits.encode = function encode(m, w) {
|
||||
if (!w) w = $Writer.create();
|
||||
if (m.denom != null && Object.hasOwnProperty.call(m, "denom")) w.uint32(10).string(m.denom);
|
||||
if (m.exponent != null && Object.hasOwnProperty.call(m, "exponent")) w.uint32(16).uint32(m.exponent);
|
||||
if (m.aliases != null && m.aliases.length) {
|
||||
for (var i = 0; i < m.aliases.length; ++i) w.uint32(26).string(m.aliases[i]);
|
||||
}
|
||||
return w;
|
||||
};
|
||||
DenomUnits.decode = function decode(r, l) {
|
||||
if (!(r instanceof $Reader)) r = $Reader.create(r);
|
||||
var c = l === undefined ? r.len : r.pos + l,
|
||||
m = new $root.cosmos.bank.DenomUnits();
|
||||
while (r.pos < c) {
|
||||
var t = r.uint32();
|
||||
switch (t >>> 3) {
|
||||
case 1:
|
||||
m.denom = r.string();
|
||||
break;
|
||||
case 2:
|
||||
m.exponent = r.uint32();
|
||||
break;
|
||||
case 3:
|
||||
if (!(m.aliases && m.aliases.length)) m.aliases = [];
|
||||
m.aliases.push(r.string());
|
||||
break;
|
||||
default:
|
||||
r.skipType(t & 7);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return m;
|
||||
};
|
||||
return DenomUnits;
|
||||
})();
|
||||
bank.Metadata = (function () {
|
||||
function Metadata(p) {
|
||||
this.denomUnits = [];
|
||||
if (p)
|
||||
for (var ks = Object.keys(p), i = 0; i < ks.length; ++i)
|
||||
if (p[ks[i]] != null) this[ks[i]] = p[ks[i]];
|
||||
}
|
||||
Metadata.prototype.description = "";
|
||||
Metadata.prototype.denomUnits = $util.emptyArray;
|
||||
Metadata.prototype.base = "";
|
||||
Metadata.prototype.display = "";
|
||||
Metadata.create = function create(properties) {
|
||||
return new Metadata(properties);
|
||||
};
|
||||
Metadata.encode = function encode(m, w) {
|
||||
if (!w) w = $Writer.create();
|
||||
if (m.description != null && Object.hasOwnProperty.call(m, "description"))
|
||||
w.uint32(10).string(m.description);
|
||||
if (m.denomUnits != null && m.denomUnits.length) {
|
||||
for (var i = 0; i < m.denomUnits.length; ++i)
|
||||
$root.cosmos.bank.DenomUnits.encode(m.denomUnits[i], w.uint32(18).fork()).ldelim();
|
||||
}
|
||||
if (m.base != null && Object.hasOwnProperty.call(m, "base")) w.uint32(26).string(m.base);
|
||||
if (m.display != null && Object.hasOwnProperty.call(m, "display")) w.uint32(34).string(m.display);
|
||||
return w;
|
||||
};
|
||||
Metadata.decode = function decode(r, l) {
|
||||
if (!(r instanceof $Reader)) r = $Reader.create(r);
|
||||
var c = l === undefined ? r.len : r.pos + l,
|
||||
m = new $root.cosmos.bank.Metadata();
|
||||
while (r.pos < c) {
|
||||
var t = r.uint32();
|
||||
switch (t >>> 3) {
|
||||
case 1:
|
||||
m.description = r.string();
|
||||
break;
|
||||
case 2:
|
||||
if (!(m.denomUnits && m.denomUnits.length)) m.denomUnits = [];
|
||||
m.denomUnits.push($root.cosmos.bank.DenomUnits.decode(r, r.uint32()));
|
||||
break;
|
||||
case 3:
|
||||
m.base = r.string();
|
||||
break;
|
||||
case 4:
|
||||
m.display = r.string();
|
||||
break;
|
||||
default:
|
||||
r.skipType(t & 7);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return m;
|
||||
};
|
||||
return Metadata;
|
||||
})();
|
||||
return bank;
|
||||
})();
|
||||
cosmos.crypto = (function () {
|
||||
@ -1401,6 +1727,229 @@ exports.cosmos = $root.cosmos = (function () {
|
||||
values[(valuesById[127] = "SIGN_MODE_LEGACY_AMINO_JSON")] = 127;
|
||||
return values;
|
||||
})();
|
||||
signing.SignatureDescriptors = (function () {
|
||||
function SignatureDescriptors(p) {
|
||||
this.signatures = [];
|
||||
if (p)
|
||||
for (var ks = Object.keys(p), i = 0; i < ks.length; ++i)
|
||||
if (p[ks[i]] != null) this[ks[i]] = p[ks[i]];
|
||||
}
|
||||
SignatureDescriptors.prototype.signatures = $util.emptyArray;
|
||||
SignatureDescriptors.create = function create(properties) {
|
||||
return new SignatureDescriptors(properties);
|
||||
};
|
||||
SignatureDescriptors.encode = function encode(m, w) {
|
||||
if (!w) w = $Writer.create();
|
||||
if (m.signatures != null && m.signatures.length) {
|
||||
for (var i = 0; i < m.signatures.length; ++i)
|
||||
$root.cosmos.tx.signing.SignatureDescriptor.encode(
|
||||
m.signatures[i],
|
||||
w.uint32(10).fork(),
|
||||
).ldelim();
|
||||
}
|
||||
return w;
|
||||
};
|
||||
SignatureDescriptors.decode = function decode(r, l) {
|
||||
if (!(r instanceof $Reader)) r = $Reader.create(r);
|
||||
var c = l === undefined ? r.len : r.pos + l,
|
||||
m = new $root.cosmos.tx.signing.SignatureDescriptors();
|
||||
while (r.pos < c) {
|
||||
var t = r.uint32();
|
||||
switch (t >>> 3) {
|
||||
case 1:
|
||||
if (!(m.signatures && m.signatures.length)) m.signatures = [];
|
||||
m.signatures.push($root.cosmos.tx.signing.SignatureDescriptor.decode(r, r.uint32()));
|
||||
break;
|
||||
default:
|
||||
r.skipType(t & 7);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return m;
|
||||
};
|
||||
return SignatureDescriptors;
|
||||
})();
|
||||
signing.SignatureDescriptor = (function () {
|
||||
function SignatureDescriptor(p) {
|
||||
if (p)
|
||||
for (var ks = Object.keys(p), i = 0; i < ks.length; ++i)
|
||||
if (p[ks[i]] != null) this[ks[i]] = p[ks[i]];
|
||||
}
|
||||
SignatureDescriptor.prototype.publicKey = null;
|
||||
SignatureDescriptor.prototype.data = null;
|
||||
SignatureDescriptor.create = function create(properties) {
|
||||
return new SignatureDescriptor(properties);
|
||||
};
|
||||
SignatureDescriptor.encode = function encode(m, w) {
|
||||
if (!w) w = $Writer.create();
|
||||
if (m.publicKey != null && Object.hasOwnProperty.call(m, "publicKey"))
|
||||
$root.cosmos.crypto.PublicKey.encode(m.publicKey, w.uint32(10).fork()).ldelim();
|
||||
if (m.data != null && Object.hasOwnProperty.call(m, "data"))
|
||||
$root.cosmos.tx.signing.SignatureDescriptor.Data.encode(m.data, w.uint32(18).fork()).ldelim();
|
||||
return w;
|
||||
};
|
||||
SignatureDescriptor.decode = function decode(r, l) {
|
||||
if (!(r instanceof $Reader)) r = $Reader.create(r);
|
||||
var c = l === undefined ? r.len : r.pos + l,
|
||||
m = new $root.cosmos.tx.signing.SignatureDescriptor();
|
||||
while (r.pos < c) {
|
||||
var t = r.uint32();
|
||||
switch (t >>> 3) {
|
||||
case 1:
|
||||
m.publicKey = $root.cosmos.crypto.PublicKey.decode(r, r.uint32());
|
||||
break;
|
||||
case 2:
|
||||
m.data = $root.cosmos.tx.signing.SignatureDescriptor.Data.decode(r, r.uint32());
|
||||
break;
|
||||
default:
|
||||
r.skipType(t & 7);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return m;
|
||||
};
|
||||
SignatureDescriptor.Data = (function () {
|
||||
function Data(p) {
|
||||
if (p)
|
||||
for (var ks = Object.keys(p), i = 0; i < ks.length; ++i)
|
||||
if (p[ks[i]] != null) this[ks[i]] = p[ks[i]];
|
||||
}
|
||||
Data.prototype.single = null;
|
||||
Data.prototype.multi = null;
|
||||
var $oneOfFields;
|
||||
Object.defineProperty(Data.prototype, "sum", {
|
||||
get: $util.oneOfGetter(($oneOfFields = ["single", "multi"])),
|
||||
set: $util.oneOfSetter($oneOfFields),
|
||||
});
|
||||
Data.create = function create(properties) {
|
||||
return new Data(properties);
|
||||
};
|
||||
Data.encode = function encode(m, w) {
|
||||
if (!w) w = $Writer.create();
|
||||
if (m.single != null && Object.hasOwnProperty.call(m, "single"))
|
||||
$root.cosmos.tx.signing.SignatureDescriptor.Data.Single.encode(
|
||||
m.single,
|
||||
w.uint32(10).fork(),
|
||||
).ldelim();
|
||||
if (m.multi != null && Object.hasOwnProperty.call(m, "multi"))
|
||||
$root.cosmos.tx.signing.SignatureDescriptor.Data.Multi.encode(
|
||||
m.multi,
|
||||
w.uint32(18).fork(),
|
||||
).ldelim();
|
||||
return w;
|
||||
};
|
||||
Data.decode = function decode(r, l) {
|
||||
if (!(r instanceof $Reader)) r = $Reader.create(r);
|
||||
var c = l === undefined ? r.len : r.pos + l,
|
||||
m = new $root.cosmos.tx.signing.SignatureDescriptor.Data();
|
||||
while (r.pos < c) {
|
||||
var t = r.uint32();
|
||||
switch (t >>> 3) {
|
||||
case 1:
|
||||
m.single = $root.cosmos.tx.signing.SignatureDescriptor.Data.Single.decode(r, r.uint32());
|
||||
break;
|
||||
case 2:
|
||||
m.multi = $root.cosmos.tx.signing.SignatureDescriptor.Data.Multi.decode(r, r.uint32());
|
||||
break;
|
||||
default:
|
||||
r.skipType(t & 7);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return m;
|
||||
};
|
||||
Data.Single = (function () {
|
||||
function Single(p) {
|
||||
if (p)
|
||||
for (var ks = Object.keys(p), i = 0; i < ks.length; ++i)
|
||||
if (p[ks[i]] != null) this[ks[i]] = p[ks[i]];
|
||||
}
|
||||
Single.prototype.mode = 0;
|
||||
Single.prototype.signature = $util.newBuffer([]);
|
||||
Single.create = function create(properties) {
|
||||
return new Single(properties);
|
||||
};
|
||||
Single.encode = function encode(m, w) {
|
||||
if (!w) w = $Writer.create();
|
||||
if (m.mode != null && Object.hasOwnProperty.call(m, "mode")) w.uint32(8).int32(m.mode);
|
||||
if (m.signature != null && Object.hasOwnProperty.call(m, "signature"))
|
||||
w.uint32(18).bytes(m.signature);
|
||||
return w;
|
||||
};
|
||||
Single.decode = function decode(r, l) {
|
||||
if (!(r instanceof $Reader)) r = $Reader.create(r);
|
||||
var c = l === undefined ? r.len : r.pos + l,
|
||||
m = new $root.cosmos.tx.signing.SignatureDescriptor.Data.Single();
|
||||
while (r.pos < c) {
|
||||
var t = r.uint32();
|
||||
switch (t >>> 3) {
|
||||
case 1:
|
||||
m.mode = r.int32();
|
||||
break;
|
||||
case 2:
|
||||
m.signature = r.bytes();
|
||||
break;
|
||||
default:
|
||||
r.skipType(t & 7);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return m;
|
||||
};
|
||||
return Single;
|
||||
})();
|
||||
Data.Multi = (function () {
|
||||
function Multi(p) {
|
||||
this.signatures = [];
|
||||
if (p)
|
||||
for (var ks = Object.keys(p), i = 0; i < ks.length; ++i)
|
||||
if (p[ks[i]] != null) this[ks[i]] = p[ks[i]];
|
||||
}
|
||||
Multi.prototype.bitarray = null;
|
||||
Multi.prototype.signatures = $util.emptyArray;
|
||||
Multi.create = function create(properties) {
|
||||
return new Multi(properties);
|
||||
};
|
||||
Multi.encode = function encode(m, w) {
|
||||
if (!w) w = $Writer.create();
|
||||
if (m.bitarray != null && Object.hasOwnProperty.call(m, "bitarray"))
|
||||
$root.cosmos.crypto.CompactBitArray.encode(m.bitarray, w.uint32(10).fork()).ldelim();
|
||||
if (m.signatures != null && m.signatures.length) {
|
||||
for (var i = 0; i < m.signatures.length; ++i)
|
||||
$root.cosmos.tx.signing.SignatureDescriptor.Data.encode(
|
||||
m.signatures[i],
|
||||
w.uint32(18).fork(),
|
||||
).ldelim();
|
||||
}
|
||||
return w;
|
||||
};
|
||||
Multi.decode = function decode(r, l) {
|
||||
if (!(r instanceof $Reader)) r = $Reader.create(r);
|
||||
var c = l === undefined ? r.len : r.pos + l,
|
||||
m = new $root.cosmos.tx.signing.SignatureDescriptor.Data.Multi();
|
||||
while (r.pos < c) {
|
||||
var t = r.uint32();
|
||||
switch (t >>> 3) {
|
||||
case 1:
|
||||
m.bitarray = $root.cosmos.crypto.CompactBitArray.decode(r, r.uint32());
|
||||
break;
|
||||
case 2:
|
||||
if (!(m.signatures && m.signatures.length)) m.signatures = [];
|
||||
m.signatures.push($root.cosmos.tx.signing.SignatureDescriptor.Data.decode(r, r.uint32()));
|
||||
break;
|
||||
default:
|
||||
r.skipType(t & 7);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return m;
|
||||
};
|
||||
return Multi;
|
||||
})();
|
||||
return Data;
|
||||
})();
|
||||
return SignatureDescriptor;
|
||||
})();
|
||||
return signing;
|
||||
})();
|
||||
return tx;
|
||||
|
176
packages/proto-signing/src/signing.spec.ts
Normal file
176
packages/proto-signing/src/signing.spec.ts
Normal file
@ -0,0 +1,176 @@
|
||||
/* eslint-disable @typescript-eslint/naming-convention */
|
||||
import { Bech32, fromBase64, fromHex, toHex } from "@cosmjs/encoding";
|
||||
import { Secp256k1Wallet } from "@cosmjs/launchpad";
|
||||
|
||||
import { omitDefaults } from "./adr27";
|
||||
import { cosmos } from "./generated/codecimpl";
|
||||
import { defaultRegistry } from "./msgs";
|
||||
import { Registry, TxBodyValue } from "./registry";
|
||||
|
||||
const { AuthInfo, SignDoc, Tx, TxBody } = cosmos.tx;
|
||||
const { PublicKey } = cosmos.crypto;
|
||||
|
||||
export function pendingWithoutSimapp(): void {
|
||||
if (!process.env.SIMAPP_ENABLED) {
|
||||
return pending("Set SIMAPP_ENABLED to enable Simapp based tests");
|
||||
}
|
||||
}
|
||||
|
||||
const faucet = {
|
||||
mnemonic:
|
||||
"economy stock theory fatal elder harbor betray wasp final emotion task crumble siren bottom lizard educate guess current outdoor pair theory focus wife stone",
|
||||
pubkey: {
|
||||
type: "tendermint/PubKeySecp256k1",
|
||||
value: "A08EGB7ro1ORuFhjOnZcSgwYlpe0DSFjVNUIkNNQxwKQ",
|
||||
},
|
||||
address: "cosmos1pkptre7fdkl6gfrzlesjjvhxhlc3r4gmmk8rs6",
|
||||
};
|
||||
|
||||
// Test vectors were generated using this command with Ethan’s custom fork of Cosmos-SDK with printf:
|
||||
// simd tx bank send --sign-mode direct --chain-id simd-testing testgen cosmos1qypqxpq9qcrsszg2pvxq6rs0zqg3yyc5lzv7xu 1234567ucosm -b block
|
||||
const testVectors = [
|
||||
{
|
||||
sequenceNumber: 0,
|
||||
signedTxBytes:
|
||||
"0a580a560a142f636f736d6f732e62616e6b2e4d736753656e64123e0a140d82b1e7c96dbfa42462fe612932e6bff111d51b12140102030405060708090a0b0c0d0e0f10111213141a100a0575636f736d12073132333435363712330a2b0a230a21034f04181eeba35391b858633a765c4a0c189697b40d216354d50890d350c7029012040a020801120410c09a0c1a40692d88f681d5d69924a53668e8ecec535ca0ca170d1febfb1dd87de9959b07340427d6bba22526d6c30cc622f27dc5eb1ce04cfc0ff98716154066ec69db62e5",
|
||||
signBytes:
|
||||
"0a580a560a142f636f736d6f732e62616e6b2e4d736753656e64123e0a140d82b1e7c96dbfa42462fe612932e6bff111d51b12140102030405060708090a0b0c0d0e0f10111213141a100a0575636f736d12073132333435363712330a2b0a230a21034f04181eeba35391b858633a765c4a0c189697b40d216354d50890d350c7029012040a020801120410c09a0c1a0c73696d642d74657374696e672001",
|
||||
signature:
|
||||
"692d88f681d5d69924a53668e8ecec535ca0ca170d1febfb1dd87de9959b07340427d6bba22526d6c30cc622f27dc5eb1ce04cfc0ff98716154066ec69db62e5",
|
||||
},
|
||||
|
||||
{
|
||||
sequenceNumber: 1,
|
||||
signedTxBytes:
|
||||
"0a580a560a142f636f736d6f732e62616e6b2e4d736753656e64123e0a140d82b1e7c96dbfa42462fe612932e6bff111d51b12140102030405060708090a0b0c0d0e0f10111213141a100a0575636f736d12073132333435363712330a2b0a230a21034f04181eeba35391b858633a765c4a0c189697b40d216354d50890d350c7029012040a020801120410c09a0c1a40811c3c7dd85b1478b15e3cc710503045559d805d2bf538e5015dbcd868a440a94c7fc0b12b755a838cc3f9b8245d9f926e0432d07ee97557cff7c50c73f64a58",
|
||||
signBytes:
|
||||
"0a580a560a142f636f736d6f732e62616e6b2e4d736753656e64123e0a140d82b1e7c96dbfa42462fe612932e6bff111d51b12140102030405060708090a0b0c0d0e0f10111213141a100a0575636f736d12073132333435363712330a2b0a230a21034f04181eeba35391b858633a765c4a0c189697b40d216354d50890d350c7029012040a020801120410c09a0c1a0c73696d642d74657374696e6720012801",
|
||||
signature:
|
||||
"811c3c7dd85b1478b15e3cc710503045559d805d2bf538e5015dbcd868a440a94c7fc0b12b755a838cc3f9b8245d9f926e0432d07ee97557cff7c50c73f64a58",
|
||||
},
|
||||
|
||||
{
|
||||
sequenceNumber: 2,
|
||||
signedTxBytes:
|
||||
"0a580a560a142f636f736d6f732e62616e6b2e4d736753656e64123e0a140d82b1e7c96dbfa42462fe612932e6bff111d51b12140102030405060708090a0b0c0d0e0f10111213141a100a0575636f736d12073132333435363712330a2b0a230a21034f04181eeba35391b858633a765c4a0c189697b40d216354d50890d350c7029012040a020801120410c09a0c1a405e2e11567c181db4f38788ff6d417b1f7d147f3d6bd8274989bf181c35b3fb97218f64172030dd5a84dd38933765609d70771cbba60168d8ded611f14ec4fb12",
|
||||
signBytes:
|
||||
"0a580a560a142f636f736d6f732e62616e6b2e4d736753656e64123e0a140d82b1e7c96dbfa42462fe612932e6bff111d51b12140102030405060708090a0b0c0d0e0f10111213141a100a0575636f736d12073132333435363712330a2b0a230a21034f04181eeba35391b858633a765c4a0c189697b40d216354d50890d350c7029012040a020801120410c09a0c1a0c73696d642d74657374696e6720012802",
|
||||
signature:
|
||||
"5e2e11567c181db4f38788ff6d417b1f7d147f3d6bd8274989bf181c35b3fb97218f64172030dd5a84dd38933765609d70771cbba60168d8ded611f14ec4fb12",
|
||||
},
|
||||
];
|
||||
|
||||
describe("signing demo", () => {
|
||||
const chainId = "simd-testing";
|
||||
const toAddress = Uint8Array.from({ length: 20 }, (_, i) => i + 1);
|
||||
|
||||
const sendAmount = "1234567";
|
||||
const sendDenom = "ucosm";
|
||||
const gasLimit = 200000;
|
||||
|
||||
it("correctly parses test vectors", async () => {
|
||||
const wallet = await Secp256k1Wallet.fromMnemonic(faucet.mnemonic);
|
||||
const [{ address, pubkey: pubkeyBytes }] = await wallet.getAccounts();
|
||||
|
||||
testVectors.forEach(({ signedTxBytes }) => {
|
||||
const parsedTestTx = Tx.decode(fromHex(signedTxBytes));
|
||||
expect(parsedTestTx.signatures.length).toEqual(1);
|
||||
expect(parsedTestTx.authInfo?.signerInfos?.length).toEqual(1);
|
||||
expect(parsedTestTx.authInfo?.signerInfos![0].publicKey!.secp256k1).toEqual(pubkeyBytes);
|
||||
expect(parsedTestTx.authInfo?.signerInfos![0].modeInfo!.single!.mode).toEqual(
|
||||
cosmos.tx.signing.SignMode.SIGN_MODE_DIRECT,
|
||||
);
|
||||
expect(parsedTestTx.authInfo?.fee!.amount).toEqual([]);
|
||||
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);
|
||||
|
||||
const parsedTestTxMsg = defaultRegistry.decode({
|
||||
typeUrl: parsedTestTx.body!.messages![0].type_url!,
|
||||
value: parsedTestTx.body!.messages![0].value!,
|
||||
});
|
||||
expect(parsedTestTxMsg.from_address).toEqual(Bech32.decode(address).data);
|
||||
expect(parsedTestTxMsg.to_address).toEqual(toAddress);
|
||||
expect(parsedTestTxMsg.amount.length).toEqual(1);
|
||||
expect(parsedTestTxMsg.amount[0].denom).toEqual(sendDenom);
|
||||
expect(parsedTestTxMsg.amount[0].amount).toEqual(sendAmount);
|
||||
});
|
||||
});
|
||||
|
||||
it("correctly generates test vectors", async () => {
|
||||
const myRegistry = new Registry();
|
||||
const wallet = await Secp256k1Wallet.fromMnemonic(faucet.mnemonic);
|
||||
const [{ address, pubkey: pubkeyBytes }] = await wallet.getAccounts();
|
||||
const publicKey = PublicKey.create({
|
||||
secp256k1: pubkeyBytes,
|
||||
});
|
||||
|
||||
const txBodyFields: TxBodyValue = {
|
||||
messages: [
|
||||
{
|
||||
typeUrl: "/cosmos.bank.MsgSend",
|
||||
value: {
|
||||
fromAddress: Bech32.decode(address).data,
|
||||
toAddress: toAddress,
|
||||
amount: [
|
||||
{
|
||||
denom: sendDenom,
|
||||
amount: sendAmount,
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
],
|
||||
};
|
||||
const txBodyBytes = myRegistry.encode({
|
||||
typeUrl: "/cosmos.tx.TxBody",
|
||||
value: txBodyFields,
|
||||
});
|
||||
const txBody = TxBody.decode(txBodyBytes);
|
||||
|
||||
const authInfo = {
|
||||
signerInfos: [
|
||||
{
|
||||
publicKey: publicKey,
|
||||
modeInfo: {
|
||||
single: {
|
||||
mode: cosmos.tx.signing.SignMode.SIGN_MODE_DIRECT,
|
||||
},
|
||||
},
|
||||
},
|
||||
],
|
||||
fee: {
|
||||
gasLimit: gasLimit,
|
||||
},
|
||||
};
|
||||
const authInfoBytes = Uint8Array.from(AuthInfo.encode(authInfo).finish());
|
||||
const accountNumber = 1;
|
||||
|
||||
await Promise.all(
|
||||
testVectors.map(async ({ sequenceNumber, signBytes, signedTxBytes }) => {
|
||||
const signDoc = SignDoc.create(
|
||||
omitDefaults({
|
||||
bodyBytes: txBodyBytes,
|
||||
authInfoBytes: authInfoBytes,
|
||||
chainId: chainId,
|
||||
accountNumber: accountNumber,
|
||||
accountSequence: sequenceNumber,
|
||||
}),
|
||||
);
|
||||
const signDocBytes = Uint8Array.from(SignDoc.encode(signDoc).finish());
|
||||
expect(toHex(signDocBytes)).toEqual(signBytes);
|
||||
|
||||
const signature = await wallet.sign(address, signDocBytes);
|
||||
const txRaw = Tx.create({
|
||||
body: txBody,
|
||||
authInfo: authInfo,
|
||||
signatures: [fromBase64(signature.signature)],
|
||||
});
|
||||
const txRawBytes = Uint8Array.from(Tx.encode(txRaw).finish());
|
||||
const txBytesHex = toHex(txRawBytes);
|
||||
expect(txBytesHex).toEqual(signedTxBytes);
|
||||
}),
|
||||
);
|
||||
});
|
||||
});
|
11
packages/proto-signing/types/adr27.d.ts
vendored
Normal file
11
packages/proto-signing/types/adr27.d.ts
vendored
Normal file
@ -0,0 +1,11 @@
|
||||
/**
|
||||
* Converts default values to null in order to tell protobuf.js
|
||||
* to not serialize them.
|
||||
*
|
||||
* @see https://github.com/cosmos/cosmos-sdk/pull/6979
|
||||
*/
|
||||
export declare function omitDefault<T>(input: T): T | null;
|
||||
/**
|
||||
* Walks through a potentially nested object and calls omitDefault on each element.
|
||||
*/
|
||||
export declare function omitDefaults(input: any): any;
|
@ -473,6 +473,268 @@ export namespace cosmos {
|
||||
public static decode(r: $protobuf.Reader | Uint8Array, l?: number): cosmos.TxData;
|
||||
}
|
||||
|
||||
/** Properties of a TxResponse. */
|
||||
interface ITxResponse {
|
||||
/** TxResponse height */
|
||||
height?: number | Long | null;
|
||||
|
||||
/** TxResponse txhash */
|
||||
txhash?: string | null;
|
||||
|
||||
/** TxResponse codespace */
|
||||
codespace?: string | null;
|
||||
|
||||
/** TxResponse code */
|
||||
code?: number | null;
|
||||
|
||||
/** TxResponse data */
|
||||
data?: string | null;
|
||||
|
||||
/** TxResponse rawLog */
|
||||
rawLog?: string | null;
|
||||
|
||||
/** TxResponse logs */
|
||||
logs?: cosmos.IABCIMessageLog[] | null;
|
||||
|
||||
/** TxResponse info */
|
||||
info?: string | null;
|
||||
|
||||
/** TxResponse gasWanted */
|
||||
gasWanted?: number | Long | null;
|
||||
|
||||
/** TxResponse gasUsed */
|
||||
gasUsed?: number | Long | null;
|
||||
|
||||
/** TxResponse tx */
|
||||
tx?: google.protobuf.IAny | null;
|
||||
|
||||
/** TxResponse timestamp */
|
||||
timestamp?: string | null;
|
||||
}
|
||||
|
||||
/** Represents a TxResponse. */
|
||||
class TxResponse implements ITxResponse {
|
||||
/**
|
||||
* Constructs a new TxResponse.
|
||||
* @param [p] Properties to set
|
||||
*/
|
||||
constructor(p?: cosmos.ITxResponse);
|
||||
|
||||
/** TxResponse height. */
|
||||
public height: number | Long;
|
||||
|
||||
/** TxResponse txhash. */
|
||||
public txhash: string;
|
||||
|
||||
/** TxResponse codespace. */
|
||||
public codespace: string;
|
||||
|
||||
/** TxResponse code. */
|
||||
public code: number;
|
||||
|
||||
/** TxResponse data. */
|
||||
public data: string;
|
||||
|
||||
/** TxResponse rawLog. */
|
||||
public rawLog: string;
|
||||
|
||||
/** TxResponse logs. */
|
||||
public logs: cosmos.IABCIMessageLog[];
|
||||
|
||||
/** TxResponse info. */
|
||||
public info: string;
|
||||
|
||||
/** TxResponse gasWanted. */
|
||||
public gasWanted: number | Long;
|
||||
|
||||
/** TxResponse gasUsed. */
|
||||
public gasUsed: number | Long;
|
||||
|
||||
/** TxResponse tx. */
|
||||
public tx?: google.protobuf.IAny | null;
|
||||
|
||||
/** TxResponse timestamp. */
|
||||
public timestamp: string;
|
||||
|
||||
/**
|
||||
* Creates a new TxResponse instance using the specified properties.
|
||||
* @param [properties] Properties to set
|
||||
* @returns TxResponse instance
|
||||
*/
|
||||
public static create(properties?: cosmos.ITxResponse): cosmos.TxResponse;
|
||||
|
||||
/**
|
||||
* Encodes the specified TxResponse message. Does not implicitly {@link cosmos.TxResponse.verify|verify} messages.
|
||||
* @param m TxResponse message or plain object to encode
|
||||
* @param [w] Writer to encode to
|
||||
* @returns Writer
|
||||
*/
|
||||
public static encode(m: cosmos.ITxResponse, w?: $protobuf.Writer): $protobuf.Writer;
|
||||
|
||||
/**
|
||||
* Decodes a TxResponse message from the specified reader or buffer.
|
||||
* @param r Reader or buffer to decode from
|
||||
* @param [l] Message length if known beforehand
|
||||
* @returns TxResponse
|
||||
* @throws {Error} If the payload is not a reader or valid buffer
|
||||
* @throws {$protobuf.util.ProtocolError} If required fields are missing
|
||||
*/
|
||||
public static decode(r: $protobuf.Reader | Uint8Array, l?: number): cosmos.TxResponse;
|
||||
}
|
||||
|
||||
/** Properties of a ABCIMessageLog. */
|
||||
interface IABCIMessageLog {
|
||||
/** ABCIMessageLog msgIndex */
|
||||
msgIndex?: number | null;
|
||||
|
||||
/** ABCIMessageLog log */
|
||||
log?: string | null;
|
||||
|
||||
/** ABCIMessageLog events */
|
||||
events?: cosmos.IStringEvent[] | null;
|
||||
}
|
||||
|
||||
/** Represents a ABCIMessageLog. */
|
||||
class ABCIMessageLog implements IABCIMessageLog {
|
||||
/**
|
||||
* Constructs a new ABCIMessageLog.
|
||||
* @param [p] Properties to set
|
||||
*/
|
||||
constructor(p?: cosmos.IABCIMessageLog);
|
||||
|
||||
/** ABCIMessageLog msgIndex. */
|
||||
public msgIndex: number;
|
||||
|
||||
/** ABCIMessageLog log. */
|
||||
public log: string;
|
||||
|
||||
/** ABCIMessageLog events. */
|
||||
public events: cosmos.IStringEvent[];
|
||||
|
||||
/**
|
||||
* Creates a new ABCIMessageLog instance using the specified properties.
|
||||
* @param [properties] Properties to set
|
||||
* @returns ABCIMessageLog instance
|
||||
*/
|
||||
public static create(properties?: cosmos.IABCIMessageLog): cosmos.ABCIMessageLog;
|
||||
|
||||
/**
|
||||
* Encodes the specified ABCIMessageLog message. Does not implicitly {@link cosmos.ABCIMessageLog.verify|verify} messages.
|
||||
* @param m ABCIMessageLog message or plain object to encode
|
||||
* @param [w] Writer to encode to
|
||||
* @returns Writer
|
||||
*/
|
||||
public static encode(m: cosmos.IABCIMessageLog, w?: $protobuf.Writer): $protobuf.Writer;
|
||||
|
||||
/**
|
||||
* Decodes a ABCIMessageLog message from the specified reader or buffer.
|
||||
* @param r Reader or buffer to decode from
|
||||
* @param [l] Message length if known beforehand
|
||||
* @returns ABCIMessageLog
|
||||
* @throws {Error} If the payload is not a reader or valid buffer
|
||||
* @throws {$protobuf.util.ProtocolError} If required fields are missing
|
||||
*/
|
||||
public static decode(r: $protobuf.Reader | Uint8Array, l?: number): cosmos.ABCIMessageLog;
|
||||
}
|
||||
|
||||
/** Properties of a StringEvent. */
|
||||
interface IStringEvent {
|
||||
/** StringEvent type */
|
||||
type?: string | null;
|
||||
|
||||
/** StringEvent attributes */
|
||||
attributes?: cosmos.IAttribute[] | null;
|
||||
}
|
||||
|
||||
/** Represents a StringEvent. */
|
||||
class StringEvent implements IStringEvent {
|
||||
/**
|
||||
* Constructs a new StringEvent.
|
||||
* @param [p] Properties to set
|
||||
*/
|
||||
constructor(p?: cosmos.IStringEvent);
|
||||
|
||||
/** StringEvent type. */
|
||||
public type: string;
|
||||
|
||||
/** StringEvent attributes. */
|
||||
public attributes: cosmos.IAttribute[];
|
||||
|
||||
/**
|
||||
* Creates a new StringEvent instance using the specified properties.
|
||||
* @param [properties] Properties to set
|
||||
* @returns StringEvent instance
|
||||
*/
|
||||
public static create(properties?: cosmos.IStringEvent): cosmos.StringEvent;
|
||||
|
||||
/**
|
||||
* Encodes the specified StringEvent message. Does not implicitly {@link cosmos.StringEvent.verify|verify} messages.
|
||||
* @param m StringEvent message or plain object to encode
|
||||
* @param [w] Writer to encode to
|
||||
* @returns Writer
|
||||
*/
|
||||
public static encode(m: cosmos.IStringEvent, w?: $protobuf.Writer): $protobuf.Writer;
|
||||
|
||||
/**
|
||||
* Decodes a StringEvent message from the specified reader or buffer.
|
||||
* @param r Reader or buffer to decode from
|
||||
* @param [l] Message length if known beforehand
|
||||
* @returns StringEvent
|
||||
* @throws {Error} If the payload is not a reader or valid buffer
|
||||
* @throws {$protobuf.util.ProtocolError} If required fields are missing
|
||||
*/
|
||||
public static decode(r: $protobuf.Reader | Uint8Array, l?: number): cosmos.StringEvent;
|
||||
}
|
||||
|
||||
/** Properties of an Attribute. */
|
||||
interface IAttribute {
|
||||
/** Attribute key */
|
||||
key?: string | null;
|
||||
|
||||
/** Attribute value */
|
||||
value?: string | null;
|
||||
}
|
||||
|
||||
/** Represents an Attribute. */
|
||||
class Attribute implements IAttribute {
|
||||
/**
|
||||
* Constructs a new Attribute.
|
||||
* @param [p] Properties to set
|
||||
*/
|
||||
constructor(p?: cosmos.IAttribute);
|
||||
|
||||
/** Attribute key. */
|
||||
public key: string;
|
||||
|
||||
/** Attribute value. */
|
||||
public value: string;
|
||||
|
||||
/**
|
||||
* Creates a new Attribute instance using the specified properties.
|
||||
* @param [properties] Properties to set
|
||||
* @returns Attribute instance
|
||||
*/
|
||||
public static create(properties?: cosmos.IAttribute): cosmos.Attribute;
|
||||
|
||||
/**
|
||||
* Encodes the specified Attribute message. Does not implicitly {@link cosmos.Attribute.verify|verify} messages.
|
||||
* @param m Attribute message or plain object to encode
|
||||
* @param [w] Writer to encode to
|
||||
* @returns Writer
|
||||
*/
|
||||
public static encode(m: cosmos.IAttribute, w?: $protobuf.Writer): $protobuf.Writer;
|
||||
|
||||
/**
|
||||
* Decodes an Attribute message from the specified reader or buffer.
|
||||
* @param r Reader or buffer to decode from
|
||||
* @param [l] Message length if known beforehand
|
||||
* @returns Attribute
|
||||
* @throws {Error} If the payload is not a reader or valid buffer
|
||||
* @throws {$protobuf.util.ProtocolError} If required fields are missing
|
||||
*/
|
||||
public static decode(r: $protobuf.Reader | Uint8Array, l?: number): cosmos.Attribute;
|
||||
}
|
||||
|
||||
/** Namespace bank. */
|
||||
namespace bank {
|
||||
/** Properties of a Params. */
|
||||
@ -817,6 +1079,122 @@ export namespace cosmos {
|
||||
*/
|
||||
public static decode(r: $protobuf.Reader | Uint8Array, l?: number): cosmos.bank.Supply;
|
||||
}
|
||||
|
||||
/** Properties of a DenomUnits. */
|
||||
interface IDenomUnits {
|
||||
/** DenomUnits denom */
|
||||
denom?: string | null;
|
||||
|
||||
/** DenomUnits exponent */
|
||||
exponent?: number | null;
|
||||
|
||||
/** DenomUnits aliases */
|
||||
aliases?: string[] | null;
|
||||
}
|
||||
|
||||
/** Represents a DenomUnits. */
|
||||
class DenomUnits implements IDenomUnits {
|
||||
/**
|
||||
* Constructs a new DenomUnits.
|
||||
* @param [p] Properties to set
|
||||
*/
|
||||
constructor(p?: cosmos.bank.IDenomUnits);
|
||||
|
||||
/** DenomUnits denom. */
|
||||
public denom: string;
|
||||
|
||||
/** DenomUnits exponent. */
|
||||
public exponent: number;
|
||||
|
||||
/** DenomUnits aliases. */
|
||||
public aliases: string[];
|
||||
|
||||
/**
|
||||
* Creates a new DenomUnits instance using the specified properties.
|
||||
* @param [properties] Properties to set
|
||||
* @returns DenomUnits instance
|
||||
*/
|
||||
public static create(properties?: cosmos.bank.IDenomUnits): cosmos.bank.DenomUnits;
|
||||
|
||||
/**
|
||||
* Encodes the specified DenomUnits message. Does not implicitly {@link cosmos.bank.DenomUnits.verify|verify} messages.
|
||||
* @param m DenomUnits message or plain object to encode
|
||||
* @param [w] Writer to encode to
|
||||
* @returns Writer
|
||||
*/
|
||||
public static encode(m: cosmos.bank.IDenomUnits, w?: $protobuf.Writer): $protobuf.Writer;
|
||||
|
||||
/**
|
||||
* Decodes a DenomUnits message from the specified reader or buffer.
|
||||
* @param r Reader or buffer to decode from
|
||||
* @param [l] Message length if known beforehand
|
||||
* @returns DenomUnits
|
||||
* @throws {Error} If the payload is not a reader or valid buffer
|
||||
* @throws {$protobuf.util.ProtocolError} If required fields are missing
|
||||
*/
|
||||
public static decode(r: $protobuf.Reader | Uint8Array, l?: number): cosmos.bank.DenomUnits;
|
||||
}
|
||||
|
||||
/** Properties of a Metadata. */
|
||||
interface IMetadata {
|
||||
/** Metadata description */
|
||||
description?: string | null;
|
||||
|
||||
/** Metadata denomUnits */
|
||||
denomUnits?: cosmos.bank.IDenomUnits[] | null;
|
||||
|
||||
/** Metadata base */
|
||||
base?: string | null;
|
||||
|
||||
/** Metadata display */
|
||||
display?: string | null;
|
||||
}
|
||||
|
||||
/** Represents a Metadata. */
|
||||
class Metadata implements IMetadata {
|
||||
/**
|
||||
* Constructs a new Metadata.
|
||||
* @param [p] Properties to set
|
||||
*/
|
||||
constructor(p?: cosmos.bank.IMetadata);
|
||||
|
||||
/** Metadata description. */
|
||||
public description: string;
|
||||
|
||||
/** Metadata denomUnits. */
|
||||
public denomUnits: cosmos.bank.IDenomUnits[];
|
||||
|
||||
/** Metadata base. */
|
||||
public base: string;
|
||||
|
||||
/** Metadata display. */
|
||||
public display: string;
|
||||
|
||||
/**
|
||||
* Creates a new Metadata instance using the specified properties.
|
||||
* @param [properties] Properties to set
|
||||
* @returns Metadata instance
|
||||
*/
|
||||
public static create(properties?: cosmos.bank.IMetadata): cosmos.bank.Metadata;
|
||||
|
||||
/**
|
||||
* Encodes the specified Metadata message. Does not implicitly {@link cosmos.bank.Metadata.verify|verify} messages.
|
||||
* @param m Metadata message or plain object to encode
|
||||
* @param [w] Writer to encode to
|
||||
* @returns Writer
|
||||
*/
|
||||
public static encode(m: cosmos.bank.IMetadata, w?: $protobuf.Writer): $protobuf.Writer;
|
||||
|
||||
/**
|
||||
* Decodes a Metadata message from the specified reader or buffer.
|
||||
* @param r Reader or buffer to decode from
|
||||
* @param [l] Message length if known beforehand
|
||||
* @returns Metadata
|
||||
* @throws {Error} If the payload is not a reader or valid buffer
|
||||
* @throws {$protobuf.util.ProtocolError} If required fields are missing
|
||||
*/
|
||||
public static decode(r: $protobuf.Reader | Uint8Array, l?: number): cosmos.bank.Metadata;
|
||||
}
|
||||
}
|
||||
|
||||
/** Namespace crypto. */
|
||||
@ -1592,6 +1970,292 @@ export namespace cosmos {
|
||||
SIGN_MODE_TEXTUAL = 2,
|
||||
SIGN_MODE_LEGACY_AMINO_JSON = 127,
|
||||
}
|
||||
|
||||
/** Properties of a SignatureDescriptors. */
|
||||
interface ISignatureDescriptors {
|
||||
/** SignatureDescriptors signatures */
|
||||
signatures?: cosmos.tx.signing.ISignatureDescriptor[] | null;
|
||||
}
|
||||
|
||||
/** Represents a SignatureDescriptors. */
|
||||
class SignatureDescriptors implements ISignatureDescriptors {
|
||||
/**
|
||||
* Constructs a new SignatureDescriptors.
|
||||
* @param [p] Properties to set
|
||||
*/
|
||||
constructor(p?: cosmos.tx.signing.ISignatureDescriptors);
|
||||
|
||||
/** SignatureDescriptors signatures. */
|
||||
public signatures: cosmos.tx.signing.ISignatureDescriptor[];
|
||||
|
||||
/**
|
||||
* Creates a new SignatureDescriptors instance using the specified properties.
|
||||
* @param [properties] Properties to set
|
||||
* @returns SignatureDescriptors instance
|
||||
*/
|
||||
public static create(
|
||||
properties?: cosmos.tx.signing.ISignatureDescriptors,
|
||||
): cosmos.tx.signing.SignatureDescriptors;
|
||||
|
||||
/**
|
||||
* Encodes the specified SignatureDescriptors message. Does not implicitly {@link cosmos.tx.signing.SignatureDescriptors.verify|verify} messages.
|
||||
* @param m SignatureDescriptors message or plain object to encode
|
||||
* @param [w] Writer to encode to
|
||||
* @returns Writer
|
||||
*/
|
||||
public static encode(
|
||||
m: cosmos.tx.signing.ISignatureDescriptors,
|
||||
w?: $protobuf.Writer,
|
||||
): $protobuf.Writer;
|
||||
|
||||
/**
|
||||
* Decodes a SignatureDescriptors message from the specified reader or buffer.
|
||||
* @param r Reader or buffer to decode from
|
||||
* @param [l] Message length if known beforehand
|
||||
* @returns SignatureDescriptors
|
||||
* @throws {Error} If the payload is not a reader or valid buffer
|
||||
* @throws {$protobuf.util.ProtocolError} If required fields are missing
|
||||
*/
|
||||
public static decode(
|
||||
r: $protobuf.Reader | Uint8Array,
|
||||
l?: number,
|
||||
): cosmos.tx.signing.SignatureDescriptors;
|
||||
}
|
||||
|
||||
/** Properties of a SignatureDescriptor. */
|
||||
interface ISignatureDescriptor {
|
||||
/** SignatureDescriptor publicKey */
|
||||
publicKey?: cosmos.crypto.IPublicKey | null;
|
||||
|
||||
/** SignatureDescriptor data */
|
||||
data?: cosmos.tx.signing.SignatureDescriptor.IData | null;
|
||||
}
|
||||
|
||||
/** Represents a SignatureDescriptor. */
|
||||
class SignatureDescriptor implements ISignatureDescriptor {
|
||||
/**
|
||||
* Constructs a new SignatureDescriptor.
|
||||
* @param [p] Properties to set
|
||||
*/
|
||||
constructor(p?: cosmos.tx.signing.ISignatureDescriptor);
|
||||
|
||||
/** SignatureDescriptor publicKey. */
|
||||
public publicKey?: cosmos.crypto.IPublicKey | null;
|
||||
|
||||
/** SignatureDescriptor data. */
|
||||
public data?: cosmos.tx.signing.SignatureDescriptor.IData | null;
|
||||
|
||||
/**
|
||||
* Creates a new SignatureDescriptor instance using the specified properties.
|
||||
* @param [properties] Properties to set
|
||||
* @returns SignatureDescriptor instance
|
||||
*/
|
||||
public static create(
|
||||
properties?: cosmos.tx.signing.ISignatureDescriptor,
|
||||
): cosmos.tx.signing.SignatureDescriptor;
|
||||
|
||||
/**
|
||||
* Encodes the specified SignatureDescriptor message. Does not implicitly {@link cosmos.tx.signing.SignatureDescriptor.verify|verify} messages.
|
||||
* @param m SignatureDescriptor message or plain object to encode
|
||||
* @param [w] Writer to encode to
|
||||
* @returns Writer
|
||||
*/
|
||||
public static encode(
|
||||
m: cosmos.tx.signing.ISignatureDescriptor,
|
||||
w?: $protobuf.Writer,
|
||||
): $protobuf.Writer;
|
||||
|
||||
/**
|
||||
* Decodes a SignatureDescriptor message from the specified reader or buffer.
|
||||
* @param r Reader or buffer to decode from
|
||||
* @param [l] Message length if known beforehand
|
||||
* @returns SignatureDescriptor
|
||||
* @throws {Error} If the payload is not a reader or valid buffer
|
||||
* @throws {$protobuf.util.ProtocolError} If required fields are missing
|
||||
*/
|
||||
public static decode(
|
||||
r: $protobuf.Reader | Uint8Array,
|
||||
l?: number,
|
||||
): cosmos.tx.signing.SignatureDescriptor;
|
||||
}
|
||||
|
||||
namespace SignatureDescriptor {
|
||||
/** Properties of a Data. */
|
||||
interface IData {
|
||||
/** Data single */
|
||||
single?: cosmos.tx.signing.SignatureDescriptor.Data.ISingle | null;
|
||||
|
||||
/** Data multi */
|
||||
multi?: cosmos.tx.signing.SignatureDescriptor.Data.IMulti | null;
|
||||
}
|
||||
|
||||
/** Represents a Data. */
|
||||
class Data implements IData {
|
||||
/**
|
||||
* Constructs a new Data.
|
||||
* @param [p] Properties to set
|
||||
*/
|
||||
constructor(p?: cosmos.tx.signing.SignatureDescriptor.IData);
|
||||
|
||||
/** Data single. */
|
||||
public single?: cosmos.tx.signing.SignatureDescriptor.Data.ISingle | null;
|
||||
|
||||
/** Data multi. */
|
||||
public multi?: cosmos.tx.signing.SignatureDescriptor.Data.IMulti | null;
|
||||
|
||||
/** Data sum. */
|
||||
public sum?: "single" | "multi";
|
||||
|
||||
/**
|
||||
* Creates a new Data instance using the specified properties.
|
||||
* @param [properties] Properties to set
|
||||
* @returns Data instance
|
||||
*/
|
||||
public static create(
|
||||
properties?: cosmos.tx.signing.SignatureDescriptor.IData,
|
||||
): cosmos.tx.signing.SignatureDescriptor.Data;
|
||||
|
||||
/**
|
||||
* Encodes the specified Data message. Does not implicitly {@link cosmos.tx.signing.SignatureDescriptor.Data.verify|verify} messages.
|
||||
* @param m Data message or plain object to encode
|
||||
* @param [w] Writer to encode to
|
||||
* @returns Writer
|
||||
*/
|
||||
public static encode(
|
||||
m: cosmos.tx.signing.SignatureDescriptor.IData,
|
||||
w?: $protobuf.Writer,
|
||||
): $protobuf.Writer;
|
||||
|
||||
/**
|
||||
* Decodes a Data message from the specified reader or buffer.
|
||||
* @param r Reader or buffer to decode from
|
||||
* @param [l] Message length if known beforehand
|
||||
* @returns Data
|
||||
* @throws {Error} If the payload is not a reader or valid buffer
|
||||
* @throws {$protobuf.util.ProtocolError} If required fields are missing
|
||||
*/
|
||||
public static decode(
|
||||
r: $protobuf.Reader | Uint8Array,
|
||||
l?: number,
|
||||
): cosmos.tx.signing.SignatureDescriptor.Data;
|
||||
}
|
||||
|
||||
namespace Data {
|
||||
/** Properties of a Single. */
|
||||
interface ISingle {
|
||||
/** Single mode */
|
||||
mode?: cosmos.tx.signing.SignMode | null;
|
||||
|
||||
/** Single signature */
|
||||
signature?: Uint8Array | null;
|
||||
}
|
||||
|
||||
/** Represents a Single. */
|
||||
class Single implements ISingle {
|
||||
/**
|
||||
* Constructs a new Single.
|
||||
* @param [p] Properties to set
|
||||
*/
|
||||
constructor(p?: cosmos.tx.signing.SignatureDescriptor.Data.ISingle);
|
||||
|
||||
/** Single mode. */
|
||||
public mode: cosmos.tx.signing.SignMode;
|
||||
|
||||
/** Single signature. */
|
||||
public signature: Uint8Array;
|
||||
|
||||
/**
|
||||
* Creates a new Single instance using the specified properties.
|
||||
* @param [properties] Properties to set
|
||||
* @returns Single instance
|
||||
*/
|
||||
public static create(
|
||||
properties?: cosmos.tx.signing.SignatureDescriptor.Data.ISingle,
|
||||
): cosmos.tx.signing.SignatureDescriptor.Data.Single;
|
||||
|
||||
/**
|
||||
* Encodes the specified Single message. Does not implicitly {@link cosmos.tx.signing.SignatureDescriptor.Data.Single.verify|verify} messages.
|
||||
* @param m Single message or plain object to encode
|
||||
* @param [w] Writer to encode to
|
||||
* @returns Writer
|
||||
*/
|
||||
public static encode(
|
||||
m: cosmos.tx.signing.SignatureDescriptor.Data.ISingle,
|
||||
w?: $protobuf.Writer,
|
||||
): $protobuf.Writer;
|
||||
|
||||
/**
|
||||
* Decodes a Single message from the specified reader or buffer.
|
||||
* @param r Reader or buffer to decode from
|
||||
* @param [l] Message length if known beforehand
|
||||
* @returns Single
|
||||
* @throws {Error} If the payload is not a reader or valid buffer
|
||||
* @throws {$protobuf.util.ProtocolError} If required fields are missing
|
||||
*/
|
||||
public static decode(
|
||||
r: $protobuf.Reader | Uint8Array,
|
||||
l?: number,
|
||||
): cosmos.tx.signing.SignatureDescriptor.Data.Single;
|
||||
}
|
||||
|
||||
/** Properties of a Multi. */
|
||||
interface IMulti {
|
||||
/** Multi bitarray */
|
||||
bitarray?: cosmos.crypto.ICompactBitArray | null;
|
||||
|
||||
/** Multi signatures */
|
||||
signatures?: cosmos.tx.signing.SignatureDescriptor.IData[] | null;
|
||||
}
|
||||
|
||||
/** Represents a Multi. */
|
||||
class Multi implements IMulti {
|
||||
/**
|
||||
* Constructs a new Multi.
|
||||
* @param [p] Properties to set
|
||||
*/
|
||||
constructor(p?: cosmos.tx.signing.SignatureDescriptor.Data.IMulti);
|
||||
|
||||
/** Multi bitarray. */
|
||||
public bitarray?: cosmos.crypto.ICompactBitArray | null;
|
||||
|
||||
/** Multi signatures. */
|
||||
public signatures: cosmos.tx.signing.SignatureDescriptor.IData[];
|
||||
|
||||
/**
|
||||
* Creates a new Multi instance using the specified properties.
|
||||
* @param [properties] Properties to set
|
||||
* @returns Multi instance
|
||||
*/
|
||||
public static create(
|
||||
properties?: cosmos.tx.signing.SignatureDescriptor.Data.IMulti,
|
||||
): cosmos.tx.signing.SignatureDescriptor.Data.Multi;
|
||||
|
||||
/**
|
||||
* Encodes the specified Multi message. Does not implicitly {@link cosmos.tx.signing.SignatureDescriptor.Data.Multi.verify|verify} messages.
|
||||
* @param m Multi message or plain object to encode
|
||||
* @param [w] Writer to encode to
|
||||
* @returns Writer
|
||||
*/
|
||||
public static encode(
|
||||
m: cosmos.tx.signing.SignatureDescriptor.Data.IMulti,
|
||||
w?: $protobuf.Writer,
|
||||
): $protobuf.Writer;
|
||||
|
||||
/**
|
||||
* Decodes a Multi message from the specified reader or buffer.
|
||||
* @param r Reader or buffer to decode from
|
||||
* @param [l] Message length if known beforehand
|
||||
* @returns Multi
|
||||
* @throws {Error} If the payload is not a reader or valid buffer
|
||||
* @throws {$protobuf.util.ProtocolError} If required fields are missing
|
||||
*/
|
||||
public static decode(
|
||||
r: $protobuf.Reader | Uint8Array,
|
||||
l?: number,
|
||||
): cosmos.tx.signing.SignatureDescriptor.Data.Multi;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user