@neuraiproject/neurai-assets 1.7.1 → 1.8.0

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
@@ -37,6 +37,15 @@ Complete asset management library for Neurai blockchain. Supports creation, reis
37
37
  > (full name, owner `!` included: 31 mainnet / 121 testnet-regtest, validated
38
38
  > against a regtest node); peer `neurai-rpc ^0.6.0`.
39
39
 
40
+ ## 1.8.0: Reset testnet marker policy
41
+
42
+ Testnet builders require the node's `getblockchaininfo.asset_marker` value
43
+ (or an explicit override) and reject a missing marker instead of silently
44
+ using `rvn` after the activation of `xna`. This release requires
45
+ `@neuraiproject/neurai-rpc` `^0.7.0` as a peer and
46
+ `@neuraiproject/neurai-create-transaction` `^0.9.2`. Development tests use
47
+ `@neuraiproject/neurai-sign-transaction` `^3.0.3`.
48
+
40
49
  ## Features
41
50
 
42
51
  - ✅ **Non-custodial**: Library builds unsigned transactions, your wallet signs them
@@ -786,7 +795,7 @@ The library automatically validates that the owner token is returned in each ope
786
795
 
787
796
  Asset payloads open with a 3-byte marker that NIP-040 migrates from the
788
797
  Ravencoin-inherited `rvn` to `xna` at an activation height per network
789
- (testnet: 303000, already crossed; regtest: 1; mainnet: not scheduled yet).
798
+ (reset testnet: 10; regtest: 1; mainnet: not scheduled yet).
790
799
 
791
800
  - Transactions built **through the node** (`createrawtransaction`) need
792
801
  nothing: the node stamps the marker itself.
@@ -797,10 +806,12 @@ Ravencoin-inherited `rvn` to `xna` at an activation height per network
797
806
  `'xna'` — offline builds or tests);
798
807
  2. otherwise the node's `getblockchaininfo.asset_marker` (node commit
799
808
  `347362b` or later);
800
- 3. `'rvn'` when the node predates that field — which matches what such a
801
- node enforces.
809
+ 3. On mainnet, `'rvn'` when the node predates that field. Testnet requires
810
+ the field or an explicit `assetMarker` override.
802
811
 
803
- No height tables and no network inference: the node (or you) decides.
812
+ The node reports the marker for the next block. On the reset testnet it reports
813
+ `rvn` with tip 8 and `xna` with tip 9. The builder does not infer a marker
814
+ from the network name.
804
815
 
805
816
  ### Failure policy (`assetMarkerPolicy`, 1.5.0+)
806
817
 
@@ -811,16 +822,16 @@ not answer at all is a different situation, and `assetMarkerPolicy` decides it:
811
822
  const assets = new NeuraiAssets(rpc, {
812
823
  network: 'xna-test',
813
824
  addresses: [...],
814
- assetMarkerPolicy: 'strict' // default: 'legacy-fallback'
825
+ assetMarkerPolicy: 'strict' // default on testnet
815
826
  });
816
827
  ```
817
828
 
818
829
  | Policy | `getblockchaininfo` fails | Field absent/null | Unknown value |
819
830
  | --- | --- | --- | --- |
820
- | `legacy-fallback` (default in 1.x) | resolves `'rvn'` | resolves `'rvn'` | throws |
821
- | `strict` | **throws** | resolves `'rvn'` | throws |
831
+ | `legacy-fallback` (mainnet default) | resolves `'rvn'` | mainnet: `'rvn'`; testnet: throws | throws |
832
+ | `strict` (testnet default) | **throws** | mainnet: `'rvn'`; testnet: throws | throws |
822
833
 
823
- Use `strict` in a connected wallet on a post-NIP-040 chain: guessing `'rvn'`
834
+ The reset testnet defaults to `strict`. Guessing `'rvn'`
824
835
  there builds a transaction the node rejects with
825
836
  `bad-txns-legacy-asset-marker-after-nip040`, so "the node did not answer" must
826
837
  not silently become "the node said rvn". The rejection propagates out of the
@@ -893,8 +904,8 @@ Address types (every family is valid with the network label of its chain):
893
904
 
894
905
  The old `nq1p...` / `tnq1p...` encoding of generic AuthScript v1 is rejected, like
895
906
  in the node (same scriptPubKey: regenerate it as `nc1p...` / `tnc1p...`). The node
896
- only protects a witness family where it is active: today v1 on testnet and regtest,
897
- v2 / v3 only on regtest.
907
+ only protects a witness family where it is active. All three families activate
908
+ on the reset testnet from block 10 and on regtest from block 1.
898
909
 
899
910
  The library accepts these network names. A label only selects the chain: the
900
911
  address type always comes from the address itself.
@@ -1132,6 +1143,19 @@ remain available as `totalSats` / raw methods; never use a rounded display value
1132
1143
  as a new transaction input.
1133
1144
 
1134
1145
 
1146
+ ## 1.7.2: CommonJS type declarations
1147
+
1148
+ `require()` loads `dist/index.cjs`, but the package only published the ESM
1149
+ declarations (`index.d.ts`), so a CommonJS file compiled with
1150
+ `moduleResolution: "node16"` got `TS1471` and no types. The `require`
1151
+ condition now has its own declarations, `dist/index.d.cts`, written by the
1152
+ build from `index.d.ts` (both entry points export the same values, with
1153
+ `default === NeuraiAssets`). No runtime or API change. `npm run test:types`
1154
+ also compiles ESM, CommonJS and browser consumers against the declarations
1155
+ (NodeNext, Node16, Bundler; `skipLibCheck: false`), and `npm run
1156
+ test:package` checks the packed tarball in a clean project, with TypeScript
1157
+ 4.7 too.
1158
+
1135
1159
  ## 1.7.1: type declarations
1136
1160
 
1137
1161
  `index.d.ts` exported `AssetQueries` twice (`export class AssetQueries` plus
@@ -1931,8 +1931,8 @@ var NeuraiAssetsBundle = (function (exports) {
1931
1931
  * Every transfer / new / owner / reissue payload opens with a 3-byte marker
1932
1932
  * followed by the type byte. The marker is consensus: blocks below the NIP-040
1933
1933
  * activation height of a network only accept `rvn` on new asset outputs and
1934
- * blocks at or above it only accept `xna` (mainnet: not scheduled; testnet:
1935
- * 303000; regtest: 1). This library does NOT know chain state and never
1934
+ * blocks at or above it only accept `xna` (mainnet: not scheduled; reset testnet:
1935
+ * 10; regtest: 1). This library does NOT know chain state and never
1936
1936
  * infers the marker from a network or an address: the caller passes the
1937
1937
  * value reported by the node for the next block
1938
1938
  * (`getblockchaininfo.asset_marker`, node commit 347362b) — or, when building
@@ -8859,14 +8859,13 @@ var NeuraiAssetsBundle = (function (exports) {
8859
8859
  * 1. `params.assetMarker` (explicit caller override — offline builds,
8860
8860
  * tests, or a node this library should not ask);
8861
8861
  * 2. `getblockchaininfo.asset_marker` from the connected node;
8862
- * 3. `'rvn'` when the node predates the field (a node without it enforces
8863
- * the legacy marker, so that is the right answer, not a guess).
8862
+ * 3. On mainnet, `'rvn'` when the field is absent. Testnet requires
8863
+ * the field or an explicit override.
8864
8864
  *
8865
8865
  * An RPC *failure* is a different case, and `params.assetMarkerPolicy`
8866
8866
  * decides it:
8867
- * - `'legacy-fallback'` (default in 1.x) resolves `'rvn'`, preserving the
8868
- * 1.4.x behaviour;
8869
- * - `'strict'` propagates the failure. On a post-NIP-040 chain a build
8867
+ * - `'legacy-fallback'` (mainnet default) resolves `'rvn'`;
8868
+ * - `'strict'` (testnet default) propagates the failure. On a post-NIP-040 chain a build
8870
8869
  * that guessed `'rvn'` produces a transaction the node rejects with
8871
8870
  * `bad-txns-legacy-asset-marker-after-nip040`, so an online wallet
8872
8871
  * should not treat "the node did not answer" as "the node said rvn".
@@ -8894,7 +8893,7 @@ var NeuraiAssetsBundle = (function (exports) {
8894
8893
  assetMarkerPolicy() {
8895
8894
  const policy = this.params.assetMarkerPolicy;
8896
8895
  if (policy === undefined || policy === null) {
8897
- return 'legacy-fallback';
8896
+ return getNetworkConfig(this.network).baseNetwork === 'xna-test' ? 'strict' : 'legacy-fallback';
8898
8897
  }
8899
8898
  if (policy !== 'strict' && policy !== 'legacy-fallback') {
8900
8899
  throw new Error(
@@ -8932,7 +8931,9 @@ var NeuraiAssetsBundle = (function (exports) {
8932
8931
  }
8933
8932
  const marker = info ? info.asset_marker : undefined;
8934
8933
  if (marker === undefined || marker === null) {
8935
- // A valid answer from a node that predates the field: legacy is correct.
8934
+ if (getNetworkConfig(this.network).baseNetwork === 'xna-test') {
8935
+ throw new Error('Testnet node did not report asset_marker; pass params.assetMarker for an offline build');
8936
+ }
8936
8937
  return 'rvn';
8937
8938
  }
8938
8939
  if (marker !== 'rvn' && marker !== 'xna') {
@@ -12632,14 +12633,11 @@ var NeuraiAssetsBundle = (function (exports) {
12632
12633
  * @param {string} config.toAddress - Default receiving address
12633
12634
  * @param {('rvn'|'xna')} [config.assetMarker] - NIP-040 marker for locally
12634
12635
  * built raw transactions. Omit to use the node's
12635
- * getblockchaininfo.asset_marker (falls back to 'rvn' on nodes that do
12636
- * not report it). Per-operation params.assetMarker overrides this.
12636
+ * getblockchaininfo.asset_marker. A missing field fails on testnet and
12637
+ * falls back to 'rvn' on mainnet. Per-operation params.assetMarker overrides this.
12637
12638
  * @param {('strict'|'legacy-fallback')} [config.assetMarkerPolicy] - What to
12638
- * do when getblockchaininfo FAILS. 'legacy-fallback' (default in 1.x)
12639
- * resolves 'rvn'; 'strict' propagates the error instead, because on a
12640
- * post-NIP-040 chain a guessed 'rvn' builds a transaction the node
12641
- * rejects. A node that simply predates the field still resolves 'rvn'
12642
- * under both policies — that is an answer, not a failure.
12639
+ * do when getblockchaininfo fails. Testnet defaults to 'strict'; mainnet
12640
+ * defaults to 'legacy-fallback'. An absent field always fails on testnet.
12643
12641
  */
12644
12642
  constructor(rpc, config = {}) {
12645
12643
  if (!rpc || typeof rpc !== 'function') {