Incorporate onboarding module and export required types (#5)
* Add proto bindings and generated ts files * Add onboard participant message * Add onboard participant method in client * Add test for onboarding participant * Regenerate proto bindings * Remove hard-coded values from onboarding-test * Export required types for onboarding app * Export types from message files --------- Co-authored-by: Adw8 <adwaitgharpure@gmail.com>
This commit is contained in:
parent
25651a8e7a
commit
f2e1a1bd4a
15
proto/cerc/onboarding/module/v1/module.proto
Normal file
15
proto/cerc/onboarding/module/v1/module.proto
Normal file
@ -0,0 +1,15 @@
|
||||
syntax = "proto3";
|
||||
|
||||
package cerc.onboarding.module.v1;
|
||||
|
||||
import "cosmos/app/v1alpha1/module.proto";
|
||||
|
||||
// Module is the app config object of the module.
|
||||
// Learn more: https://docs.cosmos.network/main/building-modules/depinject
|
||||
message Module {
|
||||
option (cosmos.app.v1alpha1.module) = {
|
||||
go_import : "git.vdb.to/cerc-io/laconicd/x/onboarding"
|
||||
};
|
||||
|
||||
string authority = 1;
|
||||
}
|
16
proto/cerc/onboarding/v1/genesis.proto
Normal file
16
proto/cerc/onboarding/v1/genesis.proto
Normal file
@ -0,0 +1,16 @@
|
||||
syntax = "proto3";
|
||||
|
||||
package cerc.onboarding.v1;
|
||||
|
||||
import "gogoproto/gogo.proto";
|
||||
import "cerc/onboarding/v1/onboarding.proto";
|
||||
|
||||
option go_package = "git.vdb.to/cerc-io/laconicd/x/onboarding";
|
||||
|
||||
// GenesisState defines the onboarding module's genesis state.
|
||||
message GenesisState {
|
||||
// params defines all the parameters of the module.
|
||||
Params params = 1 [ (gogoproto.nullable) = false ];
|
||||
// participants defines all the participants
|
||||
repeated Participant participants = 2 [ (gogoproto.nullable) = false ];
|
||||
}
|
31
proto/cerc/onboarding/v1/onboarding.proto
Normal file
31
proto/cerc/onboarding/v1/onboarding.proto
Normal file
@ -0,0 +1,31 @@
|
||||
syntax = "proto3";
|
||||
|
||||
package cerc.onboarding.v1;
|
||||
|
||||
import "gogoproto/gogo.proto";
|
||||
|
||||
option go_package = "git.vdb.to/cerc-io/laconicd/x/onboarding";
|
||||
|
||||
// Params defines the parameters of the onboarding module.
|
||||
message Params {}
|
||||
|
||||
// Participant defines the data that will be stored for each enrolled participant
|
||||
message Participant {
|
||||
string cosmos_address = 1 [
|
||||
(gogoproto.moretags) = "json:\"cosmos_address\" yaml:\"cosmos_address\""
|
||||
];
|
||||
|
||||
string ethereum_address = 2 [
|
||||
(gogoproto.moretags) = "json:\"ethereum_address\" yaml:\"ethereum_address\""
|
||||
];
|
||||
}
|
||||
// EthPayload defines the payload that is signed by the ethereum private key
|
||||
message EthPayload {
|
||||
string address = 1 [
|
||||
(gogoproto.moretags) = "json:\"address\" yaml:\"address\""
|
||||
];
|
||||
|
||||
string msg = 2 [
|
||||
(gogoproto.moretags) = "json:\"msg\" yaml:\"msg\""
|
||||
];
|
||||
}
|
5
proto/cerc/onboarding/v1/query.proto
Normal file
5
proto/cerc/onboarding/v1/query.proto
Normal file
@ -0,0 +1,5 @@
|
||||
syntax = "proto3";
|
||||
|
||||
package cerc.onboarding.v1;
|
||||
|
||||
option go_package = "git.vdb.to/cerc-io/laconicd/x/onboarding";
|
35
proto/cerc/onboarding/v1/tx.proto
Normal file
35
proto/cerc/onboarding/v1/tx.proto
Normal file
@ -0,0 +1,35 @@
|
||||
syntax = "proto3";
|
||||
|
||||
package cerc.onboarding.v1;
|
||||
|
||||
import "cosmos/msg/v1/msg.proto";
|
||||
import "gogoproto/gogo.proto";
|
||||
import "google/api/annotations.proto";
|
||||
import "cerc/onboarding/v1/onboarding.proto";
|
||||
|
||||
option go_package = "git.vdb.to/cerc-io/laconicd/x/onboarding";
|
||||
|
||||
// Msg defines the onboarding Msg service.
|
||||
service Msg {
|
||||
option (cosmos.msg.v1.service) = true;
|
||||
|
||||
// OnboardParticipant defines a method for enrolling a new validator.
|
||||
rpc OnboardParticipant(MsgOnboardParticipant)
|
||||
returns (MsgOnboardParticipantResponse) {
|
||||
option (google.api.http).post = "/cerc/onboarding/v1/onboard_participant";
|
||||
};
|
||||
}
|
||||
|
||||
// MsgOnboardParticipant defines a SDK message for enrolling a new validator.
|
||||
message MsgOnboardParticipant {
|
||||
option (cosmos.msg.v1.signer) = "participant";
|
||||
|
||||
// Participant is the msg sender
|
||||
string participant = 1;
|
||||
EthPayload eth_payload = 2 [ (gogoproto.nullable) = false ];
|
||||
string eth_signature = 3;
|
||||
string message = 4;
|
||||
}
|
||||
|
||||
// MsgOnboardParticipantResponse defines the Msg/OnboardParticipant response type.
|
||||
message MsgOnboardParticipantResponse {}
|
34
src/index.ts
34
src/index.ts
@ -24,11 +24,13 @@ import {
|
||||
MessageMsgCommitBid,
|
||||
MessageMsgRevealBid
|
||||
} from './types/cerc/auction/message';
|
||||
import { LaconicClient } from './laconic-client';
|
||||
import { MsgCancelBondResponse, MsgCreateBondResponse, MsgRefillBondResponse, MsgWithdrawBondResponse } from './proto/cerc/bond/v1/tx';
|
||||
import { Coin } from './proto/cosmos/base/v1beta1/coin';
|
||||
import { MsgSendResponse } from './proto/cosmos/bank/v1beta1/tx';
|
||||
import { MessageMsgSendCoins } from './types/cosmos/bank/message';
|
||||
import { MessageMsgOnboardParticipant } from './types/cerc/onboarding/message';
|
||||
import { LaconicClient } from './laconic-client';
|
||||
import { Coin } from './proto/cosmos/base/v1beta1/coin';
|
||||
import { MsgCancelBondResponse, MsgCreateBondResponse, MsgRefillBondResponse, MsgWithdrawBondResponse } from './proto/cerc/bond/v1/tx';
|
||||
import { MsgOnboardParticipantResponse } from './proto/cerc/onboarding/v1/tx';
|
||||
import { MsgSendResponse } from './proto/cosmos/bank/v1beta1/tx';
|
||||
|
||||
export const DEFAULT_CHAIN_ID = 'laconic_9000-1';
|
||||
|
||||
@ -59,7 +61,7 @@ export const createBid = async (chainId: string, auctionId: string, bidderAddres
|
||||
};
|
||||
|
||||
export class Registry {
|
||||
_endpoints: {[key: string]: string};
|
||||
_endpoints: { [key: string]: string };
|
||||
_chainID: string;
|
||||
_client: RegistryClient;
|
||||
|
||||
@ -105,7 +107,7 @@ export class Registry {
|
||||
/**
|
||||
* Get records by attributes.
|
||||
*/
|
||||
async queryRecords (attributes: {[key: string]: any}, all = false, refs = false) {
|
||||
async queryRecords (attributes: { [key: string]: any }, all = false, refs = false) {
|
||||
return this._client.queryRecords(attributes, all, refs);
|
||||
}
|
||||
|
||||
@ -434,6 +436,26 @@ export class Registry {
|
||||
async getLaconicClient (account: Account) {
|
||||
return LaconicClient.connectWithSigner(this._endpoints.rpc, account.wallet);
|
||||
}
|
||||
|
||||
/**
|
||||
* Onboard participant.
|
||||
*/
|
||||
async onboardParticipant ({ ethPayload, ethSignature, message }: MessageMsgOnboardParticipant, privateKey: string, fee: StdFee): Promise<MsgOnboardParticipantResponse> {
|
||||
const account = new Account(Buffer.from(privateKey, 'hex'));
|
||||
await account.init();
|
||||
const laconicClient = await this.getLaconicClient(account);
|
||||
|
||||
return laconicClient.onboardParticipant(
|
||||
account.address,
|
||||
ethPayload,
|
||||
ethSignature,
|
||||
message,
|
||||
fee
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
export { Account };
|
||||
export { LaconicClient };
|
||||
export * from './types/cerc/bond/message';
|
||||
export * from './types/cerc/onboarding/message';
|
||||
|
@ -13,13 +13,16 @@ import { MsgCancelBondEncodeObject, MsgCreateBondEncodeObject, MsgRefillBondEnco
|
||||
import { Coin } from './proto/cosmos/base/v1beta1/coin';
|
||||
import { MsgAssociateBondEncodeObject, MsgDeleteNameEncodeObject, MsgDissociateBondEncodeObject, MsgDissociateRecordsEncodeObject, MsgReassociateRecordsEncodeObject, MsgReserveAuthorityEncodeObject, MsgSetAuthorityBondEncodeObject, MsgSetNameEncodeObject, MsgSetRecordEncodeObject, registryTypes, typeUrlMsgAssociateBond, typeUrlMsgDeleteName, typeUrlMsgDissociateBond, typeUrlMsgDissociateRecords, typeUrlMsgReassociateRecords, typeUrlMsgReserveAuthority, typeUrlMsgSetAuthorityBond, typeUrlMsgSetName, typeUrlMsgSetRecord, NAMESERVICE_ERRORS } from './types/cerc/registry/message';
|
||||
import { MsgCommitBidEncodeObject, MsgRevealBidEncodeObject, auctionTypes, typeUrlMsgCommitBid, typeUrlMsgRevealBid } from './types/cerc/auction/message';
|
||||
import { MsgOnboardParticipantEncodeObject, onboardingTypes, typeUrlMsgOnboardParticipant } from './types/cerc/onboarding/message';
|
||||
import { MsgAssociateBondResponse, MsgDeleteNameResponse, MsgDissociateBondResponse, MsgDissociateRecordsResponse, MsgReassociateRecordsResponse, MsgReserveAuthorityResponse, MsgSetAuthorityBondResponse, MsgSetNameResponse, MsgSetRecordResponse, Payload } from './proto/cerc/registry/v1/tx';
|
||||
import { Record, Signature } from './proto/cerc/registry/v1/registry';
|
||||
import { Account } from './account';
|
||||
import { Util } from './util';
|
||||
import { MsgCommitBidResponse, MsgRevealBidResponse } from './proto/cerc/auction/v1/tx';
|
||||
import { MsgCancelBondResponse, MsgCreateBondResponse, MsgRefillBondResponse, MsgWithdrawBondResponse } from './proto/cerc/bond/v1/tx';
|
||||
import { MsgOnboardParticipantResponse } from './proto/cerc/onboarding/v1/tx';
|
||||
import { bankTypes } from './types/cosmos/bank/message';
|
||||
import { EthPayload } from './proto/cerc/onboarding/v1/onboarding';
|
||||
|
||||
const DEFAULT_WRITE_ERROR = 'Unable to write to laconic2d.';
|
||||
|
||||
@ -28,7 +31,8 @@ export const laconicDefaultRegistryTypes: ReadonlyArray<[string, GeneratedType]>
|
||||
...bondTypes,
|
||||
...registryTypes,
|
||||
...auctionTypes,
|
||||
...bankTypes
|
||||
...bankTypes,
|
||||
...onboardingTypes
|
||||
];
|
||||
|
||||
function createDefaultRegistry (): Registry {
|
||||
@ -385,4 +389,26 @@ export class LaconicClient extends SigningStargateClient {
|
||||
|
||||
return `${errorMessage || DEFAULT_WRITE_ERROR}: ${error}`;
|
||||
}
|
||||
|
||||
public async onboardParticipant (
|
||||
signer: string,
|
||||
ethPayload: EthPayload,
|
||||
ethSignature: string,
|
||||
message: string,
|
||||
fee: StdFee | 'auto' | number,
|
||||
memo = ''
|
||||
) {
|
||||
const onboardParticipantMsg: MsgOnboardParticipantEncodeObject = {
|
||||
typeUrl: typeUrlMsgOnboardParticipant,
|
||||
value: {
|
||||
participant: signer,
|
||||
ethPayload,
|
||||
ethSignature,
|
||||
message
|
||||
}
|
||||
};
|
||||
|
||||
const response = await this.signAndBroadcast(signer, [onboardParticipantMsg], fee, memo);
|
||||
return this.parseResponse<MsgOnboardParticipantResponse>(response);
|
||||
}
|
||||
}
|
||||
|
40
src/onboarding.test.ts
Normal file
40
src/onboarding.test.ts
Normal file
@ -0,0 +1,40 @@
|
||||
import { Wallet } from 'ethers';
|
||||
|
||||
import { Registry, Account } from './index';
|
||||
import { getConfig } from './testing/helper';
|
||||
|
||||
const { chainId, rpcEndpoint, gqlEndpoint, privateKey, fee } = getConfig();
|
||||
|
||||
jest.setTimeout(90 * 1000);
|
||||
|
||||
const onboardingTests = () => {
|
||||
let registry: Registry;
|
||||
|
||||
beforeAll(async () => {
|
||||
registry = new Registry(gqlEndpoint, rpcEndpoint, chainId);
|
||||
});
|
||||
|
||||
test('Onboard participant.', async () => {
|
||||
const mnenonic = Account.generateMnemonic();
|
||||
let wallet = Wallet.fromMnemonic(mnenonic);
|
||||
|
||||
const ethPayload = {
|
||||
address: wallet.address,
|
||||
msg: 'Message signed by ethereum private key'
|
||||
};
|
||||
|
||||
const message = JSON.stringify(ethPayload);
|
||||
|
||||
const ethSignature = await wallet.signMessage(message);
|
||||
|
||||
await registry.onboardParticipant({
|
||||
ethPayload,
|
||||
ethSignature,
|
||||
message: 'Message signed by cosmos private key'
|
||||
}, privateKey, fee);
|
||||
|
||||
// TODO: Verify participant getting stored in state
|
||||
});
|
||||
};
|
||||
|
||||
describe('Onboarding', onboardingTests);
|
102
src/proto/cerc/onboarding/module/v1/module.ts
Normal file
102
src/proto/cerc/onboarding/module/v1/module.ts
Normal file
@ -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
src/proto/cerc/onboarding/v1/genesis.ts
Normal file
129
src/proto/cerc/onboarding/v1/genesis.ts
Normal 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;
|
||||
}
|
228
src/proto/cerc/onboarding/v1/onboarding.ts
Normal file
228
src/proto/cerc/onboarding/v1/onboarding.ts
Normal file
@ -0,0 +1,228 @@
|
||||
/* 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 {}
|
||||
|
||||
/** Participant defines the data that will be stored for each enrolled participant */
|
||||
export interface Participant {
|
||||
cosmosAddress: string;
|
||||
ethereumAddress: string;
|
||||
}
|
||||
|
||||
/** EthPayload defines the payload that is signed by the ethereum private key */
|
||||
export interface EthPayload {
|
||||
address: string;
|
||||
msg: string;
|
||||
}
|
||||
|
||||
function createBaseParams(): Params {
|
||||
return {};
|
||||
}
|
||||
|
||||
export const Params = {
|
||||
encode(_: Params, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer {
|
||||
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) {
|
||||
default:
|
||||
reader.skipType(tag & 7);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return message;
|
||||
},
|
||||
|
||||
fromJSON(_: any): Params {
|
||||
return {};
|
||||
},
|
||||
|
||||
toJSON(_: Params): unknown {
|
||||
const obj: any = {};
|
||||
return obj;
|
||||
},
|
||||
|
||||
fromPartial<I extends Exact<DeepPartial<Params>, I>>(_: I): Params {
|
||||
const message = createBaseParams();
|
||||
return message;
|
||||
},
|
||||
};
|
||||
|
||||
function createBaseParticipant(): Participant {
|
||||
return { cosmosAddress: "", ethereumAddress: "" };
|
||||
}
|
||||
|
||||
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.ethereumAddress !== "") {
|
||||
writer.uint32(18).string(message.ethereumAddress);
|
||||
}
|
||||
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.ethereumAddress = reader.string();
|
||||
break;
|
||||
default:
|
||||
reader.skipType(tag & 7);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return message;
|
||||
},
|
||||
|
||||
fromJSON(object: any): Participant {
|
||||
return {
|
||||
cosmosAddress: isSet(object.cosmosAddress)
|
||||
? String(object.cosmosAddress)
|
||||
: "",
|
||||
ethereumAddress: isSet(object.ethereumAddress)
|
||||
? String(object.ethereumAddress)
|
||||
: "",
|
||||
};
|
||||
},
|
||||
|
||||
toJSON(message: Participant): unknown {
|
||||
const obj: any = {};
|
||||
message.cosmosAddress !== undefined &&
|
||||
(obj.cosmosAddress = message.cosmosAddress);
|
||||
message.ethereumAddress !== undefined &&
|
||||
(obj.ethereumAddress = message.ethereumAddress);
|
||||
return obj;
|
||||
},
|
||||
|
||||
fromPartial<I extends Exact<DeepPartial<Participant>, I>>(
|
||||
object: I
|
||||
): Participant {
|
||||
const message = createBaseParticipant();
|
||||
message.cosmosAddress = object.cosmosAddress ?? "";
|
||||
message.ethereumAddress = object.ethereumAddress ?? "";
|
||||
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;
|
||||
}
|
2
src/proto/cerc/onboarding/v1/query.ts
Normal file
2
src/proto/cerc/onboarding/v1/query.ts
Normal file
@ -0,0 +1,2 @@
|
||||
/* eslint-disable */
|
||||
export const protobufPackage = "cerc.onboarding.v1";
|
240
src/proto/cerc/onboarding/v1/tx.ts
Normal file
240
src/proto/cerc/onboarding/v1/tx.ts
Normal file
@ -0,0 +1,240 @@
|
||||
/* 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;
|
||||
message: string;
|
||||
}
|
||||
|
||||
/** MsgOnboardParticipantResponse defines the Msg/OnboardParticipant response type. */
|
||||
export interface MsgOnboardParticipantResponse {}
|
||||
|
||||
function createBaseMsgOnboardParticipant(): MsgOnboardParticipant {
|
||||
return {
|
||||
participant: "",
|
||||
ethPayload: undefined,
|
||||
ethSignature: "",
|
||||
message: "",
|
||||
};
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
if (message.message !== "") {
|
||||
writer.uint32(34).string(message.message);
|
||||
}
|
||||
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;
|
||||
case 4:
|
||||
message.message = 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)
|
||||
: "",
|
||||
message: isSet(object.message) ? String(object.message) : "",
|
||||
};
|
||||
},
|
||||
|
||||
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);
|
||||
message.message !== undefined && (obj.message = message.message);
|
||||
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 ?? "";
|
||||
message.message = object.message ?? "";
|
||||
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;
|
||||
}
|
@ -7,4 +7,4 @@ record:
|
||||
/: QmP8jTG1m9GSDJLCbeWhVSVgEzCPPwXRdCRuJtQ5Tz9Kc9
|
||||
tls_cert_cid:
|
||||
/: QmbWqxBEKC3P8tqsKc98xmWNzrzDtRLMiMPL8wBuTGsMnR
|
||||
version: 1.0.23
|
||||
version: 1.0.28
|
||||
|
27
src/types/cerc/onboarding/message.ts
Normal file
27
src/types/cerc/onboarding/message.ts
Normal file
@ -0,0 +1,27 @@
|
||||
import { EncodeObject, GeneratedType } from '@cosmjs/proto-signing';
|
||||
|
||||
import { MsgOnboardParticipantResponse, MsgOnboardParticipant } from '../../../proto/cerc/onboarding/v1/tx';
|
||||
|
||||
export const typeUrlMsgOnboardParticipant = '/cerc.onboarding.v1.MsgOnboardParticipant';
|
||||
export const typeUrlMsgOnboardParticipantResponse = '/cerc.onboarding.v1.MsgOnboardParticipantResponse';
|
||||
|
||||
export const onboardingTypes: ReadonlyArray<[string, GeneratedType]> = [
|
||||
[typeUrlMsgOnboardParticipant, MsgOnboardParticipant],
|
||||
[typeUrlMsgOnboardParticipantResponse, MsgOnboardParticipantResponse]
|
||||
];
|
||||
|
||||
export interface MsgOnboardParticipantEncodeObject extends EncodeObject {
|
||||
readonly typeUrl: '/cerc.onboarding.v1.MsgOnboardParticipant';
|
||||
readonly value: Partial<MsgOnboardParticipant>;
|
||||
}
|
||||
|
||||
interface ethPayload {
|
||||
address: string
|
||||
msg: string
|
||||
}
|
||||
|
||||
export interface MessageMsgOnboardParticipant {
|
||||
ethPayload: ethPayload
|
||||
ethSignature: string
|
||||
message: string
|
||||
}
|
Loading…
Reference in New Issue
Block a user