NEM-sdk: Error? in prepare("mosaicTransferTransaction") result fee is null.
Hi, I am always indebted to NEM-sdk.
I noticed that the result of calling nem.model.transactions.prepare (“mosaicTransferTransaction”) is Fee null.
var transactionEntity = nem.model.transactions.prepare("mosaicTransferTransaction")(common, transferTransaction, mosaicDefinitionMetaDataPair, nem.model.network.data.testnet.id);
// !transactionEntity.fee == null;
Moreover, I think that cause is in the following code of the calculateMosaics function. In the following code, is not it possible to get initialSupply correctly? fees.js#124
let supply = mosaicDefinitionMetaDataPair.supply; //
I can get initialSupply if I change it like this, fee will not be undefine.
let initialSupplyProperties = Helpers.grep(mosaicDefinitionMetaDataPair.mosaicDefinition.properties, function(w) {
return w.name === "initialSupply";
});
let supply = initialSupplyProperties.length === 1 ? (initialSupplyProperties[0].value) : 0;
I will separately send you a pull request, please check. thank, you.
*Also, I am bad at English. I am using Google Translate to write this issue.
About this issue
- Original URL
- State: open
- Created 6 years ago
- Reactions: 5
- Comments: 19 (4 by maintainers)
no it doesnt cost you 1 XEM, in case of mosaic transfers, the
transaction.amount
field is used as a multiplier for the attachments. You only pay the fee + the mosaics attached (in case transaction.amount is not 0)This means if you put 3 there, it would affect the balance 3 times with said attachments.
For noobs it would be nice to fix the example code provided with the one liner:
mosaicDefinitionMetaDataPair[fullMosaicName].supply = neededDefinition[fullMosaicName].properties[1].value;
around this line: https://github.com/QuantumMechanics/NEM-sdk/blob/master/examples/nodejs/mosaicTransfer.js#L57
Until discovering this thread on github, I verified I could set the fee manually and get a successful transaction. However, glad to find a solution on the forums.
@maxp Thanks for giving me a hint! I rewrote the example.
@QuantumMechanics Thank you for giving me a reply! Please let me question as many as 2 points.
Confirm the bug.
Can confirm that this error blocks mosaic transfers and that the proposed fix fixes the issue. Thanks, @scrpgil !