def main(): equal = 9 l4 = l3 = l0 = [9, 8, "hello", 6] l1 = [9, 8, "world", 6] l2 = [9, 8, "hello", 6] if l0 is l2: equal = 1 else: equal = 0 assert(equal == 0) equal = 9 if l0 is l3: equal = 1 else: equal = 0 assert(equal == 1) equal = 9 if l3 is l4: equal = 1 else: equal = 0 assert(equal == 1) a = "hello" l0 = list_remove_elt(l0, 8) assert(not elt_in(l0, 8)) l0 = list_remove_elt(l0, a) assert(not elt_in(l0, a)) assert(not elt_in(l1, "world0")) assert(elt_in(l1, "world"))
def main(): operation = 'add' inor = 888 if elt_in(['add', 'sub', 'mul'], operation): inor = 1 print("in ") else: inor = 0 print("not in") VaasAssert(inor == 1 + 1)
def int(arg, scale=10): from ontology.libont import elt_in slen = len(arg) n = 1 num = 0 elt_p0 = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '-'] elt_p1 = ['a', 'b', 'c', 'd', 'e', 'f'] elt_p2 = ['A', 'B', 'C', 'D', 'E', 'F'] if scale != 10 and scale != 16: assert (False) for i in reversed(range(0, slen)): cur_char = arg[i:i + 1] if i != 0 and cur_char == '-': assert (False) if i == 0 and cur_char == '-': num = -num break else: if scale == 10: assert (elt_in(elt_p0, cur_char)) num += (cur_char - '0') * n elif scale == 16: if elt_in(elt_p0, cur_char): num += (cur_char - '0') * n elif elt_in(elt_p1, cur_char): num += (cur_char - 'a' + 10) * n elif elt_in(elt_p2, cur_char): num += (cur_char - 'A' + 10) * n else: assert (False) else: assert (False) n = n * scale return num
def Main(operation, args): print("appcall in") if elt_in(['add', 'sub', 'mul'], operation): print("StaticAppCall") return CalculatorContract(operation, args) elif operation[0:1] == 'd': address = bytearray_reverse( hexstring2bytes('1a6f62cc0ff3d9ae32b0b924aeda2056a9fdfccb')) print("DynamicAppCall") operation = operation[1:] print(operation) return DynamicAppCall(address, operation, args) elif operation == 'name': print("getname") return NAME
def hexstring2bytes(arg): from ontology.libont import elt_in elt_p0 = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9'] elt_p1 = ['a', 'b', 'c', 'd', 'e', 'f'] elt_p2 = ['A', 'B', 'C', 'D', 'E', 'F'] slen = len(arg) assert (slen % 2 == 0) str_res = '' num = 0 for i in range(0, slen): cur_char = arg[i:i + 1] if i % 2 == 0: if elt_in(elt_p0, cur_char): num = (cur_char - '0') elif elt_in(elt_p1, cur_char): num = (cur_char - 'a' + 10) elif elt_in(elt_p2, cur_char): num = (cur_char - 'A' + 10) else: assert (False) if num != 0: num = num & 0xf num = (num << 4) & 0xf0 num = num[0:1] assert (len(num) == 1) else: num = 0 else: if elt_in(elt_p0, cur_char): num += (cur_char - '0') elif elt_in(elt_p1, cur_char): num += (cur_char - 'a' + 10) elif elt_in(elt_p2, cur_char): num += (cur_char - 'A' + 10) else: assert (False) if num != 0: num = num[0:1] assert (len(num) == 1) str_res = concat(str_res, num) else: str_res = concat(str_res, b'\x00') return str_res
def Main(operation, args): global z0 z0 = 999 b0[a0[4]][0] = 30 b0[a0[0]][a0[4]][1] = 20 x = 'local' assert (b[1] == 7) assert (b[2] == 7) assert (b[3] == 7) assert (b[4] == 7) b[1] = 90 global a a[0][0] = '00' assert (x == 'local') checkglobal() assert (b[1] == 'checkglobal') assert (a == 9) print(a) print(b[1]) assert (b0 == 8888) assert (y0[2] == 88) if elt_in(['add', 'sub', 'mul'], operation): print("StaticAppCall") return CalculatorContract(operation, args) elif operation[0:1] == 'd': address = bytearray_reverse( hexstring2bytes('91125f47bd4823324de4897b64e0c2b3b503dfed')) print("DynamicAppCall") operation = operation[1:] print(operation) return DynamicAppCall(address, operation, args) elif operation == 'name': print("getname") return NAME
def supports(standard): return elt_in(STANDARDS, standard)