fn pay_back(&mut self, reward: fn(&Self, to: AccountId) -> (), to: AccountId) {
            // should be executed only on Ended auction
            assert_eq!(
                self.get_status(),
                Status::Ended,
                "Auction is not Ended, no payback is possible!"
            );

            if let Some(winner) = self.get_winner() {
                // winner gets her reward
                if to == winner {
                    // reward winner with specified reward method call
                    reward(&self, to);
                    return;
                } else if to == self.owner {
                    // remove winner balance from ledger:
                    let bal = self.balances.take(&winner).unwrap();
                    // zero-balance check: bid 0 is possible, but nothing to pay back
                    if bal > 0 {
                        // and pay for sold lot
                        // to auction owner
                        transfer::<Environment>(to, bal).unwrap();
                    }
                    return;
                }
            }

            // pay the looser his bidded amount back
            let bal = self.balances.take(&to).unwrap();
            // zero-balance check: bid 0 is possible, but nothing to pay back
            if bal > 0 {
                // and pay
                transfer::<Environment>(to, bal).unwrap();
            }
        }
/// Pay back.
/// Winner gets her reward.
/// Loosers get their balances back.
/// Contract owner gets winner`s balance (winning bid)
Pay back.
Winner gets her reward.
Loosers get their balances back.
Contract owner gets winner`s balance (winning bid)
Pay back . Winner gets her reward . Loosers get their balances back . Contract owner gets winner ` s balance ( winning bid )
fn pay_back(&mut self, reward: fn(&Self, to: AccountId) -> (), to: AccountId) {
            // should be executed only on Ended auction
            assert_eq!(
                self.get_status(),
                Status::Ended,
                "Auction is not Ended, no payback is possible!"
            );
            if let Some(winner) = self.get_winner() {
                // winner gets her reward
                if to == winner {
                    // reward winner with specified reward method call
                    reward(&self, to);
                    return;
                } else if to == self.owner {
                    // remove winner balance from ledger:
                    let bal = self.balances.take(&winner).unwrap();
                    // zero-balance check: bid 0 is possible, but nothing to pay back
                    if bal > 0 {
                        // and pay for sold lot
                        // to auction owner
                        transfer::<Environment>(to, bal).unwrap();
                    }
                    return;
                }
            }
            // pay the looser his bidded amount back
            let bal = self.balances.take(&to).unwrap();
            // zero-balance check: bid 0 is possible, but nothing to pay back
            if bal > 0 {
                // and pay
                transfer::<Environment>(to, bal).unwrap();
            }
        }
fn pay_back ( & mut self , reward : fn ( & Self , to : AccountId ) -> ( ) , to : AccountId ) { // should be executed only on Ended auction assert_eq ! ( self get_status ( ) Status Ended " " ) ; if let Some ( winner ) = self . get_winner ( ) { // winner gets her reward if to == winner { // reward winner with specified reward method call reward ( & self , to ) ; return ; } else if to == self . owner { // remove winner balance from ledger: let bal = self . balances . take ( & winner ) . unwrap ( ) ; // zero-balance check: bid 0 is possible, but nothing to pay back if bal > 0 { // and pay for sold lot // to auction owner transfer :: < Environment > ( to , bal ) . unwrap ( ) ; } return ; } } // pay the looser his bidded amount back let bal = self . balances . take ( & to ) . unwrap ( ) ; // zero-balance check: bid 0 is possible, but nothing to pay back if bal > 0 { // and pay transfer :: < Environment > ( to , bal ) . unwrap ( ) ; } }
Pay back.
Pay back .
&mut self
reward
fn(&Self, to: AccountId) -> ()
to
AccountId
&mut self
reward
fn(&Self, to: AccountId) -> ()
to
AccountId