@neuraiproject/neurai-assets 1.3.0 → 1.3.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/README.md +45 -6
- package/dist/NeuraiAssets.global.js +42 -11
- package/dist/NeuraiAssets.global.js.map +1 -1
- package/dist/browser.js +42 -11
- package/dist/browser.js.map +1 -1
- package/dist/index.cjs +42 -11
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +42 -11
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/browser.js
CHANGED
|
@@ -4415,6 +4415,11 @@ function requireBaseAssetTransactionBuilder () {
|
|
|
4415
4415
|
this.ownerTokenManager = new OwnerTokenManager(rpc);
|
|
4416
4416
|
this.utxoSelector = new UTXOSelector(rpc);
|
|
4417
4417
|
this.outputOrderer = new OutputOrderer();
|
|
4418
|
+
|
|
4419
|
+
// `estimatesmartfee` is called twice per build (pre-selection guess and
|
|
4420
|
+
// post-selection recompute). The fee rate is stable for the duration of
|
|
4421
|
+
// a single build, so cache the first lookup and reuse it.
|
|
4422
|
+
this._feeRatePromise = null;
|
|
4418
4423
|
}
|
|
4419
4424
|
|
|
4420
4425
|
/**
|
|
@@ -4461,7 +4466,10 @@ function requireBaseAssetTransactionBuilder () {
|
|
|
4461
4466
|
* @returns {Promise<number>} Estimated fee in XNA
|
|
4462
4467
|
*/
|
|
4463
4468
|
async estimateFee(inputs, outputs) {
|
|
4464
|
-
|
|
4469
|
+
if (!this._feeRatePromise) {
|
|
4470
|
+
this._feeRatePromise = this.utxoSelector.getFeeRate();
|
|
4471
|
+
}
|
|
4472
|
+
const feeRate = await this._feeRatePromise;
|
|
4465
4473
|
return this.utxoSelector.estimateFee(inputs, outputs, feeRate);
|
|
4466
4474
|
}
|
|
4467
4475
|
|
|
@@ -4595,24 +4603,47 @@ function requireBaseAssetTransactionBuilder () {
|
|
|
4595
4603
|
}
|
|
4596
4604
|
|
|
4597
4605
|
/**
|
|
4598
|
-
*
|
|
4599
|
-
*
|
|
4600
|
-
*
|
|
4606
|
+
* Build the JSON `asset_quantity` value for a `createrawtransaction`
|
|
4607
|
+
* output (issue / reissue / tag change_quantity / etc.).
|
|
4608
|
+
*
|
|
4609
|
+
* The chain parses this field with `AmountFromValue()` (Bitcoin-style
|
|
4610
|
+
* decimal-XNA → 10^8 sats), then validates that the resulting CAmount
|
|
4611
|
+
* is a multiple of `10^(8 - units)` via `CheckAmountWithUnits`
|
|
4612
|
+
* (assets.cpp). So:
|
|
4613
|
+
*
|
|
4614
|
+
* - The JSON value MUST be the user-facing display amount
|
|
4615
|
+
* (e.g. "1" for one token, "1.5" for one and a half tokens).
|
|
4616
|
+
* - The lib must NOT pre-multiply by 10^8 or 10^units; the daemon
|
|
4617
|
+
* does the 10^8 scaling itself, and any extra factor here lands
|
|
4618
|
+
* duplicated and inflates the minted supply (or trips the
|
|
4619
|
+
* ParseFixedPoint `exponent >= 18` cap → "Invalid amount (3)").
|
|
4620
|
+
*
|
|
4621
|
+
* History: pre-1.2.2 multiplied by 10^units (correct only for units=0
|
|
4622
|
+
* assets, inflated everything else by 10^units). v1.2.2 changed to
|
|
4623
|
+
* always 10^8 (correct only for units=8, inflated everything else by
|
|
4624
|
+
* 10^8 — e.g. reissuing 1 token of a units=0 asset minted 100,000,000).
|
|
4625
|
+
* The right answer is to send the value untouched.
|
|
4626
|
+
*
|
|
4627
|
+
* The `units` parameter is kept for API compatibility but is unused.
|
|
4601
4628
|
*
|
|
4602
4629
|
* @param {number} amount - User-facing asset amount
|
|
4603
|
-
* @param {number} units - Asset decimal places (kept for API
|
|
4604
|
-
* @returns {number}
|
|
4630
|
+
* @param {number} units - Asset decimal places (unused; kept for API)
|
|
4631
|
+
* @returns {number} The user-facing amount, ready for the JSON output
|
|
4605
4632
|
*/
|
|
4606
4633
|
toSatoshis(amount, units) {
|
|
4607
|
-
return
|
|
4634
|
+
return amount;
|
|
4608
4635
|
}
|
|
4609
4636
|
|
|
4610
4637
|
/**
|
|
4611
|
-
* Convert
|
|
4638
|
+
* Convert a chain-side asset balance / UTXO satoshis value back to a
|
|
4639
|
+
* user-facing amount. The chain consistently encodes asset balances
|
|
4640
|
+
* in 10^8 sats (because everything goes through AmountFromValue on
|
|
4641
|
+
* the way in), so the divisor is always 10^8 — independent of the
|
|
4642
|
+
* asset's `units`.
|
|
4612
4643
|
*
|
|
4613
|
-
* @param {number} satoshis -
|
|
4614
|
-
* @param {number} units - Asset decimal places (kept for API
|
|
4615
|
-
* @returns {number}
|
|
4644
|
+
* @param {number} satoshis - Chain value in 10^8 sats
|
|
4645
|
+
* @param {number} units - Asset decimal places (unused; kept for API)
|
|
4646
|
+
* @returns {number} User-facing asset amount
|
|
4616
4647
|
*/
|
|
4617
4648
|
fromSatoshis(satoshis, units) {
|
|
4618
4649
|
return satoshis / 100000000;
|