Beispiel #1
0
 def init(self):
     super(OracleContract, self).init()
     self.manifest.abi.events = [
         contracts.ContractEventDescriptor(
             "OracleRequest",
             parameters=[
                 contracts.ContractParameterDefinition(
                     "Id", contracts.ContractParameterType.INTEGER),
                 contracts.ContractParameterDefinition(
                     "RequestContract",
                     contracts.ContractParameterType.HASH160),
                 contracts.ContractParameterDefinition(
                     "Url", contracts.ContractParameterType.STRING),
                 contracts.ContractParameterDefinition(
                     "Filter", contracts.ContractParameterType.STRING)
             ]),
         contracts.ContractEventDescriptor(
             "OracleResponse",
             parameters=[
                 contracts.ContractParameterDefinition(
                     "Id", contracts.ContractParameterType.INTEGER),
                 contracts.ContractParameterDefinition(
                     "OriginalTx", contracts.ContractParameterType.HASH160)
             ])
     ]
Beispiel #2
0
 def init(self):
     super(DesignationContract, self).init()
     self.manifest.abi.events = [
         contracts.ContractEventDescriptor(
             "Designation",
             parameters=[
                 contracts.ContractParameterDefinition(
                     "Role", contracts.ContractParameterType.INTEGER),
                 contracts.ContractParameterDefinition(
                     "BlockIndex", contracts.ContractParameterType.INTEGER),
             ]),
         contracts.ContractEventDescriptor(
             "OracleResponse",
             parameters=[
                 contracts.ContractParameterDefinition(
                     "Id", contracts.ContractParameterType.INTEGER),
                 contracts.ContractParameterDefinition(
                     "OriginalTx", contracts.ContractParameterType.HASH160)
             ])
     ]
Beispiel #3
0
    def init(self):
        super(ManagementContract, self).init()

        self.manifest.abi.events = [
            contracts.ContractEventDescriptor(
                "Deploy",
                parameters=[
                    contracts.ContractParameterDefinition(
                        "Hash", contracts.ContractParameterType.HASH160)
                ]),
            contracts.ContractEventDescriptor(
                "Update",
                parameters=[
                    contracts.ContractParameterDefinition(
                        "Hash", contracts.ContractParameterType.HASH160)
                ]),
            contracts.ContractEventDescriptor(
                "Destroy",
                parameters=[
                    contracts.ContractParameterDefinition(
                        "Hash", contracts.ContractParameterType.HASH160)
                ]),
        ]
Beispiel #4
0
 def setUpClass(cls) -> None:
     """
     var methods = new ContractMethodDescriptor[]
     {
         new ContractMethodDescriptor {
             Name = "main_entry",
             Offset = 0,
             Parameters = new ContractParameterDefinition[0],
             ReturnType = ContractParameterType.Integer,
             Safe = true
         }
     };
     var events = new ContractEventDescriptor[]
     {
         new ContractEventDescriptor() { Name = "main_event", Parameters = new ContractParameterDefinition[0]}
     };
     var abi = new ContractAbi()
     {
         Methods = methods,
         Events = events
     };
     Console.WriteLine(abi.ToJson());
     """
     cls.method1 = contracts.ContractMethodDescriptor(
         name="main_entry",
         offset=0,
         parameters=[],
         return_type=contracts.ContractParameterType.INTEGER,
         safe=True)
     cls.methods = [cls.method1]
     cls.event = contracts.ContractEventDescriptor(name="main_event",
                                                   parameters=[])
     cls.events = [cls.event]
     # captured from C#
     cls.expected_json = {
         "methods": [{
             "name": "main_entry",
             "parameters": [],
             "returntype": "Integer",
             "offset": 0,
             "safe": True
         }],
         "events": [{
             "name": "main_event",
             "parameters": []
         }]
     }
Beispiel #5
0
    def init(self):
        super(NonFungibleToken, self).init()
        self.key_total_suppply = storage.StorageKey(self._id, b'\x0b')
        self.key_token = storage.StorageKey(self._id, b'\x05')
        self.key_account = storage.StorageKey(self._id, b'\x07')

        self.manifest.abi.events = [
            contracts.ContractEventDescriptor(
                "Transfer",
                parameters=[
                    contracts.ContractParameterDefinition("from", contracts.ContractParameterType.HASH160),
                    contracts.ContractParameterDefinition("to", contracts.ContractParameterType.HASH160),
                    contracts.ContractParameterDefinition("amount", contracts.ContractParameterType.INTEGER),
                    contracts.ContractParameterDefinition("tokenId", contracts.ContractParameterType.BYTEARRAY)
                ]
            )
        ]
Beispiel #6
0
    def init(self):
        super(FungibleToken, self).init()

        self.key_account = storage.StorageKey(self._id, b'\x14')
        self.key_total_supply = storage.StorageKey(self._id, b'\x0B')

        self.manifest.supported_standards = ["NEP-17"]
        self.manifest.abi.events = [
            contracts.ContractEventDescriptor(
                "Transfer",
                parameters=[
                    contracts.ContractParameterDefinition("from", contracts.ContractParameterType.HASH160),
                    contracts.ContractParameterDefinition("to", contracts.ContractParameterType.HASH160),
                    contracts.ContractParameterDefinition("amount", contracts.ContractParameterType.INTEGER)
                ]
            )
        ]
        self.factor = pow(vm.BigInteger(10), vm.BigInteger(self._decimals))
Beispiel #7
0
 def test_to_json(self):
     ced = contracts.ContractEventDescriptor("MainEvent", self.parameters)
     self.assertEqual(self.expected, ced.to_json())