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

WeBASE的页面上发起交易时,智能合约函数的参数为字符串时,无法传入空内容的字符串 #287

Open
AndyLvVip opened this issue Jul 4, 2023 · 2 comments
Labels
help wanted Extra attention is needed

Comments

@AndyLvVip
Copy link

AndyLvVip commented Jul 4, 2023

WeBASE版本:1.5.5

测试的智能合约:

// SPDX-License-Identifier: GPL-3.0 
pragma solidity >=0.6.0 <0.9.0;
pragma experimental ABIEncoderV2;

contract EmptyString {
    
    function empty(string memory str) public view returns (uint256 len) {
        return bytes(str).length;
    }
    
    struct DummyBO {
        string str;
    }
    
    function emptyStruct(DummyBO memory dummy) public view returns (uint256 len) {
        return bytes(dummy.str).length;
    }
}

操作步骤

第一步:在页面上部署智能合约
第二步:在页面上发起交易

第一个函数的测试数据为""时,返回2

第二个函数的测试数据为[""],返回0

期望结果

当第一个函数的测试数据为""时,返回0,当第一个函数的测试数据为"\"\"",这种情况返回2才是跟现有的逻辑保持一致。
@CodingCattwo
Copy link
Contributor

输入""的时候,双引号被当做了参数
当前合约IDE前端对参数输入框做了非空限制,确实会影响输入空字符串的情况。

考虑在后续版本的参数输入框中加入“取消非空限制”的按钮,实现传入空字符串的效果

@AndyLvVip
Copy link
Author

输入""的时候,双引号被当做了参数 当前合约IDE前端对参数输入框做了非空限制,确实会影响输入空字符串的情况。

考虑在后续版本的参数输入框中加入“取消非空限制”的按钮,实现传入空字符串的效果

为什么不是将""解释成空白字符串,因为"a"也是解释成a,保持一致的逻辑不是更合理吗?

@CodingCattwo CodingCattwo added the help wanted Extra attention is needed label Sep 26, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants