Skip to content

EVM交易日志打印信息优化(低优先级) #1012

Description

@andyYuanFZM

在solidity合约中定义出错信息: only authorized owner can store files.
EVM交易中打印的信息中会多出一些空格符号,有时间可以优化下:

receipt": {
"ty": 1,
"tyName": "ExecPack",
"logs": [
{
"ty": 1,
"tyName": "LogErr",
"log": "evm: execution reverted,detail: \u0008\ufffdy\ufffd\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000 \u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0026only authorized owner can store files.\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000",
"rawLog": "0x65766d3a20657865637574696f6e2072657665727465642c64657461696c3a2008c379a0000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000266f6e6c7920617574686f72697a6564206f776e65722063616e2073746f72652066696c65732e0000000000000000000000000000000000000000000000000000"
}
]
},

solidity合约参考代码如下:
==== BasicAuth.sol
contract BasicAuth {
address public _owner;

constructor() public {
    _owner = msg.sender;
}

function setOwner(address owner)
    public onlyOwner {
    _owner = owner;
}

modifier onlyOwner() { 
    require(msg.sender == _owner, "only authorized owner can store files.");
    _; 
}

}

===== FileStore.sol
pragma solidity >=0.6.2 <0.7.0;

import "./BasicAuth.sol";

contract FileStore is BasicAuth {
mapping(string => string) _fileStockByID;

modifier validFileId(string memory fileId) {
    require(bytes(fileId).length > 0, "fileId is invalid!");
    _;
}

function setFileStockById(string memory fileId, string memory content) 
    onlyOwner validFileId(fileId) external {
    _fileStockByID[fileId] = content;
}

function getFileById(string memory fileId) external view  returns(string memory) {
    return _fileStockByID[fileId];
}

}

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions