@carrot-foundation/schemas 0.1.36 → 0.1.37
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +1124 -36
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +959 -13
- package/dist/index.d.ts +959 -13
- package/dist/index.js +1102 -37
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/schemas/ipfs/collection/collection.example.json +1 -0
- package/schemas/ipfs/collection/collection.schema.json +305 -32
- package/schemas/ipfs/credit/credit.example.json +1 -0
- package/schemas/ipfs/credit/credit.schema.json +326 -45
- package/schemas/ipfs/credit-purchase-receipt/credit-purchase-receipt.example.json +290 -0
- package/schemas/ipfs/credit-purchase-receipt/credit-purchase-receipt.schema.json +1768 -0
- package/schemas/ipfs/gas-id/gas-id.schema.json +6 -6
- package/schemas/ipfs/mass-id/mass-id.schema.json +6 -6
- package/schemas/ipfs/mass-id-audit/mass-id-audit.example.json +30 -29
- package/schemas/ipfs/mass-id-audit/mass-id-audit.schema.json +636 -15
- package/schemas/ipfs/methodology/methodology.example.json +27 -26
- package/schemas/ipfs/methodology/methodology.schema.json +457 -15
- package/schemas/ipfs/recycled-id/recycled-id.schema.json +6 -6
- package/schemas/ipfs/gas-id/gas-id.attributes.schema.json +0 -219
- package/schemas/ipfs/gas-id/gas-id.data.schema.json +0 -120
- package/schemas/ipfs/mass-id-audit/mass-id-audit.data.schema.json +0 -130
- package/schemas/ipfs/methodology/methodology.data.schema.json +0 -121
- package/schemas/ipfs/purchase-id/purchase-id.attributes.schema.json +0 -91
- package/schemas/ipfs/purchase-id/purchase-id.data.schema.json +0 -337
- package/schemas/ipfs/purchase-id/purchase-id.example.json +0 -224
- package/schemas/ipfs/purchase-id/purchase-id.schema.json +0 -29
- package/schemas/ipfs/recycled-id/recycled-id.attributes.schema.json +0 -202
- package/schemas/ipfs/recycled-id/recycled-id.data.schema.json +0 -63
- package/schemas/ipfs/shared/base/base.schema.json +0 -163
- package/schemas/ipfs/shared/certificate/certificate.schema.json +0 -145
- package/schemas/ipfs/shared/definitions/definitions.schema.json +0 -255
- package/schemas/ipfs/shared/entities/location/location.schema.json +0 -90
- package/schemas/ipfs/shared/entities/participant/participant.schema.json +0 -28
- package/schemas/ipfs/shared/nft/nft.schema.json +0 -182
- package/schemas/ipfs/shared/references/audit-reference/audit-reference.schema.json +0 -42
- package/schemas/ipfs/shared/references/gas-id-reference/gas-id-reference.schema.json +0 -27
- package/schemas/ipfs/shared/references/mass-id-reference/mass-id-reference.schema.json +0 -27
- 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-
|
|
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,7 @@ var RecordSchemaTypeSchema = z.enum([
|
|
|
262
289
|
"MassID Audit",
|
|
263
290
|
"RecycledID",
|
|
264
291
|
"GasID",
|
|
265
|
-
"
|
|
292
|
+
"CreditPurchaseReceipt",
|
|
266
293
|
"Methodology",
|
|
267
294
|
"Credit",
|
|
268
295
|
"Collection"
|
|
@@ -286,12 +313,12 @@ var RecordRelationshipTypeSchema = z.enum([
|
|
|
286
313
|
"mass-id",
|
|
287
314
|
"mass-id-audit",
|
|
288
315
|
"methodology",
|
|
289
|
-
"purchase-
|
|
316
|
+
"credit-purchase-receipt",
|
|
290
317
|
"recycled-id"
|
|
291
318
|
]).meta({
|
|
292
319
|
title: "Relationship Type",
|
|
293
320
|
description: "Type of relationship between different entities in the system",
|
|
294
|
-
examples: ["mass-id", "
|
|
321
|
+
examples: ["mass-id", "collection", "credit-purchase-receipt"]
|
|
295
322
|
});
|
|
296
323
|
function uniqueArrayItems(schema, errorMessage = "Array items must be unique") {
|
|
297
324
|
return z.array(schema).refine((items) => new Set(items).size === items.length, {
|
|
@@ -704,7 +731,7 @@ var NftSchemaTypeSchema = RecordSchemaTypeSchema.extract([
|
|
|
704
731
|
"MassID",
|
|
705
732
|
"RecycledID",
|
|
706
733
|
"GasID",
|
|
707
|
-
"
|
|
734
|
+
"CreditPurchaseReceipt"
|
|
708
735
|
]).meta({
|
|
709
736
|
title: "NFT Schema Type",
|
|
710
737
|
description: "Type of schema for NFT records"
|
|
@@ -881,16 +908,16 @@ function buildSchemaUrl(schemaPath) {
|
|
|
881
908
|
return `${getSchemaBaseUrl()}/${cleanPath}`;
|
|
882
909
|
}
|
|
883
910
|
function getSchemaVersionOrDefault() {
|
|
884
|
-
return "0.1.
|
|
911
|
+
return "0.1.37";
|
|
885
912
|
}
|
|
886
|
-
var MethodologyAttributeSchema = NftAttributeSchema.
|
|
913
|
+
var MethodologyAttributeSchema = NftAttributeSchema.safeExtend({
|
|
887
914
|
trait_type: z.literal("Methodology"),
|
|
888
915
|
value: MethodologyNameSchema
|
|
889
916
|
}).meta({
|
|
890
917
|
title: "Methodology Attribute",
|
|
891
918
|
description: "Methodology used for certification"
|
|
892
919
|
});
|
|
893
|
-
var CreditAmountAttributeSchema = NftAttributeSchema.
|
|
920
|
+
var CreditAmountAttributeSchema = NftAttributeSchema.safeExtend({
|
|
894
921
|
trait_type: z.literal("Credit Amount"),
|
|
895
922
|
value: CreditAmountSchema,
|
|
896
923
|
display_type: z.literal("number")
|
|
@@ -898,21 +925,21 @@ var CreditAmountAttributeSchema = NftAttributeSchema.extend({
|
|
|
898
925
|
title: "Credit Amount Attribute",
|
|
899
926
|
description: "Credit amount attribute with numeric display"
|
|
900
927
|
});
|
|
901
|
-
var CreditTypeAttributeSchema = NftAttributeSchema.
|
|
928
|
+
var CreditTypeAttributeSchema = NftAttributeSchema.safeExtend({
|
|
902
929
|
trait_type: z.literal("Credit Type"),
|
|
903
930
|
value: CreditTypeSchema
|
|
904
931
|
}).meta({
|
|
905
932
|
title: "Credit Type Attribute",
|
|
906
933
|
description: "Credit type attribute"
|
|
907
934
|
});
|
|
908
|
-
var SourceWasteTypeAttributeSchema = NftAttributeSchema.
|
|
935
|
+
var SourceWasteTypeAttributeSchema = NftAttributeSchema.safeExtend({
|
|
909
936
|
trait_type: z.literal("Source Waste Type"),
|
|
910
937
|
value: WasteTypeSchema
|
|
911
938
|
}).meta({
|
|
912
939
|
title: "Source Waste Type Attribute",
|
|
913
940
|
description: "Source waste type attribute"
|
|
914
941
|
});
|
|
915
|
-
var SourceWeightAttributeSchema = NftAttributeSchema.
|
|
942
|
+
var SourceWeightAttributeSchema = NftAttributeSchema.safeExtend({
|
|
916
943
|
trait_type: z.literal("Source Weight (kg)"),
|
|
917
944
|
value: WeightKgSchema.meta({
|
|
918
945
|
title: "Source Weight",
|
|
@@ -923,21 +950,21 @@ var SourceWeightAttributeSchema = NftAttributeSchema.extend({
|
|
|
923
950
|
title: "Source Weight Attribute",
|
|
924
951
|
description: "Source weight attribute with numeric display"
|
|
925
952
|
});
|
|
926
|
-
var OriginCountryAttributeSchema = NftAttributeSchema.
|
|
953
|
+
var OriginCountryAttributeSchema = NftAttributeSchema.safeExtend({
|
|
927
954
|
trait_type: z.literal("Origin Country"),
|
|
928
955
|
value: CountryNameSchema
|
|
929
956
|
}).meta({
|
|
930
957
|
title: "Origin Country Attribute",
|
|
931
958
|
description: "Origin country attribute"
|
|
932
959
|
});
|
|
933
|
-
var OriginMunicipalityAttributeSchema = NftAttributeSchema.
|
|
960
|
+
var OriginMunicipalityAttributeSchema = NftAttributeSchema.safeExtend({
|
|
934
961
|
trait_type: z.literal("Origin Municipality"),
|
|
935
962
|
value: MunicipalitySchema
|
|
936
963
|
}).meta({
|
|
937
964
|
title: "Origin Municipality Attribute",
|
|
938
965
|
description: "Origin municipality attribute"
|
|
939
966
|
});
|
|
940
|
-
var RecyclerAttributeSchema = NftAttributeSchema.
|
|
967
|
+
var RecyclerAttributeSchema = NftAttributeSchema.safeExtend({
|
|
941
968
|
trait_type: z.literal("Recycler"),
|
|
942
969
|
value: NonEmptyStringSchema.max(100).meta({
|
|
943
970
|
title: "Recycler",
|
|
@@ -948,7 +975,7 @@ var RecyclerAttributeSchema = NftAttributeSchema.extend({
|
|
|
948
975
|
title: "Recycler Attribute",
|
|
949
976
|
description: "Recycler attribute"
|
|
950
977
|
});
|
|
951
|
-
var MassIDTokenIdAttributeSchema = NftAttributeSchema.
|
|
978
|
+
var MassIDTokenIdAttributeSchema = NftAttributeSchema.safeExtend({
|
|
952
979
|
trait_type: z.literal("MassID"),
|
|
953
980
|
value: StringifiedTokenIdSchema.meta({
|
|
954
981
|
title: "MassID Token ID",
|
|
@@ -960,7 +987,7 @@ var MassIDTokenIdAttributeSchema = NftAttributeSchema.extend({
|
|
|
960
987
|
});
|
|
961
988
|
var MassIDRecyclingDateAttributeSchema = NftAttributeSchema.omit({
|
|
962
989
|
max_value: true
|
|
963
|
-
}).
|
|
990
|
+
}).safeExtend({
|
|
964
991
|
trait_type: z.literal("MassID Recycling Date"),
|
|
965
992
|
value: UnixTimestampSchema.meta({
|
|
966
993
|
title: "MassID Recycling Date",
|
|
@@ -971,23 +998,108 @@ var MassIDRecyclingDateAttributeSchema = NftAttributeSchema.omit({
|
|
|
971
998
|
title: "MassID Recycling Date Attribute",
|
|
972
999
|
description: "MassID recycling date attribute using Unix timestamp in milliseconds"
|
|
973
1000
|
});
|
|
1001
|
+
var AuditRuleDefinitionSchema = z.strictObject({
|
|
1002
|
+
rule_id: UuidSchema.meta({
|
|
1003
|
+
title: "Rule ID",
|
|
1004
|
+
description: "Unique identifier for the audit rule"
|
|
1005
|
+
}),
|
|
1006
|
+
rule_slug: SlugSchema.meta({
|
|
1007
|
+
title: "Rule Slug",
|
|
1008
|
+
description: "URL-friendly identifier for the rule"
|
|
1009
|
+
}),
|
|
1010
|
+
rule_name: NonEmptyStringSchema.max(100).meta({
|
|
1011
|
+
title: "Rule Name",
|
|
1012
|
+
description: "Human-readable name of the rule",
|
|
1013
|
+
examples: ["Waste Mass is Unique", "No Conflicting GasID or Credit"]
|
|
1014
|
+
}),
|
|
1015
|
+
description: z.string().min(10).max(500).meta({
|
|
1016
|
+
title: "Rule Description",
|
|
1017
|
+
description: "Detailed description of what the rule validates and why it is necessary",
|
|
1018
|
+
examples: [
|
|
1019
|
+
"Validates that each MassID is unique within the system to prevent duplicate entries"
|
|
1020
|
+
]
|
|
1021
|
+
}),
|
|
1022
|
+
source_code_url: z.url().regex(/^https:\/\/github\.com\/.*$/, "Must be a GitHub URL").meta({
|
|
1023
|
+
title: "Rule Source Code URL",
|
|
1024
|
+
description: "GitHub URL pointing to the implementation source code for this rule",
|
|
1025
|
+
examples: [
|
|
1026
|
+
"https://github.com/carrot-foundation/methodologies/blob/main/bold-carbon/rules/waste-mass-unique.js"
|
|
1027
|
+
]
|
|
1028
|
+
}),
|
|
1029
|
+
mandatory: z.boolean().meta({
|
|
1030
|
+
title: "Mandatory",
|
|
1031
|
+
description: "Whether this rule is mandatory for methodology compliance"
|
|
1032
|
+
}),
|
|
1033
|
+
execution_order: PositiveIntegerSchema.meta({
|
|
1034
|
+
title: "Rule Execution Order",
|
|
1035
|
+
description: "Sequential order in which this rule must be executed"
|
|
1036
|
+
})
|
|
1037
|
+
}).meta({
|
|
1038
|
+
title: "Audit Rule Definition",
|
|
1039
|
+
description: "Definition of an audit rule that must be executed for methodology compliance"
|
|
1040
|
+
});
|
|
1041
|
+
var AuditRuleDefinitionsSchema = z.array(AuditRuleDefinitionSchema).min(1).meta({
|
|
1042
|
+
title: "Audit Rule Definitions",
|
|
1043
|
+
description: "List of audit rules that must be executed to check methodology compliance"
|
|
1044
|
+
});
|
|
1045
|
+
var AuditRuleExecutionResultSchema = z.strictObject({
|
|
1046
|
+
rule_name: NonEmptyStringSchema.meta({
|
|
1047
|
+
title: "Rule Name",
|
|
1048
|
+
description: "Human-readable name of the audit rule"
|
|
1049
|
+
}),
|
|
1050
|
+
rule_id: UuidSchema.meta({
|
|
1051
|
+
title: "Rule ID",
|
|
1052
|
+
description: "Unique identifier for the rule"
|
|
1053
|
+
}),
|
|
1054
|
+
rule_slug: SlugSchema.meta({
|
|
1055
|
+
title: "Rule Slug",
|
|
1056
|
+
description: "URL-friendly identifier for the rule"
|
|
1057
|
+
}),
|
|
1058
|
+
execution_order: PositiveIntegerSchema.meta({
|
|
1059
|
+
title: "Rule Execution Order",
|
|
1060
|
+
description: "Sequential order in which this rule was executed"
|
|
1061
|
+
}),
|
|
1062
|
+
result: MethodologyComplianceSchema.meta({
|
|
1063
|
+
title: "Rule Execution Result",
|
|
1064
|
+
description: "Result of the rule execution"
|
|
1065
|
+
}),
|
|
1066
|
+
description: z.string().min(1).max(2e3).meta({
|
|
1067
|
+
title: "Rule Description",
|
|
1068
|
+
description: "Detailed description of what this rule validates"
|
|
1069
|
+
}),
|
|
1070
|
+
rule_processor_checksum: NonEmptyStringSchema.max(200).meta({
|
|
1071
|
+
title: "Rule Processor Checksum",
|
|
1072
|
+
description: "Checksum for rule processor integrity verification"
|
|
1073
|
+
}),
|
|
1074
|
+
rule_source_code_version: NonEmptyStringSchema.max(200).meta({
|
|
1075
|
+
title: "Rule Source Code Version",
|
|
1076
|
+
description: "Version identifier for the rule source code"
|
|
1077
|
+
})
|
|
1078
|
+
}).meta({
|
|
1079
|
+
title: "Audit Rule Execution Result",
|
|
1080
|
+
description: "Detailed result of an audit rule execution"
|
|
1081
|
+
});
|
|
1082
|
+
var AuditRuleExecutionResultsSchema = z.array(AuditRuleExecutionResultSchema).meta({
|
|
1083
|
+
title: "Audit Rule Execution Results",
|
|
1084
|
+
description: "Detailed results of each audit rule execution"
|
|
1085
|
+
});
|
|
974
1086
|
|
|
975
1087
|
// src/mass-id/mass-id.attributes.ts
|
|
976
|
-
var MassIDAttributeWasteTypeSchema = NftAttributeSchema.
|
|
1088
|
+
var MassIDAttributeWasteTypeSchema = NftAttributeSchema.safeExtend({
|
|
977
1089
|
trait_type: z.literal("Waste Type"),
|
|
978
1090
|
value: WasteTypeSchema
|
|
979
1091
|
}).meta({
|
|
980
1092
|
title: "Waste Type Attribute",
|
|
981
1093
|
description: "Waste type attribute"
|
|
982
1094
|
});
|
|
983
|
-
var MassIDAttributeWasteSubtypeSchema = NftAttributeSchema.
|
|
1095
|
+
var MassIDAttributeWasteSubtypeSchema = NftAttributeSchema.safeExtend({
|
|
984
1096
|
trait_type: z.literal("Waste Subtype"),
|
|
985
1097
|
value: WasteSubtypeSchema
|
|
986
1098
|
}).meta({
|
|
987
1099
|
title: "Waste Subtype Attribute",
|
|
988
1100
|
description: "Waste subtype attribute"
|
|
989
1101
|
});
|
|
990
|
-
var MassIDAttributeWeightSchema = NftAttributeSchema.
|
|
1102
|
+
var MassIDAttributeWeightSchema = NftAttributeSchema.safeExtend({
|
|
991
1103
|
trait_type: z.literal("Weight (kg)"),
|
|
992
1104
|
value: WeightKgSchema,
|
|
993
1105
|
display_type: z.literal("number")
|
|
@@ -995,20 +1107,20 @@ var MassIDAttributeWeightSchema = NftAttributeSchema.extend({
|
|
|
995
1107
|
title: "Weight Attribute",
|
|
996
1108
|
description: "Weight attribute with numeric display"
|
|
997
1109
|
});
|
|
998
|
-
var MassIDAttributeOriginCountrySchema = OriginCountryAttributeSchema.
|
|
1110
|
+
var MassIDAttributeOriginCountrySchema = OriginCountryAttributeSchema.safeExtend({
|
|
999
1111
|
value: CountryNameSchema
|
|
1000
1112
|
});
|
|
1001
|
-
var MassIDAttributeOriginMunicipalitySchema = OriginMunicipalityAttributeSchema.
|
|
1113
|
+
var MassIDAttributeOriginMunicipalitySchema = OriginMunicipalityAttributeSchema.safeExtend({
|
|
1002
1114
|
value: MunicipalitySchema
|
|
1003
1115
|
});
|
|
1004
|
-
var MassIDAttributeOriginDivisionSchema = NftAttributeSchema.
|
|
1116
|
+
var MassIDAttributeOriginDivisionSchema = NftAttributeSchema.safeExtend({
|
|
1005
1117
|
trait_type: z.literal("Origin Administrative Division"),
|
|
1006
1118
|
value: AdministrativeDivisionSchema
|
|
1007
1119
|
}).meta({
|
|
1008
1120
|
title: "Origin Administrative Division Attribute",
|
|
1009
1121
|
description: "Origin administrative division attribute"
|
|
1010
1122
|
});
|
|
1011
|
-
var MassIDAttributeVehicleTypeSchema = NftAttributeSchema.
|
|
1123
|
+
var MassIDAttributeVehicleTypeSchema = NftAttributeSchema.safeExtend({
|
|
1012
1124
|
trait_type: z.literal("Vehicle Type"),
|
|
1013
1125
|
value: NonEmptyStringSchema.max(100).meta({
|
|
1014
1126
|
title: "Vehicle Type",
|
|
@@ -1019,7 +1131,7 @@ var MassIDAttributeVehicleTypeSchema = NftAttributeSchema.extend({
|
|
|
1019
1131
|
title: "Vehicle Type Attribute",
|
|
1020
1132
|
description: "Vehicle type attribute"
|
|
1021
1133
|
});
|
|
1022
|
-
var MassIDAttributeRecyclingMethodSchema = NftAttributeSchema.
|
|
1134
|
+
var MassIDAttributeRecyclingMethodSchema = NftAttributeSchema.safeExtend({
|
|
1023
1135
|
trait_type: z.literal("Recycling Method"),
|
|
1024
1136
|
value: NonEmptyStringSchema.max(100).meta({
|
|
1025
1137
|
title: "Recycling Method",
|
|
@@ -1034,7 +1146,7 @@ var MassIDAttributeRecyclingMethodSchema = NftAttributeSchema.extend({
|
|
|
1034
1146
|
title: "Recycling Method Attribute",
|
|
1035
1147
|
description: "Recycling method attribute"
|
|
1036
1148
|
});
|
|
1037
|
-
var MassIDAttributeProcessingTimeSchema = NftAttributeSchema.
|
|
1149
|
+
var MassIDAttributeProcessingTimeSchema = NftAttributeSchema.safeExtend({
|
|
1038
1150
|
trait_type: z.literal("Processing Time (hours)"),
|
|
1039
1151
|
value: HoursSchema,
|
|
1040
1152
|
trait_description: NonEmptyStringSchema.max(200).optional().meta({
|
|
@@ -1045,7 +1157,7 @@ var MassIDAttributeProcessingTimeSchema = NftAttributeSchema.extend({
|
|
|
1045
1157
|
title: "Processing Time Attribute",
|
|
1046
1158
|
description: "Processing time attribute with optional trait description"
|
|
1047
1159
|
});
|
|
1048
|
-
var MassIDAttributeLocalWasteClassificationIdSchema = NftAttributeSchema.
|
|
1160
|
+
var MassIDAttributeLocalWasteClassificationIdSchema = NftAttributeSchema.safeExtend({
|
|
1049
1161
|
trait_type: z.literal("Local Waste Classification ID"),
|
|
1050
1162
|
value: NonEmptyStringSchema.max(100).meta({
|
|
1051
1163
|
title: "Local Waste Classification ID",
|
|
@@ -1056,7 +1168,7 @@ var MassIDAttributeLocalWasteClassificationIdSchema = NftAttributeSchema.extend(
|
|
|
1056
1168
|
title: "Local Waste Classification ID Attribute",
|
|
1057
1169
|
description: "Local waste classification ID attribute"
|
|
1058
1170
|
});
|
|
1059
|
-
var MassIDAttributeRecyclingManifestCodeSchema = NftAttributeSchema.
|
|
1171
|
+
var MassIDAttributeRecyclingManifestCodeSchema = NftAttributeSchema.safeExtend({
|
|
1060
1172
|
trait_type: z.literal("Recycling Manifest Code"),
|
|
1061
1173
|
value: NonEmptyStringSchema.max(100).meta({
|
|
1062
1174
|
title: "Recycling Manifest Code",
|
|
@@ -1067,7 +1179,7 @@ var MassIDAttributeRecyclingManifestCodeSchema = NftAttributeSchema.extend({
|
|
|
1067
1179
|
title: "Recycling Manifest Code Attribute",
|
|
1068
1180
|
description: "Recycling manifest code attribute (optional)"
|
|
1069
1181
|
});
|
|
1070
|
-
var MassIDAttributeTransportManifestCodeSchema = NftAttributeSchema.
|
|
1182
|
+
var MassIDAttributeTransportManifestCodeSchema = NftAttributeSchema.safeExtend({
|
|
1071
1183
|
trait_type: z.literal("Transport Manifest Code"),
|
|
1072
1184
|
value: NonEmptyStringSchema.max(100).meta({
|
|
1073
1185
|
title: "Transport Manifest Code",
|
|
@@ -1078,7 +1190,7 @@ var MassIDAttributeTransportManifestCodeSchema = NftAttributeSchema.extend({
|
|
|
1078
1190
|
title: "Transport Manifest Code Attribute",
|
|
1079
1191
|
description: "Transport manifest code attribute (optional)"
|
|
1080
1192
|
});
|
|
1081
|
-
var MassIDAttributeWeighingCaptureMethodSchema = NftAttributeSchema.
|
|
1193
|
+
var MassIDAttributeWeighingCaptureMethodSchema = NftAttributeSchema.safeExtend({
|
|
1082
1194
|
trait_type: z.literal("Weighing Capture Method"),
|
|
1083
1195
|
value: NonEmptyStringSchema.max(100).meta({
|
|
1084
1196
|
title: "Weighing Capture Method",
|
|
@@ -1089,7 +1201,7 @@ var MassIDAttributeWeighingCaptureMethodSchema = NftAttributeSchema.extend({
|
|
|
1089
1201
|
title: "Weighing Capture Method Attribute",
|
|
1090
1202
|
description: "Weighing capture method attribute (optional)"
|
|
1091
1203
|
});
|
|
1092
|
-
var MassIDAttributeScaleTypeSchema = NftAttributeSchema.
|
|
1204
|
+
var MassIDAttributeScaleTypeSchema = NftAttributeSchema.safeExtend({
|
|
1093
1205
|
trait_type: z.literal("Scale Type"),
|
|
1094
1206
|
value: NonEmptyStringSchema.max(100).meta({
|
|
1095
1207
|
title: "Scale Type",
|
|
@@ -1105,7 +1217,7 @@ var MassIDAttributeScaleTypeSchema = NftAttributeSchema.extend({
|
|
|
1105
1217
|
title: "Scale Type Attribute",
|
|
1106
1218
|
description: "Scale type attribute (optional)"
|
|
1107
1219
|
});
|
|
1108
|
-
var MassIDAttributeContainerTypeSchema = NftAttributeSchema.
|
|
1220
|
+
var MassIDAttributeContainerTypeSchema = NftAttributeSchema.safeExtend({
|
|
1109
1221
|
trait_type: z.literal("Container Type"),
|
|
1110
1222
|
value: NonEmptyStringSchema.max(100).meta({
|
|
1111
1223
|
title: "Container Type",
|
|
@@ -1116,7 +1228,7 @@ var MassIDAttributeContainerTypeSchema = NftAttributeSchema.extend({
|
|
|
1116
1228
|
title: "Container Type Attribute",
|
|
1117
1229
|
description: "Container type attribute (optional)"
|
|
1118
1230
|
});
|
|
1119
|
-
var MassIDAttributePickUpDateSchema = NftAttributeSchema.
|
|
1231
|
+
var MassIDAttributePickUpDateSchema = NftAttributeSchema.safeExtend({
|
|
1120
1232
|
trait_type: z.literal("Pick-up Date"),
|
|
1121
1233
|
value: UnixTimestampSchema.meta({
|
|
1122
1234
|
title: "Pick-up Date",
|
|
@@ -1128,7 +1240,7 @@ var MassIDAttributePickUpDateSchema = NftAttributeSchema.extend({
|
|
|
1128
1240
|
title: "Pick-up Date Attribute",
|
|
1129
1241
|
description: "Pick-up date attribute with Unix timestamp"
|
|
1130
1242
|
});
|
|
1131
|
-
var MassIDAttributeRecyclingDateSchema = NftAttributeSchema.
|
|
1243
|
+
var MassIDAttributeRecyclingDateSchema = NftAttributeSchema.safeExtend({
|
|
1132
1244
|
trait_type: z.literal("Recycling Date"),
|
|
1133
1245
|
value: UnixTimestampSchema.meta({
|
|
1134
1246
|
title: "Recycling Date",
|
|
@@ -1467,7 +1579,7 @@ var MassIDIpfsSchema = NftIpfsSchema.safeExtend({
|
|
|
1467
1579
|
data: MassIDDataSchema
|
|
1468
1580
|
}).meta(MassIDIpfsSchemaMeta);
|
|
1469
1581
|
var GasIDAttributeMethodologySchema = MethodologyAttributeSchema;
|
|
1470
|
-
var GasIDAttributeGasTypeSchema = NftAttributeSchema.
|
|
1582
|
+
var GasIDAttributeGasTypeSchema = NftAttributeSchema.safeExtend({
|
|
1471
1583
|
trait_type: z.literal("Gas Type"),
|
|
1472
1584
|
value: NonEmptyStringSchema.max(100).meta({
|
|
1473
1585
|
title: "Gas Type",
|
|
@@ -1478,7 +1590,7 @@ var GasIDAttributeGasTypeSchema = NftAttributeSchema.extend({
|
|
|
1478
1590
|
title: "Gas Type Attribute",
|
|
1479
1591
|
description: "Gas type attribute"
|
|
1480
1592
|
});
|
|
1481
|
-
var GasIDAttributeCo2ePreventedSchema = NftAttributeSchema.
|
|
1593
|
+
var GasIDAttributeCo2ePreventedSchema = NftAttributeSchema.safeExtend({
|
|
1482
1594
|
trait_type: z.literal("CO\u2082e Prevented (kg)"),
|
|
1483
1595
|
value: NonNegativeFloatSchema.meta({
|
|
1484
1596
|
title: "CO\u2082e Prevented",
|
|
@@ -1612,7 +1724,7 @@ var GasIDIpfsSchema = NftIpfsSchema.safeExtend({
|
|
|
1612
1724
|
data: GasIDDataSchema
|
|
1613
1725
|
}).meta(GasIDIpfsSchemaMeta);
|
|
1614
1726
|
var RecycledIDAttributeMethodologySchema = MethodologyAttributeSchema;
|
|
1615
|
-
var RecycledIDAttributeRecycledMassWeightSchema = NftAttributeSchema.
|
|
1727
|
+
var RecycledIDAttributeRecycledMassWeightSchema = NftAttributeSchema.safeExtend({
|
|
1616
1728
|
trait_type: z.literal("Recycled Mass Weight (kg)"),
|
|
1617
1729
|
value: WeightKgSchema.meta({
|
|
1618
1730
|
title: "Recycled Mass Weight",
|
|
@@ -1691,7 +1803,960 @@ var RecycledIDIpfsSchema = NftIpfsSchema.safeExtend({
|
|
|
1691
1803
|
attributes: RecycledIDAttributesSchema,
|
|
1692
1804
|
data: RecycledIDDataSchema
|
|
1693
1805
|
}).meta(RecycledIDIpfsSchemaMeta);
|
|
1806
|
+
var CreditPurchaseReceiptCreditAttributeSchema = NftAttributeSchema.safeExtend({
|
|
1807
|
+
trait_type: TokenSymbolSchema.meta({
|
|
1808
|
+
title: "Credit Token Symbol",
|
|
1809
|
+
description: "Symbol of the credit token (e.g., C-CARB, C-BIOW)",
|
|
1810
|
+
examples: ["C-CARB", "C-BIOW"]
|
|
1811
|
+
}),
|
|
1812
|
+
value: CreditAmountSchema.meta({
|
|
1813
|
+
title: "Credit Amount",
|
|
1814
|
+
description: "Amount of credits purchased for the token symbol"
|
|
1815
|
+
}),
|
|
1816
|
+
display_type: z.literal("number")
|
|
1817
|
+
}).meta({
|
|
1818
|
+
title: "Credit Attribute",
|
|
1819
|
+
description: "Attribute representing purchased amount per credit token symbol"
|
|
1820
|
+
});
|
|
1821
|
+
var CreditPurchaseReceiptTotalCreditsAttributeSchema = NftAttributeSchema.safeExtend({
|
|
1822
|
+
trait_type: z.literal("Total Credits Purchased"),
|
|
1823
|
+
value: CreditAmountSchema.meta({
|
|
1824
|
+
title: "Total Credits Purchased",
|
|
1825
|
+
description: "Total number of credits purchased across all tokens"
|
|
1826
|
+
}),
|
|
1827
|
+
display_type: z.literal("number")
|
|
1828
|
+
}).meta({
|
|
1829
|
+
title: "Total Credits Purchased Attribute",
|
|
1830
|
+
description: "Aggregate credits purchased attribute"
|
|
1831
|
+
});
|
|
1832
|
+
var CreditPurchaseReceiptTotalUsdcAttributeSchema = NftAttributeSchema.safeExtend({
|
|
1833
|
+
trait_type: z.literal("Total USDC Amount"),
|
|
1834
|
+
value: CreditAmountSchema.meta({
|
|
1835
|
+
title: "Total USDC Amount",
|
|
1836
|
+
description: "Total USDC amount paid for the purchase"
|
|
1837
|
+
}),
|
|
1838
|
+
display_type: z.literal("number")
|
|
1839
|
+
}).meta({
|
|
1840
|
+
title: "Total USDC Amount Attribute",
|
|
1841
|
+
description: "Aggregate USDC amount attribute"
|
|
1842
|
+
});
|
|
1843
|
+
var CreditPurchaseReceiptPurchaseDateAttributeSchema = NftAttributeSchema.safeExtend({
|
|
1844
|
+
trait_type: z.literal("Purchase Date"),
|
|
1845
|
+
value: UnixTimestampSchema.meta({
|
|
1846
|
+
title: "Purchase Date",
|
|
1847
|
+
description: "Unix timestamp in milliseconds when the purchase was completed"
|
|
1848
|
+
}),
|
|
1849
|
+
display_type: z.literal("date")
|
|
1850
|
+
}).meta({
|
|
1851
|
+
title: "Purchase Date Attribute",
|
|
1852
|
+
description: "Purchase date attribute using Unix timestamp in milliseconds"
|
|
1853
|
+
});
|
|
1854
|
+
var CreditPurchaseReceiptCertificatesAttributeSchema = NftAttributeSchema.safeExtend({
|
|
1855
|
+
trait_type: z.literal("Certificates Purchased"),
|
|
1856
|
+
value: PositiveIntegerSchema.meta({
|
|
1857
|
+
title: "Certificates Purchased",
|
|
1858
|
+
description: "Total number of certificates purchased"
|
|
1859
|
+
}),
|
|
1860
|
+
display_type: z.literal("number")
|
|
1861
|
+
}).meta({
|
|
1862
|
+
title: "Certificates Purchased Attribute",
|
|
1863
|
+
description: "Attribute representing how many certificates were purchased"
|
|
1864
|
+
});
|
|
1865
|
+
var CreditPurchaseReceiptReceiverAttributeSchema = NftAttributeSchema.omit({
|
|
1866
|
+
display_type: true,
|
|
1867
|
+
max_value: true
|
|
1868
|
+
}).safeExtend({
|
|
1869
|
+
trait_type: z.literal("Receiver"),
|
|
1870
|
+
value: ParticipantNameSchema.meta({
|
|
1871
|
+
title: "Receiver",
|
|
1872
|
+
description: "Organization or individual receiving the credits from the purchase",
|
|
1873
|
+
examples: ["EcoTech Solutions Inc."]
|
|
1874
|
+
})
|
|
1875
|
+
}).meta({
|
|
1876
|
+
title: "Receiver Attribute",
|
|
1877
|
+
description: "Attribute containing the receiver display name"
|
|
1878
|
+
});
|
|
1879
|
+
var CreditPurchaseReceiptCollectionAttributeSchema = NftAttributeSchema.safeExtend({
|
|
1880
|
+
trait_type: CollectionNameSchema,
|
|
1881
|
+
value: CreditAmountSchema.meta({
|
|
1882
|
+
title: "Credits from Collection",
|
|
1883
|
+
description: "Amount of credits purchased from the collection"
|
|
1884
|
+
}),
|
|
1885
|
+
display_type: z.literal("number")
|
|
1886
|
+
}).meta({
|
|
1887
|
+
title: "Collection Attribute",
|
|
1888
|
+
description: "Attribute representing the amount of credits purchased from a collection"
|
|
1889
|
+
});
|
|
1890
|
+
var CreditPurchaseReceiptAttributesSchema = uniqueBy(
|
|
1891
|
+
z.union([
|
|
1892
|
+
CreditPurchaseReceiptCreditAttributeSchema,
|
|
1893
|
+
CreditPurchaseReceiptTotalCreditsAttributeSchema,
|
|
1894
|
+
CreditPurchaseReceiptTotalUsdcAttributeSchema,
|
|
1895
|
+
CreditPurchaseReceiptPurchaseDateAttributeSchema,
|
|
1896
|
+
CreditPurchaseReceiptCertificatesAttributeSchema,
|
|
1897
|
+
CreditPurchaseReceiptReceiverAttributeSchema,
|
|
1898
|
+
CreditPurchaseReceiptCollectionAttributeSchema
|
|
1899
|
+
]),
|
|
1900
|
+
(attribute) => attribute.trait_type,
|
|
1901
|
+
"Attribute trait_type values must be unique"
|
|
1902
|
+
).min(5).meta({
|
|
1903
|
+
title: "Credit Purchase Receipt NFT Attribute Array",
|
|
1904
|
+
description: "Attributes for credit purchase receipts including per-credit breakdowns, totals, receiver, purchase date, and per-collection amounts. Attributes must have unique trait types."
|
|
1905
|
+
});
|
|
1906
|
+
var CreditPurchaseReceiptSummarySchema = z.strictObject({
|
|
1907
|
+
total_usdc_amount: NonNegativeFloatSchema.meta({
|
|
1908
|
+
title: "Total USDC Amount",
|
|
1909
|
+
description: "Total amount paid in USDC for the purchase"
|
|
1910
|
+
}),
|
|
1911
|
+
total_credits: CreditAmountSchema.meta({
|
|
1912
|
+
title: "Total Credits",
|
|
1913
|
+
description: "Total amount of credits purchased"
|
|
1914
|
+
}),
|
|
1915
|
+
total_certificates: PositiveIntegerSchema.meta({
|
|
1916
|
+
title: "Total Certificates",
|
|
1917
|
+
description: "Total number of certificates purchased"
|
|
1918
|
+
}),
|
|
1919
|
+
purchase_date: IsoDateSchema.meta({
|
|
1920
|
+
title: "Purchase Date",
|
|
1921
|
+
description: "Date when the purchase was made (YYYY-MM-DD)"
|
|
1922
|
+
}),
|
|
1923
|
+
credit_symbols: uniqueArrayItems(
|
|
1924
|
+
TokenSymbolSchema,
|
|
1925
|
+
"Credit symbols must be unique"
|
|
1926
|
+
).min(1).meta({
|
|
1927
|
+
title: "Credit Symbols",
|
|
1928
|
+
description: "Array of credit token symbols included in the purchase"
|
|
1929
|
+
}),
|
|
1930
|
+
certificate_types: uniqueArrayItems(
|
|
1931
|
+
RecordSchemaTypeSchema.extract(["GasID", "RecycledID"]),
|
|
1932
|
+
"Certificate types must be unique"
|
|
1933
|
+
).min(1).meta({
|
|
1934
|
+
title: "Certificate Types",
|
|
1935
|
+
description: "Array of certificate types included in the purchase"
|
|
1936
|
+
}),
|
|
1937
|
+
collection_slugs: uniqueArrayItems(
|
|
1938
|
+
CollectionSlugSchema,
|
|
1939
|
+
"Collection slugs must be unique"
|
|
1940
|
+
).min(1).meta({
|
|
1941
|
+
title: "Collection Slugs",
|
|
1942
|
+
description: "Array of collection slugs represented in the purchase"
|
|
1943
|
+
})
|
|
1944
|
+
}).meta({
|
|
1945
|
+
title: "Credit Purchase Receipt Summary",
|
|
1946
|
+
description: "Summary totals for the credit purchase including amounts and collections represented"
|
|
1947
|
+
});
|
|
1948
|
+
var CreditPurchaseReceiptIdentitySchema = z.strictObject({
|
|
1949
|
+
name: ParticipantNameSchema.meta({
|
|
1950
|
+
title: "Identity Name",
|
|
1951
|
+
description: "Display name for the participant",
|
|
1952
|
+
examples: ["EcoTech Solutions Inc."]
|
|
1953
|
+
}),
|
|
1954
|
+
external_id: ExternalIdSchema.meta({
|
|
1955
|
+
title: "Identity External ID",
|
|
1956
|
+
description: "External identifier for the participant"
|
|
1957
|
+
}),
|
|
1958
|
+
external_url: ExternalUrlSchema.meta({
|
|
1959
|
+
title: "Identity External URL",
|
|
1960
|
+
description: "External URL for the participant profile"
|
|
1961
|
+
})
|
|
1962
|
+
}).meta({
|
|
1963
|
+
title: "Identity",
|
|
1964
|
+
description: "Participant identity information"
|
|
1965
|
+
});
|
|
1966
|
+
var CreditPurchaseReceiptReceiverSchema = z.strictObject({
|
|
1967
|
+
wallet_address: EthereumAddressSchema.meta({
|
|
1968
|
+
title: "Receiver Wallet Address",
|
|
1969
|
+
description: "Ethereum address of the receiver"
|
|
1970
|
+
}),
|
|
1971
|
+
identity: CreditPurchaseReceiptIdentitySchema.optional()
|
|
1972
|
+
}).meta({
|
|
1973
|
+
title: "Receiver",
|
|
1974
|
+
description: "Receiver wallet and optional identity information"
|
|
1975
|
+
});
|
|
1976
|
+
var CreditPurchaseReceiptBuyerSchema = z.strictObject({
|
|
1977
|
+
buyer_id: ExternalIdSchema.meta({
|
|
1978
|
+
title: "Buyer ID",
|
|
1979
|
+
description: "Unique identifier for the buyer"
|
|
1980
|
+
}),
|
|
1981
|
+
identity: CreditPurchaseReceiptIdentitySchema.optional()
|
|
1982
|
+
}).meta({
|
|
1983
|
+
title: "Buyer",
|
|
1984
|
+
description: "Buyer identifier and optional identity information"
|
|
1985
|
+
});
|
|
1986
|
+
var CreditPurchaseReceiptPartiesSchema = z.strictObject({
|
|
1987
|
+
payer: EthereumAddressSchema.meta({
|
|
1988
|
+
title: "Payer Wallet Address",
|
|
1989
|
+
description: "Ethereum address paying for the purchase"
|
|
1990
|
+
}),
|
|
1991
|
+
receiver: CreditPurchaseReceiptReceiverSchema,
|
|
1992
|
+
buyer: CreditPurchaseReceiptBuyerSchema.optional()
|
|
1993
|
+
}).meta({
|
|
1994
|
+
title: "Parties",
|
|
1995
|
+
description: "Parties involved in the purchase including payer, receiver, and optional buyer"
|
|
1996
|
+
});
|
|
1997
|
+
var CreditPurchaseReceiptCollectionSchema = z.strictObject({
|
|
1998
|
+
slug: CollectionSlugSchema,
|
|
1999
|
+
external_id: ExternalIdSchema.meta({
|
|
2000
|
+
title: "Collection External ID",
|
|
2001
|
+
description: "External identifier for the collection"
|
|
2002
|
+
}),
|
|
2003
|
+
name: CollectionNameSchema,
|
|
2004
|
+
external_url: ExternalUrlSchema.meta({
|
|
2005
|
+
title: "Collection External URL",
|
|
2006
|
+
description: "External URL for the collection"
|
|
2007
|
+
}),
|
|
2008
|
+
uri: IpfsUriSchema.meta({
|
|
2009
|
+
title: "Collection URI",
|
|
2010
|
+
description: "IPFS URI for the collection metadata"
|
|
2011
|
+
}),
|
|
2012
|
+
credit_amount: CreditAmountSchema.meta({
|
|
2013
|
+
title: "Collection Credit Amount",
|
|
2014
|
+
description: "Total credits purchased from this collection"
|
|
2015
|
+
})
|
|
2016
|
+
}).meta({
|
|
2017
|
+
title: "Collection",
|
|
2018
|
+
description: "Collection included in the purchase"
|
|
2019
|
+
});
|
|
2020
|
+
var CreditPurchaseReceiptCreditSchema = z.strictObject({
|
|
2021
|
+
slug: SlugSchema.meta({
|
|
2022
|
+
title: "Credit Slug",
|
|
2023
|
+
description: "URL-friendly identifier for the credit"
|
|
2024
|
+
}),
|
|
2025
|
+
symbol: TokenSymbolSchema.meta({
|
|
2026
|
+
title: "Credit Token Symbol",
|
|
2027
|
+
description: "Symbol of the credit token",
|
|
2028
|
+
examples: ["C-CARB", "C-BIOW"]
|
|
2029
|
+
}),
|
|
2030
|
+
external_id: ExternalIdSchema.meta({
|
|
2031
|
+
title: "Credit External ID",
|
|
2032
|
+
description: "External identifier for the credit"
|
|
2033
|
+
}),
|
|
2034
|
+
external_url: ExternalUrlSchema.meta({
|
|
2035
|
+
title: "Credit External URL",
|
|
2036
|
+
description: "External URL for the credit"
|
|
2037
|
+
}),
|
|
2038
|
+
uri: IpfsUriSchema.meta({
|
|
2039
|
+
title: "Credit URI",
|
|
2040
|
+
description: "IPFS URI for the credit details"
|
|
2041
|
+
}),
|
|
2042
|
+
smart_contract: SmartContractSchema,
|
|
2043
|
+
purchase_amount: CreditAmountSchema.meta({
|
|
2044
|
+
title: "Credit Purchase Amount",
|
|
2045
|
+
description: "Total credits purchased for this credit type"
|
|
2046
|
+
}),
|
|
2047
|
+
retirement_amount: CreditAmountSchema.optional().meta({
|
|
2048
|
+
title: "Credit Retirement Amount",
|
|
2049
|
+
description: "Credits retired immediately for this credit type during purchase"
|
|
2050
|
+
})
|
|
2051
|
+
}).meta({
|
|
2052
|
+
title: "Credit",
|
|
2053
|
+
description: "Credit token included in the purchase"
|
|
2054
|
+
});
|
|
2055
|
+
var MassIDReferenceWithContractSchema = MassIDReferenceSchema.omit({
|
|
2056
|
+
external_id: true
|
|
2057
|
+
}).safeExtend({
|
|
2058
|
+
external_id: ExternalIdSchema.meta({
|
|
2059
|
+
title: "MassID External ID",
|
|
2060
|
+
description: "Unique identifier for the referenced MassID"
|
|
2061
|
+
}),
|
|
2062
|
+
smart_contract: SmartContractSchema
|
|
2063
|
+
}).meta({
|
|
2064
|
+
title: "MassID Reference with Smart Contract",
|
|
2065
|
+
description: "Reference to a MassID record including smart contract details"
|
|
2066
|
+
});
|
|
2067
|
+
var CreditPurchaseReceiptCertificateSchema = z.strictObject({
|
|
2068
|
+
token_id: TokenIdSchema.meta({
|
|
2069
|
+
title: "Certificate Token ID",
|
|
2070
|
+
description: "Token ID of the certificate"
|
|
2071
|
+
}),
|
|
2072
|
+
type: RecordSchemaTypeSchema.extract(["GasID", "RecycledID"]).meta({
|
|
2073
|
+
title: "Certificate Type",
|
|
2074
|
+
description: "Type of certificate (e.g., GasID, RecycledID)"
|
|
2075
|
+
}),
|
|
2076
|
+
external_id: ExternalIdSchema.meta({
|
|
2077
|
+
title: "Certificate External ID",
|
|
2078
|
+
description: "External identifier for the certificate"
|
|
2079
|
+
}),
|
|
2080
|
+
external_url: ExternalUrlSchema.meta({
|
|
2081
|
+
title: "Certificate External URL",
|
|
2082
|
+
description: "External URL for the certificate"
|
|
2083
|
+
}),
|
|
2084
|
+
uri: IpfsUriSchema.meta({
|
|
2085
|
+
title: "Certificate URI",
|
|
2086
|
+
description: "IPFS URI for the certificate metadata"
|
|
2087
|
+
}),
|
|
2088
|
+
smart_contract: SmartContractSchema,
|
|
2089
|
+
collection_slug: CollectionSlugSchema.meta({
|
|
2090
|
+
title: "Collection Slug",
|
|
2091
|
+
description: "Slug of the collection this certificate belongs to"
|
|
2092
|
+
}),
|
|
2093
|
+
total_amount: CreditAmountSchema.meta({
|
|
2094
|
+
title: "Certificate Total Amount",
|
|
2095
|
+
description: "Total credits available in this certificate"
|
|
2096
|
+
}),
|
|
2097
|
+
purchased_amount: CreditAmountSchema.meta({
|
|
2098
|
+
title: "Certificate Purchased Amount",
|
|
2099
|
+
description: "Credits purchased from this certificate"
|
|
2100
|
+
}),
|
|
2101
|
+
retired_amount: CreditAmountSchema.meta({
|
|
2102
|
+
title: "Certificate Retired Amount",
|
|
2103
|
+
description: "Credits retired from this certificate during the purchase (0 if none)"
|
|
2104
|
+
}),
|
|
2105
|
+
credit_slug: SlugSchema.meta({
|
|
2106
|
+
title: "Credit Slug",
|
|
2107
|
+
description: "Slug of the credit type for this certificate",
|
|
2108
|
+
examples: ["carbon", "organic"]
|
|
2109
|
+
}),
|
|
2110
|
+
mass_id: MassIDReferenceWithContractSchema
|
|
2111
|
+
}).meta({
|
|
2112
|
+
title: "Certificate",
|
|
2113
|
+
description: "Certificate associated with the purchase"
|
|
2114
|
+
});
|
|
2115
|
+
var CreditPurchaseReceiptParticipantRewardSchema = z.strictObject({
|
|
2116
|
+
id_hash: Sha256HashSchema.meta({
|
|
2117
|
+
title: "Participant ID Hash",
|
|
2118
|
+
description: "Hash representing the participant identifier (SHA-256 hex string)"
|
|
2119
|
+
}),
|
|
2120
|
+
participant_name: ParticipantNameSchema.meta({
|
|
2121
|
+
title: "Participant Name",
|
|
2122
|
+
description: "Legal name of the participant receiving the reward"
|
|
2123
|
+
}),
|
|
2124
|
+
roles: uniqueArrayItems(
|
|
2125
|
+
ParticipantRoleSchema,
|
|
2126
|
+
"Participant roles must be unique"
|
|
2127
|
+
).min(1).meta({
|
|
2128
|
+
title: "Participant Roles",
|
|
2129
|
+
description: "Roles the participant has in the supply chain"
|
|
2130
|
+
}),
|
|
2131
|
+
usdc_amount: NonNegativeFloatSchema.meta({
|
|
2132
|
+
title: "USDC Reward Amount",
|
|
2133
|
+
description: "USDC amount allocated to this participant"
|
|
2134
|
+
})
|
|
2135
|
+
}).meta({
|
|
2136
|
+
title: "Participant Reward",
|
|
2137
|
+
description: "Reward distribution for a participant"
|
|
2138
|
+
});
|
|
2139
|
+
var CreditPurchaseReceiptRetirementReceiptSchema = z.strictObject({
|
|
2140
|
+
token_id: TokenIdSchema.meta({
|
|
2141
|
+
title: "Retirement Receipt Token ID",
|
|
2142
|
+
description: "Token ID of the retirement receipt NFT"
|
|
2143
|
+
}),
|
|
2144
|
+
external_id: ExternalIdSchema.meta({
|
|
2145
|
+
title: "Retirement Receipt External ID",
|
|
2146
|
+
description: "External identifier for the retirement receipt"
|
|
2147
|
+
}),
|
|
2148
|
+
external_url: ExternalUrlSchema.meta({
|
|
2149
|
+
title: "Retirement Receipt External URL",
|
|
2150
|
+
description: "External URL for the retirement receipt"
|
|
2151
|
+
}),
|
|
2152
|
+
uri: IpfsUriSchema.meta({
|
|
2153
|
+
title: "Retirement Receipt URI",
|
|
2154
|
+
description: "IPFS URI for the retirement receipt metadata"
|
|
2155
|
+
}),
|
|
2156
|
+
smart_contract: SmartContractSchema
|
|
2157
|
+
}).meta({
|
|
2158
|
+
title: "Retirement Receipt Reference",
|
|
2159
|
+
description: "Reference to the retirement receipt NFT"
|
|
2160
|
+
});
|
|
2161
|
+
var CreditPurchaseReceiptRetirementSchema = z.strictObject({
|
|
2162
|
+
beneficiary_id: ExternalIdSchema.meta({
|
|
2163
|
+
title: "Retirement Beneficiary ID",
|
|
2164
|
+
description: "UUID identifying the beneficiary of the retirement (bytes16 normalized to UUID)"
|
|
2165
|
+
}),
|
|
2166
|
+
retirement_receipt: CreditPurchaseReceiptRetirementReceiptSchema.optional()
|
|
2167
|
+
}).meta({
|
|
2168
|
+
title: "Retirement",
|
|
2169
|
+
description: "Immediate retirement details performed as part of purchase"
|
|
2170
|
+
});
|
|
2171
|
+
var EPSILON = 1e-9;
|
|
2172
|
+
function nearlyEqual(a, b) {
|
|
2173
|
+
return Math.abs(a - b) <= EPSILON;
|
|
2174
|
+
}
|
|
2175
|
+
var CreditPurchaseReceiptDataSchema = z.strictObject({
|
|
2176
|
+
summary: CreditPurchaseReceiptSummarySchema,
|
|
2177
|
+
parties: CreditPurchaseReceiptPartiesSchema,
|
|
2178
|
+
collections: uniqueBy(
|
|
2179
|
+
CreditPurchaseReceiptCollectionSchema,
|
|
2180
|
+
(collection) => collection.slug,
|
|
2181
|
+
"Collection slugs must be unique"
|
|
2182
|
+
).min(1).meta({
|
|
2183
|
+
title: "Collections",
|
|
2184
|
+
description: "Collections included in the purchase"
|
|
2185
|
+
}),
|
|
2186
|
+
credits: uniqueBy(
|
|
2187
|
+
CreditPurchaseReceiptCreditSchema,
|
|
2188
|
+
(credit) => credit.slug,
|
|
2189
|
+
"Credit slugs must be unique"
|
|
2190
|
+
).min(1).meta({
|
|
2191
|
+
title: "Credits",
|
|
2192
|
+
description: "Credits included in the purchase"
|
|
2193
|
+
}),
|
|
2194
|
+
certificates: uniqueBy(
|
|
2195
|
+
CreditPurchaseReceiptCertificateSchema,
|
|
2196
|
+
(certificate) => certificate.token_id,
|
|
2197
|
+
"Certificate token_ids must be unique"
|
|
2198
|
+
).min(1).meta({
|
|
2199
|
+
title: "Certificates",
|
|
2200
|
+
description: "Certificates involved in the purchase"
|
|
2201
|
+
}),
|
|
2202
|
+
participant_rewards: uniqueBy(
|
|
2203
|
+
CreditPurchaseReceiptParticipantRewardSchema,
|
|
2204
|
+
(reward) => reward.id_hash,
|
|
2205
|
+
"Participant id_hash must be unique"
|
|
2206
|
+
).min(1).meta({
|
|
2207
|
+
title: "Participant Rewards",
|
|
2208
|
+
description: "Rewards distributed to participants in the supply chain for this purchase"
|
|
2209
|
+
}),
|
|
2210
|
+
retirement: CreditPurchaseReceiptRetirementSchema.optional()
|
|
2211
|
+
}).superRefine((data, ctx) => {
|
|
2212
|
+
const retirementProvided = Boolean(data.retirement);
|
|
2213
|
+
const creditsWithRetirement = data.credits.reduce(
|
|
2214
|
+
(indices, credit, index) => {
|
|
2215
|
+
if ((credit.retirement_amount ?? 0) > 0) {
|
|
2216
|
+
indices.push(index);
|
|
2217
|
+
}
|
|
2218
|
+
return indices;
|
|
2219
|
+
},
|
|
2220
|
+
[]
|
|
2221
|
+
);
|
|
2222
|
+
if (retirementProvided && creditsWithRetirement.length === 0) {
|
|
2223
|
+
ctx.addIssue({
|
|
2224
|
+
code: "custom",
|
|
2225
|
+
message: "retirement is present but no credit has retirement_amount greater than 0",
|
|
2226
|
+
path: ["retirement"]
|
|
2227
|
+
});
|
|
2228
|
+
}
|
|
2229
|
+
if (!retirementProvided && creditsWithRetirement.length > 0) {
|
|
2230
|
+
creditsWithRetirement.forEach((index) => {
|
|
2231
|
+
ctx.addIssue({
|
|
2232
|
+
code: "custom",
|
|
2233
|
+
message: "credit retirement_amount greater than 0 requires retirement details",
|
|
2234
|
+
path: ["credits", index, "retirement_amount"]
|
|
2235
|
+
});
|
|
2236
|
+
});
|
|
2237
|
+
}
|
|
2238
|
+
const collectionSlugs = new Set(
|
|
2239
|
+
data.collections.map((collection) => collection.slug)
|
|
2240
|
+
);
|
|
2241
|
+
const creditSlugs = new Set(data.credits.map((credit) => credit.slug));
|
|
2242
|
+
const creditSymbols = new Set(data.credits.map((credit) => credit.symbol));
|
|
2243
|
+
const summaryCreditSymbols = new Set(data.summary.credit_symbols);
|
|
2244
|
+
const summaryCollectionSlugs = new Set(data.summary.collection_slugs);
|
|
2245
|
+
const summaryCertificateTypes = new Set(data.summary.certificate_types);
|
|
2246
|
+
if (data.summary.total_certificates !== data.certificates.length) {
|
|
2247
|
+
ctx.addIssue({
|
|
2248
|
+
code: "custom",
|
|
2249
|
+
message: "summary.total_certificates must equal the number of certificates",
|
|
2250
|
+
path: ["summary", "total_certificates"]
|
|
2251
|
+
});
|
|
2252
|
+
}
|
|
2253
|
+
data.summary.credit_symbols.forEach((symbol) => {
|
|
2254
|
+
if (!creditSymbols.has(symbol)) {
|
|
2255
|
+
ctx.addIssue({
|
|
2256
|
+
code: "custom",
|
|
2257
|
+
message: "summary.credit_symbols must reference symbols from credits",
|
|
2258
|
+
path: ["summary", "credit_symbols"]
|
|
2259
|
+
});
|
|
2260
|
+
}
|
|
2261
|
+
});
|
|
2262
|
+
creditSymbols.forEach((symbol) => {
|
|
2263
|
+
if (!summaryCreditSymbols.has(symbol)) {
|
|
2264
|
+
ctx.addIssue({
|
|
2265
|
+
code: "custom",
|
|
2266
|
+
message: "All credit symbols must be listed in summary.credit_symbols",
|
|
2267
|
+
path: ["summary", "credit_symbols"]
|
|
2268
|
+
});
|
|
2269
|
+
}
|
|
2270
|
+
});
|
|
2271
|
+
data.summary.collection_slugs.forEach((slug) => {
|
|
2272
|
+
if (!collectionSlugs.has(slug)) {
|
|
2273
|
+
ctx.addIssue({
|
|
2274
|
+
code: "custom",
|
|
2275
|
+
message: "summary.collection_slugs must reference slugs from collections",
|
|
2276
|
+
path: ["summary", "collection_slugs"]
|
|
2277
|
+
});
|
|
2278
|
+
}
|
|
2279
|
+
});
|
|
2280
|
+
collectionSlugs.forEach((slug) => {
|
|
2281
|
+
if (!summaryCollectionSlugs.has(slug)) {
|
|
2282
|
+
ctx.addIssue({
|
|
2283
|
+
code: "custom",
|
|
2284
|
+
message: "All collection slugs must be listed in summary.collection_slugs",
|
|
2285
|
+
path: ["summary", "collection_slugs"]
|
|
2286
|
+
});
|
|
2287
|
+
}
|
|
2288
|
+
});
|
|
2289
|
+
const certificateTypes = new Set(
|
|
2290
|
+
data.certificates.map((certificate) => certificate.type)
|
|
2291
|
+
);
|
|
2292
|
+
data.summary.certificate_types.forEach((type) => {
|
|
2293
|
+
if (!certificateTypes.has(type)) {
|
|
2294
|
+
ctx.addIssue({
|
|
2295
|
+
code: "custom",
|
|
2296
|
+
message: "summary.certificate_types must reference types present in certificates",
|
|
2297
|
+
path: ["summary", "certificate_types"]
|
|
2298
|
+
});
|
|
2299
|
+
}
|
|
2300
|
+
});
|
|
2301
|
+
certificateTypes.forEach((type) => {
|
|
2302
|
+
if (!summaryCertificateTypes.has(type)) {
|
|
2303
|
+
ctx.addIssue({
|
|
2304
|
+
code: "custom",
|
|
2305
|
+
message: "All certificate types must be listed in summary.certificate_types",
|
|
2306
|
+
path: ["summary", "certificate_types"]
|
|
2307
|
+
});
|
|
2308
|
+
}
|
|
2309
|
+
});
|
|
2310
|
+
const creditPurchaseTotalsBySlug = /* @__PURE__ */ new Map();
|
|
2311
|
+
const creditRetiredTotalsBySlug = /* @__PURE__ */ new Map();
|
|
2312
|
+
const collectionTotalsBySlug = /* @__PURE__ */ new Map();
|
|
2313
|
+
let totalCreditsFromCertificates = 0;
|
|
2314
|
+
data.certificates.forEach((certificate, index) => {
|
|
2315
|
+
if (!collectionSlugs.has(certificate.collection_slug)) {
|
|
2316
|
+
ctx.addIssue({
|
|
2317
|
+
code: "custom",
|
|
2318
|
+
message: "collection_slug must match a collection slug in collections",
|
|
2319
|
+
path: ["certificates", index, "collection_slug"]
|
|
2320
|
+
});
|
|
2321
|
+
}
|
|
2322
|
+
if (!creditSlugs.has(certificate.credit_slug)) {
|
|
2323
|
+
ctx.addIssue({
|
|
2324
|
+
code: "custom",
|
|
2325
|
+
message: "credit_slug must match a credit slug in credits",
|
|
2326
|
+
path: ["certificates", index, "credit_slug"]
|
|
2327
|
+
});
|
|
2328
|
+
}
|
|
2329
|
+
if (certificate.retired_amount > certificate.purchased_amount) {
|
|
2330
|
+
ctx.addIssue({
|
|
2331
|
+
code: "custom",
|
|
2332
|
+
message: "retired_amount cannot exceed purchased_amount",
|
|
2333
|
+
path: ["certificates", index, "retired_amount"]
|
|
2334
|
+
});
|
|
2335
|
+
}
|
|
2336
|
+
if (certificate.purchased_amount > certificate.total_amount) {
|
|
2337
|
+
ctx.addIssue({
|
|
2338
|
+
code: "custom",
|
|
2339
|
+
message: "purchased_amount cannot exceed total_amount",
|
|
2340
|
+
path: ["certificates", index, "purchased_amount"]
|
|
2341
|
+
});
|
|
2342
|
+
}
|
|
2343
|
+
totalCreditsFromCertificates += certificate.purchased_amount;
|
|
2344
|
+
creditPurchaseTotalsBySlug.set(
|
|
2345
|
+
certificate.credit_slug,
|
|
2346
|
+
(creditPurchaseTotalsBySlug.get(certificate.credit_slug) ?? 0) + certificate.purchased_amount
|
|
2347
|
+
);
|
|
2348
|
+
creditRetiredTotalsBySlug.set(
|
|
2349
|
+
certificate.credit_slug,
|
|
2350
|
+
(creditRetiredTotalsBySlug.get(certificate.credit_slug) ?? 0) + certificate.retired_amount
|
|
2351
|
+
);
|
|
2352
|
+
collectionTotalsBySlug.set(
|
|
2353
|
+
certificate.collection_slug,
|
|
2354
|
+
(collectionTotalsBySlug.get(certificate.collection_slug) ?? 0) + certificate.purchased_amount
|
|
2355
|
+
);
|
|
2356
|
+
});
|
|
2357
|
+
const totalCreditsFromCollections = data.collections.reduce(
|
|
2358
|
+
(sum, collection) => sum + collection.credit_amount,
|
|
2359
|
+
0
|
|
2360
|
+
);
|
|
2361
|
+
const totalCreditsFromCredits = data.credits.reduce(
|
|
2362
|
+
(sum, credit) => sum + credit.purchase_amount,
|
|
2363
|
+
0
|
|
2364
|
+
);
|
|
2365
|
+
if (!nearlyEqual(totalCreditsFromCertificates, data.summary.total_credits)) {
|
|
2366
|
+
ctx.addIssue({
|
|
2367
|
+
code: "custom",
|
|
2368
|
+
message: "summary.total_credits must equal sum of certificates.purchased_amount",
|
|
2369
|
+
path: ["summary", "total_credits"]
|
|
2370
|
+
});
|
|
2371
|
+
}
|
|
2372
|
+
if (!nearlyEqual(totalCreditsFromCredits, data.summary.total_credits)) {
|
|
2373
|
+
ctx.addIssue({
|
|
2374
|
+
code: "custom",
|
|
2375
|
+
message: "summary.total_credits must equal sum of credits.purchase_amount",
|
|
2376
|
+
path: ["summary", "total_credits"]
|
|
2377
|
+
});
|
|
2378
|
+
}
|
|
2379
|
+
if (!nearlyEqual(totalCreditsFromCollections, data.summary.total_credits)) {
|
|
2380
|
+
ctx.addIssue({
|
|
2381
|
+
code: "custom",
|
|
2382
|
+
message: "summary.total_credits must equal sum of collections.credit_amount",
|
|
2383
|
+
path: ["summary", "total_credits"]
|
|
2384
|
+
});
|
|
2385
|
+
}
|
|
2386
|
+
data.credits.forEach((credit, index) => {
|
|
2387
|
+
const purchasedTotal = creditPurchaseTotalsBySlug.get(credit.slug) ?? 0;
|
|
2388
|
+
if (!nearlyEqual(credit.purchase_amount, purchasedTotal)) {
|
|
2389
|
+
ctx.addIssue({
|
|
2390
|
+
code: "custom",
|
|
2391
|
+
message: "credit.purchase_amount must equal sum of certificate purchased_amount for the credit slug",
|
|
2392
|
+
path: ["credits", index, "purchase_amount"]
|
|
2393
|
+
});
|
|
2394
|
+
}
|
|
2395
|
+
const retiredTotal = creditRetiredTotalsBySlug.get(credit.slug) ?? 0;
|
|
2396
|
+
const retirementAmount = credit.retirement_amount ?? 0;
|
|
2397
|
+
if (!nearlyEqual(retirementAmount, retiredTotal)) {
|
|
2398
|
+
ctx.addIssue({
|
|
2399
|
+
code: "custom",
|
|
2400
|
+
message: "credit.retirement_amount must equal sum of certificate retired_amount for the credit slug",
|
|
2401
|
+
path: ["credits", index, "retirement_amount"]
|
|
2402
|
+
});
|
|
2403
|
+
}
|
|
2404
|
+
});
|
|
2405
|
+
data.collections.forEach((collection, index) => {
|
|
2406
|
+
const purchasedTotal = collectionTotalsBySlug.get(collection.slug) ?? 0;
|
|
2407
|
+
if (!nearlyEqual(collection.credit_amount, purchasedTotal)) {
|
|
2408
|
+
ctx.addIssue({
|
|
2409
|
+
code: "custom",
|
|
2410
|
+
message: "collection.credit_amount must equal sum of certificate purchased_amount for the collection slug",
|
|
2411
|
+
path: ["collections", index, "credit_amount"]
|
|
2412
|
+
});
|
|
2413
|
+
}
|
|
2414
|
+
});
|
|
2415
|
+
const participantRewardTotal = data.participant_rewards.reduce(
|
|
2416
|
+
(sum, reward) => sum + reward.usdc_amount,
|
|
2417
|
+
0
|
|
2418
|
+
);
|
|
2419
|
+
if (!nearlyEqual(participantRewardTotal, data.summary.total_usdc_amount)) {
|
|
2420
|
+
ctx.addIssue({
|
|
2421
|
+
code: "custom",
|
|
2422
|
+
message: "summary.total_usdc_amount must equal sum of participant_rewards.usdc_amount",
|
|
2423
|
+
path: ["summary", "total_usdc_amount"]
|
|
2424
|
+
});
|
|
2425
|
+
}
|
|
2426
|
+
}).meta({
|
|
2427
|
+
title: "Credit Purchase Receipt Data",
|
|
2428
|
+
description: "Complete data structure for a credit purchase receipt"
|
|
2429
|
+
});
|
|
2430
|
+
var CreditPurchaseReceiptIpfsSchemaMeta = {
|
|
2431
|
+
title: "CreditPurchaseReceipt NFT IPFS Record",
|
|
2432
|
+
description: "Complete CreditPurchaseReceipt NFT IPFS record including attributes and credit purchase data",
|
|
2433
|
+
$id: buildSchemaUrl(
|
|
2434
|
+
"credit-purchase-receipt/credit-purchase-receipt.schema.json"
|
|
2435
|
+
),
|
|
2436
|
+
version: getSchemaVersionOrDefault()
|
|
2437
|
+
};
|
|
2438
|
+
var CreditPurchaseReceiptIpfsSchema = NftIpfsSchema.safeExtend({
|
|
2439
|
+
schema: NftIpfsSchema.shape.schema.safeExtend({
|
|
2440
|
+
type: z.literal("CreditPurchaseReceipt").meta({
|
|
2441
|
+
title: "CreditPurchaseReceipt Schema Type",
|
|
2442
|
+
description: "CreditPurchaseReceipt NFT schema type"
|
|
2443
|
+
})
|
|
2444
|
+
}),
|
|
2445
|
+
attributes: CreditPurchaseReceiptAttributesSchema,
|
|
2446
|
+
data: CreditPurchaseReceiptDataSchema
|
|
2447
|
+
}).superRefine((value, ctx) => {
|
|
2448
|
+
const attributes = value.attributes;
|
|
2449
|
+
const data = value.data;
|
|
2450
|
+
const attributeByTraitType = new Map(
|
|
2451
|
+
attributes.map((attribute) => [attribute.trait_type, attribute])
|
|
2452
|
+
);
|
|
2453
|
+
const totalCreditsAttribute = attributeByTraitType.get(
|
|
2454
|
+
"Total Credits Purchased"
|
|
2455
|
+
);
|
|
2456
|
+
const totalCreditsAttr = totalCreditsAttribute;
|
|
2457
|
+
if (!totalCreditsAttr) {
|
|
2458
|
+
ctx.addIssue({
|
|
2459
|
+
code: "custom",
|
|
2460
|
+
message: 'Attribute "Total Credits Purchased" is required',
|
|
2461
|
+
path: ["attributes"]
|
|
2462
|
+
});
|
|
2463
|
+
} else if (totalCreditsAttr.value !== data.summary.total_credits) {
|
|
2464
|
+
ctx.addIssue({
|
|
2465
|
+
code: "custom",
|
|
2466
|
+
message: 'Attribute "Total Credits Purchased" must match data.summary.total_credits',
|
|
2467
|
+
path: ["attributes"]
|
|
2468
|
+
});
|
|
2469
|
+
}
|
|
2470
|
+
const totalUsdcAttribute = attributeByTraitType.get("Total USDC Amount");
|
|
2471
|
+
if (!totalUsdcAttribute) {
|
|
2472
|
+
ctx.addIssue({
|
|
2473
|
+
code: "custom",
|
|
2474
|
+
message: 'Attribute "Total USDC Amount" is required',
|
|
2475
|
+
path: ["attributes"]
|
|
2476
|
+
});
|
|
2477
|
+
} else if (totalUsdcAttribute.value !== data.summary.total_usdc_amount) {
|
|
2478
|
+
ctx.addIssue({
|
|
2479
|
+
code: "custom",
|
|
2480
|
+
message: 'Attribute "Total USDC Amount" must match data.summary.total_usdc_amount',
|
|
2481
|
+
path: ["attributes"]
|
|
2482
|
+
});
|
|
2483
|
+
}
|
|
2484
|
+
const certificatesAttribute = attributeByTraitType.get(
|
|
2485
|
+
"Certificates Purchased"
|
|
2486
|
+
);
|
|
2487
|
+
if (!certificatesAttribute) {
|
|
2488
|
+
ctx.addIssue({
|
|
2489
|
+
code: "custom",
|
|
2490
|
+
message: 'Attribute "Certificates Purchased" is required',
|
|
2491
|
+
path: ["attributes"]
|
|
2492
|
+
});
|
|
2493
|
+
} else if (certificatesAttribute.value !== data.summary.total_certificates) {
|
|
2494
|
+
ctx.addIssue({
|
|
2495
|
+
code: "custom",
|
|
2496
|
+
message: 'Attribute "Certificates Purchased" must match data.summary.total_certificates',
|
|
2497
|
+
path: ["attributes"]
|
|
2498
|
+
});
|
|
2499
|
+
}
|
|
2500
|
+
const receiverAttribute = attributeByTraitType.get("Receiver");
|
|
2501
|
+
if (data.parties.receiver.identity?.name && !receiverAttribute) {
|
|
2502
|
+
ctx.addIssue({
|
|
2503
|
+
code: "custom",
|
|
2504
|
+
message: 'Attribute "Receiver" is required when receiver.identity.name is provided',
|
|
2505
|
+
path: ["attributes"]
|
|
2506
|
+
});
|
|
2507
|
+
} else if (receiverAttribute && data.parties.receiver.identity?.name && receiverAttribute.value !== data.parties.receiver.identity.name) {
|
|
2508
|
+
ctx.addIssue({
|
|
2509
|
+
code: "custom",
|
|
2510
|
+
message: 'Attribute "Receiver" must match receiver.identity.name',
|
|
2511
|
+
path: ["attributes"]
|
|
2512
|
+
});
|
|
2513
|
+
}
|
|
2514
|
+
const purchaseDateAttribute = attributeByTraitType.get("Purchase Date");
|
|
2515
|
+
const purchaseDateAttr = purchaseDateAttribute;
|
|
2516
|
+
if (!purchaseDateAttr) {
|
|
2517
|
+
ctx.addIssue({
|
|
2518
|
+
code: "custom",
|
|
2519
|
+
message: 'Attribute "Purchase Date" is required',
|
|
2520
|
+
path: ["attributes"]
|
|
2521
|
+
});
|
|
2522
|
+
} else {
|
|
2523
|
+
const purchaseDateMs = Date.parse(
|
|
2524
|
+
`${data.summary.purchase_date}T00:00:00.000Z`
|
|
2525
|
+
);
|
|
2526
|
+
if (Number.isNaN(purchaseDateMs)) {
|
|
2527
|
+
ctx.addIssue({
|
|
2528
|
+
code: "custom",
|
|
2529
|
+
message: "data.summary.purchase_date must be a valid date string",
|
|
2530
|
+
path: ["data", "summary", "purchase_date"]
|
|
2531
|
+
});
|
|
2532
|
+
} else if (purchaseDateAttr.value !== purchaseDateMs) {
|
|
2533
|
+
ctx.addIssue({
|
|
2534
|
+
code: "custom",
|
|
2535
|
+
message: 'Attribute "Purchase Date" must match data.summary.purchase_date as a Unix timestamp in milliseconds',
|
|
2536
|
+
path: ["attributes"]
|
|
2537
|
+
});
|
|
2538
|
+
}
|
|
2539
|
+
}
|
|
2540
|
+
data.credits.forEach((credit) => {
|
|
2541
|
+
const creditAttribute = attributeByTraitType.get(credit.symbol);
|
|
2542
|
+
if (!creditAttribute) {
|
|
2543
|
+
ctx.addIssue({
|
|
2544
|
+
code: "custom",
|
|
2545
|
+
message: `Attribute for credit symbol ${credit.symbol} is required`,
|
|
2546
|
+
path: ["attributes"]
|
|
2547
|
+
});
|
|
2548
|
+
return;
|
|
2549
|
+
}
|
|
2550
|
+
if (creditAttribute.value !== credit.purchase_amount) {
|
|
2551
|
+
ctx.addIssue({
|
|
2552
|
+
code: "custom",
|
|
2553
|
+
message: `Attribute for credit symbol ${credit.symbol} must match credit.purchase_amount`,
|
|
2554
|
+
path: ["attributes"]
|
|
2555
|
+
});
|
|
2556
|
+
}
|
|
2557
|
+
});
|
|
2558
|
+
data.collections.forEach((collection) => {
|
|
2559
|
+
const collectionAttribute = attributeByTraitType.get(collection.name);
|
|
2560
|
+
if (!collectionAttribute) {
|
|
2561
|
+
ctx.addIssue({
|
|
2562
|
+
code: "custom",
|
|
2563
|
+
message: `Attribute for collection ${collection.name} is required`,
|
|
2564
|
+
path: ["attributes"]
|
|
2565
|
+
});
|
|
2566
|
+
return;
|
|
2567
|
+
}
|
|
2568
|
+
if (collectionAttribute.value !== collection.credit_amount) {
|
|
2569
|
+
ctx.addIssue({
|
|
2570
|
+
code: "custom",
|
|
2571
|
+
message: `Attribute for collection ${collection.name} must match collection.credit_amount`,
|
|
2572
|
+
path: ["attributes"]
|
|
2573
|
+
});
|
|
2574
|
+
}
|
|
2575
|
+
});
|
|
2576
|
+
}).meta(CreditPurchaseReceiptIpfsSchemaMeta);
|
|
2577
|
+
var CollectionSchemaMeta = {
|
|
2578
|
+
title: "Collection IPFS Record",
|
|
2579
|
+
description: "Collection metadata stored in IPFS, extending the base schema with collection-specific fields required for NFT collection definitions in Carrot's ecosystem",
|
|
2580
|
+
$id: buildSchemaUrl("collection/collection.schema.json"),
|
|
2581
|
+
version: getSchemaVersionOrDefault()
|
|
2582
|
+
};
|
|
2583
|
+
var CollectionSchema = BaseIpfsSchema.safeExtend({
|
|
2584
|
+
schema: BaseIpfsSchema.shape.schema.safeExtend({
|
|
2585
|
+
type: z.literal("Collection").meta({
|
|
2586
|
+
title: "Collection Schema Type",
|
|
2587
|
+
description: "Collection schema type"
|
|
2588
|
+
})
|
|
2589
|
+
}),
|
|
2590
|
+
name: CollectionNameSchema,
|
|
2591
|
+
slug: CollectionSlugSchema.optional(),
|
|
2592
|
+
image: IpfsUriSchema.meta({
|
|
2593
|
+
title: "Collection Image",
|
|
2594
|
+
description: "IPFS URI pointing to the collection's visual representation",
|
|
2595
|
+
examples: ["ipfs://QmCollectionImageHash/collection-icon.png"]
|
|
2596
|
+
}),
|
|
2597
|
+
description: z.string().min(50).max(1e3).meta({
|
|
2598
|
+
title: "Collection Description",
|
|
2599
|
+
description: "Comprehensive description of the collection, its purpose, and context",
|
|
2600
|
+
examples: [
|
|
2601
|
+
"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."
|
|
2602
|
+
]
|
|
2603
|
+
})
|
|
2604
|
+
}).meta(CollectionSchemaMeta);
|
|
2605
|
+
var CreditSchemaMeta = {
|
|
2606
|
+
title: "Credit IPFS Record",
|
|
2607
|
+
description: "Credit token metadata stored in IPFS, extending the base schema with ERC20-specific details",
|
|
2608
|
+
$id: buildSchemaUrl("credit/credit.schema.json"),
|
|
2609
|
+
version: getSchemaVersionOrDefault()
|
|
2610
|
+
};
|
|
2611
|
+
var CreditSchema = BaseIpfsSchema.safeExtend({
|
|
2612
|
+
schema: BaseIpfsSchema.shape.schema.safeExtend({
|
|
2613
|
+
type: z.literal("Credit").meta({
|
|
2614
|
+
title: "Credit Schema Type",
|
|
2615
|
+
description: "Credit schema type"
|
|
2616
|
+
})
|
|
2617
|
+
}),
|
|
2618
|
+
symbol: TokenSymbolSchema,
|
|
2619
|
+
slug: SlugSchema.meta({
|
|
2620
|
+
title: "Token Slug",
|
|
2621
|
+
description: "URL-friendly identifier for the token",
|
|
2622
|
+
examples: ["carbon"]
|
|
2623
|
+
}).optional(),
|
|
2624
|
+
name: NonEmptyStringSchema.meta({
|
|
2625
|
+
title: "Token Name",
|
|
2626
|
+
description: "Full human-readable name of the ERC20 token",
|
|
2627
|
+
examples: ["Carrot Carbon"]
|
|
2628
|
+
}),
|
|
2629
|
+
decimals: z.number().int().min(0).max(18).meta({
|
|
2630
|
+
title: "Token Decimals",
|
|
2631
|
+
description: "Number of decimal places for the ERC20 token",
|
|
2632
|
+
examples: [18]
|
|
2633
|
+
}),
|
|
2634
|
+
image: IpfsUriSchema.meta({
|
|
2635
|
+
title: "Token Image",
|
|
2636
|
+
description: "IPFS URI pointing to the token's visual representation image",
|
|
2637
|
+
examples: ["ipfs://QmTokenImageHash/credit-icon.png"]
|
|
2638
|
+
}),
|
|
2639
|
+
description: z.string().min(50).max(1e3).meta({
|
|
2640
|
+
title: "Token Description",
|
|
2641
|
+
description: "Comprehensive description of the credit token, its purpose, and impact",
|
|
2642
|
+
examples: [
|
|
2643
|
+
"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."
|
|
2644
|
+
]
|
|
2645
|
+
})
|
|
2646
|
+
}).meta(CreditSchemaMeta);
|
|
2647
|
+
var MethodologyDataSchema = z.strictObject({
|
|
2648
|
+
name: MethodologyNameSchema.meta({
|
|
2649
|
+
title: "Methodology Name",
|
|
2650
|
+
description: "Full official name of the methodology"
|
|
2651
|
+
}),
|
|
2652
|
+
short_name: NonEmptyStringSchema.max(50).meta({
|
|
2653
|
+
title: "Methodology Short Name",
|
|
2654
|
+
description: "Abbreviated name for UI display and references",
|
|
2655
|
+
examples: ["BOLD Carbon", "BOLD Recycling"]
|
|
2656
|
+
}),
|
|
2657
|
+
slug: SlugSchema.meta({
|
|
2658
|
+
title: "Methodology Slug",
|
|
2659
|
+
description: "URL-friendly identifier for the methodology",
|
|
2660
|
+
examples: ["bold-carbon-ch4", "bold-recycling"]
|
|
2661
|
+
}),
|
|
2662
|
+
version: SemanticVersionSchema.meta({
|
|
2663
|
+
title: "Methodology Version",
|
|
2664
|
+
description: "Version of the methodology"
|
|
2665
|
+
}),
|
|
2666
|
+
description: z.string().min(50).max(2e3).meta({
|
|
2667
|
+
title: "Methodology Description",
|
|
2668
|
+
description: "Comprehensive methodology description including purpose, scope, and implementation approach"
|
|
2669
|
+
}),
|
|
2670
|
+
revision_date: IsoDateSchema.meta({
|
|
2671
|
+
title: "Revision Date",
|
|
2672
|
+
description: "ISO 8601 date of the last revision to this methodology"
|
|
2673
|
+
}),
|
|
2674
|
+
publication_date: IsoDateSchema.meta({
|
|
2675
|
+
title: "Publication Date",
|
|
2676
|
+
description: "ISO 8601 date of the original publication of this methodology"
|
|
2677
|
+
}),
|
|
2678
|
+
methodology_pdf: IpfsUriSchema.meta({
|
|
2679
|
+
title: "Methodology PDF",
|
|
2680
|
+
description: "IPFS URI pointing to the complete methodology PDF document"
|
|
2681
|
+
}),
|
|
2682
|
+
mass_id_audit_rules: AuditRuleDefinitionsSchema.meta({
|
|
2683
|
+
title: "MassID Audit Rules",
|
|
2684
|
+
description: "Audit rules that must be executed to check MassID compliance with the methodology"
|
|
2685
|
+
})
|
|
2686
|
+
}).meta({
|
|
2687
|
+
title: "Methodology Data",
|
|
2688
|
+
description: "Methodology-specific data including audit rules"
|
|
2689
|
+
});
|
|
2690
|
+
|
|
2691
|
+
// src/methodology/methodology.schema.ts
|
|
2692
|
+
var MethodologySchemaMeta = {
|
|
2693
|
+
title: "Methodology IPFS Record",
|
|
2694
|
+
description: "Methodology metadata stored in IPFS, extending the base schema with methodology data and audit rules",
|
|
2695
|
+
$id: buildSchemaUrl("methodology/methodology.schema.json"),
|
|
2696
|
+
version: getSchemaVersionOrDefault()
|
|
2697
|
+
};
|
|
2698
|
+
var MethodologySchema = BaseIpfsSchema.safeExtend({
|
|
2699
|
+
schema: BaseIpfsSchema.shape.schema.safeExtend({
|
|
2700
|
+
type: z.literal("Methodology").meta({
|
|
2701
|
+
title: "Methodology Schema Type",
|
|
2702
|
+
description: "Methodology schema type"
|
|
2703
|
+
})
|
|
2704
|
+
}),
|
|
2705
|
+
data: MethodologyDataSchema
|
|
2706
|
+
}).meta(MethodologySchemaMeta);
|
|
2707
|
+
var MassIDAuditSummarySchema = z.strictObject({
|
|
2708
|
+
audit_date: IsoDateSchema.meta({
|
|
2709
|
+
title: "Audit Date",
|
|
2710
|
+
description: "Date when the audit was completed"
|
|
2711
|
+
}),
|
|
2712
|
+
methodology_compliance: MethodologyComplianceSchema.meta({
|
|
2713
|
+
title: "Methodology Compliance",
|
|
2714
|
+
description: "Overall outcome of the audit process"
|
|
2715
|
+
}),
|
|
2716
|
+
total_rules_executed: NonNegativeIntegerSchema.meta({
|
|
2717
|
+
title: "Total Rules Executed",
|
|
2718
|
+
description: "Total number of audit rules executed"
|
|
2719
|
+
}),
|
|
2720
|
+
passed_rules: NonNegativeIntegerSchema.meta({
|
|
2721
|
+
title: "Passed Rules Count",
|
|
2722
|
+
description: "Number of rules that passed verification"
|
|
2723
|
+
}),
|
|
2724
|
+
failed_rules: NonNegativeIntegerSchema.meta({
|
|
2725
|
+
title: "Failed Rules Count",
|
|
2726
|
+
description: "Number of rules that failed verification"
|
|
2727
|
+
})
|
|
2728
|
+
}).meta({
|
|
2729
|
+
title: "Audit Summary",
|
|
2730
|
+
description: "Summary of audit execution results"
|
|
2731
|
+
});
|
|
2732
|
+
var MassIDAuditDataSchema = z.strictObject({
|
|
2733
|
+
methodology: MethodologyReferenceSchema,
|
|
2734
|
+
mass_id: MassIDReferenceSchema,
|
|
2735
|
+
gas_id: GasIDReferenceSchema,
|
|
2736
|
+
audit_summary: MassIDAuditSummarySchema,
|
|
2737
|
+
rules_execution_results: AuditRuleExecutionResultsSchema
|
|
2738
|
+
}).meta({
|
|
2739
|
+
title: "MassID Audit Data",
|
|
2740
|
+
description: "Complete data structure for MassID Audit records"
|
|
2741
|
+
});
|
|
2742
|
+
|
|
2743
|
+
// src/mass-id-audit/mass-id-audit.schema.ts
|
|
2744
|
+
var MassIDAuditSchemaMeta = {
|
|
2745
|
+
title: "MassID Audit IPFS Record",
|
|
2746
|
+
description: "MassID audit metadata stored in IPFS, extending the base schema with audit results and references",
|
|
2747
|
+
$id: buildSchemaUrl("mass-id-audit/mass-id-audit.schema.json"),
|
|
2748
|
+
version: getSchemaVersionOrDefault()
|
|
2749
|
+
};
|
|
2750
|
+
var MassIDAuditSchema = BaseIpfsSchema.safeExtend({
|
|
2751
|
+
schema: BaseIpfsSchema.shape.schema.safeExtend({
|
|
2752
|
+
type: z.literal("MassID Audit").meta({
|
|
2753
|
+
title: "MassID Audit Schema Type",
|
|
2754
|
+
description: "MassID Audit schema type"
|
|
2755
|
+
})
|
|
2756
|
+
}),
|
|
2757
|
+
data: MassIDAuditDataSchema
|
|
2758
|
+
}).meta(MassIDAuditSchemaMeta);
|
|
1694
2759
|
|
|
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 };
|
|
2760
|
+
export { AccreditedParticipantSchema, AccreditedParticipantsSchema, AdministrativeDivisionSchema, AuditReferenceSchema, AuditRuleDefinitionSchema, AuditRuleDefinitionsSchema, AuditRuleExecutionResultSchema, AuditRuleExecutionResultsSchema, BaseIpfsSchema, BlockchainChainIdSchema, BlockchainNetworkNameSchema, CollectionNameSchema, CollectionSchema, CollectionSchemaMeta, CollectionSlugSchema, CoordinatesSchema, CountryNameSchema, CreditAmountAttributeSchema, CreditAmountSchema, CreditPurchaseReceiptAttributesSchema, CreditPurchaseReceiptDataSchema, CreditPurchaseReceiptIpfsSchema, CreditPurchaseReceiptIpfsSchemaMeta, CreditSchema, CreditSchemaMeta, CreditTypeAttributeSchema, CreditTypeSchema, DistributionNotesSchema, 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, MethodologyAttributeSchema, MethodologyComplianceSchema, MethodologyDataSchema, MethodologyNameSchema, MethodologyReferenceSchema, MethodologySchema, MethodologySchemaMeta, 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, SmartContractAddressSchema, SmartContractSchema, SourceWasteTypeAttributeSchema, SourceWeightAttributeSchema, StringifiedTokenIdSchema, TokenIdSchema, TokenSymbolSchema, UnixTimestampSchema, UuidSchema, WasteClassificationSchema, WasteSubtypeSchema, WasteTypeSchema, WeightKgSchema, buildSchemaUrl, getSchemaBaseUrl, getSchemaVersionOrDefault, uniqueArrayItems, uniqueBy };
|
|
1696
2761
|
//# sourceMappingURL=index.js.map
|
|
1697
2762
|
//# sourceMappingURL=index.js.map
|