@carrot-foundation/schemas 0.1.33 → 0.1.35

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -75,6 +75,34 @@ var NonEmptyStringSchema = zod.z.string().min(1, "Cannot be empty").meta({
75
75
  description: "A string that contains at least one character",
76
76
  examples: ["Example text", "Sample value", "Test string"]
77
77
  });
78
+ var MunicipalitySchema = NonEmptyStringSchema.max(50).meta({
79
+ title: "Municipality",
80
+ description: "Municipality or city name",
81
+ examples: ["Macap\xE1", "S\xE3o Paulo", "New York", "Berlin", "Tokyo"]
82
+ });
83
+ var AdministrativeDivisionSchema = NonEmptyStringSchema.max(50).meta({
84
+ title: "Administrative Division",
85
+ description: "State, province, or administrative region name",
86
+ examples: ["Amap\xE1", "California", "Bavaria"]
87
+ });
88
+ var CountryNameSchema = NonEmptyStringSchema.max(50).meta({
89
+ title: "Country",
90
+ description: "Full country name in English",
91
+ examples: ["Brazil", "United States", "Germany", "Japan"]
92
+ });
93
+ var MethodologyNameSchema = NonEmptyStringSchema.max(100).meta({
94
+ title: "Methodology Name",
95
+ description: "Name of the methodology used for certification",
96
+ examples: ["BOLD Recycling", "BOLD Carbon (CH\u2084)"]
97
+ });
98
+ var StringifiedTokenIdSchema = NonEmptyStringSchema.regex(
99
+ /^#\d+$/,
100
+ "Must match pattern #<token_id>"
101
+ ).meta({
102
+ title: "Token ID",
103
+ description: "Token ID represented as #<token_id>",
104
+ example: "#123"
105
+ });
78
106
  var SlugSchema = NonEmptyStringSchema.regex(
79
107
  /^[a-z0-9-]+$/,
80
108
  "Must contain only lowercase letters, numbers, and hyphens"
@@ -142,6 +170,15 @@ var NonNegativeFloatSchema = zod.z.number().min(0).meta({
142
170
  description: "Floating-point number that is zero or positive",
143
171
  examples: [0, 45.2, 72.5]
144
172
  });
173
+ var CreditTypeSchema = NonEmptyStringSchema.max(100).meta({
174
+ title: "Credit Type",
175
+ description: "Type of credit issued",
176
+ examples: ["Organic", "Carbon (CH\u2084)"]
177
+ });
178
+ var CreditAmountSchema = NonNegativeFloatSchema.meta({
179
+ title: "Credit Amount",
180
+ description: "Amount of credits issued"
181
+ });
145
182
  var HoursSchema = zod.z.number().min(0).multipleOf(0.1).meta({
146
183
  title: "Hours",
147
184
  description: "Time duration in hours with 0.1 hour precision",
@@ -258,118 +295,6 @@ var RecordRelationshipTypeSchema = zod.z.enum([
258
295
  description: "Type of relationship between different entities in the system",
259
296
  examples: ["mass-id", "audit", "collection"]
260
297
  });
261
- var SchemaInfoSchema = zod.z.strictObject({
262
- hash: Keccak256HashSchema.meta({
263
- title: "Schema Hash",
264
- description: "Keccak256 hash of the JSON Schema this record was validated against"
265
- }),
266
- type: RecordSchemaTypeSchema.meta({
267
- title: "Schema Type",
268
- description: "Type/category of this schema"
269
- }),
270
- version: SemanticVersionSchema.meta({
271
- title: "Schema Version",
272
- description: "Version of the schema, using semantic versioning"
273
- })
274
- }).meta({
275
- title: "Schema Information"
276
- });
277
- var RecordCreatorSchema = zod.z.strictObject({
278
- name: zod.z.string().meta({
279
- title: "Creator Name",
280
- description: "Company or individual name that created this record",
281
- examples: ["Carrot Foundation"]
282
- }),
283
- id: UuidSchema.meta({
284
- title: "Creator ID",
285
- description: "Unique identifier for the creator"
286
- })
287
- }).meta({
288
- title: "Creator",
289
- description: "Entity that created this record"
290
- });
291
- var RecordRelationshipSchema = zod.z.strictObject({
292
- target_uri: IpfsUriSchema.meta({
293
- title: "Target IPFS URI",
294
- description: "Target IPFS URI of the referenced record"
295
- }),
296
- type: RecordRelationshipTypeSchema.meta({
297
- title: "Relationship Type",
298
- description: "Type of relationship to the referenced record"
299
- }),
300
- description: zod.z.string().optional().meta({
301
- title: "Relationship Description",
302
- description: "Human-readable description of the relationship",
303
- examples: [
304
- "This record supersedes the previous version",
305
- "Related carbon credit batch",
306
- "Source document for this verification",
307
- "Child record derived from this parent",
308
- "Updated version of original record"
309
- ]
310
- })
311
- }).meta({
312
- title: "Relationship",
313
- description: "Relationship to another IPFS record"
314
- });
315
- var RecordEnvironmentSchema = zod.z.strictObject({
316
- blockchain_network: zod.z.enum(["mainnet", "testnet"]).meta({
317
- title: "Blockchain Network",
318
- description: "Blockchain Network Environment"
319
- }),
320
- deployment: zod.z.enum(["production", "development", "testing"]).meta({
321
- title: "Deployment Environment",
322
- description: "System environment where this record was generated"
323
- }),
324
- data_set_name: zod.z.enum(["TEST", "PROD"]).meta({
325
- title: "Data Set Name",
326
- description: "Name of the data set for this record"
327
- })
328
- }).meta({
329
- title: "Environment",
330
- description: "Environment information"
331
- });
332
- var BaseIpfsSchema = zod.z.strictObject({
333
- $schema: zod.z.url("Must be a valid URI").meta({
334
- title: "JSON Schema URI",
335
- description: "URI of the JSON Schema used to validate this record",
336
- example: "https://raw.githubusercontent.com/carrot-foundation/schemas/refs/heads/main/schemas/ipfs/shared/base/base.schema.json"
337
- }),
338
- schema: SchemaInfoSchema,
339
- created_at: IsoTimestampSchema.meta({
340
- title: "Created At",
341
- description: "ISO 8601 creation timestamp for this record"
342
- }),
343
- external_id: ExternalIdSchema.meta({
344
- title: "External ID",
345
- description: "Off-chain reference ID (UUID from Carrot backend)"
346
- }),
347
- external_url: ExternalUrlSchema.meta({
348
- title: "External URL",
349
- description: "External URL of the content"
350
- }),
351
- original_content_hash: Sha256HashSchema.meta({
352
- title: "Original Content Hash",
353
- description: "SHA-256 hash of the original JSON content including private data before schema validation"
354
- }),
355
- content_hash: Sha256HashSchema.meta({
356
- title: "Content Hash",
357
- description: "SHA-256 hash of RFC 8785 canonicalized JSON after schema validation"
358
- }),
359
- creator: RecordCreatorSchema.optional(),
360
- relationships: zod.z.array(RecordRelationshipSchema).optional().meta({
361
- title: "Relationships",
362
- description: "References to other IPFS records this record relates to"
363
- }),
364
- environment: RecordEnvironmentSchema.optional(),
365
- data: zod.z.record(zod.z.string(), zod.z.unknown()).optional().meta({
366
- title: "Custom Data",
367
- description: "Custom data block that includes the record's data"
368
- })
369
- }).meta({
370
- title: "Base IPFS Record",
371
- description: "Base fields for all Carrot IPFS records, providing common structure for any JSON content stored in IPFS"
372
- });
373
298
  function uniqueArrayItems(schema, errorMessage = "Array items must be unique") {
374
299
  return zod.z.array(schema).refine((items) => new Set(items).size === items.length, {
375
300
  message: errorMessage
@@ -387,760 +312,568 @@ function uniqueBy(schema, selector, errorMessage = "Items must be unique") {
387
312
  );
388
313
  }
389
314
 
390
- // src/shared/nft.schema.ts
391
- var NftSchemaTypeSchema = RecordSchemaTypeSchema.extract([
392
- "MassID",
393
- "RecycledID",
394
- "GasID",
395
- "PurchaseID"
396
- ]).meta({
397
- title: "NFT Schema Type",
398
- description: "Type of schema for NFT records"
399
- });
400
- var BlockchainReferenceSchema = zod.z.strictObject({
401
- smart_contract_address: EthereumAddressSchema.meta({
402
- title: "Smart Contract Address"
403
- }),
404
- chain_id: BlockchainChainIdSchema.meta({
405
- title: "Chain ID",
406
- description: "Blockchain chain ID"
315
+ // src/shared/entities/participant.schema.ts
316
+ var ParticipantSchema = zod.z.strictObject({
317
+ id_hash: Sha256HashSchema.meta({
318
+ title: "Participant ID Hash",
319
+ description: "Anonymized identifier for the participant"
407
320
  }),
408
- network_name: zod.z.string().min(5).max(100).meta({
409
- title: "Network Name",
410
- description: "Name of the blockchain network"
321
+ name: ParticipantNameSchema.meta({
322
+ title: "Participant Name",
323
+ description: "Name of the participant"
411
324
  }),
412
- token_id: TokenIdSchema.meta({
413
- title: "Token ID",
414
- description: "NFT token ID"
325
+ roles: uniqueArrayItems(
326
+ ParticipantRoleSchema,
327
+ "Participant roles must be unique"
328
+ ).min(1).meta({
329
+ title: "Participant Roles",
330
+ description: "Roles of the participant in the waste management supply chain"
415
331
  })
416
332
  }).meta({
417
- title: "Blockchain Information",
418
- description: "Blockchain-specific information for the NFT"
333
+ title: "Participant",
334
+ description: "A participant in the waste management supply chain"
419
335
  });
420
- var ExternalLinkSchema = zod.z.strictObject({
421
- label: zod.z.string().min(1).max(50).meta({
422
- title: "Link Label",
423
- description: "Display name for the external link"
336
+ var PrecisionLevelSchema = zod.z.enum(["exact", "neighborhood", "city", "region", "country"]).meta({
337
+ title: "Coordinate Precision Level",
338
+ description: "Level of coordinate precision",
339
+ examples: ["city", "exact", "neighborhood"]
340
+ });
341
+ var CoordinatesSchema = zod.z.strictObject({
342
+ latitude: LatitudeSchema,
343
+ longitude: LongitudeSchema,
344
+ precision_level: PrecisionLevelSchema
345
+ }).meta({
346
+ title: "Coordinates",
347
+ description: "GPS coordinates of the location"
348
+ });
349
+ var LocationSchema = zod.z.strictObject({
350
+ id_hash: Sha256HashSchema.meta({
351
+ title: "Location ID Hash",
352
+ description: "Anonymized identifier for the location"
424
353
  }),
425
- url: zod.z.url("Must be a valid URI").meta({
426
- title: "Link URL",
427
- description: "Direct URI to the linked resource"
354
+ municipality: MunicipalitySchema,
355
+ administrative_division: AdministrativeDivisionSchema,
356
+ administrative_division_code: IsoAdministrativeDivisionCodeSchema.optional(),
357
+ country: CountryNameSchema,
358
+ country_code: IsoCountryCodeSchema,
359
+ responsible_participant_id_hash: Sha256HashSchema.meta({
360
+ title: "Responsible Participant ID Hash",
361
+ description: "Anonymized ID of the participant responsible for this location"
428
362
  }),
429
- description: zod.z.string().min(10).max(100).optional().meta({
430
- title: "Link Description",
431
- description: "Optional context about what the link provides"
432
- })
363
+ coordinates: CoordinatesSchema,
364
+ facility_type: FacilityTypeSchema.optional()
433
365
  }).meta({
434
- title: "External Link",
435
- description: "External link with label and description"
366
+ title: "Location",
367
+ description: "Geographic location with address and coordinate information"
436
368
  });
437
- var NftAttributeSchema = zod.z.strictObject({
438
- trait_type: zod.z.string().max(50).meta({
439
- title: "Trait Type",
440
- description: "Name of the trait or attribute"
369
+ var MethodologyComplianceSchema = zod.z.enum(["PASSED", "FAILED"]).meta({
370
+ title: "Methodology Compliance",
371
+ description: "Result of methodology compliance check",
372
+ examples: ["PASSED", "FAILED"]
373
+ });
374
+ var AuditReferenceSchema = zod.z.strictObject({
375
+ date: IsoDateSchema.meta({
376
+ title: "Audit Date",
377
+ description: "Date when the audit was completed"
441
378
  }),
442
- value: zod.z.union([zod.z.string(), zod.z.number(), zod.z.boolean()]).meta({
443
- title: "Trait Value",
444
- description: "Value of the trait - can be string, number, or boolean"
379
+ external_id: ExternalIdSchema.meta({
380
+ title: "Audit External ID",
381
+ description: "Unique identifier for the audit"
445
382
  }),
446
- display_type: zod.z.enum(["number", "date", "boost_number", "boost_percentage"]).optional().meta({
447
- title: "Display Type",
448
- description: "How the trait should be displayed in marketplace UIs"
383
+ external_url: ExternalUrlSchema.meta({
384
+ title: "Audit External URL",
385
+ description: "URL to view the audit on Carrot Explorer"
449
386
  }),
450
- max_value: NonNegativeFloatSchema.optional().meta({
451
- title: "Max Value",
452
- description: "Maximum possible value for numeric traits"
387
+ methodology_compliance: MethodologyComplianceSchema.meta({
388
+ title: "Methodology Compliance",
389
+ description: "Result of methodology compliance check"
390
+ }),
391
+ rules_executed: NonNegativeIntegerSchema.meta({
392
+ title: "Rules Executed",
393
+ description: "Number of rules executed during the audit"
394
+ }),
395
+ report: IpfsUriSchema.meta({
396
+ title: "Audit Report",
397
+ description: "IPFS URI of the audit report"
453
398
  })
454
399
  }).meta({
455
- title: "NFT Attribute",
456
- description: "NFT attribute or trait with type and value"
400
+ title: "Audit Reference",
401
+ description: "Reference to an audit record"
457
402
  });
458
- var NftIpfsSchema = BaseIpfsSchema.safeExtend({
459
- schema: BaseIpfsSchema.shape.schema.safeExtend({
460
- type: NftSchemaTypeSchema.meta({
461
- title: "NFT Schema Type",
462
- description: "Type/category of this NFT schema"
463
- })
464
- }),
465
- blockchain: BlockchainReferenceSchema,
466
- name: zod.z.string().min(1).max(100).meta({
467
- title: "NFT Name",
468
- description: "Full display name for this NFT, including extra context",
469
- examples: [
470
- "MassID #123 \u2022 Organic \u2022 3.0t",
471
- "RecycledID #456 \u2022 Plastic \u2022 2.5t",
472
- "GasID #789 \u2022 Methane \u2022 1000 m\xB3"
473
- ]
403
+ var GasIDReferenceSchema = zod.z.strictObject({
404
+ external_id: ExternalIdSchema.meta({
405
+ title: "GasID External ID",
406
+ description: "Unique identifier for the GasID"
474
407
  }),
475
- short_name: zod.z.string().min(1).max(50).meta({
476
- title: "Short Name",
477
- description: "Compact name for UI summaries, tables, or tooltips",
478
- examples: ["MassID #123", "RecycledID #456", "GasID #789"]
408
+ token_id: TokenIdSchema.meta({
409
+ title: "GasID Token ID",
410
+ description: "NFT token ID of the GasID"
479
411
  }),
480
- description: zod.z.string().min(10).max(500).meta({
481
- title: "Description",
482
- description: "Human-readable summary of the NFT's role and context. Ideally, maximum 300 characters.",
483
- examples: [
484
- "This MassID represents 3 metric tons of organic food waste from Enlatados Produ\xE7\xE3o, tracked through complete chain of custody from generation to composting.",
485
- "This RecycledID represents 2.5 metric tons of recycled plastic bottles processed by Green Solutions Ltd."
486
- ]
487
- }),
488
- image: IpfsUriSchema.meta({
489
- title: "Image URI",
490
- description: "IPFS URI pointing to the preview image"
412
+ external_url: ExternalUrlSchema.meta({
413
+ title: "GasID External URL",
414
+ description: "URL to view the GasID on Carrot Explorer"
491
415
  }),
492
- background_color: HexColorSchema.optional().meta({
493
- title: "Background Color",
494
- description: "Hex color code for marketplace background display"
416
+ uri: IpfsUriSchema.meta({
417
+ title: "GasID IPFS URI",
418
+ description: "IPFS URI of the GasID record"
419
+ })
420
+ }).meta({
421
+ title: "GasID Reference",
422
+ description: "Reference to a GasID record"
423
+ });
424
+ var MassIDReferenceSchema = zod.z.strictObject({
425
+ external_id: ExternalIdSchema.meta({
426
+ title: "MassID External ID",
427
+ description: "Unique identifier for the MassID"
495
428
  }),
496
- animation_url: IpfsUriSchema.optional().meta({
497
- title: "Animation URL",
498
- description: "IPFS URI pointing to an animated or interactive media file",
499
- examples: [
500
- "ipfs://QmAnimation123/mass-id-animation.mp4",
501
- "ipfs://QmInteractive456/recycled-visualization.webm"
502
- ]
429
+ token_id: TokenIdSchema.meta({
430
+ title: "MassID Token ID",
431
+ description: "NFT token ID of the MassID"
503
432
  }),
504
- external_links: uniqueBy(
505
- ExternalLinkSchema,
506
- (link) => link.url,
507
- "External link URLs must be unique"
508
- ).max(10).optional().meta({
509
- title: "External Links",
510
- description: "Optional list of public resource links with labels",
511
- examples: [
512
- [
513
- {
514
- label: "Carrot Explorer",
515
- url: "https://explore.carrot.eco/document/ad44dd3f-f176-4b98-bf78-5ee6e77d0530",
516
- description: "Complete chain of custody and audit trail"
517
- },
518
- {
519
- label: "Carrot White Paper",
520
- url: "https://carrot.eco/whitepaper.pdf",
521
- description: "Carrot Foundation technical and impact white paper"
522
- }
523
- ]
524
- ]
433
+ external_url: ExternalUrlSchema.meta({
434
+ title: "MassID External URL",
435
+ description: "URL to view the MassID on Carrot Explorer"
525
436
  }),
526
- attributes: uniqueBy(
527
- NftAttributeSchema,
528
- (attr) => attr.trait_type,
529
- "Attribute trait_type values must be unique"
530
- ).meta({
531
- title: "NFT Attributes",
532
- description: "List of visual traits and filterable attributes compatible with NFT marketplaces",
533
- examples: [
534
- [
535
- {
536
- trait_type: "Waste Type",
537
- value: "Organic"
538
- },
539
- {
540
- trait_type: "Waste Subtype",
541
- value: "Food, Food Waste and Beverages"
542
- },
543
- {
544
- trait_type: "Weight (kg)",
545
- value: 3e3,
546
- display_type: "number"
547
- },
548
- {
549
- trait_type: "Origin Country",
550
- value: "Brazil"
551
- },
552
- {
553
- trait_type: "Pick-up Date",
554
- value: "2024-12-05",
555
- display_type: "date"
556
- }
557
- ]
558
- ]
437
+ uri: IpfsUriSchema.meta({
438
+ title: "MassID IPFS URI",
439
+ description: "IPFS URI of the MassID record"
559
440
  })
560
441
  }).meta({
561
- title: "NFT IPFS Record",
562
- description: "NFT-specific fields for Carrot IPFS records"
563
- });
564
-
565
- // src/mass-id/mass-id.attributes.ts
566
- var MassIDAttributeWasteTypeSchema = NftAttributeSchema.extend({
567
- trait_type: zod.z.literal("Waste Type"),
568
- value: WasteTypeSchema
569
- }).meta({
570
- title: "Waste Type Attribute",
571
- description: "Waste type attribute"
572
- });
573
- var MassIDAttributeWasteSubtypeSchema = NftAttributeSchema.extend({
574
- trait_type: zod.z.literal("Waste Subtype"),
575
- value: WasteSubtypeSchema
576
- }).meta({
577
- title: "Waste Subtype Attribute",
578
- description: "Waste subtype attribute"
579
- });
580
- var MassIDAttributeWeightSchema = NftAttributeSchema.extend({
581
- trait_type: zod.z.literal("Weight (kg)"),
582
- value: WeightKgSchema,
583
- display_type: zod.z.literal("number")
584
- }).meta({
585
- title: "Weight Attribute",
586
- description: "Weight attribute with numeric display"
442
+ title: "MassID Reference",
443
+ description: "Reference to a MassID record"
587
444
  });
588
- var MassIDAttributeOriginCountrySchema = NftAttributeSchema.extend({
589
- trait_type: zod.z.literal("Origin Country"),
590
- value: NonEmptyStringSchema.max(100).meta({
591
- title: "Origin Country Value",
592
- description: "Country where the waste was generated",
593
- examples: ["Brazil", "United States", "Germany", "Japan"]
445
+ var MethodologyReferenceSchema = zod.z.strictObject({
446
+ external_id: ExternalIdSchema.meta({
447
+ title: "Methodology External ID",
448
+ description: "Unique identifier for the methodology"
449
+ }),
450
+ name: NonEmptyStringSchema.min(5).max(150).meta({
451
+ title: "Methodology Name",
452
+ description: "Human-readable name of the methodology",
453
+ examples: ["BOLD Carbon (CH\u2084)", "BOLD Recycling"]
454
+ }),
455
+ version: SemanticVersionSchema.meta({
456
+ title: "Methodology Version",
457
+ description: "Version of the methodology"
458
+ }),
459
+ external_url: ExternalUrlSchema.meta({
460
+ title: "Methodology External URL",
461
+ description: "URL to view the methodology on Carrot Explorer"
462
+ }),
463
+ uri: IpfsUriSchema.optional().meta({
464
+ title: "Methodology IPFS URI",
465
+ description: "IPFS URI to the methodology record"
594
466
  })
595
467
  }).meta({
596
- title: "Origin Country Attribute",
597
- description: "Origin country attribute"
468
+ title: "Methodology Reference",
469
+ description: "Reference to a methodology record"
598
470
  });
599
- var MassIDAttributeOriginMunicipalitySchema = NftAttributeSchema.extend({
600
- trait_type: zod.z.literal("Origin Municipality"),
601
- value: NonEmptyStringSchema.max(100).meta({
602
- title: "Origin Municipality Value",
603
- description: "Municipality where the waste was generated",
604
- examples: ["S\xE3o Paulo", "New York", "Berlin", "Tokyo"]
471
+ var WasteClassificationSchema = zod.z.strictObject({
472
+ primary_type: WasteTypeSchema.meta({
473
+ title: "Source Waste Primary Type",
474
+ description: "Primary type of the source waste"
475
+ }),
476
+ subtype: WasteSubtypeSchema.meta({
477
+ title: "Source Waste Subtype",
478
+ description: "Subtype of the source waste"
479
+ }),
480
+ net_weight_kg: WeightKgSchema.meta({
481
+ title: "Source Waste Net Weight",
482
+ description: "Net weight of the source waste"
605
483
  })
606
484
  }).meta({
607
- title: "Origin Municipality Attribute",
608
- description: "Origin municipality attribute"
485
+ title: "Waste Classification",
486
+ description: "Classification of the source waste (MassID)"
609
487
  });
610
- var MassIDAttributeOriginDivisionSchema = NftAttributeSchema.extend({
611
- trait_type: zod.z.literal("Origin Administrative Division"),
612
- value: NonEmptyStringSchema.max(100).meta({
613
- title: "Origin Division Value",
614
- description: "Administrative division (state/province) where the waste was generated",
615
- examples: ["S\xE3o Paulo", "California", "Bavaria"]
488
+ var AccreditedParticipantSchema = zod.z.strictObject({
489
+ participant_id: UuidSchema.meta({
490
+ title: "Participant ID",
491
+ description: "Unique identifier for the participant"
492
+ }),
493
+ name: ParticipantNameSchema.meta({
494
+ title: "Participant Name",
495
+ description: "Name of the participant"
496
+ }),
497
+ role: ParticipantRoleSchema.meta({
498
+ title: "Participant Role",
499
+ description: "Role of the participant in the supply chain"
500
+ }),
501
+ accreditation_id: UuidSchema.meta({
502
+ title: "Accreditation ID",
503
+ description: "Unique identifier for the participant accreditation"
504
+ }),
505
+ external_url: ExternalUrlSchema.meta({
506
+ title: "Participant Accreditation External URL",
507
+ description: "URL to view the participant accreditation on Carrot Explorer"
616
508
  })
617
509
  }).meta({
618
- title: "Origin Administrative Division Attribute",
619
- description: "Origin administrative division attribute"
510
+ title: "Accredited Participant",
511
+ description: "Participant with valid accreditation in the supply chain"
620
512
  });
621
- var MassIDAttributeVehicleTypeSchema = NftAttributeSchema.extend({
622
- trait_type: zod.z.literal("Vehicle Type"),
623
- value: NonEmptyStringSchema.max(100).meta({
624
- title: "Vehicle Type Value",
625
- description: "Type of vehicle used for waste transportation",
626
- examples: ["Garbage Truck", "Box Truck", "Flatbed Truck", "Roll-off Truck"]
513
+ var AccreditedParticipantsSchema = zod.z.array(AccreditedParticipantSchema).min(1).meta({
514
+ title: "Accredited Participants",
515
+ description: "List of participants with valid accreditations"
516
+ });
517
+ var RewardAllocationSchema = zod.z.strictObject({
518
+ participant_id: UuidSchema.meta({
519
+ title: "Participant ID",
520
+ description: "Unique identifier for the participant receiving the reward"
521
+ }),
522
+ participant_name: ParticipantNameSchema.meta({
523
+ title: "Participant Name",
524
+ description: "Name of the participant receiving the reward"
525
+ }),
526
+ role: ParticipantRoleSchema.meta({
527
+ title: "Participant Role",
528
+ description: "Role of the participant in the supply chain"
529
+ }),
530
+ reward_percentage: PercentageSchema.meta({
531
+ title: "Reward Percentage",
532
+ description: "Reward percentage allocated to the participant"
533
+ }),
534
+ large_business_discount_applied: zod.z.boolean().optional().meta({
535
+ title: "Large Business Discount Applied",
536
+ description: "Whether the large business discount was applied"
537
+ }),
538
+ effective_percentage: PercentageSchema.meta({
539
+ title: "Effective Percentage",
540
+ description: "Effective percentage of the reward after discounts"
627
541
  })
628
542
  }).meta({
629
- title: "Vehicle Type Attribute",
630
- description: "Vehicle type attribute"
543
+ title: "Reward Allocation",
544
+ description: "Reward allocation for a specific participant"
631
545
  });
632
- var MassIDAttributeRecyclingMethodSchema = NftAttributeSchema.extend({
633
- trait_type: zod.z.literal("Recycling Method"),
634
- value: NonEmptyStringSchema.max(100).meta({
635
- title: "Recycling Method Value",
636
- description: "Method used for recycling or processing the waste",
546
+ var DistributionNotesSchema = zod.z.strictObject({
547
+ large_business_discount_applied: NonEmptyStringSchema.optional().meta({
548
+ title: "Large Business Discount Applied",
549
+ description: "Description of the large business discount applied",
637
550
  examples: [
638
- "Composting",
639
- "Mechanical Recycling",
640
- "Incineration with Energy Recovery"
551
+ "50% reduction applied to participants with >$4M annual revenue"
552
+ ]
553
+ }),
554
+ redirected_rewards: NonEmptyStringSchema.optional().meta({
555
+ title: "Redirected Rewards",
556
+ description: "Description of the redirected rewards",
557
+ examples: [
558
+ "Discounted rewards from large businesses redirected to accredited NGOs"
641
559
  ]
642
560
  })
643
561
  }).meta({
644
- title: "Recycling Method Attribute",
645
- description: "Recycling method attribute"
646
- });
647
- var MassIDAttributeProcessingTimeSchema = NftAttributeSchema.extend({
648
- trait_type: zod.z.literal("Processing Time (hours)"),
649
- value: HoursSchema,
650
- trait_description: NonEmptyStringSchema.max(200).optional().meta({
651
- title: "Processing Time Description",
652
- description: "Custom description for the processing time"
653
- })
654
- }).meta({
655
- title: "Processing Time Attribute",
656
- description: "Processing time attribute with optional trait description"
562
+ title: "Distribution Notes",
563
+ description: "Additional notes about the reward distribution"
657
564
  });
658
- var MassIDAttributeLocalWasteClassificationIdSchema = NftAttributeSchema.extend({
659
- trait_type: zod.z.literal("Local Waste Classification ID"),
660
- value: NonEmptyStringSchema.max(100).meta({
661
- title: "Local Waste Classification ID Value",
662
- description: "Local or regional waste classification identifier",
663
- examples: ["04 02 20", "IBAMA-A001", "EWC-150101"]
565
+ var ParticipantRewardsSchema = zod.z.strictObject({
566
+ distribution_basis: NonEmptyStringSchema.max(200).meta({
567
+ title: "Distribution Basis",
568
+ description: "Basis for the rewards distribution"
569
+ }),
570
+ reward_allocations: zod.z.array(RewardAllocationSchema).min(1).meta({
571
+ title: "Reward Allocations",
572
+ description: "Rewards percentage allocated to each participant"
573
+ }),
574
+ distribution_notes: DistributionNotesSchema.optional().meta({
575
+ title: "Distribution Notes",
576
+ description: "Additional notes about the reward distribution"
664
577
  })
665
578
  }).meta({
666
- title: "Local Waste Classification ID Attribute",
667
- description: "Local waste classification ID attribute"
579
+ title: "Participant Rewards",
580
+ description: "Rewards distribution to participants"
668
581
  });
669
- var MassIDAttributeRecyclingManifestCodeSchema = NftAttributeSchema.extend({
670
- trait_type: zod.z.literal("Recycling Manifest Code"),
671
- value: NonEmptyStringSchema.max(100).meta({
672
- title: "Recycling Manifest Code Value",
673
- description: "Concatenated recycling manifest code (Document Type + Document Number)",
674
- examples: ["CDF-2353", "RC-12345", "REC-MANIFEST-789"]
675
- })
676
- }).meta({
677
- title: "Recycling Manifest Code Attribute",
678
- description: "Recycling manifest code attribute (optional)"
582
+ var SchemaHashSchema = zod.z.union([
583
+ Keccak256HashSchema,
584
+ zod.z.string().regex(
585
+ /^0x[a-fA-F0-9]{64}$/,
586
+ "Must be a Keccak256 hash as 0x-prefixed hex string"
587
+ )
588
+ ]).meta({
589
+ title: "Schema Hash",
590
+ description: "Keccak256 hash of the JSON Schema this record was validated against",
591
+ examples: [
592
+ "ac08c3cf2e175e55961d6affdb38bc24591b84ceef7f3707c69ae3d52c148b2f",
593
+ "0xac08c3cf2e175e55961d6affdb38bc24591b84ceef7f3707c69ae3d52c148b2f"
594
+ ]
679
595
  });
680
- var MassIDAttributeTransportManifestCodeSchema = NftAttributeSchema.extend({
681
- trait_type: zod.z.literal("Transport Manifest Code"),
682
- value: NonEmptyStringSchema.max(100).meta({
683
- title: "Transport Manifest Code Value",
684
- description: "Concatenated transport manifest code (Document Type + Document Number)",
685
- examples: ["MTR-4126", "TRN-67890", "TRANS-MANIFEST-456"]
596
+ var SchemaInfoSchema = zod.z.strictObject({
597
+ hash: SchemaHashSchema,
598
+ type: RecordSchemaTypeSchema.meta({
599
+ title: "Schema Type",
600
+ description: "Type/category of this schema"
601
+ }),
602
+ version: SemanticVersionSchema.meta({
603
+ title: "Schema Version",
604
+ description: "Version of the schema, using semantic versioning"
686
605
  })
687
606
  }).meta({
688
- title: "Transport Manifest Code Attribute",
689
- description: "Transport manifest code attribute (optional)"
607
+ title: "Schema Information"
690
608
  });
691
- var MassIDAttributeWeighingCaptureMethodSchema = NftAttributeSchema.extend({
692
- trait_type: zod.z.literal("Weighing Capture Method"),
693
- value: NonEmptyStringSchema.max(100).meta({
694
- title: "Weighing Capture Method Value",
695
- description: "Method used to capture weight data",
696
- examples: ["Digital", "Manual", "Automated", "Electronic Scale"]
609
+ var RecordCreatorSchema = zod.z.strictObject({
610
+ name: zod.z.string().meta({
611
+ title: "Creator Name",
612
+ description: "Company or individual name that created this record",
613
+ examples: ["Carrot Foundation"]
614
+ }),
615
+ id: UuidSchema.meta({
616
+ title: "Creator ID",
617
+ description: "Unique identifier for the creator"
697
618
  })
698
619
  }).meta({
699
- title: "Weighing Capture Method Attribute",
700
- description: "Weighing capture method attribute (optional)"
620
+ title: "Creator",
621
+ description: "Entity that created this record"
701
622
  });
702
- var MassIDAttributeScaleTypeSchema = NftAttributeSchema.extend({
703
- trait_type: zod.z.literal("Scale Type"),
704
- value: NonEmptyStringSchema.max(100).meta({
705
- title: "Scale Type Value",
706
- description: "Type of scale used for weighing",
623
+ var RecordRelationshipSchema = zod.z.strictObject({
624
+ target_uri: IpfsUriSchema.meta({
625
+ title: "Target IPFS URI",
626
+ description: "Target IPFS URI of the referenced record"
627
+ }),
628
+ type: RecordRelationshipTypeSchema.meta({
629
+ title: "Relationship Type",
630
+ description: "Type of relationship to the referenced record"
631
+ }),
632
+ description: zod.z.string().optional().meta({
633
+ title: "Relationship Description",
634
+ description: "Human-readable description of the relationship",
707
635
  examples: [
708
- "Weighbridge (Truck Scale)",
709
- "Floor Scale",
710
- "Bench Scale",
711
- "Crane Scale"
636
+ "This record supersedes the previous version",
637
+ "Related carbon credit batch",
638
+ "Source document for this verification",
639
+ "Child record derived from this parent",
640
+ "Updated version of original record"
712
641
  ]
713
642
  })
714
643
  }).meta({
715
- title: "Scale Type Attribute",
716
- description: "Scale type attribute (optional)"
717
- });
718
- var MassIDAttributeContainerTypeSchema = NftAttributeSchema.extend({
719
- trait_type: zod.z.literal("Container Type"),
720
- value: NonEmptyStringSchema.max(100).meta({
721
- title: "Container Type Value",
722
- description: "Type of container used for waste storage or transport",
723
- examples: ["Truck", "Dumpster", "Roll-off Container", "Compactor", "Bin"]
724
- })
725
- }).meta({
726
- title: "Container Type Attribute",
727
- description: "Container type attribute (optional)"
728
- });
729
- var MassIDAttributePickUpDateSchema = NftAttributeSchema.extend({
730
- trait_type: zod.z.literal("Pick-up Date"),
731
- value: UnixTimestampSchema.meta({
732
- title: "Pick-up Date Value",
733
- description: "Unix timestamp in milliseconds when the waste was picked up from the source",
734
- examples: [17105184e5, 17040672e5, 17152704e5]
735
- }),
736
- display_type: zod.z.literal("date")
737
- }).meta({
738
- title: "Pick-up Date Attribute",
739
- description: "Pick-up date attribute with Unix timestamp"
740
- });
741
- var MassIDAttributeRecyclingDateSchema = NftAttributeSchema.extend({
742
- trait_type: zod.z.literal("Recycling Date"),
743
- value: UnixTimestampSchema.meta({
744
- title: "Recycling Date Value",
745
- description: "Unix timestamp in milliseconds when the waste was recycled/processed",
746
- examples: [17106048e5, 17041536e5, 17153568e5]
747
- }),
748
- display_type: zod.z.literal("date")
749
- }).meta({
750
- title: "Recycling Date Attribute",
751
- description: "Recycling date attribute with Unix timestamp"
752
- });
753
- var MassIDAttributesSchema = uniqueBy(
754
- zod.z.union([
755
- MassIDAttributeWasteTypeSchema,
756
- MassIDAttributeWasteSubtypeSchema,
757
- MassIDAttributeWeightSchema,
758
- MassIDAttributeOriginCountrySchema,
759
- MassIDAttributeOriginMunicipalitySchema,
760
- MassIDAttributeOriginDivisionSchema,
761
- MassIDAttributeVehicleTypeSchema,
762
- MassIDAttributeRecyclingMethodSchema,
763
- MassIDAttributeProcessingTimeSchema,
764
- MassIDAttributeLocalWasteClassificationIdSchema,
765
- MassIDAttributeRecyclingManifestCodeSchema,
766
- MassIDAttributeTransportManifestCodeSchema,
767
- MassIDAttributeWeighingCaptureMethodSchema,
768
- MassIDAttributeScaleTypeSchema,
769
- MassIDAttributeContainerTypeSchema,
770
- MassIDAttributePickUpDateSchema,
771
- MassIDAttributeRecyclingDateSchema
772
- ]),
773
- (attr) => attr.trait_type
774
- ).min(12).max(17).meta({
775
- title: "MassID Attributes",
776
- description: "MassID NFT attributes array containing attributes selected from the available attribute types. The schema validates array length but does not enforce which specific attributes must be present."
777
- });
778
- var PrecisionLevelSchema = zod.z.enum(["exact", "neighborhood", "city", "region", "country"]).meta({
779
- title: "Precision Level",
780
- description: "Level of coordinate precision",
781
- examples: ["city", "exact", "neighborhood"]
644
+ title: "Relationship",
645
+ description: "Relationship to another IPFS record"
782
646
  });
783
- var CoordinatesSchema = zod.z.strictObject({
784
- latitude: LatitudeSchema.meta({
785
- title: "Latitude",
786
- description: "GPS latitude coordinate"
647
+ var RecordEnvironmentSchema = zod.z.strictObject({
648
+ blockchain_network: zod.z.enum(["mainnet", "testnet"]).meta({
649
+ title: "Blockchain Network",
650
+ description: "Blockchain Network Environment"
787
651
  }),
788
- longitude: LongitudeSchema.meta({
789
- title: "Longitude",
790
- description: "GPS longitude coordinate"
652
+ deployment: zod.z.enum(["production", "development", "testing"]).meta({
653
+ title: "Deployment Environment",
654
+ description: "System environment where this record was generated"
791
655
  }),
792
- precision_level: PrecisionLevelSchema
656
+ data_set_name: zod.z.enum(["TEST", "PROD"]).meta({
657
+ title: "Data Set Name",
658
+ description: "Name of the data set for this record"
659
+ })
793
660
  }).meta({
794
- title: "Coordinates",
795
- description: "GPS coordinates of the location"
661
+ title: "Environment",
662
+ description: "Environment information"
796
663
  });
797
- var LocationSchema = zod.z.strictObject({
798
- id_hash: Sha256HashSchema.meta({
799
- title: "Location ID Hash",
800
- description: "Anonymized identifier for the location"
664
+ var BaseIpfsSchema = zod.z.strictObject({
665
+ $schema: zod.z.url("Must be a valid URI").meta({
666
+ title: "JSON Schema URI",
667
+ description: "URI of the JSON Schema used to validate this record",
668
+ example: "https://raw.githubusercontent.com/carrot-foundation/schemas/refs/heads/main/schemas/ipfs/shared/base/base.schema.json"
801
669
  }),
802
- municipality: NonEmptyStringSchema.max(50).meta({
803
- title: "Municipality",
804
- description: "Municipality or city name",
805
- examples: ["New York", "S\xE3o Paulo", "London", "Tokyo"]
670
+ schema: SchemaInfoSchema,
671
+ created_at: IsoTimestampSchema.meta({
672
+ title: "Created At",
673
+ description: "ISO 8601 creation timestamp for this record"
806
674
  }),
807
- administrative_division: NonEmptyStringSchema.max(50).meta({
808
- title: "Administrative Division",
809
- description: "State, province, or administrative region",
810
- examples: ["California", "Ontario", "Bavaria", "Queensland"]
675
+ external_id: ExternalIdSchema.meta({
676
+ title: "External ID",
677
+ description: "Off-chain reference ID (UUID from Carrot backend)"
811
678
  }),
812
- administrative_division_code: IsoAdministrativeDivisionCodeSchema.optional().meta({
813
- title: "Administrative Division Code",
814
- description: "ISO 3166-2 administrative division code"
679
+ external_url: ExternalUrlSchema.meta({
680
+ title: "External URL",
681
+ description: "External URL of the content"
815
682
  }),
816
- country: NonEmptyStringSchema.max(50).meta({
817
- title: "Country",
818
- description: "Full country name in English",
819
- examples: ["United States", "Canada", "Germany", "Australia"]
683
+ original_content_hash: Sha256HashSchema.meta({
684
+ title: "Original Content Hash",
685
+ description: "SHA-256 hash of the original JSON content including private data before schema validation"
820
686
  }),
821
- country_code: IsoCountryCodeSchema.meta({
822
- title: "Country Code",
823
- description: "ISO 3166-1 alpha-2 country code"
687
+ content_hash: Sha256HashSchema.meta({
688
+ title: "Content Hash",
689
+ description: "SHA-256 hash of RFC 8785 canonicalized JSON after schema validation"
824
690
  }),
825
- responsible_participant_id_hash: Sha256HashSchema.meta({
826
- title: "Responsible Participant ID Hash",
827
- description: "Anonymized ID of the participant responsible for this location"
691
+ creator: RecordCreatorSchema.optional(),
692
+ relationships: zod.z.array(RecordRelationshipSchema).optional().meta({
693
+ title: "Relationships",
694
+ description: "References to other IPFS records this record relates to"
828
695
  }),
829
- coordinates: CoordinatesSchema,
830
- facility_type: FacilityTypeSchema.optional().meta({
831
- title: "Facility Type",
832
- description: "Type of facility at this location"
696
+ environment: RecordEnvironmentSchema.optional(),
697
+ data: zod.z.record(zod.z.string(), zod.z.unknown()).optional().meta({
698
+ title: "Custom Data",
699
+ description: "Custom data block that includes the record's data"
833
700
  })
834
701
  }).meta({
835
- title: "Location",
836
- description: "Geographic location with address and coordinate information"
702
+ title: "Base IPFS Record",
703
+ description: "Base fields for all Carrot IPFS records, providing common structure for any JSON content stored in IPFS"
837
704
  });
838
- var ParticipantSchema = zod.z.strictObject({
839
- id_hash: Sha256HashSchema.meta({
840
- title: "Participant ID Hash",
841
- description: "Anonymized identifier for the participant"
705
+ var NftSchemaTypeSchema = RecordSchemaTypeSchema.extract([
706
+ "MassID",
707
+ "RecycledID",
708
+ "GasID",
709
+ "PurchaseID"
710
+ ]).meta({
711
+ title: "NFT Schema Type",
712
+ description: "Type of schema for NFT records"
713
+ });
714
+ var BlockchainReferenceSchema = zod.z.strictObject({
715
+ smart_contract_address: EthereumAddressSchema.meta({
716
+ title: "Smart Contract Address"
842
717
  }),
843
- name: ParticipantNameSchema.meta({
844
- title: "Participant Name",
845
- description: "Name of the participant"
718
+ chain_id: BlockchainChainIdSchema.meta({
719
+ title: "Chain ID",
720
+ description: "Blockchain chain ID"
846
721
  }),
847
- roles: uniqueArrayItems(
848
- ParticipantRoleSchema,
849
- "Participant roles must be unique"
850
- ).min(1).meta({
851
- title: "Participant Roles",
852
- description: "Roles of the participant in the waste management supply chain"
722
+ network_name: zod.z.string().min(5).max(100).meta({
723
+ title: "Network Name",
724
+ description: "Name of the blockchain network"
725
+ }),
726
+ token_id: TokenIdSchema.meta({
727
+ title: "Token ID",
728
+ description: "NFT token ID"
853
729
  })
854
730
  }).meta({
855
- title: "Participant",
856
- description: "A participant in the waste management supply chain"
731
+ title: "Blockchain Information",
732
+ description: "Blockchain-specific information for the NFT"
857
733
  });
858
-
859
- // src/mass-id/mass-id.data.schema.ts
860
- var MassIDLocalClassificationSchema = zod.z.strictObject({
861
- code: NonEmptyStringSchema.max(20).meta({
862
- title: "Classification Code",
863
- description: "Local waste classification code",
864
- examples: ["20 01 01", "D001", "EWC-150101", "IBAMA-A001"]
734
+ var ExternalLinkSchema = zod.z.strictObject({
735
+ label: zod.z.string().min(1).max(50).meta({
736
+ title: "Link Label",
737
+ description: "Display name for the external link"
865
738
  }),
866
- description: NonEmptyStringSchema.max(200).meta({
867
- title: "Classification Description",
868
- description: "Local waste classification description",
869
- examples: [
870
- "Paper and cardboard packaging",
871
- "Ignitable waste",
872
- "Paper and cardboard packaging waste",
873
- "Municipal solid waste - organic fraction"
874
- ]
739
+ url: zod.z.url("Must be a valid URI").meta({
740
+ title: "Link URL",
741
+ description: "Direct URI to the linked resource"
875
742
  }),
876
- system: zod.z.enum(["IBAMA"]).meta({
877
- title: "Classification System",
878
- description: "Classification system name - currently supports IBAMA (Instituto Brasileiro do Meio Ambiente e dos Recursos Naturais Renov\xE1veis)",
879
- examples: ["IBAMA"]
743
+ description: zod.z.string().min(10).max(100).optional().meta({
744
+ title: "Link Description",
745
+ description: "Optional context about what the link provides"
880
746
  })
881
747
  }).meta({
882
- title: "Local Classification",
883
- description: "Local or regional waste classification codes and descriptions"
884
- });
885
- var MassIDMeasurementUnitSchema = zod.z.enum(["kg", "ton"]).meta({
886
- title: "Measurement Unit",
887
- description: "Unit of measurement for the waste quantity",
888
- examples: ["kg", "ton"]
748
+ title: "External Link",
749
+ description: "External link with label and description"
889
750
  });
890
- var MassIDWastePropertiesSchema = zod.z.strictObject({
891
- type: WasteTypeSchema.meta({
892
- title: "Waste Type",
893
- description: "Waste material category"
751
+ var NftAttributeSchema = zod.z.strictObject({
752
+ trait_type: zod.z.string().max(50).meta({
753
+ title: "Trait Type",
754
+ description: "Name of the trait or attribute"
894
755
  }),
895
- subtype: WasteSubtypeSchema.meta({
896
- title: "Waste Subtype",
897
- description: "Specific subcategory of waste material"
756
+ value: zod.z.union([zod.z.string(), zod.z.number(), zod.z.boolean()]).meta({
757
+ title: "Trait Value",
758
+ description: "Value of the trait - can be string, number, or boolean"
898
759
  }),
899
- local_classification: MassIDLocalClassificationSchema.optional(),
900
- measurement_unit: MassIDMeasurementUnitSchema,
901
- net_weight: NonNegativeFloatSchema.meta({
902
- title: "Net Weight",
903
- description: "Net weight of the waste batch in the specified measurement unit"
760
+ display_type: zod.z.enum(["number", "date", "boost_number", "boost_percentage"]).optional().meta({
761
+ title: "Display Type",
762
+ description: "How the trait should be displayed in marketplace UIs"
763
+ }),
764
+ max_value: NonNegativeFloatSchema.optional().meta({
765
+ title: "Max Value",
766
+ description: "Maximum possible value for numeric traits"
904
767
  })
905
768
  }).meta({
906
- title: "Waste Properties",
907
- description: "Standardized waste material properties and regulatory information"
908
- });
909
- var EventAttributeFormatSchema = zod.z.enum(["KILOGRAM", "DATE", "CURRENCY", "PERCENTAGE", "COORDINATE"]).meta({
910
- title: "Event Attribute Format",
911
- description: "Data format hint for proper display",
912
- examples: ["KILOGRAM", "DATE", "PERCENTAGE"]
769
+ title: "NFT Attribute",
770
+ description: "NFT attribute or trait with type and value"
913
771
  });
914
- var EventAttributeSchema = zod.z.strictObject({
915
- name: NonEmptyStringSchema.max(100).meta({
916
- title: "Attribute Name",
917
- description: "Event attribute name",
918
- examples: [
919
- "temperature",
920
- "humidity",
921
- "contamination_percentage",
922
- "quality_grade",
923
- "batch_number",
924
- "operator_id",
925
- "equipment_used",
926
- "processing_cost"
927
- ]
772
+ var NftIpfsSchema = BaseIpfsSchema.safeExtend({
773
+ schema: BaseIpfsSchema.shape.schema.safeExtend({
774
+ type: NftSchemaTypeSchema.meta({
775
+ title: "NFT Schema Type",
776
+ description: "Type/category of this NFT schema"
777
+ })
928
778
  }),
929
- value: zod.z.union([zod.z.string(), zod.z.number(), zod.z.boolean()]).optional().meta({
930
- title: "Attribute Value",
931
- description: "Event attribute value",
779
+ blockchain: BlockchainReferenceSchema,
780
+ name: zod.z.string().min(1).max(100).meta({
781
+ title: "NFT Name",
782
+ description: "Full display name for this NFT, including extra context",
932
783
  examples: [
933
- 25.5,
934
- "Grade A",
935
- true,
936
- "BATCH-2024-001",
937
- 12.75,
938
- "Shredder-X200",
939
- false,
940
- "OP-456"
784
+ "MassID #123 \u2022 Organic \u2022 3.0t",
785
+ "RecycledID #456 \u2022 Plastic \u2022 2.5t",
786
+ "GasID #789 \u2022 Methane \u2022 1000 m\xB3"
941
787
  ]
942
788
  }),
943
- preserved_sensitivity: zod.z.boolean().optional().meta({
944
- title: "Preserved Sensitivity",
945
- description: "Indicates if the attribute contains sensitive information that was preserved"
946
- }),
947
- format: EventAttributeFormatSchema.optional()
948
- }).meta({
949
- title: "Event Attribute",
950
- description: "Additional attribute specific to an event"
951
- });
952
- var EventAttachmentSchema = zod.z.strictObject({
953
- type: NonEmptyStringSchema.max(50).meta({
954
- title: "Attachment Type",
955
- description: "Type of supporting attachment",
956
- examples: [
957
- "Waste Transfer Note",
958
- "Certificate of Disposal",
959
- "Certificate of Final Destination",
960
- "Quality Assessment Report",
961
- "Transport Manifest",
962
- "Processing Receipt",
963
- "Environmental Permit",
964
- "Invoice"
965
- ]
789
+ short_name: zod.z.string().min(1).max(50).meta({
790
+ title: "Short Name",
791
+ description: "Compact name for UI summaries, tables, or tooltips",
792
+ examples: ["MassID #123", "RecycledID #456", "GasID #789"]
966
793
  }),
967
- document_number: NonEmptyStringSchema.max(50).optional().meta({
968
- title: "Document Number",
969
- description: "Official document number if applicable",
794
+ description: zod.z.string().min(10).max(500).meta({
795
+ title: "Description",
796
+ description: "Human-readable summary of the NFT's role and context. Ideally, maximum 300 characters.",
970
797
  examples: [
971
- "WTN-2024-001234",
972
- "CD-ENV-456789",
973
- "INV-2024-QTR1-789",
974
- "PERMIT-EPA-2024-001",
975
- "MANIFEST-DOT-567890"
798
+ "This MassID represents 3 metric tons of organic food waste from Enlatados Produ\xE7\xE3o, tracked through complete chain of custody from generation to composting.",
799
+ "This RecycledID represents 2.5 metric tons of recycled plastic bottles processed by Green Solutions Ltd."
976
800
  ]
977
801
  }),
978
- reference: NonEmptyStringSchema.meta({
979
- title: "Attachment Reference",
980
- description: "Reference to attachment (IPFS hash, file name, or external URL)",
981
- examples: [
982
- "QmYjtig7VJQ6XsnUjqqJvj7QaMcCAwtrgNdahSiFofrE7o",
983
- "waste_transfer_note_2024_001.pdf",
984
- "https://docs.example.com/certificates/disposal_cert_456.pdf",
985
- "bafybeigdyrzt5sfp7udm7hu76uh7y26nf3efuylqabf3oclgtqy55fbzdi",
986
- "processing_receipt_20240315.jpg"
987
- ]
802
+ image: IpfsUriSchema.meta({
803
+ title: "Image URI",
804
+ description: "IPFS URI pointing to the preview image"
988
805
  }),
989
- issue_timestamp: UnixTimestampSchema.optional().meta({
990
- title: "Issue Timestamp",
991
- description: "Unix timestamp in milliseconds when the attachment was issued",
992
- examples: [17105184e5, 17040672e5, 17152704e5]
806
+ background_color: HexColorSchema.optional().meta({
807
+ title: "Background Color",
808
+ description: "Hex color code for marketplace background display"
993
809
  }),
994
- issuer: NonEmptyStringSchema.max(100).optional().meta({
995
- title: "Attachment Issuer",
996
- description: "Entity that issued the attachment",
810
+ animation_url: IpfsUriSchema.optional().meta({
811
+ title: "Animation URL",
812
+ description: "IPFS URI pointing to an animated or interactive media file",
997
813
  examples: [
998
- "Environmental Protection Agency",
999
- "Waste Management Solutions Ltd",
1000
- "Green Recycling Corp",
1001
- "City Waste Authority",
1002
- "EcoProcess Industries",
1003
- "Regional Environmental Office"
814
+ "ipfs://QmAnimation123/mass-id-animation.mp4",
815
+ "ipfs://QmInteractive456/recycled-visualization.webm"
1004
816
  ]
1005
- })
1006
- }).meta({
1007
- title: "Event Attachment",
1008
- description: "Supporting event attachment"
1009
- });
1010
- var MassIDChainOfCustodyEventSchema = zod.z.strictObject({
1011
- event_id: UuidSchema.meta({
1012
- title: "Event ID",
1013
- description: "Unique event identifier"
1014
- }),
1015
- event_name: NonEmptyStringSchema.max(50).meta({
1016
- title: "Event Name",
1017
- description: "Name of custody or processing event",
1018
- examples: ["Sorting", "Processing", "Recycling", "Weighing"]
1019
817
  }),
1020
- description: NonEmptyStringSchema.max(200).optional().meta({
1021
- title: "Event Description",
1022
- description: "Detailed description of what happened during this event",
818
+ external_links: uniqueBy(
819
+ ExternalLinkSchema,
820
+ (link) => link.url,
821
+ "External link URLs must be unique"
822
+ ).max(10).optional().meta({
823
+ title: "External Links",
824
+ description: "Optional list of public resource links with labels",
1023
825
  examples: [
1024
- "Waste collected from residential area using collection truck",
1025
- "Material sorted into recyclable and non-recyclable fractions",
1026
- "Plastic waste processed through shredding and washing",
1027
- "Waste transferred to authorized recycling facility",
1028
- "Final disposal at licensed landfill site",
1029
- "Quality inspection and contamination assessment completed"
1030
- ]
1031
- }),
1032
- timestamp: UnixTimestampSchema.meta({
1033
- title: "Event Timestamp",
1034
- description: "Unix timestamp in milliseconds when the event occurred",
1035
- examples: [17105184e5, 17040672e5, 17152704e5]
1036
- }),
1037
- participant_id_hash: Sha256HashSchema.meta({
1038
- title: "Participant ID Hash",
1039
- description: "Reference to participant in the participants array"
1040
- }),
1041
- location_id_hash: Sha256HashSchema.meta({
1042
- title: "Location ID Hash",
1043
- description: "Reference to location in the locations array"
1044
- }),
1045
- weight: NonNegativeFloatSchema.optional().meta({
1046
- title: "Event Weight",
1047
- description: "Mass weight after this event"
1048
- }),
1049
- attributes: zod.z.array(EventAttributeSchema).optional().meta({
1050
- title: "Event Attributes",
1051
- description: "Additional attributes specific to this event"
1052
- }),
1053
- attachments: zod.z.array(EventAttachmentSchema).optional().meta({
1054
- title: "Event Attachments",
1055
- description: "Associated attachments for this event"
1056
- })
1057
- }).meta({
1058
- title: "Chain of Custody Event",
1059
- description: "Chain of custody event"
1060
- });
1061
- var MassIDChainOfCustodySchema = zod.z.strictObject({
1062
- events: zod.z.array(MassIDChainOfCustodyEventSchema).min(1).meta({
1063
- title: "Custody Events",
1064
- description: "Chronological sequence of custody transfer and processing events"
1065
- }),
1066
- total_duration_minutes: MinutesSchema.meta({
1067
- title: "Total Duration (minutes)",
1068
- description: "Total time from first to last event in minutes"
1069
- })
1070
- }).meta({
1071
- title: "Chain of Custody",
1072
- description: "Complete chain of custody tracking from waste generation to final processing"
1073
- });
1074
- var MassIDGeographicDataSchema = zod.z.strictObject({
1075
- from_location_id_hash: Sha256HashSchema.meta({
1076
- title: "From Location ID Hash",
1077
- description: "Reference hash of the location where the waste started movement"
1078
- }),
1079
- to_location_id_hash: Sha256HashSchema.meta({
1080
- title: "To Location ID Hash",
1081
- description: "Reference hash of the location where the waste ended movement"
1082
- }),
1083
- first_reported_timestamp: UnixTimestampSchema.meta({
1084
- title: "First Reported Timestamp",
1085
- description: "Unix timestamp in milliseconds when the waste was first reported/collected at the origin location",
1086
- examples: [17105184e5, 17040672e5, 17152704e5]
1087
- }),
1088
- last_reported_timestamp: UnixTimestampSchema.meta({
1089
- title: "Last Reported Timestamp",
1090
- description: "Unix timestamp in milliseconds when the waste was last reported/processed at the destination location",
1091
- examples: [17106048e5, 17041536e5, 17153568e5]
1092
- })
1093
- }).refine((data) => {
1094
- return data.first_reported_timestamp <= data.last_reported_timestamp;
1095
- }, "first_reported_timestamp must be before or equal to last_reported_timestamp").meta({
1096
- title: "Geographic Data",
1097
- description: "Simplified geographic information tracking waste movement from origin to destination with temporal bounds"
1098
- });
1099
- var MassIDDataSchema = zod.z.strictObject({
1100
- waste_properties: MassIDWastePropertiesSchema,
1101
- locations: uniqueBy(
1102
- LocationSchema,
1103
- (loc) => loc.id_hash,
1104
- "Location ID hashes must be unique"
1105
- ).min(1).meta({
1106
- title: "Locations",
1107
- description: "All locations referenced in this MassID, indexed by ID"
1108
- }),
1109
- participants: uniqueBy(
1110
- ParticipantSchema,
1111
- (p) => p.id_hash,
1112
- "Participant ID hashes must be unique"
1113
- ).min(1).meta({
1114
- title: "Participants",
1115
- description: "All participants referenced in this MassID, indexed by ID"
1116
- }),
1117
- chain_of_custody: MassIDChainOfCustodySchema,
1118
- geographic_data: MassIDGeographicDataSchema
1119
- }).refine((data) => {
1120
- const participantIdSet = new Set(
1121
- data.participants.map((participant) => participant.id_hash)
1122
- );
1123
- const eventParticipantIds = data.chain_of_custody.events.map(
1124
- (event) => event.participant_id_hash
1125
- );
1126
- const allEventParticipantsExist = eventParticipantIds.every(
1127
- (participantId) => participantIdSet.has(participantId)
1128
- );
1129
- return allEventParticipantsExist;
1130
- }, "All participant ID hashes in chain of custody events must exist in participants array").refine((data) => {
1131
- const locationIdSet = new Set(
1132
- data.locations.map((location) => location.id_hash)
1133
- );
1134
- const eventLocationIds = data.chain_of_custody.events.map(
1135
- (event) => event.location_id_hash
1136
- );
1137
- const allEventLocationsExist = eventLocationIds.every(
1138
- (locationId) => locationIdSet.has(locationId)
1139
- );
1140
- return allEventLocationsExist;
1141
- }, "All location ID hashes in chain of custody events must exist in locations array").meta({
1142
- title: "MassID Data",
1143
- description: "MassID data containing waste tracking and chain of custody information"
826
+ [
827
+ {
828
+ label: "Carrot Explorer",
829
+ url: "https://explore.carrot.eco/document/ad44dd3f-f176-4b98-bf78-5ee6e77d0530",
830
+ description: "Complete chain of custody and audit trail"
831
+ },
832
+ {
833
+ label: "Carrot White Paper",
834
+ url: "https://carrot.eco/whitepaper.pdf",
835
+ description: "Carrot Foundation technical and impact white paper"
836
+ }
837
+ ]
838
+ ]
839
+ }),
840
+ attributes: uniqueBy(
841
+ NftAttributeSchema,
842
+ (attr) => attr.trait_type,
843
+ "Attribute trait_type values must be unique"
844
+ ).meta({
845
+ title: "NFT Attributes",
846
+ description: "List of visual traits and filterable attributes compatible with NFT marketplaces",
847
+ examples: [
848
+ [
849
+ {
850
+ trait_type: "Waste Type",
851
+ value: "Organic"
852
+ },
853
+ {
854
+ trait_type: "Waste Subtype",
855
+ value: "Food, Food Waste and Beverages"
856
+ },
857
+ {
858
+ trait_type: "Weight (kg)",
859
+ value: 3e3,
860
+ display_type: "number"
861
+ },
862
+ {
863
+ trait_type: "Origin Country",
864
+ value: "Brazil"
865
+ },
866
+ {
867
+ trait_type: "Pick-up Date",
868
+ value: "2024-12-05",
869
+ display_type: "date"
870
+ }
871
+ ]
872
+ ]
873
+ })
874
+ }).meta({
875
+ title: "NFT IPFS Record",
876
+ description: "NFT-specific fields for Carrot IPFS records"
1144
877
  });
1145
878
  function getSchemaBaseUrl() {
1146
879
  return `https://raw.githubusercontent.com/carrot-foundation/schemas/refs/tags/${getSchemaVersionOrDefault()}/schemas/ipfs`;
@@ -1150,402 +883,648 @@ function buildSchemaUrl(schemaPath) {
1150
883
  return `${getSchemaBaseUrl()}/${cleanPath}`;
1151
884
  }
1152
885
  function getSchemaVersionOrDefault() {
1153
- return "0.1.33";
886
+ return "0.1.35";
1154
887
  }
1155
-
1156
- // src/mass-id/mass-id.schema.ts
1157
- var MassIDIpfsSchemaMeta = {
1158
- title: "MassID NFT IPFS Record",
1159
- description: "Complete MassID NFT IPFS record including fixed attributes and detailed waste tracking data",
1160
- $id: buildSchemaUrl("mass-id/mass-id.schema.json"),
1161
- version: getSchemaVersionOrDefault()
1162
- };
1163
- var MassIDIpfsSchema = NftIpfsSchema.safeExtend({
1164
- schema: NftIpfsSchema.shape.schema.safeExtend({
1165
- type: zod.z.literal("MassID").meta({
1166
- title: "MassID Schema Type",
1167
- description: "MassID NFT schema type"
1168
- })
1169
- }),
1170
- attributes: MassIDAttributesSchema,
1171
- data: MassIDDataSchema
1172
- }).meta(MassIDIpfsSchemaMeta);
1173
- var GasIDAttributeMethodologySchema = NftAttributeSchema.extend({
888
+ var MethodologyAttributeSchema = NftAttributeSchema.extend({
1174
889
  trait_type: zod.z.literal("Methodology"),
1175
- value: NonEmptyStringSchema.max(100).meta({
1176
- title: "Methodology Value",
1177
- description: "Name of the carbon methodology used for certification",
1178
- examples: ["BOLD Carbon (CH\u2084)"]
1179
- })
890
+ value: MethodologyNameSchema
1180
891
  }).meta({
1181
892
  title: "Methodology Attribute",
1182
- description: "Methodology attribute"
1183
- });
1184
- var GasIDAttributeGasTypeSchema = NftAttributeSchema.extend({
1185
- trait_type: zod.z.literal("Gas Type"),
1186
- value: NonEmptyStringSchema.max(100).meta({
1187
- title: "Gas Type Value",
1188
- description: "Type of gas prevented",
1189
- examples: ["Methane (CH\u2084)", "Carbon Dioxide (CO\u2082)"]
1190
- })
1191
- }).meta({
1192
- title: "Gas Type Attribute",
1193
- description: "Gas type attribute"
1194
- });
1195
- var GasIDAttributeCo2ePreventedSchema = NftAttributeSchema.extend({
1196
- trait_type: zod.z.literal("CO\u2082e Prevented (kg)"),
1197
- value: NonNegativeFloatSchema.meta({
1198
- title: "CO\u2082e Prevented Value",
1199
- description: "Total CO\u2082 equivalent emissions prevented in kilograms"
1200
- }),
1201
- display_type: zod.z.literal("number")
1202
- }).meta({
1203
- title: "CO\u2082e Prevented Attribute",
1204
- description: "CO\u2082e prevented attribute with numeric display"
893
+ description: "Methodology used for certification"
1205
894
  });
1206
- var GasIDAttributeCreditAmountSchema = NftAttributeSchema.extend({
895
+ var CreditAmountAttributeSchema = NftAttributeSchema.extend({
1207
896
  trait_type: zod.z.literal("Credit Amount"),
1208
- value: NonNegativeFloatSchema.meta({
1209
- title: "Credit Amount Value",
1210
- description: "Amount of credits issued"
1211
- }),
897
+ value: CreditAmountSchema,
1212
898
  display_type: zod.z.literal("number")
1213
899
  }).meta({
1214
900
  title: "Credit Amount Attribute",
1215
901
  description: "Credit amount attribute with numeric display"
1216
902
  });
1217
- var GasIDAttributeCreditTypeSchema = NftAttributeSchema.extend({
903
+ var CreditTypeAttributeSchema = NftAttributeSchema.extend({
1218
904
  trait_type: zod.z.literal("Credit Type"),
1219
- value: NonEmptyStringSchema.max(100).meta({
1220
- title: "Credit Type Value",
1221
- description: "Type of credit issued",
1222
- examples: ["Carrot Carbon"]
1223
- })
905
+ value: CreditTypeSchema
1224
906
  }).meta({
1225
907
  title: "Credit Type Attribute",
1226
908
  description: "Credit type attribute"
1227
909
  });
1228
- var GasIDAttributeSourceWasteTypeSchema = NftAttributeSchema.extend({
910
+ var SourceWasteTypeAttributeSchema = NftAttributeSchema.extend({
1229
911
  trait_type: zod.z.literal("Source Waste Type"),
1230
912
  value: WasteTypeSchema
1231
913
  }).meta({
1232
914
  title: "Source Waste Type Attribute",
1233
915
  description: "Source waste type attribute"
1234
916
  });
1235
- var GasIDAttributeSourceWeightSchema = NftAttributeSchema.extend({
917
+ var SourceWeightAttributeSchema = NftAttributeSchema.extend({
1236
918
  trait_type: zod.z.literal("Source Weight (kg)"),
1237
- value: WeightKgSchema,
919
+ value: WeightKgSchema.meta({
920
+ title: "Source Weight",
921
+ description: "Weight of the source waste in kilograms"
922
+ }),
1238
923
  display_type: zod.z.literal("number")
1239
924
  }).meta({
1240
925
  title: "Source Weight Attribute",
1241
926
  description: "Source weight attribute with numeric display"
1242
927
  });
1243
- var GasIDAttributeOriginCountrySchema = NftAttributeSchema.extend({
928
+ var OriginCountryAttributeSchema = NftAttributeSchema.extend({
1244
929
  trait_type: zod.z.literal("Origin Country"),
1245
- value: NonEmptyStringSchema.max(100).meta({
1246
- title: "Origin Country Value",
1247
- description: "Country where the waste was generated",
1248
- examples: ["Brazil"]
1249
- })
930
+ value: CountryNameSchema
1250
931
  }).meta({
1251
932
  title: "Origin Country Attribute",
1252
933
  description: "Origin country attribute"
1253
934
  });
1254
- var GasIDAttributeOriginMunicipalitySchema = NftAttributeSchema.extend({
935
+ var OriginMunicipalityAttributeSchema = NftAttributeSchema.extend({
1255
936
  trait_type: zod.z.literal("Origin Municipality"),
1256
- value: NonEmptyStringSchema.max(100).meta({
1257
- title: "Origin Municipality Value",
1258
- description: "Municipality where the waste was generated",
1259
- examples: ["Macap\xE1"]
1260
- })
937
+ value: MunicipalitySchema
1261
938
  }).meta({
1262
939
  title: "Origin Municipality Attribute",
1263
940
  description: "Origin municipality attribute"
1264
941
  });
1265
- var GasIDAttributeRecyclerSchema = NftAttributeSchema.extend({
942
+ var RecyclerAttributeSchema = NftAttributeSchema.extend({
1266
943
  trait_type: zod.z.literal("Recycler"),
1267
944
  value: NonEmptyStringSchema.max(100).meta({
1268
- title: "Recycler Value",
945
+ title: "Recycler",
1269
946
  description: "Organization that processed the waste",
1270
- examples: ["Eco Reciclagem"]
947
+ example: "Eco Reciclagem"
1271
948
  })
1272
949
  }).meta({
1273
950
  title: "Recycler Attribute",
1274
951
  description: "Recycler attribute"
1275
952
  });
1276
- var GasIDAttributeMassIDTokenIdSchema = NftAttributeSchema.extend({
953
+ var MassIdTokenIdAttributeSchema = NftAttributeSchema.extend({
1277
954
  trait_type: zod.z.literal("MassID"),
1278
- value: NonEmptyStringSchema.regex(
1279
- /^#\d+$/,
1280
- "Must match pattern #<token_id>"
1281
- ).meta({
1282
- title: "MassID Token ID Value",
1283
- description: "Token ID of the source MassID NFT",
1284
- examples: ["#123"]
955
+ value: StringifiedTokenIdSchema.meta({
956
+ title: "MassID Token ID",
957
+ description: "Token ID of the source MassID NFT as #<token_id>"
1285
958
  })
1286
959
  }).meta({
1287
960
  title: "MassID Token ID Attribute",
1288
961
  description: "MassID token ID attribute"
1289
962
  });
1290
- var GasIDAttributeMassIDRecyclingDateSchema = NftAttributeSchema.extend({
963
+ var MassIdRecyclingDateAttributeSchema = NftAttributeSchema.omit({
964
+ max_value: true
965
+ }).extend({
1291
966
  trait_type: zod.z.literal("MassID Recycling Date"),
1292
- value: IsoDateSchema.meta({
1293
- title: "MassID Recycling Date Value",
1294
- description: "Date when the source waste was recycled",
1295
- examples: ["2025-02-22"]
967
+ value: UnixTimestampSchema.meta({
968
+ title: "MassID Recycling Date",
969
+ description: "Unix timestamp in milliseconds when the source waste was recycled"
1296
970
  }),
1297
971
  display_type: zod.z.literal("date")
1298
972
  }).meta({
1299
973
  title: "MassID Recycling Date Attribute",
1300
- description: "MassID recycling date attribute with date display"
974
+ description: "MassID recycling date attribute using Unix timestamp in milliseconds"
1301
975
  });
1302
- var GasIDAttributesSchema = zod.z.tuple([
1303
- GasIDAttributeMethodologySchema,
1304
- GasIDAttributeGasTypeSchema,
1305
- GasIDAttributeCo2ePreventedSchema,
1306
- GasIDAttributeCreditAmountSchema,
1307
- GasIDAttributeCreditTypeSchema,
1308
- GasIDAttributeSourceWasteTypeSchema,
1309
- GasIDAttributeSourceWeightSchema,
1310
- GasIDAttributeOriginCountrySchema,
1311
- GasIDAttributeOriginMunicipalitySchema,
1312
- GasIDAttributeRecyclerSchema,
1313
- GasIDAttributeMassIDTokenIdSchema,
1314
- GasIDAttributeMassIDRecyclingDateSchema
1315
- ]).meta({
1316
- title: "GasID NFT Attribute Array",
1317
- description: "Schema for the fixed set of GasID NFT attributes, enforcing order and type for each trait"
976
+
977
+ // src/mass-id/mass-id.attributes.ts
978
+ var MassIDAttributeWasteTypeSchema = NftAttributeSchema.extend({
979
+ trait_type: zod.z.literal("Waste Type"),
980
+ value: WasteTypeSchema
981
+ }).meta({
982
+ title: "Waste Type Attribute",
983
+ description: "Waste type attribute"
1318
984
  });
1319
- var WasteClassificationSchema = zod.z.strictObject({
1320
- primary_type: WasteTypeSchema.meta({
1321
- title: "Source Waste Primary Type",
1322
- description: "Primary type of the source waste"
1323
- }),
1324
- subtype: WasteSubtypeSchema.meta({
1325
- title: "Source Waste Subtype",
1326
- description: "Subtype of the source waste"
985
+ var MassIDAttributeWasteSubtypeSchema = NftAttributeSchema.extend({
986
+ trait_type: zod.z.literal("Waste Subtype"),
987
+ value: WasteSubtypeSchema
988
+ }).meta({
989
+ title: "Waste Subtype Attribute",
990
+ description: "Waste subtype attribute"
991
+ });
992
+ var MassIDAttributeWeightSchema = NftAttributeSchema.extend({
993
+ trait_type: zod.z.literal("Weight (kg)"),
994
+ value: WeightKgSchema,
995
+ display_type: zod.z.literal("number")
996
+ }).meta({
997
+ title: "Weight Attribute",
998
+ description: "Weight attribute with numeric display"
999
+ });
1000
+ var MassIDAttributeOriginCountrySchema = OriginCountryAttributeSchema.extend({
1001
+ value: CountryNameSchema
1002
+ });
1003
+ var MassIDAttributeOriginMunicipalitySchema = OriginMunicipalityAttributeSchema.extend({
1004
+ value: MunicipalitySchema
1005
+ });
1006
+ var MassIDAttributeOriginDivisionSchema = NftAttributeSchema.extend({
1007
+ trait_type: zod.z.literal("Origin Administrative Division"),
1008
+ value: AdministrativeDivisionSchema
1009
+ }).meta({
1010
+ title: "Origin Administrative Division Attribute",
1011
+ description: "Origin administrative division attribute"
1012
+ });
1013
+ var MassIDAttributeVehicleTypeSchema = NftAttributeSchema.extend({
1014
+ trait_type: zod.z.literal("Vehicle Type"),
1015
+ value: NonEmptyStringSchema.max(100).meta({
1016
+ title: "Vehicle Type",
1017
+ description: "Type of vehicle used for waste transportation",
1018
+ examples: ["Garbage Truck", "Box Truck", "Flatbed Truck", "Roll-off Truck"]
1019
+ })
1020
+ }).meta({
1021
+ title: "Vehicle Type Attribute",
1022
+ description: "Vehicle type attribute"
1023
+ });
1024
+ var MassIDAttributeRecyclingMethodSchema = NftAttributeSchema.extend({
1025
+ trait_type: zod.z.literal("Recycling Method"),
1026
+ value: NonEmptyStringSchema.max(100).meta({
1027
+ title: "Recycling Method",
1028
+ description: "Method used for recycling or processing the waste",
1029
+ examples: [
1030
+ "Composting",
1031
+ "Mechanical Recycling",
1032
+ "Incineration with Energy Recovery"
1033
+ ]
1034
+ })
1035
+ }).meta({
1036
+ title: "Recycling Method Attribute",
1037
+ description: "Recycling method attribute"
1038
+ });
1039
+ var MassIDAttributeProcessingTimeSchema = NftAttributeSchema.extend({
1040
+ trait_type: zod.z.literal("Processing Time (hours)"),
1041
+ value: HoursSchema,
1042
+ trait_description: NonEmptyStringSchema.max(200).optional().meta({
1043
+ title: "Processing Time Description",
1044
+ description: "Custom description for the processing time"
1045
+ })
1046
+ }).meta({
1047
+ title: "Processing Time Attribute",
1048
+ description: "Processing time attribute with optional trait description"
1049
+ });
1050
+ var MassIDAttributeLocalWasteClassificationIdSchema = NftAttributeSchema.extend({
1051
+ trait_type: zod.z.literal("Local Waste Classification ID"),
1052
+ value: NonEmptyStringSchema.max(100).meta({
1053
+ title: "Local Waste Classification ID",
1054
+ description: "Local or regional waste classification identifier",
1055
+ examples: ["04 02 20", "IBAMA-A001", "EWC-150101"]
1056
+ })
1057
+ }).meta({
1058
+ title: "Local Waste Classification ID Attribute",
1059
+ description: "Local waste classification ID attribute"
1060
+ });
1061
+ var MassIDAttributeRecyclingManifestCodeSchema = NftAttributeSchema.extend({
1062
+ trait_type: zod.z.literal("Recycling Manifest Code"),
1063
+ value: NonEmptyStringSchema.max(100).meta({
1064
+ title: "Recycling Manifest Code",
1065
+ description: "Concatenated recycling manifest code (Document Type + Document Number)",
1066
+ examples: ["CDF-2353", "RC-12345", "REC-MANIFEST-789"]
1067
+ })
1068
+ }).meta({
1069
+ title: "Recycling Manifest Code Attribute",
1070
+ description: "Recycling manifest code attribute (optional)"
1071
+ });
1072
+ var MassIDAttributeTransportManifestCodeSchema = NftAttributeSchema.extend({
1073
+ trait_type: zod.z.literal("Transport Manifest Code"),
1074
+ value: NonEmptyStringSchema.max(100).meta({
1075
+ title: "Transport Manifest Code",
1076
+ description: "Concatenated transport manifest code (Document Type + Document Number)",
1077
+ examples: ["MTR-4126", "TRN-67890", "TRANS-MANIFEST-456"]
1078
+ })
1079
+ }).meta({
1080
+ title: "Transport Manifest Code Attribute",
1081
+ description: "Transport manifest code attribute (optional)"
1082
+ });
1083
+ var MassIDAttributeWeighingCaptureMethodSchema = NftAttributeSchema.extend({
1084
+ trait_type: zod.z.literal("Weighing Capture Method"),
1085
+ value: NonEmptyStringSchema.max(100).meta({
1086
+ title: "Weighing Capture Method",
1087
+ description: "Method used to capture weight data",
1088
+ examples: ["Digital", "Manual", "Automated", "Electronic Scale"]
1089
+ })
1090
+ }).meta({
1091
+ title: "Weighing Capture Method Attribute",
1092
+ description: "Weighing capture method attribute (optional)"
1093
+ });
1094
+ var MassIDAttributeScaleTypeSchema = NftAttributeSchema.extend({
1095
+ trait_type: zod.z.literal("Scale Type"),
1096
+ value: NonEmptyStringSchema.max(100).meta({
1097
+ title: "Scale Type",
1098
+ description: "Type of scale used for weighing",
1099
+ examples: [
1100
+ "Weighbridge (Truck Scale)",
1101
+ "Floor Scale",
1102
+ "Bench Scale",
1103
+ "Crane Scale"
1104
+ ]
1105
+ })
1106
+ }).meta({
1107
+ title: "Scale Type Attribute",
1108
+ description: "Scale type attribute (optional)"
1109
+ });
1110
+ var MassIDAttributeContainerTypeSchema = NftAttributeSchema.extend({
1111
+ trait_type: zod.z.literal("Container Type"),
1112
+ value: NonEmptyStringSchema.max(100).meta({
1113
+ title: "Container Type",
1114
+ description: "Type of container used for waste storage or transport",
1115
+ examples: ["Truck", "Dumpster", "Roll-off Container", "Compactor", "Bin"]
1116
+ })
1117
+ }).meta({
1118
+ title: "Container Type Attribute",
1119
+ description: "Container type attribute (optional)"
1120
+ });
1121
+ var MassIDAttributePickUpDateSchema = NftAttributeSchema.extend({
1122
+ trait_type: zod.z.literal("Pick-up Date"),
1123
+ value: UnixTimestampSchema.meta({
1124
+ title: "Pick-up Date",
1125
+ description: "Unix timestamp in milliseconds when the waste was picked up from the source",
1126
+ examples: [17105184e5, 17040672e5, 17152704e5]
1327
1127
  }),
1328
- net_weight_kg: WeightKgSchema.meta({
1329
- title: "Source Waste Net Weight",
1330
- description: "Net weight of the source waste"
1331
- })
1128
+ display_type: zod.z.literal("date")
1332
1129
  }).meta({
1333
- title: "Waste Classification",
1334
- description: "Classification of the source waste (MassID)"
1130
+ title: "Pick-up Date Attribute",
1131
+ description: "Pick-up date attribute with Unix timestamp"
1335
1132
  });
1336
- var AccreditedParticipantSchema = zod.z.strictObject({
1337
- participant_id: UuidSchema.meta({
1338
- title: "Participant ID",
1339
- description: "Unique identifier for the participant"
1340
- }),
1341
- name: ParticipantNameSchema.meta({
1342
- title: "Participant Name",
1343
- description: "Name of the participant"
1133
+ var MassIDAttributeRecyclingDateSchema = NftAttributeSchema.extend({
1134
+ trait_type: zod.z.literal("Recycling Date"),
1135
+ value: UnixTimestampSchema.meta({
1136
+ title: "Recycling Date",
1137
+ description: "Unix timestamp in milliseconds when the waste was recycled/processed",
1138
+ examples: [17106048e5, 17041536e5, 17153568e5]
1344
1139
  }),
1345
- role: ParticipantRoleSchema.meta({
1346
- title: "Participant Role",
1347
- description: "Role of the participant in the supply chain"
1140
+ display_type: zod.z.literal("date")
1141
+ }).meta({
1142
+ title: "Recycling Date Attribute",
1143
+ description: "Recycling date attribute with Unix timestamp"
1144
+ });
1145
+ var MassIDAttributesSchema = uniqueBy(
1146
+ zod.z.union([
1147
+ MassIDAttributeWasteTypeSchema,
1148
+ MassIDAttributeWasteSubtypeSchema,
1149
+ MassIDAttributeWeightSchema,
1150
+ MassIDAttributeOriginCountrySchema,
1151
+ MassIDAttributeOriginMunicipalitySchema,
1152
+ MassIDAttributeOriginDivisionSchema,
1153
+ MassIDAttributeVehicleTypeSchema,
1154
+ MassIDAttributeRecyclingMethodSchema,
1155
+ MassIDAttributeProcessingTimeSchema,
1156
+ MassIDAttributeLocalWasteClassificationIdSchema,
1157
+ MassIDAttributeRecyclingManifestCodeSchema,
1158
+ MassIDAttributeTransportManifestCodeSchema,
1159
+ MassIDAttributeWeighingCaptureMethodSchema,
1160
+ MassIDAttributeScaleTypeSchema,
1161
+ MassIDAttributeContainerTypeSchema,
1162
+ MassIDAttributePickUpDateSchema,
1163
+ MassIDAttributeRecyclingDateSchema
1164
+ ]),
1165
+ (attr) => attr.trait_type
1166
+ ).min(12).max(17).meta({
1167
+ title: "MassID Attributes",
1168
+ description: "MassID NFT attributes array containing attributes selected from the available attribute types. The schema validates array length but does not enforce which specific attributes must be present."
1169
+ });
1170
+ var MassIDLocalClassificationSchema = zod.z.strictObject({
1171
+ code: NonEmptyStringSchema.max(20).meta({
1172
+ title: "Classification Code",
1173
+ description: "Local waste classification code",
1174
+ examples: ["20 01 01", "D001", "EWC-150101", "IBAMA-A001"]
1348
1175
  }),
1349
- accreditation_id: UuidSchema.meta({
1350
- title: "Accreditation ID",
1351
- description: "Unique identifier for the participant accreditation"
1176
+ description: NonEmptyStringSchema.max(200).meta({
1177
+ title: "Classification Description",
1178
+ description: "Local waste classification description",
1179
+ examples: [
1180
+ "Paper and cardboard packaging",
1181
+ "Ignitable waste",
1182
+ "Paper and cardboard packaging waste",
1183
+ "Municipal solid waste - organic fraction"
1184
+ ]
1352
1185
  }),
1353
- external_url: ExternalUrlSchema.meta({
1354
- title: "Participant Accreditation External URL",
1355
- description: "URL to view the participant accreditation on Carrot Explorer"
1186
+ system: zod.z.enum(["IBAMA"]).meta({
1187
+ title: "Classification System",
1188
+ description: "Classification system name - currently supports IBAMA (Instituto Brasileiro do Meio Ambiente e dos Recursos Naturais Renov\xE1veis)",
1189
+ examples: ["IBAMA"]
1356
1190
  })
1357
1191
  }).meta({
1358
- title: "Accredited Participant",
1359
- description: "Participant with valid accreditation in the supply chain"
1192
+ title: "Local Classification",
1193
+ description: "Local or regional waste classification codes and descriptions"
1360
1194
  });
1361
- var AccreditedParticipantsSchema = zod.z.array(AccreditedParticipantSchema).min(1).meta({
1362
- title: "Accredited Participants",
1363
- description: "List of participants with valid accreditations"
1195
+ var MassIDMeasurementUnitSchema = zod.z.enum(["kg", "ton"]).meta({
1196
+ title: "Measurement Unit",
1197
+ description: "Unit of measurement for the waste quantity",
1198
+ examples: ["kg", "ton"]
1364
1199
  });
1365
- var RewardAllocationSchema = zod.z.strictObject({
1366
- participant_id: UuidSchema.meta({
1367
- title: "Participant ID",
1368
- description: "Unique identifier for the participant receiving the reward"
1369
- }),
1370
- participant_name: ParticipantNameSchema.meta({
1371
- title: "Participant Name",
1372
- description: "Name of the participant receiving the reward"
1373
- }),
1374
- role: ParticipantRoleSchema.meta({
1375
- title: "Participant Role",
1376
- description: "Role of the participant in the supply chain"
1377
- }),
1378
- reward_percentage: PercentageSchema.meta({
1379
- title: "Reward Percentage",
1380
- description: "Reward percentage allocated to the participant"
1200
+ var MassIDWastePropertiesSchema = zod.z.strictObject({
1201
+ type: WasteTypeSchema.meta({
1202
+ title: "Waste Type",
1203
+ description: "Waste material category"
1381
1204
  }),
1382
- large_business_discount_applied: zod.z.boolean().optional().meta({
1383
- title: "Large Business Discount Applied",
1384
- description: "Whether the large business discount was applied"
1205
+ subtype: WasteSubtypeSchema.meta({
1206
+ title: "Waste Subtype",
1207
+ description: "Specific subcategory of waste material"
1385
1208
  }),
1386
- effective_percentage: PercentageSchema.meta({
1387
- title: "Effective Percentage",
1388
- description: "Effective percentage of the reward after discounts"
1209
+ local_classification: MassIDLocalClassificationSchema.optional(),
1210
+ measurement_unit: MassIDMeasurementUnitSchema,
1211
+ net_weight: NonNegativeFloatSchema.meta({
1212
+ title: "Net Weight",
1213
+ description: "Net weight of the waste batch in the specified measurement unit"
1389
1214
  })
1390
1215
  }).meta({
1391
- title: "Reward Allocation",
1392
- description: "Reward allocation for a specific participant"
1216
+ title: "Waste Properties",
1217
+ description: "Standardized waste material properties and regulatory information"
1393
1218
  });
1394
- var DistributionNotesSchema = zod.z.strictObject({
1395
- large_business_discount_applied: NonEmptyStringSchema.optional().meta({
1396
- title: "Large Business Discount Applied",
1397
- description: "Description of the large business discount applied",
1219
+ var EventAttributeFormatSchema = zod.z.enum(["KILOGRAM", "DATE", "CURRENCY", "PERCENTAGE", "COORDINATE"]).meta({
1220
+ title: "Event Attribute Format",
1221
+ description: "Data format hint for proper display",
1222
+ examples: ["KILOGRAM", "DATE", "PERCENTAGE"]
1223
+ });
1224
+ var EventAttributeSchema = zod.z.strictObject({
1225
+ name: NonEmptyStringSchema.max(100).meta({
1226
+ title: "Attribute Name",
1227
+ description: "Event attribute name",
1398
1228
  examples: [
1399
- "50% reduction applied to participants with >$4M annual revenue"
1229
+ "temperature",
1230
+ "humidity",
1231
+ "contamination_percentage",
1232
+ "quality_grade",
1233
+ "batch_number",
1234
+ "operator_id",
1235
+ "equipment_used",
1236
+ "processing_cost"
1400
1237
  ]
1401
1238
  }),
1402
- redirected_rewards: NonEmptyStringSchema.optional().meta({
1403
- title: "Redirected Rewards",
1404
- description: "Description of the redirected rewards",
1239
+ value: zod.z.union([zod.z.string(), zod.z.number(), zod.z.boolean()]).optional().meta({
1240
+ title: "Attribute Value",
1241
+ description: "Event attribute value",
1405
1242
  examples: [
1406
- "Discounted rewards from large businesses redirected to accredited NGOs"
1243
+ 25.5,
1244
+ "Grade A",
1245
+ true,
1246
+ "BATCH-2024-001",
1247
+ 12.75,
1248
+ "Shredder-X200",
1249
+ false,
1250
+ "OP-456"
1407
1251
  ]
1408
- })
1252
+ }),
1253
+ preserved_sensitivity: zod.z.boolean().optional().meta({
1254
+ title: "Preserved Sensitivity",
1255
+ description: "Indicates if the attribute contains sensitive information that was preserved"
1256
+ }),
1257
+ format: EventAttributeFormatSchema.optional()
1409
1258
  }).meta({
1410
- title: "Distribution Notes",
1411
- description: "Additional notes about the reward distribution"
1259
+ title: "Event Attribute",
1260
+ description: "Additional attribute specific to an event"
1412
1261
  });
1413
- var ParticipantRewardsSchema = zod.z.strictObject({
1414
- distribution_basis: NonEmptyStringSchema.max(200).meta({
1415
- title: "Distribution Basis",
1416
- description: "Basis for the rewards distribution"
1262
+ var EventAttachmentSchema = zod.z.strictObject({
1263
+ type: NonEmptyStringSchema.max(50).meta({
1264
+ title: "Attachment Type",
1265
+ description: "Type of supporting attachment",
1266
+ examples: [
1267
+ "Waste Transfer Note",
1268
+ "Certificate of Disposal",
1269
+ "Certificate of Final Destination",
1270
+ "Quality Assessment Report",
1271
+ "Transport Manifest",
1272
+ "Processing Receipt",
1273
+ "Environmental Permit",
1274
+ "Invoice"
1275
+ ]
1417
1276
  }),
1418
- reward_allocations: zod.z.array(RewardAllocationSchema).min(1).meta({
1419
- title: "Reward Allocations",
1420
- description: "Rewards percentage allocated to each participant"
1277
+ document_number: NonEmptyStringSchema.max(50).optional().meta({
1278
+ title: "Document Number",
1279
+ description: "Official document number if applicable",
1280
+ examples: [
1281
+ "WTN-2024-001234",
1282
+ "CD-ENV-456789",
1283
+ "INV-2024-QTR1-789",
1284
+ "PERMIT-EPA-2024-001",
1285
+ "MANIFEST-DOT-567890"
1286
+ ]
1421
1287
  }),
1422
- distribution_notes: DistributionNotesSchema.optional().meta({
1423
- title: "Distribution Notes",
1424
- description: "Additional notes about the reward distribution"
1288
+ reference: NonEmptyStringSchema.meta({
1289
+ title: "Attachment Reference",
1290
+ description: "Reference to attachment (IPFS hash, file name, or external URL)",
1291
+ examples: [
1292
+ "QmYjtig7VJQ6XsnUjqqJvj7QaMcCAwtrgNdahSiFofrE7o",
1293
+ "waste_transfer_note_2024_001.pdf",
1294
+ "https://docs.example.com/certificates/disposal_cert_456.pdf",
1295
+ "bafybeigdyrzt5sfp7udm7hu76uh7y26nf3efuylqabf3oclgtqy55fbzdi",
1296
+ "processing_receipt_20240315.jpg"
1297
+ ]
1298
+ }),
1299
+ issue_timestamp: UnixTimestampSchema.optional().meta({
1300
+ title: "Issue Timestamp",
1301
+ description: "Unix timestamp in milliseconds when the attachment was issued",
1302
+ examples: [17105184e5, 17040672e5, 17152704e5]
1303
+ }),
1304
+ issuer: NonEmptyStringSchema.max(100).optional().meta({
1305
+ title: "Attachment Issuer",
1306
+ description: "Entity that issued the attachment",
1307
+ examples: [
1308
+ "Environmental Protection Agency",
1309
+ "Waste Management Solutions Ltd",
1310
+ "Green Recycling Corp",
1311
+ "City Waste Authority",
1312
+ "EcoProcess Industries",
1313
+ "Regional Environmental Office"
1314
+ ]
1425
1315
  })
1426
1316
  }).meta({
1427
- title: "Participant Rewards",
1428
- description: "Rewards distribution to participants"
1429
- });
1430
- var MethodologyComplianceSchema = zod.z.enum(["PASSED", "FAILED"]).meta({
1431
- title: "Methodology Compliance",
1432
- description: "Result of methodology compliance check",
1433
- examples: ["PASSED", "FAILED"]
1317
+ title: "Event Attachment",
1318
+ description: "Supporting event attachment"
1434
1319
  });
1435
- var AuditReferenceSchema = zod.z.strictObject({
1436
- date: IsoDateSchema.meta({
1437
- title: "Audit Date",
1438
- description: "Date when the audit was completed"
1320
+ var MassIDChainOfCustodyEventSchema = zod.z.strictObject({
1321
+ event_id: UuidSchema.meta({
1322
+ title: "Event ID",
1323
+ description: "Unique event identifier"
1324
+ }),
1325
+ event_name: NonEmptyStringSchema.max(50).meta({
1326
+ title: "Event Name",
1327
+ description: "Name of custody or processing event",
1328
+ examples: ["Sorting", "Processing", "Recycling", "Weighing"]
1439
1329
  }),
1440
- external_id: ExternalIdSchema.meta({
1441
- title: "Audit External ID",
1442
- description: "Unique identifier for the audit"
1330
+ description: NonEmptyStringSchema.max(200).optional().meta({
1331
+ title: "Event Description",
1332
+ description: "Detailed description of what happened during this event",
1333
+ examples: [
1334
+ "Waste collected from residential area using collection truck",
1335
+ "Material sorted into recyclable and non-recyclable fractions",
1336
+ "Plastic waste processed through shredding and washing",
1337
+ "Waste transferred to authorized recycling facility",
1338
+ "Final disposal at licensed landfill site",
1339
+ "Quality inspection and contamination assessment completed"
1340
+ ]
1443
1341
  }),
1444
- external_url: ExternalUrlSchema.meta({
1445
- title: "Audit External URL",
1446
- description: "URL to view the audit on Carrot Explorer"
1342
+ timestamp: UnixTimestampSchema.meta({
1343
+ title: "Event Timestamp",
1344
+ description: "Unix timestamp in milliseconds when the event occurred",
1345
+ examples: [17105184e5, 17040672e5, 17152704e5]
1447
1346
  }),
1448
- methodology_compliance: MethodologyComplianceSchema.meta({
1449
- title: "Methodology Compliance",
1450
- description: "Result of methodology compliance check"
1347
+ participant_id_hash: Sha256HashSchema.meta({
1348
+ title: "Participant ID Hash",
1349
+ description: "Reference to participant in the participants array"
1451
1350
  }),
1452
- rules_executed: NonNegativeIntegerSchema.meta({
1453
- title: "Rules Executed",
1454
- description: "Number of rules executed during the audit"
1351
+ location_id_hash: Sha256HashSchema.meta({
1352
+ title: "Location ID Hash",
1353
+ description: "Reference to location in the locations array"
1455
1354
  }),
1456
- report: IpfsUriSchema.meta({
1457
- title: "Audit Report",
1458
- description: "IPFS URI of the audit report"
1355
+ weight: NonNegativeFloatSchema.optional().meta({
1356
+ title: "Event Weight",
1357
+ description: "Mass weight after this event"
1358
+ }),
1359
+ attributes: zod.z.array(EventAttributeSchema).optional().meta({
1360
+ title: "Event Attributes",
1361
+ description: "Additional attributes specific to this event"
1362
+ }),
1363
+ attachments: zod.z.array(EventAttachmentSchema).optional().meta({
1364
+ title: "Event Attachments",
1365
+ description: "Associated attachments for this event"
1459
1366
  })
1460
1367
  }).meta({
1461
- title: "Audit Reference",
1462
- description: "Reference to an audit record"
1368
+ title: "Chain of Custody Event",
1369
+ description: "Chain of custody event"
1463
1370
  });
1464
- var GasIDReferenceSchema = zod.z.strictObject({
1465
- external_id: ExternalIdSchema.meta({
1466
- title: "GasID External ID",
1467
- description: "Unique identifier for the GasID"
1468
- }),
1469
- token_id: TokenIdSchema.meta({
1470
- title: "GasID Token ID",
1471
- description: "NFT token ID of the GasID"
1472
- }),
1473
- external_url: ExternalUrlSchema.meta({
1474
- title: "GasID External URL",
1475
- description: "URL to view the GasID on Carrot Explorer"
1371
+ var MassIDChainOfCustodySchema = zod.z.strictObject({
1372
+ events: zod.z.array(MassIDChainOfCustodyEventSchema).min(1).meta({
1373
+ title: "Custody Events",
1374
+ description: "Chronological sequence of custody transfer and processing events"
1476
1375
  }),
1477
- uri: IpfsUriSchema.meta({
1478
- title: "GasID IPFS URI",
1479
- description: "IPFS URI of the GasID record"
1376
+ total_duration_minutes: MinutesSchema.meta({
1377
+ title: "Total Duration (minutes)",
1378
+ description: "Total time from first to last event in minutes"
1480
1379
  })
1481
1380
  }).meta({
1482
- title: "GasID Reference",
1483
- description: "Reference to a GasID record"
1381
+ title: "Chain of Custody",
1382
+ description: "Complete chain of custody tracking from waste generation to final processing"
1484
1383
  });
1485
- var MassIDReferenceSchema = zod.z.strictObject({
1486
- external_id: ExternalIdSchema.meta({
1487
- title: "MassID External ID",
1488
- description: "Unique identifier for the MassID"
1384
+ var MassIDGeographicDataSchema = zod.z.strictObject({
1385
+ from_location_id_hash: Sha256HashSchema.meta({
1386
+ title: "From Location ID Hash",
1387
+ description: "Reference hash of the location where the waste started movement"
1489
1388
  }),
1490
- token_id: TokenIdSchema.meta({
1491
- title: "MassID Token ID",
1492
- description: "NFT token ID of the MassID"
1389
+ to_location_id_hash: Sha256HashSchema.meta({
1390
+ title: "To Location ID Hash",
1391
+ description: "Reference hash of the location where the waste ended movement"
1493
1392
  }),
1494
- external_url: ExternalUrlSchema.meta({
1495
- title: "MassID External URL",
1496
- description: "URL to view the MassID on Carrot Explorer"
1393
+ first_reported_timestamp: UnixTimestampSchema.meta({
1394
+ title: "First Reported Timestamp",
1395
+ description: "Unix timestamp in milliseconds when the waste was first reported/collected at the origin location",
1396
+ examples: [17105184e5, 17040672e5, 17152704e5]
1497
1397
  }),
1498
- uri: IpfsUriSchema.meta({
1499
- title: "MassID IPFS URI",
1500
- description: "IPFS URI of the MassID record"
1398
+ last_reported_timestamp: UnixTimestampSchema.meta({
1399
+ title: "Last Reported Timestamp",
1400
+ description: "Unix timestamp in milliseconds when the waste was last reported/processed at the destination location",
1401
+ examples: [17106048e5, 17041536e5, 17153568e5]
1501
1402
  })
1502
- }).meta({
1503
- title: "MassID Reference",
1504
- description: "Reference to a MassID record"
1403
+ }).refine((data) => {
1404
+ return data.first_reported_timestamp <= data.last_reported_timestamp;
1405
+ }, "first_reported_timestamp must be before or equal to last_reported_timestamp").meta({
1406
+ title: "Geographic Data",
1407
+ description: "Simplified geographic information tracking waste movement from origin to destination with temporal bounds"
1505
1408
  });
1506
- var MethodologyReferenceSchema = zod.z.strictObject({
1507
- external_id: ExternalIdSchema.meta({
1508
- title: "Methodology External ID",
1509
- description: "Unique identifier for the methodology"
1510
- }),
1511
- name: NonEmptyStringSchema.min(5).max(150).meta({
1512
- title: "Methodology Name",
1513
- description: "Human-readable name of the methodology",
1514
- examples: ["BOLD Carbon (CH\u2084)", "BOLD Recycling"]
1409
+ var MassIDDataSchema = zod.z.strictObject({
1410
+ waste_properties: MassIDWastePropertiesSchema,
1411
+ locations: uniqueBy(
1412
+ LocationSchema,
1413
+ (loc) => loc.id_hash,
1414
+ "Location ID hashes must be unique"
1415
+ ).min(1).meta({
1416
+ title: "Locations",
1417
+ description: "All locations referenced in this MassID, indexed by ID"
1515
1418
  }),
1516
- version: SemanticVersionSchema.meta({
1517
- title: "Methodology Version",
1518
- description: "Version of the methodology"
1419
+ participants: uniqueBy(
1420
+ ParticipantSchema,
1421
+ (p) => p.id_hash,
1422
+ "Participant ID hashes must be unique"
1423
+ ).min(1).meta({
1424
+ title: "Participants",
1425
+ description: "All participants referenced in this MassID, indexed by ID"
1519
1426
  }),
1520
- external_url: ExternalUrlSchema.meta({
1521
- title: "Methodology External URL",
1522
- description: "URL to view the methodology on Carrot Explorer"
1427
+ chain_of_custody: MassIDChainOfCustodySchema,
1428
+ geographic_data: MassIDGeographicDataSchema
1429
+ }).refine((data) => {
1430
+ const participantIdSet = new Set(
1431
+ data.participants.map((participant) => participant.id_hash)
1432
+ );
1433
+ const eventParticipantIds = data.chain_of_custody.events.map(
1434
+ (event) => event.participant_id_hash
1435
+ );
1436
+ const allEventParticipantsExist = eventParticipantIds.every(
1437
+ (participantId) => participantIdSet.has(participantId)
1438
+ );
1439
+ return allEventParticipantsExist;
1440
+ }, "All participant ID hashes in chain of custody events must exist in participants array").refine((data) => {
1441
+ const locationIdSet = new Set(
1442
+ data.locations.map((location) => location.id_hash)
1443
+ );
1444
+ const eventLocationIds = data.chain_of_custody.events.map(
1445
+ (event) => event.location_id_hash
1446
+ );
1447
+ const allEventLocationsExist = eventLocationIds.every(
1448
+ (locationId) => locationIdSet.has(locationId)
1449
+ );
1450
+ return allEventLocationsExist;
1451
+ }, "All location ID hashes in chain of custody events must exist in locations array").meta({
1452
+ title: "MassID Data",
1453
+ description: "MassID data containing waste tracking and chain of custody information"
1454
+ });
1455
+ var MassIDIpfsSchemaMeta = {
1456
+ title: "MassID NFT IPFS Record",
1457
+ description: "Complete MassID NFT IPFS record including fixed attributes and detailed waste tracking data",
1458
+ $id: buildSchemaUrl("mass-id/mass-id.schema.json"),
1459
+ version: getSchemaVersionOrDefault()
1460
+ };
1461
+ var MassIDIpfsSchema = NftIpfsSchema.safeExtend({
1462
+ schema: NftIpfsSchema.shape.schema.safeExtend({
1463
+ type: zod.z.literal("MassID").meta({
1464
+ title: "MassID Schema Type",
1465
+ description: "MassID NFT schema type"
1466
+ })
1523
1467
  }),
1524
- uri: IpfsUriSchema.optional().meta({
1525
- title: "Methodology IPFS URI",
1526
- description: "IPFS URI to the methodology record"
1468
+ attributes: MassIDAttributesSchema,
1469
+ data: MassIDDataSchema
1470
+ }).meta(MassIDIpfsSchemaMeta);
1471
+ var GasIDAttributeMethodologySchema = MethodologyAttributeSchema;
1472
+ var GasIDAttributeGasTypeSchema = NftAttributeSchema.extend({
1473
+ trait_type: zod.z.literal("Gas Type"),
1474
+ value: NonEmptyStringSchema.max(100).meta({
1475
+ title: "Gas Type",
1476
+ description: "Type of gas prevented",
1477
+ examples: ["Methane (CH\u2084)", "Carbon Dioxide (CO\u2082)"]
1527
1478
  })
1528
1479
  }).meta({
1529
- title: "Methodology Reference",
1530
- description: "Reference to a methodology record"
1480
+ title: "Gas Type Attribute",
1481
+ description: "Gas type attribute"
1482
+ });
1483
+ var GasIDAttributeCo2ePreventedSchema = NftAttributeSchema.extend({
1484
+ trait_type: zod.z.literal("CO\u2082e Prevented (kg)"),
1485
+ value: NonNegativeFloatSchema.meta({
1486
+ title: "CO\u2082e Prevented",
1487
+ description: "Total CO\u2082 equivalent emissions prevented in kilograms"
1488
+ }),
1489
+ display_type: zod.z.literal("number")
1490
+ }).meta({
1491
+ title: "CO\u2082e Prevented Attribute",
1492
+ description: "CO\u2082e prevented attribute with numeric display"
1493
+ });
1494
+ var GasIDAttributeCreditAmountSchema = CreditAmountAttributeSchema;
1495
+ var GasIDAttributeCreditTypeSchema = CreditTypeAttributeSchema;
1496
+ var GasIDAttributeSourceWasteTypeSchema = SourceWasteTypeAttributeSchema;
1497
+ var GasIDAttributeSourceWeightSchema = SourceWeightAttributeSchema;
1498
+ var GasIDAttributeOriginCountrySchema = OriginCountryAttributeSchema;
1499
+ var GasIDAttributeOriginMunicipalitySchema = OriginMunicipalityAttributeSchema;
1500
+ var GasIDAttributeRecyclerSchema = RecyclerAttributeSchema;
1501
+ var GasIDAttributeMassIDTokenIdSchema = MassIdTokenIdAttributeSchema;
1502
+ var GasIDAttributeMassIDRecyclingDateSchema = MassIdRecyclingDateAttributeSchema;
1503
+ var GasIDAttributesSchema = zod.z.tuple([
1504
+ GasIDAttributeMethodologySchema,
1505
+ GasIDAttributeGasTypeSchema,
1506
+ GasIDAttributeCo2ePreventedSchema,
1507
+ GasIDAttributeCreditAmountSchema,
1508
+ GasIDAttributeCreditTypeSchema,
1509
+ GasIDAttributeSourceWasteTypeSchema,
1510
+ GasIDAttributeSourceWeightSchema,
1511
+ GasIDAttributeOriginCountrySchema,
1512
+ GasIDAttributeOriginMunicipalitySchema,
1513
+ GasIDAttributeRecyclerSchema,
1514
+ GasIDAttributeMassIDTokenIdSchema,
1515
+ GasIDAttributeMassIDRecyclingDateSchema
1516
+ ]).meta({
1517
+ title: "GasID NFT Attribute Array",
1518
+ description: "Schema for the fixed set of GasID NFT attributes, enforcing order and type for each trait"
1531
1519
  });
1532
-
1533
- // src/gas-id/gas-id.data.schema.ts
1534
1520
  var GasIDSummarySchema = zod.z.strictObject({
1535
1521
  gas_type: NonEmptyStringSchema.meta({
1536
1522
  title: "Gas Type",
1537
1523
  description: "Type of gas prevented",
1538
1524
  examples: ["Methane (CH\u2084)", "Carbon Dioxide (CO\u2082)"]
1539
1525
  }),
1540
- credit_type: NonEmptyStringSchema.meta({
1541
- title: "Credit Type",
1542
- description: "Type of credit issued",
1543
- examples: ["Carrot Carbon (C-CARB)", "Carbon Credit"]
1544
- }),
1545
- credit_amount: NonNegativeFloatSchema.meta({
1546
- title: "Credit Amount",
1547
- description: "Amount of credits issued"
1548
- }),
1526
+ credit_type: CreditTypeSchema,
1527
+ credit_amount: CreditAmountSchema,
1549
1528
  prevented_co2e_kg: WeightKgSchema.meta({
1550
1529
  title: "Prevented Emissions (CO\u2082e kg)",
1551
1530
  description: "CO\u2082e weight of the prevented emissions"
@@ -1634,13 +1613,99 @@ var GasIDIpfsSchema = NftIpfsSchema.safeExtend({
1634
1613
  attributes: GasIDAttributesSchema,
1635
1614
  data: GasIDDataSchema
1636
1615
  }).meta(GasIDIpfsSchemaMeta);
1616
+ var RecycledIDAttributeMethodologySchema = MethodologyAttributeSchema;
1617
+ var RecycledIDAttributeRecycledMassWeightSchema = NftAttributeSchema.extend({
1618
+ trait_type: zod.z.literal("Recycled Mass Weight (kg)"),
1619
+ value: WeightKgSchema.meta({
1620
+ title: "Recycled Mass Weight",
1621
+ description: "Total weight of recycled materials in kilograms"
1622
+ }),
1623
+ display_type: zod.z.literal("number")
1624
+ }).meta({
1625
+ title: "Recycled Mass Weight Attribute",
1626
+ description: "Recycled mass weight attribute with numeric display"
1627
+ });
1628
+ var RecycledIDAttributeCreditAmountSchema = CreditAmountAttributeSchema;
1629
+ var RecycledIDAttributeCreditTypeSchema = CreditTypeAttributeSchema;
1630
+ var RecycledIDAttributeSourceWasteTypeSchema = SourceWasteTypeAttributeSchema;
1631
+ var RecycledIDAttributeSourceWeightSchema = SourceWeightAttributeSchema;
1632
+ var RecycledIDAttributeOriginCountrySchema = OriginCountryAttributeSchema;
1633
+ var RecycledIDAttributeOriginMunicipalitySchema = OriginMunicipalityAttributeSchema;
1634
+ var RecycledIDAttributeRecyclerSchema = RecyclerAttributeSchema;
1635
+ var RecycledIDAttributeMassIDTokenIdSchema = MassIdTokenIdAttributeSchema;
1636
+ var RecycledIDAttributeMassIDRecyclingDateSchema = MassIdRecyclingDateAttributeSchema;
1637
+ var RecycledIDAttributesSchema = zod.z.tuple([
1638
+ RecycledIDAttributeMethodologySchema,
1639
+ RecycledIDAttributeRecycledMassWeightSchema,
1640
+ RecycledIDAttributeCreditAmountSchema,
1641
+ RecycledIDAttributeCreditTypeSchema,
1642
+ RecycledIDAttributeSourceWasteTypeSchema,
1643
+ RecycledIDAttributeSourceWeightSchema,
1644
+ RecycledIDAttributeOriginCountrySchema,
1645
+ RecycledIDAttributeOriginMunicipalitySchema,
1646
+ RecycledIDAttributeRecyclerSchema,
1647
+ RecycledIDAttributeMassIDTokenIdSchema,
1648
+ RecycledIDAttributeMassIDRecyclingDateSchema
1649
+ ]).meta({
1650
+ title: "RecycledID NFT Attribute Array",
1651
+ description: "Schema for the fixed set of RecycledID NFT attributes, enforcing order and type for each trait"
1652
+ });
1653
+ var RecycledIDSummarySchema = zod.z.strictObject({
1654
+ recycled_mass_kg: WeightKgSchema.meta({
1655
+ title: "Recycled Mass Weight",
1656
+ description: "Total weight of materials successfully recycled"
1657
+ }),
1658
+ credit_type: CreditTypeSchema,
1659
+ credit_amount: CreditAmountSchema
1660
+ }).meta({
1661
+ title: "RecycledID Summary",
1662
+ description: "Summary information for the RecycledID certificate"
1663
+ });
1664
+ var RecycledIDDataSchema = zod.z.strictObject({
1665
+ summary: RecycledIDSummarySchema,
1666
+ methodology: MethodologyReferenceSchema,
1667
+ audit: AuditReferenceSchema,
1668
+ mass_id: MassIDReferenceSchema,
1669
+ waste_classification: WasteClassificationSchema,
1670
+ origin_location: LocationSchema.meta({
1671
+ title: "RecycledID Origin Location",
1672
+ description: "Source waste origin location details"
1673
+ }),
1674
+ accredited_participants: AccreditedParticipantsSchema,
1675
+ participant_rewards: ParticipantRewardsSchema.optional()
1676
+ }).meta({
1677
+ title: "RecycledID Data",
1678
+ description: "Complete data structure for RecycledID certificate"
1679
+ });
1680
+ var RecycledIDIpfsSchemaMeta = {
1681
+ title: "RecycledID NFT IPFS Record",
1682
+ description: "Complete RecycledID NFT IPFS record including fixed attributes and recycling outcome data",
1683
+ $id: buildSchemaUrl("recycled-id/recycled-id.schema.json"),
1684
+ version: getSchemaVersionOrDefault()
1685
+ };
1686
+ var RecycledIDIpfsSchema = NftIpfsSchema.safeExtend({
1687
+ schema: NftIpfsSchema.shape.schema.safeExtend({
1688
+ type: zod.z.literal("RecycledID").meta({
1689
+ title: "RecycledID Schema Type",
1690
+ description: "RecycledID NFT schema type"
1691
+ })
1692
+ }),
1693
+ attributes: RecycledIDAttributesSchema,
1694
+ data: RecycledIDDataSchema
1695
+ }).meta(RecycledIDIpfsSchemaMeta);
1637
1696
 
1638
1697
  exports.AccreditedParticipantSchema = AccreditedParticipantSchema;
1639
1698
  exports.AccreditedParticipantsSchema = AccreditedParticipantsSchema;
1699
+ exports.AdministrativeDivisionSchema = AdministrativeDivisionSchema;
1640
1700
  exports.AuditReferenceSchema = AuditReferenceSchema;
1641
1701
  exports.BaseIpfsSchema = BaseIpfsSchema;
1642
1702
  exports.BlockchainChainIdSchema = BlockchainChainIdSchema;
1643
1703
  exports.CoordinatesSchema = CoordinatesSchema;
1704
+ exports.CountryNameSchema = CountryNameSchema;
1705
+ exports.CreditAmountAttributeSchema = CreditAmountAttributeSchema;
1706
+ exports.CreditAmountSchema = CreditAmountSchema;
1707
+ exports.CreditTypeAttributeSchema = CreditTypeAttributeSchema;
1708
+ exports.CreditTypeSchema = CreditTypeSchema;
1644
1709
  exports.DistributionNotesSchema = DistributionNotesSchema;
1645
1710
  exports.EthereumAddressSchema = EthereumAddressSchema;
1646
1711
  exports.ExternalIdSchema = ExternalIdSchema;
@@ -1667,14 +1732,21 @@ exports.MassIDDataSchema = MassIDDataSchema;
1667
1732
  exports.MassIDIpfsSchema = MassIDIpfsSchema;
1668
1733
  exports.MassIDIpfsSchemaMeta = MassIDIpfsSchemaMeta;
1669
1734
  exports.MassIDReferenceSchema = MassIDReferenceSchema;
1735
+ exports.MassIdRecyclingDateAttributeSchema = MassIdRecyclingDateAttributeSchema;
1736
+ exports.MassIdTokenIdAttributeSchema = MassIdTokenIdAttributeSchema;
1737
+ exports.MethodologyAttributeSchema = MethodologyAttributeSchema;
1670
1738
  exports.MethodologyComplianceSchema = MethodologyComplianceSchema;
1739
+ exports.MethodologyNameSchema = MethodologyNameSchema;
1671
1740
  exports.MethodologyReferenceSchema = MethodologyReferenceSchema;
1672
1741
  exports.MinutesSchema = MinutesSchema;
1742
+ exports.MunicipalitySchema = MunicipalitySchema;
1673
1743
  exports.NftAttributeSchema = NftAttributeSchema;
1674
1744
  exports.NftIpfsSchema = NftIpfsSchema;
1675
1745
  exports.NonEmptyStringSchema = NonEmptyStringSchema;
1676
1746
  exports.NonNegativeFloatSchema = NonNegativeFloatSchema;
1677
1747
  exports.NonNegativeIntegerSchema = NonNegativeIntegerSchema;
1748
+ exports.OriginCountryAttributeSchema = OriginCountryAttributeSchema;
1749
+ exports.OriginMunicipalityAttributeSchema = OriginMunicipalityAttributeSchema;
1678
1750
  exports.ParticipantNameSchema = ParticipantNameSchema;
1679
1751
  exports.ParticipantRewardsSchema = ParticipantRewardsSchema;
1680
1752
  exports.ParticipantRoleSchema = ParticipantRoleSchema;
@@ -1684,10 +1756,18 @@ exports.PositiveIntegerSchema = PositiveIntegerSchema;
1684
1756
  exports.RecordEnvironmentSchema = RecordEnvironmentSchema;
1685
1757
  exports.RecordRelationshipTypeSchema = RecordRelationshipTypeSchema;
1686
1758
  exports.RecordSchemaTypeSchema = RecordSchemaTypeSchema;
1759
+ exports.RecycledIDAttributesSchema = RecycledIDAttributesSchema;
1760
+ exports.RecycledIDDataSchema = RecycledIDDataSchema;
1761
+ exports.RecycledIDIpfsSchema = RecycledIDIpfsSchema;
1762
+ exports.RecycledIDIpfsSchemaMeta = RecycledIDIpfsSchemaMeta;
1763
+ exports.RecyclerAttributeSchema = RecyclerAttributeSchema;
1687
1764
  exports.RewardAllocationSchema = RewardAllocationSchema;
1688
1765
  exports.SemanticVersionSchema = SemanticVersionSchema;
1689
1766
  exports.Sha256HashSchema = Sha256HashSchema;
1690
1767
  exports.SlugSchema = SlugSchema;
1768
+ exports.SourceWasteTypeAttributeSchema = SourceWasteTypeAttributeSchema;
1769
+ exports.SourceWeightAttributeSchema = SourceWeightAttributeSchema;
1770
+ exports.StringifiedTokenIdSchema = StringifiedTokenIdSchema;
1691
1771
  exports.TokenIdSchema = TokenIdSchema;
1692
1772
  exports.TokenSymbolSchema = TokenSymbolSchema;
1693
1773
  exports.UnixTimestampSchema = UnixTimestampSchema;