nebulasio / wiki

This repository is out of date, please check the new wiki:
http://wiki.nebulas.io/en/latest/
GNU General Public License v3.0
421 stars 153 forks source link

你们官方教程Nebulas 101 - 04 智能合约存储区,示例代码存在语法错误,根本无法编译 #139

Closed bugparty closed 6 years ago

bugparty commented 6 years ago

你们官方文档作者啊,还是得学习一个,你看看西方的以太坊,比你们不知道高到哪里去了

LocalContractStorage.defineMapProperty(this, "value", {
        stringify: function (obj) {
            return obj.toString();
        },
        parse: function (str) {
            return new BigNumber(str);
        }
    });
 testStorage: function (balance) {
        // 使用value时会从存储中读取链上数据,并根据descriptor设置自动转换为Bignumber
        var amount = this.value.plus(new BigNumber(2));
        if (amount.lessThan(new BigNumber(balance))) {
            return 0
        }
    }

this.value是一个map对象,testStorage函数居然把他当成了BigNumber进行操作 稍微懂得使用记事本复制粘贴的,部署下合约都会发现错误

yupnano commented 6 years ago

Thanks for your advice.