@neuraiproject/neurai-assets 1.6.0 → 1.6.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 +42 -0
- package/dist/NeuraiAssets.global.js +922 -842
- package/dist/NeuraiAssets.global.js.map +1 -1
- package/dist/browser.js +922 -842
- package/dist/browser.js.map +1 -1
- package/dist/index.cjs +922 -842
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +922 -842
- package/dist/index.js.map +1 -1
- package/index.d.ts +56 -7
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -1089,3 +1089,45 @@ The estimator assumes the most common spend layout for every input:
|
|
|
1089
1089
|
- PQ inputs → AuthScript v1 with the **default** `OP_TRUE` `witnessScript` and **no** `functionalArgs`
|
|
1090
1090
|
|
|
1091
1091
|
That covers all standard asset operations. If you build transactions whose PQ inputs use covenant `witnessScript`s, NoAuth (`authType=0x00`) or Legacy AuthScript (`authType=0x02`) witnesses, compute the witness size yourself and add it to the result of `estimateTransactionVbytes` (or use `estimateVirtualSize` from `@neuraiproject/neurai-sign-transaction` after building the raw transaction, which fills dummy witnesses of the worst-case size and returns the exact post-signing vsize).
|
|
1092
|
+
|
|
1093
|
+
### Large amounts and exact result envelopes
|
|
1094
|
+
|
|
1095
|
+
Pass large fractional quantities as decimal strings and RPC raw `satoshis` as
|
|
1096
|
+
bigint or integer strings. Build envelopes retain numeric display fields for
|
|
1097
|
+
safe monetary values; large fractional values are returned as decimal strings
|
|
1098
|
+
instead of rounding or preventing a valid build. Consumers must accept both.
|
|
1099
|
+
Canonical `createTransactionBuild` quantities and changes remain bigint.
|
|
1100
|
+
XNA string outputs are preserved during output ordering. Exact selection totals
|
|
1101
|
+
remain available as `totalSats` / raw methods; never use a rounded display value
|
|
1102
|
+
as a new transaction input.
|
|
1103
|
+
|
|
1104
|
+
|
|
1105
|
+
## Exact amounts and legacy converter migration
|
|
1106
|
+
|
|
1107
|
+
In 1.6.2, insufficient-funds errors preserve `required` and `available` as
|
|
1108
|
+
`number | string`. Large fractional amounts are returned as exact decimal text;
|
|
1109
|
+
consumers must not convert them to `Number` before computing or displaying funds.
|
|
1110
|
+
`BuildInput.satoshis` accepts exact raw integers and `changeAmount` may be text.
|
|
1111
|
+
|
|
1112
|
+
```js
|
|
1113
|
+
import { utils } from '@neuraiproject/neurai-assets';
|
|
1114
|
+
const { assetAmountToRaw, rawToDisplayAmount, formatRawAsDecimal } = utils.AssetAmount;
|
|
1115
|
+
const raw = assetAmountToRaw('100000000.00000001', 8);
|
|
1116
|
+
const compatibleDisplay = rawToDisplayAmount(raw); // '100000000.00000001'
|
|
1117
|
+
const decimalText = formatRawAsDecimal(raw); // Always plain decimal text
|
|
1118
|
+
```
|
|
1119
|
+
|
|
1120
|
+
`utils.AmountConverter` is deprecated but retains its existing behavior in 1.x.
|
|
1121
|
+
It may round even when its result is a safe integer. Its scale is `10^units`;
|
|
1122
|
+
protocol XNA and asset amounts always use `10^8`, with `units` only restricting
|
|
1123
|
+
asset divisibility. For example, legacy `toSatoshis(1.23, 2)` returns `123`, while
|
|
1124
|
+
`assetAmountToRaw('1.23', 2)` returns `123000000n`. Check the unit of stored values
|
|
1125
|
+
before migrating: for a valid legacy integer with units 2, multiplying that exact
|
|
1126
|
+
integer by `1000000n` converts it to protocol raw units. Already rounded digits
|
|
1127
|
+
cannot be recovered. Prefer the original decimal text whenever available.
|
|
1128
|
+
|
|
1129
|
+
Replace protocol decimal-to-raw conversion with `assetAmountToRaw`, and raw-to-display
|
|
1130
|
+
conversion with `rawToDisplayAmount` or `formatRawAsDecimal`. These are not drop-in
|
|
1131
|
+
replacements for legacy formatting or deliberate rounding. Keep user input as
|
|
1132
|
+
text; validate divisibility instead of silently rounding it. A display number can
|
|
1133
|
+
use exponent notation for tiny values, so use `formatRawAsDecimal` for plain text.
|