Compare commits

..
10 Commits
Author SHA1 Message Date
IshaVenikar 5fe6c432de Fix authority expiry timeout 2024-08-05 09:57:11 +05:30
IshaVenikar 37c2f5897f Check for properties in returned authorities list 2024-08-02 16:06:37 +05:30
IshaVenikar 225aa2a6aa Check name and owner address for authorities 2024-08-02 15:15:05 +05:30
IshaVenikar 81dbf57fc2 Update check for list authorities by owner 2024-08-02 11:52:49 +05:30
IshaVenikar a3b78fd363 Check owner address for returned authorities 2024-08-02 10:04:14 +05:30
IshaVenikar 52cab23c70 Add method for get authorities 2024-08-01 16:44:21 +05:30
prathameshandIshaVenikar 147348cf1d Change token denom from photon to alnt (#17)
Part of [laconicd testnet validator enrollment](https://www.notion.so/laconicd-testnet-validator-enrollment-6fc1d3cafcc64fef8c5ed3affa27c675)

Co-authored-by: IshaVenikar <ishavenikar7@gmail.com>
Reviewed-on: cerc-io/registry-sdk#17
Co-authored-by: Prathamesh Musale <prathamesh.musale0@gmail.com>
Co-committed-by: Prathamesh Musale <prathamesh.musale0@gmail.com>
2024-07-30 11:55:33 +00:00
prathameshandIshaVenikar 5fc42e897a Add queries to get participant by laconic or nitro address (#16)
Part of [laconicd testnet validator enrollment](https://www.notion.so/laconicd-testnet-validator-enrollment-6fc1d3cafcc64fef8c5ed3affa27c675)

Co-authored-by: IshaVenikar <ishavenikar7@gmail.com>
Reviewed-on: cerc-io/registry-sdk#16
Co-authored-by: Prathamesh Musale <prathamesh.musale0@gmail.com>
Co-committed-by: Prathamesh Musale <prathamesh.musale0@gmail.com>
2024-07-29 11:19:23 +00:00
prathameshandnabarun 3a828b47ae Accommodate changes for participant role and KYC ID (#15)
Part of [Sumsub KYC integration in onboarding app](https://www.notion.so/Sumsub-KYC-integration-in-onboarding-app-607b598c9c1d4d12adc71725e2ab5e7e)
Follows cerc-io/laconicd#43

Co-authored-by: Nabarun <nabarun@deepstacksoft.com>
Reviewed-on: cerc-io/registry-sdk#15
Co-authored-by: Prathamesh Musale <prathamesh.musale0@gmail.com>
Co-committed-by: Prathamesh Musale <prathamesh.musale0@gmail.com>
2024-07-26 15:41:00 +00:00
nabarun 022c55268c Rename laconic2d repo to laconicd in CI (#14)
Part of [Rename laconic2d to laconicd](https://www.notion.so/Rename-laconic2d-to-laconicd-9028d0c020d24d1288e92ebcb773d7a7)

Reviewed-on: cerc-io/registry-sdk#14
Co-authored-by: Nabarun <nabarun@deepstacksoft.com>
Co-committed-by: Nabarun <nabarun@deepstacksoft.com>
2024-07-23 04:52:49 +00:00
23 changed files with 911 additions and 71 deletions
+1 -1
View File
@@ -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
+1 -1
View File
@@ -15,7 +15,7 @@ jobs:
uses: actions/checkout@v3
with:
path: "./laconicd/"
repository: cerc-io/laconic2d
repository: cerc-io/laconicd
fetch-depth: 0
ref: main
- name: Environment
+9 -8
View File
@@ -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
```
+1 -1
View File
@@ -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`.
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@cerc-io/registry-sdk",
"version": "0.2.2",
"version": "0.2.6",
"main": "dist/index.js",
"types": "dist/index.d.ts",
"repository": "git@github.com:cerc-io/registry-sdk.git",
+24 -16
View File
@@ -8,28 +8,36 @@ 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\""
];
bool onboarding_enabled = 1
[ (gogoproto.moretags) =
"json:\"onboarding_enabled\" yaml:\"onboarding_enabled\"" ];
}
// Participant defines the data that will be stored for each enrolled participant
// 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\""
];
// participant's cosmos (laconic) address
string cosmos_address = 1
[ (gogoproto.moretags) =
"json:\"cosmos_address\" yaml:\"cosmos_address\"" ];
string nitro_address = 2 [
(gogoproto.moretags) = "json:\"nitro_address\" yaml:\"nitro_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 address = 1
[ (gogoproto.moretags) = "json:\"address\" yaml:\"address\"" ];
string msg = 2 [
(gogoproto.moretags) = "json:\"msg\" yaml:\"msg\""
];
string msg = 2 [ (gogoproto.moretags) = "json:\"msg\" yaml:\"msg\"" ];
}
+44 -2
View File
@@ -12,9 +12,23 @@ 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) {
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
@@ -23,7 +37,7 @@ message QueryParticipantsRequest {
cosmos.base.query.v1beta1.PageRequest pagination = 1;
}
// QueryParticipantsResponse is response type for get the participants
// QueryParticipantsResponse is response type for querying the participants
message QueryParticipantsResponse {
repeated Participant participants = 1
[ (gogoproto.moretags) = "json:\"participants\" yaml:\"participants\"" ];
@@ -31,3 +45,31 @@ message QueryParticipantsResponse {
// 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;
}
+7 -4
View File
@@ -15,9 +15,9 @@ service Msg {
// OnboardParticipant defines a method for enrolling a new validator.
rpc OnboardParticipant(MsgOnboardParticipant)
returns (MsgOnboardParticipantResponse) {
option (google.api.http).post = "/cerc/onboarding/v1/onboard_participant";
};
returns (MsgOnboardParticipantResponse) {
option (google.api.http).post = "/cerc/onboarding/v1/onboard_participant";
};
}
// MsgOnboardParticipant defines a SDK message for enrolling a new validator.
@@ -28,7 +28,10 @@ message MsgOnboardParticipant {
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.
// MsgOnboardParticipantResponse defines the Msg/OnboardParticipant response
// type.
message MsgOnboardParticipantResponse {}
+15
View File
@@ -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
View File
@@ -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
+1 -1
View File
@@ -1 +1 @@
export const DENOM = 'photon';
export const DENOM = 'alnt';
+24 -1
View File
@@ -389,6 +389,13 @@ export class Registry {
return this._client.getAuctionsByIds(ids);
}
/**
* List authorities by owner.
*/
async getAuthorities (owner?: string, auction = false) {
return this._client.getAuthorities(owner, auction);
}
/**
* Lookup authorities by names.
*/
@@ -440,7 +447,7 @@ export class Registry {
/**
* Onboard participant.
*/
async onboardParticipant ({ ethPayload, ethSignature }: MessageMsgOnboardParticipant, privateKey: string, fee: StdFee): Promise<MsgOnboardParticipantResponse> {
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);
@@ -449,6 +456,8 @@ export class Registry {
account.address,
ethPayload,
ethSignature,
role,
kycId,
fee
);
}
@@ -459,6 +468,20 @@ export class Registry {
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 };
+6 -2
View File
@@ -24,7 +24,7 @@ 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,
@@ -394,6 +394,8 @@ export class LaconicClient extends SigningStargateClient {
signer: string,
ethPayload: EthPayload,
ethSignature: string,
role: string,
kycId: string,
fee: StdFee | 'auto' | number,
memo = ''
) {
@@ -402,7 +404,9 @@ export class LaconicClient extends SigningStargateClient {
value: {
participant: signer,
ethPayload,
ethSignature
ethSignature,
role,
kycId
}
};
+11 -3
View File
@@ -60,7 +60,11 @@ const nameserviceExpiryTests = () => {
});
test('Wait for expiry duration', (done) => {
setTimeout(done, 60 * 1000);
const expiryTime = 60 * 1000;
// Wait some more time for block to be executed
const waitTime = expiryTime + (3 * 1000);
setTimeout(done, waitTime);
});
test('Check record expiry time', async () => {
@@ -84,7 +88,11 @@ const nameserviceExpiryTests = () => {
});
test('Wait for expiry duration', (done) => {
setTimeout(done, 60 * 1000);
const expiryTime = 60 * 1000;
// Wait some more time for block to be executed
const waitTime = expiryTime + (3 * 1000);
setTimeout(done, waitTime);
});
test('Check record deleted without bond balance', async () => {
@@ -103,7 +111,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
+86 -5
View File
@@ -1,6 +1,8 @@
import assert from 'assert';
import path from 'path';
import { DirectSecp256k1Wallet, AccountData as CosmosAccount } from '@cosmjs/proto-signing';
import { Account } from './account';
import { Registry } from './index';
import { ensureUpdatedConfig, getConfig } from './testing/helper';
@@ -19,6 +21,18 @@ const namingTests = () => {
let watcher: any;
let watcherId: string;
let otherAccount1: Account;
let reservedAuthorities: {
name: string;
entry: {
ownerAddress: string;
status: string;
};
}[] = [];
let account: CosmosAccount;
beforeAll(async () => {
registry = new Registry(gqlEndpoint, rpcEndpoint, chainId);
@@ -39,12 +53,26 @@ const namingTests = () => {
);
watcherId = result.id;
const accountWallet = await DirectSecp256k1Wallet.fromKey(Buffer.from(privateKey, 'hex'), 'laconic');
[account] = await accountWallet.getAccounts();
const mnenonic1 = Account.generateMnemonic();
otherAccount1 = await Account.generateFromMnemonic(mnenonic1);
await otherAccount1.init();
});
describe('Authority tests', () => {
test('Reserve authority.', async () => {
const authorityName = `laconic-${Date.now()}`;
await registry.reserveAuthority({ name: authorityName }, privateKey, fee);
reservedAuthorities.push({
name: authorityName,
entry: {
ownerAddress: account.address,
status: 'active'
}
});
});
describe('With authority reserved', () => {
@@ -56,6 +84,13 @@ const namingTests = () => {
lrn = `lrn://${authorityName}/app/test`;
await registry.reserveAuthority({ name: authorityName }, privateKey, fee);
reservedAuthorities.push({
name: authorityName,
entry: {
ownerAddress: account.address,
status: 'active'
}
});
});
test('Lookup authority.', async () => {
@@ -80,6 +115,13 @@ const namingTests = () => {
test('Reserve sub-authority.', async () => {
const subAuthority = `echo.${authorityName}`;
await registry.reserveAuthority({ name: subAuthority }, privateKey, fee);
reservedAuthorities.push({
name: subAuthority,
entry: {
ownerAddress: account.address,
status: 'active'
}
});
const [record] = await registry.lookupAuthorities([subAuthority]);
expect(record).toBeDefined();
@@ -90,18 +132,22 @@ const namingTests = () => {
test('Reserve sub-authority with different owner.', async () => {
// Create another account, send tx to set public key on the account.
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);
const mnenonic2 = Account.generateMnemonic();
const otherAccount2 = await Account.generateFromMnemonic(mnenonic2);
await otherAccount2.init();
await registry.sendCoins({ denom: DENOM, amount: '1000000000', destinationAddress: otherAccount1.address }, privateKey, fee);
await registry.sendCoins({ denom: DENOM, amount: '1000', destinationAddress: otherAccount2.address }, otherAccount1.getPrivateKey(), fee);
const subAuthority = `halo.${authorityName}`;
await registry.reserveAuthority({ name: subAuthority, owner: otherAccount1.address }, privateKey, fee);
reservedAuthorities.push({
name: subAuthority,
entry: {
ownerAddress: otherAccount1.address,
status: 'active'
}
});
const [record] = await registry.lookupAuthorities([subAuthority]);
expect(record).toBeDefined();
@@ -120,6 +166,41 @@ const namingTests = () => {
test('Set authority bond', async () => {
await registry.setAuthorityBond({ name: authorityName, bondId }, privateKey, fee);
});
test('List authorities.', async () => {
const authorities = await registry.getAuthorities(undefined, true);
reservedAuthorities.sort((a, b) => a.name.localeCompare(b.name));
const expectedEntryKeys = [
'ownerAddress',
'ownerPublicKey',
'height',
'status',
'bondId',
'expiryTime',
'auction'
];
expect(authorities.length).toEqual(4);
expectedEntryKeys.forEach(key => {
authorities.forEach((authority: any) => {
expect(authority.entry).toHaveProperty(key);
});
});
authorities.forEach((authority: any, index: number) => {
expect(authority).toHaveProperty('name');
expect(authority.entry).toHaveProperty('ownerAddress');
expect(authority.entry).toHaveProperty('status');
expect(authority).toMatchObject(reservedAuthorities[index]);
});
});
test('List authorities by owner.', async () => {
const authorities = await registry.getAuthorities(otherAccount1.address);
expect(authorities.length).toEqual(1);
expect(authorities[0].entry.ownerAddress).toBe(otherAccount1.address);
expect(authorities[0].entry.ownerPublicKey).toBe(otherAccount1.encodedPubkey);
});
});
});
+37 -16
View File
@@ -1,6 +1,6 @@
import { Wallet } from 'ethers';
import { DirectSecp256k1Wallet } from '@cosmjs/proto-signing';
import { DirectSecp256k1Wallet, AccountData as CosmosAccount } from '@cosmjs/proto-signing';
import { Registry, Account } from './index';
import { getConfig } from './testing/helper';
@@ -10,18 +10,35 @@ 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);
});
test('Onboard participant.', async () => {
const mnemonic = Account.generateMnemonic();
ethWallet = Wallet.fromMnemonic(mnemonic);
const accountWallet = await DirectSecp256k1Wallet.fromKey(Buffer.from(privateKey, 'hex'), 'laconic');
[cosmosWallet] = await accountWallet.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'
@@ -32,24 +49,26 @@ const onboardingEnabledTests = () => {
await registry.onboardParticipant({
ethPayload,
ethSignature
ethSignature,
role: DUMMY_ROLE,
kycId: DUMMY_KYC_ID
}, privateKey, fee);
});
test('Query participants.', async () => {
const account = new Account(Buffer.from(privateKey, 'hex'));
const cosmosAccount = await DirectSecp256k1Wallet.fromKey(account._privateKey, 'laconic');
const [cosmosWallet] = await cosmosAccount.getAccounts();
const expectedParticipants = [
{
cosmosAddress: cosmosWallet.address,
nitroAddress: ethWallet.address
}
];
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 = () => {
@@ -76,7 +95,9 @@ const onboardingDisabledTests = () => {
try {
await registry.onboardParticipant({
ethPayload,
ethSignature
ethSignature,
role: DUMMY_ROLE,
kycId: DUMMY_KYC_ID
}, privateKey, fee);
} catch (error: any) {
expect(error.toString()).toContain(errorMsg);
@@ -94,7 +115,7 @@ if (process.env.ONBOARDING_ENABLED !== '1') {
describe('Onboarding disabled', onboardingDisabledTests);
} else {
/**
Running this test requires participants onboarding enabled. In laconic2d repo run:
Running this test requires participants onboarding enabled. In laconicd repo run:
ONBOARDING_ENABLED=true ./init.sh
+29 -2
View File
@@ -9,10 +9,19 @@ export interface Params {
onboardingEnabled: boolean;
}
/** Participant defines the data that will be stored for each enrolled participant */
/**
* 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 */
@@ -77,7 +86,7 @@ export const Params = {
};
function createBaseParticipant(): Participant {
return { cosmosAddress: "", nitroAddress: "" };
return { cosmosAddress: "", nitroAddress: "", role: "", kycId: "" };
}
export const Participant = {
@@ -91,6 +100,12 @@ export const Participant = {
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;
},
@@ -107,6 +122,12 @@ export const Participant = {
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;
@@ -123,6 +144,8 @@ export const Participant = {
nitroAddress: isSet(object.nitroAddress)
? String(object.nitroAddress)
: "",
role: isSet(object.role) ? String(object.role) : "",
kycId: isSet(object.kycId) ? String(object.kycId) : "",
};
},
@@ -132,6 +155,8 @@ export const Participant = {
(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;
},
@@ -141,6 +166,8 @@ export const Participant = {
const message = createBaseParticipant();
message.cosmosAddress = object.cosmosAddress ?? "";
message.nitroAddress = object.nitroAddress ?? "";
message.role = object.role ?? "";
message.kycId = object.kycId ?? "";
return message;
},
};
+331 -2
View File
@@ -3,8 +3,8 @@ import {
PageRequest,
PageResponse,
} from "../../../cosmos/base/query/v1beta1/pagination";
import Long from "long";
import { Participant } from "./onboarding";
import Long from "long";
import _m0 from "protobufjs/minimal";
export const protobufPackage = "cerc.onboarding.v1";
@@ -15,13 +15,49 @@ export interface QueryParticipantsRequest {
pagination?: PageRequest;
}
/** QueryParticipantsResponse is response type for get the participants */
/** 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 };
}
@@ -175,12 +211,273 @@ export const QueryParticipantsResponse = {
},
};
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 {
@@ -188,6 +485,9 @@ export class QueryClientImpl implements Query {
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
@@ -202,6 +502,35 @@ export class QueryClientImpl implements Query {
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 {
+31 -2
View File
@@ -11,13 +11,24 @@ export interface MsgOnboardParticipant {
participant: string;
ethPayload?: EthPayload;
ethSignature: string;
role: string;
kycId: string;
}
/** MsgOnboardParticipantResponse defines the Msg/OnboardParticipant response type. */
/**
* MsgOnboardParticipantResponse defines the Msg/OnboardParticipant response
* type.
*/
export interface MsgOnboardParticipantResponse {}
function createBaseMsgOnboardParticipant(): MsgOnboardParticipant {
return { participant: "", ethPayload: undefined, ethSignature: "" };
return {
participant: "",
ethPayload: undefined,
ethSignature: "",
role: "",
kycId: "",
};
}
export const MsgOnboardParticipant = {
@@ -34,6 +45,12 @@ export const MsgOnboardParticipant = {
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;
},
@@ -56,6 +73,12 @@ export const MsgOnboardParticipant = {
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;
@@ -73,6 +96,8 @@ export const MsgOnboardParticipant = {
ethSignature: isSet(object.ethSignature)
? String(object.ethSignature)
: "",
role: isSet(object.role) ? String(object.role) : "",
kycId: isSet(object.kycId) ? String(object.kycId) : "",
};
},
@@ -86,6 +111,8 @@ export const MsgOnboardParticipant = {
: undefined);
message.ethSignature !== undefined &&
(obj.ethSignature = message.ethSignature);
message.role !== undefined && (obj.role = message.role);
message.kycId !== undefined && (obj.kycId = message.kycId);
return obj;
},
@@ -99,6 +126,8 @@ export const MsgOnboardParticipant = {
? EthPayload.fromPartial(object.ethPayload)
: undefined;
message.ethSignature = object.ethSignature ?? "";
message.role = object.role ?? "";
message.kycId = object.kycId ?? "";
return message;
},
};
+177
View File
@@ -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 {
+70
View File
@@ -270,6 +270,34 @@ export class RegistryClient {
return result;
}
/**
* List authorities by owner.
*/
async getAuthorities (owner?: string, auction = false) {
const query = `query ($owner: String) {
getAuthorities(owner: $owner) {
name
entry {
ownerAddress
ownerPublicKey
height
status
bondId
expiryTime
${auction ? ('auction { ' + auctionFields + ' }') : ''}
}
}
}`;
const variables = {
owner
};
const result = await this._graph(query)(variables);
return result.getAuthorities;
}
/**
* Lookup authorities by names.
*/
@@ -426,6 +454,8 @@ export class RegistryClient {
getParticipants {
cosmosAddress
nitroAddress
role
kycId
}
}`;
@@ -433,4 +463,44 @@ export class RegistryClient {
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');
}
}
+1 -1
View File
@@ -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'
}
};
+3 -1
View File
@@ -12,7 +12,7 @@ export const onboardingTypes: ReadonlyArray<[string, GeneratedType]> = [
export interface MsgOnboardParticipantEncodeObject extends EncodeObject {
readonly typeUrl: '/cerc.onboarding.v1.MsgOnboardParticipant';
readonly value: Partial<MsgOnboardParticipant>;
readonly value: MsgOnboardParticipant;
}
interface ethPayload {
@@ -23,4 +23,6 @@ interface ethPayload {
export interface MessageMsgOnboardParticipant {
ethPayload: ethPayload
ethSignature: string
role: string
kycId: string
}