|
@@ -1,38 +1,34 @@
|
|
import { ApiPromise, WsProvider } from '@polkadot/api'
|
|
import { ApiPromise, WsProvider } from '@polkadot/api'
|
|
-import { Bytes, Option, u32, Vec } from '@polkadot/types'
|
|
|
|
|
|
+import { Bytes, Option, u32, Vec, StorageKey } from '@polkadot/types'
|
|
import { Codec } from '@polkadot/types/types'
|
|
import { Codec } from '@polkadot/types/types'
|
|
import { KeyringPair } from '@polkadot/keyring/types'
|
|
import { KeyringPair } from '@polkadot/keyring/types'
|
|
-import { MemberId, PaidMembershipTerms, PaidTermId, UserInfo } from '@alexandria/types/members'
|
|
|
|
|
|
+import { MemberId, PaidMembershipTerms, PaidTermId } from '@alexandria/types/members'
|
|
import { Mint, MintId } from '@alexandria/types/mint'
|
|
import { Mint, MintId } from '@alexandria/types/mint'
|
|
import { Lead, LeadId } from '@alexandria/types/content-working-group'
|
|
import { Lead, LeadId } from '@alexandria/types/content-working-group'
|
|
import {
|
|
import {
|
|
Application,
|
|
Application,
|
|
ApplicationIdToWorkerIdMap,
|
|
ApplicationIdToWorkerIdMap,
|
|
- RewardPolicy,
|
|
|
|
- SlashingTerms,
|
|
|
|
Worker,
|
|
Worker,
|
|
WorkerId,
|
|
WorkerId,
|
|
WorkingGroupOpeningPolicyCommitment,
|
|
WorkingGroupOpeningPolicyCommitment,
|
|
} from '@alexandria/types/working-group'
|
|
} from '@alexandria/types/working-group'
|
|
import { ElectionStake, Seat } from '@alexandria/types/council'
|
|
import { ElectionStake, Seat } from '@alexandria/types/council'
|
|
-import { AccountId, Balance, BalanceOf, BlockNumber, Event, EventRecord } from '@polkadot/types/interfaces'
|
|
|
|
|
|
+import { AccountId, AccountInfo, Balance, BalanceOf, BlockNumber, Event, EventRecord } from '@polkadot/types/interfaces'
|
|
import BN from 'bn.js'
|
|
import BN from 'bn.js'
|
|
import { SubmittableExtrinsic } from '@polkadot/api/types'
|
|
import { SubmittableExtrinsic } from '@polkadot/api/types'
|
|
import { Sender } from './sender'
|
|
import { Sender } from './sender'
|
|
import { Utils } from './utils'
|
|
import { Utils } from './utils'
|
|
import { Stake, StakedState, StakeId } from '@alexandria/types/stake'
|
|
import { Stake, StakedState, StakeId } from '@alexandria/types/stake'
|
|
import { RewardRelationship, RewardRelationshipId } from '@alexandria/types/recurring-rewards'
|
|
import { RewardRelationship, RewardRelationshipId } from '@alexandria/types/recurring-rewards'
|
|
|
|
+import { types } from '@alexandria/types'
|
|
import {
|
|
import {
|
|
ActivateOpeningAt,
|
|
ActivateOpeningAt,
|
|
Application as HiringApplication,
|
|
Application as HiringApplication,
|
|
ApplicationId,
|
|
ApplicationId,
|
|
- ApplicationRationingPolicy,
|
|
|
|
Opening as HiringOpening,
|
|
Opening as HiringOpening,
|
|
OpeningId,
|
|
OpeningId,
|
|
- StakingPolicy,
|
|
|
|
} from '@alexandria/types/hiring'
|
|
} from '@alexandria/types/hiring'
|
|
import { FillOpeningParameters, ProposalId } from '@alexandria/types/proposals'
|
|
import { FillOpeningParameters, ProposalId } from '@alexandria/types/proposals'
|
|
-import { WorkingGroup } from '@alexandria/types/common'
|
|
|
|
|
|
|
|
export enum WorkingGroups {
|
|
export enum WorkingGroups {
|
|
StorageWorkingGroup = 'storageWorkingGroup',
|
|
StorageWorkingGroup = 'storageWorkingGroup',
|
|
@@ -43,7 +39,7 @@ export class ApiWrapper {
|
|
private readonly sender: Sender
|
|
private readonly sender: Sender
|
|
|
|
|
|
public static async create(provider: WsProvider): Promise<ApiWrapper> {
|
|
public static async create(provider: WsProvider): Promise<ApiWrapper> {
|
|
- const api = await ApiPromise.create({ provider })
|
|
|
|
|
|
+ const api = await ApiPromise.create({ provider, types })
|
|
return new ApiWrapper(api)
|
|
return new ApiWrapper(api)
|
|
}
|
|
}
|
|
|
|
|
|
@@ -65,6 +61,10 @@ export class ApiWrapper {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ public createPaidTermId(value: BN): PaidTermId {
|
|
|
|
+ return this.api.createType('PaidTermId', value)
|
|
|
|
+ }
|
|
|
|
+
|
|
public async buyMembership(
|
|
public async buyMembership(
|
|
account: KeyringPair,
|
|
account: KeyringPair,
|
|
paidTermsId: PaidTermId,
|
|
paidTermsId: PaidTermId,
|
|
@@ -87,20 +87,22 @@ export class ApiWrapper {
|
|
return this.api.query.members.memberIdsByControllerAccountId<Vec<MemberId>>(address)
|
|
return this.api.query.members.memberIdsByControllerAccountId<Vec<MemberId>>(address)
|
|
}
|
|
}
|
|
|
|
|
|
- public getBalance(address: string): Promise<Balance> {
|
|
|
|
- return this.api.query.balances.freeBalance<Balance>(address)
|
|
|
|
|
|
+ public async getBalance(address: string): Promise<Balance> {
|
|
|
|
+ const accountData: AccountInfo = await this.api.query.system.account<AccountInfo>(address)
|
|
|
|
+ return (await this.api.query.system.account<AccountInfo>(address)).data.free
|
|
}
|
|
}
|
|
|
|
|
|
public async transferBalance(from: KeyringPair, to: string, amount: BN): Promise<void> {
|
|
public async transferBalance(from: KeyringPair, to: string, amount: BN): Promise<void> {
|
|
return this.sender.signAndSend(this.api.tx.balances.transfer(to, amount), from)
|
|
return this.sender.signAndSend(this.api.tx.balances.transfer(to, amount), from)
|
|
}
|
|
}
|
|
|
|
|
|
- public getPaidMembershipTerms(paidTermsId: PaidTermId): Promise<Option<PaidMembershipTerms>> {
|
|
|
|
- return this.api.query.members.paidMembershipTermsById<Option<PaidMembershipTerms>>(paidTermsId)
|
|
|
|
|
|
+ public getPaidMembershipTerms(paidTermsId: PaidTermId): Promise<PaidMembershipTerms> {
|
|
|
|
+ return this.api.query.members.paidMembershipTermsById<PaidMembershipTerms>(paidTermsId)
|
|
}
|
|
}
|
|
|
|
|
|
- public getMembershipFee(paidTermsId: PaidTermId): Promise<BN> {
|
|
|
|
- return this.getPaidMembershipTerms(paidTermsId).then((terms) => terms.unwrap().fee)
|
|
|
|
|
|
+ public async getMembershipFee(paidTermsId: PaidTermId): Promise<BN> {
|
|
|
|
+ const terms: PaidMembershipTerms = await this.getPaidMembershipTerms(paidTermsId)
|
|
|
|
+ return terms.fee
|
|
}
|
|
}
|
|
|
|
|
|
public async transferBalanceToAccounts(from: KeyringPair, to: KeyringPair[], amount: BN): Promise<void[]> {
|
|
public async transferBalanceToAccounts(from: KeyringPair, to: KeyringPair[], amount: BN): Promise<void[]> {
|
|
@@ -264,44 +266,50 @@ export class ApiWrapper {
|
|
public estimateVoteForProposalFee(): BN {
|
|
public estimateVoteForProposalFee(): BN {
|
|
return this.estimateTxFee(
|
|
return this.estimateTxFee(
|
|
(this.api.tx.proposalsEngine.vote(
|
|
(this.api.tx.proposalsEngine.vote(
|
|
- new MemberId(0),
|
|
|
|
- new ProposalId(0),
|
|
|
|
|
|
+ this.api.createType('MemberId', 0),
|
|
|
|
+ this.api.createType('ProposalId', 0),
|
|
'Approve'
|
|
'Approve'
|
|
) as unknown) as SubmittableExtrinsic<'promise'>
|
|
) as unknown) as SubmittableExtrinsic<'promise'>
|
|
)
|
|
)
|
|
}
|
|
}
|
|
|
|
|
|
public estimateAddOpeningFee(module: WorkingGroups): BN {
|
|
public estimateAddOpeningFee(module: WorkingGroups): BN {
|
|
- const commitment: WorkingGroupOpeningPolicyCommitment = new WorkingGroupOpeningPolicyCommitment({
|
|
|
|
- application_rationing_policy: new Option(ApplicationRationingPolicy, {
|
|
|
|
|
|
+ const commitment: WorkingGroupOpeningPolicyCommitment = this.api.createType('WorkingGroupOpeningPolicyCommitment', {
|
|
|
|
+ application_rationing_policy: this.api.createType('Option<ApplicationRationingPolicy>', {
|
|
max_active_applicants: new BN(32) as u32,
|
|
max_active_applicants: new BN(32) as u32,
|
|
}),
|
|
}),
|
|
max_review_period_length: new BN(32) as u32,
|
|
max_review_period_length: new BN(32) as u32,
|
|
- application_staking_policy: new Option(StakingPolicy, {
|
|
|
|
|
|
+ application_staking_policy: this.api.createType('Option<StakingPolicy>', {
|
|
amount: new BN(1),
|
|
amount: new BN(1),
|
|
amount_mode: 'AtLeast',
|
|
amount_mode: 'AtLeast',
|
|
crowded_out_unstaking_period_length: new BN(1),
|
|
crowded_out_unstaking_period_length: new BN(1),
|
|
review_period_expired_unstaking_period_length: new BN(1),
|
|
review_period_expired_unstaking_period_length: new BN(1),
|
|
}),
|
|
}),
|
|
- role_staking_policy: new Option(StakingPolicy, {
|
|
|
|
|
|
+ role_staking_policy: this.api.createType('Option<StakingPolicy>', {
|
|
amount: new BN(1),
|
|
amount: new BN(1),
|
|
amount_mode: 'AtLeast',
|
|
amount_mode: 'AtLeast',
|
|
crowded_out_unstaking_period_length: new BN(1),
|
|
crowded_out_unstaking_period_length: new BN(1),
|
|
review_period_expired_unstaking_period_length: new BN(1),
|
|
review_period_expired_unstaking_period_length: new BN(1),
|
|
}),
|
|
}),
|
|
- role_slashing_terms: new SlashingTerms({
|
|
|
|
|
|
+ role_slashing_terms: this.api.createType('SlashingTerms', {
|
|
Slashable: {
|
|
Slashable: {
|
|
max_count: new BN(0),
|
|
max_count: new BN(0),
|
|
max_percent_pts_per_time: new BN(0),
|
|
max_percent_pts_per_time: new BN(0),
|
|
},
|
|
},
|
|
}),
|
|
}),
|
|
- fill_opening_successful_applicant_application_stake_unstaking_period: new Option(u32, new BN(1) as BlockNumber),
|
|
|
|
- fill_opening_failed_applicant_application_stake_unstaking_period: new Option(u32, new BN(1) as BlockNumber),
|
|
|
|
- fill_opening_failed_applicant_role_stake_unstaking_period: new Option(u32, new BN(1) as BlockNumber),
|
|
|
|
- terminate_application_stake_unstaking_period: new Option(u32, new BN(1) as BlockNumber),
|
|
|
|
- terminate_role_stake_unstaking_period: new Option(u32, new BN(1) as BlockNumber),
|
|
|
|
- exit_role_application_stake_unstaking_period: new Option(u32, new BN(1) as BlockNumber),
|
|
|
|
- exit_role_stake_unstaking_period: new Option(u32, new BN(1) as BlockNumber),
|
|
|
|
|
|
+ fill_opening_successful_applicant_application_stake_unstaking_period: this.api.createType(
|
|
|
|
+ 'Option<BlockNumber>',
|
|
|
|
+ new BN(1)
|
|
|
|
+ ),
|
|
|
|
+ fill_opening_failed_applicant_application_stake_unstaking_period: this.api.createType(
|
|
|
|
+ 'Option<BlockNumber>',
|
|
|
|
+ new BN(1)
|
|
|
|
+ ),
|
|
|
|
+ fill_opening_failed_applicant_role_stake_unstaking_period: this.api.createType('Option<BlockNumber>', new BN(1)),
|
|
|
|
+ terminate_application_stake_unstaking_period: this.api.createType('Option<BlockNumber>', new BN(1)),
|
|
|
|
+ terminate_role_stake_unstaking_period: this.api.createType('Option<BlockNumber>', new BN(1)),
|
|
|
|
+ exit_role_application_stake_unstaking_period: this.api.createType('Option<BlockNumber>', new BN(1)),
|
|
|
|
+ exit_role_stake_unstaking_period: this.api.createType('Option<BlockNumber>', new BN(1)),
|
|
})
|
|
})
|
|
|
|
|
|
return this.estimateTxFee(
|
|
return this.estimateTxFee(
|
|
@@ -316,15 +324,17 @@ export class ApiWrapper {
|
|
|
|
|
|
public estimateAcceptApplicationsFee(module: WorkingGroups): BN {
|
|
public estimateAcceptApplicationsFee(module: WorkingGroups): BN {
|
|
return this.estimateTxFee(
|
|
return this.estimateTxFee(
|
|
- (this.api.tx[module].acceptApplications(new OpeningId(0)) as unknown) as SubmittableExtrinsic<'promise'>
|
|
|
|
|
|
+ (this.api.tx[module].acceptApplications(this.api.createType('OpeningId', 0)) as unknown) as SubmittableExtrinsic<
|
|
|
|
+ 'promise'
|
|
|
|
+ >
|
|
)
|
|
)
|
|
}
|
|
}
|
|
|
|
|
|
public estimateApplyOnOpeningFee(account: KeyringPair, module: WorkingGroups): BN {
|
|
public estimateApplyOnOpeningFee(account: KeyringPair, module: WorkingGroups): BN {
|
|
return this.estimateTxFee(
|
|
return this.estimateTxFee(
|
|
(this.api.tx[module].applyOnOpening(
|
|
(this.api.tx[module].applyOnOpening(
|
|
- new MemberId(0),
|
|
|
|
- new OpeningId(0),
|
|
|
|
|
|
+ this.api.createType('MemberId', 0),
|
|
|
|
+ this.api.createType('OpeningId', 0),
|
|
account.address,
|
|
account.address,
|
|
0,
|
|
0,
|
|
0,
|
|
0,
|
|
@@ -335,13 +345,15 @@ export class ApiWrapper {
|
|
|
|
|
|
public estimateBeginApplicantReviewFee(module: WorkingGroups): BN {
|
|
public estimateBeginApplicantReviewFee(module: WorkingGroups): BN {
|
|
return this.estimateTxFee(
|
|
return this.estimateTxFee(
|
|
- (this.api.tx[module].beginApplicantReview(new OpeningId(0)) as unknown) as SubmittableExtrinsic<'promise'>
|
|
|
|
|
|
+ (this.api.tx[module].beginApplicantReview(
|
|
|
|
+ this.api.createType('OpeningId', 0)
|
|
|
|
+ ) as unknown) as SubmittableExtrinsic<'promise'>
|
|
)
|
|
)
|
|
}
|
|
}
|
|
|
|
|
|
public estimateFillOpeningFee(module: WorkingGroups): BN {
|
|
public estimateFillOpeningFee(module: WorkingGroups): BN {
|
|
return this.estimateTxFee(
|
|
return this.estimateTxFee(
|
|
- (this.api.tx[module].fillOpening(new OpeningId(0), [new ApplicationId(0)], {
|
|
|
|
|
|
+ (this.api.tx[module].fillOpening(this.api.createType('OpeningId', 0), [this.api.createType('ApplicationId', 0)], {
|
|
'amount_per_payout': 0,
|
|
'amount_per_payout': 0,
|
|
'next_payment_at_block': 0,
|
|
'next_payment_at_block': 0,
|
|
'payout_interval': 0,
|
|
'payout_interval': 0,
|
|
@@ -351,58 +363,75 @@ export class ApiWrapper {
|
|
|
|
|
|
public estimateIncreaseStakeFee(module: WorkingGroups): BN {
|
|
public estimateIncreaseStakeFee(module: WorkingGroups): BN {
|
|
return this.estimateTxFee(
|
|
return this.estimateTxFee(
|
|
- (this.api.tx[module].increaseStake(new WorkerId(0), 0) as unknown) as SubmittableExtrinsic<'promise'>
|
|
|
|
|
|
+ (this.api.tx[module].increaseStake(this.api.createType('WorkerId', 0), 0) as unknown) as SubmittableExtrinsic<
|
|
|
|
+ 'promise'
|
|
|
|
+ >
|
|
)
|
|
)
|
|
}
|
|
}
|
|
|
|
|
|
public estimateDecreaseStakeFee(module: WorkingGroups): BN {
|
|
public estimateDecreaseStakeFee(module: WorkingGroups): BN {
|
|
return this.estimateTxFee(
|
|
return this.estimateTxFee(
|
|
- (this.api.tx[module].decreaseStake(new WorkerId(0), 0) as unknown) as SubmittableExtrinsic<'promise'>
|
|
|
|
|
|
+ (this.api.tx[module].decreaseStake(this.api.createType('WorkerId', 0), 0) as unknown) as SubmittableExtrinsic<
|
|
|
|
+ 'promise'
|
|
|
|
+ >
|
|
)
|
|
)
|
|
}
|
|
}
|
|
|
|
|
|
public estimateUpdateRoleAccountFee(address: string, module: WorkingGroups): BN {
|
|
public estimateUpdateRoleAccountFee(address: string, module: WorkingGroups): BN {
|
|
return this.estimateTxFee(
|
|
return this.estimateTxFee(
|
|
- (this.api.tx[module].updateRoleAccount(new WorkerId(0), address) as unknown) as SubmittableExtrinsic<'promise'>
|
|
|
|
|
|
+ (this.api.tx[module].updateRoleAccount(
|
|
|
|
+ this.api.createType('WorkerId', 0),
|
|
|
|
+ address
|
|
|
|
+ ) as unknown) as SubmittableExtrinsic<'promise'>
|
|
)
|
|
)
|
|
}
|
|
}
|
|
|
|
|
|
public estimateUpdateRewardAccountFee(address: string, module: WorkingGroups): BN {
|
|
public estimateUpdateRewardAccountFee(address: string, module: WorkingGroups): BN {
|
|
return this.estimateTxFee(
|
|
return this.estimateTxFee(
|
|
- (this.api.tx[module].updateRewardAccount(new WorkerId(0), address) as unknown) as SubmittableExtrinsic<'promise'>
|
|
|
|
|
|
+ (this.api.tx[module].updateRewardAccount(
|
|
|
|
+ this.api.createType('WorkerId', 0),
|
|
|
|
+ address
|
|
|
|
+ ) as unknown) as SubmittableExtrinsic<'promise'>
|
|
)
|
|
)
|
|
}
|
|
}
|
|
|
|
|
|
public estimateLeaveRoleFee(module: WorkingGroups): BN {
|
|
public estimateLeaveRoleFee(module: WorkingGroups): BN {
|
|
return this.estimateTxFee(
|
|
return this.estimateTxFee(
|
|
- (this.api.tx[module].leaveRole(new WorkerId(0), 'Long justification text') as unknown) as SubmittableExtrinsic<
|
|
|
|
- 'promise'
|
|
|
|
- >
|
|
|
|
|
|
+ (this.api.tx[module].leaveRole(
|
|
|
|
+ this.api.createType('WorkerId', 0),
|
|
|
|
+ 'Long justification text'
|
|
|
|
+ ) as unknown) as SubmittableExtrinsic<'promise'>
|
|
)
|
|
)
|
|
}
|
|
}
|
|
|
|
|
|
public estimateWithdrawApplicationFee(module: WorkingGroups): BN {
|
|
public estimateWithdrawApplicationFee(module: WorkingGroups): BN {
|
|
return this.estimateTxFee(
|
|
return this.estimateTxFee(
|
|
- (this.api.tx[module].withdrawApplication(new ApplicationId(0)) as unknown) as SubmittableExtrinsic<'promise'>
|
|
|
|
|
|
+ (this.api.tx[module].withdrawApplication(
|
|
|
|
+ this.api.createType('ApplicationId', 0)
|
|
|
|
+ ) as unknown) as SubmittableExtrinsic<'promise'>
|
|
)
|
|
)
|
|
}
|
|
}
|
|
|
|
|
|
public estimateTerminateApplicationFee(module: WorkingGroups): BN {
|
|
public estimateTerminateApplicationFee(module: WorkingGroups): BN {
|
|
return this.estimateTxFee(
|
|
return this.estimateTxFee(
|
|
- (this.api.tx[module].terminateApplication(new ApplicationId(0)) as unknown) as SubmittableExtrinsic<'promise'>
|
|
|
|
|
|
+ (this.api.tx[module].terminateApplication(
|
|
|
|
+ this.api.createType('ApplicationId', 0)
|
|
|
|
+ ) as unknown) as SubmittableExtrinsic<'promise'>
|
|
)
|
|
)
|
|
}
|
|
}
|
|
|
|
|
|
public estimateSlashStakeFee(module: WorkingGroups): BN {
|
|
public estimateSlashStakeFee(module: WorkingGroups): BN {
|
|
return this.estimateTxFee(
|
|
return this.estimateTxFee(
|
|
- (this.api.tx[module].slashStake(new WorkerId(0), 0) as unknown) as SubmittableExtrinsic<'promise'>
|
|
|
|
|
|
+ (this.api.tx[module].slashStake(this.api.createType('WorkerId', 0), 0) as unknown) as SubmittableExtrinsic<
|
|
|
|
+ 'promise'
|
|
|
|
+ >
|
|
)
|
|
)
|
|
}
|
|
}
|
|
|
|
|
|
public estimateTerminateRoleFee(module: WorkingGroups): BN {
|
|
public estimateTerminateRoleFee(module: WorkingGroups): BN {
|
|
return this.estimateTxFee(
|
|
return this.estimateTxFee(
|
|
(this.api.tx[module].terminateRole(
|
|
(this.api.tx[module].terminateRole(
|
|
- new WorkerId(0),
|
|
|
|
|
|
+ this.api.createType('WorkerId', 0),
|
|
'Long justification text explaining why the worker role will be terminated',
|
|
'Long justification text explaining why the worker role will be terminated',
|
|
false
|
|
false
|
|
) as unknown) as SubmittableExtrinsic<'promise'>
|
|
) as unknown) as SubmittableExtrinsic<'promise'>
|
|
@@ -410,41 +439,47 @@ export class ApiWrapper {
|
|
}
|
|
}
|
|
|
|
|
|
public estimateProposeCreateWorkingGroupLeaderOpeningFee(): BN {
|
|
public estimateProposeCreateWorkingGroupLeaderOpeningFee(): BN {
|
|
- const commitment: WorkingGroupOpeningPolicyCommitment = new WorkingGroupOpeningPolicyCommitment({
|
|
|
|
- application_rationing_policy: new Option(ApplicationRationingPolicy, {
|
|
|
|
|
|
+ const commitment: WorkingGroupOpeningPolicyCommitment = this.api.createType('WorkingGroupOpeningPolicyCommitment', {
|
|
|
|
+ application_rationing_policy: this.api.createType('Option<ApplicationRationingPolicy>', {
|
|
max_active_applicants: new BN(32) as u32,
|
|
max_active_applicants: new BN(32) as u32,
|
|
}),
|
|
}),
|
|
max_review_period_length: new BN(32) as u32,
|
|
max_review_period_length: new BN(32) as u32,
|
|
- application_staking_policy: new Option(StakingPolicy, {
|
|
|
|
|
|
+ application_staking_policy: this.api.createType('Option<StakingPolicy>', {
|
|
amount: new BN(1),
|
|
amount: new BN(1),
|
|
amount_mode: 'AtLeast',
|
|
amount_mode: 'AtLeast',
|
|
crowded_out_unstaking_period_length: new BN(1),
|
|
crowded_out_unstaking_period_length: new BN(1),
|
|
review_period_expired_unstaking_period_length: new BN(1),
|
|
review_period_expired_unstaking_period_length: new BN(1),
|
|
}),
|
|
}),
|
|
- role_staking_policy: new Option(StakingPolicy, {
|
|
|
|
|
|
+ role_staking_policy: this.api.createType('Option<StakingPolicy>', {
|
|
amount: new BN(1),
|
|
amount: new BN(1),
|
|
amount_mode: 'AtLeast',
|
|
amount_mode: 'AtLeast',
|
|
crowded_out_unstaking_period_length: new BN(1),
|
|
crowded_out_unstaking_period_length: new BN(1),
|
|
review_period_expired_unstaking_period_length: new BN(1),
|
|
review_period_expired_unstaking_period_length: new BN(1),
|
|
}),
|
|
}),
|
|
- role_slashing_terms: new SlashingTerms({
|
|
|
|
|
|
+ role_slashing_terms: this.api.createType('SlashingTerms', {
|
|
Slashable: {
|
|
Slashable: {
|
|
max_count: new BN(0),
|
|
max_count: new BN(0),
|
|
max_percent_pts_per_time: new BN(0),
|
|
max_percent_pts_per_time: new BN(0),
|
|
},
|
|
},
|
|
}),
|
|
}),
|
|
- fill_opening_successful_applicant_application_stake_unstaking_period: new Option(u32, new BN(1) as BlockNumber),
|
|
|
|
- fill_opening_failed_applicant_application_stake_unstaking_period: new Option(u32, new BN(1) as BlockNumber),
|
|
|
|
- fill_opening_failed_applicant_role_stake_unstaking_period: new Option(u32, new BN(1) as BlockNumber),
|
|
|
|
- terminate_application_stake_unstaking_period: new Option(u32, new BN(1) as BlockNumber),
|
|
|
|
- terminate_role_stake_unstaking_period: new Option(u32, new BN(1) as BlockNumber),
|
|
|
|
- exit_role_application_stake_unstaking_period: new Option(u32, new BN(1) as BlockNumber),
|
|
|
|
- exit_role_stake_unstaking_period: new Option(u32, new BN(1) as BlockNumber),
|
|
|
|
|
|
+ fill_opening_successful_applicant_application_stake_unstaking_period: this.api.createType(
|
|
|
|
+ 'Option<BlockNumber>',
|
|
|
|
+ new BN(1)
|
|
|
|
+ ),
|
|
|
|
+ fill_opening_failed_applicant_application_stake_unstaking_period: this.api.createType(
|
|
|
|
+ 'Option<BlockNumber>',
|
|
|
|
+ new BN(1)
|
|
|
|
+ ),
|
|
|
|
+ fill_opening_failed_applicant_role_stake_unstaking_period: this.api.createType('Option<BlockNumber>', new BN(1)),
|
|
|
|
+ terminate_application_stake_unstaking_period: this.api.createType('Option<BlockNumber>', new BN(1)),
|
|
|
|
+ terminate_role_stake_unstaking_period: this.api.createType('Option<BlockNumber>', new BN(1)),
|
|
|
|
+ exit_role_application_stake_unstaking_period: this.api.createType('Option<BlockNumber>', new BN(1)),
|
|
|
|
+ exit_role_stake_unstaking_period: this.api.createType('Option<BlockNumber>', new BN(1)),
|
|
})
|
|
})
|
|
|
|
|
|
return this.estimateTxFee(
|
|
return this.estimateTxFee(
|
|
(this.api.tx.proposalsCodex.createAddWorkingGroupLeaderOpeningProposal(
|
|
(this.api.tx.proposalsCodex.createAddWorkingGroupLeaderOpeningProposal(
|
|
- new MemberId(0),
|
|
|
|
|
|
+ this.api.createType('MemberId', 0),
|
|
'some long title for the purpose of testing',
|
|
'some long title for the purpose of testing',
|
|
'some long description for the purpose of testing',
|
|
'some long description for the purpose of testing',
|
|
0,
|
|
0,
|
|
@@ -461,34 +496,31 @@ export class ApiWrapper {
|
|
public estimateProposeBeginWorkingGroupLeaderApplicationReviewFee(): BN {
|
|
public estimateProposeBeginWorkingGroupLeaderApplicationReviewFee(): BN {
|
|
return this.estimateTxFee(
|
|
return this.estimateTxFee(
|
|
(this.api.tx.proposalsCodex.createBeginReviewWorkingGroupLeaderApplicationsProposal(
|
|
(this.api.tx.proposalsCodex.createBeginReviewWorkingGroupLeaderApplicationsProposal(
|
|
- new MemberId(0),
|
|
|
|
|
|
+ this.api.createType('MemberId', 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',
|
|
'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,
|
|
0,
|
|
- new OpeningId(0),
|
|
|
|
|
|
+ this.api.createType('OpeningId', 0),
|
|
'Storage'
|
|
'Storage'
|
|
) as unknown) as SubmittableExtrinsic<'promise'>
|
|
) as unknown) as SubmittableExtrinsic<'promise'>
|
|
)
|
|
)
|
|
}
|
|
}
|
|
|
|
|
|
public estimateProposeFillLeaderOpeningFee(): BN {
|
|
public estimateProposeFillLeaderOpeningFee(): BN {
|
|
- const fillOpeningParameters: FillOpeningParameters = new FillOpeningParameters({
|
|
|
|
- opening_id: new OpeningId(0),
|
|
|
|
- successful_application_id: new ApplicationId(0),
|
|
|
|
- reward_policy: new Option(
|
|
|
|
- RewardPolicy,
|
|
|
|
- new RewardPolicy({
|
|
|
|
- amount_per_payout: new BN(1) as Balance,
|
|
|
|
- next_payment_at_block: new BN(99999) as BlockNumber,
|
|
|
|
- payout_interval: new Option(u32, new u32(99999)),
|
|
|
|
- })
|
|
|
|
- ),
|
|
|
|
- working_group: new WorkingGroup('Storage'),
|
|
|
|
|
|
+ const fillOpeningParameters: FillOpeningParameters = this.api.createType('FillOpeningParameters', {
|
|
|
|
+ opening_id: this.api.createType('OpeningId', 0),
|
|
|
|
+ successful_application_id: this.api.createType('ApplicationId', 0),
|
|
|
|
+ reward_policy: this.api.createType('Option<RewardPolicy>', {
|
|
|
|
+ amount_per_payout: new BN(1) as Balance,
|
|
|
|
+ next_payment_at_block: new BN(99999) as BlockNumber,
|
|
|
|
+ payout_interval: this.api.createType('Option<u32>', new BN(99999)),
|
|
|
|
+ }),
|
|
|
|
+ working_group: this.api.createType('WorkingGroup', 'Storage'),
|
|
})
|
|
})
|
|
|
|
|
|
return this.estimateTxFee(
|
|
return this.estimateTxFee(
|
|
(this.api.tx.proposalsCodex.createFillWorkingGroupLeaderOpeningProposal(
|
|
(this.api.tx.proposalsCodex.createFillWorkingGroupLeaderOpeningProposal(
|
|
- new MemberId(0),
|
|
|
|
|
|
+ this.api.createType('MemberId', 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',
|
|
'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,
|
|
0,
|
|
@@ -500,12 +532,12 @@ export class ApiWrapper {
|
|
public estimateProposeTerminateLeaderRoleFee(): BN {
|
|
public estimateProposeTerminateLeaderRoleFee(): BN {
|
|
return this.estimateTxFee(
|
|
return this.estimateTxFee(
|
|
(this.api.tx.proposalsCodex.createTerminateWorkingGroupLeaderRoleProposal(
|
|
(this.api.tx.proposalsCodex.createTerminateWorkingGroupLeaderRoleProposal(
|
|
- new MemberId(0),
|
|
|
|
|
|
+ this.api.createType('MemberId', 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',
|
|
'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,
|
|
0,
|
|
{
|
|
{
|
|
- 'worker_id': new WorkerId(0),
|
|
|
|
|
|
+ 'worker_id': this.api.createType('WorkerId', 0),
|
|
'rationale': 'Exceptionaly long and extraordinary descriptive rationale',
|
|
'rationale': 'Exceptionaly long and extraordinary descriptive rationale',
|
|
'slash': true,
|
|
'slash': true,
|
|
'working_group': 'Storage',
|
|
'working_group': 'Storage',
|
|
@@ -517,11 +549,11 @@ export class ApiWrapper {
|
|
public estimateProposeLeaderRewardFee(): BN {
|
|
public estimateProposeLeaderRewardFee(): BN {
|
|
return this.estimateTxFee(
|
|
return this.estimateTxFee(
|
|
(this.api.tx.proposalsCodex.createSetWorkingGroupLeaderRewardProposal(
|
|
(this.api.tx.proposalsCodex.createSetWorkingGroupLeaderRewardProposal(
|
|
- new MemberId(0),
|
|
|
|
|
|
+ this.api.createType('MemberId', 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',
|
|
'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,
|
|
0,
|
|
- new WorkerId(0),
|
|
|
|
|
|
+ this.api.createType('WorkerId', 0),
|
|
0,
|
|
0,
|
|
'Storage'
|
|
'Storage'
|
|
) as unknown) as SubmittableExtrinsic<'promise'>
|
|
) as unknown) as SubmittableExtrinsic<'promise'>
|
|
@@ -531,11 +563,11 @@ export class ApiWrapper {
|
|
public estimateProposeDecreaseLeaderStakeFee(): BN {
|
|
public estimateProposeDecreaseLeaderStakeFee(): BN {
|
|
return this.estimateTxFee(
|
|
return this.estimateTxFee(
|
|
(this.api.tx.proposalsCodex.createDecreaseWorkingGroupLeaderStakeProposal(
|
|
(this.api.tx.proposalsCodex.createDecreaseWorkingGroupLeaderStakeProposal(
|
|
- new MemberId(0),
|
|
|
|
|
|
+ this.api.createType('MemberId', 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',
|
|
'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,
|
|
0,
|
|
- new WorkerId(0),
|
|
|
|
|
|
+ this.api.createType('WorkerId', 0),
|
|
0,
|
|
0,
|
|
'Storage'
|
|
'Storage'
|
|
) as unknown) as SubmittableExtrinsic<'promise'>
|
|
) as unknown) as SubmittableExtrinsic<'promise'>
|
|
@@ -545,11 +577,11 @@ export class ApiWrapper {
|
|
public estimateProposeSlashLeaderStakeFee(): BN {
|
|
public estimateProposeSlashLeaderStakeFee(): BN {
|
|
return this.estimateTxFee(
|
|
return this.estimateTxFee(
|
|
(this.api.tx.proposalsCodex.createSlashWorkingGroupLeaderStakeProposal(
|
|
(this.api.tx.proposalsCodex.createSlashWorkingGroupLeaderStakeProposal(
|
|
- new MemberId(0),
|
|
|
|
|
|
+ this.api.createType('MemberId', 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',
|
|
'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,
|
|
0,
|
|
- new WorkerId(0),
|
|
|
|
|
|
+ this.api.createType('WorkerId', 0),
|
|
0,
|
|
0,
|
|
'Storage'
|
|
'Storage'
|
|
) as unknown) as SubmittableExtrinsic<'promise'>
|
|
) as unknown) as SubmittableExtrinsic<'promise'>
|
|
@@ -559,7 +591,7 @@ export class ApiWrapper {
|
|
public estimateProposeWorkingGroupMintCapacityFee(): BN {
|
|
public estimateProposeWorkingGroupMintCapacityFee(): BN {
|
|
return this.estimateTxFee(
|
|
return this.estimateTxFee(
|
|
(this.api.tx.proposalsCodex.createSetWorkingGroupMintCapacityProposal(
|
|
(this.api.tx.proposalsCodex.createSetWorkingGroupMintCapacityProposal(
|
|
- new MemberId(0),
|
|
|
|
|
|
+ this.api.createType('MemberId', 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',
|
|
'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,
|
|
0,
|
|
@@ -949,16 +981,14 @@ export class ApiWrapper {
|
|
|
|
|
|
public async getContentWorkingGroupMintCapacity(): Promise<BN> {
|
|
public async getContentWorkingGroupMintCapacity(): Promise<BN> {
|
|
const mintId: MintId = await this.api.query.contentWorkingGroup.mint<MintId>()
|
|
const mintId: MintId = await this.api.query.contentWorkingGroup.mint<MintId>()
|
|
- const mintCodec = await this.api.query.minting.mints<Codec[]>(mintId)
|
|
|
|
- const mint: Mint = (mintCodec[0] as unknown) as Mint
|
|
|
|
- return mint.getField<Balance>('capacity')
|
|
|
|
|
|
+ const mint: Mint = await this.api.query.minting.mints<Mint>(mintId)
|
|
|
|
+ return mint.capacity
|
|
}
|
|
}
|
|
|
|
|
|
public async getWorkingGroupMintCapacity(module: WorkingGroups): Promise<BN> {
|
|
public async getWorkingGroupMintCapacity(module: WorkingGroups): Promise<BN> {
|
|
const mintId: MintId = await this.api.query[module].mint<MintId>()
|
|
const mintId: MintId = await this.api.query[module].mint<MintId>()
|
|
- const mintCodec = await this.api.query.minting.mints<Codec[]>(mintId)
|
|
|
|
- const mint: Mint = (mintCodec[0] as unknown) as Mint
|
|
|
|
- return mint.getField<Balance>('capacity')
|
|
|
|
|
|
+ const mint: Mint = await this.api.query.minting.mints<Mint>(mintId)
|
|
|
|
+ return mint.capacity
|
|
}
|
|
}
|
|
|
|
|
|
public getValidatorCount(): Promise<BN> {
|
|
public getValidatorCount(): Promise<BN> {
|
|
@@ -967,8 +997,7 @@ export class ApiWrapper {
|
|
|
|
|
|
public async getCurrentLeadAddress(): Promise<string> {
|
|
public async getCurrentLeadAddress(): Promise<string> {
|
|
const leadId: Option<LeadId> = await this.api.query.contentWorkingGroup.currentLeadId<Option<LeadId>>()
|
|
const leadId: Option<LeadId> = await this.api.query.contentWorkingGroup.currentLeadId<Option<LeadId>>()
|
|
- const leadCodec = await this.api.query.contentWorkingGroup.leadById<Codec[]>(leadId.unwrap())
|
|
|
|
- const lead = (leadCodec[0] as unknown) as Lead
|
|
|
|
|
|
+ const lead = await this.api.query.contentWorkingGroup.leadById<Lead>(leadId.unwrap())
|
|
return lead.role_account.toString()
|
|
return lead.role_account.toString()
|
|
}
|
|
}
|
|
|
|
|
|
@@ -980,84 +1009,338 @@ export class ApiWrapper {
|
|
return accountWorkers !== undefined
|
|
return accountWorkers !== undefined
|
|
}
|
|
}
|
|
|
|
|
|
- public async addOpening(
|
|
|
|
- leader: KeyringPair,
|
|
|
|
- actiavteAt: ActivateOpeningAt,
|
|
|
|
- commitment: WorkingGroupOpeningPolicyCommitment,
|
|
|
|
- text: string,
|
|
|
|
- type: string,
|
|
|
|
- module: WorkingGroups,
|
|
|
|
|
|
+ public async addOpening(openingParameters: {
|
|
|
|
+ leader: KeyringPair
|
|
|
|
+ activationDelay: BN
|
|
|
|
+ maxActiveApplicants: BN
|
|
|
|
+ maxReviewPeriodLength: BN
|
|
|
|
+ applicationStakingPolicyAmount: BN
|
|
|
|
+ applicationCrowdedOutUnstakingPeriodLength: BN
|
|
|
|
+ applicationReviewPeriodExpiredUnstakingPeriodLength: BN
|
|
|
|
+ roleStakingPolicyAmount: BN
|
|
|
|
+ roleCrowdedOutUnstakingPeriodLength: BN
|
|
|
|
+ roleReviewPeriodExpiredUnstakingPeriodLength: BN
|
|
|
|
+ slashableMaxCount: BN
|
|
|
|
+ slashableMaxPercentPtsPerTime: BN
|
|
|
|
+ fillOpeningSuccessfulApplicantApplicationStakeUnstakingPeriod: BN
|
|
|
|
+ fillOpeningFailedApplicantApplicationStakeUnstakingPeriod: BN
|
|
|
|
+ fillOpeningFailedApplicantRoleStakeUnstakingPeriod: BN
|
|
|
|
+ terminateApplicationStakeUnstakingPeriod: BN
|
|
|
|
+ terminateRoleStakeUnstakingPeriod: BN
|
|
|
|
+ exitRoleApplicationStakeUnstakingPeriod: BN
|
|
|
|
+ exitRoleStakeUnstakingPeriod: BN
|
|
|
|
+ text: string
|
|
|
|
+ type: string
|
|
|
|
+ module: WorkingGroups
|
|
expectFailure: boolean
|
|
expectFailure: boolean
|
|
- ): Promise<void> {
|
|
|
|
- return this.sender.signAndSend(
|
|
|
|
- this.createAddOpeningTransaction(actiavteAt, commitment, text, type, module),
|
|
|
|
- leader,
|
|
|
|
- expectFailure
|
|
|
|
|
|
+ }): Promise<void> {
|
|
|
|
+ const activateAt: ActivateOpeningAt = this.api.createType(
|
|
|
|
+ 'ActivateOpeningAt',
|
|
|
|
+ openingParameters.activationDelay.eqn(0)
|
|
|
|
+ ? 'CurrentBlock'
|
|
|
|
+ : { ExactBlock: (await this.getBestBlock()).add(openingParameters.activationDelay) }
|
|
)
|
|
)
|
|
- }
|
|
|
|
|
|
|
|
- public async sudoAddOpening(
|
|
|
|
- sudo: KeyringPair,
|
|
|
|
- actiavteAt: ActivateOpeningAt,
|
|
|
|
- commitment: WorkingGroupOpeningPolicyCommitment,
|
|
|
|
- text: string,
|
|
|
|
- type: string,
|
|
|
|
|
|
+ const commitment: WorkingGroupOpeningPolicyCommitment = this.api.createType('WorkingGroupOpeningPolicyCommitment', {
|
|
|
|
+ application_rationing_policy: this.api.createType('Option<ApplicationRationingPolicy>', {
|
|
|
|
+ max_active_applicants: openingParameters.maxActiveApplicants as u32,
|
|
|
|
+ }),
|
|
|
|
+ max_review_period_length: openingParameters.maxReviewPeriodLength as u32,
|
|
|
|
+ application_staking_policy: this.api.createType('Option<StakingPolicy>', {
|
|
|
|
+ amount: openingParameters.applicationStakingPolicyAmount,
|
|
|
|
+ amount_mode: 'AtLeast',
|
|
|
|
+ crowded_out_unstaking_period_length: openingParameters.applicationCrowdedOutUnstakingPeriodLength,
|
|
|
|
+ review_period_expired_unstaking_period_length:
|
|
|
|
+ openingParameters.applicationReviewPeriodExpiredUnstakingPeriodLength,
|
|
|
|
+ }),
|
|
|
|
+ role_staking_policy: this.api.createType('Option<StakingPolicy>', {
|
|
|
|
+ amount: openingParameters.roleStakingPolicyAmount,
|
|
|
|
+ amount_mode: 'AtLeast',
|
|
|
|
+ crowded_out_unstaking_period_length: openingParameters.roleCrowdedOutUnstakingPeriodLength,
|
|
|
|
+ review_period_expired_unstaking_period_length: openingParameters.roleReviewPeriodExpiredUnstakingPeriodLength,
|
|
|
|
+ }),
|
|
|
|
+ role_slashing_terms: this.api.createType('SlashingTerms', {
|
|
|
|
+ Slashable: {
|
|
|
|
+ max_count: openingParameters.slashableMaxCount,
|
|
|
|
+ max_percent_pts_per_time: openingParameters.slashableMaxPercentPtsPerTime,
|
|
|
|
+ },
|
|
|
|
+ }),
|
|
|
|
+ fill_opening_successful_applicant_application_stake_unstaking_period: this.api.createType(
|
|
|
|
+ 'Option<BlockNumber>',
|
|
|
|
+ openingParameters.fillOpeningSuccessfulApplicantApplicationStakeUnstakingPeriod
|
|
|
|
+ ),
|
|
|
|
+ fill_opening_failed_applicant_application_stake_unstaking_period: this.api.createType(
|
|
|
|
+ 'Option<BlockNumber>',
|
|
|
|
+ openingParameters.fillOpeningFailedApplicantApplicationStakeUnstakingPeriod
|
|
|
|
+ ),
|
|
|
|
+ fill_opening_failed_applicant_role_stake_unstaking_period: this.api.createType(
|
|
|
|
+ 'Option<BlockNumber>',
|
|
|
|
+ openingParameters.fillOpeningFailedApplicantRoleStakeUnstakingPeriod
|
|
|
|
+ ),
|
|
|
|
+ terminate_application_stake_unstaking_period: this.api.createType(
|
|
|
|
+ 'Option<BlockNumber>',
|
|
|
|
+ openingParameters.terminateApplicationStakeUnstakingPeriod
|
|
|
|
+ ),
|
|
|
|
+ terminate_role_stake_unstaking_period: this.api.createType(
|
|
|
|
+ 'Option<BlockNumber>',
|
|
|
|
+ openingParameters.terminateRoleStakeUnstakingPeriod
|
|
|
|
+ ),
|
|
|
|
+ exit_role_application_stake_unstaking_period: this.api.createType(
|
|
|
|
+ 'Option<BlockNumber>',
|
|
|
|
+ openingParameters.exitRoleApplicationStakeUnstakingPeriod
|
|
|
|
+ ),
|
|
|
|
+ exit_role_stake_unstaking_period: this.api.createType(
|
|
|
|
+ 'Option<BlockNumber>',
|
|
|
|
+ openingParameters.exitRoleStakeUnstakingPeriod
|
|
|
|
+ ),
|
|
|
|
+ })
|
|
|
|
+
|
|
|
|
+ return this.sender.signAndSend(
|
|
|
|
+ this.createAddOpeningTransaction(
|
|
|
|
+ activateAt,
|
|
|
|
+ commitment,
|
|
|
|
+ openingParameters.text,
|
|
|
|
+ openingParameters.type,
|
|
|
|
+ openingParameters.module
|
|
|
|
+ ),
|
|
|
|
+ openingParameters.leader,
|
|
|
|
+ openingParameters.expectFailure
|
|
|
|
+ )
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public async sudoAddOpening(openingParameters: {
|
|
|
|
+ sudo: KeyringPair
|
|
|
|
+ activationDelay: BN
|
|
|
|
+ maxActiveApplicants: BN
|
|
|
|
+ maxReviewPeriodLength: BN
|
|
|
|
+ applicationStakingPolicyAmount: BN
|
|
|
|
+ applicationCrowdedOutUnstakingPeriodLength: BN
|
|
|
|
+ applicationReviewPeriodExpiredUnstakingPeriodLength: BN
|
|
|
|
+ roleStakingPolicyAmount: BN
|
|
|
|
+ roleCrowdedOutUnstakingPeriodLength: BN
|
|
|
|
+ roleReviewPeriodExpiredUnstakingPeriodLength: BN
|
|
|
|
+ slashableMaxCount: BN
|
|
|
|
+ slashableMaxPercentPtsPerTime: BN
|
|
|
|
+ fillOpeningSuccessfulApplicantApplicationStakeUnstakingPeriod: BN
|
|
|
|
+ fillOpeningFailedApplicantApplicationStakeUnstakingPeriod: BN
|
|
|
|
+ fillOpeningFailedApplicantRoleStakeUnstakingPeriod: BN
|
|
|
|
+ terminateApplicationStakeUnstakingPeriod: BN
|
|
|
|
+ terminateRoleStakeUnstakingPeriod: BN
|
|
|
|
+ exitRoleApplicationStakeUnstakingPeriod: BN
|
|
|
|
+ exitRoleStakeUnstakingPeriod: BN
|
|
|
|
+ text: string
|
|
|
|
+ type: string
|
|
module: WorkingGroups
|
|
module: WorkingGroups
|
|
- ): Promise<void> {
|
|
|
|
|
|
+ }): Promise<void> {
|
|
|
|
+ const activateAt: ActivateOpeningAt = this.api.createType(
|
|
|
|
+ 'ActivateOpeningAt',
|
|
|
|
+ openingParameters.activationDelay.eqn(0)
|
|
|
|
+ ? 'CurrentBlock'
|
|
|
|
+ : { ExactBlock: (await this.getBestBlock()).add(openingParameters.activationDelay) }
|
|
|
|
+ )
|
|
|
|
+
|
|
|
|
+ const commitment: WorkingGroupOpeningPolicyCommitment = this.api.createType('WorkingGroupOpeningPolicyCommitment', {
|
|
|
|
+ application_rationing_policy: this.api.createType('Option<ApplicationRationingPolicy>', {
|
|
|
|
+ max_active_applicants: openingParameters.maxActiveApplicants as u32,
|
|
|
|
+ }),
|
|
|
|
+ max_review_period_length: openingParameters.maxReviewPeriodLength as u32,
|
|
|
|
+ application_staking_policy: this.api.createType('Option<StakingPolicy>', {
|
|
|
|
+ amount: openingParameters.applicationStakingPolicyAmount,
|
|
|
|
+ amount_mode: 'AtLeast',
|
|
|
|
+ crowded_out_unstaking_period_length: openingParameters.applicationCrowdedOutUnstakingPeriodLength,
|
|
|
|
+ review_period_expired_unstaking_period_length:
|
|
|
|
+ openingParameters.applicationReviewPeriodExpiredUnstakingPeriodLength,
|
|
|
|
+ }),
|
|
|
|
+ role_staking_policy: this.api.createType('Option<StakingPolicy>', {
|
|
|
|
+ amount: openingParameters.roleStakingPolicyAmount,
|
|
|
|
+ amount_mode: 'AtLeast',
|
|
|
|
+ crowded_out_unstaking_period_length: openingParameters.roleCrowdedOutUnstakingPeriodLength,
|
|
|
|
+ review_period_expired_unstaking_period_length: openingParameters.roleReviewPeriodExpiredUnstakingPeriodLength,
|
|
|
|
+ }),
|
|
|
|
+ role_slashing_terms: this.api.createType('SlashingTerms', {
|
|
|
|
+ Slashable: {
|
|
|
|
+ max_count: openingParameters.slashableMaxCount,
|
|
|
|
+ max_percent_pts_per_time: openingParameters.slashableMaxPercentPtsPerTime,
|
|
|
|
+ },
|
|
|
|
+ }),
|
|
|
|
+ fill_opening_successful_applicant_application_stake_unstaking_period: this.api.createType(
|
|
|
|
+ 'Option<BlockNumber>',
|
|
|
|
+ openingParameters.fillOpeningSuccessfulApplicantApplicationStakeUnstakingPeriod
|
|
|
|
+ ),
|
|
|
|
+ fill_opening_failed_applicant_application_stake_unstaking_period: this.api.createType(
|
|
|
|
+ 'Option<BlockNumber>',
|
|
|
|
+ openingParameters.fillOpeningFailedApplicantApplicationStakeUnstakingPeriod
|
|
|
|
+ ),
|
|
|
|
+ fill_opening_failed_applicant_role_stake_unstaking_period: this.api.createType(
|
|
|
|
+ 'Option<BlockNumber>',
|
|
|
|
+ openingParameters.fillOpeningFailedApplicantRoleStakeUnstakingPeriod
|
|
|
|
+ ),
|
|
|
|
+ terminate_application_stake_unstaking_period: this.api.createType(
|
|
|
|
+ 'Option<BlockNumber>',
|
|
|
|
+ openingParameters.terminateApplicationStakeUnstakingPeriod
|
|
|
|
+ ),
|
|
|
|
+ terminate_role_stake_unstaking_period: this.api.createType(
|
|
|
|
+ 'Option<BlockNumber>',
|
|
|
|
+ openingParameters.terminateRoleStakeUnstakingPeriod
|
|
|
|
+ ),
|
|
|
|
+ exit_role_application_stake_unstaking_period: this.api.createType(
|
|
|
|
+ 'Option<BlockNumber>',
|
|
|
|
+ openingParameters.exitRoleApplicationStakeUnstakingPeriod
|
|
|
|
+ ),
|
|
|
|
+ exit_role_stake_unstaking_period: this.api.createType(
|
|
|
|
+ 'Option<BlockNumber>',
|
|
|
|
+ openingParameters.exitRoleStakeUnstakingPeriod
|
|
|
|
+ ),
|
|
|
|
+ })
|
|
|
|
+
|
|
return this.sender.signAndSend(
|
|
return this.sender.signAndSend(
|
|
- this.api.tx.sudo.sudo(this.createAddOpeningTransaction(actiavteAt, commitment, text, type, module)),
|
|
|
|
- sudo,
|
|
|
|
|
|
+ this.api.tx.sudo.sudo(
|
|
|
|
+ this.createAddOpeningTransaction(
|
|
|
|
+ activateAt,
|
|
|
|
+ commitment,
|
|
|
|
+ openingParameters.text,
|
|
|
|
+ openingParameters.type,
|
|
|
|
+ openingParameters.module
|
|
|
|
+ )
|
|
|
|
+ ),
|
|
|
|
+ openingParameters.sudo,
|
|
false
|
|
false
|
|
)
|
|
)
|
|
}
|
|
}
|
|
|
|
|
|
- public async proposeCreateWorkingGroupLeaderOpening(
|
|
|
|
- account: KeyringPair,
|
|
|
|
- title: string,
|
|
|
|
- description: string,
|
|
|
|
- proposalStake: BN,
|
|
|
|
- actiavteAt: ActivateOpeningAt,
|
|
|
|
- commitment: WorkingGroupOpeningPolicyCommitment,
|
|
|
|
- text: string,
|
|
|
|
|
|
+ public async proposeCreateWorkingGroupLeaderOpening(leaderOpening: {
|
|
|
|
+ account: KeyringPair
|
|
|
|
+ title: string
|
|
|
|
+ description: string
|
|
|
|
+ proposalStake: BN
|
|
|
|
+ actiavteAt: string
|
|
|
|
+ maxActiveApplicants: BN
|
|
|
|
+ maxReviewPeriodLength: BN
|
|
|
|
+ applicationStakingPolicyAmount: BN
|
|
|
|
+ applicationCrowdedOutUnstakingPeriodLength: BN
|
|
|
|
+ applicationReviewPeriodExpiredUnstakingPeriodLength: BN
|
|
|
|
+ roleStakingPolicyAmount: BN
|
|
|
|
+ roleCrowdedOutUnstakingPeriodLength: BN
|
|
|
|
+ roleReviewPeriodExpiredUnstakingPeriodLength: BN
|
|
|
|
+ slashableMaxCount: BN
|
|
|
|
+ slashableMaxPercentPtsPerTime: BN
|
|
|
|
+ fillOpeningSuccessfulApplicantApplicationStakeUnstakingPeriod: BN
|
|
|
|
+ fillOpeningFailedApplicantApplicationStakeUnstakingPeriod: BN
|
|
|
|
+ fillOpeningFailedApplicantRoleStakeUnstakingPeriod: BN
|
|
|
|
+ terminateApplicationStakeUnstakingPeriod: BN
|
|
|
|
+ terminateRoleStakeUnstakingPeriod: BN
|
|
|
|
+ exitRoleApplicationStakeUnstakingPeriod: BN
|
|
|
|
+ exitRoleStakeUnstakingPeriod: BN
|
|
|
|
+ text: string
|
|
workingGroup: string
|
|
workingGroup: string
|
|
- ): Promise<void> {
|
|
|
|
- const memberId: MemberId = (await this.getMemberIds(account.address))[0]
|
|
|
|
|
|
+ }): Promise<void> {
|
|
|
|
+ const commitment: WorkingGroupOpeningPolicyCommitment = this.api.createType('WorkingGroupOpeningPolicyCommitment', {
|
|
|
|
+ application_rationing_policy: this.api.createType('Option<ApplicationRationingPolicy>', {
|
|
|
|
+ max_active_applicants: leaderOpening.maxActiveApplicants as u32,
|
|
|
|
+ }),
|
|
|
|
+ max_review_period_length: leaderOpening.maxReviewPeriodLength as u32,
|
|
|
|
+ application_staking_policy: this.api.createType('Option<StakingPolicy>', {
|
|
|
|
+ amount: leaderOpening.applicationStakingPolicyAmount,
|
|
|
|
+ amount_mode: 'AtLeast',
|
|
|
|
+ crowded_out_unstaking_period_length: leaderOpening.applicationCrowdedOutUnstakingPeriodLength,
|
|
|
|
+ review_period_expired_unstaking_period_length:
|
|
|
|
+ leaderOpening.applicationReviewPeriodExpiredUnstakingPeriodLength,
|
|
|
|
+ }),
|
|
|
|
+ role_staking_policy: this.api.createType('Option<StakingPolicy>', {
|
|
|
|
+ amount: leaderOpening.roleStakingPolicyAmount,
|
|
|
|
+ amount_mode: 'AtLeast',
|
|
|
|
+ crowded_out_unstaking_period_length: leaderOpening.roleCrowdedOutUnstakingPeriodLength,
|
|
|
|
+ review_period_expired_unstaking_period_length: leaderOpening.roleReviewPeriodExpiredUnstakingPeriodLength,
|
|
|
|
+ }),
|
|
|
|
+ role_slashing_terms: this.api.createType('SlashingTerms', {
|
|
|
|
+ Slashable: {
|
|
|
|
+ max_count: leaderOpening.slashableMaxCount,
|
|
|
|
+ max_percent_pts_per_time: leaderOpening.slashableMaxPercentPtsPerTime,
|
|
|
|
+ },
|
|
|
|
+ }),
|
|
|
|
+ fill_opening_successful_applicant_application_stake_unstaking_period: this.api.createType(
|
|
|
|
+ 'Option<BlockNumber>',
|
|
|
|
+ leaderOpening.fillOpeningSuccessfulApplicantApplicationStakeUnstakingPeriod
|
|
|
|
+ ),
|
|
|
|
+ fill_opening_failed_applicant_application_stake_unstaking_period: this.api.createType(
|
|
|
|
+ 'Option<BlockNumber>',
|
|
|
|
+ leaderOpening.fillOpeningFailedApplicantApplicationStakeUnstakingPeriod
|
|
|
|
+ ),
|
|
|
|
+ fill_opening_failed_applicant_role_stake_unstaking_period: this.api.createType(
|
|
|
|
+ 'Option<BlockNumber>',
|
|
|
|
+ leaderOpening.fillOpeningFailedApplicantRoleStakeUnstakingPeriod
|
|
|
|
+ ),
|
|
|
|
+ terminate_application_stake_unstaking_period: this.api.createType(
|
|
|
|
+ 'Option<BlockNumber>',
|
|
|
|
+ leaderOpening.terminateApplicationStakeUnstakingPeriod
|
|
|
|
+ ),
|
|
|
|
+ terminate_role_stake_unstaking_period: this.api.createType(
|
|
|
|
+ 'Option<BlockNumber>',
|
|
|
|
+ leaderOpening.terminateRoleStakeUnstakingPeriod
|
|
|
|
+ ),
|
|
|
|
+ exit_role_application_stake_unstaking_period: this.api.createType(
|
|
|
|
+ 'Option<BlockNumber>',
|
|
|
|
+ leaderOpening.exitRoleApplicationStakeUnstakingPeriod
|
|
|
|
+ ),
|
|
|
|
+ exit_role_stake_unstaking_period: this.api.createType(
|
|
|
|
+ 'Option<BlockNumber>',
|
|
|
|
+ leaderOpening.exitRoleStakeUnstakingPeriod
|
|
|
|
+ ),
|
|
|
|
+ })
|
|
|
|
+
|
|
|
|
+ const memberId: MemberId = (await this.getMemberIds(leaderOpening.account.address))[0]
|
|
return this.sender.signAndSend(
|
|
return this.sender.signAndSend(
|
|
(this.api.tx.proposalsCodex.createAddWorkingGroupLeaderOpeningProposal(
|
|
(this.api.tx.proposalsCodex.createAddWorkingGroupLeaderOpeningProposal(
|
|
memberId,
|
|
memberId,
|
|
- title,
|
|
|
|
- description,
|
|
|
|
- proposalStake,
|
|
|
|
|
|
+ leaderOpening.title,
|
|
|
|
+ leaderOpening.description,
|
|
|
|
+ leaderOpening.proposalStake,
|
|
{
|
|
{
|
|
- activate_at: actiavteAt,
|
|
|
|
|
|
+ activate_at: leaderOpening.actiavteAt,
|
|
commitment: commitment,
|
|
commitment: commitment,
|
|
- human_readable_text: text,
|
|
|
|
- working_group: workingGroup,
|
|
|
|
|
|
+ human_readable_text: leaderOpening.text,
|
|
|
|
+ working_group: leaderOpening.workingGroup,
|
|
}
|
|
}
|
|
) as unknown) as SubmittableExtrinsic<'promise'>,
|
|
) as unknown) as SubmittableExtrinsic<'promise'>,
|
|
- account,
|
|
|
|
|
|
+ leaderOpening.account,
|
|
false
|
|
false
|
|
)
|
|
)
|
|
}
|
|
}
|
|
|
|
|
|
- public async proposeFillLeaderOpening(
|
|
|
|
- account: KeyringPair,
|
|
|
|
- title: string,
|
|
|
|
- description: string,
|
|
|
|
- proposalStake: BN,
|
|
|
|
- fillOpeningParameters: FillOpeningParameters
|
|
|
|
- ): Promise<void> {
|
|
|
|
- const memberId: MemberId = (await this.getMemberIds(account.address))[0]
|
|
|
|
|
|
+ public async proposeFillLeaderOpening(fillOpening: {
|
|
|
|
+ account: KeyringPair
|
|
|
|
+ title: string
|
|
|
|
+ description: string
|
|
|
|
+ proposalStake: BN
|
|
|
|
+ openingId: OpeningId
|
|
|
|
+ successfulApplicationId: ApplicationId
|
|
|
|
+ amountPerPayout: BN
|
|
|
|
+ nextPaymentAtBlock: BN
|
|
|
|
+ payoutInterval: BN
|
|
|
|
+ workingGroup: string
|
|
|
|
+ }): Promise<void> {
|
|
|
|
+ const memberId: MemberId = (await this.getMemberIds(fillOpening.account.address))[0]
|
|
|
|
+
|
|
|
|
+ const fillOpeningParameters: FillOpeningParameters = this.api.createType('FillOpeningParameters', {
|
|
|
|
+ opening_id: fillOpening.openingId,
|
|
|
|
+ successful_application_id: fillOpening.successfulApplicationId,
|
|
|
|
+ reward_policy: this.api.createType('Option<RewardPolicy>', {
|
|
|
|
+ amount_per_payout: fillOpening.amountPerPayout as Balance,
|
|
|
|
+ next_payment_at_block: fillOpening.nextPaymentAtBlock as BlockNumber,
|
|
|
|
+ payout_interval: this.api.createType('Option<u32>', fillOpening.payoutInterval),
|
|
|
|
+ }),
|
|
|
|
+ working_group: this.api.createType('WorkingGroup', fillOpening.workingGroup),
|
|
|
|
+ })
|
|
|
|
|
|
return this.sender.signAndSend(
|
|
return this.sender.signAndSend(
|
|
(this.api.tx.proposalsCodex.createFillWorkingGroupLeaderOpeningProposal(
|
|
(this.api.tx.proposalsCodex.createFillWorkingGroupLeaderOpeningProposal(
|
|
memberId,
|
|
memberId,
|
|
- title,
|
|
|
|
- description,
|
|
|
|
- proposalStake,
|
|
|
|
|
|
+ fillOpening.title,
|
|
|
|
+ fillOpening.description,
|
|
|
|
+ fillOpening.proposalStake,
|
|
fillOpeningParameters
|
|
fillOpeningParameters
|
|
) as unknown) as SubmittableExtrinsic<'promise'>,
|
|
) as unknown) as SubmittableExtrinsic<'promise'>,
|
|
- account,
|
|
|
|
|
|
+ fillOpening.account,
|
|
false
|
|
false
|
|
)
|
|
)
|
|
}
|
|
}
|
|
@@ -1398,7 +1681,10 @@ export class ApiWrapper {
|
|
public async batchWithdrawApplication(accounts: KeyringPair[], module: WorkingGroups): Promise<void[]> {
|
|
public async batchWithdrawApplication(accounts: KeyringPair[], module: WorkingGroups): Promise<void[]> {
|
|
return Promise.all(
|
|
return Promise.all(
|
|
accounts.map(async (keyPair) => {
|
|
accounts.map(async (keyPair) => {
|
|
- const applicationIds: ApplicationId[] = await this.getApplicationsIdsByRoleAccount(keyPair.address, module)
|
|
|
|
|
|
+ const applicationIds: ApplicationId[] = await this.getActiveApplicationsIdsByRoleAccount(
|
|
|
|
+ keyPair.address,
|
|
|
|
+ module
|
|
|
|
+ )
|
|
await this.withdrawApplication(keyPair, applicationIds[0], module)
|
|
await this.withdrawApplication(keyPair, applicationIds[0], module)
|
|
})
|
|
})
|
|
)
|
|
)
|
|
@@ -1506,54 +1792,68 @@ export class ApiWrapper {
|
|
}
|
|
}
|
|
|
|
|
|
public async getHiringOpening(id: OpeningId): Promise<HiringOpening> {
|
|
public async getHiringOpening(id: OpeningId): Promise<HiringOpening> {
|
|
- return ((await this.api.query.hiring.openingById<Codec[]>(id))[0] as unknown) as HiringOpening
|
|
|
|
|
|
+ return await this.api.query.hiring.openingById<HiringOpening>(id)
|
|
}
|
|
}
|
|
|
|
|
|
public async getWorkers(module: WorkingGroups): Promise<Worker[]> {
|
|
public async getWorkers(module: WorkingGroups): Promise<Worker[]> {
|
|
- return ((await this.api.query[module].workerById<Codec[]>())[1] as unknown) as Worker[]
|
|
|
|
|
|
+ return (await this.api.query[module].workerById.entries<Worker>()).map((workerWithId) => workerWithId[1])
|
|
}
|
|
}
|
|
|
|
|
|
public async getWorkerById(id: WorkerId, module: WorkingGroups): Promise<Worker> {
|
|
public async getWorkerById(id: WorkerId, module: WorkingGroups): Promise<Worker> {
|
|
- return ((await this.api.query[module].workerById<Codec[]>(id))[0] as unknown) as Worker
|
|
|
|
|
|
+ return await this.api.query[module].workerById<Worker>(id)
|
|
}
|
|
}
|
|
|
|
|
|
public async getWorkerIdByRoleAccount(address: string, module: WorkingGroups): Promise<WorkerId> {
|
|
public async getWorkerIdByRoleAccount(address: string, module: WorkingGroups): Promise<WorkerId> {
|
|
- const workersAndIds = await this.api.query[module].workerById<Codec[]>()
|
|
|
|
- const workers: Worker[] = (workersAndIds[1] as unknown) as Worker[]
|
|
|
|
- const ids: WorkerId[] = (workersAndIds[0] as unknown) as WorkerId[]
|
|
|
|
- const index: number = workers.findIndex((worker) => worker.role_account_id.toString() === address)
|
|
|
|
- return ids[index]
|
|
|
|
|
|
+ const workersAndIds: [StorageKey, Worker][] = await this.api.query[module].workerById.entries<Worker>()
|
|
|
|
+ const index: number = workersAndIds.findIndex(
|
|
|
|
+ (workersAndId) => workersAndId[1].role_account_id.toString() === address
|
|
|
|
+ )
|
|
|
|
+ return workersAndIds[index][0].args[0] as WorkerId
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public async isWorker(address: string, module: WorkingGroups): Promise<boolean> {
|
|
|
|
+ const workersAndIds: [StorageKey, Worker][] = await this.api.query[module].workerById.entries<Worker>()
|
|
|
|
+ const index: number = workersAndIds.findIndex(
|
|
|
|
+ (workersAndId) => workersAndId[1].role_account_id.toString() === address
|
|
|
|
+ )
|
|
|
|
+ return index !== -1
|
|
}
|
|
}
|
|
|
|
|
|
public async getApplicationsIdsByRoleAccount(address: string, module: WorkingGroups): Promise<ApplicationId[]> {
|
|
public async getApplicationsIdsByRoleAccount(address: string, module: WorkingGroups): Promise<ApplicationId[]> {
|
|
- const applicationsAndIds = await this.api.query[module].applicationById<Codec[]>()
|
|
|
|
- const applications: Application[] = (applicationsAndIds[1] as unknown) as Application[]
|
|
|
|
- const ids: ApplicationId[] = (applicationsAndIds[0] as unknown) as ApplicationId[]
|
|
|
|
- return applications
|
|
|
|
- .map((application, index) => (application.role_account_id.toString() === address ? ids[index] : undefined))
|
|
|
|
|
|
+ const applicationsAndIds: [StorageKey, Application][] = await this.api.query[module].applicationById.entries<
|
|
|
|
+ Application
|
|
|
|
+ >()
|
|
|
|
+ return applicationsAndIds
|
|
|
|
+ .map((applicationWithId) => {
|
|
|
|
+ const application: Application = applicationWithId[1]
|
|
|
|
+ return application.role_account_id.toString() === address
|
|
|
|
+ ? (applicationWithId[0].args[0] as ApplicationId)
|
|
|
|
+ : undefined
|
|
|
|
+ })
|
|
.filter((id) => id !== undefined) as ApplicationId[]
|
|
.filter((id) => id !== undefined) as ApplicationId[]
|
|
}
|
|
}
|
|
|
|
|
|
public async getHiringApplicationById(id: ApplicationId): Promise<HiringApplication> {
|
|
public async getHiringApplicationById(id: ApplicationId): Promise<HiringApplication> {
|
|
- return ((await this.api.query.hiring.applicationById<Codec[]>(id))[0] as unknown) as HiringApplication
|
|
|
|
|
|
+ return this.api.query.hiring.applicationById<HiringApplication>(id)
|
|
}
|
|
}
|
|
|
|
|
|
public async getApplicationById(id: ApplicationId, module: WorkingGroups): Promise<Application> {
|
|
public async getApplicationById(id: ApplicationId, module: WorkingGroups): Promise<Application> {
|
|
- return ((await this.api.query[module].applicationById<Codec[]>(id))[0] as unknown) as Application
|
|
|
|
|
|
+ return this.api.query[module].applicationById<Application>(id)
|
|
}
|
|
}
|
|
|
|
|
|
public async getActiveApplicationsIdsByRoleAccount(address: string, module: WorkingGroups): Promise<ApplicationId[]> {
|
|
public async getActiveApplicationsIdsByRoleAccount(address: string, module: WorkingGroups): Promise<ApplicationId[]> {
|
|
- const applicationsAndIds = await this.api.query[module].applicationById<Codec[]>()
|
|
|
|
- const applications: Application[] = (applicationsAndIds[1] as unknown) as Application[]
|
|
|
|
- const ids: ApplicationId[] = (applicationsAndIds[0] as unknown) as ApplicationId[]
|
|
|
|
|
|
+ const applicationsAndIds: [StorageKey, Application][] = await this.api.query[module].applicationById.entries<
|
|
|
|
+ Application
|
|
|
|
+ >()
|
|
return (
|
|
return (
|
|
await Promise.all(
|
|
await Promise.all(
|
|
- applications.map(async (application, index) => {
|
|
|
|
|
|
+ applicationsAndIds.map(async (applicationWithId) => {
|
|
|
|
+ const application: Application = applicationWithId[1]
|
|
if (
|
|
if (
|
|
application.role_account_id.toString() === address &&
|
|
application.role_account_id.toString() === address &&
|
|
(await this.getHiringApplicationById(application.application_id)).stage.type === 'Active'
|
|
(await this.getHiringApplicationById(application.application_id)).stage.type === 'Active'
|
|
) {
|
|
) {
|
|
- return ids[index]
|
|
|
|
|
|
+ return applicationWithId[0].args[0] as ApplicationId
|
|
} else {
|
|
} else {
|
|
return undefined
|
|
return undefined
|
|
}
|
|
}
|
|
@@ -1563,7 +1863,7 @@ export class ApiWrapper {
|
|
}
|
|
}
|
|
|
|
|
|
public async getStake(id: StakeId): Promise<Stake> {
|
|
public async getStake(id: StakeId): Promise<Stake> {
|
|
- return ((await this.api.query.stake.stakes<Codec[]>(id))[0] as unknown) as Stake
|
|
|
|
|
|
+ return this.api.query.stake.stakes<Stake>(id)
|
|
}
|
|
}
|
|
|
|
|
|
public async getWorkerStakeAmount(workerId: WorkerId, module: WorkingGroups): Promise<BN> {
|
|
public async getWorkerStakeAmount(workerId: WorkerId, module: WorkingGroups): Promise<BN> {
|
|
@@ -1572,9 +1872,7 @@ export class ApiWrapper {
|
|
}
|
|
}
|
|
|
|
|
|
public async getRewardRelationship(id: RewardRelationshipId): Promise<RewardRelationship> {
|
|
public async getRewardRelationship(id: RewardRelationshipId): Promise<RewardRelationship> {
|
|
- return ((
|
|
|
|
- await this.api.query.recurringRewards.rewardRelationships<Codec[]>(id)
|
|
|
|
- )[0] as unknown) as RewardRelationship
|
|
|
|
|
|
+ return this.api.query.recurringRewards.rewardRelationships<RewardRelationship>(id)
|
|
}
|
|
}
|
|
|
|
|
|
public async getWorkerRewardAccount(workerId: WorkerId, module: WorkingGroups): Promise<string> {
|
|
public async getWorkerRewardAccount(workerId: WorkerId, module: WorkingGroups): Promise<string> {
|
|
@@ -1587,4 +1885,12 @@ export class ApiWrapper {
|
|
public async getLeadWorkerId(module: WorkingGroups): Promise<WorkerId | undefined> {
|
|
public async getLeadWorkerId(module: WorkingGroups): Promise<WorkerId | undefined> {
|
|
return (await this.api.query[module].currentLead<Option<WorkerId>>()).unwrapOr(undefined)
|
|
return (await this.api.query[module].currentLead<Option<WorkerId>>()).unwrapOr(undefined)
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ public async getActiveWorkersCount(module: WorkingGroups): Promise<BN> {
|
|
|
|
+ return this.api.query[module].activeWorkerCount<u32>()
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public getMaxWorkersCount(module: WorkingGroups): BN {
|
|
|
|
+ return this.api.createType('u32', this.api.consts[module].maxWorkerNumberLimit)
|
|
|
|
+ }
|
|
}
|
|
}
|