def fr_list_append(project_id, key, new_item): """Adds the input list of funding stages to storage (as serialized array) Args: project_id (list): ID for referencing the project new_list (list): list of funding stages to save to storage """ storage = StorageManager() print('new_item') print(new_item) # Gets current stored list current_serialized_list = storage.get_double(project_id, key) # Converts serialized list to normal list current_list = storage.deserialize_bytearray(current_serialized_list) current_list_len = len(current_list) print('current_list_len') print(current_list_len) if current_list_len == 0: output_list = [new_item] else: output_list = current_list output_list.append(new_item) # Serializes list serialized_output_list = storage.serialize_array(output_list) print('serialized_output_list') print(serialized_output_list) # Saves updated serialized list to storage storage.put_double(project_id, key, serialized_output_list)
def ms_get(project_id, milestone_id) -> Milestone: """ Pulls an existing Milestone from storage using the input attributes, and returns a Milestone object Args: project_id (str): ID for referencing the project milestone_id (str): ID for referencing the Milestone Return: (Milestone): Returns a Milestone object containing attributes """ storage = StorageManager() ms = Milestone() # Pull Milestone info milestone_info_serialized = storage.get_triple('MS', project_id, milestone_id) milestone_info = storage.deserialize_bytearray(milestone_info_serialized) if len(milestone_info) == 4: # Saves vars to object ms.project_id = project_id ms.milestone_id = milestone_id ms.title = milestone_info[0] ms.subtitle = milestone_info[1] ms.extra_info_hash = milestone_info[2] ms.progress = milestone_info[3] return ms
def sts_get(project_id) -> SmartTokenShare: """ Get the info list Args: project_id (str): ID for referencing the project Return: (SmartTokenShare): Returns a Smart Token Share object containing attributes """ storage = StorageManager() sts = SmartTokenShare() # Pull STS info sts_info_serialized = storage.get_double('STS', project_id) if sts_info_serialized: sts_info = storage.deserialize_bytearray(sts_info_serialized) # Saves vars to object sts.project_id = project_id sts.symbol = sts_info[0] sts.decimals = sts_info[1] sts.owner = sts_info[2] sts.total_supply = sts_info[3] sts.total_in_circulation = sts_info[4] print('sts_get') print(sts.owner) return sts
def fr_get_list(project_id, key): """ Registers all input addresses Args: project_id (list): ID for referencing the project Return: (list): Output list for key """ storage = StorageManager() # Gets current stored list serialized_list = storage.get_double(project_id, key) # Converts serialized list to normal list output_list = storage.deserialize_bytearray(serialized_list) # output_list = ['sdad','sdads'] return output_list
def fs_get(project_id, funding_stage_id) -> FundingStage: """ Pulls an existing Funding Stage from storage using the input attributes, and returns a FundingStage object Args: project_id (str): ID for referencing the project funding_stage_id (str): ID for referencing the funding stage Return: (FundingStage): Returns a funding stage object containing attributes """ storage = StorageManager() fs = FundingStage() # Pull FundingStage info fs_info_serialized = storage.get_triple('FS', project_id, funding_stage_id) if not fs_info_serialized: print('fs_info_serialized is null') return None fs_info = storage.deserialize_bytearray(fs_info_serialized) # Saves vars to object fs.project_id = project_id fs.funding_stage_id = funding_stage_id fs.start_block = fs_info[0] fs.end_block = fs_info[1] fs.supply = fs_info[2] fs.tokens_per_gas = fs_info[3] fs.in_circulation = fs_info[4] return fs
def get_kyc_submission(self, project_id, address): """ Submits a KYC information to the smart contract Args: sts (SmartTokenShare): Smart Token Share reference object address (str): Wallet address to whitelist Returns: (list): Of KYC submission list (address, phys_address, first_name, last_name, id_type, id_number, id_expiry, file_location, file_hash) """ storage = StorageManager() # Gets sts object sts = sts_get(project_id) # Checking the invoker is the owner/admin if CheckWitness(sts.owner): if len(address) == 20: # Deserialises bytearray back into a list serialized_kyc_sub = storage.get_triple('KYC', project_id, address) return storage.deserialize_bytearray(serialized_kyc_sub)