Ejemplo n.º 1
0
    async def get_contract(self, addr: TAddress) -> AsyncContract:
        """Get a contract object."""
        addr = keys.to_base58check_address(addr)
        info = await self.provider.make_request("wallet/getcontract", {
            "value": addr,
            "visible": True
        })

        try:
            self._handle_api_error(info)
        except ApiError:
            # your java's null pointer exception sucks
            raise AddressNotFound("contract address not found")

        cntr = AsyncContract(
            addr=addr,
            bytecode=info.get("bytecode", ''),
            name=info.get("name", ""),
            abi=info.get("abi", {}).get("entrys", []),
            origin_energy_limit=info.get("origin_energy_limit", 0),
            user_resource_percent=info.get("consume_user_resource_percent",
                                           100),
            client=self,
        )
        return cntr
Ejemplo n.º 2
0
    def get_account_resource(self, addr: TAddress) -> dict:
        """Get resource info of an account."""

        ret = self.provider.make_request(
            "wallet/getaccountresource", {"address": keys.to_base58check_address(addr), "visible": True},
        )
        if ret:
            return ret
        else:
            raise AddressNotFound("account not found on-chain")
Ejemplo n.º 3
0
    async def get_account(self, addr: TAddress) -> dict:
        """Get account info from an address."""

        ret = await self.provider.make_request(
            "wallet/getaccount", {"address": keys.to_base58check_address(addr), "visible": True}
        )
        if ret:
            return ret
        else:
            raise AddressNotFound("account not found on-chain")