@neuraiproject/neurai-assets 1.3.0 → 1.3.1

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 CHANGED
@@ -656,6 +656,8 @@ are `xna` and `xna-test`; `xna-pq` and `xna-pq-test` remain available as compati
656
656
 
657
657
  Asset transactions are usually built with one or two XNA inputs plus, depending on the operation, an owner-token or qualifier UTXO. The library estimates the fee twice per build: a rough pre-estimate to size the initial XNA selection, and a final estimate once the actual UTXOs are known.
658
658
 
659
+ Both estimates share a single `estimatesmartfee` lookup. The fee rate is stable for the lifetime of one build, so it is fetched on the first `estimateFee` call and cached on the builder instance for the second — half as many RPC round trips as before `1.3.1`.
660
+
659
661
  Both estimates use the helpers in [`src/utils/feeSizing.js`](src/utils/feeSizing.js) and distinguish PQ AuthScript inputs/outputs from legacy P2PKH ones. PQ inputs spend ~977 vbytes vs ~148 for legacy — without this distinction, transactions built from PQ addresses fall under the node's `min relay fee` and are rejected with `code -26: min relay fee not met`.
660
662
 
661
663
  You should not need to call these helpers directly; they are wired into every builder. They are documented here so you can audit the fee math or use the same constants if you compose transactions outside the standard builder flow.
@@ -4418,6 +4418,11 @@ var NeuraiAssetsBundle = (function (exports) {
4418
4418
  this.ownerTokenManager = new OwnerTokenManager(rpc);
4419
4419
  this.utxoSelector = new UTXOSelector(rpc);
4420
4420
  this.outputOrderer = new OutputOrderer();
4421
+
4422
+ // `estimatesmartfee` is called twice per build (pre-selection guess and
4423
+ // post-selection recompute). The fee rate is stable for the duration of
4424
+ // a single build, so cache the first lookup and reuse it.
4425
+ this._feeRatePromise = null;
4421
4426
  }
4422
4427
 
4423
4428
  /**
@@ -4464,7 +4469,10 @@ var NeuraiAssetsBundle = (function (exports) {
4464
4469
  * @returns {Promise<number>} Estimated fee in XNA
4465
4470
  */
4466
4471
  async estimateFee(inputs, outputs) {
4467
- const feeRate = await this.utxoSelector.getFeeRate();
4472
+ if (!this._feeRatePromise) {
4473
+ this._feeRatePromise = this.utxoSelector.getFeeRate();
4474
+ }
4475
+ const feeRate = await this._feeRatePromise;
4468
4476
  return this.utxoSelector.estimateFee(inputs, outputs, feeRate);
4469
4477
  }
4470
4478