@carrot-foundation/schemas 0.1.36 → 0.1.38

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (42) hide show
  1. package/dist/index.cjs +1778 -36
  2. package/dist/index.cjs.map +1 -1
  3. package/dist/index.d.cts +1510 -14
  4. package/dist/index.d.ts +1510 -14
  5. package/dist/index.js +1735 -37
  6. package/dist/index.js.map +1 -1
  7. package/package.json +1 -1
  8. package/schemas/ipfs/collection/collection.example.json +1 -0
  9. package/schemas/ipfs/collection/collection.schema.json +306 -32
  10. package/schemas/ipfs/credit/credit.example.json +1 -0
  11. package/schemas/ipfs/credit/credit.schema.json +327 -45
  12. package/schemas/ipfs/credit-purchase-receipt/credit-purchase-receipt.example.json +290 -0
  13. package/schemas/ipfs/credit-purchase-receipt/credit-purchase-receipt.schema.json +1772 -0
  14. package/schemas/ipfs/credit-retirement-receipt/credit-retirement-receipt.example.json +280 -0
  15. package/schemas/ipfs/credit-retirement-receipt/credit-retirement-receipt.schema.json +1704 -0
  16. package/schemas/ipfs/gas-id/gas-id.schema.json +7 -6
  17. package/schemas/ipfs/mass-id/mass-id.schema.json +7 -6
  18. package/schemas/ipfs/mass-id-audit/mass-id-audit.example.json +30 -29
  19. package/schemas/ipfs/mass-id-audit/mass-id-audit.schema.json +637 -15
  20. package/schemas/ipfs/methodology/methodology.example.json +27 -26
  21. package/schemas/ipfs/methodology/methodology.schema.json +458 -15
  22. package/schemas/ipfs/recycled-id/recycled-id.schema.json +7 -6
  23. package/schemas/ipfs/gas-id/gas-id.attributes.schema.json +0 -219
  24. package/schemas/ipfs/gas-id/gas-id.data.schema.json +0 -120
  25. package/schemas/ipfs/mass-id-audit/mass-id-audit.data.schema.json +0 -130
  26. package/schemas/ipfs/methodology/methodology.data.schema.json +0 -121
  27. package/schemas/ipfs/purchase-id/purchase-id.attributes.schema.json +0 -91
  28. package/schemas/ipfs/purchase-id/purchase-id.data.schema.json +0 -337
  29. package/schemas/ipfs/purchase-id/purchase-id.example.json +0 -224
  30. package/schemas/ipfs/purchase-id/purchase-id.schema.json +0 -29
  31. package/schemas/ipfs/recycled-id/recycled-id.attributes.schema.json +0 -202
  32. package/schemas/ipfs/recycled-id/recycled-id.data.schema.json +0 -63
  33. package/schemas/ipfs/shared/base/base.schema.json +0 -163
  34. package/schemas/ipfs/shared/certificate/certificate.schema.json +0 -145
  35. package/schemas/ipfs/shared/definitions/definitions.schema.json +0 -255
  36. package/schemas/ipfs/shared/entities/location/location.schema.json +0 -90
  37. package/schemas/ipfs/shared/entities/participant/participant.schema.json +0 -28
  38. package/schemas/ipfs/shared/nft/nft.schema.json +0 -182
  39. package/schemas/ipfs/shared/references/audit-reference/audit-reference.schema.json +0 -42
  40. package/schemas/ipfs/shared/references/gas-id-reference/gas-id-reference.schema.json +0 -27
  41. package/schemas/ipfs/shared/references/mass-id-reference/mass-id-reference.schema.json +0 -27
  42. package/schemas/ipfs/shared/references/methodology-reference/methodology-reference.schema.json +0 -34
package/dist/index.js CHANGED
@@ -13,7 +13,7 @@ var UuidSchema = z.uuidv4("Must be a valid UUID v4 string").meta({
13
13
  ]
14
14
  });
15
15
  var EthereumAddressSchema = z.string().regex(
16
- /^0x[a-fA-F0-9]{40}$/,
16
+ /^0x[a-f0-9]{40}$/,
17
17
  "Must be a valid Ethereum address in lowercase hexadecimal format"
18
18
  ).meta({
19
19
  title: "Ethereum Address",
@@ -88,6 +88,11 @@ var CountryNameSchema = NonEmptyStringSchema.max(50).meta({
88
88
  description: "Full country name in English",
89
89
  examples: ["Brazil", "United States", "Germany", "Japan"]
90
90
  });
91
+ var CollectionNameSchema = NonEmptyStringSchema.max(150).meta({
92
+ title: "Collection Name",
93
+ description: "Display name of the collection",
94
+ examples: ["BOLD Cold Start - Carazinho", "BOLD Brazil"]
95
+ });
91
96
  var MethodologyNameSchema = NonEmptyStringSchema.max(100).meta({
92
97
  title: "Methodology Name",
93
98
  description: "Name of the methodology used for certification",
@@ -109,6 +114,11 @@ var SlugSchema = NonEmptyStringSchema.regex(
109
114
  description: "URL-friendly identifier with lowercase letters, numbers, and hyphens",
110
115
  examples: ["mass-id-123", "recycled-plastic", "organic-waste"]
111
116
  });
117
+ var CollectionSlugSchema = SlugSchema.meta({
118
+ title: "Collection Slug",
119
+ description: "URL-friendly identifier for a collection",
120
+ examples: ["bold-cold-start-carazinho", "bold-brazil"]
121
+ });
112
122
  var WasteTypeSchema = NonEmptyStringSchema.max(100).meta({
113
123
  title: "Waste Type",
114
124
  description: "Category or type of waste material",
@@ -148,6 +158,23 @@ var BlockchainChainIdSchema = z.number().int().min(1).meta({
148
158
  description: "Blockchain network identifier",
149
159
  examples: [1, 137, 11155111]
150
160
  });
161
+ var BlockchainNetworkNameSchema = NonEmptyStringSchema.max(100).meta({
162
+ title: "Blockchain Network Name",
163
+ description: "Name of the blockchain network",
164
+ examples: ["Polygon", "Ethereum mainnet", "Sepolia"]
165
+ });
166
+ var SmartContractAddressSchema = EthereumAddressSchema.meta({
167
+ title: "Smart Contract Address",
168
+ description: "Address of the smart contract"
169
+ });
170
+ var SmartContractSchema = z.strictObject({
171
+ address: SmartContractAddressSchema,
172
+ chain_id: BlockchainChainIdSchema,
173
+ network_name: BlockchainNetworkNameSchema
174
+ }).meta({
175
+ title: "Smart Contract",
176
+ description: "Smart contract details for on-chain references"
177
+ });
151
178
  var PercentageSchema = z.number().min(0).max(100).meta({
152
179
  title: "Percentage",
153
180
  description: "Percentage value between 0 and 100",
@@ -262,7 +289,8 @@ var RecordSchemaTypeSchema = z.enum([
262
289
  "MassID Audit",
263
290
  "RecycledID",
264
291
  "GasID",
265
- "PurchaseID",
292
+ "CreditPurchaseReceipt",
293
+ "CreditRetirementReceipt",
266
294
  "Methodology",
267
295
  "Credit",
268
296
  "Collection"
@@ -279,6 +307,11 @@ var TokenSymbolSchema = NonEmptyStringSchema.max(10).regex(
279
307
  description: "Symbol representing a token or cryptocurrency",
280
308
  examples: ["MASS", "REC", "GAS"]
281
309
  });
310
+ var CreditTokenSymbolSchema = TokenSymbolSchema.meta({
311
+ title: "Credit Token Symbol",
312
+ description: "Symbol of the credit token (e.g., C-CARB, C-BIOW)",
313
+ examples: ["C-CARB", "C-BIOW"]
314
+ });
282
315
  var RecordRelationshipTypeSchema = z.enum([
283
316
  "collection",
284
317
  "credit",
@@ -286,12 +319,13 @@ var RecordRelationshipTypeSchema = z.enum([
286
319
  "mass-id",
287
320
  "mass-id-audit",
288
321
  "methodology",
289
- "purchase-id",
322
+ "credit-purchase-receipt",
323
+ "credit-retirement-receipt",
290
324
  "recycled-id"
291
325
  ]).meta({
292
326
  title: "Relationship Type",
293
327
  description: "Type of relationship between different entities in the system",
294
- examples: ["mass-id", "audit", "collection"]
328
+ examples: ["mass-id", "collection", "credit-purchase-receipt"]
295
329
  });
296
330
  function uniqueArrayItems(schema, errorMessage = "Array items must be unique") {
297
331
  return z.array(schema).refine((items) => new Set(items).size === items.length, {
@@ -704,7 +738,8 @@ var NftSchemaTypeSchema = RecordSchemaTypeSchema.extract([
704
738
  "MassID",
705
739
  "RecycledID",
706
740
  "GasID",
707
- "PurchaseID"
741
+ "CreditPurchaseReceipt",
742
+ "CreditRetirementReceipt"
708
743
  ]).meta({
709
744
  title: "NFT Schema Type",
710
745
  description: "Type of schema for NFT records"
@@ -881,16 +916,16 @@ function buildSchemaUrl(schemaPath) {
881
916
  return `${getSchemaBaseUrl()}/${cleanPath}`;
882
917
  }
883
918
  function getSchemaVersionOrDefault() {
884
- return "0.1.36";
919
+ return "0.1.38";
885
920
  }
886
- var MethodologyAttributeSchema = NftAttributeSchema.extend({
921
+ var MethodologyAttributeSchema = NftAttributeSchema.safeExtend({
887
922
  trait_type: z.literal("Methodology"),
888
923
  value: MethodologyNameSchema
889
924
  }).meta({
890
925
  title: "Methodology Attribute",
891
926
  description: "Methodology used for certification"
892
927
  });
893
- var CreditAmountAttributeSchema = NftAttributeSchema.extend({
928
+ var CreditAmountAttributeSchema = NftAttributeSchema.safeExtend({
894
929
  trait_type: z.literal("Credit Amount"),
895
930
  value: CreditAmountSchema,
896
931
  display_type: z.literal("number")
@@ -898,21 +933,21 @@ var CreditAmountAttributeSchema = NftAttributeSchema.extend({
898
933
  title: "Credit Amount Attribute",
899
934
  description: "Credit amount attribute with numeric display"
900
935
  });
901
- var CreditTypeAttributeSchema = NftAttributeSchema.extend({
936
+ var CreditTypeAttributeSchema = NftAttributeSchema.safeExtend({
902
937
  trait_type: z.literal("Credit Type"),
903
938
  value: CreditTypeSchema
904
939
  }).meta({
905
940
  title: "Credit Type Attribute",
906
941
  description: "Credit type attribute"
907
942
  });
908
- var SourceWasteTypeAttributeSchema = NftAttributeSchema.extend({
943
+ var SourceWasteTypeAttributeSchema = NftAttributeSchema.safeExtend({
909
944
  trait_type: z.literal("Source Waste Type"),
910
945
  value: WasteTypeSchema
911
946
  }).meta({
912
947
  title: "Source Waste Type Attribute",
913
948
  description: "Source waste type attribute"
914
949
  });
915
- var SourceWeightAttributeSchema = NftAttributeSchema.extend({
950
+ var SourceWeightAttributeSchema = NftAttributeSchema.safeExtend({
916
951
  trait_type: z.literal("Source Weight (kg)"),
917
952
  value: WeightKgSchema.meta({
918
953
  title: "Source Weight",
@@ -923,21 +958,21 @@ var SourceWeightAttributeSchema = NftAttributeSchema.extend({
923
958
  title: "Source Weight Attribute",
924
959
  description: "Source weight attribute with numeric display"
925
960
  });
926
- var OriginCountryAttributeSchema = NftAttributeSchema.extend({
961
+ var OriginCountryAttributeSchema = NftAttributeSchema.safeExtend({
927
962
  trait_type: z.literal("Origin Country"),
928
963
  value: CountryNameSchema
929
964
  }).meta({
930
965
  title: "Origin Country Attribute",
931
966
  description: "Origin country attribute"
932
967
  });
933
- var OriginMunicipalityAttributeSchema = NftAttributeSchema.extend({
968
+ var OriginMunicipalityAttributeSchema = NftAttributeSchema.safeExtend({
934
969
  trait_type: z.literal("Origin Municipality"),
935
970
  value: MunicipalitySchema
936
971
  }).meta({
937
972
  title: "Origin Municipality Attribute",
938
973
  description: "Origin municipality attribute"
939
974
  });
940
- var RecyclerAttributeSchema = NftAttributeSchema.extend({
975
+ var RecyclerAttributeSchema = NftAttributeSchema.safeExtend({
941
976
  trait_type: z.literal("Recycler"),
942
977
  value: NonEmptyStringSchema.max(100).meta({
943
978
  title: "Recycler",
@@ -948,7 +983,7 @@ var RecyclerAttributeSchema = NftAttributeSchema.extend({
948
983
  title: "Recycler Attribute",
949
984
  description: "Recycler attribute"
950
985
  });
951
- var MassIDTokenIdAttributeSchema = NftAttributeSchema.extend({
986
+ var MassIDTokenIdAttributeSchema = NftAttributeSchema.safeExtend({
952
987
  trait_type: z.literal("MassID"),
953
988
  value: StringifiedTokenIdSchema.meta({
954
989
  title: "MassID Token ID",
@@ -960,7 +995,7 @@ var MassIDTokenIdAttributeSchema = NftAttributeSchema.extend({
960
995
  });
961
996
  var MassIDRecyclingDateAttributeSchema = NftAttributeSchema.omit({
962
997
  max_value: true
963
- }).extend({
998
+ }).safeExtend({
964
999
  trait_type: z.literal("MassID Recycling Date"),
965
1000
  value: UnixTimestampSchema.meta({
966
1001
  title: "MassID Recycling Date",
@@ -971,23 +1006,433 @@ var MassIDRecyclingDateAttributeSchema = NftAttributeSchema.omit({
971
1006
  title: "MassID Recycling Date Attribute",
972
1007
  description: "MassID recycling date attribute using Unix timestamp in milliseconds"
973
1008
  });
1009
+ var AuditRuleDefinitionSchema = z.strictObject({
1010
+ rule_id: UuidSchema.meta({
1011
+ title: "Rule ID",
1012
+ description: "Unique identifier for the audit rule"
1013
+ }),
1014
+ rule_slug: SlugSchema.meta({
1015
+ title: "Rule Slug",
1016
+ description: "URL-friendly identifier for the rule"
1017
+ }),
1018
+ rule_name: NonEmptyStringSchema.max(100).meta({
1019
+ title: "Rule Name",
1020
+ description: "Human-readable name of the rule",
1021
+ examples: ["Waste Mass is Unique", "No Conflicting GasID or Credit"]
1022
+ }),
1023
+ description: z.string().min(10).max(500).meta({
1024
+ title: "Rule Description",
1025
+ description: "Detailed description of what the rule validates and why it is necessary",
1026
+ examples: [
1027
+ "Validates that each MassID is unique within the system to prevent duplicate entries"
1028
+ ]
1029
+ }),
1030
+ source_code_url: z.url().regex(/^https:\/\/github\.com\/.*$/, "Must be a GitHub URL").meta({
1031
+ title: "Rule Source Code URL",
1032
+ description: "GitHub URL pointing to the implementation source code for this rule",
1033
+ examples: [
1034
+ "https://github.com/carrot-foundation/methodologies/blob/main/bold-carbon/rules/waste-mass-unique.js"
1035
+ ]
1036
+ }),
1037
+ mandatory: z.boolean().meta({
1038
+ title: "Mandatory",
1039
+ description: "Whether this rule is mandatory for methodology compliance"
1040
+ }),
1041
+ execution_order: PositiveIntegerSchema.meta({
1042
+ title: "Rule Execution Order",
1043
+ description: "Sequential order in which this rule must be executed"
1044
+ })
1045
+ }).meta({
1046
+ title: "Audit Rule Definition",
1047
+ description: "Definition of an audit rule that must be executed for methodology compliance"
1048
+ });
1049
+ var AuditRuleDefinitionsSchema = z.array(AuditRuleDefinitionSchema).min(1).meta({
1050
+ title: "Audit Rule Definitions",
1051
+ description: "List of audit rules that must be executed to check methodology compliance"
1052
+ });
1053
+ var AuditRuleExecutionResultSchema = z.strictObject({
1054
+ rule_name: NonEmptyStringSchema.meta({
1055
+ title: "Rule Name",
1056
+ description: "Human-readable name of the audit rule"
1057
+ }),
1058
+ rule_id: UuidSchema.meta({
1059
+ title: "Rule ID",
1060
+ description: "Unique identifier for the rule"
1061
+ }),
1062
+ rule_slug: SlugSchema.meta({
1063
+ title: "Rule Slug",
1064
+ description: "URL-friendly identifier for the rule"
1065
+ }),
1066
+ execution_order: PositiveIntegerSchema.meta({
1067
+ title: "Rule Execution Order",
1068
+ description: "Sequential order in which this rule was executed"
1069
+ }),
1070
+ result: MethodologyComplianceSchema.meta({
1071
+ title: "Rule Execution Result",
1072
+ description: "Result of the rule execution"
1073
+ }),
1074
+ description: z.string().min(1).max(2e3).meta({
1075
+ title: "Rule Description",
1076
+ description: "Detailed description of what this rule validates"
1077
+ }),
1078
+ rule_processor_checksum: NonEmptyStringSchema.max(200).meta({
1079
+ title: "Rule Processor Checksum",
1080
+ description: "Checksum for rule processor integrity verification"
1081
+ }),
1082
+ rule_source_code_version: NonEmptyStringSchema.max(200).meta({
1083
+ title: "Rule Source Code Version",
1084
+ description: "Version identifier for the rule source code"
1085
+ })
1086
+ }).meta({
1087
+ title: "Audit Rule Execution Result",
1088
+ description: "Detailed result of an audit rule execution"
1089
+ });
1090
+ var AuditRuleExecutionResultsSchema = z.array(AuditRuleExecutionResultSchema).meta({
1091
+ title: "Audit Rule Execution Results",
1092
+ description: "Detailed results of each audit rule execution"
1093
+ });
1094
+ var EPSILON = 1e-9;
1095
+ function nearlyEqual(a, b, epsilon = EPSILON) {
1096
+ return Math.abs(a - b) <= epsilon;
1097
+ }
1098
+ var SummaryBaseSchema = z.strictObject({
1099
+ total_certificates: PositiveIntegerSchema.meta({
1100
+ title: "Total Certificates",
1101
+ description: "Total number of certificates represented in the receipt"
1102
+ }),
1103
+ credit_symbols: uniqueArrayItems(
1104
+ CreditTokenSymbolSchema,
1105
+ "Credit symbols must be unique"
1106
+ ).min(1).meta({
1107
+ title: "Credit Symbols",
1108
+ description: "Array of credit token symbols represented in the receipt"
1109
+ }),
1110
+ certificate_types: uniqueArrayItems(
1111
+ RecordSchemaTypeSchema.extract(["GasID", "RecycledID"]),
1112
+ "Certificate types must be unique"
1113
+ ).min(1).meta({
1114
+ title: "Certificate Types",
1115
+ description: "Array of certificate types represented in the receipt"
1116
+ }),
1117
+ collection_slugs: uniqueArrayItems(
1118
+ CollectionSlugSchema,
1119
+ "Collection slugs must be unique"
1120
+ ).min(1).meta({
1121
+ title: "Collection Slugs",
1122
+ description: "Array of collection slugs represented in the receipt"
1123
+ })
1124
+ });
1125
+ var CreditPurchaseReceiptSummarySchema = SummaryBaseSchema.extend({
1126
+ total_usdc_amount: NonNegativeFloatSchema.meta({
1127
+ title: "Total USDC Amount",
1128
+ description: "Total amount paid in USDC for the purchase"
1129
+ }),
1130
+ total_credits: CreditAmountSchema.meta({
1131
+ title: "Total Credits",
1132
+ description: "Total amount of credits purchased"
1133
+ }),
1134
+ purchase_date: IsoDateSchema.meta({
1135
+ title: "Purchase Date",
1136
+ description: "Date when the purchase was made (YYYY-MM-DD)"
1137
+ })
1138
+ }).meta({
1139
+ title: "Credit Purchase Receipt Summary",
1140
+ description: "Summary totals for the credit purchase including amounts and collections represented"
1141
+ });
1142
+ var CreditRetirementReceiptSummarySchema = SummaryBaseSchema.extend({
1143
+ total_retirement_amount: CreditAmountSchema.meta({
1144
+ title: "Total Retirement Amount",
1145
+ description: "Total amount of credits retired"
1146
+ }),
1147
+ retirement_date: IsoDateSchema.meta({
1148
+ title: "Retirement Date",
1149
+ description: "Date when the retirement occurred (YYYY-MM-DD)"
1150
+ })
1151
+ }).meta({
1152
+ title: "Credit Retirement Receipt Summary",
1153
+ description: "Summary totals for the credit retirement including amounts and collections represented"
1154
+ });
1155
+ var ReceiptIdentitySchema = z.strictObject({
1156
+ name: ParticipantNameSchema.meta({
1157
+ title: "Identity Name",
1158
+ description: "Display name for the participant",
1159
+ examples: ["EcoTech Solutions Inc.", "Climate Action Corp"]
1160
+ }),
1161
+ external_id: ExternalIdSchema.meta({
1162
+ title: "Identity External ID",
1163
+ description: "External identifier for the participant"
1164
+ }),
1165
+ external_url: ExternalUrlSchema.meta({
1166
+ title: "Identity External URL",
1167
+ description: "External URL for the participant profile"
1168
+ })
1169
+ }).meta({
1170
+ title: "Identity",
1171
+ description: "Participant identity information"
1172
+ });
1173
+ var MassIdReferenceWithContractSchema = MassIDReferenceSchema.safeExtend({
1174
+ smart_contract: SmartContractSchema
1175
+ }).meta({
1176
+ title: "MassID Reference with Smart Contract",
1177
+ description: "Reference to a MassID record including smart contract details"
1178
+ });
1179
+ function createReceiptCollectionSchema(params) {
1180
+ const { amountKey, amountMeta, meta } = params;
1181
+ return z.strictObject({
1182
+ slug: CollectionSlugSchema,
1183
+ external_id: ExternalIdSchema.meta({
1184
+ title: "Collection External ID",
1185
+ description: "External identifier for the collection"
1186
+ }),
1187
+ name: CollectionNameSchema,
1188
+ external_url: ExternalUrlSchema.meta({
1189
+ title: "Collection External URL",
1190
+ description: "External URL for the collection"
1191
+ }),
1192
+ uri: IpfsUriSchema.meta({
1193
+ title: "Collection URI",
1194
+ description: "IPFS URI for the collection metadata"
1195
+ }),
1196
+ [amountKey]: CreditAmountSchema.meta(amountMeta)
1197
+ }).meta(meta);
1198
+ }
1199
+ function createReceiptCreditSchema(params) {
1200
+ const { amountKey, amountMeta, meta, retirementAmountMeta } = params;
1201
+ const creditShape = {
1202
+ slug: SlugSchema.meta({
1203
+ title: "Credit Slug",
1204
+ description: "URL-friendly identifier for the credit"
1205
+ }),
1206
+ symbol: CreditTokenSymbolSchema.meta({
1207
+ title: "Credit Token Symbol",
1208
+ description: "Symbol of the credit token",
1209
+ examples: ["CARBON", "ORGANIC", "C-CARB", "C-BIOW"]
1210
+ }),
1211
+ external_id: ExternalIdSchema.meta({
1212
+ title: "Credit External ID",
1213
+ description: "External identifier for the credit"
1214
+ }),
1215
+ external_url: ExternalUrlSchema.meta({
1216
+ title: "Credit External URL",
1217
+ description: "External URL for the credit"
1218
+ }),
1219
+ uri: IpfsUriSchema.meta({
1220
+ title: "Credit URI",
1221
+ description: "IPFS URI for the credit details"
1222
+ }),
1223
+ smart_contract: SmartContractSchema,
1224
+ [amountKey]: CreditAmountSchema.meta(amountMeta)
1225
+ };
1226
+ if (retirementAmountMeta) {
1227
+ creditShape.retirement_amount = CreditAmountSchema.optional().meta(retirementAmountMeta);
1228
+ }
1229
+ return z.strictObject(creditShape).meta(meta);
1230
+ }
1231
+ var certificateBaseShape = {
1232
+ token_id: TokenIdSchema.meta({
1233
+ title: "Certificate Token ID",
1234
+ description: "Token ID of the certificate"
1235
+ }),
1236
+ type: RecordSchemaTypeSchema.extract(["GasID", "RecycledID"]).meta({
1237
+ title: "Certificate Type",
1238
+ description: "Type of certificate (e.g., GasID, RecycledID)"
1239
+ }),
1240
+ external_id: ExternalIdSchema.meta({
1241
+ title: "Certificate External ID",
1242
+ description: "External identifier for the certificate"
1243
+ }),
1244
+ external_url: ExternalUrlSchema.meta({
1245
+ title: "Certificate External URL",
1246
+ description: "External URL for the certificate"
1247
+ }),
1248
+ uri: IpfsUriSchema.meta({
1249
+ title: "Certificate URI",
1250
+ description: "IPFS URI for the certificate metadata"
1251
+ }),
1252
+ smart_contract: SmartContractSchema,
1253
+ collection_slug: CollectionSlugSchema.meta({
1254
+ title: "Collection Slug",
1255
+ description: "Slug of the collection this certificate belongs to"
1256
+ }),
1257
+ total_amount: CreditAmountSchema.meta({
1258
+ title: "Certificate Total Amount",
1259
+ description: "Total credits available in this certificate"
1260
+ }),
1261
+ mass_id: MassIdReferenceWithContractSchema
1262
+ };
1263
+ function createReceiptCertificateSchema(params) {
1264
+ return z.strictObject({
1265
+ ...certificateBaseShape,
1266
+ ...params.additionalShape
1267
+ }).meta(params.meta);
1268
+ }
1269
+
1270
+ // src/shared/receipt/receipt.validation.ts
1271
+ function buildMessage(message, value) {
1272
+ return typeof message === "function" ? message(value) : message;
1273
+ }
1274
+ function createAttributeMap(attributes) {
1275
+ return new Map(
1276
+ attributes.map((attribute) => [attribute.trait_type, attribute])
1277
+ );
1278
+ }
1279
+ function validateSummaryListMatchesData(params) {
1280
+ const { ctx, summaryValues, dataValues, summaryPath } = params;
1281
+ const summarySet = new Set(summaryValues);
1282
+ const dataSet = new Set(dataValues);
1283
+ summarySet.forEach((value) => {
1284
+ if (!dataSet.has(value)) {
1285
+ ctx.addIssue({
1286
+ code: "custom",
1287
+ message: buildMessage(params.missingFromDataMessage, value),
1288
+ path: summaryPath
1289
+ });
1290
+ }
1291
+ });
1292
+ dataSet.forEach((value) => {
1293
+ if (!summarySet.has(value)) {
1294
+ ctx.addIssue({
1295
+ code: "custom",
1296
+ message: buildMessage(params.missingFromSummaryMessage, value),
1297
+ path: summaryPath
1298
+ });
1299
+ }
1300
+ });
1301
+ }
1302
+ function validateTotalMatches(params) {
1303
+ const { ctx, actualTotal, expectedTotal, path, message } = params;
1304
+ if (!nearlyEqual(actualTotal, expectedTotal)) {
1305
+ ctx.addIssue({
1306
+ code: "custom",
1307
+ message,
1308
+ path
1309
+ });
1310
+ }
1311
+ }
1312
+ function validateCountMatches(params) {
1313
+ const { ctx, actualCount, expectedCount, path, message } = params;
1314
+ if (actualCount !== expectedCount) {
1315
+ ctx.addIssue({
1316
+ code: "custom",
1317
+ message,
1318
+ path
1319
+ });
1320
+ }
1321
+ }
1322
+ function validateAttributeValue(params) {
1323
+ const {
1324
+ ctx,
1325
+ attributeByTraitType,
1326
+ traitType,
1327
+ expectedValue,
1328
+ missingMessage,
1329
+ mismatchMessage,
1330
+ path = ["attributes"]
1331
+ } = params;
1332
+ const attribute = attributeByTraitType.get(traitType);
1333
+ if (!attribute) {
1334
+ ctx.addIssue({
1335
+ code: "custom",
1336
+ message: missingMessage,
1337
+ path
1338
+ });
1339
+ return;
1340
+ }
1341
+ if (attribute.value !== expectedValue) {
1342
+ ctx.addIssue({
1343
+ code: "custom",
1344
+ message: mismatchMessage,
1345
+ path
1346
+ });
1347
+ }
1348
+ }
1349
+ function validateDateAttribute(params) {
1350
+ const {
1351
+ ctx,
1352
+ attributeByTraitType,
1353
+ traitType,
1354
+ dateValue,
1355
+ missingMessage,
1356
+ invalidDateMessage,
1357
+ mismatchMessage,
1358
+ attributePath = ["attributes"],
1359
+ datePath
1360
+ } = params;
1361
+ const attribute = attributeByTraitType.get(traitType);
1362
+ if (!attribute) {
1363
+ ctx.addIssue({
1364
+ code: "custom",
1365
+ message: missingMessage,
1366
+ path: attributePath
1367
+ });
1368
+ return;
1369
+ }
1370
+ const dateMs = Date.parse(`${dateValue}T00:00:00.000Z`);
1371
+ if (Number.isNaN(dateMs)) {
1372
+ ctx.addIssue({
1373
+ code: "custom",
1374
+ message: invalidDateMessage,
1375
+ path: datePath ?? attributePath
1376
+ });
1377
+ return;
1378
+ }
1379
+ if (attribute.value !== dateMs) {
1380
+ ctx.addIssue({
1381
+ code: "custom",
1382
+ message: mismatchMessage,
1383
+ path: attributePath
1384
+ });
1385
+ }
1386
+ }
1387
+ function validateAttributesForItems(params) {
1388
+ const {
1389
+ ctx,
1390
+ attributeByTraitType,
1391
+ items,
1392
+ traitSelector,
1393
+ valueSelector,
1394
+ missingMessage,
1395
+ mismatchMessage,
1396
+ path = ["attributes"]
1397
+ } = params;
1398
+ items.forEach((item) => {
1399
+ const traitType = traitSelector(item);
1400
+ const expectedValue = valueSelector(item);
1401
+ const attribute = attributeByTraitType.get(traitType);
1402
+ if (!attribute) {
1403
+ ctx.addIssue({
1404
+ code: "custom",
1405
+ message: missingMessage(traitType),
1406
+ path
1407
+ });
1408
+ return;
1409
+ }
1410
+ if (attribute.value !== expectedValue) {
1411
+ ctx.addIssue({
1412
+ code: "custom",
1413
+ message: mismatchMessage(traitType),
1414
+ path
1415
+ });
1416
+ }
1417
+ });
1418
+ }
974
1419
 
975
1420
  // src/mass-id/mass-id.attributes.ts
976
- var MassIDAttributeWasteTypeSchema = NftAttributeSchema.extend({
1421
+ var MassIDAttributeWasteTypeSchema = NftAttributeSchema.safeExtend({
977
1422
  trait_type: z.literal("Waste Type"),
978
1423
  value: WasteTypeSchema
979
1424
  }).meta({
980
1425
  title: "Waste Type Attribute",
981
1426
  description: "Waste type attribute"
982
1427
  });
983
- var MassIDAttributeWasteSubtypeSchema = NftAttributeSchema.extend({
1428
+ var MassIDAttributeWasteSubtypeSchema = NftAttributeSchema.safeExtend({
984
1429
  trait_type: z.literal("Waste Subtype"),
985
1430
  value: WasteSubtypeSchema
986
1431
  }).meta({
987
1432
  title: "Waste Subtype Attribute",
988
1433
  description: "Waste subtype attribute"
989
1434
  });
990
- var MassIDAttributeWeightSchema = NftAttributeSchema.extend({
1435
+ var MassIDAttributeWeightSchema = NftAttributeSchema.safeExtend({
991
1436
  trait_type: z.literal("Weight (kg)"),
992
1437
  value: WeightKgSchema,
993
1438
  display_type: z.literal("number")
@@ -995,20 +1440,20 @@ var MassIDAttributeWeightSchema = NftAttributeSchema.extend({
995
1440
  title: "Weight Attribute",
996
1441
  description: "Weight attribute with numeric display"
997
1442
  });
998
- var MassIDAttributeOriginCountrySchema = OriginCountryAttributeSchema.extend({
1443
+ var MassIDAttributeOriginCountrySchema = OriginCountryAttributeSchema.safeExtend({
999
1444
  value: CountryNameSchema
1000
1445
  });
1001
- var MassIDAttributeOriginMunicipalitySchema = OriginMunicipalityAttributeSchema.extend({
1446
+ var MassIDAttributeOriginMunicipalitySchema = OriginMunicipalityAttributeSchema.safeExtend({
1002
1447
  value: MunicipalitySchema
1003
1448
  });
1004
- var MassIDAttributeOriginDivisionSchema = NftAttributeSchema.extend({
1449
+ var MassIDAttributeOriginDivisionSchema = NftAttributeSchema.safeExtend({
1005
1450
  trait_type: z.literal("Origin Administrative Division"),
1006
1451
  value: AdministrativeDivisionSchema
1007
1452
  }).meta({
1008
1453
  title: "Origin Administrative Division Attribute",
1009
1454
  description: "Origin administrative division attribute"
1010
1455
  });
1011
- var MassIDAttributeVehicleTypeSchema = NftAttributeSchema.extend({
1456
+ var MassIDAttributeVehicleTypeSchema = NftAttributeSchema.safeExtend({
1012
1457
  trait_type: z.literal("Vehicle Type"),
1013
1458
  value: NonEmptyStringSchema.max(100).meta({
1014
1459
  title: "Vehicle Type",
@@ -1019,7 +1464,7 @@ var MassIDAttributeVehicleTypeSchema = NftAttributeSchema.extend({
1019
1464
  title: "Vehicle Type Attribute",
1020
1465
  description: "Vehicle type attribute"
1021
1466
  });
1022
- var MassIDAttributeRecyclingMethodSchema = NftAttributeSchema.extend({
1467
+ var MassIDAttributeRecyclingMethodSchema = NftAttributeSchema.safeExtend({
1023
1468
  trait_type: z.literal("Recycling Method"),
1024
1469
  value: NonEmptyStringSchema.max(100).meta({
1025
1470
  title: "Recycling Method",
@@ -1034,7 +1479,7 @@ var MassIDAttributeRecyclingMethodSchema = NftAttributeSchema.extend({
1034
1479
  title: "Recycling Method Attribute",
1035
1480
  description: "Recycling method attribute"
1036
1481
  });
1037
- var MassIDAttributeProcessingTimeSchema = NftAttributeSchema.extend({
1482
+ var MassIDAttributeProcessingTimeSchema = NftAttributeSchema.safeExtend({
1038
1483
  trait_type: z.literal("Processing Time (hours)"),
1039
1484
  value: HoursSchema,
1040
1485
  trait_description: NonEmptyStringSchema.max(200).optional().meta({
@@ -1045,7 +1490,7 @@ var MassIDAttributeProcessingTimeSchema = NftAttributeSchema.extend({
1045
1490
  title: "Processing Time Attribute",
1046
1491
  description: "Processing time attribute with optional trait description"
1047
1492
  });
1048
- var MassIDAttributeLocalWasteClassificationIdSchema = NftAttributeSchema.extend({
1493
+ var MassIDAttributeLocalWasteClassificationIdSchema = NftAttributeSchema.safeExtend({
1049
1494
  trait_type: z.literal("Local Waste Classification ID"),
1050
1495
  value: NonEmptyStringSchema.max(100).meta({
1051
1496
  title: "Local Waste Classification ID",
@@ -1056,7 +1501,7 @@ var MassIDAttributeLocalWasteClassificationIdSchema = NftAttributeSchema.extend(
1056
1501
  title: "Local Waste Classification ID Attribute",
1057
1502
  description: "Local waste classification ID attribute"
1058
1503
  });
1059
- var MassIDAttributeRecyclingManifestCodeSchema = NftAttributeSchema.extend({
1504
+ var MassIDAttributeRecyclingManifestCodeSchema = NftAttributeSchema.safeExtend({
1060
1505
  trait_type: z.literal("Recycling Manifest Code"),
1061
1506
  value: NonEmptyStringSchema.max(100).meta({
1062
1507
  title: "Recycling Manifest Code",
@@ -1067,7 +1512,7 @@ var MassIDAttributeRecyclingManifestCodeSchema = NftAttributeSchema.extend({
1067
1512
  title: "Recycling Manifest Code Attribute",
1068
1513
  description: "Recycling manifest code attribute (optional)"
1069
1514
  });
1070
- var MassIDAttributeTransportManifestCodeSchema = NftAttributeSchema.extend({
1515
+ var MassIDAttributeTransportManifestCodeSchema = NftAttributeSchema.safeExtend({
1071
1516
  trait_type: z.literal("Transport Manifest Code"),
1072
1517
  value: NonEmptyStringSchema.max(100).meta({
1073
1518
  title: "Transport Manifest Code",
@@ -1078,7 +1523,7 @@ var MassIDAttributeTransportManifestCodeSchema = NftAttributeSchema.extend({
1078
1523
  title: "Transport Manifest Code Attribute",
1079
1524
  description: "Transport manifest code attribute (optional)"
1080
1525
  });
1081
- var MassIDAttributeWeighingCaptureMethodSchema = NftAttributeSchema.extend({
1526
+ var MassIDAttributeWeighingCaptureMethodSchema = NftAttributeSchema.safeExtend({
1082
1527
  trait_type: z.literal("Weighing Capture Method"),
1083
1528
  value: NonEmptyStringSchema.max(100).meta({
1084
1529
  title: "Weighing Capture Method",
@@ -1089,7 +1534,7 @@ var MassIDAttributeWeighingCaptureMethodSchema = NftAttributeSchema.extend({
1089
1534
  title: "Weighing Capture Method Attribute",
1090
1535
  description: "Weighing capture method attribute (optional)"
1091
1536
  });
1092
- var MassIDAttributeScaleTypeSchema = NftAttributeSchema.extend({
1537
+ var MassIDAttributeScaleTypeSchema = NftAttributeSchema.safeExtend({
1093
1538
  trait_type: z.literal("Scale Type"),
1094
1539
  value: NonEmptyStringSchema.max(100).meta({
1095
1540
  title: "Scale Type",
@@ -1105,7 +1550,7 @@ var MassIDAttributeScaleTypeSchema = NftAttributeSchema.extend({
1105
1550
  title: "Scale Type Attribute",
1106
1551
  description: "Scale type attribute (optional)"
1107
1552
  });
1108
- var MassIDAttributeContainerTypeSchema = NftAttributeSchema.extend({
1553
+ var MassIDAttributeContainerTypeSchema = NftAttributeSchema.safeExtend({
1109
1554
  trait_type: z.literal("Container Type"),
1110
1555
  value: NonEmptyStringSchema.max(100).meta({
1111
1556
  title: "Container Type",
@@ -1116,7 +1561,7 @@ var MassIDAttributeContainerTypeSchema = NftAttributeSchema.extend({
1116
1561
  title: "Container Type Attribute",
1117
1562
  description: "Container type attribute (optional)"
1118
1563
  });
1119
- var MassIDAttributePickUpDateSchema = NftAttributeSchema.extend({
1564
+ var MassIDAttributePickUpDateSchema = NftAttributeSchema.safeExtend({
1120
1565
  trait_type: z.literal("Pick-up Date"),
1121
1566
  value: UnixTimestampSchema.meta({
1122
1567
  title: "Pick-up Date",
@@ -1128,7 +1573,7 @@ var MassIDAttributePickUpDateSchema = NftAttributeSchema.extend({
1128
1573
  title: "Pick-up Date Attribute",
1129
1574
  description: "Pick-up date attribute with Unix timestamp"
1130
1575
  });
1131
- var MassIDAttributeRecyclingDateSchema = NftAttributeSchema.extend({
1576
+ var MassIDAttributeRecyclingDateSchema = NftAttributeSchema.safeExtend({
1132
1577
  trait_type: z.literal("Recycling Date"),
1133
1578
  value: UnixTimestampSchema.meta({
1134
1579
  title: "Recycling Date",
@@ -1467,7 +1912,7 @@ var MassIDIpfsSchema = NftIpfsSchema.safeExtend({
1467
1912
  data: MassIDDataSchema
1468
1913
  }).meta(MassIDIpfsSchemaMeta);
1469
1914
  var GasIDAttributeMethodologySchema = MethodologyAttributeSchema;
1470
- var GasIDAttributeGasTypeSchema = NftAttributeSchema.extend({
1915
+ var GasIDAttributeGasTypeSchema = NftAttributeSchema.safeExtend({
1471
1916
  trait_type: z.literal("Gas Type"),
1472
1917
  value: NonEmptyStringSchema.max(100).meta({
1473
1918
  title: "Gas Type",
@@ -1478,7 +1923,7 @@ var GasIDAttributeGasTypeSchema = NftAttributeSchema.extend({
1478
1923
  title: "Gas Type Attribute",
1479
1924
  description: "Gas type attribute"
1480
1925
  });
1481
- var GasIDAttributeCo2ePreventedSchema = NftAttributeSchema.extend({
1926
+ var GasIDAttributeCo2ePreventedSchema = NftAttributeSchema.safeExtend({
1482
1927
  trait_type: z.literal("CO\u2082e Prevented (kg)"),
1483
1928
  value: NonNegativeFloatSchema.meta({
1484
1929
  title: "CO\u2082e Prevented",
@@ -1612,7 +2057,7 @@ var GasIDIpfsSchema = NftIpfsSchema.safeExtend({
1612
2057
  data: GasIDDataSchema
1613
2058
  }).meta(GasIDIpfsSchemaMeta);
1614
2059
  var RecycledIDAttributeMethodologySchema = MethodologyAttributeSchema;
1615
- var RecycledIDAttributeRecycledMassWeightSchema = NftAttributeSchema.extend({
2060
+ var RecycledIDAttributeRecycledMassWeightSchema = NftAttributeSchema.safeExtend({
1616
2061
  trait_type: z.literal("Recycled Mass Weight (kg)"),
1617
2062
  value: WeightKgSchema.meta({
1618
2063
  title: "Recycled Mass Weight",
@@ -1691,7 +2136,1260 @@ var RecycledIDIpfsSchema = NftIpfsSchema.safeExtend({
1691
2136
  attributes: RecycledIDAttributesSchema,
1692
2137
  data: RecycledIDDataSchema
1693
2138
  }).meta(RecycledIDIpfsSchemaMeta);
2139
+ var CreditPurchaseReceiptCreditAttributeSchema = NftAttributeSchema.safeExtend({
2140
+ trait_type: TokenSymbolSchema.meta({
2141
+ title: "Credit Token Symbol",
2142
+ description: "Symbol of the credit token (e.g., C-CARB, C-BIOW)",
2143
+ examples: ["C-CARB", "C-BIOW"]
2144
+ }),
2145
+ value: CreditAmountSchema.meta({
2146
+ title: "Credit Amount",
2147
+ description: "Amount of credits purchased for the token symbol"
2148
+ }),
2149
+ display_type: z.literal("number")
2150
+ }).meta({
2151
+ title: "Credit Attribute",
2152
+ description: "Attribute representing purchased amount per credit token symbol"
2153
+ });
2154
+ var CreditPurchaseReceiptTotalCreditsAttributeSchema = NftAttributeSchema.safeExtend({
2155
+ trait_type: z.literal("Total Credits Purchased"),
2156
+ value: CreditAmountSchema.meta({
2157
+ title: "Total Credits Purchased",
2158
+ description: "Total number of credits purchased across all tokens"
2159
+ }),
2160
+ display_type: z.literal("number")
2161
+ }).meta({
2162
+ title: "Total Credits Purchased Attribute",
2163
+ description: "Aggregate credits purchased attribute"
2164
+ });
2165
+ var CreditPurchaseReceiptTotalUsdcAttributeSchema = NftAttributeSchema.safeExtend({
2166
+ trait_type: z.literal("Total USDC Amount"),
2167
+ value: CreditAmountSchema.meta({
2168
+ title: "Total USDC Amount",
2169
+ description: "Total USDC amount paid for the purchase"
2170
+ }),
2171
+ display_type: z.literal("number")
2172
+ }).meta({
2173
+ title: "Total USDC Amount Attribute",
2174
+ description: "Aggregate USDC amount attribute"
2175
+ });
2176
+ var CreditPurchaseReceiptPurchaseDateAttributeSchema = NftAttributeSchema.safeExtend({
2177
+ trait_type: z.literal("Purchase Date"),
2178
+ value: UnixTimestampSchema.meta({
2179
+ title: "Purchase Date",
2180
+ description: "Unix timestamp in milliseconds when the purchase was completed"
2181
+ }),
2182
+ display_type: z.literal("date")
2183
+ }).meta({
2184
+ title: "Purchase Date Attribute",
2185
+ description: "Purchase date attribute using Unix timestamp in milliseconds"
2186
+ });
2187
+ var CreditPurchaseReceiptCertificatesAttributeSchema = NftAttributeSchema.safeExtend({
2188
+ trait_type: z.literal("Certificates Purchased"),
2189
+ value: PositiveIntegerSchema.meta({
2190
+ title: "Certificates Purchased",
2191
+ description: "Total number of certificates purchased"
2192
+ }),
2193
+ display_type: z.literal("number")
2194
+ }).meta({
2195
+ title: "Certificates Purchased Attribute",
2196
+ description: "Attribute representing how many certificates were purchased"
2197
+ });
2198
+ var CreditPurchaseReceiptReceiverAttributeSchema = NftAttributeSchema.omit({
2199
+ display_type: true,
2200
+ max_value: true
2201
+ }).safeExtend({
2202
+ trait_type: z.literal("Receiver"),
2203
+ value: ParticipantNameSchema.meta({
2204
+ title: "Receiver",
2205
+ description: "Organization or individual receiving the credits from the purchase",
2206
+ examples: ["EcoTech Solutions Inc."]
2207
+ })
2208
+ }).meta({
2209
+ title: "Receiver Attribute",
2210
+ description: "Attribute containing the receiver display name"
2211
+ });
2212
+ var CreditPurchaseReceiptCollectionAttributeSchema = NftAttributeSchema.safeExtend({
2213
+ trait_type: CollectionNameSchema,
2214
+ value: CreditAmountSchema.meta({
2215
+ title: "Credits from Collection",
2216
+ description: "Amount of credits purchased from the collection"
2217
+ }),
2218
+ display_type: z.literal("number")
2219
+ }).meta({
2220
+ title: "Collection Attribute",
2221
+ description: "Attribute representing the amount of credits purchased from a collection"
2222
+ });
2223
+ var CreditPurchaseReceiptAttributesSchema = uniqueBy(
2224
+ z.union([
2225
+ CreditPurchaseReceiptCreditAttributeSchema,
2226
+ CreditPurchaseReceiptTotalCreditsAttributeSchema,
2227
+ CreditPurchaseReceiptTotalUsdcAttributeSchema,
2228
+ CreditPurchaseReceiptPurchaseDateAttributeSchema,
2229
+ CreditPurchaseReceiptCertificatesAttributeSchema,
2230
+ CreditPurchaseReceiptReceiverAttributeSchema,
2231
+ CreditPurchaseReceiptCollectionAttributeSchema
2232
+ ]),
2233
+ (attribute) => attribute.trait_type,
2234
+ "Attribute trait_type values must be unique"
2235
+ ).min(5).meta({
2236
+ title: "Credit Purchase Receipt NFT Attribute Array",
2237
+ description: "Attributes for credit purchase receipts including per-credit breakdowns, totals, receiver, purchase date, and per-collection amounts. Attributes must have unique trait types."
2238
+ });
2239
+ var CreditPurchaseReceiptIdentitySchema = ReceiptIdentitySchema;
2240
+ var CreditPurchaseReceiptReceiverSchema = z.strictObject({
2241
+ wallet_address: EthereumAddressSchema.meta({
2242
+ title: "Receiver Wallet Address",
2243
+ description: "Ethereum address of the receiver"
2244
+ }),
2245
+ identity: CreditPurchaseReceiptIdentitySchema.optional()
2246
+ }).meta({
2247
+ title: "Receiver",
2248
+ description: "Receiver wallet and optional identity information"
2249
+ });
2250
+ var CreditPurchaseReceiptBuyerSchema = z.strictObject({
2251
+ buyer_id: ExternalIdSchema.meta({
2252
+ title: "Buyer ID",
2253
+ description: "Unique identifier for the buyer"
2254
+ }),
2255
+ identity: CreditPurchaseReceiptIdentitySchema.optional()
2256
+ }).meta({
2257
+ title: "Buyer",
2258
+ description: "Buyer identifier and optional identity information"
2259
+ });
2260
+ var CreditPurchaseReceiptPartiesSchema = z.strictObject({
2261
+ payer: EthereumAddressSchema.meta({
2262
+ title: "Payer Wallet Address",
2263
+ description: "Ethereum address paying for the purchase"
2264
+ }),
2265
+ receiver: CreditPurchaseReceiptReceiverSchema,
2266
+ buyer: CreditPurchaseReceiptBuyerSchema.optional()
2267
+ }).meta({
2268
+ title: "Parties",
2269
+ description: "Parties involved in the purchase including payer, receiver, and optional buyer"
2270
+ });
2271
+ var CreditPurchaseReceiptCollectionSchema = createReceiptCollectionSchema({
2272
+ amountKey: "credit_amount",
2273
+ amountMeta: {
2274
+ title: "Collection Credit Amount",
2275
+ description: "Total credits purchased from this collection"
2276
+ },
2277
+ meta: {
2278
+ title: "Collection",
2279
+ description: "Collection included in the purchase"
2280
+ }
2281
+ });
2282
+ var CreditPurchaseReceiptCreditSchema = createReceiptCreditSchema({
2283
+ amountKey: "purchase_amount",
2284
+ amountMeta: {
2285
+ title: "Credit Purchase Amount",
2286
+ description: "Total credits purchased for this credit type"
2287
+ },
2288
+ retirementAmountMeta: {
2289
+ title: "Credit Retirement Amount",
2290
+ description: "Credits retired immediately for this credit type during purchase"
2291
+ },
2292
+ meta: {
2293
+ title: "Credit",
2294
+ description: "Credit token included in the purchase"
2295
+ }
2296
+ });
2297
+ var CreditPurchaseReceiptCertificateSchema = createReceiptCertificateSchema({
2298
+ additionalShape: {
2299
+ purchased_amount: CreditAmountSchema.meta({
2300
+ title: "Certificate Purchased Amount",
2301
+ description: "Credits purchased from this certificate"
2302
+ }),
2303
+ retired_amount: CreditAmountSchema.meta({
2304
+ title: "Certificate Retired Amount",
2305
+ description: "Credits retired from this certificate during the purchase (0 if none)"
2306
+ }),
2307
+ credit_slug: SlugSchema.meta({
2308
+ title: "Credit Slug",
2309
+ description: "Slug of the credit type for this certificate",
2310
+ examples: ["carbon", "organic"]
2311
+ })
2312
+ },
2313
+ meta: {
2314
+ title: "Certificate",
2315
+ description: "Certificate associated with the purchase"
2316
+ }
2317
+ });
2318
+ var CreditPurchaseReceiptParticipantRewardSchema = z.strictObject({
2319
+ id_hash: Sha256HashSchema.meta({
2320
+ title: "Participant ID Hash",
2321
+ description: "Hash representing the participant identifier (SHA-256 hex string)"
2322
+ }),
2323
+ participant_name: ParticipantNameSchema.meta({
2324
+ title: "Participant Name",
2325
+ description: "Legal name of the participant receiving the reward"
2326
+ }),
2327
+ roles: uniqueArrayItems(
2328
+ ParticipantRoleSchema,
2329
+ "Participant roles must be unique"
2330
+ ).min(1).meta({
2331
+ title: "Participant Roles",
2332
+ description: "Roles the participant has in the supply chain"
2333
+ }),
2334
+ usdc_amount: NonNegativeFloatSchema.meta({
2335
+ title: "USDC Reward Amount",
2336
+ description: "USDC amount allocated to this participant"
2337
+ })
2338
+ }).meta({
2339
+ title: "Participant Reward",
2340
+ description: "Reward distribution for a participant"
2341
+ });
2342
+ var CreditPurchaseReceiptRetirementReceiptSchema = z.strictObject({
2343
+ token_id: TokenIdSchema.meta({
2344
+ title: "Retirement Receipt Token ID",
2345
+ description: "Token ID of the retirement receipt NFT"
2346
+ }),
2347
+ external_id: ExternalIdSchema.meta({
2348
+ title: "Retirement Receipt External ID",
2349
+ description: "External identifier for the retirement receipt"
2350
+ }),
2351
+ external_url: ExternalUrlSchema.meta({
2352
+ title: "Retirement Receipt External URL",
2353
+ description: "External URL for the retirement receipt"
2354
+ }),
2355
+ uri: IpfsUriSchema.meta({
2356
+ title: "Retirement Receipt URI",
2357
+ description: "IPFS URI for the retirement receipt metadata"
2358
+ }),
2359
+ smart_contract: SmartContractSchema
2360
+ }).meta({
2361
+ title: "Retirement Receipt Reference",
2362
+ description: "Reference to the retirement receipt NFT"
2363
+ });
2364
+ var CreditPurchaseReceiptRetirementSchema = z.strictObject({
2365
+ beneficiary_id: ExternalIdSchema.meta({
2366
+ title: "Retirement Beneficiary ID",
2367
+ description: "UUID identifying the beneficiary of the retirement (bytes16 normalized to UUID)"
2368
+ }),
2369
+ retirement_receipt: CreditPurchaseReceiptRetirementReceiptSchema.optional()
2370
+ }).meta({
2371
+ title: "Retirement",
2372
+ description: "Immediate retirement details performed as part of purchase"
2373
+ });
2374
+ var CreditPurchaseReceiptDataSchema = z.strictObject({
2375
+ summary: CreditPurchaseReceiptSummarySchema,
2376
+ parties: CreditPurchaseReceiptPartiesSchema,
2377
+ collections: uniqueBy(
2378
+ CreditPurchaseReceiptCollectionSchema,
2379
+ (collection) => collection.slug,
2380
+ "Collection slugs must be unique"
2381
+ ).min(1).meta({
2382
+ title: "Collections",
2383
+ description: "Collections included in the purchase"
2384
+ }),
2385
+ credits: uniqueBy(
2386
+ CreditPurchaseReceiptCreditSchema,
2387
+ (credit) => credit.slug,
2388
+ "Credit slugs must be unique"
2389
+ ).min(1).meta({
2390
+ title: "Credits",
2391
+ description: "Credits included in the purchase"
2392
+ }),
2393
+ certificates: uniqueBy(
2394
+ CreditPurchaseReceiptCertificateSchema,
2395
+ (certificate) => certificate.token_id,
2396
+ "Certificate token_ids must be unique"
2397
+ ).min(1).meta({
2398
+ title: "Certificates",
2399
+ description: "Certificates involved in the purchase"
2400
+ }),
2401
+ participant_rewards: uniqueBy(
2402
+ CreditPurchaseReceiptParticipantRewardSchema,
2403
+ (reward) => reward.id_hash,
2404
+ "Participant id_hash must be unique"
2405
+ ).min(1).meta({
2406
+ title: "Participant Rewards",
2407
+ description: "Rewards distributed to participants in the supply chain for this purchase"
2408
+ }),
2409
+ retirement: CreditPurchaseReceiptRetirementSchema.optional()
2410
+ }).superRefine((data, ctx) => {
2411
+ const retirementProvided = Boolean(data.retirement);
2412
+ const creditsWithRetirement = data.credits.reduce(
2413
+ (indices, credit, index) => {
2414
+ const retirementAmount = Number(credit.retirement_amount ?? 0);
2415
+ if (retirementAmount > 0) {
2416
+ indices.push(index);
2417
+ }
2418
+ return indices;
2419
+ },
2420
+ []
2421
+ );
2422
+ if (retirementProvided && creditsWithRetirement.length === 0) {
2423
+ ctx.addIssue({
2424
+ code: "custom",
2425
+ message: "retirement is present but no credit has retirement_amount greater than 0",
2426
+ path: ["retirement"]
2427
+ });
2428
+ }
2429
+ if (!retirementProvided && creditsWithRetirement.length > 0) {
2430
+ creditsWithRetirement.forEach((index) => {
2431
+ ctx.addIssue({
2432
+ code: "custom",
2433
+ message: "credit retirement_amount greater than 0 requires retirement details",
2434
+ path: ["credits", index, "retirement_amount"]
2435
+ });
2436
+ });
2437
+ }
2438
+ validateCountMatches({
2439
+ ctx,
2440
+ actualCount: data.certificates.length,
2441
+ expectedCount: data.summary.total_certificates,
2442
+ path: ["summary", "total_certificates"],
2443
+ message: "summary.total_certificates must equal the number of certificates"
2444
+ });
2445
+ const collectionSlugs = new Set(
2446
+ data.collections.map((collection) => String(collection.slug))
2447
+ );
2448
+ const creditSlugs = new Set(
2449
+ data.credits.map((credit) => String(credit.slug))
2450
+ );
2451
+ const creditSymbols = new Set(
2452
+ data.credits.map((credit) => String(credit.symbol))
2453
+ );
2454
+ const certificateTypes = new Set(
2455
+ data.certificates.map((certificate) => String(certificate.type))
2456
+ );
2457
+ validateSummaryListMatchesData({
2458
+ ctx,
2459
+ summaryValues: data.summary.credit_symbols,
2460
+ dataValues: creditSymbols,
2461
+ summaryPath: ["summary", "credit_symbols"],
2462
+ missingFromDataMessage: "summary.credit_symbols must reference symbols from credits",
2463
+ missingFromSummaryMessage: "All credit symbols must be listed in summary.credit_symbols"
2464
+ });
2465
+ validateSummaryListMatchesData({
2466
+ ctx,
2467
+ summaryValues: data.summary.collection_slugs,
2468
+ dataValues: collectionSlugs,
2469
+ summaryPath: ["summary", "collection_slugs"],
2470
+ missingFromDataMessage: "summary.collection_slugs must reference slugs from collections",
2471
+ missingFromSummaryMessage: "All collection slugs must be listed in summary.collection_slugs"
2472
+ });
2473
+ validateSummaryListMatchesData({
2474
+ ctx,
2475
+ summaryValues: data.summary.certificate_types,
2476
+ dataValues: certificateTypes,
2477
+ summaryPath: ["summary", "certificate_types"],
2478
+ missingFromDataMessage: "summary.certificate_types must reference types present in certificates",
2479
+ missingFromSummaryMessage: "All certificate types must be listed in summary.certificate_types"
2480
+ });
2481
+ const creditPurchaseTotalsBySlug = /* @__PURE__ */ new Map();
2482
+ const creditRetiredTotalsBySlug = /* @__PURE__ */ new Map();
2483
+ const collectionTotalsBySlug = /* @__PURE__ */ new Map();
2484
+ let totalCreditsFromCertificates = 0;
2485
+ data.certificates.forEach((certificate, index) => {
2486
+ if (!collectionSlugs.has(certificate.collection_slug)) {
2487
+ ctx.addIssue({
2488
+ code: "custom",
2489
+ message: "collection_slug must match a collection slug in collections",
2490
+ path: ["certificates", index, "collection_slug"]
2491
+ });
2492
+ }
2493
+ if (!creditSlugs.has(certificate.credit_slug)) {
2494
+ ctx.addIssue({
2495
+ code: "custom",
2496
+ message: "credit_slug must match a credit slug in credits",
2497
+ path: ["certificates", index, "credit_slug"]
2498
+ });
2499
+ }
2500
+ if (certificate.retired_amount > certificate.purchased_amount) {
2501
+ ctx.addIssue({
2502
+ code: "custom",
2503
+ message: "retired_amount cannot exceed purchased_amount",
2504
+ path: ["certificates", index, "retired_amount"]
2505
+ });
2506
+ }
2507
+ if (certificate.purchased_amount > certificate.total_amount) {
2508
+ ctx.addIssue({
2509
+ code: "custom",
2510
+ message: "purchased_amount cannot exceed total_amount",
2511
+ path: ["certificates", index, "purchased_amount"]
2512
+ });
2513
+ }
2514
+ totalCreditsFromCertificates += Number(certificate.purchased_amount);
2515
+ creditPurchaseTotalsBySlug.set(
2516
+ String(certificate.credit_slug),
2517
+ (creditPurchaseTotalsBySlug.get(certificate.credit_slug) ?? 0) + Number(certificate.purchased_amount)
2518
+ );
2519
+ creditRetiredTotalsBySlug.set(
2520
+ String(certificate.credit_slug),
2521
+ (creditRetiredTotalsBySlug.get(certificate.credit_slug) ?? 0) + Number(certificate.retired_amount)
2522
+ );
2523
+ collectionTotalsBySlug.set(
2524
+ String(certificate.collection_slug),
2525
+ (collectionTotalsBySlug.get(certificate.collection_slug) ?? 0) + Number(certificate.purchased_amount)
2526
+ );
2527
+ });
2528
+ const totalCreditsFromCollections = data.collections.reduce(
2529
+ (sum, collection) => sum + Number(collection.credit_amount),
2530
+ 0
2531
+ );
2532
+ const totalCreditsFromCredits = data.credits.reduce(
2533
+ (sum, credit) => sum + Number(credit.purchase_amount),
2534
+ 0
2535
+ );
2536
+ validateTotalMatches({
2537
+ ctx,
2538
+ actualTotal: totalCreditsFromCertificates,
2539
+ expectedTotal: data.summary.total_credits,
2540
+ path: ["summary", "total_credits"],
2541
+ message: "summary.total_credits must equal sum of certificates.purchased_amount"
2542
+ });
2543
+ validateTotalMatches({
2544
+ ctx,
2545
+ actualTotal: totalCreditsFromCredits,
2546
+ expectedTotal: data.summary.total_credits,
2547
+ path: ["summary", "total_credits"],
2548
+ message: "summary.total_credits must equal sum of credits.purchase_amount"
2549
+ });
2550
+ validateTotalMatches({
2551
+ ctx,
2552
+ actualTotal: totalCreditsFromCollections,
2553
+ expectedTotal: data.summary.total_credits,
2554
+ path: ["summary", "total_credits"],
2555
+ message: "summary.total_credits must equal sum of collections.credit_amount"
2556
+ });
2557
+ data.credits.forEach((credit, index) => {
2558
+ const purchasedTotal = creditPurchaseTotalsBySlug.get(String(credit.slug)) ?? 0;
2559
+ if (!nearlyEqual(Number(credit.purchase_amount), purchasedTotal)) {
2560
+ ctx.addIssue({
2561
+ code: "custom",
2562
+ message: "credit.purchase_amount must equal sum of certificate purchased_amount for the credit slug",
2563
+ path: ["credits", index, "purchase_amount"]
2564
+ });
2565
+ }
2566
+ const retiredTotal = creditRetiredTotalsBySlug.get(String(credit.slug)) ?? 0;
2567
+ const retirementAmount = Number(credit.retirement_amount ?? 0);
2568
+ if (!nearlyEqual(retirementAmount, retiredTotal)) {
2569
+ ctx.addIssue({
2570
+ code: "custom",
2571
+ message: "credit.retirement_amount must equal sum of certificate retired_amount for the credit slug",
2572
+ path: ["credits", index, "retirement_amount"]
2573
+ });
2574
+ }
2575
+ });
2576
+ data.collections.forEach((collection, index) => {
2577
+ const purchasedTotal = collectionTotalsBySlug.get(String(collection.slug)) ?? 0;
2578
+ if (!nearlyEqual(Number(collection.credit_amount), purchasedTotal)) {
2579
+ ctx.addIssue({
2580
+ code: "custom",
2581
+ message: "collection.credit_amount must equal sum of certificate purchased_amount for the collection slug",
2582
+ path: ["collections", index, "credit_amount"]
2583
+ });
2584
+ }
2585
+ });
2586
+ const participantRewardTotal = data.participant_rewards.reduce(
2587
+ (sum, reward) => sum + Number(reward.usdc_amount),
2588
+ 0
2589
+ );
2590
+ validateTotalMatches({
2591
+ ctx,
2592
+ actualTotal: participantRewardTotal,
2593
+ expectedTotal: data.summary.total_usdc_amount,
2594
+ path: ["summary", "total_usdc_amount"],
2595
+ message: "summary.total_usdc_amount must equal sum of participant_rewards.usdc_amount"
2596
+ });
2597
+ }).meta({
2598
+ title: "Credit Purchase Receipt Data",
2599
+ description: "Complete data structure for a credit purchase receipt"
2600
+ });
2601
+ var CreditPurchaseReceiptIpfsSchemaMeta = {
2602
+ title: "CreditPurchaseReceipt NFT IPFS Record",
2603
+ description: "Complete CreditPurchaseReceipt NFT IPFS record including attributes and credit purchase data",
2604
+ $id: buildSchemaUrl(
2605
+ "credit-purchase-receipt/credit-purchase-receipt.schema.json"
2606
+ ),
2607
+ version: getSchemaVersionOrDefault()
2608
+ };
2609
+ var CreditPurchaseReceiptIpfsSchema = NftIpfsSchema.safeExtend({
2610
+ schema: NftIpfsSchema.shape.schema.safeExtend({
2611
+ type: z.literal("CreditPurchaseReceipt").meta({
2612
+ title: "CreditPurchaseReceipt Schema Type",
2613
+ description: "CreditPurchaseReceipt NFT schema type"
2614
+ })
2615
+ }),
2616
+ attributes: CreditPurchaseReceiptAttributesSchema,
2617
+ data: CreditPurchaseReceiptDataSchema
2618
+ }).superRefine((value, ctx) => {
2619
+ const attributes = value.attributes;
2620
+ const data = value.data;
2621
+ const attributeByTraitType = createAttributeMap(attributes);
2622
+ validateAttributeValue({
2623
+ ctx,
2624
+ attributeByTraitType,
2625
+ traitType: "Total Credits Purchased",
2626
+ expectedValue: data.summary.total_credits,
2627
+ missingMessage: 'Attribute "Total Credits Purchased" is required',
2628
+ mismatchMessage: 'Attribute "Total Credits Purchased" must match data.summary.total_credits'
2629
+ });
2630
+ validateAttributeValue({
2631
+ ctx,
2632
+ attributeByTraitType,
2633
+ traitType: "Total USDC Amount",
2634
+ expectedValue: data.summary.total_usdc_amount,
2635
+ missingMessage: 'Attribute "Total USDC Amount" is required',
2636
+ mismatchMessage: 'Attribute "Total USDC Amount" must match data.summary.total_usdc_amount'
2637
+ });
2638
+ validateAttributeValue({
2639
+ ctx,
2640
+ attributeByTraitType,
2641
+ traitType: "Certificates Purchased",
2642
+ expectedValue: data.summary.total_certificates,
2643
+ missingMessage: 'Attribute "Certificates Purchased" is required',
2644
+ mismatchMessage: 'Attribute "Certificates Purchased" must match data.summary.total_certificates'
2645
+ });
2646
+ const receiverName = data.parties.receiver.identity?.name;
2647
+ if (receiverName) {
2648
+ validateAttributeValue({
2649
+ ctx,
2650
+ attributeByTraitType,
2651
+ traitType: "Receiver",
2652
+ expectedValue: String(receiverName),
2653
+ missingMessage: 'Attribute "Receiver" is required when receiver.identity.name is provided',
2654
+ mismatchMessage: 'Attribute "Receiver" must match receiver.identity.name'
2655
+ });
2656
+ }
2657
+ validateDateAttribute({
2658
+ ctx,
2659
+ attributeByTraitType,
2660
+ traitType: "Purchase Date",
2661
+ dateValue: data.summary.purchase_date,
2662
+ missingMessage: 'Attribute "Purchase Date" is required',
2663
+ invalidDateMessage: "data.summary.purchase_date must be a valid date string",
2664
+ mismatchMessage: 'Attribute "Purchase Date" must match data.summary.purchase_date as a Unix timestamp in milliseconds',
2665
+ datePath: ["data", "summary", "purchase_date"]
2666
+ });
2667
+ validateAttributesForItems({
2668
+ ctx,
2669
+ attributeByTraitType,
2670
+ items: data.credits,
2671
+ traitSelector: (credit) => String(credit.symbol),
2672
+ valueSelector: (credit) => Number(credit.purchase_amount),
2673
+ missingMessage: (symbol) => `Attribute for credit symbol ${symbol} is required`,
2674
+ mismatchMessage: (symbol) => `Attribute for credit symbol ${symbol} must match credit.purchase_amount`
2675
+ });
2676
+ validateAttributesForItems({
2677
+ ctx,
2678
+ attributeByTraitType,
2679
+ items: data.collections,
2680
+ traitSelector: (collection) => String(collection.name),
2681
+ valueSelector: (collection) => Number(collection.credit_amount),
2682
+ missingMessage: (name) => `Attribute for collection ${name} is required`,
2683
+ mismatchMessage: (name) => `Attribute for collection ${name} must match collection.credit_amount`
2684
+ });
2685
+ }).meta(CreditPurchaseReceiptIpfsSchemaMeta);
2686
+ var CreditRetirementReceiptCreditAttributeSchema = NftAttributeSchema.safeExtend({
2687
+ trait_type: CreditTokenSymbolSchema,
2688
+ value: CreditAmountSchema.meta({
2689
+ title: "Credit Retirement Amount",
2690
+ description: "Amount of credits retired for the token symbol"
2691
+ }),
2692
+ display_type: z.literal("number")
2693
+ }).meta({
2694
+ title: "Credit Attribute",
2695
+ description: "Attribute representing retired amount per credit token symbol"
2696
+ });
2697
+ var CreditRetirementReceiptTotalCreditsAttributeSchema = NftAttributeSchema.safeExtend({
2698
+ trait_type: z.literal("Total Credits Retired"),
2699
+ value: CreditAmountSchema.meta({
2700
+ title: "Total Credits Retired",
2701
+ description: "Total number of credits retired across all tokens"
2702
+ }),
2703
+ display_type: z.literal("number")
2704
+ }).meta({
2705
+ title: "Total Credits Retired Attribute",
2706
+ description: "Aggregate credits retired attribute"
2707
+ });
2708
+ var CreditRetirementReceiptBeneficiaryAttributeSchema = NftAttributeSchema.safeExtend({
2709
+ trait_type: z.literal("Beneficiary"),
2710
+ value: ParticipantNameSchema.meta({
2711
+ title: "Beneficiary",
2712
+ description: "Beneficiary receiving the retirement benefit",
2713
+ examples: ["Climate Action Corp"]
2714
+ })
2715
+ }).meta({
2716
+ title: "Beneficiary Attribute",
2717
+ description: "Attribute containing the beneficiary display name"
2718
+ });
2719
+ var CreditRetirementReceiptCreditHolderAttributeSchema = NftAttributeSchema.safeExtend({
2720
+ trait_type: z.literal("Credit Holder"),
2721
+ value: ParticipantNameSchema.meta({
2722
+ title: "Credit Holder",
2723
+ description: "Entity that surrendered the credits",
2724
+ examples: ["EcoTech Solutions Inc."]
2725
+ })
2726
+ }).meta({
2727
+ title: "Credit Holder Attribute",
2728
+ description: "Attribute containing the credit holder display name"
2729
+ });
2730
+ var CreditRetirementReceiptRetirementDateAttributeSchema = NftAttributeSchema.safeExtend({
2731
+ trait_type: z.literal("Retirement Date"),
2732
+ value: UnixTimestampSchema.meta({
2733
+ title: "Retirement Date",
2734
+ description: "Unix timestamp in milliseconds when the retirement was completed"
2735
+ }),
2736
+ display_type: z.literal("date")
2737
+ }).meta({
2738
+ title: "Retirement Date Attribute",
2739
+ description: "Retirement date attribute using Unix timestamp in milliseconds"
2740
+ });
2741
+ var CreditRetirementReceiptCertificatesAttributeSchema = NftAttributeSchema.safeExtend({
2742
+ trait_type: z.literal("Certificates Retired"),
2743
+ value: PositiveIntegerSchema.meta({
2744
+ title: "Certificates Retired",
2745
+ description: "Total number of certificates retired"
2746
+ }),
2747
+ display_type: z.literal("number")
2748
+ }).meta({
2749
+ title: "Certificates Retired Attribute",
2750
+ description: "Attribute representing how many certificates were retired in total"
2751
+ });
2752
+ var CreditRetirementReceiptCollectionAttributeSchema = NftAttributeSchema.safeExtend({
2753
+ trait_type: CollectionNameSchema,
2754
+ value: CreditAmountSchema.meta({
2755
+ title: "Credits from Collection",
2756
+ description: "Amount of credits retired from the collection"
2757
+ }),
2758
+ display_type: z.literal("number")
2759
+ }).meta({
2760
+ title: "Collection Attribute",
2761
+ description: "Attribute representing the amount of credits retired from a collection"
2762
+ });
2763
+ var CreditRetirementReceiptAttributesSchema = uniqueBy(
2764
+ z.union([
2765
+ CreditRetirementReceiptCreditAttributeSchema,
2766
+ CreditRetirementReceiptTotalCreditsAttributeSchema,
2767
+ CreditRetirementReceiptBeneficiaryAttributeSchema,
2768
+ CreditRetirementReceiptCreditHolderAttributeSchema,
2769
+ CreditRetirementReceiptRetirementDateAttributeSchema,
2770
+ CreditRetirementReceiptCertificatesAttributeSchema,
2771
+ CreditRetirementReceiptCollectionAttributeSchema
2772
+ ]),
2773
+ (attribute) => attribute.trait_type,
2774
+ "Attribute trait_type values must be unique"
2775
+ ).min(6).meta({
2776
+ title: "Credit Retirement Receipt NFT Attribute Array",
2777
+ description: "Attributes for credit retirement receipts including per-credit breakdowns, totals, beneficiary, credit holder, retirement date, certificate count, and per-collection amounts. Attributes must have unique trait types."
2778
+ });
2779
+ var CreditRetirementReceiptIdentitySchema = ReceiptIdentitySchema;
2780
+ var CreditRetirementReceiptBeneficiarySchema = z.strictObject({
2781
+ beneficiary_id: ExternalIdSchema.meta({
2782
+ title: "Retirement Beneficiary ID",
2783
+ description: "UUID identifying the beneficiary of the retirement (bytes16 normalized to UUID)"
2784
+ }),
2785
+ identity: CreditRetirementReceiptIdentitySchema
2786
+ }).meta({
2787
+ title: "Beneficiary",
2788
+ description: "Beneficiary receiving the retirement benefit"
2789
+ });
2790
+ var CreditRetirementReceiptCreditHolderSchema = z.strictObject({
2791
+ wallet_address: EthereumAddressSchema.meta({
2792
+ title: "Credit Holder Wallet Address",
2793
+ description: "Ethereum address of the credit holder surrendering credits"
2794
+ }),
2795
+ identity: CreditRetirementReceiptIdentitySchema.optional()
2796
+ }).meta({
2797
+ title: "Credit Holder",
2798
+ description: "Credit holder wallet and optional identity information"
2799
+ });
2800
+ var CreditRetirementReceiptCollectionSchema = createReceiptCollectionSchema({
2801
+ amountKey: "amount",
2802
+ amountMeta: {
2803
+ title: "Collection Retirement Amount",
2804
+ description: "Total credits retired from this collection"
2805
+ },
2806
+ meta: {
2807
+ title: "Collection",
2808
+ description: "Collection included in the retirement"
2809
+ }
2810
+ });
2811
+ var CreditRetirementReceiptCreditSchema = createReceiptCreditSchema({
2812
+ amountKey: "amount",
2813
+ amountMeta: {
2814
+ title: "Credit Retirement Amount",
2815
+ description: "Total credits retired for this credit type"
2816
+ },
2817
+ meta: {
2818
+ title: "Credit",
2819
+ description: "Credit token retired in this receipt"
2820
+ }
2821
+ });
2822
+ var CreditRetirementReceiptCertificateCreditSchema = z.strictObject({
2823
+ credit_symbol: CreditTokenSymbolSchema.meta({
2824
+ title: "Credit Token Symbol",
2825
+ description: "Symbol of the credit token retired from the certificate"
2826
+ }),
2827
+ credit_slug: SlugSchema.meta({
2828
+ title: "Credit Slug",
2829
+ description: "Slug of the credit type retired from the certificate",
2830
+ examples: ["carbon", "organic"]
2831
+ }),
2832
+ amount: CreditAmountSchema.meta({
2833
+ title: "Retired Credit Amount",
2834
+ description: "Credits retired of this type from the certificate"
2835
+ }),
2836
+ external_id: ExternalIdSchema.meta({
2837
+ title: "Retired Credit External ID",
2838
+ description: "External identifier for the retired credit entry"
2839
+ }),
2840
+ external_url: ExternalUrlSchema.meta({
2841
+ title: "Retired Credit External URL",
2842
+ description: "External URL for the retired credit entry"
2843
+ })
2844
+ }).meta({
2845
+ title: "Certificate Credit Retirement",
2846
+ description: "Credit retirement breakdown for a certificate"
2847
+ });
2848
+ var CreditPurchaseReceiptReferenceSchema = z.strictObject({
2849
+ token_id: TokenIdSchema.meta({
2850
+ title: "Purchase Receipt Token ID",
2851
+ description: "Token ID of the credit purchase receipt"
2852
+ }),
2853
+ external_id: ExternalIdSchema.meta({
2854
+ title: "Purchase Receipt External ID",
2855
+ description: "External identifier for the purchase receipt"
2856
+ }),
2857
+ external_url: ExternalUrlSchema.meta({
2858
+ title: "Purchase Receipt External URL",
2859
+ description: "External URL for the purchase receipt"
2860
+ }),
2861
+ uri: IpfsUriSchema.meta({
2862
+ title: "Purchase Receipt URI",
2863
+ description: "IPFS URI for the purchase receipt metadata"
2864
+ }),
2865
+ smart_contract: SmartContractSchema
2866
+ }).meta({
2867
+ title: "Credit Purchase Receipt Reference",
2868
+ description: "Reference to the credit purchase receipt when retirement occurs during purchase"
2869
+ });
2870
+ var CreditRetirementReceiptCertificateSchema = createReceiptCertificateSchema(
2871
+ {
2872
+ additionalShape: {
2873
+ retired_amount: CreditAmountSchema.meta({
2874
+ title: "Certificate Retired Amount",
2875
+ description: "Credits retired from this certificate"
2876
+ }),
2877
+ credits_retired: uniqueBy(
2878
+ CreditRetirementReceiptCertificateCreditSchema,
2879
+ (credit) => credit.credit_symbol,
2880
+ "Credit symbols within credits_retired must be unique"
2881
+ ).min(1).meta({
2882
+ title: "Credits Retired",
2883
+ description: "Breakdown of credits retired from this certificate by symbol"
2884
+ })
2885
+ },
2886
+ meta: {
2887
+ title: "Certificate",
2888
+ description: "Certificate associated with the retirement"
2889
+ }
2890
+ }
2891
+ );
2892
+ var CreditRetirementReceiptDataSchema = z.strictObject({
2893
+ summary: CreditRetirementReceiptSummarySchema,
2894
+ beneficiary: CreditRetirementReceiptBeneficiarySchema,
2895
+ credit_holder: CreditRetirementReceiptCreditHolderSchema,
2896
+ collections: uniqueBy(
2897
+ CreditRetirementReceiptCollectionSchema,
2898
+ (collection) => collection.slug,
2899
+ "Collection slugs must be unique"
2900
+ ).min(1).meta({
2901
+ title: "Collections",
2902
+ description: "Collections included in the retirement"
2903
+ }),
2904
+ credits: uniqueBy(
2905
+ CreditRetirementReceiptCreditSchema,
2906
+ (credit) => credit.slug,
2907
+ "Credit slugs must be unique"
2908
+ ).min(1).meta({
2909
+ title: "Credits",
2910
+ description: "Credits included in the retirement"
2911
+ }),
2912
+ certificates: uniqueBy(
2913
+ CreditRetirementReceiptCertificateSchema,
2914
+ (certificate) => certificate.token_id,
2915
+ "Certificate token_ids must be unique"
2916
+ ).min(1).meta({
2917
+ title: "Certificates",
2918
+ description: "Certificates retired in this receipt"
2919
+ }),
2920
+ purchase_receipt: CreditPurchaseReceiptReferenceSchema.optional()
2921
+ }).superRefine((data, ctx) => {
2922
+ const creditSymbols = new Set(
2923
+ data.credits.map((credit) => String(credit.symbol))
2924
+ );
2925
+ const creditBySlug = new Map(
2926
+ data.credits.map((credit) => [credit.slug, credit])
2927
+ );
2928
+ const collectionSlugs = new Set(
2929
+ data.collections.map((collection) => String(collection.slug))
2930
+ );
2931
+ const certificateTypes = new Set(
2932
+ data.certificates.map((certificate) => String(certificate.type))
2933
+ );
2934
+ validateCountMatches({
2935
+ ctx,
2936
+ actualCount: data.certificates.length,
2937
+ expectedCount: data.summary.total_certificates,
2938
+ path: ["summary", "total_certificates"],
2939
+ message: "summary.total_certificates must equal the number of certificates"
2940
+ });
2941
+ validateSummaryListMatchesData({
2942
+ ctx,
2943
+ summaryValues: data.summary.credit_symbols,
2944
+ dataValues: creditSymbols,
2945
+ summaryPath: ["summary", "credit_symbols"],
2946
+ missingFromDataMessage: "summary.credit_symbols must reference symbols from credits",
2947
+ missingFromSummaryMessage: "All credit symbols must be listed in summary.credit_symbols"
2948
+ });
2949
+ validateSummaryListMatchesData({
2950
+ ctx,
2951
+ summaryValues: data.summary.collection_slugs,
2952
+ dataValues: collectionSlugs,
2953
+ summaryPath: ["summary", "collection_slugs"],
2954
+ missingFromDataMessage: "summary.collection_slugs must reference slugs from collections",
2955
+ missingFromSummaryMessage: "All collection slugs must be listed in summary.collection_slugs"
2956
+ });
2957
+ validateSummaryListMatchesData({
2958
+ ctx,
2959
+ summaryValues: data.summary.certificate_types,
2960
+ dataValues: certificateTypes,
2961
+ summaryPath: ["summary", "certificate_types"],
2962
+ missingFromDataMessage: "summary.certificate_types must reference types present in certificates",
2963
+ missingFromSummaryMessage: "All certificate types must be listed in summary.certificate_types"
2964
+ });
2965
+ const creditTotalsBySymbol = /* @__PURE__ */ new Map();
2966
+ const collectionTotalsBySlug = /* @__PURE__ */ new Map();
2967
+ let totalRetiredFromCertificates = 0;
2968
+ data.certificates.forEach((certificate, index) => {
2969
+ if (!collectionSlugs.has(certificate.collection_slug)) {
2970
+ ctx.addIssue({
2971
+ code: "custom",
2972
+ message: "collection_slug must match a collection slug in collections",
2973
+ path: ["certificates", index, "collection_slug"]
2974
+ });
2975
+ }
2976
+ if (certificate.retired_amount > certificate.total_amount) {
2977
+ ctx.addIssue({
2978
+ code: "custom",
2979
+ message: "retired_amount cannot exceed total_amount",
2980
+ path: ["certificates", index, "retired_amount"]
2981
+ });
2982
+ }
2983
+ const creditsRetiredTotal = certificate.credits_retired.reduce(
2984
+ (sum, credit) => sum + Number(credit.amount),
2985
+ 0
2986
+ );
2987
+ if (!nearlyEqual(creditsRetiredTotal, certificate.retired_amount)) {
2988
+ ctx.addIssue({
2989
+ code: "custom",
2990
+ message: "certificates.credits_retired amounts must sum to certificates.retired_amount",
2991
+ path: ["certificates", index, "credits_retired"]
2992
+ });
2993
+ }
2994
+ certificate.credits_retired.forEach((credit, creditIndex) => {
2995
+ const referencedCredit = creditBySlug.get(credit.credit_slug);
2996
+ if (!referencedCredit) {
2997
+ ctx.addIssue({
2998
+ code: "custom",
2999
+ message: "credit_slug must match a credit slug in credits",
3000
+ path: [
3001
+ "certificates",
3002
+ index,
3003
+ "credits_retired",
3004
+ creditIndex,
3005
+ "credit_slug"
3006
+ ]
3007
+ });
3008
+ }
3009
+ if (!creditSymbols.has(credit.credit_symbol)) {
3010
+ ctx.addIssue({
3011
+ code: "custom",
3012
+ message: "credit_symbol must match a credit symbol in credits",
3013
+ path: [
3014
+ "certificates",
3015
+ index,
3016
+ "credits_retired",
3017
+ creditIndex,
3018
+ "credit_symbol"
3019
+ ]
3020
+ });
3021
+ }
3022
+ if (referencedCredit && referencedCredit.symbol !== credit.credit_symbol) {
3023
+ ctx.addIssue({
3024
+ code: "custom",
3025
+ message: "credit_symbol must match the symbol for the referenced credit_slug",
3026
+ path: [
3027
+ "certificates",
3028
+ index,
3029
+ "credits_retired",
3030
+ creditIndex,
3031
+ "credit_symbol"
3032
+ ]
3033
+ });
3034
+ }
3035
+ creditTotalsBySymbol.set(
3036
+ credit.credit_symbol,
3037
+ (creditTotalsBySymbol.get(credit.credit_symbol) ?? 0) + credit.amount
3038
+ );
3039
+ });
3040
+ collectionTotalsBySlug.set(
3041
+ String(certificate.collection_slug),
3042
+ (collectionTotalsBySlug.get(certificate.collection_slug) ?? 0) + Number(certificate.retired_amount)
3043
+ );
3044
+ totalRetiredFromCertificates += Number(certificate.retired_amount);
3045
+ });
3046
+ const totalRetiredFromCollections = data.collections.reduce(
3047
+ (sum, collection) => sum + Number(collection.amount),
3048
+ 0
3049
+ );
3050
+ const totalRetiredFromCredits = data.credits.reduce(
3051
+ (sum, credit) => sum + Number(credit.amount),
3052
+ 0
3053
+ );
3054
+ data.summary.credit_symbols.forEach((symbol) => {
3055
+ if ((creditTotalsBySymbol.get(symbol) ?? 0) === 0) {
3056
+ ctx.addIssue({
3057
+ code: "custom",
3058
+ message: "Each summary credit symbol must appear in certificates.credits_retired with a retired amount",
3059
+ path: ["summary", "credit_symbols"]
3060
+ });
3061
+ }
3062
+ });
3063
+ validateTotalMatches({
3064
+ ctx,
3065
+ actualTotal: totalRetiredFromCertificates,
3066
+ expectedTotal: data.summary.total_retirement_amount,
3067
+ path: ["summary", "total_retirement_amount"],
3068
+ message: "summary.total_retirement_amount must equal sum of certificates.retired_amount"
3069
+ });
3070
+ validateTotalMatches({
3071
+ ctx,
3072
+ actualTotal: totalRetiredFromCredits,
3073
+ expectedTotal: data.summary.total_retirement_amount,
3074
+ path: ["summary", "total_retirement_amount"],
3075
+ message: "summary.total_retirement_amount must equal sum of credits.amount"
3076
+ });
3077
+ validateTotalMatches({
3078
+ ctx,
3079
+ actualTotal: totalRetiredFromCollections,
3080
+ expectedTotal: data.summary.total_retirement_amount,
3081
+ path: ["summary", "total_retirement_amount"],
3082
+ message: "summary.total_retirement_amount must equal sum of collections.amount"
3083
+ });
3084
+ data.credits.forEach((credit, index) => {
3085
+ const retiredTotal = creditTotalsBySymbol.get(String(credit.symbol)) ?? 0;
3086
+ if (!nearlyEqual(Number(credit.amount), retiredTotal)) {
3087
+ ctx.addIssue({
3088
+ code: "custom",
3089
+ message: "credit.amount must equal sum of retired amounts for the credit symbol across certificates",
3090
+ path: ["credits", index, "amount"]
3091
+ });
3092
+ }
3093
+ });
3094
+ data.collections.forEach((collection, index) => {
3095
+ const retiredTotal = collectionTotalsBySlug.get(String(collection.slug)) ?? 0;
3096
+ if (retiredTotal === 0) {
3097
+ ctx.addIssue({
3098
+ code: "custom",
3099
+ message: "collection must be referenced by at least one certificate with retired_amount > 0",
3100
+ path: ["collections", index, "slug"]
3101
+ });
3102
+ }
3103
+ if (Number(collection.amount) <= 0) {
3104
+ ctx.addIssue({
3105
+ code: "custom",
3106
+ message: "collection.amount must be greater than zero",
3107
+ path: ["collections", index, "amount"]
3108
+ });
3109
+ }
3110
+ if (!nearlyEqual(Number(collection.amount), retiredTotal)) {
3111
+ ctx.addIssue({
3112
+ code: "custom",
3113
+ message: "collection.amount must equal sum of certificate retired_amount for the collection slug",
3114
+ path: ["collections", index, "amount"]
3115
+ });
3116
+ }
3117
+ });
3118
+ }).meta({
3119
+ title: "Credit Retirement Receipt Data",
3120
+ description: "Complete data structure for a credit retirement receipt"
3121
+ });
3122
+ var CreditRetirementReceiptIpfsSchemaBase = NftIpfsSchema.omit({
3123
+ original_content_hash: true
3124
+ });
3125
+ var CreditRetirementReceiptIpfsSchemaMeta = {
3126
+ title: "CreditRetirementReceipt NFT IPFS Record",
3127
+ description: "Complete CreditRetirementReceipt NFT IPFS record including attributes and credit retirement data",
3128
+ $id: buildSchemaUrl(
3129
+ "credit-retirement-receipt/credit-retirement-receipt.schema.json"
3130
+ ),
3131
+ version: getSchemaVersionOrDefault()
3132
+ };
3133
+ var CreditRetirementReceiptIpfsSchema = CreditRetirementReceiptIpfsSchemaBase.safeExtend({
3134
+ schema: CreditRetirementReceiptIpfsSchemaBase.shape.schema.safeExtend({
3135
+ type: z.literal("CreditRetirementReceipt").meta({
3136
+ title: "CreditRetirementReceipt Schema Type",
3137
+ description: "CreditRetirementReceipt NFT schema type"
3138
+ })
3139
+ }),
3140
+ attributes: CreditRetirementReceiptAttributesSchema,
3141
+ data: CreditRetirementReceiptDataSchema
3142
+ }).superRefine((value, ctx) => {
3143
+ const attributes = value.attributes;
3144
+ const data = value.data;
3145
+ const attributeByTraitType = createAttributeMap(attributes);
3146
+ validateAttributeValue({
3147
+ ctx,
3148
+ attributeByTraitType,
3149
+ traitType: "Total Credits Retired",
3150
+ expectedValue: data.summary.total_retirement_amount,
3151
+ missingMessage: 'Attribute "Total Credits Retired" is required',
3152
+ mismatchMessage: 'Attribute "Total Credits Retired" must match data.summary.total_retirement_amount'
3153
+ });
3154
+ validateAttributeValue({
3155
+ ctx,
3156
+ attributeByTraitType,
3157
+ traitType: "Certificates Retired",
3158
+ expectedValue: data.summary.total_certificates,
3159
+ missingMessage: 'Attribute "Certificates Retired" is required',
3160
+ mismatchMessage: 'Attribute "Certificates Retired" must match data.summary.total_certificates'
3161
+ });
3162
+ validateAttributeValue({
3163
+ ctx,
3164
+ attributeByTraitType,
3165
+ traitType: "Beneficiary",
3166
+ expectedValue: String(data.beneficiary.identity.name),
3167
+ missingMessage: 'Attribute "Beneficiary" is required',
3168
+ mismatchMessage: 'Attribute "Beneficiary" must match beneficiary.identity.name'
3169
+ });
3170
+ const creditHolderName = data.credit_holder.identity?.name;
3171
+ if (creditHolderName) {
3172
+ validateAttributeValue({
3173
+ ctx,
3174
+ attributeByTraitType,
3175
+ traitType: "Credit Holder",
3176
+ expectedValue: String(creditHolderName),
3177
+ missingMessage: 'Attribute "Credit Holder" is required when credit_holder.identity.name is provided',
3178
+ mismatchMessage: 'Attribute "Credit Holder" must match credit_holder.identity.name'
3179
+ });
3180
+ }
3181
+ validateDateAttribute({
3182
+ ctx,
3183
+ attributeByTraitType,
3184
+ traitType: "Retirement Date",
3185
+ dateValue: data.summary.retirement_date,
3186
+ missingMessage: 'Attribute "Retirement Date" is required',
3187
+ invalidDateMessage: "data.summary.retirement_date must be a valid date string",
3188
+ mismatchMessage: 'Attribute "Retirement Date" must match data.summary.retirement_date as a Unix timestamp in milliseconds',
3189
+ datePath: ["data", "summary", "retirement_date"]
3190
+ });
3191
+ validateAttributesForItems({
3192
+ ctx,
3193
+ attributeByTraitType,
3194
+ items: data.credits,
3195
+ traitSelector: (credit) => String(credit.symbol),
3196
+ valueSelector: (credit) => Number(credit.amount),
3197
+ missingMessage: (symbol) => `Attribute for credit symbol ${symbol} is required`,
3198
+ mismatchMessage: (symbol) => `Attribute for credit symbol ${symbol} must match credit.amount`
3199
+ });
3200
+ validateAttributesForItems({
3201
+ ctx,
3202
+ attributeByTraitType,
3203
+ items: data.collections,
3204
+ traitSelector: (collection) => String(collection.name),
3205
+ valueSelector: (collection) => Number(collection.amount),
3206
+ missingMessage: (name) => `Attribute for collection ${name} is required`,
3207
+ mismatchMessage: (name) => `Attribute for collection ${name} must match collection.amount`
3208
+ });
3209
+ }).meta(CreditRetirementReceiptIpfsSchemaMeta);
3210
+ var CollectionSchemaMeta = {
3211
+ title: "Collection IPFS Record",
3212
+ description: "Collection metadata stored in IPFS, extending the base schema with collection-specific fields required for NFT collection definitions in Carrot's ecosystem",
3213
+ $id: buildSchemaUrl("collection/collection.schema.json"),
3214
+ version: getSchemaVersionOrDefault()
3215
+ };
3216
+ var CollectionSchema = BaseIpfsSchema.safeExtend({
3217
+ schema: BaseIpfsSchema.shape.schema.safeExtend({
3218
+ type: z.literal("Collection").meta({
3219
+ title: "Collection Schema Type",
3220
+ description: "Collection schema type"
3221
+ })
3222
+ }),
3223
+ name: CollectionNameSchema,
3224
+ slug: CollectionSlugSchema.optional(),
3225
+ image: IpfsUriSchema.meta({
3226
+ title: "Collection Image",
3227
+ description: "IPFS URI pointing to the collection's visual representation",
3228
+ examples: ["ipfs://QmCollectionImageHash/collection-icon.png"]
3229
+ }),
3230
+ description: z.string().min(50).max(1e3).meta({
3231
+ title: "Collection Description",
3232
+ description: "Comprehensive description of the collection, its purpose, and context",
3233
+ examples: [
3234
+ "Cold Start is a limited-edition collection created for early supporters of BOLD - Breakthrough in Organic Landfill Diversion. This purchase contributes to reducing global waste and promoting circularity, with funds distributed via smart contract to local recycling operations and communities."
3235
+ ]
3236
+ })
3237
+ }).meta(CollectionSchemaMeta);
3238
+ var CreditSchemaMeta = {
3239
+ title: "Credit IPFS Record",
3240
+ description: "Credit token metadata stored in IPFS, extending the base schema with ERC20-specific details",
3241
+ $id: buildSchemaUrl("credit/credit.schema.json"),
3242
+ version: getSchemaVersionOrDefault()
3243
+ };
3244
+ var CreditSchema = BaseIpfsSchema.safeExtend({
3245
+ schema: BaseIpfsSchema.shape.schema.safeExtend({
3246
+ type: z.literal("Credit").meta({
3247
+ title: "Credit Schema Type",
3248
+ description: "Credit schema type"
3249
+ })
3250
+ }),
3251
+ symbol: TokenSymbolSchema,
3252
+ slug: SlugSchema.meta({
3253
+ title: "Token Slug",
3254
+ description: "URL-friendly identifier for the token",
3255
+ examples: ["carbon"]
3256
+ }).optional(),
3257
+ name: NonEmptyStringSchema.meta({
3258
+ title: "Token Name",
3259
+ description: "Full human-readable name of the ERC20 token",
3260
+ examples: ["Carrot Carbon"]
3261
+ }),
3262
+ decimals: z.number().int().min(0).max(18).meta({
3263
+ title: "Token Decimals",
3264
+ description: "Number of decimal places for the ERC20 token",
3265
+ examples: [18]
3266
+ }),
3267
+ image: IpfsUriSchema.meta({
3268
+ title: "Token Image",
3269
+ description: "IPFS URI pointing to the token's visual representation image",
3270
+ examples: ["ipfs://QmTokenImageHash/credit-icon.png"]
3271
+ }),
3272
+ description: z.string().min(50).max(1e3).meta({
3273
+ title: "Token Description",
3274
+ description: "Comprehensive description of the credit token, its purpose, and impact",
3275
+ examples: [
3276
+ "Carrot Carbon (C-CARB) represents verified carbon emissions reductions from organic waste composting projects. Each token equals one metric ton of CO2 equivalent prevented from entering the atmosphere through sustainable waste management practices."
3277
+ ]
3278
+ })
3279
+ }).meta(CreditSchemaMeta);
3280
+ var MethodologyDataSchema = z.strictObject({
3281
+ name: MethodologyNameSchema.meta({
3282
+ title: "Methodology Name",
3283
+ description: "Full official name of the methodology"
3284
+ }),
3285
+ short_name: NonEmptyStringSchema.max(50).meta({
3286
+ title: "Methodology Short Name",
3287
+ description: "Abbreviated name for UI display and references",
3288
+ examples: ["BOLD Carbon", "BOLD Recycling"]
3289
+ }),
3290
+ slug: SlugSchema.meta({
3291
+ title: "Methodology Slug",
3292
+ description: "URL-friendly identifier for the methodology",
3293
+ examples: ["bold-carbon-ch4", "bold-recycling"]
3294
+ }),
3295
+ version: SemanticVersionSchema.meta({
3296
+ title: "Methodology Version",
3297
+ description: "Version of the methodology"
3298
+ }),
3299
+ description: z.string().min(50).max(2e3).meta({
3300
+ title: "Methodology Description",
3301
+ description: "Comprehensive methodology description including purpose, scope, and implementation approach"
3302
+ }),
3303
+ revision_date: IsoDateSchema.meta({
3304
+ title: "Revision Date",
3305
+ description: "ISO 8601 date of the last revision to this methodology"
3306
+ }),
3307
+ publication_date: IsoDateSchema.meta({
3308
+ title: "Publication Date",
3309
+ description: "ISO 8601 date of the original publication of this methodology"
3310
+ }),
3311
+ methodology_pdf: IpfsUriSchema.meta({
3312
+ title: "Methodology PDF",
3313
+ description: "IPFS URI pointing to the complete methodology PDF document"
3314
+ }),
3315
+ mass_id_audit_rules: AuditRuleDefinitionsSchema.meta({
3316
+ title: "MassID Audit Rules",
3317
+ description: "Audit rules that must be executed to check MassID compliance with the methodology"
3318
+ })
3319
+ }).meta({
3320
+ title: "Methodology Data",
3321
+ description: "Methodology-specific data including audit rules"
3322
+ });
3323
+
3324
+ // src/methodology/methodology.schema.ts
3325
+ var MethodologySchemaMeta = {
3326
+ title: "Methodology IPFS Record",
3327
+ description: "Methodology metadata stored in IPFS, extending the base schema with methodology data and audit rules",
3328
+ $id: buildSchemaUrl("methodology/methodology.schema.json"),
3329
+ version: getSchemaVersionOrDefault()
3330
+ };
3331
+ var MethodologySchema = BaseIpfsSchema.safeExtend({
3332
+ schema: BaseIpfsSchema.shape.schema.safeExtend({
3333
+ type: z.literal("Methodology").meta({
3334
+ title: "Methodology Schema Type",
3335
+ description: "Methodology schema type"
3336
+ })
3337
+ }),
3338
+ data: MethodologyDataSchema
3339
+ }).meta(MethodologySchemaMeta);
3340
+ var MassIDAuditSummarySchema = z.strictObject({
3341
+ audit_date: IsoDateSchema.meta({
3342
+ title: "Audit Date",
3343
+ description: "Date when the audit was completed"
3344
+ }),
3345
+ methodology_compliance: MethodologyComplianceSchema.meta({
3346
+ title: "Methodology Compliance",
3347
+ description: "Overall outcome of the audit process"
3348
+ }),
3349
+ total_rules_executed: NonNegativeIntegerSchema.meta({
3350
+ title: "Total Rules Executed",
3351
+ description: "Total number of audit rules executed"
3352
+ }),
3353
+ passed_rules: NonNegativeIntegerSchema.meta({
3354
+ title: "Passed Rules Count",
3355
+ description: "Number of rules that passed verification"
3356
+ }),
3357
+ failed_rules: NonNegativeIntegerSchema.meta({
3358
+ title: "Failed Rules Count",
3359
+ description: "Number of rules that failed verification"
3360
+ })
3361
+ }).meta({
3362
+ title: "Audit Summary",
3363
+ description: "Summary of audit execution results"
3364
+ });
3365
+ var MassIDAuditDataSchema = z.strictObject({
3366
+ methodology: MethodologyReferenceSchema,
3367
+ mass_id: MassIDReferenceSchema,
3368
+ gas_id: GasIDReferenceSchema,
3369
+ audit_summary: MassIDAuditSummarySchema,
3370
+ rules_execution_results: AuditRuleExecutionResultsSchema
3371
+ }).meta({
3372
+ title: "MassID Audit Data",
3373
+ description: "Complete data structure for MassID Audit records"
3374
+ });
3375
+
3376
+ // src/mass-id-audit/mass-id-audit.schema.ts
3377
+ var MassIDAuditSchemaMeta = {
3378
+ title: "MassID Audit IPFS Record",
3379
+ description: "MassID audit metadata stored in IPFS, extending the base schema with audit results and references",
3380
+ $id: buildSchemaUrl("mass-id-audit/mass-id-audit.schema.json"),
3381
+ version: getSchemaVersionOrDefault()
3382
+ };
3383
+ var MassIDAuditSchema = BaseIpfsSchema.safeExtend({
3384
+ schema: BaseIpfsSchema.shape.schema.safeExtend({
3385
+ type: z.literal("MassID Audit").meta({
3386
+ title: "MassID Audit Schema Type",
3387
+ description: "MassID Audit schema type"
3388
+ })
3389
+ }),
3390
+ data: MassIDAuditDataSchema
3391
+ }).meta(MassIDAuditSchemaMeta);
1694
3392
 
1695
- export { AccreditedParticipantSchema, AccreditedParticipantsSchema, AdministrativeDivisionSchema, AuditReferenceSchema, BaseIpfsSchema, BlockchainChainIdSchema, CoordinatesSchema, CountryNameSchema, CreditAmountAttributeSchema, CreditAmountSchema, CreditTypeAttributeSchema, CreditTypeSchema, DistributionNotesSchema, EthereumAddressSchema, ExternalIdSchema, ExternalUrlSchema, FacilityTypeSchema, GasIDAttributesSchema, GasIDDataSchema, GasIDIpfsSchema, GasIDIpfsSchemaMeta, GasIDReferenceSchema, HexColorSchema, HoursSchema, IpfsUriSchema, IsoAdministrativeDivisionCodeSchema, IsoCountryCodeSchema, IsoDateSchema, IsoTimestampSchema, Keccak256HashSchema, LatitudeSchema, LocationSchema, LongitudeSchema, MassIDAttributesSchema, MassIDDataSchema, MassIDIpfsSchema, MassIDIpfsSchemaMeta, MassIDRecyclingDateAttributeSchema, MassIDReferenceSchema, MassIDTokenIdAttributeSchema, MethodologyAttributeSchema, MethodologyComplianceSchema, MethodologyNameSchema, MethodologyReferenceSchema, MinutesSchema, MunicipalitySchema, NftAttributeSchema, NftIpfsSchema, NonEmptyStringSchema, NonNegativeFloatSchema, NonNegativeIntegerSchema, OriginCountryAttributeSchema, OriginMunicipalityAttributeSchema, ParticipantNameSchema, ParticipantRewardsSchema, ParticipantRoleSchema, ParticipantSchema, PercentageSchema, PositiveIntegerSchema, RecordEnvironmentSchema, RecordRelationshipTypeSchema, RecordSchemaTypeSchema, RecycledIDAttributesSchema, RecycledIDDataSchema, RecycledIDIpfsSchema, RecycledIDIpfsSchemaMeta, RecyclerAttributeSchema, RewardAllocationSchema, SemanticVersionSchema, Sha256HashSchema, SlugSchema, SourceWasteTypeAttributeSchema, SourceWeightAttributeSchema, StringifiedTokenIdSchema, TokenIdSchema, TokenSymbolSchema, UnixTimestampSchema, UuidSchema, WasteClassificationSchema, WasteSubtypeSchema, WasteTypeSchema, WeightKgSchema, buildSchemaUrl, getSchemaBaseUrl, getSchemaVersionOrDefault, uniqueArrayItems, uniqueBy };
3393
+ export { AccreditedParticipantSchema, AccreditedParticipantsSchema, AdministrativeDivisionSchema, AuditReferenceSchema, AuditRuleDefinitionSchema, AuditRuleDefinitionsSchema, AuditRuleExecutionResultSchema, AuditRuleExecutionResultsSchema, BaseIpfsSchema, BlockchainChainIdSchema, BlockchainNetworkNameSchema, CollectionNameSchema, CollectionSchema, CollectionSchemaMeta, CollectionSlugSchema, CoordinatesSchema, CountryNameSchema, CreditAmountAttributeSchema, CreditAmountSchema, CreditPurchaseReceiptAttributesSchema, CreditPurchaseReceiptDataSchema, CreditPurchaseReceiptIpfsSchema, CreditPurchaseReceiptIpfsSchemaMeta, CreditPurchaseReceiptSummarySchema, CreditRetirementReceiptAttributesSchema, CreditRetirementReceiptDataSchema, CreditRetirementReceiptIpfsSchema, CreditRetirementReceiptIpfsSchemaMeta, CreditRetirementReceiptSummarySchema, CreditSchema, CreditSchemaMeta, CreditTokenSymbolSchema, CreditTypeAttributeSchema, CreditTypeSchema, DistributionNotesSchema, EPSILON, EthereumAddressSchema, ExternalIdSchema, ExternalUrlSchema, FacilityTypeSchema, GasIDAttributesSchema, GasIDDataSchema, GasIDIpfsSchema, GasIDIpfsSchemaMeta, GasIDReferenceSchema, HexColorSchema, HoursSchema, IpfsUriSchema, IsoAdministrativeDivisionCodeSchema, IsoCountryCodeSchema, IsoDateSchema, IsoTimestampSchema, Keccak256HashSchema, LatitudeSchema, LocationSchema, LongitudeSchema, MassIDAttributesSchema, MassIDAuditDataSchema, MassIDAuditSchema, MassIDAuditSchemaMeta, MassIDDataSchema, MassIDIpfsSchema, MassIDIpfsSchemaMeta, MassIDRecyclingDateAttributeSchema, MassIDReferenceSchema, MassIDTokenIdAttributeSchema, MassIdReferenceWithContractSchema, MethodologyAttributeSchema, MethodologyComplianceSchema, MethodologyDataSchema, MethodologyNameSchema, MethodologyReferenceSchema, MethodologySchema, MethodologySchemaMeta, MinutesSchema, MunicipalitySchema, NftAttributeSchema, NftIpfsSchema, NonEmptyStringSchema, NonNegativeFloatSchema, NonNegativeIntegerSchema, OriginCountryAttributeSchema, OriginMunicipalityAttributeSchema, ParticipantNameSchema, ParticipantRewardsSchema, ParticipantRoleSchema, ParticipantSchema, PercentageSchema, PositiveIntegerSchema, ReceiptIdentitySchema, RecordEnvironmentSchema, RecordRelationshipTypeSchema, RecordSchemaTypeSchema, RecycledIDAttributesSchema, RecycledIDDataSchema, RecycledIDIpfsSchema, RecycledIDIpfsSchemaMeta, RecyclerAttributeSchema, RewardAllocationSchema, SemanticVersionSchema, Sha256HashSchema, SlugSchema, SmartContractAddressSchema, SmartContractSchema, SourceWasteTypeAttributeSchema, SourceWeightAttributeSchema, StringifiedTokenIdSchema, TokenIdSchema, TokenSymbolSchema, UnixTimestampSchema, UuidSchema, WasteClassificationSchema, WasteSubtypeSchema, WasteTypeSchema, WeightKgSchema, buildSchemaUrl, createAttributeMap, createReceiptCertificateSchema, createReceiptCollectionSchema, createReceiptCreditSchema, getSchemaBaseUrl, getSchemaVersionOrDefault, nearlyEqual, uniqueArrayItems, uniqueBy, validateAttributeValue, validateAttributesForItems, validateCountMatches, validateDateAttribute, validateSummaryListMatchesData, validateTotalMatches };
1696
3394
  //# sourceMappingURL=index.js.map
1697
3395
  //# sourceMappingURL=index.js.map