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