Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
andyYuanFZM opened this issue Aug 5, 2021 · 0 comments
Open

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

andyYuanFZM opened this issue Aug 5, 2021 · 0 comments

Comments

@andyYuanFZM
Copy link
Collaborator

在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];
}

}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant