|
@@ -5,14 +5,7 @@ import { KeyringPair } from '@polkadot/keyring/types';
|
|
|
import { UserInfo, PaidMembershipTerms, MemberId } from '@nicaea/types/members';
|
|
|
import { Mint, MintId } from '@nicaea/types/mint';
|
|
|
import { Lead, LeadId } from '@nicaea/types/content-working-group';
|
|
|
-import {
|
|
|
- Application,
|
|
|
- WorkerId,
|
|
|
- Worker,
|
|
|
- ApplicationIdToWorkerIdMap,
|
|
|
- Opening,
|
|
|
- RewardPolicy,
|
|
|
-} from '@nicaea/types/working-group';
|
|
|
+import { Application, WorkerId, Worker, ApplicationIdToWorkerIdMap, Opening } from '@nicaea/types/working-group';
|
|
|
import { Application as HiringApplication } from '@nicaea/types/hiring';
|
|
|
import { RoleParameters } from '@nicaea/types/roles';
|
|
|
import { Seat } from '@nicaea/types/lib/council';
|
|
@@ -49,6 +42,15 @@ export class ApiWrapper {
|
|
|
this.api.disconnect();
|
|
|
}
|
|
|
|
|
|
+ public getWorkingGroupString(workingGroup: WorkingGroups): string {
|
|
|
+ switch (workingGroup) {
|
|
|
+ case WorkingGroups.storageWorkingGroup:
|
|
|
+ return 'Storage';
|
|
|
+ default:
|
|
|
+ return 'Undefined';
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
public async buyMembership(
|
|
|
account: KeyringPair,
|
|
|
paidTermsId: number,
|
|
@@ -396,6 +398,23 @@ export class ApiWrapper {
|
|
|
);
|
|
|
}
|
|
|
|
|
|
+ public estimateProposeTerminateLeaderRole(): BN {
|
|
|
+ return this.estimateTxFee(
|
|
|
+ this.api.tx.proposalsCodex.createTerminateWorkingGroupLeaderRoleProposal(
|
|
|
+ 0,
|
|
|
+ 'Some testing text used for estimation purposes which is longer than text expected during the test',
|
|
|
+ 'Some testing text used for estimation purposes which is longer than text expected during the test',
|
|
|
+ 0,
|
|
|
+ {
|
|
|
+ worker_id: 0,
|
|
|
+ rationale: 'Exceptionaly long and extraordinary descriptive rationale',
|
|
|
+ slash: true,
|
|
|
+ working_group: 'Storage',
|
|
|
+ }
|
|
|
+ )
|
|
|
+ );
|
|
|
+ }
|
|
|
+
|
|
|
private applyForCouncilElection(account: KeyringPair, amount: BN): Promise<void> {
|
|
|
return this.sender.signAndSend(this.api.tx.councilElection.apply(amount), account, false);
|
|
|
}
|
|
@@ -803,6 +822,18 @@ export class ApiWrapper {
|
|
|
});
|
|
|
}
|
|
|
|
|
|
+ public expectLeaderUnset(): Promise<void> {
|
|
|
+ return new Promise(async resolve => {
|
|
|
+ await this.api.query.system.events<Vec<EventRecord>>(events => {
|
|
|
+ events.forEach(record => {
|
|
|
+ if (record.event.method && record.event.method.toString() === 'LeaderUnset') {
|
|
|
+ resolve();
|
|
|
+ }
|
|
|
+ });
|
|
|
+ });
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
public expectApplicationReviewBegan(): Promise<BN> {
|
|
|
return new Promise(async resolve => {
|
|
|
await this.api.query.system.events<Vec<EventRecord>>(events => {
|
|
@@ -927,6 +958,35 @@ export class ApiWrapper {
|
|
|
);
|
|
|
}
|
|
|
|
|
|
+ public async proposeTerminateLeaderRole(
|
|
|
+ account: KeyringPair,
|
|
|
+ title: string,
|
|
|
+ description: string,
|
|
|
+ proposalStake: BN,
|
|
|
+ leadWorkerId: BN,
|
|
|
+ rationale: string,
|
|
|
+ slash: boolean,
|
|
|
+ workingGroup: string
|
|
|
+ ): Promise<void> {
|
|
|
+ const memberId: BN = (await this.getMemberIds(account.address))[0];
|
|
|
+ return this.sender.signAndSend(
|
|
|
+ this.api.tx.proposalsCodex.createTerminateWorkingGroupLeaderRoleProposal(
|
|
|
+ memberId,
|
|
|
+ title,
|
|
|
+ description,
|
|
|
+ proposalStake,
|
|
|
+ {
|
|
|
+ worker_id: leadWorkerId,
|
|
|
+ rationale: rationale,
|
|
|
+ slash: slash,
|
|
|
+ working_group: workingGroup,
|
|
|
+ }
|
|
|
+ ),
|
|
|
+ account,
|
|
|
+ false
|
|
|
+ );
|
|
|
+ }
|
|
|
+
|
|
|
private createAddOpeningTransaction(
|
|
|
opening: WorkingGroupOpening,
|
|
|
module: WorkingGroups
|
|
@@ -1273,4 +1333,8 @@ export class ApiWrapper {
|
|
|
let rewardRelationshipId: BN = (await this.getWorkerById(workerId, module)).reward_relationship.unwrap();
|
|
|
return (await this.getRewardRelationship(rewardRelationshipId)).getField('account').toString();
|
|
|
}
|
|
|
+
|
|
|
+ public async getLeadWorkerId(module: WorkingGroups): Promise<BN | undefined> {
|
|
|
+ return (await this.api.query[module].currentLead<Option<WorkerId>>()).unwrapOr(undefined);
|
|
|
+ }
|
|
|
}
|