AppWorkingGroup¶
Calls¶
add_opening¶
Add a job opening for a regular worker/lead role. Require signed leader origin or the root (to add opening for the leader position).
# <weight>
## Weight
O (D)
where:
- D
is the size of description
in kilobytes
- DB:
- O(1) doesn't depend on the state or parameters
# </weight>
Attributes¶
Name | Type |
---|---|
description | Vec<u8> |
opening_type | OpeningType |
stake_policy | StakePolicy<T::BlockNumber, BalanceOf<T>> |
reward_per_block | Option<BalanceOf<T>> |
Python¶
call = substrate.compose_call(
'AppWorkingGroup', 'add_opening', {
'description': 'Bytes',
'opening_type': (
'Leader',
'Regular',
),
'reward_per_block': (None, 'u128'),
'stake_policy': {
'leaving_unstaking_period': 'u32',
'stake_amount': 'u128',
},
}
)
apply_on_opening¶
Apply on a worker opening.
# <weight>
## Weight
O (D)
where:
- D
is the size of p.description
in kilobytes
- DB:
- O(1) doesn't depend on the state or parameters
# </weight>
Attributes¶
Name | Type |
---|---|
p | ApplyOnOpeningParameters<T> |
Python¶
call = substrate.compose_call(
'AppWorkingGroup', 'apply_on_opening', {
'p': {
'description': 'Bytes',
'member_id': 'u64',
'opening_id': 'u64',
'reward_account_id': 'AccountId',
'role_account_id': 'AccountId',
'stake_parameters': {
'stake': 'u128',
'staking_account_id': 'AccountId',
},
},
}
)
cancel_opening¶
Cancel an opening for the regular worker/lead position. Require signed leader origin or the root (to cancel opening for the leader position).
# <weight>
## Weight
O (1)
- DB:
- O(1) doesn't depend on the state or parameters
# </weight>
Attributes¶
Name | Type |
---|---|
opening_id | OpeningId |
Python¶
call = substrate.compose_call(
'AppWorkingGroup', 'cancel_opening', {'opening_id': 'u64'}
)
decrease_stake¶
Decreases the regular worker/lead stake and returns the remainder to the worker staking_account_id. Can be decreased to zero, no actions on zero stake. Accepts the stake amount to decrease. Requires signed leader origin or the root (to decrease the leader stake).
# <weight>
## Weight
O (1)
- DB:
- O(1) doesn't depend on the state or parameters
# </weight>
Attributes¶
Name | Type |
---|---|
worker_id | WorkerId<T> |
stake_balance_delta | BalanceOf<T> |
Python¶
call = substrate.compose_call(
'AppWorkingGroup', 'decrease_stake', {
'stake_balance_delta': 'u128',
'worker_id': 'u64',
}
)
fill_opening¶
Fill opening for the regular/lead position. Require signed leader origin or the root (to fill opening for the leader position). # <weight>
## Weight
O (A)
where:
- A
is the length of successful_application_ids
- DB:
- O(A)
# </weight>
Attributes¶
Name | Type |
---|---|
opening_id | OpeningId |
successful_application_ids | BTreeSet<ApplicationId> |
Python¶
call = substrate.compose_call(
'AppWorkingGroup', 'fill_opening', {
'opening_id': 'u64',
'successful_application_ids': 'scale_info::91',
}
)
fund_working_group_budget¶
Fund working group budget by a member. <weight>
## Weight
O (1)
Doesn't depend on the state or parameters
- DB:
- O(1) doesn't depend on the state or parameters
# </weight>
Attributes¶
Name | Type |
---|---|
member_id | MemberId<T> |
amount | BalanceOf<T> |
rationale | Vec<u8> |
Python¶
call = substrate.compose_call(
'AppWorkingGroup', 'fund_working_group_budget', {
'amount': 'u128',
'member_id': 'u64',
'rationale': 'Bytes',
}
)
increase_stake¶
Increases the regular worker/lead stake, demands a worker origin. Locks tokens from the worker staking_account_id equal to new stake. No limits on the stake.
# <weight>
## Weight
O (1)
- DB:
- O(1) doesn't depend on the state or parameters
# </weight>
Attributes¶
Name | Type |
---|---|
worker_id | WorkerId<T> |
stake_balance_delta | BalanceOf<T> |
Python¶
call = substrate.compose_call(
'AppWorkingGroup', 'increase_stake', {
'stake_balance_delta': 'u128',
'worker_id': 'u64',
}
)
lead_remark¶
Lead remark message
# <weight>
## Weight
O (M)
where:
- M
is the size of msg
in kilobytes
- DB:
- O(1) doesn't depend on the state or parameters
# </weight>
Attributes¶
Name | Type |
---|---|
msg | Vec<u8> |
Python¶
call = substrate.compose_call(
'AppWorkingGroup', 'lead_remark', {'msg': 'Bytes'}
)
leave_role¶
Leave the role by the active worker. # <weight>
## Weight
O (R)
where:
- R
is the size of rationale
in kilobytes
- DB:
- O(1) doesn't depend on the state or parameters
# </weight>
Attributes¶
Name | Type |
---|---|
worker_id | WorkerId<T> |
rationale | Option<Vec<u8>> |
Python¶
call = substrate.compose_call(
'AppWorkingGroup', 'leave_role', {'rationale': (None, 'Bytes'), 'worker_id': 'u64'}
)
set_budget¶
Sets a new budget for the working group. Requires root origin.
# <weight>
## Weight
O (1)
- DB:
- O(1) doesn't depend on the state or parameters
# </weight>
Attributes¶
Name | Type |
---|---|
new_budget | BalanceOf<T> |
Python¶
call = substrate.compose_call(
'AppWorkingGroup', 'set_budget', {'new_budget': 'u128'}
)
set_status_text¶
Sets a new status text for the working group. Requires root origin.
# <weight>
## Weight
O (S)
where:
- S
is the size of the contents of status_text
in kilobytes when it is not none
- DB:
- O(1) doesn't depend on the state or parameters # </weight>
Attributes¶
Name | Type |
---|---|
status_text | Option<Vec<u8>> |
Python¶
call = substrate.compose_call(
'AppWorkingGroup', 'set_status_text', {'status_text': (None, 'Bytes')}
)
slash_stake¶
Slashes the regular worker stake, demands a leader origin. No limits, no actions on zero stake. If slashing balance greater than the existing stake - stake is slashed to zero. Requires signed leader origin or the root (to slash the leader stake). # <weight>
## Weight
O (P)
where:
- P
is the size of penality.slashing_text
in kilobytes
- DB:
- O(1) doesn't depend on the state or parameters
# </weight>
Attributes¶
Name | Type |
---|---|
worker_id | WorkerId<T> |
penalty | BalanceOf<T> |
rationale | Option<Vec<u8>> |
Python¶
call = substrate.compose_call(
'AppWorkingGroup', 'slash_stake', {
'penalty': 'u128',
'rationale': (None, 'Bytes'),
'worker_id': 'u64',
}
)
spend_from_budget¶
Attributes¶
Name | Type |
---|---|
account_id | T::AccountId |
amount | BalanceOf<T> |
rationale | Option<Vec<u8>> |
Python¶
call = substrate.compose_call(
'AppWorkingGroup', 'spend_from_budget', {
'account_id': 'AccountId',
'amount': 'u128',
'rationale': (None, 'Bytes'),
}
)
terminate_role¶
Terminate the active worker by the lead. Requires signed leader origin or the root (to terminate the leader role). # <weight>
## Weight
O (P)
where:
- P
is the size penalty.slashing_text
in kilobytes
- DB:
- O(1) doesn't depend on the state or parameters
# </weight>
Attributes¶
Name | Type |
---|---|
worker_id | WorkerId<T> |
penalty | Option<BalanceOf<T>> |
rationale | Option<Vec<u8>> |
Python¶
call = substrate.compose_call(
'AppWorkingGroup', 'terminate_role', {
'penalty': (None, 'u128'),
'rationale': (None, 'Bytes'),
'worker_id': 'u64',
}
)
update_reward_account¶
Update the reward account associated with a set reward relationship for the active worker.
# <weight>
## Weight
O (1)
- DB:
- O(1) doesn't depend on the state or parameters
# </weight>
Attributes¶
Name | Type |
---|---|
worker_id | WorkerId<T> |
new_reward_account_id | T::AccountId |
Python¶
call = substrate.compose_call(
'AppWorkingGroup', 'update_reward_account', {
'new_reward_account_id': 'AccountId',
'worker_id': 'u64',
}
)
update_reward_amount¶
Update the reward per block for the active worker. Require signed leader origin or the root (to update leader's reward amount).
# <weight>
## Weight
O (1)
- DB:
- O(1) doesn't depend on the state or parameters
# </weight>
Attributes¶
Name | Type |
---|---|
worker_id | WorkerId<T> |
reward_per_block | Option<BalanceOf<T>> |
Python¶
call = substrate.compose_call(
'AppWorkingGroup', 'update_reward_amount', {
'reward_per_block': (None, 'u128'),
'worker_id': 'u64',
}
)
update_role_account¶
Update the associated role account of the active regular worker/lead.
# <weight>
## Weight
O (1)
- DB:
- O(1) doesn't depend on the state or parameters
# </weight>
Attributes¶
Name | Type |
---|---|
worker_id | WorkerId<T> |
new_role_account_id | T::AccountId |
Python¶
call = substrate.compose_call(
'AppWorkingGroup', 'update_role_account', {
'new_role_account_id': 'AccountId',
'worker_id': 'u64',
}
)
vested_spend_from_budget¶
Transfers specified amount to any account. Requires leader origin.
# <weight>
## Weight
O (1)
- DB:
- O(1) doesn't depend on the state or parameters
# </weight>
Attributes¶
Name | Type |
---|---|
account_id | T::AccountId |
vesting_schedule | VestingInfoOf<T> |
rationale | Option<Vec<u8>> |
Python¶
call = substrate.compose_call(
'AppWorkingGroup', 'vested_spend_from_budget', {
'account_id': 'AccountId',
'rationale': (None, 'Bytes'),
'vesting_schedule': {
'locked': 'u128',
'per_block': 'u128',
'starting_block': 'u32',
},
}
)
withdraw_application¶
Withdraw the worker application. Can be done by the worker only.
# <weight>
## Weight
O (1)
- DB:
- O(1) doesn't depend on the state or parameters
# </weight>
Attributes¶
Name | Type |
---|---|
application_id | ApplicationId |
Python¶
call = substrate.compose_call(
'AppWorkingGroup', 'withdraw_application', {'application_id': 'u64'}
)
worker_remark¶
Worker remark message
# <weight>
## Weight
O (M)
where:
- M
is the size of msg
in kilobytes
- DB:
- O(1) doesn't depend on the state or parameters
# </weight>
Attributes¶
Name | Type |
---|---|
worker_id | WorkerId<T> |
msg | Vec<u8> |
Python¶
call = substrate.compose_call(
'AppWorkingGroup', 'worker_remark', {'msg': 'Bytes', 'worker_id': 'u64'}
)
Events¶
ApplicationWithdrawn¶
Emits on withdrawing the application for the regular worker/lead opening. Params: - Job application id
Attributes¶
Name | Type | Composition |
---|---|---|
None | ApplicationId |
u64 |
AppliedOnOpening¶
Emits on adding the application for the worker opening. Params: - Opening parameteres - Application id
Attributes¶
Name | Type | Composition |
---|---|---|
None | ApplyOnOpeningParameters |
{'member_id': 'u64', 'opening_id': 'u64', 'role_account_id': 'AccountId', 'reward_account_id': 'AccountId', 'description': 'Bytes', 'stake_parameters': {'stake': 'u128', 'staking_account_id': 'AccountId'}} |
None | ApplicationId |
u64 |
BudgetSet¶
Emits on setting the budget for the working group. Params: - new budget
Attributes¶
Name | Type | Composition |
---|---|---|
None | Balance |
u128 |
BudgetSpending¶
Emits on budget from the working group being spent Params: - Receiver Account Id. - Amount to spend - Rationale.
Attributes¶
Name | Type | Composition |
---|---|---|
None | AccountId |
AccountId |
None | Balance |
u128 |
None | Option<Vec<u8>> |
(None, 'Bytes') |
LeadRemarked¶
Emits on Lead making a remark message Params: - message
Attributes¶
Name | Type | Composition |
---|---|---|
None | Vec<u8> |
Bytes |
LeaderSet¶
Emits on setting the group leader. Params: - Group worker id.
Attributes¶
Name | Type | Composition |
---|---|---|
None | WorkerId |
u64 |
LeaderUnset¶
Emits on un-setting the leader.
Attributes¶
No attributes
NewMissedRewardLevelReached¶
Emits on reaching new missed reward. Params: - Worker ID. - Missed reward (optional). None means 'no missed reward'.
Attributes¶
Name | Type | Composition |
---|---|---|
None | WorkerId |
u64 |
None | Option<Balance> |
(None, 'u128') |
OpeningAdded¶
Emits on adding new job opening. Params: - Opening id - Description - Opening Type(Lead or Worker) - Stake Policy for the opening - Reward per block
Attributes¶
Name | Type | Composition |
---|---|---|
None | OpeningId |
u64 |
None | Vec<u8> |
Bytes |
None | OpeningType |
('Leader', 'Regular') |
None | StakePolicy |
{'stake_amount': 'u128', 'leaving_unstaking_period': 'u32'} |
None | Option<Balance> |
(None, 'u128') |
OpeningCanceled¶
Emits on canceling the job opening. Params: - Opening id
Attributes¶
Name | Type | Composition |
---|---|---|
None | OpeningId |
u64 |
OpeningFilled¶
Emits on filling the job opening. Params: - Worker opening id - Worker application id to the worker id dictionary - Applicationd ids used to fill the opening
Attributes¶
Name | Type | Composition |
---|---|---|
None | OpeningId |
u64 |
None | ApplicationIdToWorkerIdMap |
scale_info::231 |
None | BTreeSet<ApplicationId> |
scale_info::91 |
RewardPaid¶
Emits on paying the reward. Params: - Id of the worker. - Receiver Account Id. - Reward - Payment type (missed reward or regular one)
Attributes¶
Name | Type | Composition |
---|---|---|
None | WorkerId |
u64 |
None | AccountId |
AccountId |
None | Balance |
u128 |
None | RewardPaymentType |
('MissedReward', 'RegularReward') |
StakeDecreased¶
Emits on decreasing the regular worker/lead stake. Params: - regular worker/lead id. - stake delta amount
Attributes¶
Name | Type | Composition |
---|---|---|
None | WorkerId |
u64 |
None | Balance |
u128 |
StakeIncreased¶
Emits on increasing the regular worker/lead stake. Params: - regular worker/lead id. - stake delta amount
Attributes¶
Name | Type | Composition |
---|---|---|
None | WorkerId |
u64 |
None | Balance |
u128 |
StakeSlashed¶
Emits on slashing the regular worker/lead stake. Params: - regular worker/lead id. - actual slashed balance. - Requested slashed balance. - Rationale.
Attributes¶
Name | Type | Composition |
---|---|---|
None | WorkerId |
u64 |
None | Balance |
u128 |
None | Balance |
u128 |
None | Option<Vec<u8>> |
(None, 'Bytes') |
StatusTextChanged¶
Emits on updating the status text of the working group. Params: - status text hash - status text
Attributes¶
Name | Type | Composition |
---|---|---|
None | Hash |
scale_info::11 |
None | Option<Vec<u8>> |
(None, 'Bytes') |
TerminatedLeader¶
Emits on terminating the leader. Params: - leader worker id. - Penalty. - Rationale.
Attributes¶
Name | Type | Composition |
---|---|---|
None | WorkerId |
u64 |
None | Option<Balance> |
(None, 'u128') |
None | Option<Vec<u8>> |
(None, 'Bytes') |
TerminatedWorker¶
Emits on terminating the worker. Params: - worker id. - Penalty. - Rationale.
Attributes¶
Name | Type | Composition |
---|---|---|
None | WorkerId |
u64 |
None | Option<Balance> |
(None, 'u128') |
None | Option<Vec<u8>> |
(None, 'Bytes') |
VestedBudgetSpending¶
Emits on budget from the working group being spent Params: - Receiver Account Id. - Vesting scheduled - Rationale.
Attributes¶
Name | Type | Composition |
---|---|---|
None | AccountId |
AccountId |
None | VestingInfo |
{'locked': 'u128', 'per_block': 'u128', 'starting_block': 'u32'} |
None | Option<Vec<u8>> |
(None, 'Bytes') |
WorkerExited¶
Emits on exiting the worker. Params: - worker id. - Rationale.
Attributes¶
Name | Type | Composition |
---|---|---|
None | WorkerId |
u64 |
WorkerRemarked¶
Emits on Lead making a remark message Params: - worker - message
Attributes¶
Name | Type | Composition |
---|---|---|
None | WorkerId |
u64 |
None | Vec<u8> |
Bytes |
WorkerRewardAccountUpdated¶
Emits on updating the reward account of the worker. Params: - Id of the worker. - Reward account id of the worker.
Attributes¶
Name | Type | Composition |
---|---|---|
None | WorkerId |
u64 |
None | AccountId |
AccountId |
WorkerRewardAmountUpdated¶
Emits on updating the reward amount of the worker. Params: - Id of the worker. - Reward per block
Attributes¶
Name | Type | Composition |
---|---|---|
None | WorkerId |
u64 |
None | Option<Balance> |
(None, 'u128') |
WorkerRoleAccountUpdated¶
Emits on updating the role account of the worker. Params: - Id of the worker. - Role account id of the worker.
Attributes¶
Name | Type | Composition |
---|---|---|
None | WorkerId |
u64 |
None | AccountId |
AccountId |
WorkerStartedLeaving¶
Emits when worker started leaving their role. Params: - Worker id. - Rationale.
Attributes¶
Name | Type | Composition |
---|---|---|
None | WorkerId |
u64 |
None | Option<Vec<u8>> |
(None, 'Bytes') |
WorkingGroupBudgetFunded¶
Fund the working group budget. Params: - Member ID - Amount of balance - Rationale
Attributes¶
Name | Type | Composition |
---|---|---|
None | MemberId |
u64 |
None | Balance |
u128 |
None | Vec<u8> |
Bytes |
Storage functions¶
ActiveWorkerCount¶
Count of active workers.
Python¶
result = substrate.query(
'AppWorkingGroup', 'ActiveWorkerCount', []
)
Return value¶
'u32'
ApplicationById¶
Maps identifier to worker application on opening.
Python¶
result = substrate.query(
'AppWorkingGroup', 'ApplicationById', ['u64']
)
Return value¶
{
'description_hash': 'scale_info::11',
'member_id': 'u64',
'opening_id': 'u64',
'reward_account_id': 'AccountId',
'role_account_id': 'AccountId',
'staking_account_id': 'AccountId',
}
Budget¶
Budget for the working group.
Python¶
result = substrate.query(
'AppWorkingGroup', 'Budget', []
)
Return value¶
'u128'
CurrentLead¶
Current group lead.
Python¶
result = substrate.query(
'AppWorkingGroup', 'CurrentLead', []
)
Return value¶
'u64'
NextApplicationId¶
Next identifier value for new worker application.
Python¶
result = substrate.query(
'AppWorkingGroup', 'NextApplicationId', []
)
Return value¶
'u64'
NextOpeningId¶
Next identifier value for new job opening.
Python¶
result = substrate.query(
'AppWorkingGroup', 'NextOpeningId', []
)
Return value¶
'u64'
NextWorkerId¶
Next identifier for a new worker.
Python¶
result = substrate.query(
'AppWorkingGroup', 'NextWorkerId', []
)
Return value¶
'u64'
OpeningById¶
Maps identifier to job opening.
Python¶
result = substrate.query(
'AppWorkingGroup', 'OpeningById', ['u64']
)
Return value¶
{
'created': 'u32',
'creation_stake': 'u128',
'description_hash': 'scale_info::11',
'opening_type': ('Leader', 'Regular'),
'reward_per_block': (None, 'u128'),
'stake_policy': {
'leaving_unstaking_period': 'u32',
'stake_amount': 'u128',
},
}
StatusTextHash¶
Status text hash.
Python¶
result = substrate.query(
'AppWorkingGroup', 'StatusTextHash', []
)
Return value¶
'scale_info::11'
WorkerById¶
Maps identifier to corresponding worker.
Python¶
result = substrate.query(
'AppWorkingGroup', 'WorkerById', ['u64']
)
Return value¶
{
'created_at': 'u32',
'job_unstaking_period': 'u32',
'member_id': 'u64',
'missed_reward': (None, 'u128'),
'reward_account_id': 'AccountId',
'reward_per_block': (None, 'u128'),
'role_account_id': 'AccountId',
'staking_account_id': 'AccountId',
'started_leaving_at': (None, 'u32'),
}
Constants¶
LeaderOpeningStake¶
Stake needed to create an opening.
Value¶
16666666666600
Python¶
constant = substrate.get_constant('AppWorkingGroup', 'LeaderOpeningStake')
MaxWorkerNumberLimit¶
Exports const Max simultaneous active worker number.
Value¶
30
Python¶
constant = substrate.get_constant('AppWorkingGroup', 'MaxWorkerNumberLimit')
MinUnstakingPeriodLimit¶
Defines min unstaking period in the group.
Value¶
288000
Python¶
constant = substrate.get_constant('AppWorkingGroup', 'MinUnstakingPeriodLimit')
MinimumApplicationStake¶
Minimum stake required for applying into an opening.
Value¶
3333333333320
Python¶
constant = substrate.get_constant('AppWorkingGroup', 'MinimumApplicationStake')
RewardPeriod¶
Defines the period every worker gets paid in blocks.
Value¶
14450
Python¶
constant = substrate.get_constant('AppWorkingGroup', 'RewardPeriod')
StakingHandlerLockId¶
Staking handler lock id.
Value¶
'0x77672d6170706c69'
Python¶
constant = substrate.get_constant('AppWorkingGroup', 'StakingHandlerLockId')
Errors¶
ApplicationStakeDoesntMatchOpening¶
Application stake is less than required opening stake.
ApplicationsNotForOpening¶
Trying to fill opening with an application for other opening
ArithmeticError¶
Unexpected arithmetic error (overflow / underflow)
BelowMinimumStakes¶
Staking less than the lower bound.
CannotDecreaseStakeDeltaGreaterThanStake¶
Cannot decrease stake - stake delta greater than initial stake.
CannotHireLeaderWhenLeaderExists¶
There is leader already, cannot hire another one.
CannotHireMultipleLeaders¶
Cannot fill opening with multiple applications.
CannotRewardWithZero¶
Reward could not be zero.
CannotSpendZero¶
Invalid spending amount.
ConflictStakesOnAccount¶
Staking account contains conflicting stakes.
CurrentLeadNotSet¶
Current lead is not set.
InsufficientBalanceForTransfer¶
Cannot withdraw: insufficient budget balance.
InsufficientBalanceToCoverStake¶
Insufficient balance to cover stake.
InsufficientBudgetForSpending¶
It's not enough budget for this spending.
InsufficientTokensForFunding¶
Insufficient tokens for funding (on member controller account)
InvalidMemberOrigin¶
Invalid origin for a member.
InvalidStakingAccountForMember¶
Staking account doesn't belong to a member.
IsNotLeadAccount¶
Not a lead account.
MaxActiveWorkerNumberExceeded¶
Working group size limit exceeded.
NoApplicationsProvided¶
Cannot fill opening - no applications provided.
OpeningDoesNotExist¶
Opening does not exist.
OriginIsNotApplicant¶
Origin is not applicant.
SignerIsNotWorkerRoleAccount¶
Signer is not worker role account.
StakeBalanceCannotBeZero¶
Provided stake balance cannot be zero.
SuccessfulWorkerApplicationDoesNotExist¶
Successful worker application does not exist.
UnstakingPeriodLessThanMinimum¶
Specified unstaking period is less then minimum set for the group.
WorkerApplicationDoesNotExist¶
Worker application does not exist.
WorkerDoesNotExist¶
Worker does not exist.
WorkerHasNoReward¶
Worker has no recurring reward.
WorkerIsLeaving¶
Invalid operation - worker is leaving.
WorkerStorageValueTooLong¶
Worker storage text is too long.
ZeroTokensFunding¶
Trying to fund with zero tokens