def Main(operation, args): """ :Entry point of Core_NA SmartContract: """ trigger = GetTrigger() if trigger == Verification(): # check if the invoker is the owner of this contract is_owner = CheckWitness(ROOT_ADMIN) # If owner, proceed if is_owner: return True return False elif trigger == Application(): if operation == 'init': initialized = storage_load("Core_NASC_initialized") if not initialized: return init() root_na = storage_load("root_NA") if root_na: return DynamicAppCall(root_na, operation, args) else: Notify("DynamicAppCall failed.") return False
def alias_available_for_registration(alias): """ :returns true if alias is available for registration: Based on expiration of alias """ owner = alias_get_owner(alias) for_sale = alias_get_for_sale(alias) if for_sale or CheckWitness(owner): alias_reservation = 0 else: hard_coded_minimum = 0 # prevent negative reservation alias_reservation = storage_load(b'res_dur') if not alias_reservation or alias_reservation < hard_coded_minimum: alias_reservation = hard_coded_minimum expiration = alias_get_expiration(alias) end = expiration + alias_reservation timestamp = get_header_timestamp() free = storage_load(b'non_expirable_accs') if free and alias_get_type(alias) == 4: return False if end > timestamp: return False return True
def alias_load(alias): """ :param alias::: Alias: \n:returns alias::: Alias: \nLoads alias from storage, based on alias.name and alias.atype.load_alias """ name = alias_get_name(alias) prefix = alias_get_prefix(alias) key = concat(prefix, name) serialized = storage_load(key) if serialized: deserialized = deserialize_bytearray(serialized) dummy = alias_set_target(alias, deserialized[0]) dummy = alias_set_owner(alias, deserialized[1]) dummy = alias_set_expiration(alias, deserialized[2]) dummy = alias_set_owner_since(alias, deserialized[3]) dummy = alias_set_buy_offer_owner(alias, deserialized[4]) dummy = alias_set_buy_offer_price(alias, deserialized[5]) dummy = alias_set_buy_offer_expiration(alias, deserialized[6]) dummy = alias_set_buy_offer_target(alias, deserialized[7]) dummy = alias_set_for_sale(alias, deserialized[8]) dummy = alias_set_sell_offer_price(alias, deserialized[9]) return alias
def alias_in_storage(alias): """ :returns True if alias inStorage: it is based on ability to load alias """ name = alias_get_name(alias) prefix = alias_get_prefix(alias) key = concat(prefix, name) serialized = storage_load(key) if serialized: return True return False
def alias_expired(alias): """ : returns True if alias already expired: May be expired but not available for registrations, because of defined reservation """ # if NEO accs free of charge # NEO account never expire, can be only sold free = storage_load(b'non_expirable_accs') if free and alias_get_type(alias) == 4: return False expiration = alias_get_expiration(alias) return expiration < get_header_timestamp()
def get_collected_fees(): """ :returns total of collected fees (not redistributed): """ collected = storage_load("collected_fees_in_pool") return collected