Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error at WeiAccounting trigger #450

Open
wmanshu opened this issue Aug 6, 2019 · 0 comments
Open

Error at WeiAccounting trigger #450

wmanshu opened this issue Aug 6, 2019 · 0 comments
Labels

Comments

@wmanshu
Copy link

wmanshu commented Aug 6, 2019

In KotET.flint, contract ValidKotET, function dethrone
pastKings[king] = Wei(&pot, calculateCompensation())

cause an error:

Warning in /flint/stdlib/WeiAccounting.inv:
  This is the failing pre-condition
    Caused by WeiAccounting trigger at line 2, column 3:
    totalValue_Wei == receivedValue_Wei - sentValue_Wei

However in a simpler contract, KotET, we also have dethrone function, these two are similar except the line above. Doesn't have any problem.

  public func dethrone(implicit value: Wei)
    mutates (Wei.rawValue, king, claimPrice, pot, owner)

  {
    if value.rawValue < claimPrice {
      fatalError()
    }

    let oldKing: Address = king
    let compensation: Wei = Wei(&pot, calculateCompensation())

    self.claimPrice = calculateNewPrice(bid: value.rawValue)
    self.king = caller
    pot.transfer(source: &value)
    send(oldKing, &compensatiosn)
  }

func calculateCompensation() -> Int
  post (returns (pot.rawValue))
  {
    return pot.getRawValue()
  }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants