您的代码非常好。通过 npm 分发的最新 erdjs 版本中只有一个小错误。
在TransactionOnNetwork
类中,包中的代码当前如下所示:
static fromHttpResponse(response) {
let transactionOnNetwork = new TransactionOnNetwork();
transactionOnNetwork.type = new TransactionOnNetworkType(response.type || "");
transactionOnNetwork.nonce = new nonce_1.Nonce(response.nonce || 0);
transactionOnNetwork.round = response.round;
transactionOnNetwork.epoch = response.epoch || 0;
transactionOnNetwork.value = balance_1.Balance.fromString(response.value);
transactionOnNetwork.sender = address_1.Address.fromBech32(response.sender);
transactionOnNetwork.receiver = address_1.Address.fromBech32(response.receiver);
transactionOnNetwork.gasPrice = new networkParams_1.GasPrice(response.gasPrice);
transactionOnNetwork.gasLimit = new networkParams_1.GasLimit(response.gasLimit);
transactionOnNetwork.data = transactionPayload_1.TransactionPayload.fromEncoded(response.data);
transactionOnNetwork.status = new transaction_1.TransactionStatus(response.status);
transactionOnNetwork.hyperblockNonce = new nonce_1.Nonce(response.hyperblockNonce || 0);
transactionOnNetwork.hyperblockHash = new hash_1.Hash(response.hyperblockHash);
transactionOnNetwork.receipt = Receipt.fromHttpResponse(response.receipt || {});
transactionOnNetwork.results = smartContractResults_1.SmartContractResults.fromHttpResponse(response.results || []);
return transactionOnNetwork;
}
如您所见,它尝试从results
响应中的字段解析 SmartContract 结果。
但是,改为解析该smartContractResults
字段是正确的。
这也可以在官方github中看到,该问题似乎已经修复。
因此,现在您可以手动修补要使用的transactionOnNetwork.js
文件,也可以降级到较低版本,直到此问题在最新的 npm 包中得到解决。node_modules
smartContractResults