forked from cerc-io/registry-sdk
Compare commits
7
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
798ed712b3 | ||
|
|
147348cf1d | ||
|
|
5fc42e897a | ||
|
|
3a828b47ae | ||
|
|
022c55268c | ||
|
|
2757281e5b | ||
|
|
25651a8e7a |
@@ -0,0 +1,27 @@
|
||||
name: Lint & Build
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
|
||||
jobs:
|
||||
lint_and_build:
|
||||
runs-on: ubuntu-latest
|
||||
strategy:
|
||||
matrix:
|
||||
node-version: [20.x]
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- name: Download yarn
|
||||
run: |
|
||||
curl -fsSL -o /usr/local/bin/yarn https://github.com/yarnpkg/yarn/releases/download/v1.22.21/yarn-1.22.21.js
|
||||
chmod +x /usr/local/bin/yarn
|
||||
- name: Use Node.js ${{ matrix.node-version }}
|
||||
uses: actions/setup-node@v3
|
||||
with:
|
||||
node-version: ${{ matrix.node-version }}
|
||||
registry-url: 'https://npm.pkg.github.com'
|
||||
- run: yarn
|
||||
- name: Run lint
|
||||
run: yarn lint
|
||||
- name: Run build
|
||||
run: yarn build
|
||||
@@ -20,7 +20,7 @@ jobs:
|
||||
uses: actions/checkout@v3
|
||||
with:
|
||||
path: "./laconicd/"
|
||||
repository: cerc-io/laconic2d # TODO: Update to laconicd on repo renaming
|
||||
repository: cerc-io/laconicd
|
||||
fetch-depth: 0
|
||||
ref: main
|
||||
- name: Environment
|
||||
@@ -61,3 +61,12 @@ jobs:
|
||||
- name: Run nameservice expiry tests
|
||||
working-directory: laconicd/tests/sdk_tests
|
||||
run: ./run-tests.sh test:nameservice-expiry
|
||||
|
||||
- name: Start containers (onboarding enabled)
|
||||
working-directory: laconicd/tests/sdk_tests
|
||||
env:
|
||||
ONBOARDING_ENABLED: true
|
||||
run: docker compose up -d
|
||||
- name: Run participants onboarding tests
|
||||
working-directory: laconicd/tests/sdk_tests
|
||||
run: ./run-tests.sh test:onboarding
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
name: Lint & Build
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
|
||||
jobs:
|
||||
lint_and_build:
|
||||
runs-on: ubuntu-latest
|
||||
strategy:
|
||||
matrix:
|
||||
node-version: [20.x]
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- name: Use Node.js ${{ matrix.node-version }}
|
||||
uses: actions/setup-node@v3
|
||||
with:
|
||||
node-version: ${{ matrix.node-version }}
|
||||
registry-url: 'https://npm.pkg.github.com'
|
||||
- run: yarn
|
||||
- name: Run lint
|
||||
run: yarn lint
|
||||
- name: Run build
|
||||
run: yarn build
|
||||
@@ -51,3 +51,12 @@ jobs:
|
||||
- name: Run nameservice expiry tests
|
||||
working-directory: laconicd/tests/sdk_tests
|
||||
run: ./run-tests.sh test:nameservice-expiry
|
||||
|
||||
- name: Start containers (onboarding enabled)
|
||||
working-directory: laconicd/tests/sdk_tests
|
||||
env:
|
||||
ONBOARDING_ENABLED: true
|
||||
run: docker compose up -d
|
||||
- name: Run participants onboarding tests
|
||||
working-directory: laconicd/tests/sdk_tests
|
||||
run: ./run-tests.sh test:onboarding
|
||||
|
||||
+9
-8
@@ -4,13 +4,14 @@
|
||||
|
||||
Run following scripts when [proto files](./proto/) are updated.
|
||||
|
||||
1. Install dependencies
|
||||
```bash
|
||||
yarn
|
||||
```
|
||||
* Install dependencies:
|
||||
|
||||
2. Generate typescript code for the proto files
|
||||
```bash
|
||||
yarn
|
||||
```
|
||||
|
||||
```bash
|
||||
./scripts/proto-gen.sh
|
||||
```
|
||||
* Generate typescript bindings for the proto files:
|
||||
|
||||
```bash
|
||||
./scripts/proto-gen.sh
|
||||
```
|
||||
|
||||
@@ -18,7 +18,7 @@ Follow these steps to run the tests:
|
||||
cp .env.example .env
|
||||
```
|
||||
|
||||
- Clone the [laconicd repo](https://git.vdb.to/cerc-io/laconic2d) and change to repo directory.
|
||||
- Clone the [laconicd repo](https://git.vdb.to/cerc-io/laconicd) and change to repo directory.
|
||||
|
||||
- Run the chain using `./scripts/init.sh`.
|
||||
|
||||
|
||||
+2
-1
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@cerc-io/registry-sdk",
|
||||
"version": "0.2.1",
|
||||
"version": "0.2.5",
|
||||
"main": "dist/index.js",
|
||||
"types": "dist/index.d.ts",
|
||||
"repository": "git@github.com:cerc-io/registry-sdk.git",
|
||||
@@ -64,6 +64,7 @@
|
||||
"test": "jest --runInBand --verbose --testPathPattern=src",
|
||||
"test:auctions": "TEST_AUCTIONS_ENABLED=1 jest --runInBand --verbose src/auction.test.ts",
|
||||
"test:nameservice-expiry": "TEST_NAMESERVICE_EXPIRY=1 jest --runInBand --verbose src/nameservice-expiry.test.ts",
|
||||
"test:onboarding": "ONBOARDING_ENABLED=1 jest --runInBand --verbose src/onboarding.test.ts",
|
||||
"build": "tsc",
|
||||
"lint": "eslint .",
|
||||
"prepare": "husky"
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
@@ -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 ];
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
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 {
|
||||
bool onboarding_enabled = 1
|
||||
[ (gogoproto.moretags) =
|
||||
"json:\"onboarding_enabled\" yaml:\"onboarding_enabled\"" ];
|
||||
}
|
||||
|
||||
// Participant defines the data that will be stored for each enrolled
|
||||
// participant
|
||||
message Participant {
|
||||
// participant's cosmos (laconic) address
|
||||
string cosmos_address = 1
|
||||
[ (gogoproto.moretags) =
|
||||
"json:\"cosmos_address\" yaml:\"cosmos_address\"" ];
|
||||
|
||||
// participant's Nitro address
|
||||
string nitro_address = 2
|
||||
[ (gogoproto.moretags) =
|
||||
"json:\"nitro_address\" yaml:\"nitro_address\"" ];
|
||||
|
||||
// participant's role (participant | validator)
|
||||
string role = 3 [ (gogoproto.moretags) = "json:\"role\" yaml:\"role\"" ];
|
||||
|
||||
// participant's KYC receipt ID
|
||||
string kyc_id = 4
|
||||
[ (gogoproto.moretags) = "json:\"kyc_id\" yaml:\"kyc_id\"" ];
|
||||
}
|
||||
|
||||
// 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\"" ];
|
||||
}
|
||||
@@ -0,0 +1,75 @@
|
||||
syntax = "proto3";
|
||||
|
||||
package cerc.onboarding.v1;
|
||||
|
||||
import "gogoproto/gogo.proto";
|
||||
import "cosmos/base/query/v1beta1/pagination.proto";
|
||||
import "cerc/onboarding/v1/onboarding.proto";
|
||||
import "google/api/annotations.proto";
|
||||
|
||||
option go_package = "git.vdb.to/cerc-io/laconicd/x/onboarding";
|
||||
|
||||
// Query defines the gRPC querier service for onboarding module
|
||||
service Query {
|
||||
// Participants queries Participants list
|
||||
rpc Participants(QueryParticipantsRequest)
|
||||
returns (QueryParticipantsResponse) {
|
||||
option (google.api.http).get = "/cerc/onboarding/v1/participants";
|
||||
}
|
||||
|
||||
// GetParticipantByAddress queries a participant by cosmos (laconic) address
|
||||
rpc GetParticipantByAddress(QueryGetParticipantByAddressRequest)
|
||||
returns (QueryGetParticipantByAddressResponse) {
|
||||
option (google.api.http).get = "/cerc/onboarding/v1/participants/{address}";
|
||||
}
|
||||
|
||||
// GetParticipantByNitroAddress queries a participant by nitro address
|
||||
rpc GetParticipantByNitroAddress(QueryGetParticipantByNitroAddressRequest)
|
||||
returns (QueryGetParticipantByNitroAddressResponse) {
|
||||
option (google.api.http).get =
|
||||
"/cerc/onboarding/v1/participants/{nitro_address}";
|
||||
}
|
||||
}
|
||||
|
||||
// QueryParticipantsRequest queries participants
|
||||
message QueryParticipantsRequest {
|
||||
// pagination defines an optional pagination for the request.
|
||||
cosmos.base.query.v1beta1.PageRequest pagination = 1;
|
||||
}
|
||||
|
||||
// QueryParticipantsResponse is response type for querying the participants
|
||||
message QueryParticipantsResponse {
|
||||
repeated Participant participants = 1
|
||||
[ (gogoproto.moretags) = "json:\"participants\" yaml:\"participants\"" ];
|
||||
|
||||
// pagination defines the pagination in the response.
|
||||
cosmos.base.query.v1beta1.PageResponse pagination = 2;
|
||||
}
|
||||
|
||||
// QueryGetParticipantByAddressRequest queries participant by the laconic
|
||||
// address
|
||||
message QueryGetParticipantByAddressRequest {
|
||||
// Laconic address
|
||||
string address = 1;
|
||||
}
|
||||
|
||||
// QueryGetParticipantByAddressResponse is response type for querying
|
||||
// participant by the laconic address
|
||||
message QueryGetParticipantByAddressResponse {
|
||||
// Participant details
|
||||
Participant participant = 1;
|
||||
}
|
||||
|
||||
// QueryGetParticipantByNitroAddressRequest queries participant by the nitro
|
||||
// address
|
||||
message QueryGetParticipantByNitroAddressRequest {
|
||||
// Nitro address
|
||||
string nitro_address = 1;
|
||||
}
|
||||
|
||||
// QueryGetParticipantByNitroAddressResponse is response type for querying
|
||||
// participant by the nitro address
|
||||
message QueryGetParticipantByNitroAddressResponse {
|
||||
// Participant details
|
||||
Participant participant = 1;
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
syntax = "proto3";
|
||||
|
||||
package cerc.onboarding.v1;
|
||||
|
||||
import "cosmos/msg/v1/msg.proto";
|
||||
import "google/api/annotations.proto";
|
||||
import "gogoproto/gogo.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 role = 4;
|
||||
string kyc_id = 5;
|
||||
}
|
||||
|
||||
// MsgOnboardParticipantResponse defines the Msg/OnboardParticipant response
|
||||
// type.
|
||||
message MsgOnboardParticipantResponse {}
|
||||
@@ -58,6 +58,11 @@ service Query {
|
||||
returns (QueryGetRegistryModuleBalanceResponse) {
|
||||
option (google.api.http).get = "/cerc/registry/v1/balance";
|
||||
}
|
||||
|
||||
// Authorities queries all authorities
|
||||
rpc Authorities(QueryAuthoritiesRequest) returns (QueryAuthoritiesResponse) {
|
||||
option (google.api.http).get = "/cerc/registry/v1/authorities";
|
||||
}
|
||||
}
|
||||
|
||||
// QueryParamsRequest is request type for registry params
|
||||
@@ -152,6 +157,16 @@ message QueryWhoisResponse {
|
||||
];
|
||||
}
|
||||
|
||||
// QueryAuthoritiesRequest is request type to get all authorities
|
||||
message QueryAuthoritiesRequest { string owner = 1; }
|
||||
|
||||
// QueryAuthoritiesResponse is response type for authorities request
|
||||
message QueryAuthoritiesResponse {
|
||||
repeated AuthorityEntry authorities = 1 [ (gogoproto.nullable) = false ];
|
||||
// pagination defines the pagination in the response.
|
||||
cosmos.base.query.v1beta1.PageResponse pagination = 2;
|
||||
}
|
||||
|
||||
// QueryLookupLrnRequest is request type for LookupLrn
|
||||
message QueryLookupLrnRequest { string lrn = 1; }
|
||||
|
||||
|
||||
+1
-1
@@ -115,7 +115,7 @@ if (!process.env.TEST_AUCTIONS_ENABLED) {
|
||||
test('skipping auction tests', () => {});
|
||||
} else {
|
||||
/**
|
||||
Running these tests requires name auctions enabled. In laconic2d repo run:
|
||||
Running these tests requires name auctions enabled. In laconicd repo run:
|
||||
|
||||
TEST_AUCTION_ENABLED=true ./init.sh
|
||||
|
||||
|
||||
+2
-1
@@ -1 +1,2 @@
|
||||
export const DENOM = 'photon';
|
||||
export const DENOM = 'alnt';
|
||||
export const DEFAULT_CHAIN_ID = 'laconic_9000-1';
|
||||
|
||||
+52
-8
@@ -24,13 +24,14 @@ 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';
|
||||
|
||||
export const DEFAULT_CHAIN_ID = 'laconic_9000-1';
|
||||
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';
|
||||
import { DEFAULT_CHAIN_ID } from './constants';
|
||||
|
||||
/**
|
||||
* Create an auction bid.
|
||||
@@ -59,7 +60,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 +106,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 +435,49 @@ export class Registry {
|
||||
async getLaconicClient (account: Account) {
|
||||
return LaconicClient.connectWithSigner(this._endpoints.rpc, account.wallet);
|
||||
}
|
||||
|
||||
/**
|
||||
* Onboard participant.
|
||||
*/
|
||||
async onboardParticipant ({ ethPayload, ethSignature, role, kycId }: 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,
|
||||
role,
|
||||
kycId,
|
||||
fee
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Query participants.
|
||||
*/
|
||||
async getParticipants () {
|
||||
return this._client.getParticipants();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get participant by cosmos (laconic) address.
|
||||
*/
|
||||
async getParticipantByAddress (address: string) {
|
||||
return this._client.getParticipantByAddress(address);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get participant by nitro address.
|
||||
*/
|
||||
async getParticipantByNitroAddress (nitroAddress: string) {
|
||||
return this._client.getParticipantByNitroAddress(nitroAddress);
|
||||
}
|
||||
}
|
||||
|
||||
export { Account };
|
||||
export { LaconicClient };
|
||||
export { DENOM, DEFAULT_CHAIN_ID } from './constants';
|
||||
export * from './types/cerc/bond/message';
|
||||
export * from './types/cerc/onboarding/message';
|
||||
|
||||
+31
-3
@@ -13,22 +13,26 @@ 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.';
|
||||
const DEFAULT_WRITE_ERROR = 'Unable to write to laconicd.';
|
||||
|
||||
export const laconicDefaultRegistryTypes: ReadonlyArray<[string, GeneratedType]> = [
|
||||
...defaultRegistryTypes,
|
||||
...bondTypes,
|
||||
...registryTypes,
|
||||
...auctionTypes,
|
||||
...bankTypes
|
||||
...bankTypes,
|
||||
...onboardingTypes
|
||||
];
|
||||
|
||||
function createDefaultRegistry (): Registry {
|
||||
@@ -383,6 +387,30 @@ export class LaconicClient extends SigningStargateClient {
|
||||
console.error(error);
|
||||
}
|
||||
|
||||
return errorMessage || DEFAULT_WRITE_ERROR;
|
||||
return `${errorMessage || DEFAULT_WRITE_ERROR}: ${error}`;
|
||||
}
|
||||
|
||||
public async onboardParticipant (
|
||||
signer: string,
|
||||
ethPayload: EthPayload,
|
||||
ethSignature: string,
|
||||
role: string,
|
||||
kycId: string,
|
||||
fee: StdFee | 'auto' | number,
|
||||
memo = ''
|
||||
) {
|
||||
const onboardParticipantMsg: MsgOnboardParticipantEncodeObject = {
|
||||
typeUrl: typeUrlMsgOnboardParticipant,
|
||||
value: {
|
||||
participant: signer,
|
||||
ethPayload,
|
||||
ethSignature,
|
||||
role,
|
||||
kycId
|
||||
}
|
||||
};
|
||||
|
||||
const response = await this.signAndBroadcast(signer, [onboardParticipantMsg], fee, memo);
|
||||
return this.parseResponse<MsgOnboardParticipantResponse>(response);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -103,7 +103,7 @@ if (!process.env.TEST_NAMESERVICE_EXPIRY) {
|
||||
test('skipping nameservice expiry tests', () => {});
|
||||
} else {
|
||||
/**
|
||||
Running these tests requires timers to be set. In laconic2d repo run:
|
||||
Running these tests requires timers to be set. In laconicd repo run:
|
||||
|
||||
TEST_REGISTRY_EXPIRY=true ./init.sh
|
||||
|
||||
|
||||
+1
-1
@@ -93,7 +93,7 @@ const namingTests = () => {
|
||||
const mnenonic1 = Account.generateMnemonic();
|
||||
const otherAccount1 = await Account.generateFromMnemonic(mnenonic1);
|
||||
await otherAccount1.init();
|
||||
await registry.sendCoins({ denom: DENOM, amount: '10000', destinationAddress: otherAccount1.address }, privateKey, fee);
|
||||
await registry.sendCoins({ denom: DENOM, amount: '1000000000', destinationAddress: otherAccount1.address }, privateKey, fee);
|
||||
|
||||
const mnenonic2 = Account.generateMnemonic();
|
||||
const otherAccount2 = await Account.generateFromMnemonic(mnenonic2);
|
||||
|
||||
@@ -0,0 +1,128 @@
|
||||
import { Wallet } from 'ethers';
|
||||
|
||||
import { DirectSecp256k1Wallet, AccountData as CosmosAccount } from '@cosmjs/proto-signing';
|
||||
|
||||
import { Registry, Account } from './index';
|
||||
import { getConfig } from './testing/helper';
|
||||
import { Participant } from './proto/cerc/onboarding/v1/onboarding';
|
||||
|
||||
const { chainId, rpcEndpoint, gqlEndpoint, privateKey, fee } = getConfig();
|
||||
|
||||
jest.setTimeout(90 * 1000);
|
||||
|
||||
const DUMMY_ROLE = 'validator';
|
||||
const DUMMY_KYC_ID = 'dummyKycId';
|
||||
|
||||
const onboardingEnabledTests = () => {
|
||||
let registry: Registry;
|
||||
let ethWallet: Wallet;
|
||||
let cosmosWallet: CosmosAccount;
|
||||
let expectedParticipants: Participant[] = [];
|
||||
|
||||
beforeAll(async () => {
|
||||
registry = new Registry(gqlEndpoint, rpcEndpoint, chainId);
|
||||
|
||||
const mnemonic = Account.generateMnemonic();
|
||||
ethWallet = Wallet.fromMnemonic(mnemonic);
|
||||
|
||||
const account = new Account(Buffer.from(privateKey, 'hex'));
|
||||
const cosmosAccount = await DirectSecp256k1Wallet.fromKey(account._privateKey, 'laconic');
|
||||
[cosmosWallet] = await cosmosAccount.getAccounts();
|
||||
|
||||
expectedParticipants = [
|
||||
{
|
||||
cosmosAddress: cosmosWallet.address,
|
||||
nitroAddress: ethWallet.address,
|
||||
role: DUMMY_ROLE,
|
||||
kycId: DUMMY_KYC_ID
|
||||
}
|
||||
];
|
||||
});
|
||||
|
||||
test('Onboard participant.', async () => {
|
||||
const ethPayload = {
|
||||
address: ethWallet.address,
|
||||
msg: 'Message signed by ethereum private key'
|
||||
};
|
||||
|
||||
const message = JSON.stringify(ethPayload);
|
||||
const ethSignature = await ethWallet.signMessage(message);
|
||||
|
||||
await registry.onboardParticipant({
|
||||
ethPayload,
|
||||
ethSignature,
|
||||
role: DUMMY_ROLE,
|
||||
kycId: DUMMY_KYC_ID
|
||||
}, privateKey, fee);
|
||||
});
|
||||
|
||||
test('Query participants.', async () => {
|
||||
const participants = await registry.getParticipants();
|
||||
expect(participants).toEqual(expectedParticipants);
|
||||
});
|
||||
|
||||
test('Query participant by address.', async () => {
|
||||
const participant = await registry.getParticipantByAddress(cosmosWallet.address);
|
||||
expect(participant).toEqual(expectedParticipants[0]);
|
||||
});
|
||||
|
||||
test('Query participant by Nitro address.', async () => {
|
||||
const participant = await registry.getParticipantByNitroAddress(ethWallet.address);
|
||||
expect(participant).toEqual(expectedParticipants[0]);
|
||||
});
|
||||
};
|
||||
|
||||
const onboardingDisabledTests = () => {
|
||||
let registry: Registry;
|
||||
let ethWallet: Wallet;
|
||||
|
||||
beforeAll(async () => {
|
||||
registry = new Registry(gqlEndpoint, rpcEndpoint, chainId);
|
||||
});
|
||||
|
||||
test('Error on onboarding attempt.', async () => {
|
||||
const errorMsg = 'Validator onboarding is disabled: invalid request';
|
||||
const mnemonic = Account.generateMnemonic();
|
||||
ethWallet = Wallet.fromMnemonic(mnemonic);
|
||||
|
||||
const ethPayload = {
|
||||
address: ethWallet.address,
|
||||
msg: 'Message signed by ethereum private key'
|
||||
};
|
||||
|
||||
const message = JSON.stringify(ethPayload);
|
||||
const ethSignature = await ethWallet.signMessage(message);
|
||||
|
||||
try {
|
||||
await registry.onboardParticipant({
|
||||
ethPayload,
|
||||
ethSignature,
|
||||
role: DUMMY_ROLE,
|
||||
kycId: DUMMY_KYC_ID
|
||||
}, privateKey, fee);
|
||||
} catch (error: any) {
|
||||
expect(error.toString()).toContain(errorMsg);
|
||||
}
|
||||
});
|
||||
|
||||
test('No participants onboarded.', async () => {
|
||||
const expectedParticipants: Participant[] = [];
|
||||
const participants = await registry.getParticipants();
|
||||
expect(participants).toMatchObject(expectedParticipants);
|
||||
});
|
||||
};
|
||||
|
||||
if (process.env.ONBOARDING_ENABLED !== '1') {
|
||||
describe('Onboarding disabled', onboardingDisabledTests);
|
||||
} else {
|
||||
/**
|
||||
Running this test requires participants onboarding enabled. In laconicd repo run:
|
||||
|
||||
ONBOARDING_ENABLED=true ./init.sh
|
||||
|
||||
Run test:
|
||||
|
||||
yarn test:onboarding
|
||||
*/
|
||||
describe('Onboarding enabled', onboardingEnabledTests);
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
@@ -0,0 +1,273 @@
|
||||
/* 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 {
|
||||
/** participant's cosmos (laconic) address */
|
||||
cosmosAddress: string;
|
||||
/** participant's Nitro address */
|
||||
nitroAddress: string;
|
||||
/** participant's role (participant | validator) */
|
||||
role: string;
|
||||
/** participant's KYC receipt ID */
|
||||
kycId: 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: "", role: "", kycId: "" };
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
if (message.role !== "") {
|
||||
writer.uint32(26).string(message.role);
|
||||
}
|
||||
if (message.kycId !== "") {
|
||||
writer.uint32(34).string(message.kycId);
|
||||
}
|
||||
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;
|
||||
case 3:
|
||||
message.role = reader.string();
|
||||
break;
|
||||
case 4:
|
||||
message.kycId = 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)
|
||||
: "",
|
||||
role: isSet(object.role) ? String(object.role) : "",
|
||||
kycId: isSet(object.kycId) ? String(object.kycId) : "",
|
||||
};
|
||||
},
|
||||
|
||||
toJSON(message: Participant): unknown {
|
||||
const obj: any = {};
|
||||
message.cosmosAddress !== undefined &&
|
||||
(obj.cosmosAddress = message.cosmosAddress);
|
||||
message.nitroAddress !== undefined &&
|
||||
(obj.nitroAddress = message.nitroAddress);
|
||||
message.role !== undefined && (obj.role = message.role);
|
||||
message.kycId !== undefined && (obj.kycId = message.kycId);
|
||||
return obj;
|
||||
},
|
||||
|
||||
fromPartial<I extends Exact<DeepPartial<Participant>, I>>(
|
||||
object: I
|
||||
): Participant {
|
||||
const message = createBaseParticipant();
|
||||
message.cosmosAddress = object.cosmosAddress ?? "";
|
||||
message.nitroAddress = object.nitroAddress ?? "";
|
||||
message.role = object.role ?? "";
|
||||
message.kycId = object.kycId ?? "";
|
||||
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;
|
||||
}
|
||||
@@ -0,0 +1,579 @@
|
||||
/* eslint-disable */
|
||||
import {
|
||||
PageRequest,
|
||||
PageResponse,
|
||||
} from "../../../cosmos/base/query/v1beta1/pagination";
|
||||
import { Participant } from "./onboarding";
|
||||
import Long from "long";
|
||||
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 querying the participants */
|
||||
export interface QueryParticipantsResponse {
|
||||
participants: Participant[];
|
||||
/** pagination defines the pagination in the response. */
|
||||
pagination?: PageResponse;
|
||||
}
|
||||
|
||||
/**
|
||||
* QueryGetParticipantByAddressRequest queries participant by the laconic
|
||||
* address
|
||||
*/
|
||||
export interface QueryGetParticipantByAddressRequest {
|
||||
/** Laconic address */
|
||||
address: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* QueryGetParticipantByAddressResponse is response type for querying
|
||||
* participant by the laconic address
|
||||
*/
|
||||
export interface QueryGetParticipantByAddressResponse {
|
||||
/** Participant details */
|
||||
participant?: Participant;
|
||||
}
|
||||
|
||||
/**
|
||||
* QueryGetParticipantByNitroAddressRequest queries participant by the nitro
|
||||
* address
|
||||
*/
|
||||
export interface QueryGetParticipantByNitroAddressRequest {
|
||||
/** Nitro address */
|
||||
nitroAddress: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* QueryGetParticipantByNitroAddressResponse is response type for querying
|
||||
* participant by the nitro address
|
||||
*/
|
||||
export interface QueryGetParticipantByNitroAddressResponse {
|
||||
/** Participant details */
|
||||
participant?: Participant;
|
||||
}
|
||||
|
||||
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;
|
||||
},
|
||||
};
|
||||
|
||||
function createBaseQueryGetParticipantByAddressRequest(): QueryGetParticipantByAddressRequest {
|
||||
return { address: "" };
|
||||
}
|
||||
|
||||
export const QueryGetParticipantByAddressRequest = {
|
||||
encode(
|
||||
message: QueryGetParticipantByAddressRequest,
|
||||
writer: _m0.Writer = _m0.Writer.create()
|
||||
): _m0.Writer {
|
||||
if (message.address !== "") {
|
||||
writer.uint32(10).string(message.address);
|
||||
}
|
||||
return writer;
|
||||
},
|
||||
|
||||
decode(
|
||||
input: _m0.Reader | Uint8Array,
|
||||
length?: number
|
||||
): QueryGetParticipantByAddressRequest {
|
||||
const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);
|
||||
let end = length === undefined ? reader.len : reader.pos + length;
|
||||
const message = createBaseQueryGetParticipantByAddressRequest();
|
||||
while (reader.pos < end) {
|
||||
const tag = reader.uint32();
|
||||
switch (tag >>> 3) {
|
||||
case 1:
|
||||
message.address = reader.string();
|
||||
break;
|
||||
default:
|
||||
reader.skipType(tag & 7);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return message;
|
||||
},
|
||||
|
||||
fromJSON(object: any): QueryGetParticipantByAddressRequest {
|
||||
return {
|
||||
address: isSet(object.address) ? String(object.address) : "",
|
||||
};
|
||||
},
|
||||
|
||||
toJSON(message: QueryGetParticipantByAddressRequest): unknown {
|
||||
const obj: any = {};
|
||||
message.address !== undefined && (obj.address = message.address);
|
||||
return obj;
|
||||
},
|
||||
|
||||
fromPartial<
|
||||
I extends Exact<DeepPartial<QueryGetParticipantByAddressRequest>, I>
|
||||
>(object: I): QueryGetParticipantByAddressRequest {
|
||||
const message = createBaseQueryGetParticipantByAddressRequest();
|
||||
message.address = object.address ?? "";
|
||||
return message;
|
||||
},
|
||||
};
|
||||
|
||||
function createBaseQueryGetParticipantByAddressResponse(): QueryGetParticipantByAddressResponse {
|
||||
return { participant: undefined };
|
||||
}
|
||||
|
||||
export const QueryGetParticipantByAddressResponse = {
|
||||
encode(
|
||||
message: QueryGetParticipantByAddressResponse,
|
||||
writer: _m0.Writer = _m0.Writer.create()
|
||||
): _m0.Writer {
|
||||
if (message.participant !== undefined) {
|
||||
Participant.encode(
|
||||
message.participant,
|
||||
writer.uint32(10).fork()
|
||||
).ldelim();
|
||||
}
|
||||
return writer;
|
||||
},
|
||||
|
||||
decode(
|
||||
input: _m0.Reader | Uint8Array,
|
||||
length?: number
|
||||
): QueryGetParticipantByAddressResponse {
|
||||
const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);
|
||||
let end = length === undefined ? reader.len : reader.pos + length;
|
||||
const message = createBaseQueryGetParticipantByAddressResponse();
|
||||
while (reader.pos < end) {
|
||||
const tag = reader.uint32();
|
||||
switch (tag >>> 3) {
|
||||
case 1:
|
||||
message.participant = Participant.decode(reader, reader.uint32());
|
||||
break;
|
||||
default:
|
||||
reader.skipType(tag & 7);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return message;
|
||||
},
|
||||
|
||||
fromJSON(object: any): QueryGetParticipantByAddressResponse {
|
||||
return {
|
||||
participant: isSet(object.participant)
|
||||
? Participant.fromJSON(object.participant)
|
||||
: undefined,
|
||||
};
|
||||
},
|
||||
|
||||
toJSON(message: QueryGetParticipantByAddressResponse): unknown {
|
||||
const obj: any = {};
|
||||
message.participant !== undefined &&
|
||||
(obj.participant = message.participant
|
||||
? Participant.toJSON(message.participant)
|
||||
: undefined);
|
||||
return obj;
|
||||
},
|
||||
|
||||
fromPartial<
|
||||
I extends Exact<DeepPartial<QueryGetParticipantByAddressResponse>, I>
|
||||
>(object: I): QueryGetParticipantByAddressResponse {
|
||||
const message = createBaseQueryGetParticipantByAddressResponse();
|
||||
message.participant =
|
||||
object.participant !== undefined && object.participant !== null
|
||||
? Participant.fromPartial(object.participant)
|
||||
: undefined;
|
||||
return message;
|
||||
},
|
||||
};
|
||||
|
||||
function createBaseQueryGetParticipantByNitroAddressRequest(): QueryGetParticipantByNitroAddressRequest {
|
||||
return { nitroAddress: "" };
|
||||
}
|
||||
|
||||
export const QueryGetParticipantByNitroAddressRequest = {
|
||||
encode(
|
||||
message: QueryGetParticipantByNitroAddressRequest,
|
||||
writer: _m0.Writer = _m0.Writer.create()
|
||||
): _m0.Writer {
|
||||
if (message.nitroAddress !== "") {
|
||||
writer.uint32(10).string(message.nitroAddress);
|
||||
}
|
||||
return writer;
|
||||
},
|
||||
|
||||
decode(
|
||||
input: _m0.Reader | Uint8Array,
|
||||
length?: number
|
||||
): QueryGetParticipantByNitroAddressRequest {
|
||||
const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);
|
||||
let end = length === undefined ? reader.len : reader.pos + length;
|
||||
const message = createBaseQueryGetParticipantByNitroAddressRequest();
|
||||
while (reader.pos < end) {
|
||||
const tag = reader.uint32();
|
||||
switch (tag >>> 3) {
|
||||
case 1:
|
||||
message.nitroAddress = reader.string();
|
||||
break;
|
||||
default:
|
||||
reader.skipType(tag & 7);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return message;
|
||||
},
|
||||
|
||||
fromJSON(object: any): QueryGetParticipantByNitroAddressRequest {
|
||||
return {
|
||||
nitroAddress: isSet(object.nitroAddress)
|
||||
? String(object.nitroAddress)
|
||||
: "",
|
||||
};
|
||||
},
|
||||
|
||||
toJSON(message: QueryGetParticipantByNitroAddressRequest): unknown {
|
||||
const obj: any = {};
|
||||
message.nitroAddress !== undefined &&
|
||||
(obj.nitroAddress = message.nitroAddress);
|
||||
return obj;
|
||||
},
|
||||
|
||||
fromPartial<
|
||||
I extends Exact<DeepPartial<QueryGetParticipantByNitroAddressRequest>, I>
|
||||
>(object: I): QueryGetParticipantByNitroAddressRequest {
|
||||
const message = createBaseQueryGetParticipantByNitroAddressRequest();
|
||||
message.nitroAddress = object.nitroAddress ?? "";
|
||||
return message;
|
||||
},
|
||||
};
|
||||
|
||||
function createBaseQueryGetParticipantByNitroAddressResponse(): QueryGetParticipantByNitroAddressResponse {
|
||||
return { participant: undefined };
|
||||
}
|
||||
|
||||
export const QueryGetParticipantByNitroAddressResponse = {
|
||||
encode(
|
||||
message: QueryGetParticipantByNitroAddressResponse,
|
||||
writer: _m0.Writer = _m0.Writer.create()
|
||||
): _m0.Writer {
|
||||
if (message.participant !== undefined) {
|
||||
Participant.encode(
|
||||
message.participant,
|
||||
writer.uint32(10).fork()
|
||||
).ldelim();
|
||||
}
|
||||
return writer;
|
||||
},
|
||||
|
||||
decode(
|
||||
input: _m0.Reader | Uint8Array,
|
||||
length?: number
|
||||
): QueryGetParticipantByNitroAddressResponse {
|
||||
const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);
|
||||
let end = length === undefined ? reader.len : reader.pos + length;
|
||||
const message = createBaseQueryGetParticipantByNitroAddressResponse();
|
||||
while (reader.pos < end) {
|
||||
const tag = reader.uint32();
|
||||
switch (tag >>> 3) {
|
||||
case 1:
|
||||
message.participant = Participant.decode(reader, reader.uint32());
|
||||
break;
|
||||
default:
|
||||
reader.skipType(tag & 7);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return message;
|
||||
},
|
||||
|
||||
fromJSON(object: any): QueryGetParticipantByNitroAddressResponse {
|
||||
return {
|
||||
participant: isSet(object.participant)
|
||||
? Participant.fromJSON(object.participant)
|
||||
: undefined,
|
||||
};
|
||||
},
|
||||
|
||||
toJSON(message: QueryGetParticipantByNitroAddressResponse): unknown {
|
||||
const obj: any = {};
|
||||
message.participant !== undefined &&
|
||||
(obj.participant = message.participant
|
||||
? Participant.toJSON(message.participant)
|
||||
: undefined);
|
||||
return obj;
|
||||
},
|
||||
|
||||
fromPartial<
|
||||
I extends Exact<DeepPartial<QueryGetParticipantByNitroAddressResponse>, I>
|
||||
>(object: I): QueryGetParticipantByNitroAddressResponse {
|
||||
const message = createBaseQueryGetParticipantByNitroAddressResponse();
|
||||
message.participant =
|
||||
object.participant !== undefined && object.participant !== null
|
||||
? Participant.fromPartial(object.participant)
|
||||
: undefined;
|
||||
return message;
|
||||
},
|
||||
};
|
||||
|
||||
/** Query defines the gRPC querier service for onboarding module */
|
||||
export interface Query {
|
||||
/** Participants queries Participants list */
|
||||
Participants(
|
||||
request: QueryParticipantsRequest
|
||||
): Promise<QueryParticipantsResponse>;
|
||||
/** GetParticipantByAddress queries a participant by cosmos (laconic) address */
|
||||
GetParticipantByAddress(
|
||||
request: QueryGetParticipantByAddressRequest
|
||||
): Promise<QueryGetParticipantByAddressResponse>;
|
||||
/** GetParticipantByNitroAddress queries a participant by nitro address */
|
||||
GetParticipantByNitroAddress(
|
||||
request: QueryGetParticipantByNitroAddressRequest
|
||||
): Promise<QueryGetParticipantByNitroAddressResponse>;
|
||||
}
|
||||
|
||||
export class QueryClientImpl implements Query {
|
||||
private readonly rpc: Rpc;
|
||||
constructor(rpc: Rpc) {
|
||||
this.rpc = rpc;
|
||||
this.Participants = this.Participants.bind(this);
|
||||
this.GetParticipantByAddress = this.GetParticipantByAddress.bind(this);
|
||||
this.GetParticipantByNitroAddress =
|
||||
this.GetParticipantByNitroAddress.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))
|
||||
);
|
||||
}
|
||||
|
||||
GetParticipantByAddress(
|
||||
request: QueryGetParticipantByAddressRequest
|
||||
): Promise<QueryGetParticipantByAddressResponse> {
|
||||
const data = QueryGetParticipantByAddressRequest.encode(request).finish();
|
||||
const promise = this.rpc.request(
|
||||
"cerc.onboarding.v1.Query",
|
||||
"GetParticipantByAddress",
|
||||
data
|
||||
);
|
||||
return promise.then((data) =>
|
||||
QueryGetParticipantByAddressResponse.decode(new _m0.Reader(data))
|
||||
);
|
||||
}
|
||||
|
||||
GetParticipantByNitroAddress(
|
||||
request: QueryGetParticipantByNitroAddressRequest
|
||||
): Promise<QueryGetParticipantByNitroAddressResponse> {
|
||||
const data =
|
||||
QueryGetParticipantByNitroAddressRequest.encode(request).finish();
|
||||
const promise = this.rpc.request(
|
||||
"cerc.onboarding.v1.Query",
|
||||
"GetParticipantByNitroAddress",
|
||||
data
|
||||
);
|
||||
return promise.then((data) =>
|
||||
QueryGetParticipantByNitroAddressResponse.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;
|
||||
}
|
||||
@@ -0,0 +1,254 @@
|
||||
/* 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;
|
||||
role: string;
|
||||
kycId: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* MsgOnboardParticipantResponse defines the Msg/OnboardParticipant response
|
||||
* type.
|
||||
*/
|
||||
export interface MsgOnboardParticipantResponse {}
|
||||
|
||||
function createBaseMsgOnboardParticipant(): MsgOnboardParticipant {
|
||||
return {
|
||||
participant: "",
|
||||
ethPayload: undefined,
|
||||
ethSignature: "",
|
||||
role: "",
|
||||
kycId: "",
|
||||
};
|
||||
}
|
||||
|
||||
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.role !== "") {
|
||||
writer.uint32(34).string(message.role);
|
||||
}
|
||||
if (message.kycId !== "") {
|
||||
writer.uint32(42).string(message.kycId);
|
||||
}
|
||||
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.role = reader.string();
|
||||
break;
|
||||
case 5:
|
||||
message.kycId = 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)
|
||||
: "",
|
||||
role: isSet(object.role) ? String(object.role) : "",
|
||||
kycId: isSet(object.kycId) ? String(object.kycId) : "",
|
||||
};
|
||||
},
|
||||
|
||||
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.role !== undefined && (obj.role = message.role);
|
||||
message.kycId !== undefined && (obj.kycId = message.kycId);
|
||||
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.role = object.role ?? "";
|
||||
message.kycId = object.kycId ?? "";
|
||||
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;
|
||||
}
|
||||
@@ -5,6 +5,7 @@ import {
|
||||
NameAuthority,
|
||||
NameRecord,
|
||||
NameEntry,
|
||||
AuthorityEntry,
|
||||
} from "./registry";
|
||||
import {
|
||||
PageRequest,
|
||||
@@ -118,6 +119,18 @@ export interface QueryWhoisResponse {
|
||||
nameAuthority?: NameAuthority;
|
||||
}
|
||||
|
||||
/** QueryAuthoritiesRequest is request type to get all authorities */
|
||||
export interface QueryAuthoritiesRequest {
|
||||
owner: string;
|
||||
}
|
||||
|
||||
/** QueryAuthoritiesResponse is response type for authorities request */
|
||||
export interface QueryAuthoritiesResponse {
|
||||
authorities: AuthorityEntry[];
|
||||
/** pagination defines the pagination in the response. */
|
||||
pagination?: PageResponse;
|
||||
}
|
||||
|
||||
/** QueryLookupLrnRequest is request type for LookupLrn */
|
||||
export interface QueryLookupLrnRequest {
|
||||
lrn: string;
|
||||
@@ -1460,6 +1473,151 @@ export const QueryWhoisResponse = {
|
||||
},
|
||||
};
|
||||
|
||||
function createBaseQueryAuthoritiesRequest(): QueryAuthoritiesRequest {
|
||||
return { owner: "" };
|
||||
}
|
||||
|
||||
export const QueryAuthoritiesRequest = {
|
||||
encode(
|
||||
message: QueryAuthoritiesRequest,
|
||||
writer: _m0.Writer = _m0.Writer.create()
|
||||
): _m0.Writer {
|
||||
if (message.owner !== "") {
|
||||
writer.uint32(10).string(message.owner);
|
||||
}
|
||||
return writer;
|
||||
},
|
||||
|
||||
decode(
|
||||
input: _m0.Reader | Uint8Array,
|
||||
length?: number
|
||||
): QueryAuthoritiesRequest {
|
||||
const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);
|
||||
let end = length === undefined ? reader.len : reader.pos + length;
|
||||
const message = createBaseQueryAuthoritiesRequest();
|
||||
while (reader.pos < end) {
|
||||
const tag = reader.uint32();
|
||||
switch (tag >>> 3) {
|
||||
case 1:
|
||||
message.owner = reader.string();
|
||||
break;
|
||||
default:
|
||||
reader.skipType(tag & 7);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return message;
|
||||
},
|
||||
|
||||
fromJSON(object: any): QueryAuthoritiesRequest {
|
||||
return {
|
||||
owner: isSet(object.owner) ? String(object.owner) : "",
|
||||
};
|
||||
},
|
||||
|
||||
toJSON(message: QueryAuthoritiesRequest): unknown {
|
||||
const obj: any = {};
|
||||
message.owner !== undefined && (obj.owner = message.owner);
|
||||
return obj;
|
||||
},
|
||||
|
||||
fromPartial<I extends Exact<DeepPartial<QueryAuthoritiesRequest>, I>>(
|
||||
object: I
|
||||
): QueryAuthoritiesRequest {
|
||||
const message = createBaseQueryAuthoritiesRequest();
|
||||
message.owner = object.owner ?? "";
|
||||
return message;
|
||||
},
|
||||
};
|
||||
|
||||
function createBaseQueryAuthoritiesResponse(): QueryAuthoritiesResponse {
|
||||
return { authorities: [], pagination: undefined };
|
||||
}
|
||||
|
||||
export const QueryAuthoritiesResponse = {
|
||||
encode(
|
||||
message: QueryAuthoritiesResponse,
|
||||
writer: _m0.Writer = _m0.Writer.create()
|
||||
): _m0.Writer {
|
||||
for (const v of message.authorities) {
|
||||
AuthorityEntry.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
|
||||
): QueryAuthoritiesResponse {
|
||||
const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);
|
||||
let end = length === undefined ? reader.len : reader.pos + length;
|
||||
const message = createBaseQueryAuthoritiesResponse();
|
||||
while (reader.pos < end) {
|
||||
const tag = reader.uint32();
|
||||
switch (tag >>> 3) {
|
||||
case 1:
|
||||
message.authorities.push(
|
||||
AuthorityEntry.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): QueryAuthoritiesResponse {
|
||||
return {
|
||||
authorities: Array.isArray(object?.authorities)
|
||||
? object.authorities.map((e: any) => AuthorityEntry.fromJSON(e))
|
||||
: [],
|
||||
pagination: isSet(object.pagination)
|
||||
? PageResponse.fromJSON(object.pagination)
|
||||
: undefined,
|
||||
};
|
||||
},
|
||||
|
||||
toJSON(message: QueryAuthoritiesResponse): unknown {
|
||||
const obj: any = {};
|
||||
if (message.authorities) {
|
||||
obj.authorities = message.authorities.map((e) =>
|
||||
e ? AuthorityEntry.toJSON(e) : undefined
|
||||
);
|
||||
} else {
|
||||
obj.authorities = [];
|
||||
}
|
||||
message.pagination !== undefined &&
|
||||
(obj.pagination = message.pagination
|
||||
? PageResponse.toJSON(message.pagination)
|
||||
: undefined);
|
||||
return obj;
|
||||
},
|
||||
|
||||
fromPartial<I extends Exact<DeepPartial<QueryAuthoritiesResponse>, I>>(
|
||||
object: I
|
||||
): QueryAuthoritiesResponse {
|
||||
const message = createBaseQueryAuthoritiesResponse();
|
||||
message.authorities =
|
||||
object.authorities?.map((e) => AuthorityEntry.fromPartial(e)) || [];
|
||||
message.pagination =
|
||||
object.pagination !== undefined && object.pagination !== null
|
||||
? PageResponse.fromPartial(object.pagination)
|
||||
: undefined;
|
||||
return message;
|
||||
},
|
||||
};
|
||||
|
||||
function createBaseQueryLookupLrnRequest(): QueryLookupLrnRequest {
|
||||
return { lrn: "" };
|
||||
}
|
||||
@@ -1907,6 +2065,10 @@ export interface Query {
|
||||
GetRegistryModuleBalance(
|
||||
request: QueryGetRegistryModuleBalanceRequest
|
||||
): Promise<QueryGetRegistryModuleBalanceResponse>;
|
||||
/** Authorities queries all authorities */
|
||||
Authorities(
|
||||
request: QueryAuthoritiesRequest
|
||||
): Promise<QueryAuthoritiesResponse>;
|
||||
}
|
||||
|
||||
export class QueryClientImpl implements Query {
|
||||
@@ -1922,6 +2084,7 @@ export class QueryClientImpl implements Query {
|
||||
this.LookupLrn = this.LookupLrn.bind(this);
|
||||
this.ResolveLrn = this.ResolveLrn.bind(this);
|
||||
this.GetRegistryModuleBalance = this.GetRegistryModuleBalance.bind(this);
|
||||
this.Authorities = this.Authorities.bind(this);
|
||||
}
|
||||
Params(request: QueryParamsRequest): Promise<QueryParamsResponse> {
|
||||
const data = QueryParamsRequest.encode(request).finish();
|
||||
@@ -2026,6 +2189,20 @@ export class QueryClientImpl implements Query {
|
||||
QueryGetRegistryModuleBalanceResponse.decode(new _m0.Reader(data))
|
||||
);
|
||||
}
|
||||
|
||||
Authorities(
|
||||
request: QueryAuthoritiesRequest
|
||||
): Promise<QueryAuthoritiesResponse> {
|
||||
const data = QueryAuthoritiesRequest.encode(request).finish();
|
||||
const promise = this.rpc.request(
|
||||
"cerc.registry.v1.Query",
|
||||
"Authorities",
|
||||
data
|
||||
);
|
||||
return promise.then((data) =>
|
||||
QueryAuthoritiesResponse.decode(new _m0.Reader(data))
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
interface Rpc {
|
||||
|
||||
+71
-13
@@ -151,31 +151,31 @@ export class RegistryClient {
|
||||
moniker
|
||||
}
|
||||
sync {
|
||||
latest_block_hash
|
||||
latest_block_height
|
||||
latest_block_time
|
||||
catching_up
|
||||
latestBlockHash
|
||||
latestBlockHeight
|
||||
latestBlockTime
|
||||
catchingUp
|
||||
}
|
||||
validator {
|
||||
address
|
||||
voting_power
|
||||
votingPower
|
||||
}
|
||||
validators {
|
||||
address
|
||||
voting_power
|
||||
proposer_priority
|
||||
votingPower
|
||||
proposerPriority
|
||||
}
|
||||
num_peers
|
||||
numPeers
|
||||
peers {
|
||||
node {
|
||||
id
|
||||
network
|
||||
moniker
|
||||
}
|
||||
is_outbound
|
||||
remote_ip
|
||||
isOutbound
|
||||
remoteIp
|
||||
}
|
||||
disk_usage
|
||||
diskUsage
|
||||
}
|
||||
}`;
|
||||
|
||||
@@ -241,7 +241,7 @@ export class RegistryClient {
|
||||
/**
|
||||
* Get records by attributes.
|
||||
*/
|
||||
async queryRecords (attributes: {[key: string]: any}, all = false, refs = false) {
|
||||
async queryRecords (attributes: { [key: string]: any }, all = false, refs = false) {
|
||||
if (!attributes) {
|
||||
attributes = {};
|
||||
}
|
||||
@@ -397,7 +397,7 @@ export class RegistryClient {
|
||||
}
|
||||
|
||||
/**
|
||||
* Get records by attributes.
|
||||
* Get bonds by attributes.
|
||||
*/
|
||||
async queryBonds (attributes = {}) {
|
||||
const query = `query ($attributes: [KeyValueInput!]) {
|
||||
@@ -417,4 +417,62 @@ export class RegistryClient {
|
||||
|
||||
return RegistryClient.getResult(this._graph(query)(variables), 'queryBonds');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get participants.
|
||||
*/
|
||||
async getParticipants () {
|
||||
const query = `query {
|
||||
getParticipants {
|
||||
cosmosAddress
|
||||
nitroAddress
|
||||
role
|
||||
kycId
|
||||
}
|
||||
}`;
|
||||
|
||||
const variables = {};
|
||||
|
||||
return RegistryClient.getResult(this._graph(query)(variables), 'getParticipants');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get participant by cosmos address.
|
||||
*/
|
||||
async getParticipantByAddress (address: string) {
|
||||
const query = `query ($address: String!) {
|
||||
getParticipantByAddress (address: $address) {
|
||||
cosmosAddress
|
||||
nitroAddress
|
||||
role
|
||||
kycId
|
||||
}
|
||||
}`;
|
||||
|
||||
const variables = {
|
||||
address
|
||||
};
|
||||
|
||||
return RegistryClient.getResult(this._graph(query)(variables), 'getParticipantByAddress');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get participant by nitro address.
|
||||
*/
|
||||
async getParticipantByNitroAddress (nitroAddress: string) {
|
||||
const query = `query ($nitroAddress: String!) {
|
||||
getParticipantByNitroAddress (nitroAddress: $nitroAddress) {
|
||||
cosmosAddress
|
||||
nitroAddress
|
||||
role
|
||||
kycId
|
||||
}
|
||||
}`;
|
||||
|
||||
const variables = {
|
||||
nitroAddress
|
||||
};
|
||||
|
||||
return RegistryClient.getResult(this._graph(query)(variables), 'getParticipantByNitroAddress');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,4 +7,4 @@ record:
|
||||
/: QmP8jTG1m9GSDJLCbeWhVSVgEzCPPwXRdCRuJtQ5Tz9Kc9
|
||||
tls_cert_cid:
|
||||
/: QmbWqxBEKC3P8tqsKc98xmWNzrzDtRLMiMPL8wBuTGsMnR
|
||||
version: 1.0.23
|
||||
version: 1.0.30
|
||||
|
||||
@@ -2,7 +2,7 @@ import assert from 'assert';
|
||||
import yaml from 'node-yaml';
|
||||
import semver from 'semver';
|
||||
|
||||
import { DEFAULT_CHAIN_ID } from '../index';
|
||||
import { DEFAULT_CHAIN_ID } from '../constants';
|
||||
|
||||
export const ensureUpdatedConfig = async (path: string) => {
|
||||
const conf = await yaml.read(path);
|
||||
@@ -28,7 +28,7 @@ export const getConfig = () => {
|
||||
rpcEndpoint: process.env.LACONICD_RPC_ENDPOINT || 'http://localhost:26657',
|
||||
gqlEndpoint: process.env.LACONICD_GQL_ENDPOINT || 'http://localhost:9473/api',
|
||||
fee: {
|
||||
amount: [{ denom: 'photon', amount: '40' }],
|
||||
amount: [{ denom: 'alnt', amount: '400000' }],
|
||||
gas: '400000'
|
||||
}
|
||||
};
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
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: MsgOnboardParticipant;
|
||||
}
|
||||
|
||||
interface ethPayload {
|
||||
address: string
|
||||
msg: string
|
||||
}
|
||||
|
||||
export interface MessageMsgOnboardParticipant {
|
||||
ethPayload: ethPayload
|
||||
ethSignature: string
|
||||
role: string
|
||||
kycId: string
|
||||
}
|
||||
Reference in New Issue
Block a user