1

当我尝试将示例合同部署到 Azure Blockchain Workbench 时:

合约合约函数 dispose 中的 ContractUpdated 调用有一个参数“只有合约所有者才能处置合约”。这是未在工作流的函数集中定义的函数名称。

该文本实际上是 require 语句中的一条消息,与工作流中的函数无关。

这是我的合同:

pragma solidity ^0.4.24;

contract WorkbenchBase {
    event WorkbenchContractCreated(string applicationName, string workflowName, address originatingAddress);
    event WorkbenchContractUpdated(string applicationName, string workflowName, string action, address originatingAddress);

    string internal ApplicationName;
    string internal WorkflowName;

    constructor(string memory applicationName, string memory workflowName) internal
    {
        ApplicationName = applicationName;
        WorkflowName = workflowName;
    }

    function ContractCreated() internal
    {
        emit WorkbenchContractCreated(ApplicationName, WorkflowName, msg.sender);
    }

    function ContractUpdated(string memory action) internal
    {
        emit WorkbenchContractUpdated(ApplicationName, WorkflowName, action, msg.sender);
    }
}

contract Contract is WorkbenchBase("Contract", "Contract")
{
    enum StateType
    {
        New,
        Disposed
    }

    address public owner;
    StateType public state;

    constructor() public
    {
        owner = msg.sender;
        state = StateType.New;

        ContractCreated();
    }

    function destroy() public
    {
        require(msg.sender == owner, "Only the contract owner can destroy the contract.");

        selfdestruct(owner);
    }

    function dispose() public
    {
        require(msg.sender == owner, "Only the contract owner can dispose of the contract.");

        state = StateType.Disposed;

        ContractUpdated('dispose');
    }
}

这是我的 JSON 文件:

{
    "Id": 1,
    "ApplicationName": "Contract",
    "DisplayName": "Contract",
    "Description": "",
    "ApplicationRoles": [
        {
            "Name": "Representative"
        }
    ],
    "Workflows": [
        {
            "Id": 1,
            "Name": "Contract",
            "DisplayName": "Contract",
            "Initiators": [
                "Representative"
            ],
            "StartState": "New",
            "Properties": [
                {
                    "Id": 1,
                    "Name": "state",
                    "DisplayName": "State",
                    "Description": "Holds the state.",
                    "Type": {
                        "Name": "state"
                    }
                },
                {
                    "Id": 2,
                    "Name": "owner",
                    "DisplayName": "Owner",
                    "Description": "Holds the address of the owner of the contract.",
                    "Type": {
                        "Name": "address"
                    }
                }
            ],
            "Constructor": {
                "Parameters": []
            },
            "Functions": [
                {
                    "Id": "1",
                    "Name": "dispose",
                    "DisplayName": "Dispose",
                    "Description": "Disposes the contract.",
                    "Parameters": []
                },
            ],
            "States": [
                {
                    "Id": 1,
                    "Name": "New",
                    "DisplayName": "New",
                    "PercentComplete": 0,
                    "Value": "New",
                    "Style": "Success",
                    "Transitions": [
                        {
                            "AllowedRoles": [
                                "Representative"
                            ],
                            "AllowedInstanceRoles": [],
                            "Description": "Disposes the contract.",
                            "Function": "dispose",
                            "NextStates": [
                                "Disposed"
                            ],
                            "DisplayName": "Dispose"
                        }
                    ]
                },
                {
                    "Id": 100,
                    "Name": "Disposed",
                    "DisplayName": "Disposed",
                    "PercentComplete": 100,
                    "Value": "Disposed",
                    "Style": "Failure",
                    "Transitions": []
                }
            ]
        }
    ]
}

这是 Azure Blockchain Workbench 中的错误还是我做错了什么?

4

0 回答 0