unknown_variable_fail.adl
1 2 program test.alpha { 3 4 struct TokenInfo { 5 name: field, 6 symbol: field, 7 decimals: u8, 8 circulating_supply: u64, 9 total_supply: u64, 10 testers: u64, 11 admin: address, 12 } 13 14 15 struct TestToken { 16 name: field, 17 symbol: field, 18 decimals: u8, 19 circulating_supply: u64, 20 total_supply: u64, 21 admin: address, 22 } 23 24 struct GlobalState { 25 next_token_id: field, 26 admin: address, 27 } 28 29 mapping tokens: u64 => TokenInfo; 30 31 mapping test_token: u64 => TestToken; 32 33 mapping global_state: bool => GlobalState; 34 35 async transition init(b: bool) -> (address, Future) { 36 return (self.caller, finalize_init(caller)); 37 } 38 39 async function finalize_init(caller: address) { 40 let gs: GlobalState = Mapping::get_or_use(global_state, true, GlobalState { 41 next_token_id: 0field, 42 admin: ax1az8p9vlllyqwtj0c2g9svkd0e5v0p3zzdflwwrpa7kpe8xrfxgfqqpru7m, 43 }); 44 assert_eq(gs.next_token_id, 0field); 45 assert_eq(caller, gs.admin); 46 Mapping::set(global_state, true, GlobalState { 47 next_token_id: 1field, 48 admin: gs.admin, 49 }); 50 51 let test_supply: u64 = 15000000000000u64; 52 let admin_token_amt: u64 = 60000000u64; 53 let owner_amount: u64 = Mapping::get_or_use(account, caller, 0u64); 54 assert(owner_amount == 0u64); 55 Mapping::set(account, caller, owner_amount + admin_token_amt); 56 57 Mapping::set(test_token, test_supply, TestToken { 58 name: 4577111110111112111108121field, 59 symbol: 4577111110111112111108121field, 60 decimals: 6u8, 61 circulating_supply: 0u64 + admin_token_amt, 62 total_supply: test_supply, 63 admin: gs.admin, 64 }); 65 } 66 67 } 68 69