def apply(receiver, code, action): if action == N('sayhello'): from hello import sayhello sayhello.sayHello('mike') elif action == N('setcode'): data = read_action() # print(struct.unapck) code_account, code_name, code_type = struct.unpack('QQB', data[:17]) src_code = eoslib.unpack_bytes(data[17:]) eoslib.set_code_ext(code_account, 1, code_name, src_code) elif action == N('auth'): data = read_action() code_owner, code_name, auth_to = struct.unpack('QQQ', data) code = N('eosio.code') scope = code itr = db.find_i64(code, code_owner, auth_to, code_name) print(itr) if itr >= 0: return payer = code_owner db.store_i64(code_owner, auth_to, payer, code_name, b'1') elif action == N('unauth'): data = read_action() code_owner, code_name, auth_to = struct.unpack('QQQ', data) code = N('eosio.code') scope = code itr = db.find_i64(code, code_owner, auth_to, code_name) if itr >= 0: db.remove_i64(itr) elif action == N('import'): from eosio.code import hello
def apply(receiver, account, act): if act == N('create'): msg = eoslib.read_action() _create(msg) elif act == N('issue'): msg = eoslib.read_action() _issue(msg) elif act == N('transfer'): msg = eoslib.read_action() _transfer(msg)
def unpack(self): msg = read_action() self._from, self.to, self.amount = struct.unpack('QQQ', msg) self.precision = msg[24] self.symbol = msg[25:32] self.memo = msg[32:]
def unpack(self): msg = eoslib.read_action() self.issuer, self.amount = struct.unpack('QQ', msg) self.precision = msg[16] self.symbol = msg[17:24].decode('utf8') self.can_freeze = msg[24] self.can_recall = msg[25] self.can_whitelist = msg[26]
def apply(receiver, code, action): if action == N('setgreeting'): greeter = Greeter() # print('original greeting:',greeter.greeting) value = read_action() greeter.greeting = value.decode('utf8') elif action == N('greeting'): greeter = Greeter() print(greeter.greeting)
def apply(receiver, code, action): if action == N('sayhello'): eoslib.require_auth(N('call')) msg = eoslib.read_action() print(msg.decode('utf8')) elif action == N('call'): msg = eoslib.read_action() _from, to, amount = struct.unpack('QQQ', msg) symbol = bytearray(8) symbol[0] = 4 symbol[1] = ord('E') symbol[2] = ord('O') symbol[3] = ord('S') memo = eoslib.pack_bytes(b'hello') args = struct.pack('QQQ8s%ds' % (len(memo), ), _from, to, amount, symbol, memo) print('++++call') eoslib.send_inline(N('eosio.token'), N('transfer'), args, {'call': 'active'})
def apply(receiver, code, action): if action == N('sayhello'): sayHello() elif action == N('deploy'): src_code = read_action() print(src_code) eoslib.set_code_ext(receiver, 1, N('lib'), src_code) elif action == N('deploytest'): print('import lib test...') import lib print('lib', lib) lib.sayHello()
def sayHello(): n = N('hello') id = N('name') name = read_action() print('hello', name) code = n scope = n table = n payer = n itr = db.find_i64(code, scope, table, id) if itr >= 0: # value exist, update it old_name = db.get_i64(itr) print('hello,', old_name) db.update_i64(itr, payer, name) else: db.store_i64(scope, table, payer, id, name)
def unpack(self): msg = eoslib.read_action() self.to, self.amount = struct.unpack('QQ', msg) self.precision = msg[16] self.symbol = msg[17:24].decode('utf8') self.memo = eoslib.unpack(msg[24:])
def unpack(self): msg = read_action() self.to, self.amount = struct.unpack('QQ', msg) self.precision = msg[16] self.symbol = msg[17:24] self.memo = msg[24:]