Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save gists-immunefi/8d8a04d3db98751ead48c845d96927dd to your computer and use it in GitHub Desktop.
Save gists-immunefi/8d8a04d3db98751ead48c845d96927dd to your computer and use it in GitHub Desktop.
contract;
//Setup
use std::{
asset::mint_to,
constants::DEFAULT_SUB_ID
};
abi PowBug {
fn demonstrate_bug_u8(recipient: Identity, a: u8) -> AssetId;
fn demonstrate_bug_u32(a: u32) -> u32;
}
impl PowBug for Contract {
fn demonstrate_bug_u8(recipient: Identity, a: u8) -> AssetId {
let result_u8 = a.pow(2);
let coins_to_mint = result_u8.as_u64() * 100;
if result_u8 > u8::max() {
revert(1337);
}
mint_to(recipient, DEFAULT_SUB_ID, coins_to_mint);
AssetId::new(ContractId::this(), DEFAULT_SUB_ID)
}
fn demonstrate_bug_u32(a: u32) -> u32 {
let coins_to_keep = a.pow(4);
if coins_to_keep <= u32::max() {
revert(1337)
}
coins_to_keep
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment