mainnet-js 1.1.7 → 1.1.8

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.
@@ -10,10 +10,9 @@ import {
10
10
  } from "@bitauth/libauth";
11
11
  import axios from "axios";
12
12
  import { Network, TxI } from "../interface.js";
13
- import { getGlobalProvider } from "../network/default.js";
14
13
  import ElectrumNetworkProvider from "../network/ElectrumNetworkProvider.js";
15
14
  import { ElectrumRawTransaction } from "../network/interface.js";
16
- import { IdentitySnapshot, Registry } from "./bcmr-v1.schema.js";
15
+ import { IdentitySnapshot, Registry } from "./bcmr-v2.schema.js";
17
16
  import { initProvider } from "../network/Connection.js";
18
17
 
19
18
  export interface AuthChainElement {
@@ -324,9 +323,9 @@ export class BCMR {
324
323
  if (
325
324
  registry.extensions &&
326
325
  registry.extensions["authchain"] &&
327
- (registry.extensions["authchain"] as string[]).length
326
+ (Object.keys(registry.extensions["authchain"])).length
328
327
  ) {
329
- const chainTxArray = registry.extensions!["authchain"] as string[];
328
+ const chainTxArray = Object.values(registry.extensions!["authchain"]) as string[];
330
329
 
331
330
  chainBase = chainTxArray
332
331
  .map((tx) => {
@@ -435,28 +434,16 @@ export class BCMR {
435
434
  */
436
435
  public static getTokenInfo(tokenId: string): IdentitySnapshot | undefined {
437
436
  for (const registry of this.metadataRegistries.slice().reverse()) {
438
- // registry identity is an authbase string pointer
439
- if (typeof registry.registryIdentity === "string") {
440
- // enforce spec, ensure identities have this authbase
441
- if (registry.identities?.[registry.registryIdentity]) {
442
- // find the latest identity in history and add it to the list
443
- const latestIdentityInHistory = registry.identities![tokenId]?.[0];
444
- if (latestIdentityInHistory) {
445
- return latestIdentityInHistory;
446
- }
447
- }
448
- } else {
449
- // if the token identity is the registry identity and categories match, return it
450
- if (registry.registryIdentity.token?.category === tokenId) {
451
- return registry.registryIdentity;
452
- }
453
-
454
- // find the latest identity in history and add it to the list
455
- const latestIdentityInHistory = registry.identities![tokenId]?.[0];
456
- if (latestIdentityInHistory) {
457
- return latestIdentityInHistory;
458
- }
437
+ const history = registry.identities?.[tokenId];
438
+ if (!history) {
439
+ continue;
459
440
  }
441
+ const latestIdentityIndex = Object.keys(history)[0];
442
+ if (latestIdentityIndex === undefined) {
443
+ continue;
444
+ }
445
+
446
+ return history[latestIdentityIndex];
460
447
  }
461
448
 
462
449
  return undefined;
package/src/wallet/Wif.ts CHANGED
@@ -107,7 +107,7 @@ import { DERIVATION_PATHS, DUST_UTXO_THRESHOLD } from "../constant.js";
107
107
 
108
108
  import { TransactionHistoryI } from "../history/interface.js";
109
109
  import { getAddressHistory } from "../history/electrumTransformer.js";
110
- import { IdentitySnapshot, Registry } from "./bcmr-v1.schema.js";
110
+ import { IdentitySnapshot, Registry } from "./bcmr-v2.schema.js";
111
111
  import { BCMR } from "./Bcmr.js";
112
112
  import { qrAddress } from "../qr/Qr.js";
113
113
  import { ImageI } from "../qr/interface.js";