Accommodate participant role and kyc id and update tests
Some checks failed
Lint & Build / lint_and_build (20.x) (pull_request) Successful in 1m50s
Tests / sdk_tests (pull_request) Failing after 8m54s

This commit is contained in:
Prathamesh Musale 2024-07-25 17:19:35 +05:30
parent 651ea33ec5
commit 5735fb5608
5 changed files with 28 additions and 8 deletions

View File

@ -440,7 +440,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 +449,8 @@ export class Registry {
account.address,
ethPayload,
ethSignature,
role,
kycId,
fee
);
}

View File

@ -22,7 +22,7 @@ import { MsgCommitBidResponse, MsgRevealBidResponse } from './proto/cerc/auction
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';
import { EthPayload, Role } from './proto/cerc/onboarding/v1/onboarding';
const DEFAULT_WRITE_ERROR = 'Unable to write to laconicd.';
@ -394,6 +394,8 @@ export class LaconicClient extends SigningStargateClient {
signer: string,
ethPayload: EthPayload,
ethSignature: string,
role: Role,
kycId: string,
fee: StdFee | 'auto' | number,
memo = ''
) {
@ -402,7 +404,9 @@ export class LaconicClient extends SigningStargateClient {
value: {
participant: signer,
ethPayload,
ethSignature
ethSignature,
role,
kycId
}
};

View File

@ -4,12 +4,15 @@ import { DirectSecp256k1Wallet } from '@cosmjs/proto-signing';
import { Registry, Account } from './index';
import { getConfig } from './testing/helper';
import { Participant } from './proto/cerc/onboarding/v1/onboarding';
import { Participant, Role } from './proto/cerc/onboarding/v1/onboarding';
const { chainId, rpcEndpoint, gqlEndpoint, privateKey, fee } = getConfig();
jest.setTimeout(90 * 1000);
const DUMMY_ROLE = Role.ROLE_VALIDATOR;
const DUMMY_KYC_ID = 'dummyKycId';
const onboardingEnabledTests = () => {
let registry: Registry;
let ethWallet: Wallet;
@ -32,7 +35,9 @@ const onboardingEnabledTests = () => {
await registry.onboardParticipant({
ethPayload,
ethSignature
ethSignature,
role: DUMMY_ROLE,
kycId: DUMMY_KYC_ID
}, privateKey, fee);
});
@ -41,10 +46,12 @@ const onboardingEnabledTests = () => {
const cosmosAccount = await DirectSecp256k1Wallet.fromKey(account._privateKey, 'laconic');
const [cosmosWallet] = await cosmosAccount.getAccounts();
const expectedParticipants = [
const expectedParticipants: Participant[] = [
{
cosmosAddress: cosmosWallet.address,
nitroAddress: ethWallet.address
nitroAddress: ethWallet.address,
role: DUMMY_ROLE,
kycId: DUMMY_KYC_ID
}
];
const participants = await registry.getParticipants();
@ -76,7 +83,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);

View File

@ -426,6 +426,8 @@ export class RegistryClient {
getParticipants {
cosmosAddress
nitroAddress
role
kycId
}
}`;

View File

@ -1,6 +1,7 @@
import { EncodeObject, GeneratedType } from '@cosmjs/proto-signing';
import { MsgOnboardParticipantResponse, MsgOnboardParticipant } from '../../../proto/cerc/onboarding/v1/tx';
import { Role } from '../../../proto/cerc/onboarding/v1/onboarding';
export const typeUrlMsgOnboardParticipant = '/cerc.onboarding.v1.MsgOnboardParticipant';
export const typeUrlMsgOnboardParticipantResponse = '/cerc.onboarding.v1.MsgOnboardParticipantResponse';
@ -23,4 +24,6 @@ interface ethPayload {
export interface MessageMsgOnboardParticipant {
ethPayload: ethPayload
ethSignature: string
role: Role
kycId: string
}