@mainnet-cash/bcmr 2.7.23

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.
@@ -0,0 +1,832 @@
1
+ /**
2
+ * A mapping of identifiers to URIs associated with an entity. URI identifiers
3
+ * may be widely-standardized or registry-specific. Values must be valid URIs,
4
+ * including a protocol prefix – e.g. `https://` or `ipfs://`., Clients are only
5
+ * required to support `https` and `ipfs` URIs, but any scheme may be specified.
6
+ */
7
+ export type URIs = {
8
+ [identifier: string]: string;
9
+ };
10
+ /**
11
+ * A mapping of extension identifiers to extension definitions. Extensions may
12
+ * be widely standardized or application-specific, and extension definitions
13
+ * must be either:
14
+ *
15
+ * - `string`s,
16
+ * - key-value mappings of `string`s, or
17
+ * - two-dimensional, key-value mappings of `string`s.
18
+ *
19
+ * This limitation encourages safety and wider compatibility across
20
+ * implementations.
21
+ *
22
+ * To encode an array, it is recommended that each value be assigned to a
23
+ * numeric key indicating the item's index (beginning at `0`).
24
+ * Numerically-indexed objects are often a more useful and resilient
25
+ * data-transfer format than simple arrays because they simplify difference-only
26
+ * transmission: only modified indexes need to be transferred, and shifts in
27
+ * item order must be explicit, simplifying merges of conflicting updates.
28
+ *
29
+ * For encoding of more complex data, consider using base64 and/or
30
+ * string-encoded JSON.
31
+ */
32
+ export type Extensions = {
33
+ [extensionIdentifier: string]: string | {
34
+ [key: string]: string;
35
+ } | {
36
+ [keyA: string]: {
37
+ [keyB: string]: string;
38
+ };
39
+ };
40
+ };
41
+ /**
42
+ * Tags allow registries to classify and group identities by a variety of
43
+ * characteristics. Tags are standardized within a registry and may represent
44
+ * either labels applied by that registry or designations by external
45
+ * authorities (certification, membership, ownership, etc.) that are tracked by
46
+ * that registry.
47
+ *
48
+ * Examples of possible tags include: `individual`, `organization`, `token`,
49
+ * `wallet`, `exchange`, `staking`, `utility-token`, `security-token`,
50
+ * `stablecoin`, `wrapped`, `collectable`, `deflationary`, `governance`,
51
+ * `decentralized-exchange`, `liquidity-provider`, `sidechain`,
52
+ * `sidechain-bridge`, `acme-audited`, `acme-endorsed`, etc.
53
+ *
54
+ * Tags may be used by clients in search, discovery, and filtering of
55
+ * identities, and they can also convey information like accreditation from
56
+ * investor protection organizations, public certifications by security or
57
+ * financial auditors, and other designations that signal integrity and value
58
+ * to users.
59
+ */
60
+ export type Tag = {
61
+ /**
62
+ * The name of this tag for use in interfaces.
63
+ *
64
+ * In user interfaces with limited space, names should be hidden beyond
65
+ * the first newline character or `20` characters until revealed by the user.
66
+ *
67
+ * E.g.:
68
+ * - `Individual`
69
+ * - `Token`
70
+ * - `Audited by ACME, Inc.`
71
+ */
72
+ name: string;
73
+ /**
74
+ * A string describing this tag for use in user interfaces.
75
+ *
76
+ * In user interfaces with limited space, descriptions should be hidden beyond
77
+ * the first newline character or `140` characters until revealed by the user.
78
+ *
79
+ * E.g.:
80
+ * - `An identity maintained by a single individual.`
81
+ * - `An identity representing a type of token.`
82
+ * - `An on-chain application that has passed security audits by ACME, Inc.`
83
+ */
84
+ description?: string;
85
+ /**
86
+ * A mapping of identifiers to URIs associated with this tag. URI identifiers
87
+ * may be widely-standardized or registry-specific. Values must be valid URIs,
88
+ * including a protocol prefix (e.g. `https://` or `ipfs://`). Clients are
89
+ * only required to support `https` and `ipfs` URIs, but any scheme may
90
+ * be specified.
91
+ *
92
+ * The following identifiers are recommended for all tags:
93
+ * - `icon`
94
+ * - `web`
95
+ *
96
+ * The following optional identifiers are standardized:
97
+ * - `blog`
98
+ * - `chat`
99
+ * - `forum`
100
+ * - `icon-intro`
101
+ * - `registry`
102
+ * - `support`
103
+ *
104
+ * For details on these standard identifiers, see:
105
+ * https://github.com/bitjson/chip-bcmr#uri-identifiers
106
+ *
107
+ * Custom URI identifiers allow for sharing social networking profiles, p2p
108
+ * connection information, and other application-specific URIs. Identifiers
109
+ * must be lowercase, alphanumeric strings, with no whitespace or special
110
+ * characters other than dashes (as a regular expression: `/^[-a-z0-9]+$/`).
111
+ *
112
+ * For example, some common identifiers include: `discord`, `docker`,
113
+ * `facebook`, `git`, `github`, `gitter`, `instagram`, `linkedin`, `matrix`,
114
+ * `npm`, `reddit`, `slack`, `substack`, `telegram`, `twitter`, `wechat`,
115
+ * `youtube`.
116
+ */
117
+ uris?: URIs;
118
+ /**
119
+ * A mapping of `Tag` extension identifiers to extension definitions.
120
+ * {@link Extensions} may be widely standardized or application-specific.
121
+ */
122
+ extensions?: Extensions;
123
+ };
124
+ /**
125
+ * A definition for one type of NFT within a token category.
126
+ */
127
+ export type NftType = {
128
+ /**
129
+ * The name of this NFT type for use in interfaces. Names longer than
130
+ * `20` characters may be elided in some interfaces.
131
+ *
132
+ * E.g. `Market Order Buys`, `Limit Order Sales`, `Pledge Receipts`,
133
+ * `ACME Stadium Tickets`, `Sealed Votes`, etc.
134
+ */
135
+ name: string;
136
+ /**
137
+ * A string describing this NFT type for use in user interfaces.
138
+ *
139
+ * In user interfaces with limited space, names should be hidden
140
+ * beyond the first newline character or `140` characters until
141
+ * revealed by the user.
142
+ *
143
+ * E.g.:
144
+ * - "Receipts issued by the exchange to record details about
145
+ * purchases. After settlement, these receipts are redeemed for the
146
+ * purchased tokens.";
147
+ * - "Receipts issued by the crowdfunding campaign
148
+ * to document the value of funds pledged. If the user decides to
149
+ * cancel their pledge before the campaign completes, these receipts
150
+ * can be redeemed for a full refund.";
151
+ * - "Tickets issued for events at ACME Stadium.";
152
+ * - Sealed ballots certified by ACME decentralized organization
153
+ * during the voting period. After the voting period ends, these
154
+ * ballots must be revealed to reclaim the tokens used for voting."
155
+ */
156
+ description?: string;
157
+ /**
158
+ * A list of identifiers for fields contained in NFTs of this type.
159
+ * On successful parsing evaluations, the bottom item on the
160
+ * altstack indicates the matched NFT type, and the remaining
161
+ * altstack items represent NFT field contents in the order listed
162
+ * (where `fields[0]` is the second-to-bottom item, and the final
163
+ * item in `fields` is the top of the altstack).
164
+ *
165
+ * Fields should be ordered by recommended importance from most
166
+ * important to least important; in user interfaces, clients should
167
+ * display fields at lower indexes more prominently than those at
168
+ * higher indexes, e.g. if some fields cannot be displayed in
169
+ * minimized interfaces, higher-importance fields can still be
170
+ * represented. (Note, this ordering is controlled by the bytecode
171
+ * specified in `token.nft.parse.bytecode`.)
172
+ */
173
+ fields?: string[];
174
+ /**
175
+ * A mapping of identifiers to URIs associated with this NFT type.
176
+ * URI identifiers may be widely-standardized or registry-specific.
177
+ * Values must be valid URIs, including a protocol prefix (e.g.
178
+ * `https://` or `ipfs://`). Clients are only required to support
179
+ * `https` and `ipfs` URIs, but any scheme may be specified.
180
+ */
181
+ uris?: URIs;
182
+ /**
183
+ * A mapping of NFT type extension identifiers to extension
184
+ * definitions. {@link Extensions} may be widely standardized or
185
+ * application-specific.
186
+ */
187
+ extensions?: Extensions;
188
+ };
189
+ /**
190
+ * A definition specifying a field that can be encoded in non-fungible tokens of
191
+ * a token category.
192
+ */
193
+ export type NftCategoryField = {
194
+ [identifier: string]: {
195
+ /**
196
+ * The name of this field for use in interfaces. Names longer than
197
+ * `20` characters may be elided in some interfaces.
198
+ *
199
+ * E.g.:
200
+ * - `BCH Pledged`
201
+ * - `Tokens Sold`
202
+ * - `Seat Number`,
203
+ * - `IPFS Content Identifier`
204
+ * - `HTTPS URL`
205
+ */
206
+ name?: string;
207
+ /**
208
+ * A string describing how this identity uses NFTs (for use in user
209
+ * interfaces). Descriptions longer than `160` characters may be
210
+ * elided in some interfaces.
211
+ *
212
+ * E.g.:
213
+ * - `The BCH value pledged at the time this receipt was issued.`
214
+ * - `The number of tokens sold in this order.`
215
+ * - `The seat number associated with this ticket.`
216
+ */
217
+ description?: string;
218
+ /**
219
+ * The expected encoding of this field when read from the parsing
220
+ * altstack (see `token.nft.parse`). All encoding definitions must
221
+ * have a `type`, and some encoding definitions allow for additional
222
+ * hinting about display strategies in clients.
223
+ *
224
+ * Encoding types may be set to `binary`, `boolean`, `hex`, `number`,
225
+ * or `utf8`:
226
+ *
227
+ * - `binary` types should be displayed as binary literals (e.g.
228
+ * `0b0101`)
229
+ * - `boolean` types should be displayed as `true` if exactly `0x01`
230
+ * or `false` if exactly `0x00`. If a boolean value does not match one
231
+ * of these values, clients should represent the NFT as unable to be
232
+ * parsed (e.g. simply display the full `commitment`).
233
+ * - `hex` types should be displayed as hex literals (e.g.`0xabcd`).
234
+ * - `https-url` types are percent encoded with the `https://` prefix
235
+ * omitted; they may be displayed as URIs or as activatable links.
236
+ * - `ipfs-cid` types are binary-encoded IPFS Content Identifiers;
237
+ * they may be displayed as URIs or as activatable links.
238
+ * - `locktime` types are `OP_TXLOCKTIME` results: integers from `0`
239
+ * to `4294967295` (inclusive) where values less than `500000000` are
240
+ * understood to be a block height (the current block number in the
241
+ * chain, beginning from block `0`), and values greater than or equal
242
+ * to `500000000` are understood to be a Median Time Past (BIP113)
243
+ * UNIX timestamp. (Note, sequence age is not currently supported.)
244
+ * - `number` types should be displayed according the their configured
245
+ * `decimals` and `unit` values.
246
+ * - `utf8` types should be displayed as utf8 strings.
247
+ */
248
+ encoding: {
249
+ type: "binary" | "boolean" | "hex" | "https-url" | "ipfs-cid" | "utf8" | `locktime`;
250
+ } | {
251
+ type: "number";
252
+ /**
253
+ * The `aggregate` property indicates that aggregating this
254
+ * field from multiple NFTs is desirable in user interfaces. For
255
+ * example, for a field named `BCH Pledged` where `aggregate` is
256
+ * `add`, the client can display a `Total BCH Pledged` in any
257
+ * user interface listing more than one NFT.
258
+ *
259
+ * If specified, clients should aggregate the field from all
260
+ * NFTs within a view (e.g. NFTs held by a single wallet, NFTs
261
+ * existing in a single transaction's outputs, etc.) using the
262
+ * specified operation. Note, while aggregation could be
263
+ * performed using any commutative operation – multiplication,
264
+ * bitwise AND, bitwise OR, and bitwise XOR, etc. – only `add`
265
+ * is currently supported.
266
+ */
267
+ aggregate?: "add";
268
+ /**
269
+ * An integer between `0` and `18` (inclusive) indicating the
270
+ * divisibility of the primary unit of this token field.
271
+ *
272
+ * This is the number of digits that can appear after the
273
+ * decimal separator in amounts. For a field with a `decimals`
274
+ * of `2`, a value of `123456` should be displayed as `1234.56`.
275
+ *
276
+ * If omitted, defaults to `0`.
277
+ */
278
+ decimals?: number;
279
+ /**
280
+ * The unit in which this field is denominated, taking the
281
+ * `decimals` value into account. If representing fungible token
282
+ * amount, this will often be the symbol of the represented
283
+ * token category.
284
+ *
285
+ * E.g. `BCH`, `sats`, `AcmeUSD`, etc.
286
+ *
287
+ * If not provided, clients should not represent this field as
288
+ * having a unit beyond the field's `name`.
289
+ */
290
+ unit?: string;
291
+ };
292
+ /**
293
+ * A mapping of identifiers to URIs associated with this NFT field.
294
+ * URI identifiers may be widely-standardized or registry-specific.
295
+ * Values must be valid URIs, including a protocol prefix (e.g.
296
+ * `https://` or `ipfs://`). Clients are only required to support
297
+ * `https` and `ipfs` URIs, but any scheme may be specified.
298
+ */
299
+ uris?: URIs;
300
+ /**
301
+ * A mapping of NFT field extension identifiers to extension
302
+ * definitions. {@link Extensions} may be widely standardized or
303
+ * application-specific.
304
+ */
305
+ extensions?: Extensions;
306
+ };
307
+ };
308
+ /**
309
+ * A definition specifying the non-fungible token information for a
310
+ * token category.
311
+ */
312
+ export type NftCategory = {
313
+ /**
314
+ * A string describing how this identity uses NFTs (for use in user
315
+ * interfaces). Descriptions longer than `160` characters may be elided in
316
+ * some interfaces.
317
+ *
318
+ * E.g.:
319
+ * - "ACME DEX NFT order receipts are issued when you place orders on the
320
+ * decentralized exchange. After orders are processed, order receipts can
321
+ * be redeemed for purchased tokens or sales proceeds.";
322
+ * - "ACME Game collectable NFTs unlock unique playable content, user
323
+ * avatars, and item skins in ACME Game Online."; etc.
324
+ */
325
+ description?: string;
326
+ /**
327
+ * A mapping of field identifier to field definitions for the data fields
328
+ * that can appear in NFT commitments of this category.
329
+ */
330
+ fields?: NftCategoryField;
331
+ /**
332
+ * Parsing and interpretation information for all NFTs of this category;
333
+ * this enables generalized wallets to parse and display detailed
334
+ * information about all NFTs held by the wallet, e.g. `BCH Pledged`,
335
+ * `Order Price`, `Seat Number`, `Asset Number`,
336
+ * `IPFS Content Identifier`, `HTTPS URL`, etc.
337
+ *
338
+ * Parsing instructions are provided in the `bytecode` property, and the
339
+ * results are interpreted using the `types` property.
340
+ */
341
+ parse: {
342
+ /**
343
+ * A segment of hex-encoded Bitcoin Cash VM bytecode that parses UTXOs
344
+ * holding NFTs of this category, identifies the NFT's type within the
345
+ * category, and returns a list of the NFT's field values via the
346
+ * altstack.
347
+ *
348
+ * The parse `bytecode` is evaluated by instantiating and partially
349
+ * verifying a standardized NFT parsing transaction:
350
+ * - version: `2`
351
+ * - inputs:
352
+ * - 0: Spends the UTXO containing the NFT with an empty
353
+ * unlocking bytecode and sequence number of `0`.
354
+ * - 1: Spends index `0` of the empty hash outpoint, with locking
355
+ * bytecode set to `parse.bytecode`, unlocking bytecode `OP_1`
356
+ * (`0x51`) and sequence number `0`.
357
+ * - outputs:
358
+ * - 0: A locking bytecode of OP_RETURN (`0x6a`) and value of `0`.
359
+ * - locktime: `0`
360
+ *
361
+ * After input 1 of this NFT parsing transaction is evaluated, if the
362
+ * resulting stack is not valid (a single "truthy" element remaining on
363
+ * the stack) – or if the altstack is empty – parsing has failed and
364
+ * clients should represent the NFT as unable to be parsed (e.g. simply
365
+ * display the full `commitment` as a hex-encoded value in the user
366
+ * interface).
367
+ *
368
+ * On successful parsing evaluations, the bottom item on the altstack
369
+ * indicates the type of the NFT according to the matching definition in
370
+ * `types`. If no match is found, clients should represent the NFT as
371
+ * unable to be parsed.
372
+ *
373
+ * For example:
374
+ * - `00d26b` (OP_0 OP_UTXOTOKENCOMMITMENT OP_TOALTSTACK) takes the full
375
+ * contents of the commitment as a fixed type; this can be used for
376
+ * collections of unique, "numbered" NFTs. (Commitments of `01`, `02`,
377
+ * `03`, etc.)
378
+ * - `00d2517f7c6b` (OP_0 OP_UTXOTOKENCOMMITMENT OP_1 OP_SPLIT OP_SWAP
379
+ * OP_TOALTSTACK OP_TOALTSTACK) splits the commitment after 1 byte,
380
+ * pushing the first byte to the altstack as an NFT type and the
381
+ * remaining segment of the commitment as the first NFT field value.
382
+ */
383
+ bytecode: string;
384
+ /**
385
+ * A mapping of hex-encoded values to definitions of possible NFT types
386
+ * in this category.
387
+ */
388
+ types: {
389
+ /**
390
+ * A definitions for each type of NFT within the token category. NFT
391
+ * types are indexed by the expected hex-encoded value of the bottom
392
+ * altstack item following evaluation of `token.nfts.parse.bytecode`.
393
+ * The remaining altstack items are mapped to NFT fields according to
394
+ * the `fields` property of the matching NFT type.
395
+ */
396
+ [bottomAltStackItemHex: string]: NftType;
397
+ };
398
+ };
399
+ };
400
+ /**
401
+ * A definition specifying information about an identity's token category.
402
+ */
403
+ export type TokenCategory = {
404
+ /**
405
+ * The current token category used by this identity. Often, this will be
406
+ * equal to the identity's authbase, but some token identities must migrate
407
+ * to new categories for technical reasons.
408
+ */
409
+ category: string;
410
+ /**
411
+ * An abbreviation used to uniquely identity this token category.
412
+ *
413
+ * Symbols must be comprised only of capital letters, numbers, and dashes
414
+ * (`-`). This can be validated with the regular expression:
415
+ * `/^[-A-Z0-9]+$/`.
416
+ */
417
+ symbol: string;
418
+ /**
419
+ * An integer between `0` and `18` (inclusive) indicating the divisibility
420
+ * of the primary unit of this token category.
421
+ *
422
+ * This is the number of digits that can appear after the decimal separator
423
+ * in fungible token amounts. For a token category with a `symbol` of
424
+ * `SYMBOL` and a `decimals` of `2`, a fungible token amount of `12345`
425
+ * should be displayed as `123.45 SYMBOL`.
426
+ *
427
+ * If omitted, defaults to `0`.
428
+ */
429
+ decimals?: number;
430
+ /**
431
+ * Display information for non-fungible tokens (NFTs) of this identity.
432
+ * Omitted for token categories without NFTs.
433
+ */
434
+ nfts?: NftCategory;
435
+ };
436
+ /**
437
+ * A snapshot of the metadata for a particular identity at a specific time.
438
+ */
439
+ export type IdentitySnapshot = {
440
+ /**
441
+ * The name of this identity for use in interfaces.
442
+ *
443
+ * In user interfaces with limited space, names should be hidden beyond
444
+ * the first newline character or `20` characters until revealed by the user.
445
+ *
446
+ * E.g. `ACME Class A Shares`, `ACME Registry`, `Satoshi Nakamoto`, etc.
447
+ */
448
+ name: string;
449
+ /**
450
+ * A string describing this identity for use in user interfaces.
451
+ *
452
+ * In user interfaces with limited space, descriptions should be hidden beyond
453
+ * the first newline character or `140` characters until revealed by the user.
454
+ *
455
+ * E.g.:
456
+ * - `The common stock issued by ACME, Inc.`
457
+ * - `A metadata registry maintained by Company Name, the embedded registry for Wallet Name.`
458
+ * - `Software developer and lead maintainer of Wallet Name.`
459
+ */
460
+ description?: string;
461
+ /**
462
+ * An array of `Tag` identifiers marking the `Tag`s associated with this
463
+ * identity. All specified tag identifiers must be defined in the registry's
464
+ * `tags` mapping.
465
+ */
466
+ tags?: string[];
467
+ /**
468
+ * The timestamp at which this identity snapshot is fully in effect. This
469
+ * value should only be provided if the snapshot takes effect over a period
470
+ * of time (e.g. an in-circulation token identity is gradually migrating to
471
+ * a new category). In these cases, clients should gradually migrate to
472
+ * using the new information beginning after the identity snapshot's timestamp
473
+ * and the `migrated` time.
474
+ *
475
+ * This timestamp must be provided in simplified extended ISO 8601 format, a
476
+ * 24-character string of format `YYYY-MM-DDTHH:mm:ss.sssZ` where timezone is
477
+ * zero UTC (denoted by `Z`). Note, this is the format returned by ECMAScript
478
+ * `Date.toISOString()`.
479
+ */
480
+ migrated?: string;
481
+ /**
482
+ * If this identity is a type of token, a data structure indicating how tokens
483
+ * should be understood and displayed in user interfaces. Omitted for
484
+ * non-token identities.
485
+ */
486
+ token?: TokenCategory;
487
+ /**
488
+ * The status of this identity, must be `active`, `inactive`, or `burned`. If
489
+ * omitted, defaults to `active`.
490
+ * - Identities with an `active` status should be actively tracked by clients.
491
+ * - Identities with an `inactive` status may be considered for archival by
492
+ * clients and may be removed in future registry versions.
493
+ * - Identities with a `burned` status have been destroyed by setting the
494
+ * latest identity output to a data-carrier output (`OP_RETURN`), permanently
495
+ * terminating the authchain. Clients should archive burned identities and –
496
+ * if the burned identity represented a token type – consider burning any
497
+ * remaining tokens of that category to reclaim funds from those outputs.
498
+ */
499
+ status?: "active" | "burned" | "inactive";
500
+ /**
501
+ * The split ID of this identity's chain of record.
502
+ *
503
+ * If undefined, defaults to {@link Registry.defaultChain}.
504
+ */
505
+ splitId?: string;
506
+ /**
507
+ * A mapping of identifiers to URIs associated with this identity. URI
508
+ * identifiers may be widely-standardized or registry-specific. Values must be
509
+ * valid URIs, including a protocol prefix (e.g. `https://` or `ipfs://`).
510
+ * Clients are only required to support `https` and `ipfs` URIs, but any
511
+ * scheme may be specified.
512
+ *
513
+ * The following identifiers are recommended for all identities:
514
+ * - `icon`
515
+ * - `web`
516
+ *
517
+ * The following optional identifiers are standardized:
518
+ * - `blog`
519
+ * - `chat`
520
+ * - `forum`
521
+ * - `icon-intro`
522
+ * - `registry`
523
+ * - `support`
524
+ *
525
+ * For details on these standard identifiers, see:
526
+ * https://github.com/bitjson/chip-bcmr#uri-identifiers
527
+ *
528
+ * Custom URI identifiers allow for sharing social networking profiles, p2p
529
+ * connection information, and other application-specific URIs. Identifiers
530
+ * must be lowercase, alphanumeric strings, with no whitespace or special
531
+ * characters other than dashes (as a regular expression: `/^[-a-z0-9]+$/`).
532
+ *
533
+ * For example, some common identifiers include: `discord`, `docker`,
534
+ * `facebook`, `git`, `github`, `gitter`, `instagram`, `linkedin`, `matrix`,
535
+ * `npm`, `reddit`, `slack`, `substack`, `telegram`, `twitter`, `wechat`,
536
+ * `youtube`.
537
+ */
538
+ uris?: URIs;
539
+ /**
540
+ * A mapping of `IdentitySnapshot` extension identifiers to extension
541
+ * definitions. {@link Extensions} may be widely standardized or
542
+ * application-specific.
543
+ *
544
+ * Standardized extensions for `IdentitySnapshot`s include the `authchain`
545
+ * extension. See
546
+ * https://github.com/bitjson/chip-bcmr#authchain-extension for details.
547
+ */
548
+ extensions?: Extensions;
549
+ };
550
+ /**
551
+ * A snapshot of the metadata for a particular chain/network at a specific
552
+ * time. This allows for registries to provide similar metadata for each chain's
553
+ * native currency unit (name, description, symbol, icon, etc.) as can be
554
+ * provided for other registered tokens.
555
+ */
556
+ export type ChainSnapshot = Omit<IdentitySnapshot, "migrated" | "token"> & {
557
+ /**
558
+ * A data structure indicating how the chain's native currency units should be
559
+ * displayed in user interfaces.
560
+ */
561
+ token: {
562
+ /**
563
+ * An abbreviation used to uniquely identity this native currency unit.
564
+ *
565
+ * Symbols must be comprised only of capital letters, numbers, and dashes
566
+ * (`-`). This can be validated with the regular expression:
567
+ * `/^[-A-Z0-9]+$/`.
568
+ */
569
+ symbol: string;
570
+ /**
571
+ * An integer between `0` and `18` (inclusive) indicating the divisibility
572
+ * of the primary unit of this native currency.
573
+ *
574
+ * This is the number of digits that can appear after the decimal separator
575
+ * in currency amounts. For a currency with a `symbol` of `SYMBOL` and a
576
+ * `decimals` of `2`, an amount of `12345` should be displayed as
577
+ * `123.45 SYMBOL`.
578
+ *
579
+ * If omitted, defaults to `0`.
580
+ */
581
+ decimals?: number;
582
+ };
583
+ };
584
+ /**
585
+ * A field keyed by timestamps to document the evolution of the field. Each
586
+ * timestamp must be provided in simplified extended ISO 8601 format, a
587
+ * 24-character string of format `YYYY-MM-DDTHH:mm:ss.sssZ` where timezone is
588
+ * zero UTC (denoted by `Z`). Note, this is the format returned by ECMAScript
589
+ * `Date.toISOString()`.
590
+ *
591
+ * For example, to insert a new value:
592
+ * ```ts
593
+ * const result = { ...previousValue, [(new Date()).toISOString()]: newValue };
594
+ * ```
595
+ */
596
+ export type RegistryTimestampKeyedValues<T> = {
597
+ [timestamp: string]: T;
598
+ };
599
+ /**
600
+ * A block height-keyed map of {@link ChainSnapshot}s documenting the evolution
601
+ * of a particular chain/network's identity. Like {@link IdentityHistory}, this
602
+ * structure allows wallets and other user interfaces to offer better
603
+ * experiences when a chain identity is rebranded, redenominated, or other
604
+ * important metadata is modified in a coordinated update.
605
+ */
606
+ export type ChainHistory = RegistryTimestampKeyedValues<ChainSnapshot>;
607
+ /**
608
+ * A timestamp-keyed map of {@link IdentitySnapshot}s documenting
609
+ * the evolution of a particular identity. Typically, the current identity
610
+ * information is the latest record when lexicographically sorted, but in cases
611
+ * where a planned migration has not yet begun (the snapshot's timestamp has not
612
+ * yet been reached), the immediately preceding record is considered the
613
+ * current identity.
614
+ *
615
+ * This strategy allows wallets and other user interfaces to offer better
616
+ * experiences when an identity is rebranded, a token redenominated, or other
617
+ * important metadata is modified in a coordinated update. For example, a wallet
618
+ * may warn token holders of a forthcoming rebranding of fungible tokens they
619
+ * hold; after the change, the wallet may continue to offer prominent interface
620
+ * hints that the rebranded token identity was recently updated.
621
+ *
622
+ * Note, only the latest two {@link IdentitySnapshot}s should be considered
623
+ * part of an identity's "current" information. E.g. even if two snapshots have
624
+ * active, overlapping migration periods (i.e. an older snapshot's
625
+ * {@link IdentitySnapshot.migrated} timestamp has not yet been reached),
626
+ * clients should only attempt to display the migration from the previous to the
627
+ * latest snapshot.
628
+ *
629
+ * If the current snapshot's {@link IdentitySnapshot.migrated} isn't specified,
630
+ * the snapshot's index is a precise time at which the snapshot takes effect and
631
+ * clients should begin using the new information. If `migrated` is specified,
632
+ * the snapshot's index is the timestamp at which the transition is considered
633
+ * to begin, see {@link IdentitySnapshot.migrated} for details.
634
+ *
635
+ * Each timestamp must be provided in simplified extended ISO 8601 format, a
636
+ * 24-character string of format `YYYY-MM-DDTHH:mm:ss.sssZ` where timezone is
637
+ * zero UTC (denoted by `Z`). Note, this is the format returned by ECMAScript
638
+ * `Date.toISOString()`.
639
+ *
640
+ * In the case that an identity change occurs due to on-chain activity (e.g. an
641
+ * on-chain migration that is set to complete at a particular locktime value),
642
+ * registry-recorded timestamps reflect the real-world time at which the
643
+ * maintainer of the registry believes the on-chain activity to have actually
644
+ * occurred. Likewise, future-dated timestamps indicate a precise real-world
645
+ * time at which a snapshot is estimated to take effect, rather than the Median
646
+ * Time Past (BIP113) UNIX timestamp or another on-chain measurement of time.
647
+ */
648
+ export type IdentityHistory = RegistryTimestampKeyedValues<IdentitySnapshot>;
649
+ export type OffChainRegistryIdentity = Pick<IdentitySnapshot, "name" | "description" | "uris" | "tags" | "extensions">;
650
+ /**
651
+ * A Bitcoin Cash Metadata Registry is an authenticated JSON file containing
652
+ * metadata about tokens, identities, contract applications, and other on-chain
653
+ * artifacts. BCMRs conform to the Bitcoin Cash Metadata Registry JSON Schema,
654
+ * and they can be published and maintained by any entity or individual.
655
+ */
656
+ export type Registry = {
657
+ /**
658
+ * The schema used by this registry. Many JSON editors can automatically
659
+ * provide inline documentation and autocomplete support using the `$schema`
660
+ * property, so it is recommended that registries include it. E.g.:
661
+ * `https://cashtokens.org/bcmr-v2.schema.json`
662
+ */
663
+ $schema?: string;
664
+ /**
665
+ * The version of this registry. Versioning adheres to Semantic Versioning
666
+ * (https://semver.org/).
667
+ */
668
+ version: {
669
+ /**
670
+ * The major version is incremented when an identity is removed.
671
+ */
672
+ major: number;
673
+ /**
674
+ * The minor version is incremented when an identity is added or a new
675
+ * identity snapshot is added.
676
+ */
677
+ minor: number;
678
+ /**
679
+ * The patch version is incremented when an existing identity or identity
680
+ * snapshot is modified (e.g. to correct an error or add a missing piece of
681
+ * information) or when other registry properties (e.g. registry `name`,
682
+ * `description`, `uris`, etc.) are modified.
683
+ *
684
+ * Generally, substantive changes to an existing identity should be made
685
+ * using a new identity snapshot in a minor version upgrade – this allows
686
+ * clients to provide a better user experience by noting the change in
687
+ * relevant user interfaces.
688
+ *
689
+ * For example, patch upgrades might include spelling corrections in an
690
+ * existing snapshot or the addition of an `icon-svg` containing a
691
+ * higher-resolution version of an existing `icon` image. On the other hand,
692
+ * a rebranding in which the icon is substantially changed may warrant a new
693
+ * identity snapshot to be added in a minor version upgrade.
694
+ */
695
+ patch: number;
696
+ };
697
+ /**
698
+ * The timestamp of the latest revision made to this registry version. The
699
+ * timestamp must be provided in simplified extended ISO 8601 format, a
700
+ * 24-character string of format `YYYY-MM-DDTHH:mm:ss.sssZ` where timezone is
701
+ * zero UTC (denoted by `Z`). Note, this is the format returned by ECMAScript
702
+ * `Date.toISOString()`.
703
+ */
704
+ latestRevision: string;
705
+ /**
706
+ * The identity information of this particular registry, provided as either an
707
+ * authbase (recommended) or an `IdentitySnapshot`.
708
+ *
709
+ * An authbase is a 32-byte, hex-encoded transaction hash (A.K.A. TXID) for
710
+ * which the zeroth-descendant transaction chain (ZDTC) authenticates and
711
+ * publishes all registry updates. If an authbase is provided, the registry's
712
+ * identity information can be found in `identities[authbase]`, and clients
713
+ * should immediately attempt to verify the registry's identity on-chain.
714
+ * (See https://github.com/bitjson/chip-bcmr#chain-resolved-registries)
715
+ *
716
+ * If an `IdentitySnapshot` is provided directly, this registry does not
717
+ * support on-chain resolution/authentication, and the contained
718
+ * `IdentitySnapshot` can only be authenticated via DNS/HTTPS.
719
+ */
720
+ registryIdentity: OffChainRegistryIdentity | string;
721
+ /**
722
+ * A mapping of authbases to the `IdentityHistory` for that identity.
723
+ *
724
+ * An authbase is a 32-byte, hex-encoded transaction hash (A.K.A. TXID) for
725
+ * which the zeroth-descendant transaction chain (ZDTC) authenticates and
726
+ * publishes an identity's claimed metadata.
727
+ *
728
+ * Identities may represent metadata registries, specific types of tokens,
729
+ * companies, organizations, individuals, or other on-chain entities.
730
+ */
731
+ identities?: {
732
+ [authbase: string]: IdentityHistory;
733
+ };
734
+ /**
735
+ * A map of registry-specific `Tag`s used by this registry to convey
736
+ * information about identities it tracks.
737
+ *
738
+ * Tags allow registries to group identities into collections of related
739
+ * identities, marking characteristics or those identities. Tags are
740
+ * standardized within a registry and may represent either labels applied by
741
+ * that registry (e.g. `individual`, `organization`, `token`, `wallet`,
742
+ * `exchange`, `staking`, `utility-token`, `security-token`, `stablecoin`,
743
+ * `wrapped`, `collectable`, `deflationary`, `governance`,
744
+ * `decentralized-exchange`, `liquidity-provider`, `sidechain`,
745
+ * `sidechain-bridge`, etc.) or designations by external authorities
746
+ * (certification, membership, ownership, etc.) that are tracked by
747
+ * that registry.
748
+ *
749
+ * Tags may be used by clients in search, discover, and filtering of
750
+ * identities, and they can also convey information like accreditation from
751
+ * investor protection organizations, public certifications by security or
752
+ * financial auditors, and other designations that signal legitimacy and value
753
+ * to users.
754
+ */
755
+ tags?: {
756
+ [identifier: string]: Tag;
757
+ };
758
+ /**
759
+ * The split ID of the chain/network considered the "default" chain for this
760
+ * registry. Identities that do not specify a {@link IdentitySnapshot.splitId}
761
+ * are assumed to be set to this split ID. For a description of split IDs,
762
+ * see {@link Registry.chains}.
763
+ *
764
+ * If not provided, the `defaultChain` is
765
+ * `0000000000000000029e471c41818d24b8b74c911071c4ef0b4a0509f9b5a8ce`, the BCH
766
+ * side of the BCH/XEC split (mainnet). Common values include:
767
+ * - `00000000ae25e85d9e22cd6c8d72c2f5d4b0222289d801b7f633aeae3f8c6367`
768
+ * (testnet4)
769
+ * - `00000000040ba9641ba98a37b2e5ceead38e4e2930ac8f145c8094f94c708727`
770
+ * (chipnet)
771
+ */
772
+ defaultChain?: string;
773
+ /**
774
+ * A map of split IDs tracked by this registry to the {@link ChainHistory} for
775
+ * that chain/network.
776
+ *
777
+ * The split ID of a chain is the block header hash (A.K.A. block ID) of the
778
+ * first unique block after the most recent tracked split – a split after
779
+ * which both resulting chains are considered notable or tracked by the
780
+ * registry. (For chains with no such splits, this is the ID of the
781
+ * genesis block.)
782
+ *
783
+ * Note, split ID is inherently a "relative" identifier. After a tracked
784
+ * split, both resulting chains will have a new split ID. However, if a wallet
785
+ * has not yet heard about a particular split, that wallet will continue to
786
+ * reference one of the resulting chains by its previous split ID, and the
787
+ * split-unaware wallet may create transactions that are valid on both chains
788
+ * (losing claimable value if the receivers of their transactions don't
789
+ * acknowledge transfers on both chains). When a registry trusted by the
790
+ * wallet notes the split in it's `chains` map, the wallet can represent the
791
+ * split in the user interface using the the latest {@link ChainSnapshot} for
792
+ * each chain and splitting coins prior to spending (by introducing post-split
793
+ * coins in each transaction).
794
+ *
795
+ * This map may exclude the following well-known split IDs (all clients
796
+ * supporting any of these chains should build-in {@link ChainHistory} for
797
+ * those chains):
798
+ *
799
+ * - `0000000000000000029e471c41818d24b8b74c911071c4ef0b4a0509f9b5a8ce`:
800
+ * A.K.A. mainnet – the BCH side of the BCH/XEC split.
801
+ * - `00000000ae25e85d9e22cd6c8d72c2f5d4b0222289d801b7f633aeae3f8c6367`:
802
+ * A.K.A testnet4 – the test network on which CHIPs are activated
803
+ * simultaneously with mainnet (May 15 at 12 UTC).
804
+ * - `00000000040ba9641ba98a37b2e5ceead38e4e2930ac8f145c8094f94c708727`:
805
+ * A.K.A. chipnet – the test network on which CHIPs are activated 6 months
806
+ * before mainnet (November 15 at 12 UTC).
807
+ *
808
+ * All other split IDs referenced by this registry should be included in this
809
+ * map.
810
+ */
811
+ chains?: {
812
+ [splitId: string]: ChainHistory;
813
+ };
814
+ /**
815
+ * The license under which this registry is published. This may be specified
816
+ * as either a SPDX short identifier (https://spdx.org/licenses/) or by
817
+ * including the full text of the license.
818
+ *
819
+ * Common values include:
820
+ * - `CC0-1.0`: https://creativecommons.org/publicdomain/zero/1.0/
821
+ * - `MIT`: https://opensource.org/licenses/MIT
822
+ */
823
+ license?: string;
824
+ /**
825
+ * A mapping of `Registry` extension identifiers to extension definitions.
826
+ * {@link Extensions} may be widely standardized or application-specific.
827
+ *
828
+ * Standardized extensions for `Registry`s include the `locale` extension. See
829
+ * https://github.com/bitjson/chip-bcmr#locales-extension for details.
830
+ */
831
+ extensions?: Extensions;
832
+ };