def __init__(self, name: Optional[str] = None): #: Contract name self.name: str = name if name else "" #: A group represents a set of mutually trusted contracts. A contract will trust and allow any contract in the #: same group to invoke it. self.groups: List[ContractGroup] = [] #: The list of NEP standards supported e.g. "NEP-3" self.supported_standards: List[str] = [] #: For technical details of ABI, please refer to NEP-14: NeoContract ABI. #: https://github.com/neo-project/proposals/blob/d1f4e9e1a67d22a5755c45595121f80b0971ea64/nep-14.mediawiki self.abi: contracts.ContractABI = contracts.ContractABI(events=[], methods=[]) #: Permissions describe what external contract(s) and what method(s) on these are allowed to be invoked. self.permissions: List[contracts.ContractPermission] = [ contracts.ContractPermission.default_permissions() ] # Update trusts/safe_methods with outcome of https://github.com/neo-project/neo/issues/1664 # Unfortunately we have to add this nonsense logic or we get deviating VM results. self.trusts = WildcardContainer() # for UInt160 types #: Optional user defined data self.extra: Optional[Dict] = None
def __init__(self, contract_hash: types.UInt160 = types.UInt160.zero()): """ Creates a default contract manifest if no arguments are supplied. A default contract is not Payable and has no storage as configured by its features. It may not be called by any other contracts Args: contract_hash: the contract script hash to create a manifest for. """ #: A group represents a set of mutually trusted contracts. A contract will trust and allow any contract in the #: same group to invoke it. self.groups: List[ContractGroup] = [] #: Features describe what contract abilities are available. TODO: link to contract features self.features: ContractFeatures = ContractFeatures.NO_PROPERTY #: The list of NEP standards supported e.g. "NEP-3" self.supported_standards: List[str] = [] #: For technical details of ABI, please refer to NEP-14: NeoContract ABI. #: https://github.com/neo-project/proposals/blob/d1f4e9e1a67d22a5755c45595121f80b0971ea64/nep-14.mediawiki self.abi: contracts.ContractABI = contracts.ContractABI( contract_hash=contract_hash, events=[], methods=[]) #: Permissions describe what external contract(s) and what method(s) on these are allowed to be invoked. self.permissions: List[contracts.ContractPermission] = [ contracts.ContractPermission.default_permissions() ] self.contract_hash: types.UInt160 = self.abi.contract_hash # Update trusts/safe_methods with outcome of https://github.com/neo-project/neo/issues/1664 # Unfortunately we have to add this nonsense logic or we get deviating VM results. self.trusts = WildcardContainer() # for UInt160 types self.safe_methods: WildcardContainer = WildcardContainer( ) # for string types self.extra = None
def test_to_json(self): abi = contracts.ContractABI(methods=self.methods, events=self.events) self.assertEqual(self.expected_json, abi.to_json())
def test_to_json(self): abi = contracts.ContractABI(contract_hash=types.UInt160.zero(), methods=self.methods, events=self.events) self.assertEqual(self.expected_json, abi.to_json())