def __init__(self, config, **extra_storage): self.config = config self.error_message = Error_message(self.config) self.operator_set = Operator_set(self.config) self.operator_param = Operator_param(self.config) self.token_id_set = Token_id_set(self.config) self.ledger_key = Ledger_key(self.config) self.token_meta_data = Token_meta_data(self.config) self.permissions_descriptor_ = Permissions_descriptor(self.config) self.batch_transfer = Batch_transfer(self.config) if self.config.add_mutez_transfer: self.transfer_mutez = sp.entry_point(mutez_transfer) if self.config.add_permissions_descriptor: def permissions_descriptor(self, params): sp.set_type(params, sp.TContract(self.permissions_descriptor_.get_type())) v = self.permissions_descriptor_.make() sp.transfer(v, sp.mutez(0), params) self.permissions_descriptor = sp.entry_point(permissions_descriptor) if config.lazy_entry_points: self.add_flag("lazy_entry_points") if config.lazy_entry_points_multiple: self.add_flag("lazy_entry_points_multiple") self.exception_optimization_level = "DefaultLine" self.init( ledger = self.config.my_map(tvalue = Ledger_value.get_type()), token_metadata = self.config.my_map(tvalue = self.token_meta_data.get_type()), operators = self.operator_set.make(), all_tokens = self.token_id_set.empty(), **extra_storage )
def __init__(self, config, admin): self.config = config self.operator_set = Operator_set(self.config) self.operator_param = Operator_param(self.config) self.token_id_set = Token_id_set(self.config) self.ledger_key = Ledger_key(self.config) self.token_meta_data = Token_meta_data(self.config) self.permissions_descriptor_ = Permissions_descriptor(self.config) self.batch_transfer = Batch_transfer(self.config) if self.config.add_mutez_transfer: self.transfer_mutez = sp.entry_point(mutez_transfer) if self.config.add_permissions_descriptor: def permissions_descriptor(self, params): sp.set_type(params, sp.TContract(self.permissions_descriptor_.get_type())) v = self.permissions_descriptor_.make() sp.transfer(v, sp.mutez(0), params) self.permissions_descriptor = sp.entry_point(permissions_descriptor) self.init( highestTokenIndex = 0, paused = False, ledger = self.config.my_map(tvalue = Ledger_value.get_type()), tokens = self.config.my_map(tvalue = sp.TRecord( total_supply = sp.TNat, metadata = self.token_meta_data.get_type() )), operators = self.operator_set.make(), administrator = admin, all_tokens = self.token_id_set.empty(), metadata_string = sp.unit )
def __init__(self, config, metadata, **extra_storage): self.config = config self.error_message = Error_message(self.config) self.operator_set = Operator_set(self.config) self.operator_param = Operator_param(self.config) self.token_id_set = Token_id_set(self.config) self.ledger_key = Ledger_key(self.config) self.token_meta_data = Token_meta_data(self.config) self.batch_transfer = Batch_transfer(self.config) if self.config.add_mutez_transfer: self.transfer_mutez = sp.entry_point(mutez_transfer) if config.lazy_entry_points: self.add_flag("lazy-entry-points") self.add_flag("initial-cast") self.exception_optimization_level = "default-line" self.init( ledger = self.config.my_map(tvalue = Ledger_value.get_type()), token_metadata = self.config.my_map(tkey = sp.TNat, tvalue = self.token_meta_data.get_type()), operators = self.operator_set.make(), all_tokens = self.token_id_set.empty(), metadata = metadata, **extra_storage ) if self.config.store_total_supply: self.update_initial_storage( total_supply = self.config.my_map(tkey = sp.TNat, tvalue = sp.TNat), )
def __init__(self, config, admin): self.config = config self.error_message = Error_message(self.config) self.operator_set = Operator_set(self.config) self.operator_param = Operator_param(self.config) self.token_id_set = Token_id_set(self.config) self.ledger_key = Ledger_key(self.config) self.token_meta_data = Token_meta_data(self.config) self.permissions_descriptor_ = Permissions_descriptor(self.config) self.batch_transfer = Batch_transfer(self.config) self.player_meta_data = Player_meta_data(self.config) self.player_id_set = Player_id_set(self.config) if self.config.add_mutez_transfer: self.transfer_mutez = sp.entry_point(mutez_transfer) if self.config.add_permissions_descriptor: def permissions_descriptor(self, params): sp.set_type(params, sp.TContract( self.permissions_descriptor_.get_type())) v = self.permissions_descriptor_.make() sp.transfer(v, sp.mutez(0), params) self.permissions_descriptor = sp.entry_point( permissions_descriptor) if config.lazy_entry_points: self.add_flag("lazy_entry_points") if config.lazy_entry_points_multiple: self.add_flag("lazy_entry_points_multiple") self.exception_optimization_level = "DefaultLine" self.init( paused=False, ledger=self.config.my_map(tvalue=Ledger_value.get_type()), tokens=self.config.my_map(tvalue=self.token_meta_data.get_type()), operators=self.operator_set.make(), administrator=admin, all_tokens=self.token_id_set.empty(), players=self.config.my_map( tkey=sp.TNat, tvalue=self.player_meta_data.get_type()), tokens_on_sale=sp.big_map(tkey=sp.TNat, tvalue=sp.TRecord( owner=sp.TAddress, price=sp.TMutez)), selected_tokens=sp.map( tkey=sp.TAddress, tvalue=sp.TRecord(tokens=sp.TSet(sp.TNat))), matches=sp.map(tkey=sp.TNat, tvalue=sp.TRecord( teamA=sp.TString, teamB=sp.TString, active=sp.TBool, finished=sp.TBool, date=sp.TString, compete=sp.TBool)), playerPoints=sp.map(tkey=sp.TNat, tvalue=sp.TRecord( points=sp.TNat, rank=sp.TNat)), keysset=sp.set([admin]), )
def buildExtraMessages(self): for (name, f) in self.baseContract.messages.items(): def message(self, params): formerBaseData = self.baseContract.data self.baseContract.data = self.data.baseState self.nextState(name, params, f.addedMessage.f) self.baseContract.data = formerBaseData self.addMessage(sp.entry_point(message, name))
def set_contract_metadata(self, metadata): """ Set contract metadata """ self.update_initial_storage( metadata = sp.big_map(self.normalize_metadata(metadata)) ) if self.config.support_upgradable_metadata: def update_metadata(self, key, value): """ An entry-point to allow the contract metadata to be updated. Can be removed with `FA12_config(support_upgradable_metadata = False, ...)` """ sp.verify(self.is_administrator(sp.sender), FA12_Error.NotAdmin) self.data.metadata[key] = value self.update_metadata = sp.entry_point(update_metadata)