mainnet-js 2.7.22 → 2.7.24

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.
Files changed (42) hide show
  1. package/dist/index.html +1 -1
  2. package/dist/{mainnet-2.7.22.js → mainnet-2.7.24.js} +4 -24
  3. package/dist/module/index.d.ts +0 -2
  4. package/dist/module/index.d.ts.map +1 -1
  5. package/dist/module/index.js +0 -2
  6. package/dist/module/index.js.map +1 -1
  7. package/dist/module/network/index.d.ts +1 -1
  8. package/dist/module/network/index.d.ts.map +1 -1
  9. package/dist/module/network/index.js +1 -1
  10. package/dist/module/network/index.js.map +1 -1
  11. package/dist/module/util/index.d.ts +0 -1
  12. package/dist/module/util/index.d.ts.map +1 -1
  13. package/dist/module/util/index.js +0 -1
  14. package/dist/module/util/index.js.map +1 -1
  15. package/dist/module/wallet/Base.d.ts +1 -2
  16. package/dist/module/wallet/Base.d.ts.map +1 -1
  17. package/dist/module/wallet/Base.js +0 -4
  18. package/dist/module/wallet/Base.js.map +1 -1
  19. package/dist/tsconfig.tsbuildinfo +1 -1
  20. package/package.json +1 -1
  21. package/src/index.ts +0 -2
  22. package/src/network/index.ts +1 -0
  23. package/src/util/index.ts +0 -1
  24. package/src/wallet/Base.ts +0 -9
  25. package/dist/module/util/walletConnect.d.ts +0 -22
  26. package/dist/module/util/walletConnect.d.ts.map +0 -1
  27. package/dist/module/util/walletConnect.js +0 -57
  28. package/dist/module/util/walletConnect.js.map +0 -1
  29. package/dist/module/wallet/Bcmr.d.ts +0 -108
  30. package/dist/module/wallet/Bcmr.d.ts.map +0 -1
  31. package/dist/module/wallet/Bcmr.js +0 -413
  32. package/dist/module/wallet/Bcmr.js.map +0 -1
  33. package/dist/module/wallet/bcmr-v2.schema.d.ts +0 -833
  34. package/dist/module/wallet/bcmr-v2.schema.d.ts.map +0 -1
  35. package/dist/module/wallet/bcmr-v2.schema.js +0 -2
  36. package/dist/module/wallet/bcmr-v2.schema.js.map +0 -1
  37. package/src/util/walletConnect.test.ts +0 -115
  38. package/src/util/walletConnect.ts +0 -156
  39. package/src/wallet/Bcmr.test.headless.js +0 -467
  40. package/src/wallet/Bcmr.test.ts +0 -979
  41. package/src/wallet/Bcmr.ts +0 -556
  42. package/src/wallet/bcmr-v2.schema.ts +0 -893
@@ -1,108 +0,0 @@
1
- import { Transaction } from "@bitauth/libauth";
2
- import { Network, TxI } from "../interface.js";
3
- import { ElectrumRawTransaction } from "../network/interface.js";
4
- import { IdentitySnapshot, Registry } from "./bcmr-v2.schema.js";
5
- export interface AuthChainElement {
6
- txHash: string;
7
- contentHash: string;
8
- uris: string[];
9
- httpsUrl: string;
10
- }
11
- export type AuthChain = AuthChainElement[];
12
- export declare class BCMR {
13
- static metadataRegistries: Registry[];
14
- static getRegistries(): Registry[];
15
- static resetRegistries(): void;
16
- /**
17
- * fetchMetadataRegistry Fetch the BCMR registry JSON file from a remote URI, optionally verifying its content hash
18
- *
19
- * @param {string} uri URI of the registry to fetch from
20
- * @param {string?} contentHash SHA256 hash of the resource the `uri` parameter points at.
21
- * If specified, calculates the hash of the data fetched from `uri` and matches it with provided one.
22
- * Yields an error upon mismatch.
23
- *
24
- * @returns {Registry} resolved registry
25
- */
26
- static fetchMetadataRegistry(uri: string, contentHash?: string): Promise<Registry>;
27
- /**
28
- * addMetadataRegistry Add the metadata registry to the list of tracked registries
29
- *
30
- * @param {Registry} registry Registry object per schema specification, see https://raw.githubusercontent.com/bitjson/chip-bcmr/master/bcmr-v1.schema.json
31
- *
32
- */
33
- static addMetadataRegistry(registry: Registry): void;
34
- /**
35
- * addMetadataRegistryFromUri Add the metadata registry by fetching a JSON file from a remote URI, optionally verifying its content hash
36
- *
37
- * @param {string} uri URI of the registry to fetch from
38
- * @param {string?} contentHash SHA256 hash of the resource the `uri` parameter points at.
39
- * If specified, calculates the hash of the data fetched from `uri` and matches it with provided one.
40
- * Yields an error upon mismatch.
41
- *
42
- */
43
- static addMetadataRegistryFromUri(uri: string, contentHash?: string): Promise<void>;
44
- static makeAuthChainElement(rawTx: ElectrumRawTransaction | Transaction, hash: string): AuthChainElement;
45
- /**
46
- * buildAuthChain Build an authchain - Zeroth-Descendant Transaction Chain, refer to https://github.com/bitjson/chip-bcmr#zeroth-descendant-transaction-chains
47
- * The authchain in this implementation is specific to resolve to a valid metadata registry
48
- *
49
- * @param {string} options.transactionHash (required) transaction hash from which to build the auth chain
50
- * @param {Network?} options.network (default=mainnet) network to query the data from
51
- * @param {boolean?} options.resolveBase (default=false) boolean flag to indicate that autchain building should resolve and verify elements back to base or be stopped at this exact chain element
52
- * @param {boolean?} options.followToHead (default=true) boolean flag to indicate that autchain building should progress to head or be stopped at this exact chain element
53
- * @param {ElectrumRawTransaction?} options.rawTx cached raw transaction obtained previously, spares a Fulcrum call
54
- * @param {TxI[]?} options.historyCache cached address history to be reused if authchain building proceeds with the same address, spares a flurry of Fulcrum calls
55
- *
56
- * @returns {AuthChain} returns the resolved authchain
57
- */
58
- static buildAuthChain(options: {
59
- transactionHash: string;
60
- network?: Network;
61
- resolveBase?: boolean;
62
- followToHead?: boolean;
63
- rawTx?: ElectrumRawTransaction;
64
- historyCache?: TxI[];
65
- }): Promise<AuthChain>;
66
- /**
67
- * fetchAuthChainFromChaingraph Fetch the authchain information from a trusted external indexer
68
- * The authchain in this implementation is specific to resolve to a valid metadata registry
69
- *
70
- * @param {string} options.chaingraphUrl (required) URL of a chaingraph indexer instance to fetch info from
71
- * @param {string} options.transactionHash (required) transaction hash from which to build the auth chain
72
- * @param {string?} options.network (default=undefined) network to query the data from, specific to the queried instance,
73
- * can be 'mainnet', 'chipnet', or anything else.
74
- * if left undefined all chaingraph transactions will be looked at, disregarding the chain
75
- *
76
- * @returns {AuthChain} returns the resolved authchain
77
- */
78
- static fetchAuthChainFromChaingraph(options: {
79
- chaingraphUrl: string;
80
- transactionHash: string;
81
- network?: string;
82
- }): Promise<AuthChain>;
83
- /**
84
- * addMetadataRegistryAuthChain Add BCMR metadata registry by resolving an authchain
85
- *
86
- * @param {string} options.transactionHash (required) transaction hash from which to build the auth chain
87
- * @param {Network?} options.network (default=mainnet) network to query the data from
88
- * @param {boolean?} options.followToHead (default=true) boolean flag to indicate that autchain building should progress to head (most recent registry version) or be stopped at this exact chain element
89
- * @param {ElectrumRawTransaction?} options.rawTx cached raw transaction obtained previously, spares a Fulcrum call
90
- *
91
- * @returns {AuthChain} returns the resolved authchain
92
- */
93
- static addMetadataRegistryAuthChain(options: {
94
- transactionHash: string;
95
- network?: Network;
96
- followToHead?: boolean;
97
- rawTx?: ElectrumRawTransaction;
98
- }): Promise<AuthChain>;
99
- /**
100
- * getTokenInfo Return the token info (or the identity snapshot as per spec)
101
- *
102
- * @param {string} tokenId token id to look up
103
- *
104
- * @returns {IdentitySnapshot?} return the info for the token found, otherwise undefined
105
- */
106
- static getTokenInfo(tokenId: string): IdentitySnapshot | undefined;
107
- }
108
- //# sourceMappingURL=Bcmr.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"Bcmr.d.ts","sourceRoot":"","sources":["../../../src/wallet/Bcmr.ts"],"names":[],"mappings":"AAAA,OAAO,EAML,WAAW,EAEZ,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,iBAAiB,CAAC;AAE/C,OAAO,EAAE,sBAAsB,EAAE,MAAM,yBAAyB,CAAC;AACjE,OAAO,EAAE,gBAAgB,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAKjE,MAAM,WAAW,gBAAgB;IAC/B,MAAM,EAAE,MAAM,CAAC;IACf,WAAW,EAAE,MAAM,CAAC;IACpB,IAAI,EAAE,MAAM,EAAE,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,MAAM,SAAS,GAAG,gBAAgB,EAAE,CAAC;AAG3C,qBAAa,IAAI;IAEf,OAAc,kBAAkB,EAAE,QAAQ,EAAE,CAAM;WAEpC,aAAa,IAAI,QAAQ,EAAE;WAI3B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AAG,SAAS;CAgB1E"}
@@ -1,413 +0,0 @@
1
- import { binToHex, binToUtf8, decodeTransaction, hexToBin, sha256, utf8ToBin, } from "@bitauth/libauth";
2
- import { Network } from "../interface.js";
3
- import { initProvider } from "../network/Connection.js";
4
- import { OpReturnData } from "./model.js";
5
- import { Config } from "../config.js";
6
- // Implementation of CHIP-BCMR v2.0.0-draft, refer to https://github.com/bitjson/chip-bcmr
7
- export class BCMR {
8
- // List of tracked registries
9
- static { this.metadataRegistries = []; }
10
- static getRegistries() {
11
- return this.metadataRegistries;
12
- }
13
- static resetRegistries() {
14
- this.metadataRegistries = [];
15
- }
16
- /**
17
- * fetchMetadataRegistry Fetch the BCMR registry JSON file from a remote URI, optionally verifying its content hash
18
- *
19
- * @param {string} uri URI of the registry to fetch from
20
- * @param {string?} contentHash SHA256 hash of the resource the `uri` parameter points at.
21
- * If specified, calculates the hash of the data fetched from `uri` and matches it with provided one.
22
- * Yields an error upon mismatch.
23
- *
24
- * @returns {Registry} resolved registry
25
- */
26
- static async fetchMetadataRegistry(uri, contentHash) {
27
- if (uri.indexOf("https://") < 0) {
28
- uri = `https://${uri}`;
29
- }
30
- // content hashes HTTPS Publication Outputs per spec
31
- if (contentHash) {
32
- // request as text and verify hash
33
- const response = await fetch(uri);
34
- const data = await response.text();
35
- const hash = binToHex(sha256.hash(utf8ToBin(data)));
36
- if (contentHash != hash) {
37
- throw new Error(`Content hash mismatch for URI: ${uri}\nreceived: ${hash}\nrequired: ${contentHash}`);
38
- }
39
- return JSON.parse(data);
40
- }
41
- // request as JSON
42
- const response = await fetch(uri);
43
- const data = await response.json();
44
- return data;
45
- }
46
- /**
47
- * addMetadataRegistry Add the metadata registry to the list of tracked registries
48
- *
49
- * @param {Registry} registry Registry object per schema specification, see https://raw.githubusercontent.com/bitjson/chip-bcmr/master/bcmr-v1.schema.json
50
- *
51
- */
52
- static addMetadataRegistry(registry) {
53
- if (this.metadataRegistries.some((val) => JSON.stringify(val) === JSON.stringify(registry))) {
54
- return;
55
- }
56
- this.metadataRegistries.push(registry);
57
- }
58
- /**
59
- * addMetadataRegistryFromUri Add the metadata registry by fetching a JSON file from a remote URI, optionally verifying its content hash
60
- *
61
- * @param {string} uri URI of the registry to fetch from
62
- * @param {string?} contentHash SHA256 hash of the resource the `uri` parameter points at.
63
- * If specified, calculates the hash of the data fetched from `uri` and matches it with provided one.
64
- * Yields an error upon mismatch.
65
- *
66
- */
67
- static async addMetadataRegistryFromUri(uri, contentHash) {
68
- const registry = await this.fetchMetadataRegistry(uri, contentHash);
69
- this.addMetadataRegistry(registry);
70
- }
71
- // helper function to enforce the constraints on the 0th output, decode the BCMR's OP_RETURN data
72
- // returns resolved AuthChainElement
73
- static makeAuthChainElement(rawTx, hash) {
74
- let opReturns;
75
- let spends0thOutput = false;
76
- if (rawTx.hasOwnProperty("vout")) {
77
- const electrumTransaction = rawTx;
78
- opReturns = electrumTransaction.vout
79
- .filter((val) => val.scriptPubKey.type === "nulldata")
80
- .map((val) => val.scriptPubKey.hex);
81
- spends0thOutput = electrumTransaction.vin.some((val) => val.vout === 0);
82
- }
83
- else {
84
- const libauthTransaction = rawTx;
85
- opReturns = libauthTransaction.outputs
86
- .map((val) => binToHex(val.lockingBytecode))
87
- .filter((val) => val.indexOf("6a") === 0);
88
- spends0thOutput = libauthTransaction.inputs.some((val) => val.outpointIndex === 0);
89
- }
90
- if (!spends0thOutput) {
91
- throw new Error("Invalid authchain transaction (does not spend 0th output of previous transaction)");
92
- }
93
- const bcmrOpReturns = opReturns.filter((val) => val.indexOf("6a0442434d52") === 0 ||
94
- val.indexOf("6a4c0442434d52") === 0 ||
95
- val.indexOf("6a4d040042434d52") === 0 ||
96
- val.indexOf("6a4e0400000042434d52") === 0);
97
- if (bcmrOpReturns.length === 0) {
98
- return {
99
- txHash: hash,
100
- contentHash: "",
101
- uris: [],
102
- httpsUrl: "",
103
- };
104
- }
105
- const opReturnHex = opReturns[0];
106
- const chunks = OpReturnData.parseBinary(hexToBin(opReturnHex));
107
- if (chunks.length < 2) {
108
- throw new Error(`Malformed BCMR output: ${opReturnHex}`);
109
- }
110
- const result = {
111
- txHash: hash,
112
- contentHash: "",
113
- uris: [],
114
- httpsUrl: "",
115
- };
116
- if (chunks.length === 2) {
117
- // IPFS Publication Output
118
- result.contentHash = binToHex(chunks[1]);
119
- const ipfsCid = binToUtf8(chunks[1]);
120
- result.uris = [`ipfs://${ipfsCid}`];
121
- result.httpsUrl = `${Config.DefaultIpfsGateway}${ipfsCid}`;
122
- }
123
- else {
124
- // URI Publication Output
125
- // content hash is in OP_SHA256 byte order per spec
126
- result.contentHash = binToHex(chunks[1].slice());
127
- const uris = chunks.slice(2);
128
- for (const uri of uris) {
129
- const uriString = binToUtf8(uri);
130
- result.uris.push(uriString);
131
- if (result.httpsUrl) {
132
- continue;
133
- }
134
- if (uriString.indexOf("ipfs://") === 0) {
135
- const ipfsCid = uriString.replace("ipfs://", "");
136
- result.httpsUrl = `${Config.DefaultIpfsGateway}${ipfsCid}`;
137
- }
138
- else if (uriString.indexOf("https://") === 0) {
139
- result.httpsUrl = uriString;
140
- }
141
- else if (uriString.indexOf("https://") === -1) {
142
- result.httpsUrl = uriString;
143
- // case for domain name specifier, like example.com
144
- if (uriString.indexOf("/") === -1) {
145
- const parts = uriString.toLowerCase().split(".");
146
- if (!(parts?.[0]?.indexOf("baf") === 0 && parts?.[1] === "ipfs")) {
147
- result.httpsUrl = `${result.httpsUrl}/.well-known/bitcoin-cash-metadata-registry.json`;
148
- }
149
- }
150
- result.httpsUrl = `https://${result.httpsUrl}`;
151
- }
152
- else {
153
- throw new Error(`Unsupported uri type: ${uriString}`);
154
- }
155
- }
156
- }
157
- return result;
158
- }
159
- /**
160
- * buildAuthChain Build an authchain - Zeroth-Descendant Transaction Chain, refer to https://github.com/bitjson/chip-bcmr#zeroth-descendant-transaction-chains
161
- * The authchain in this implementation is specific to resolve to a valid metadata registry
162
- *
163
- * @param {string} options.transactionHash (required) transaction hash from which to build the auth chain
164
- * @param {Network?} options.network (default=mainnet) network to query the data from
165
- * @param {boolean?} options.resolveBase (default=false) boolean flag to indicate that autchain building should resolve and verify elements back to base or be stopped at this exact chain element
166
- * @param {boolean?} options.followToHead (default=true) boolean flag to indicate that autchain building should progress to head or be stopped at this exact chain element
167
- * @param {ElectrumRawTransaction?} options.rawTx cached raw transaction obtained previously, spares a Fulcrum call
168
- * @param {TxI[]?} options.historyCache cached address history to be reused if authchain building proceeds with the same address, spares a flurry of Fulcrum calls
169
- *
170
- * @returns {AuthChain} returns the resolved authchain
171
- */
172
- static async buildAuthChain(options) {
173
- if (options.network === undefined) {
174
- options.network = Network.MAINNET;
175
- }
176
- if (options.followToHead === undefined) {
177
- options.followToHead = true;
178
- }
179
- if (options.resolveBase === undefined) {
180
- options.resolveBase = false;
181
- }
182
- const provider = (await initProvider(options.network));
183
- if (options.rawTx === undefined) {
184
- options.rawTx = await provider.getRawTransactionObject(options.transactionHash);
185
- }
186
- // figure out the autchain by moving towards authhead
187
- const getAuthChainChild = async () => {
188
- const history = options.historyCache ||
189
- (await provider.getHistory(options.rawTx.vout[0].scriptPubKey.addresses[0]));
190
- const thisTx = history.find((val) => val.tx_hash === options.transactionHash);
191
- let filteredHistory = history.filter((val) => val.height > 0
192
- ? val.height >= thisTx.height || val.height <= 0
193
- : val.height <= 0 && val.tx_hash !== thisTx.tx_hash);
194
- for (const historyTx of filteredHistory) {
195
- const historyRawTx = await provider.getRawTransactionObject(historyTx.tx_hash);
196
- const authChainVin = historyRawTx.vin.find((val) => val.txid === options.transactionHash && val.vout === 0);
197
- // if we've found continuation of authchain, we shall recurse into it
198
- if (authChainVin) {
199
- // reuse queried address history if the next element in chain is the same address
200
- const historyCache = options.rawTx.vout[0].scriptPubKey.addresses[0] ===
201
- historyRawTx.vout[0].scriptPubKey.addresses[0]
202
- ? filteredHistory
203
- : undefined;
204
- // combine the authchain element with the rest obtained
205
- return { rawTx: historyRawTx, historyCache };
206
- }
207
- }
208
- return undefined;
209
- };
210
- // make authchain element and combine with the rest obtained
211
- let element;
212
- try {
213
- element = BCMR.makeAuthChainElement(options.rawTx, options.rawTx.hash);
214
- }
215
- catch (error) {
216
- // special case for cashtoken authchain lookup by categoryId - allow to fail first lookup and inspect the genesis transaction
217
- // follow authchain to head and look for BCMR outputs
218
- const child = await getAuthChainChild();
219
- if (child) {
220
- return await BCMR.buildAuthChain({
221
- ...options,
222
- transactionHash: child.rawTx.hash,
223
- rawTx: child.rawTx,
224
- historyCache: child.historyCache,
225
- });
226
- }
227
- else {
228
- throw error;
229
- }
230
- }
231
- let chainBase = [];
232
- if (options.resolveBase) {
233
- // check for accelerated path if "authchain" extension is in registry
234
- const registry = await this.fetchMetadataRegistry(element.httpsUrl, element.contentHash);
235
- if (registry.extensions &&
236
- registry.extensions["authchain"] &&
237
- Object.keys(registry.extensions["authchain"]).length) {
238
- const chainTxArray = Object.values(registry.extensions["authchain"]);
239
- chainBase = chainTxArray
240
- .map((tx) => {
241
- const transactionBin = hexToBin(tx);
242
- const decoded = decodeTransaction(transactionBin);
243
- if (typeof decoded === "string") {
244
- throw new Error(`Error decoding transaction ${JSON.stringify(tx)}, ${decoded}`);
245
- }
246
- const hash = binToHex(sha256.hash(sha256.hash(transactionBin)).reverse());
247
- return { decoded, hash };
248
- })
249
- .map(({ decoded, hash }) => BCMR.makeAuthChainElement(decoded, hash));
250
- }
251
- else {
252
- // simply go back in history towards authhead
253
- let stop = false;
254
- let tx = { ...options.rawTx };
255
- let maxElements = 10;
256
- while (stop == false || maxElements === 0) {
257
- const vin = tx.vin.find((val) => val.vout === 0);
258
- tx = await provider.getRawTransactionObject(vin.txid);
259
- try {
260
- const pastElement = BCMR.makeAuthChainElement(tx, tx.hash);
261
- chainBase.unshift(pastElement);
262
- maxElements--;
263
- }
264
- catch {
265
- stop = true;
266
- }
267
- }
268
- }
269
- }
270
- // if we follow to head, we need to locate the next transaction spending our 0th output
271
- // and repeat the building process recursively
272
- if (options.followToHead) {
273
- const child = await getAuthChainChild();
274
- if (child) {
275
- const chainHead = await BCMR.buildAuthChain({
276
- transactionHash: child.rawTx.hash,
277
- network: options.network,
278
- rawTx: child.rawTx,
279
- historyCache: child.historyCache,
280
- followToHead: options.followToHead,
281
- resolveBase: false,
282
- });
283
- // combine the authchain element with the rest obtained
284
- return [...chainBase, element, ...chainHead].filter((val) => val.httpsUrl.length);
285
- }
286
- }
287
- // return the last chain element (or the only found in an edge case)
288
- return [...chainBase, element].filter((val) => val.httpsUrl.length);
289
- }
290
- /**
291
- * fetchAuthChainFromChaingraph Fetch the authchain information from a trusted external indexer
292
- * The authchain in this implementation is specific to resolve to a valid metadata registry
293
- *
294
- * @param {string} options.chaingraphUrl (required) URL of a chaingraph indexer instance to fetch info from
295
- * @param {string} options.transactionHash (required) transaction hash from which to build the auth chain
296
- * @param {string?} options.network (default=undefined) network to query the data from, specific to the queried instance,
297
- * can be 'mainnet', 'chipnet', or anything else.
298
- * if left undefined all chaingraph transactions will be looked at, disregarding the chain
299
- *
300
- * @returns {AuthChain} returns the resolved authchain
301
- */
302
- static async fetchAuthChainFromChaingraph(options) {
303
- if (!options.chaingraphUrl) {
304
- throw new Error("Provide `chaingraphUrl` param.");
305
- }
306
- const response = await fetch(options.chaingraphUrl, {
307
- method: "POST",
308
- headers: {
309
- Accept: "*/*",
310
- "Content-Type": "application/json",
311
- },
312
- body: JSON.stringify({
313
- operationName: null,
314
- variables: {},
315
- query: `
316
- {
317
- transaction(
318
- where: {
319
- hash:{_eq:"\\\\x${options.transactionHash}"}
320
- }
321
- ) {
322
- hash
323
- authchains {
324
- authchain_length
325
- migrations(
326
- where: {
327
- transaction: {
328
- outputs: { locking_bytecode_pattern: { _like: "6a04%" } }
329
- }
330
- }
331
- ) {
332
- transaction {
333
- hash
334
- inputs(where:{ outpoint_index: { _eq:"0" } }){
335
- outpoint_index
336
- }
337
- outputs(where: { locking_bytecode_pattern: { _like: "6a04%" } }) {
338
- output_index
339
- locking_bytecode
340
- }
341
- }
342
- }
343
- }
344
- }
345
- }`,
346
- }),
347
- });
348
- const responseData = await response.json();
349
- const result = [];
350
- const migrations = responseData.data.transaction[0]?.authchains[0].migrations;
351
- if (!migrations) {
352
- return result;
353
- }
354
- for (const migration of migrations) {
355
- const transaction = migration.transaction[0];
356
- if (!transaction) {
357
- continue;
358
- }
359
- transaction.inputs.forEach((input) => (input.outpointIndex = Number(input.outpoint_index)));
360
- transaction.outputs.forEach((output) => {
361
- output.outputIndex = Number(output.output_index);
362
- output.lockingBytecode = hexToBin(output.locking_bytecode.replace("\\x", ""));
363
- });
364
- const txHash = transaction.hash.replace("\\x", "");
365
- result.push(BCMR.makeAuthChainElement(transaction, txHash));
366
- }
367
- return result.filter((element) => element.contentHash.length && element.httpsUrl.length);
368
- }
369
- /**
370
- * addMetadataRegistryAuthChain Add BCMR metadata registry by resolving an authchain
371
- *
372
- * @param {string} options.transactionHash (required) transaction hash from which to build the auth chain
373
- * @param {Network?} options.network (default=mainnet) network to query the data from
374
- * @param {boolean?} options.followToHead (default=true) boolean flag to indicate that autchain building should progress to head (most recent registry version) or be stopped at this exact chain element
375
- * @param {ElectrumRawTransaction?} options.rawTx cached raw transaction obtained previously, spares a Fulcrum call
376
- *
377
- * @returns {AuthChain} returns the resolved authchain
378
- */
379
- static async addMetadataRegistryAuthChain(options) {
380
- const authChain = await this.buildAuthChain({
381
- ...options,
382
- resolveBase: false,
383
- });
384
- if (!authChain.length) {
385
- throw new Error(`There were no BCMR entries in the resolved authchain ${JSON.stringify(authChain, null, 2)}`);
386
- }
387
- const registry = await this.fetchMetadataRegistry(authChain.reverse()[0].httpsUrl);
388
- this.addMetadataRegistry(registry);
389
- return authChain;
390
- }
391
- /**
392
- * getTokenInfo Return the token info (or the identity snapshot as per spec)
393
- *
394
- * @param {string} tokenId token id to look up
395
- *
396
- * @returns {IdentitySnapshot?} return the info for the token found, otherwise undefined
397
- */
398
- static getTokenInfo(tokenId) {
399
- for (const registry of this.metadataRegistries.slice().reverse()) {
400
- const history = registry.identities?.[tokenId];
401
- if (!history) {
402
- continue;
403
- }
404
- const latestIdentityIndex = Object.keys(history)[0];
405
- if (latestIdentityIndex === undefined) {
406
- continue;
407
- }
408
- return history[latestIdentityIndex];
409
- }
410
- return undefined;
411
- }
412
- }
413
- //# sourceMappingURL=Bcmr.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"Bcmr.js","sourceRoot":"","sources":["../../../src/wallet/Bcmr.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EACR,SAAS,EACT,iBAAiB,EACjB,QAAQ,EACR,MAAM,EAEN,SAAS,GACV,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,OAAO,EAAO,MAAM,iBAAiB,CAAC;AAI/C,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AACxD,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAC1C,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAWtC,0FAA0F;AAC1F,MAAM,OAAO,IAAI;IACf,6BAA6B;aACf,uBAAkB,GAAe,EAAE,CAAC;IAE3C,MAAM,CAAC,aAAa;QACzB,OAAO,IAAI,CAAC,kBAAkB,CAAC;IACjC,CAAC;IAEM,MAAM,CAAC,eAAe;QAC3B,IAAI,CAAC,kBAAkB,GAAG,EAAE,CAAC;IAC/B,CAAC;IAED;;;;;;;;;OASG;IACI,MAAM,CAAC,KAAK,CAAC,qBAAqB,CACvC,GAAW,EACX,WAAoB;QAEpB,IAAI,GAAG,CAAC,OAAO,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE,CAAC;YAChC,GAAG,GAAG,WAAW,GAAG,EAAE,CAAC;QACzB,CAAC;QAED,oDAAoD;QACpD,IAAI,WAAW,EAAE,CAAC;YAChB,kCAAkC;YAClC,MAAM,QAAQ,GAAG,MAAM,KAAK,CAAC,GAAG,CAAC,CAAC;YAClC,MAAM,IAAI,GAAG,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAC;YACnC,MAAM,IAAI,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