Accommodate changes for participant role and KYC ID #15
@ -440,7 +440,7 @@ export class Registry {
|
|||||||
/**
|
/**
|
||||||
* Onboard participant.
|
* 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'));
|
const account = new Account(Buffer.from(privateKey, 'hex'));
|
||||||
await account.init();
|
await account.init();
|
||||||
const laconicClient = await this.getLaconicClient(account);
|
const laconicClient = await this.getLaconicClient(account);
|
||||||
@ -449,6 +449,8 @@ export class Registry {
|
|||||||
account.address,
|
account.address,
|
||||||
ethPayload,
|
ethPayload,
|
||||||
ethSignature,
|
ethSignature,
|
||||||
|
role,
|
||||||
|
kycId,
|
||||||
fee
|
fee
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -22,7 +22,7 @@ import { MsgCommitBidResponse, MsgRevealBidResponse } from './proto/cerc/auction
|
|||||||
import { MsgCancelBondResponse, MsgCreateBondResponse, MsgRefillBondResponse, MsgWithdrawBondResponse } from './proto/cerc/bond/v1/tx';
|
import { MsgCancelBondResponse, MsgCreateBondResponse, MsgRefillBondResponse, MsgWithdrawBondResponse } from './proto/cerc/bond/v1/tx';
|
||||||
import { MsgOnboardParticipantResponse } from './proto/cerc/onboarding/v1/tx';
|
import { MsgOnboardParticipantResponse } from './proto/cerc/onboarding/v1/tx';
|
||||||
import { bankTypes } from './types/cosmos/bank/message';
|
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.';
|
const DEFAULT_WRITE_ERROR = 'Unable to write to laconicd.';
|
||||||
|
|
||||||
@ -394,6 +394,8 @@ export class LaconicClient extends SigningStargateClient {
|
|||||||
signer: string,
|
signer: string,
|
||||||
ethPayload: EthPayload,
|
ethPayload: EthPayload,
|
||||||
ethSignature: string,
|
ethSignature: string,
|
||||||
|
role: Role,
|
||||||
|
kycId: string,
|
||||||
fee: StdFee | 'auto' | number,
|
fee: StdFee | 'auto' | number,
|
||||||
memo = ''
|
memo = ''
|
||||||
) {
|
) {
|
||||||
@ -402,7 +404,9 @@ export class LaconicClient extends SigningStargateClient {
|
|||||||
value: {
|
value: {
|
||||||
participant: signer,
|
participant: signer,
|
||||||
ethPayload,
|
ethPayload,
|
||||||
ethSignature
|
ethSignature,
|
||||||
|
role,
|
||||||
|
kycId
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -4,12 +4,15 @@ import { DirectSecp256k1Wallet } from '@cosmjs/proto-signing';
|
|||||||
|
|
||||||
import { Registry, Account } from './index';
|
import { Registry, Account } from './index';
|
||||||
import { getConfig } from './testing/helper';
|
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();
|
const { chainId, rpcEndpoint, gqlEndpoint, privateKey, fee } = getConfig();
|
||||||
|
|
||||||
jest.setTimeout(90 * 1000);
|
jest.setTimeout(90 * 1000);
|
||||||
|
|
||||||
|
const DUMMY_ROLE = Role.ROLE_VALIDATOR;
|
||||||
|
const DUMMY_KYC_ID = 'dummyKycId';
|
||||||
|
|
||||||
const onboardingEnabledTests = () => {
|
const onboardingEnabledTests = () => {
|
||||||
let registry: Registry;
|
let registry: Registry;
|
||||||
let ethWallet: Wallet;
|
let ethWallet: Wallet;
|
||||||
@ -32,7 +35,9 @@ const onboardingEnabledTests = () => {
|
|||||||
|
|
||||||
await registry.onboardParticipant({
|
await registry.onboardParticipant({
|
||||||
ethPayload,
|
ethPayload,
|
||||||
ethSignature
|
ethSignature,
|
||||||
|
role: DUMMY_ROLE,
|
||||||
|
kycId: DUMMY_KYC_ID
|
||||||
}, privateKey, fee);
|
}, privateKey, fee);
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -41,10 +46,12 @@ const onboardingEnabledTests = () => {
|
|||||||
const cosmosAccount = await DirectSecp256k1Wallet.fromKey(account._privateKey, 'laconic');
|
const cosmosAccount = await DirectSecp256k1Wallet.fromKey(account._privateKey, 'laconic');
|
||||||
const [cosmosWallet] = await cosmosAccount.getAccounts();
|
const [cosmosWallet] = await cosmosAccount.getAccounts();
|
||||||
|
|
||||||
const expectedParticipants = [
|
const expectedParticipants: Participant[] = [
|
||||||
{
|
{
|
||||||
cosmosAddress: cosmosWallet.address,
|
cosmosAddress: cosmosWallet.address,
|
||||||
nitroAddress: ethWallet.address
|
nitroAddress: ethWallet.address,
|
||||||
|
role: DUMMY_ROLE,
|
||||||
|
kycId: DUMMY_KYC_ID
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
const participants = await registry.getParticipants();
|
const participants = await registry.getParticipants();
|
||||||
@ -76,7 +83,9 @@ const onboardingDisabledTests = () => {
|
|||||||
try {
|
try {
|
||||||
await registry.onboardParticipant({
|
await registry.onboardParticipant({
|
||||||
ethPayload,
|
ethPayload,
|
||||||
ethSignature
|
ethSignature,
|
||||||
|
role: DUMMY_ROLE,
|
||||||
|
kycId: DUMMY_KYC_ID
|
||||||
}, privateKey, fee);
|
}, privateKey, fee);
|
||||||
} catch (error: any) {
|
} catch (error: any) {
|
||||||
expect(error.toString()).toContain(errorMsg);
|
expect(error.toString()).toContain(errorMsg);
|
||||||
|
@ -426,6 +426,8 @@ export class RegistryClient {
|
|||||||
getParticipants {
|
getParticipants {
|
||||||
cosmosAddress
|
cosmosAddress
|
||||||
nitroAddress
|
nitroAddress
|
||||||
|
role
|
||||||
|
kycId
|
||||||
}
|
}
|
||||||
}`;
|
}`;
|
||||||
|
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
import { EncodeObject, GeneratedType } from '@cosmjs/proto-signing';
|
import { EncodeObject, GeneratedType } from '@cosmjs/proto-signing';
|
||||||
|
|
||||||
import { MsgOnboardParticipantResponse, MsgOnboardParticipant } from '../../../proto/cerc/onboarding/v1/tx';
|
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 typeUrlMsgOnboardParticipant = '/cerc.onboarding.v1.MsgOnboardParticipant';
|
||||||
export const typeUrlMsgOnboardParticipantResponse = '/cerc.onboarding.v1.MsgOnboardParticipantResponse';
|
export const typeUrlMsgOnboardParticipantResponse = '/cerc.onboarding.v1.MsgOnboardParticipantResponse';
|
||||||
@ -23,4 +24,6 @@ interface ethPayload {
|
|||||||
export interface MessageMsgOnboardParticipant {
|
export interface MessageMsgOnboardParticipant {
|
||||||
ethPayload: ethPayload
|
ethPayload: ethPayload
|
||||||
ethSignature: string
|
ethSignature: string
|
||||||
|
role: Role
|
||||||
|
kycId: string
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user