Add types and methods for participants onboarding module (#12)

Part of [laconicd testnet validator enrollment](https://www.notion.so/laconicd-testnet-validator-enrollment-6fc1d3cafcc64fef8c5ed3affa27c675)

Co-authored-by: Isha Venikar <145848618+IshaVenikar@users.noreply.github.com>
Co-authored-by: Prathamesh Musale <prathamesh.musale0@gmail.com>
Reviewed-on: cerc-io/registry-sdk#12
Co-authored-by: Nabarun <nabarun@deepstacksoft.com>
Co-committed-by: Nabarun <nabarun@deepstacksoft.com>
This commit is contained in:
2024-07-16 08:33:41 +00:00
committed by ashwin
co-authored by Isha Venikar prathamesh
parent 25651a8e7a
commit 2757281e5b
21 changed files with 1376 additions and 22 deletions
@@ -0,0 +1,102 @@
/* eslint-disable */
import Long from "long";
import _m0 from "protobufjs/minimal";
export const protobufPackage = "cerc.onboarding.module.v1";
/**
* Module is the app config object of the module.
* Learn more: https://docs.cosmos.network/main/building-modules/depinject
*/
export interface Module {
authority: string;
}
function createBaseModule(): Module {
return { authority: "" };
}
export const Module = {
encode(
message: Module,
writer: _m0.Writer = _m0.Writer.create()
): _m0.Writer {
if (message.authority !== "") {
writer.uint32(10).string(message.authority);
}
return writer;
},
decode(input: _m0.Reader | Uint8Array, length?: number): Module {
const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);
let end = length === undefined ? reader.len : reader.pos + length;
const message = createBaseModule();
while (reader.pos < end) {
const tag = reader.uint32();
switch (tag >>> 3) {
case 1:
message.authority = reader.string();
break;
default:
reader.skipType(tag & 7);
break;
}
}
return message;
},
fromJSON(object: any): Module {
return {
authority: isSet(object.authority) ? String(object.authority) : "",
};
},
toJSON(message: Module): unknown {
const obj: any = {};
message.authority !== undefined && (obj.authority = message.authority);
return obj;
},
fromPartial<I extends Exact<DeepPartial<Module>, I>>(object: I): Module {
const message = createBaseModule();
message.authority = object.authority ?? "";
return message;
},
};
type Builtin =
| Date
| Function
| Uint8Array
| string
| number
| boolean
| undefined;
export type DeepPartial<T> = T extends Builtin
? T
: T extends Long
? string | number | Long
: T extends Array<infer U>
? Array<DeepPartial<U>>
: T extends ReadonlyArray<infer U>
? ReadonlyArray<DeepPartial<U>>
: T extends {}
? { [K in keyof T]?: DeepPartial<T[K]> }
: Partial<T>;
type KeysOfUnion<T> = T extends T ? keyof T : never;
export type Exact<P, I extends P> = P extends Builtin
? P
: P & { [K in keyof P]: Exact<P[K], I[K]> } & {
[K in Exclude<keyof I, KeysOfUnion<P>>]: never;
};
if (_m0.util.Long !== Long) {
_m0.util.Long = Long as any;
_m0.configure();
}
function isSet(value: any): boolean {
return value !== null && value !== undefined;
}
+129
View File
@@ -0,0 +1,129 @@
/* eslint-disable */
import { Params, Participant } from "./onboarding";
import Long from "long";
import _m0 from "protobufjs/minimal";
export const protobufPackage = "cerc.onboarding.v1";
/** GenesisState defines the onboarding module's genesis state. */
export interface GenesisState {
/** params defines all the parameters of the module. */
params?: Params;
/** participants defines all the participants */
participants: Participant[];
}
function createBaseGenesisState(): GenesisState {
return { params: undefined, participants: [] };
}
export const GenesisState = {
encode(
message: GenesisState,
writer: _m0.Writer = _m0.Writer.create()
): _m0.Writer {
if (message.params !== undefined) {
Params.encode(message.params, writer.uint32(10).fork()).ldelim();
}
for (const v of message.participants) {
Participant.encode(v!, writer.uint32(18).fork()).ldelim();
}
return writer;
},
decode(input: _m0.Reader | Uint8Array, length?: number): GenesisState {
const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);
let end = length === undefined ? reader.len : reader.pos + length;
const message = createBaseGenesisState();
while (reader.pos < end) {
const tag = reader.uint32();
switch (tag >>> 3) {
case 1:
message.params = Params.decode(reader, reader.uint32());
break;
case 2:
message.participants.push(
Participant.decode(reader, reader.uint32())
);
break;
default:
reader.skipType(tag & 7);
break;
}
}
return message;
},
fromJSON(object: any): GenesisState {
return {
params: isSet(object.params) ? Params.fromJSON(object.params) : undefined,
participants: Array.isArray(object?.participants)
? object.participants.map((e: any) => Participant.fromJSON(e))
: [],
};
},
toJSON(message: GenesisState): unknown {
const obj: any = {};
message.params !== undefined &&
(obj.params = message.params ? Params.toJSON(message.params) : undefined);
if (message.participants) {
obj.participants = message.participants.map((e) =>
e ? Participant.toJSON(e) : undefined
);
} else {
obj.participants = [];
}
return obj;
},
fromPartial<I extends Exact<DeepPartial<GenesisState>, I>>(
object: I
): GenesisState {
const message = createBaseGenesisState();
message.params =
object.params !== undefined && object.params !== null
? Params.fromPartial(object.params)
: undefined;
message.participants =
object.participants?.map((e) => Participant.fromPartial(e)) || [];
return message;
},
};
type Builtin =
| Date
| Function
| Uint8Array
| string
| number
| boolean
| undefined;
export type DeepPartial<T> = T extends Builtin
? T
: T extends Long
? string | number | Long
: T extends Array<infer U>
? Array<DeepPartial<U>>
: T extends ReadonlyArray<infer U>
? ReadonlyArray<DeepPartial<U>>
: T extends {}
? { [K in keyof T]?: DeepPartial<T[K]> }
: Partial<T>;
type KeysOfUnion<T> = T extends T ? keyof T : never;
export type Exact<P, I extends P> = P extends Builtin
? P
: P & { [K in keyof P]: Exact<P[K], I[K]> } & {
[K in Exclude<keyof I, KeysOfUnion<P>>]: never;
};
if (_m0.util.Long !== Long) {
_m0.util.Long = Long as any;
_m0.configure();
}
function isSet(value: any): boolean {
return value !== null && value !== undefined;
}
+246
View File
@@ -0,0 +1,246 @@
/* eslint-disable */
import Long from "long";
import _m0 from "protobufjs/minimal";
export const protobufPackage = "cerc.onboarding.v1";
/** Params defines the parameters of the onboarding module. */
export interface Params {
onboardingEnabled: boolean;
}
/** Participant defines the data that will be stored for each enrolled participant */
export interface Participant {
cosmosAddress: string;
nitroAddress: string;
}
/** EthPayload defines the payload that is signed by the ethereum private key */
export interface EthPayload {
address: string;
msg: string;
}
function createBaseParams(): Params {
return { onboardingEnabled: false };
}
export const Params = {
encode(
message: Params,
writer: _m0.Writer = _m0.Writer.create()
): _m0.Writer {
if (message.onboardingEnabled === true) {
writer.uint32(8).bool(message.onboardingEnabled);
}
return writer;
},
decode(input: _m0.Reader | Uint8Array, length?: number): Params {
const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);
let end = length === undefined ? reader.len : reader.pos + length;
const message = createBaseParams();
while (reader.pos < end) {
const tag = reader.uint32();
switch (tag >>> 3) {
case 1:
message.onboardingEnabled = reader.bool();
break;
default:
reader.skipType(tag & 7);
break;
}
}
return message;
},
fromJSON(object: any): Params {
return {
onboardingEnabled: isSet(object.onboardingEnabled)
? Boolean(object.onboardingEnabled)
: false,
};
},
toJSON(message: Params): unknown {
const obj: any = {};
message.onboardingEnabled !== undefined &&
(obj.onboardingEnabled = message.onboardingEnabled);
return obj;
},
fromPartial<I extends Exact<DeepPartial<Params>, I>>(object: I): Params {
const message = createBaseParams();
message.onboardingEnabled = object.onboardingEnabled ?? false;
return message;
},
};
function createBaseParticipant(): Participant {
return { cosmosAddress: "", nitroAddress: "" };
}
export const Participant = {
encode(
message: Participant,
writer: _m0.Writer = _m0.Writer.create()
): _m0.Writer {
if (message.cosmosAddress !== "") {
writer.uint32(10).string(message.cosmosAddress);
}
if (message.nitroAddress !== "") {
writer.uint32(18).string(message.nitroAddress);
}
return writer;
},
decode(input: _m0.Reader | Uint8Array, length?: number): Participant {
const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);
let end = length === undefined ? reader.len : reader.pos + length;
const message = createBaseParticipant();
while (reader.pos < end) {
const tag = reader.uint32();
switch (tag >>> 3) {
case 1:
message.cosmosAddress = reader.string();
break;
case 2:
message.nitroAddress = reader.string();
break;
default:
reader.skipType(tag & 7);
break;
}
}
return message;
},
fromJSON(object: any): Participant {
return {
cosmosAddress: isSet(object.cosmosAddress)
? String(object.cosmosAddress)
: "",
nitroAddress: isSet(object.nitroAddress)
? String(object.nitroAddress)
: "",
};
},
toJSON(message: Participant): unknown {
const obj: any = {};
message.cosmosAddress !== undefined &&
(obj.cosmosAddress = message.cosmosAddress);
message.nitroAddress !== undefined &&
(obj.nitroAddress = message.nitroAddress);
return obj;
},
fromPartial<I extends Exact<DeepPartial<Participant>, I>>(
object: I
): Participant {
const message = createBaseParticipant();
message.cosmosAddress = object.cosmosAddress ?? "";
message.nitroAddress = object.nitroAddress ?? "";
return message;
},
};
function createBaseEthPayload(): EthPayload {
return { address: "", msg: "" };
}
export const EthPayload = {
encode(
message: EthPayload,
writer: _m0.Writer = _m0.Writer.create()
): _m0.Writer {
if (message.address !== "") {
writer.uint32(10).string(message.address);
}
if (message.msg !== "") {
writer.uint32(18).string(message.msg);
}
return writer;
},
decode(input: _m0.Reader | Uint8Array, length?: number): EthPayload {
const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);
let end = length === undefined ? reader.len : reader.pos + length;
const message = createBaseEthPayload();
while (reader.pos < end) {
const tag = reader.uint32();
switch (tag >>> 3) {
case 1:
message.address = reader.string();
break;
case 2:
message.msg = reader.string();
break;
default:
reader.skipType(tag & 7);
break;
}
}
return message;
},
fromJSON(object: any): EthPayload {
return {
address: isSet(object.address) ? String(object.address) : "",
msg: isSet(object.msg) ? String(object.msg) : "",
};
},
toJSON(message: EthPayload): unknown {
const obj: any = {};
message.address !== undefined && (obj.address = message.address);
message.msg !== undefined && (obj.msg = message.msg);
return obj;
},
fromPartial<I extends Exact<DeepPartial<EthPayload>, I>>(
object: I
): EthPayload {
const message = createBaseEthPayload();
message.address = object.address ?? "";
message.msg = object.msg ?? "";
return message;
},
};
type Builtin =
| Date
| Function
| Uint8Array
| string
| number
| boolean
| undefined;
export type DeepPartial<T> = T extends Builtin
? T
: T extends Long
? string | number | Long
: T extends Array<infer U>
? Array<DeepPartial<U>>
: T extends ReadonlyArray<infer U>
? ReadonlyArray<DeepPartial<U>>
: T extends {}
? { [K in keyof T]?: DeepPartial<T[K]> }
: Partial<T>;
type KeysOfUnion<T> = T extends T ? keyof T : never;
export type Exact<P, I extends P> = P extends Builtin
? P
: P & { [K in keyof P]: Exact<P[K], I[K]> } & {
[K in Exclude<keyof I, KeysOfUnion<P>>]: never;
};
if (_m0.util.Long !== Long) {
_m0.util.Long = Long as any;
_m0.configure();
}
function isSet(value: any): boolean {
return value !== null && value !== undefined;
}
+250
View File
@@ -0,0 +1,250 @@
/* eslint-disable */
import {
PageRequest,
PageResponse,
} from "../../../cosmos/base/query/v1beta1/pagination";
import Long from "long";
import { Participant } from "./onboarding";
import _m0 from "protobufjs/minimal";
export const protobufPackage = "cerc.onboarding.v1";
/** QueryParticipantsRequest queries participants */
export interface QueryParticipantsRequest {
/** pagination defines an optional pagination for the request. */
pagination?: PageRequest;
}
/** QueryParticipantsResponse is response type for get the participants */
export interface QueryParticipantsResponse {
participants: Participant[];
/** pagination defines the pagination in the response. */
pagination?: PageResponse;
}
function createBaseQueryParticipantsRequest(): QueryParticipantsRequest {
return { pagination: undefined };
}
export const QueryParticipantsRequest = {
encode(
message: QueryParticipantsRequest,
writer: _m0.Writer = _m0.Writer.create()
): _m0.Writer {
if (message.pagination !== undefined) {
PageRequest.encode(message.pagination, writer.uint32(10).fork()).ldelim();
}
return writer;
},
decode(
input: _m0.Reader | Uint8Array,
length?: number
): QueryParticipantsRequest {
const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);
let end = length === undefined ? reader.len : reader.pos + length;
const message = createBaseQueryParticipantsRequest();
while (reader.pos < end) {
const tag = reader.uint32();
switch (tag >>> 3) {
case 1:
message.pagination = PageRequest.decode(reader, reader.uint32());
break;
default:
reader.skipType(tag & 7);
break;
}
}
return message;
},
fromJSON(object: any): QueryParticipantsRequest {
return {
pagination: isSet(object.pagination)
? PageRequest.fromJSON(object.pagination)
: undefined,
};
},
toJSON(message: QueryParticipantsRequest): unknown {
const obj: any = {};
message.pagination !== undefined &&
(obj.pagination = message.pagination
? PageRequest.toJSON(message.pagination)
: undefined);
return obj;
},
fromPartial<I extends Exact<DeepPartial<QueryParticipantsRequest>, I>>(
object: I
): QueryParticipantsRequest {
const message = createBaseQueryParticipantsRequest();
message.pagination =
object.pagination !== undefined && object.pagination !== null
? PageRequest.fromPartial(object.pagination)
: undefined;
return message;
},
};
function createBaseQueryParticipantsResponse(): QueryParticipantsResponse {
return { participants: [], pagination: undefined };
}
export const QueryParticipantsResponse = {
encode(
message: QueryParticipantsResponse,
writer: _m0.Writer = _m0.Writer.create()
): _m0.Writer {
for (const v of message.participants) {
Participant.encode(v!, writer.uint32(10).fork()).ldelim();
}
if (message.pagination !== undefined) {
PageResponse.encode(
message.pagination,
writer.uint32(18).fork()
).ldelim();
}
return writer;
},
decode(
input: _m0.Reader | Uint8Array,
length?: number
): QueryParticipantsResponse {
const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);
let end = length === undefined ? reader.len : reader.pos + length;
const message = createBaseQueryParticipantsResponse();
while (reader.pos < end) {
const tag = reader.uint32();
switch (tag >>> 3) {
case 1:
message.participants.push(
Participant.decode(reader, reader.uint32())
);
break;
case 2:
message.pagination = PageResponse.decode(reader, reader.uint32());
break;
default:
reader.skipType(tag & 7);
break;
}
}
return message;
},
fromJSON(object: any): QueryParticipantsResponse {
return {
participants: Array.isArray(object?.participants)
? object.participants.map((e: any) => Participant.fromJSON(e))
: [],
pagination: isSet(object.pagination)
? PageResponse.fromJSON(object.pagination)
: undefined,
};
},
toJSON(message: QueryParticipantsResponse): unknown {
const obj: any = {};
if (message.participants) {
obj.participants = message.participants.map((e) =>
e ? Participant.toJSON(e) : undefined
);
} else {
obj.participants = [];
}
message.pagination !== undefined &&
(obj.pagination = message.pagination
? PageResponse.toJSON(message.pagination)
: undefined);
return obj;
},
fromPartial<I extends Exact<DeepPartial<QueryParticipantsResponse>, I>>(
object: I
): QueryParticipantsResponse {
const message = createBaseQueryParticipantsResponse();
message.participants =
object.participants?.map((e) => Participant.fromPartial(e)) || [];
message.pagination =
object.pagination !== undefined && object.pagination !== null
? PageResponse.fromPartial(object.pagination)
: undefined;
return message;
},
};
/** Query defines the gRPC querier service for onboarding module */
export interface Query {
/** Participants queries Participants list */
Participants(
request: QueryParticipantsRequest
): Promise<QueryParticipantsResponse>;
}
export class QueryClientImpl implements Query {
private readonly rpc: Rpc;
constructor(rpc: Rpc) {
this.rpc = rpc;
this.Participants = this.Participants.bind(this);
}
Participants(
request: QueryParticipantsRequest
): Promise<QueryParticipantsResponse> {
const data = QueryParticipantsRequest.encode(request).finish();
const promise = this.rpc.request(
"cerc.onboarding.v1.Query",
"Participants",
data
);
return promise.then((data) =>
QueryParticipantsResponse.decode(new _m0.Reader(data))
);
}
}
interface Rpc {
request(
service: string,
method: string,
data: Uint8Array
): Promise<Uint8Array>;
}
type Builtin =
| Date
| Function
| Uint8Array
| string
| number
| boolean
| undefined;
export type DeepPartial<T> = T extends Builtin
? T
: T extends Long
? string | number | Long
: T extends Array<infer U>
? Array<DeepPartial<U>>
: T extends ReadonlyArray<infer U>
? ReadonlyArray<DeepPartial<U>>
: T extends {}
? { [K in keyof T]?: DeepPartial<T[K]> }
: Partial<T>;
type KeysOfUnion<T> = T extends T ? keyof T : never;
export type Exact<P, I extends P> = P extends Builtin
? P
: P & { [K in keyof P]: Exact<P[K], I[K]> } & {
[K in Exclude<keyof I, KeysOfUnion<P>>]: never;
};
if (_m0.util.Long !== Long) {
_m0.util.Long = Long as any;
_m0.configure();
}
function isSet(value: any): boolean {
return value !== null && value !== undefined;
}
+225
View File
@@ -0,0 +1,225 @@
/* eslint-disable */
import { EthPayload } from "./onboarding";
import Long from "long";
import _m0 from "protobufjs/minimal";
export const protobufPackage = "cerc.onboarding.v1";
/** MsgOnboardParticipant defines a SDK message for enrolling a new validator. */
export interface MsgOnboardParticipant {
/** Participant is the msg sender */
participant: string;
ethPayload?: EthPayload;
ethSignature: string;
}
/** MsgOnboardParticipantResponse defines the Msg/OnboardParticipant response type. */
export interface MsgOnboardParticipantResponse {}
function createBaseMsgOnboardParticipant(): MsgOnboardParticipant {
return { participant: "", ethPayload: undefined, ethSignature: "" };
}
export const MsgOnboardParticipant = {
encode(
message: MsgOnboardParticipant,
writer: _m0.Writer = _m0.Writer.create()
): _m0.Writer {
if (message.participant !== "") {
writer.uint32(10).string(message.participant);
}
if (message.ethPayload !== undefined) {
EthPayload.encode(message.ethPayload, writer.uint32(18).fork()).ldelim();
}
if (message.ethSignature !== "") {
writer.uint32(26).string(message.ethSignature);
}
return writer;
},
decode(
input: _m0.Reader | Uint8Array,
length?: number
): MsgOnboardParticipant {
const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);
let end = length === undefined ? reader.len : reader.pos + length;
const message = createBaseMsgOnboardParticipant();
while (reader.pos < end) {
const tag = reader.uint32();
switch (tag >>> 3) {
case 1:
message.participant = reader.string();
break;
case 2:
message.ethPayload = EthPayload.decode(reader, reader.uint32());
break;
case 3:
message.ethSignature = reader.string();
break;
default:
reader.skipType(tag & 7);
break;
}
}
return message;
},
fromJSON(object: any): MsgOnboardParticipant {
return {
participant: isSet(object.participant) ? String(object.participant) : "",
ethPayload: isSet(object.ethPayload)
? EthPayload.fromJSON(object.ethPayload)
: undefined,
ethSignature: isSet(object.ethSignature)
? String(object.ethSignature)
: "",
};
},
toJSON(message: MsgOnboardParticipant): unknown {
const obj: any = {};
message.participant !== undefined &&
(obj.participant = message.participant);
message.ethPayload !== undefined &&
(obj.ethPayload = message.ethPayload
? EthPayload.toJSON(message.ethPayload)
: undefined);
message.ethSignature !== undefined &&
(obj.ethSignature = message.ethSignature);
return obj;
},
fromPartial<I extends Exact<DeepPartial<MsgOnboardParticipant>, I>>(
object: I
): MsgOnboardParticipant {
const message = createBaseMsgOnboardParticipant();
message.participant = object.participant ?? "";
message.ethPayload =
object.ethPayload !== undefined && object.ethPayload !== null
? EthPayload.fromPartial(object.ethPayload)
: undefined;
message.ethSignature = object.ethSignature ?? "";
return message;
},
};
function createBaseMsgOnboardParticipantResponse(): MsgOnboardParticipantResponse {
return {};
}
export const MsgOnboardParticipantResponse = {
encode(
_: MsgOnboardParticipantResponse,
writer: _m0.Writer = _m0.Writer.create()
): _m0.Writer {
return writer;
},
decode(
input: _m0.Reader | Uint8Array,
length?: number
): MsgOnboardParticipantResponse {
const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);
let end = length === undefined ? reader.len : reader.pos + length;
const message = createBaseMsgOnboardParticipantResponse();
while (reader.pos < end) {
const tag = reader.uint32();
switch (tag >>> 3) {
default:
reader.skipType(tag & 7);
break;
}
}
return message;
},
fromJSON(_: any): MsgOnboardParticipantResponse {
return {};
},
toJSON(_: MsgOnboardParticipantResponse): unknown {
const obj: any = {};
return obj;
},
fromPartial<I extends Exact<DeepPartial<MsgOnboardParticipantResponse>, I>>(
_: I
): MsgOnboardParticipantResponse {
const message = createBaseMsgOnboardParticipantResponse();
return message;
},
};
/** Msg defines the onboarding Msg service. */
export interface Msg {
/** OnboardParticipant defines a method for enrolling a new validator. */
OnboardParticipant(
request: MsgOnboardParticipant
): Promise<MsgOnboardParticipantResponse>;
}
export class MsgClientImpl implements Msg {
private readonly rpc: Rpc;
constructor(rpc: Rpc) {
this.rpc = rpc;
this.OnboardParticipant = this.OnboardParticipant.bind(this);
}
OnboardParticipant(
request: MsgOnboardParticipant
): Promise<MsgOnboardParticipantResponse> {
const data = MsgOnboardParticipant.encode(request).finish();
const promise = this.rpc.request(
"cerc.onboarding.v1.Msg",
"OnboardParticipant",
data
);
return promise.then((data) =>
MsgOnboardParticipantResponse.decode(new _m0.Reader(data))
);
}
}
interface Rpc {
request(
service: string,
method: string,
data: Uint8Array
): Promise<Uint8Array>;
}
type Builtin =
| Date
| Function
| Uint8Array
| string
| number
| boolean
| undefined;
export type DeepPartial<T> = T extends Builtin
? T
: T extends Long
? string | number | Long
: T extends Array<infer U>
? Array<DeepPartial<U>>
: T extends ReadonlyArray<infer U>
? ReadonlyArray<DeepPartial<U>>
: T extends {}
? { [K in keyof T]?: DeepPartial<T[K]> }
: Partial<T>;
type KeysOfUnion<T> = T extends T ? keyof T : never;
export type Exact<P, I extends P> = P extends Builtin
? P
: P & { [K in keyof P]: Exact<P[K], I[K]> } & {
[K in Exclude<keyof I, KeysOfUnion<P>>]: never;
};
if (_m0.util.Long !== Long) {
_m0.util.Long = Long as any;
_m0.configure();
}
function isSet(value: any): boolean {
return value !== null && value !== undefined;
}