Example #1
0
 def test_dict_in_ctx(self):
     hex_contract_address = '6690b6638251be951dded8c537678200a470c679'
     bool_value = True
     int_value = 100
     str_value = 'value3'
     dict_value = {'key': 'value'}
     list_value = [1, 10, 1024, [1, 10, 1024, [1, 10, 1024]]]
     dict_msg = {
         'key': dict_value,
         'key1': int_value,
         'key2': str_value,
         'key3': bool_value,
         'key4': list_value
     }
     func = NeoInvokeFunction('testMapInMap')
     func.set_params_value(dict_msg)
     tx_hash = sdk.rpc.send_neo_vm_transaction(hex_contract_address, None,
                                               acct1, self.gas_price,
                                               self.gas_limit, func, False)
     time.sleep(randint(10, 15))
     event = sdk.rpc.get_contract_event_by_tx_hash(tx_hash)
     states = Event.get_states_by_contract_address(event,
                                                   hex_contract_address)
     states[0] = NeoData.to_utf8_str(states[0])
     self.assertEqual('mapInfo', states[0])
     states[1] = NeoData.to_dict(states[1])
     self.assertTrue(isinstance(states[1], dict))
Example #2
0
 def parse_status(result: dict):
     status = result['Result']
     if status == '':
         status = False
     else:
         status = NeoData.to_dict(status)
         status = bool(status[3])
     return status
 def decode_neo_raw_data(data: str, d_type: str):
     if d_type.lower() == 'hex':
         return NeoData.to_hex_str(data)
     if d_type.lower() == 'int':
         return NeoData.to_int(data)
     if d_type.lower() == 'bool':
         return NeoData.to_bool(data)
     if d_type.lower() == 'utf8':
         return NeoData.to_utf8_str(data)
     if d_type.lower() == 'dict':
         return NeoData.to_dict(data)
     if d_type.lower() == 'bytes':
         return NeoData.to_bytes(data)
     if d_type.lower() == 'address':
         return NeoData.to_b58_address(data)
     return data
Example #4
0
def to_dict_cmd(ctx, data: str):
    """
    Decode Hex string to JSON string.
    """
    Info.echo_dict_info(NeoData.to_dict(data))