Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/380.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript Web3未按预期返回承诺_Javascript_Solidity_Web3 - Fatal编程技术网

Javascript Web3未按预期返回承诺

Javascript Web3未按预期返回承诺,javascript,solidity,web3,Javascript,Solidity,Web3,我试图调用一个web3函数,但它没有像预期的那样返回承诺。然而,这个陷阱似乎起到了很好的作用 合同要求: const requestDebenture = async (debentureAmount) => { createContractInstance(); await mGenerousInstance.methods.requestMDebenture(web3.utils.toWei(debentureAmount.toString(), "ether")).s

我试图调用一个web3函数,但它没有像预期的那样返回承诺。然而,这个陷阱似乎起到了很好的作用

合同要求:

const requestDebenture = async (debentureAmount) => {
    createContractInstance();
    await mGenerousInstance.methods.requestMDebenture(web3.utils.toWei(debentureAmount.toString(), "ether")).send({from: account}, (_, txHash) => {
        if(txHash) {
            notify.hash(txHash);
        }
    }).then().catch();
}
尝试访问调用的函数:

requestDebenture = async (e) => {
        const { debentureAmount } = this.state

        this.setState({debentureError: "", isInDebenture: true});

        await requestDebenture(debentureAmount)
            .then(async () => {
                await fetchAccountBalances().catch();
                await fetchAccountValues().catch();
                await fetchAccountValues().catch();
                this.setState({isInDebenture: false, debentureShowing: false});
            })
            .catch(() => {
                this.setState({isInDebenture: false, debentureError: "An error has occurred while requesting for your funds"});
            });
    }

谢谢。

requestDebenture
用作两个不同功能的名称…!?它们位于两个独立的文件中,几乎不重要。在第二个文件中,您定义了一个函数
requestDebenture
,该函数尝试调用一个函数
requestDebenture
。该名称在该文件中只能表示一种内容,而不能表示两种不同的内容。按原样,此函数似乎将自己称为…?!