ERC1155Supply.spec 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. methods {
  2. totalSupply(uint256) returns uint256 envfree
  3. }
  4. /// given two different token ids, if totalSupply for one changes, then
  5. /// totalSupply for other should not
  6. rule token_totalSupply_independence(method f)
  7. filtered {
  8. f -> f.selector != _burnBatch(address,uint256[],uint256[]).selector
  9. && f.selector != _mintBatch(address,uint256[],uint256[],bytes).selector
  10. && f.selector != safeBatchTransferFrom(address,address,uint256[],uint256[],bytes).selector
  11. }
  12. {
  13. uint256 token1; uint256 token2;
  14. require token1 != token2;
  15. uint256 token1_before = totalSupply(token1);
  16. uint256 token2_before = totalSupply(token2);
  17. env e; calldataarg args;
  18. f(e, args);
  19. uint256 token1_after = totalSupply(token1);
  20. uint256 token2_after = totalSupply(token2);
  21. assert token1_after != token1_before => token2_after == token2_before,
  22. "methods must not change the total supply of more than one token";
  23. }
  24. rule sanity {
  25. method f; env e; calldataarg args;
  26. f(e, args);
  27. assert false;
  28. }