//@ts-nocheck
import { BinaryReader, BinaryWriter } from "../../../binary";
import { isSet, bytesFromBase64, base64FromBytes } from "../../../helpers";
import { JsonSafe } from "../../../json-safe";
import { GlobalDecoderRegistry } from "../../../registry";
/**
* 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;
}
export interface PubKeyProtoMsg {
typeUrl: "/cosmos.crypto.secp256k1.PubKey";
value: Uint8Array;
}
/**
* 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 PubKeyAmino {
key?: string;
}
export interface PubKeyAminoMsg {
type: "cosmos-sdk/PubKey";
value: PubKeyAmino;
}
/**
* 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 PubKeySDKType {
key: Uint8Array;
}
/** PrivKey defines a secp256k1 private key. */
export interface PrivKey {
key: Uint8Array;
}
export interface PrivKeyProtoMsg {
typeUrl: "/cosmos.crypto.secp256k1.PrivKey";
value: Uint8Array;
}
/** PrivKey defines a secp256k1 private key. */
export interface PrivKeyAmino {
key?: string;
}
export interface PrivKeyAminoMsg {
type: "cosmos-sdk/PrivKey";
value: PrivKeyAmino;
}
/** PrivKey defines a secp256k1 private key. */
export interface PrivKeySDKType {
key: Uint8Array;
}
function createBasePubKey(): PubKey {
return {
key: new Uint8Array()
};
}
export const PubKey = {
typeUrl: "/cosmos.crypto.secp256k1.PubKey",
aminoType: "cosmos-sdk/PubKey",
is(o: any): o is PubKey {
return o && (o.$typeUrl === PubKey.typeUrl || o.key instanceof Uint8Array || typeof o.key === "string");
},
isSDK(o: any): o is PubKeySDKType {
return o && (o.$typeUrl === PubKey.typeUrl || o.key instanceof Uint8Array || typeof o.key === "string");
},
isAmino(o: any): o is PubKeyAmino {
return o && (o.$typeUrl === PubKey.typeUrl || o.key instanceof Uint8Array || typeof o.key === "string");
},
encode(message: PubKey, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter {
if (message.key.length !== 0) {
writer.uint32(10).bytes(message.key);
}
return writer;
},
decode(input: BinaryReader | Uint8Array, length?: number): PubKey {
const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
let end = length === undefined ? reader.len : reader.pos + length;
const message = createBasePubKey();
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 {
return {
key: isSet(object.key) ? bytesFromBase64(object.key) : new Uint8Array()
};
},
toJSON(message: PubKey): JsonSafe<PubKey> {
const obj: any = {};
message.key !== undefined && (obj.key = base64FromBytes(message.key !== undefined ? message.key : new Uint8Array()));
return obj;
},
fromPartial(object: Partial<PubKey>): PubKey {
const message = createBasePubKey();
message.key = object.key ?? new Uint8Array();
return message;
},
fromAmino(object: PubKeyAmino): PubKey {
const message = createBasePubKey();
if (object.key !== undefined && object.key !== null) {
message.key = bytesFromBase64(object.key);
}
return message;
},
toAmino(message: PubKey): PubKeyAmino {
const obj: any = {};
obj.key = message.key ? base64FromBytes(message.key) : undefined;
return obj;
},
fromAminoMsg(object: PubKeyAminoMsg): PubKey {
return PubKey.fromAmino(object.value);
},
toAminoMsg(message: PubKey): PubKeyAminoMsg {
return {
type: "cosmos-sdk/PubKey",
value: PubKey.toAmino(message)
};
},
fromProtoMsg(message: PubKeyProtoMsg): PubKey {
return PubKey.decode(message.value);
},
toProto(message: PubKey): Uint8Array {
return PubKey.encode(message).finish();
},
toProtoMsg(message: PubKey): PubKeyProtoMsg {
return {
typeUrl: "/cosmos.crypto.secp256k1.PubKey",
value: PubKey.encode(message).finish()
};
}
};
GlobalDecoderRegistry.register(PubKey.typeUrl, PubKey);
GlobalDecoderRegistry.registerAminoProtoMapping(PubKey.aminoType, PubKey.typeUrl);
function createBasePrivKey(): PrivKey {
return {
key: new Uint8Array()
};
}
export const PrivKey = {
typeUrl: "/cosmos.crypto.secp256k1.PrivKey",
aminoType: "cosmos-sdk/PrivKey",
is(o: any): o is PrivKey {
return o && (o.$typeUrl === PrivKey.typeUrl || o.key instanceof Uint8Array || typeof o.key === "string");
},
isSDK(o: any): o is PrivKeySDKType {
return o && (o.$typeUrl === PrivKey.typeUrl || o.key instanceof Uint8Array || typeof o.key === "string");
},
isAmino(o: any): o is PrivKeyAmino {
return o && (o.$typeUrl === PrivKey.typeUrl || o.key instanceof Uint8Array || typeof o.key === "string");
},
encode(message: PrivKey, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter {
if (message.key.length !== 0) {
writer.uint32(10).bytes(message.key);
}
return writer;
},
decode(input: BinaryReader | Uint8Array, length?: number): PrivKey {
const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
let end = length === undefined ? reader.len : reader.pos + length;
const message = createBasePrivKey();
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 {
return {
key: isSet(object.key) ? bytesFromBase64(object.key) : new Uint8Array()
};
},
toJSON(message: PrivKey): JsonSafe<PrivKey> {
const obj: any = {};
message.key !== undefined && (obj.key = base64FromBytes(message.key !== undefined ? message.key : new Uint8Array()));
return obj;
},
fromPartial(object: Partial<PrivKey>): PrivKey {
const message = createBasePrivKey();
message.key = object.key ?? new Uint8Array();
return message;
},
fromAmino(object: PrivKeyAmino): PrivKey {
const message = createBasePrivKey();
if (object.key !== undefined && object.key !== null) {
message.key = bytesFromBase64(object.key);
}
return message;
},
toAmino(message: PrivKey): PrivKeyAmino {
const obj: any = {};
obj.key = message.key ? base64FromBytes(message.key) : undefined;
return obj;
},
fromAminoMsg(object: PrivKeyAminoMsg): PrivKey {
return PrivKey.fromAmino(object.value);
},
toAminoMsg(message: PrivKey): PrivKeyAminoMsg {
return {
type: "cosmos-sdk/PrivKey",
value: PrivKey.toAmino(message)
};
},
fromProtoMsg(message: PrivKeyProtoMsg): PrivKey {
return PrivKey.decode(message.value);
},
toProto(message: PrivKey): Uint8Array {
return PrivKey.encode(message).finish();
},
toProtoMsg(message: PrivKey): PrivKeyProtoMsg {
return {
typeUrl: "/cosmos.crypto.secp256k1.PrivKey",
value: PrivKey.encode(message).finish()
};
}
};
GlobalDecoderRegistry.register(PrivKey.typeUrl, PrivKey);
GlobalDecoderRegistry.registerAminoProtoMapping(PrivKey.aminoType, PrivKey.typeUrl);