@neuraiproject/neurai-assets 1.2.1 → 1.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -4377,23 +4377,27 @@ function requireBaseAssetTransactionBuilder () {
4377
4377
  }
4378
4378
 
4379
4379
  /**
4380
- * Convert amount to satoshis
4381
- * @param {number} amount - Amount in asset units
4382
- * @param {number} units - Decimal places
4383
- * @returns {number} Amount in satoshis
4380
+ * Convert asset amount to protocol raw units.
4381
+ * Asset raw quantities in transaction payloads are always encoded with
4382
+ * 8 decimal places, regardless of the asset's displayed `units`.
4383
+ *
4384
+ * @param {number} amount - User-facing asset amount
4385
+ * @param {number} units - Asset decimal places (kept for API compatibility)
4386
+ * @returns {number} Amount in protocol raw units
4384
4387
  */
4385
4388
  toSatoshis(amount, units) {
4386
- return Math.round(amount * Math.pow(10, units));
4389
+ return Math.round(amount * 100000000);
4387
4390
  }
4388
4391
 
4389
4392
  /**
4390
- * Convert satoshis to amount
4391
- * @param {number} satoshis - Amount in satoshis
4392
- * @param {number} units - Decimal places
4393
+ * Convert protocol raw units back to a user-facing asset amount.
4394
+ *
4395
+ * @param {number} satoshis - Amount in protocol raw units
4396
+ * @param {number} units - Asset decimal places (kept for API compatibility)
4393
4397
  * @returns {number} Amount in asset units
4394
4398
  */
4395
4399
  fromSatoshis(satoshis, units) {
4396
- return satoshis / Math.pow(10, units);
4400
+ return satoshis / 100000000;
4397
4401
  }
4398
4402
 
4399
4403
  /**
@@ -5976,11 +5980,13 @@ function requireIssueQualifierBuilder () {
5976
5980
  // Last: Issue qualifier operation
5977
5981
  const issueQualifierOutput = OutputFormatter.formatIssueQualifierOutput({
5978
5982
  asset_name: assetName,
5979
- asset_quantity: quantity,
5983
+ asset_quantity: this.toSatoshis(quantity, 0),
5980
5984
  has_ipfs: hasIpfs,
5981
5985
  ipfs_hash: ipfsHash,
5982
5986
  root_change_address: isSub ? changeAddress : undefined,
5983
- change_quantity: isSub ? parentQualifierQuantity : undefined
5987
+ change_quantity: isSub && parentQualifierQuantity !== null
5988
+ ? this.toSatoshis(parentQualifierQuantity, 0)
5989
+ : undefined
5984
5990
  });
5985
5991
 
5986
5992
  outputs.push({ [toAddress]: issueQualifierOutput });
@@ -6742,12 +6748,12 @@ function requireTagAddressBuilder () {
6742
6748
  ? OutputFormatter.formatUntagAddressesOutput({
6743
6749
  qualifier: qualifierName,
6744
6750
  addresses: targetAddresses,
6745
- change_quantity: qualifierQuantity
6751
+ change_quantity: this.toSatoshis(qualifierQuantity, 0)
6746
6752
  })
6747
6753
  : OutputFormatter.formatTagAddressesOutput({
6748
6754
  qualifier: qualifierName,
6749
6755
  addresses: targetAddresses,
6750
- change_quantity: qualifierQuantity
6756
+ change_quantity: this.toSatoshis(qualifierQuantity, 0)
6751
6757
  });
6752
6758
 
6753
6759
  outputs.push({ [changeAddress]: operationOutput });