async def result(self, timeout=30, interval=1.6, solid=False) -> dict: """Wait the contract calling result. :returns: Result of contract method """ if self._method is None: raise TypeError("Not a smart contract call") receipt = await self.wait(timeout, interval, solid) if receipt.get('result', None) == 'FAILED': msg = receipt.get('resMessage', receipt['result']) if receipt['receipt']['result'] == 'REVERT': try: result = receipt.get('contractResult', []) if result and len(result[0]) > (4 + 32) * 2: error_msg = tron_abi.decode_single( 'string', bytes.fromhex(result[0])[4 + 32:]) msg = "{}: {}".format(msg, error_msg) except Exception: pass raise TvmError(msg) return self._method.parse_output(receipt['contractResult'][0])
async def trigger_const_smart_contract_function( self, owner_address: TAddress, contract_address: TAddress, function_selector: str, parameter: str, ) -> str: ret = await self.provider.make_request( "wallet/triggerconstantcontract", { "owner_address": keys.to_base58check_address(owner_address), "contract_address": keys.to_base58check_address(contract_address), "function_selector": function_selector, "parameter": parameter, "visible": True, }, ) self._handle_api_error(ret) if 'message' in ret.get('result', {}): msg = ret['result']['message'] result = ret.get('constant_result', []) try: if result and len(result[0]) > (4 + 32) * 2: error_msg = tron_abi.decode_single( 'string', bytes.fromhex(result[0])[4 + 32:]) msg = "{}: {}".format(msg, error_msg) except Exception: pass raise TvmError(msg) return ret["constant_result"][0]