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

合约返回"status":0,"execute_error":"inject tracing instructions failed" #177

Closed Goya- closed 6 years ago

Goya- commented 6 years ago

部署的合约是tutorial中改写ES6的

class DepositeContent{
    constructor(text){
        if(text){
            let o = JSON.parse(text);
            this.balance = new BigNumber(o.balance);
            this.expiryHeight = new BigNumber(o.expiryHeight);
        } else {
            this.balance = new BigNumber(0);
            this.expiryHeight = new BigNumber(0);
        }
    };
    toString(){
        return JSON.stringify(this)
    };
};

class BankVaultContract{
    constructor(){
        LocalContractStorage.defineMapProperty(this, 'bankVault', {
            parse(text) {
              return new DepositeContent(text);
            },
            stringify(o) {
              return o.toString();
            }
        })
    }

    init(){
        //TODO
    }

    save(height) {
        let from = Blockchain.transaction.from;
        let value = Blockchain.transaction.value;
        let bk_height = new BigNumber(Blockchain.block.height);

        let orig_deposit = this.bankVault.get(from);
        if (orig_deposit) {
          value = value.plus(orig_deposit.balance);
        }

        let deposit = new DepositeContent();
        deposit.balance = value;
        deposit.expiryHeight = bk_height.plus(height);

        this.bankVault.put(from, deposit);
    }
}

export {BankVaultContract}
yupnano commented 6 years ago

应该是合约代码有bug

Goya- commented 6 years ago

@yupnano 有什么方便的合约调试工具吗?

yupnano commented 6 years ago

目前还没有工具化的产品,不过neb.js有类似的功能,有兴趣可以看一下:https://github.com/nebulasio/neb.js/tree/feature/nvm