Struct dao::bid_escrow::contract::BidEscrowContractRef
source · pub struct BidEscrowContractRef { /* private fields */ }
Expand description
Reference to the BidEscrowContract contract instance.
Implementations§
source§impl BidEscrowContractRef
impl BidEscrowContractRef
sourcepub fn get_cspr_balance(&self) -> Balance
pub fn get_cspr_balance(&self) -> Balance
Returns the CSPR balance of the contract.
sourcepub fn slash_voter(&mut self, voter: Address) -> SlashedVotings
pub fn slash_voter(&mut self, voter: Address) -> SlashedVotings
Erases the VA from the all bids, offers and jobs. Only a whitelisted account is permitted to call this method. Interacts with Reputation Token Contract.
§Errors
- crate::utils::Error::BidNotFound
- crate::utils::Error::JobOfferNotFound
- crate::utils::Error::CannotCancelBidOnCompletedJobOffer
- crate::utils::Error::NotWhitelisted
§Events
sourcepub fn cancel_finished_voting(&mut self, voting_id: VotingId)
pub fn cancel_finished_voting(&mut self, voting_id: VotingId)
Cancels a voting that has not been finished in defined time
§Errors
sourcepub fn voting_exists(
&self,
voting_id: VotingId,
voting_type: VotingType
) -> bool
pub fn voting_exists( &self, voting_id: VotingId, voting_type: VotingType ) -> bool
Checks if voting of a given type and id exists.
sourcepub fn get_ballot(
&self,
voting_id: VotingId,
voting_type: VotingType,
address: Address
) -> Option<Ballot>
pub fn get_ballot( &self, voting_id: VotingId, voting_type: VotingType, address: Address ) -> Option<Ballot>
Returns the Voter’s Ballot
.
sourcepub fn get_voter(
&self,
voting_id: VotingId,
voting_type: VotingType,
at: u32
) -> Option<Address>
pub fn get_voter( &self, voting_id: VotingId, voting_type: VotingType, at: u32 ) -> Option<Address>
Returns the address of nth voter who voted on Voting with voting_id
.
sourcepub fn get_voting(&self, voting_id: VotingId) -> Option<VotingStateMachine>
pub fn get_voting(&self, voting_id: VotingId) -> Option<VotingStateMachine>
Returns Voting for given id.
sourcepub fn post_job_offer(
&mut self,
expected_timeframe: BlockTime,
budget: Balance,
dos_fee: Balance
)
pub fn post_job_offer( &mut self, expected_timeframe: BlockTime, budget: Balance, dos_fee: Balance )
Job Poster post a new Job Offer.
§Errors
NotKyced
- if the caller is not KYCedDosFeeTooLow
- if the caller has not sent enough DOS Fee
§Events
sourcepub fn pick_bid(
&mut self,
job_offer_id: JobOfferId,
bid_id: BidId,
cspr_amount: Balance
)
pub fn pick_bid( &mut self, job_offer_id: JobOfferId, bid_id: BidId, cspr_amount: Balance )
Job poster picks a bid. This creates a new Job object and saves it in a storage.
§Events
JobCreated
Unstake
- in case there were other bids on the same Job Offer
§Errors
OnlyJobPosterCanPickABid
- if the caller is not the Job PosterPurseBalanceMismatch
- if the purse balance does not match the bid amount
sourcepub fn submit_bid(
&mut self,
job_offer_id: JobOfferId,
time: BlockTime,
payment: Balance,
reputation_stake: Balance,
onboard: bool,
cspr_stake: Option<Balance>
)
pub fn submit_bid( &mut self, job_offer_id: JobOfferId, time: BlockTime, payment: Balance, reputation_stake: Balance, onboard: bool, cspr_stake: Option<Balance> )
Worker submits a Bid for a Job.
§Events
§Errors
NotKyced
- if the caller is not KYCedCannotBidOnOwnJob
- if the caller is the Job PosterVaOnboardedAlready
- if the caller has already been onboarded, but is trying to onboard againPaymentExceedsMaxBudget
- if the proposed payment exceeds the maximum budgetAuctionNotRunning
- if the auction is not runningOnlyOnboardedWorkerCanBid
- if the Worker is not onboarded and the auction is internalOnboardedWorkerCannotBid
- if the Worker is onboarded, auction is public and the configuration forbids bidding by onboarded Workers on such auctionsInsufficientBalance
- if the Worker has not enough balance to pay for the bidZeroStake
- if the Worker tries to stake 0 reputationNotWhitelisted
- if the contract is not whitelisted for Reputation Staking
sourcepub fn cancel_bid(&mut self, bid_id: BidId)
pub fn cancel_bid(&mut self, bid_id: BidId)
Worker cancels a Bid for a Job.
Bid can be cancelled only after VABidAcceptanceTimeout time has passed after submitting a Bid.
§Events
§Errors:
CannotCancelNotOwnedBid
when trying to cancel a Bid that is not owned by the WorkerCannotCancelBidOnCompletedJobOffer
when trying to cancel a Bid on a Job Offer that is already completedCannotCancelBidBeforeAcceptanceTimeout
when trying to cancel a Bid before VABidAcceptanceTimeout time has passed
sourcepub fn cancel_job_offer(&mut self, job_offer_id: JobOfferId)
pub fn cancel_job_offer(&mut self, job_offer_id: JobOfferId)
sourcepub fn job_offers_count(&self) -> u32
pub fn job_offers_count(&self) -> u32
Returns the total number of job offers.
sourcepub fn bids_count(&self) -> u32
pub fn bids_count(&self) -> u32
Returns the total number of bids.
sourcepub fn get_job_offer(&self, job_offer_id: JobOfferId) -> Option<JobOffer>
pub fn get_job_offer(&self, job_offer_id: JobOfferId) -> Option<JobOffer>
Returns a JobOffer with given JobOfferId.
sourcepub fn submit_job_proof(&mut self, job_id: JobId, proof: DocumentHash)
pub fn submit_job_proof(&mut self, job_id: JobId, proof: DocumentHash)
Submits a job proof. This is called by a Worker
or any KYC’d user during Grace Period.
This starts a new voting over the result.
§Events
JobSubmitted
Unstake
- Stake is used in the votingBallotCast
- first vote is cast by the Worker
§Errors
Throws JobAlreadySubmitted
if job was already submitted.
Throws OnlyWorkerCanSubmitProof
if the caller is not the Worker
and the grace period is not ongoing.
sourcepub fn submit_job_proof_during_grace_period(
&mut self,
job_id: JobId,
proof: DocumentHash,
reputation_stake: Balance,
onboard: bool
)
pub fn submit_job_proof_during_grace_period( &mut self, job_id: JobId, proof: DocumentHash, reputation_stake: Balance, onboard: bool )
Updates the old Bid
and Job
, the job is assigned to a new Worker
. The rest goes the same
as regular proof submission. See submit_job_proof().
The old Worker
who didn’t submit the proof in time, is getting slashed.
pub fn cancel_job(&mut self, job_id: JobId)
sourcepub fn vote(
&mut self,
voting_id: VotingId,
voting_type: VotingType,
choice: Choice,
stake: Balance
)
pub fn vote( &mut self, voting_id: VotingId, voting_type: VotingType, choice: Choice, stake: Balance )
Casts a vote over a job.
§Events
§Errors
CannotVoteOnOwnJob
if the voter is either of Job Poster or WorkerVotingNotStarted
if the voting was not yet started for this job
sourcepub fn finish_voting(
&mut self,
voting_id: VotingId,
voting_type: VotingType
) -> VotingSummary
pub fn finish_voting( &mut self, voting_id: VotingId, voting_type: VotingType ) -> VotingSummary
Finishes voting. Depending on type of voting, different actions are performed. Read more
§Events
VotingEnded
BallotCast
- when formal voting startsUnstake
Stake
Mint
§Errors
BidNotFound
if the bid was not foundVotingDoesNotExist
if the voting does not existVotingWithGivenTypeNotInProgress
if the voting is not in progressFinishingCompletedVotingNotAllowed
if the voting is already completed
sourcepub fn jobs_count(&self) -> u32
pub fn jobs_count(&self) -> u32
Returns the total number of jobs.
sourcepub fn propose_new_owner(&mut self, owner: Address)
pub fn propose_new_owner(&mut self, owner: Address)
Changes the ownership of the contract. Transfers ownership to the owner
.
Only the current owner is permitted to call this method.
Read more
sourcepub fn accept_new_owner(&mut self)
pub fn accept_new_owner(&mut self)
Accepts the new owner proposition. This can be called only by the proposed owner.
Read more
sourcepub fn add_to_whitelist(&mut self, address: Address)
pub fn add_to_whitelist(&mut self, address: Address)
Adds a new address to the whitelist.
Read more
sourcepub fn remove_from_whitelist(&mut self, address: Address)
pub fn remove_from_whitelist(&mut self, address: Address)
Remove address from the whitelist.
Read more
;
sourcepub fn is_whitelisted(&self, address: Address) -> bool
pub fn is_whitelisted(&self, address: Address) -> bool
Checks whether the given address is added to the whitelist.
Read more
.
sourcepub fn get_owner(&self) -> Option<Address>
pub fn get_owner(&self) -> Option<Address>
Returns the address of the current owner.
Read more
.
sourcepub fn init(
&mut self,
variable_repository: Address,
reputation_token: Address,
kyc_token: Address,
va_token: Address
)
pub fn init( &mut self, variable_repository: Address, reputation_token: Address, kyc_token: Address, va_token: Address )
Constructor function.
§Note
Initializes contract elements:
- Sets up the contract by saving addresses of
Variable Repository
,Reputation Token
,VA Token
,KYC Token
. - Sets [
caller
] as the owner of the contract. - Adds [
caller
] to the whitelist.
§Events
Emits:
Trait Implementations§
source§impl Clone for BidEscrowContractRef
impl Clone for BidEscrowContractRef
source§fn clone(&self) -> BidEscrowContractRef
fn clone(&self) -> BidEscrowContractRef
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more