@carrot-foundation/schemas 0.1.40 → 0.1.41
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 +101 -152
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +205 -378
- package/dist/index.d.ts +205 -378
- package/dist/index.js +102 -151
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/schemas/ipfs/collection/collection.example.json +3 -7
- package/schemas/ipfs/collection/collection.schema.json +17 -130
- package/schemas/ipfs/credit/credit.example.json +3 -7
- package/schemas/ipfs/credit/credit.schema.json +17 -130
- package/schemas/ipfs/credit-purchase-receipt/credit-purchase-receipt.example.json +3 -7
- package/schemas/ipfs/credit-purchase-receipt/credit-purchase-receipt.schema.json +135 -225
- package/schemas/ipfs/credit-retirement-receipt/credit-retirement-receipt.example.json +3 -7
- package/schemas/ipfs/credit-retirement-receipt/credit-retirement-receipt.schema.json +134 -221
- package/schemas/ipfs/gas-id/gas-id.example.json +3 -7
- package/schemas/ipfs/gas-id/gas-id.schema.json +62 -188
- package/schemas/ipfs/mass-id/mass-id.example.json +4 -4
- package/schemas/ipfs/mass-id/mass-id.schema.json +74 -219
- package/schemas/ipfs/mass-id-audit/mass-id-audit.example.json +3 -7
- package/schemas/ipfs/mass-id-audit/mass-id-audit.schema.json +28 -150
- package/schemas/ipfs/methodology/methodology.example.json +3 -28
- package/schemas/ipfs/methodology/methodology.schema.json +20 -145
- package/schemas/ipfs/recycled-id/recycled-id.example.json +4 -8
- package/schemas/ipfs/recycled-id/recycled-id.schema.json +61 -185
package/dist/index.cjs
CHANGED
|
@@ -5,14 +5,12 @@ require('fs');
|
|
|
5
5
|
require('path');
|
|
6
6
|
|
|
7
7
|
// src/mass-id/mass-id.attributes.ts
|
|
8
|
-
var
|
|
9
|
-
|
|
8
|
+
var nativeDateParse = Date.parse.bind(Date);
|
|
9
|
+
var ISO_TIMESTAMP_REGEX = /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(?:\.\d{1,3})?(?:Z|[+-]\d{2}:\d{2})$/;
|
|
10
|
+
var UuidSchema = zod.z.uuidv4().meta({
|
|
11
|
+
title: "UUID V4",
|
|
10
12
|
description: "A universally unique identifier version 4",
|
|
11
|
-
examples: [
|
|
12
|
-
"ad44dd3f-f176-4b98-bf78-5ee6e77d0530",
|
|
13
|
-
"6f520d88-864d-432d-bf9f-5c3166c4818f",
|
|
14
|
-
"f77afa89-1c58-40fd-9bf5-8a86703a8af4"
|
|
15
|
-
]
|
|
13
|
+
examples: ["ad44dd3f-f176-4b98-bf78-5ee6e77d0530"]
|
|
16
14
|
});
|
|
17
15
|
var EthereumAddressSchema = zod.z.string().regex(
|
|
18
16
|
/^0x[a-f0-9]{40}$/,
|
|
@@ -20,25 +18,33 @@ var EthereumAddressSchema = zod.z.string().regex(
|
|
|
20
18
|
).meta({
|
|
21
19
|
title: "Ethereum Address",
|
|
22
20
|
description: "A valid Ethereum address in hexadecimal format",
|
|
23
|
-
examples: [
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
21
|
+
examples: ["0x1234567890abcdef1234567890abcdef12345678"]
|
|
22
|
+
});
|
|
23
|
+
var IsoTimestampSchema = zod.z.string().regex(
|
|
24
|
+
ISO_TIMESTAMP_REGEX,
|
|
25
|
+
"Must be a valid ISO 8601 timestamp with timezone information"
|
|
26
|
+
).superRefine((value, ctx) => {
|
|
27
|
+
const parsed = nativeDateParse(value);
|
|
28
|
+
if (Number.isNaN(parsed)) {
|
|
29
|
+
ctx.addIssue({
|
|
30
|
+
code: "custom",
|
|
31
|
+
message: "Must be a valid ISO 8601 timestamp with timezone information"
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
}).meta({
|
|
29
35
|
title: "ISO Timestamp",
|
|
30
36
|
description: "ISO 8601 formatted timestamp with timezone information",
|
|
31
|
-
examples: ["2024-12-05T11:02:47.000Z"
|
|
37
|
+
examples: ["2024-12-05T11:02:47.000Z"]
|
|
32
38
|
});
|
|
33
39
|
var IsoDateSchema = zod.z.iso.date("Must be a valid ISO 8601 date (YYYY-MM-DD)").meta({
|
|
34
40
|
title: "ISO Date",
|
|
35
41
|
description: "ISO 8601 formatted date in YYYY-MM-DD format",
|
|
36
|
-
examples: ["2024-12-05"
|
|
42
|
+
examples: ["2024-12-05"]
|
|
37
43
|
});
|
|
38
44
|
var UnixTimestampSchema = zod.z.number().int().positive().meta({
|
|
39
45
|
title: "Unix Timestamp",
|
|
40
46
|
description: "Unix timestamp in milliseconds since epoch (January 1, 1970 00:00:00 UTC)",
|
|
41
|
-
examples: [17040672e5
|
|
47
|
+
examples: [17040672e5]
|
|
42
48
|
});
|
|
43
49
|
var IsoCountryCodeSchema = zod.z.string().regex(/^[A-Z]{2}$/, "Must be a valid ISO 3166-1 alpha-2 country code").meta({
|
|
44
50
|
title: "ISO Country Code",
|
|
@@ -55,15 +61,20 @@ var IsoAdministrativeDivisionCodeSchema = zod.z.string().regex(
|
|
|
55
61
|
});
|
|
56
62
|
var LatitudeSchema = zod.z.number().min(-90).max(90).multipleOf(1e-3).meta({
|
|
57
63
|
title: "Latitude",
|
|
58
|
-
description: "Geographic latitude coordinate in decimal degrees with maximum 3 decimal places precision (~100m-1km accuracy for city-level
|
|
64
|
+
description: "Geographic latitude coordinate in decimal degrees with maximum 3 decimal places precision (~100m-1km accuracy for city-level)",
|
|
59
65
|
examples: [-0.02, -20.38, 40.713]
|
|
60
66
|
});
|
|
61
67
|
var LongitudeSchema = zod.z.number().min(-180).max(180).multipleOf(1e-3).meta({
|
|
62
68
|
title: "Longitude",
|
|
63
|
-
description: "Geographic longitude coordinate in decimal degrees with maximum 3 decimal places precision (~100m-1km accuracy for city-level
|
|
69
|
+
description: "Geographic longitude coordinate in decimal degrees with maximum 3 decimal places precision (~100m-1km accuracy for city-level)",
|
|
64
70
|
examples: [-51.06, -40.34, -74.006]
|
|
65
71
|
});
|
|
66
|
-
var
|
|
72
|
+
var NonNegativeFloatSchema = zod.z.number().min(0).meta({
|
|
73
|
+
title: "Non-Negative Float",
|
|
74
|
+
description: "Floating-point number that is zero or positive",
|
|
75
|
+
examples: [0, 45.2, 72.5]
|
|
76
|
+
});
|
|
77
|
+
var WeightKgSchema = NonNegativeFloatSchema.meta({
|
|
67
78
|
title: "Weight (kg)",
|
|
68
79
|
description: "Weight measurement in kilograms",
|
|
69
80
|
examples: [3e3, 1500, 500]
|
|
@@ -127,7 +138,7 @@ var WasteTypeSchema = NonEmptyStringSchema.max(100).meta({
|
|
|
127
138
|
var WasteSubtypeSchema = NonEmptyStringSchema.max(100).meta({
|
|
128
139
|
title: "Waste Subtype",
|
|
129
140
|
description: "Specific subcategory of waste within a waste type",
|
|
130
|
-
examples: ["Food, Food Waste and Beverages", "
|
|
141
|
+
examples: ["Food, Food Waste and Beverages", "Domestic Sludge"]
|
|
131
142
|
});
|
|
132
143
|
var ParticipantRoleSchema = NonEmptyStringSchema.max(100).meta({
|
|
133
144
|
title: "Participant Role",
|
|
@@ -139,14 +150,14 @@ var ParticipantNameSchema = NonEmptyStringSchema.max(100).meta({
|
|
|
139
150
|
description: "Name of a participant in the waste management system",
|
|
140
151
|
examples: ["Enlatados Produ\xE7\xE3o", "Eco Reciclagem", "Green Tech Corp"]
|
|
141
152
|
});
|
|
142
|
-
var BlockchainChainIdSchema = zod.z.
|
|
153
|
+
var BlockchainChainIdSchema = zod.z.union([zod.z.literal(137), zod.z.literal(80002)]).meta({
|
|
143
154
|
title: "Chain ID",
|
|
144
|
-
description: "
|
|
155
|
+
description: "Supported Polygon chain identifiers",
|
|
145
156
|
examples: [137, 80002]
|
|
146
157
|
});
|
|
147
|
-
var BlockchainNetworkNameSchema =
|
|
158
|
+
var BlockchainNetworkNameSchema = zod.z.enum(["Polygon", "Amoy"]).meta({
|
|
148
159
|
title: "Blockchain Network Name",
|
|
149
|
-
description: "
|
|
160
|
+
description: "Supported Polygon network names",
|
|
150
161
|
examples: ["Polygon", "Amoy"]
|
|
151
162
|
});
|
|
152
163
|
var SmartContractAddressSchema = EthereumAddressSchema.meta({
|
|
@@ -161,7 +172,7 @@ var SmartContractSchema = zod.z.strictObject({
|
|
|
161
172
|
title: "Smart Contract",
|
|
162
173
|
description: "Smart contract details for on-chain references"
|
|
163
174
|
});
|
|
164
|
-
var PercentageSchema =
|
|
175
|
+
var PercentageSchema = NonNegativeFloatSchema.max(100).meta({
|
|
165
176
|
title: "Percentage",
|
|
166
177
|
description: "Percentage value between 0 and 100",
|
|
167
178
|
examples: [50, 75.5, 100]
|
|
@@ -176,11 +187,6 @@ var PositiveIntegerSchema = zod.z.number().int().min(1).meta({
|
|
|
176
187
|
description: "Integer value that is greater than zero",
|
|
177
188
|
examples: [1, 123, 456]
|
|
178
189
|
});
|
|
179
|
-
var NonNegativeFloatSchema = zod.z.number().min(0).meta({
|
|
180
|
-
title: "Non-Negative Float",
|
|
181
|
-
description: "Floating-point number that is zero or positive",
|
|
182
|
-
examples: [0, 45.2, 72.5]
|
|
183
|
-
});
|
|
184
190
|
var CreditTypeSchema = NonEmptyStringSchema.max(100).meta({
|
|
185
191
|
title: "Credit Type",
|
|
186
192
|
description: "Type of credit issued",
|
|
@@ -195,7 +201,7 @@ var HoursSchema = zod.z.number().min(0).multipleOf(0.1).meta({
|
|
|
195
201
|
description: "Time duration in hours with 0.1 hour precision",
|
|
196
202
|
examples: [72.5, 24, 168.5]
|
|
197
203
|
});
|
|
198
|
-
var MinutesSchema =
|
|
204
|
+
var MinutesSchema = NonNegativeIntegerSchema.meta({
|
|
199
205
|
title: "Minutes",
|
|
200
206
|
description: "Time duration in minutes",
|
|
201
207
|
examples: [4350, 1440, 10110]
|
|
@@ -225,7 +231,7 @@ var TokenIdSchema = NonEmptyStringSchema.regex(
|
|
|
225
231
|
).meta({
|
|
226
232
|
title: "Token ID",
|
|
227
233
|
description: "Numeric identifier for blockchain tokens as string",
|
|
228
|
-
examples: ["
|
|
234
|
+
examples: ["456789", "1000000"]
|
|
229
235
|
});
|
|
230
236
|
var HexColorSchema = NonEmptyStringSchema.regex(
|
|
231
237
|
/^#[0-9A-F]{6}$/,
|
|
@@ -233,41 +239,28 @@ var HexColorSchema = NonEmptyStringSchema.regex(
|
|
|
233
239
|
).meta({
|
|
234
240
|
title: "Hex Color",
|
|
235
241
|
description: "Hexadecimal color code with hash prefix",
|
|
236
|
-
examples: ["#2D5A27", "#FF5733"
|
|
242
|
+
examples: ["#2D5A27", "#FF5733"]
|
|
237
243
|
});
|
|
238
244
|
var Sha256HashSchema = zod.z.hash("sha256", {
|
|
239
|
-
error: "Must be a
|
|
245
|
+
error: "Must be a SHA-256 hash as 32-byte hex string"
|
|
240
246
|
}).meta({
|
|
241
247
|
format: void 0,
|
|
242
|
-
title: "
|
|
248
|
+
title: "SHA-256 Hash",
|
|
243
249
|
description: "SHA-256 cryptographic hash as hexadecimal string",
|
|
244
250
|
examples: [
|
|
245
|
-
"87f633634cc4b02f628685651f0a29b7bfa22a0bd841f725c6772dd00a58d489"
|
|
246
|
-
"6e83b8e6373847bbdc056549bedda38dc88854ce41ba4fca11e0fc6ce3e07ef6"
|
|
247
|
-
]
|
|
248
|
-
});
|
|
249
|
-
var Keccak256HashSchema = Sha256HashSchema.meta({
|
|
250
|
-
title: "Keccak256 Hash",
|
|
251
|
-
description: "Keccak256 cryptographic hash as hexadecimal string",
|
|
252
|
-
examples: [
|
|
253
|
-
"ac08c3cf2e175e55961d6affdb38bc24591b84ceef7f3707c69ae3d52c148b2f",
|
|
254
|
-
"b1c2d3e4f5a6b7c8d9e0f1a2b3c4d5e6f7a8b9c0d1e2f3a4b5c6d7e8f9a0b1c2"
|
|
251
|
+
"87f633634cc4b02f628685651f0a29b7bfa22a0bd841f725c6772dd00a58d489"
|
|
255
252
|
]
|
|
256
253
|
});
|
|
257
254
|
var ExternalIdSchema = UuidSchema.meta({
|
|
258
255
|
title: "External ID",
|
|
259
|
-
description: "UUID identifier for external system references"
|
|
260
|
-
examples: [
|
|
261
|
-
"ad44dd3f-f176-4b98-bf78-5ee6e77d0530",
|
|
262
|
-
"b2c4e6f8-a1b3-4c5d-9e8f-123456789abc"
|
|
263
|
-
]
|
|
256
|
+
description: "UUID identifier for external system references"
|
|
264
257
|
});
|
|
265
|
-
var ExternalUrlSchema = zod.z.url(
|
|
258
|
+
var ExternalUrlSchema = zod.z.url().meta({
|
|
266
259
|
title: "External URL",
|
|
267
|
-
description: "
|
|
260
|
+
description: "URL pointing to external resources",
|
|
268
261
|
examples: [
|
|
269
|
-
"https://explore.carrot.eco/
|
|
270
|
-
"https://carrot.eco/
|
|
262
|
+
"https://explore.carrot.eco/",
|
|
263
|
+
"https://https://whitepaper.carrot.eco/"
|
|
271
264
|
]
|
|
272
265
|
});
|
|
273
266
|
var RecordSchemaTypeSchema = zod.z.enum([
|
|
@@ -298,21 +291,6 @@ var CreditTokenSymbolSchema = TokenSymbolSchema.meta({
|
|
|
298
291
|
description: "Symbol of the credit token (e.g., C-CARB, C-BIOW)",
|
|
299
292
|
examples: ["C-CARB", "C-BIOW"]
|
|
300
293
|
});
|
|
301
|
-
var RecordRelationshipTypeSchema = zod.z.enum([
|
|
302
|
-
"collection",
|
|
303
|
-
"credit",
|
|
304
|
-
"gas-id",
|
|
305
|
-
"mass-id",
|
|
306
|
-
"mass-id-audit",
|
|
307
|
-
"methodology",
|
|
308
|
-
"credit-purchase-receipt",
|
|
309
|
-
"credit-retirement-receipt",
|
|
310
|
-
"recycled-id"
|
|
311
|
-
]).meta({
|
|
312
|
-
title: "Relationship Type",
|
|
313
|
-
description: "Type of relationship between different entities in the system",
|
|
314
|
-
examples: ["mass-id", "collection", "credit-purchase-receipt"]
|
|
315
|
-
});
|
|
316
294
|
function uniqueArrayItems(schema, errorMessage = "Array items must be unique") {
|
|
317
295
|
return zod.z.array(schema).refine((items) => new Set(items).size === items.length, {
|
|
318
296
|
message: errorMessage
|
|
@@ -351,10 +329,10 @@ var ParticipantSchema = zod.z.strictObject({
|
|
|
351
329
|
title: "Participant",
|
|
352
330
|
description: "A participant in the waste management supply chain"
|
|
353
331
|
});
|
|
354
|
-
var PrecisionLevelSchema = zod.z.enum(["
|
|
332
|
+
var PrecisionLevelSchema = zod.z.enum(["city", "region", "country"]).meta({
|
|
355
333
|
title: "Coordinate Precision Level",
|
|
356
334
|
description: "Level of coordinate precision",
|
|
357
|
-
examples: ["city"
|
|
335
|
+
examples: ["city"]
|
|
358
336
|
});
|
|
359
337
|
var CoordinatesSchema = zod.z.strictObject({
|
|
360
338
|
latitude: LatitudeSchema,
|
|
@@ -596,70 +574,20 @@ var ParticipantRewardsSchema = zod.z.strictObject({
|
|
|
596
574
|
title: "Participant Rewards",
|
|
597
575
|
description: "Rewards distribution to participants"
|
|
598
576
|
});
|
|
599
|
-
var SchemaHashSchema =
|
|
600
|
-
Keccak256HashSchema,
|
|
601
|
-
zod.z.string().regex(
|
|
602
|
-
/^0x[a-fA-F0-9]{64}$/,
|
|
603
|
-
"Must be a Keccak256 hash as 0x-prefixed hex string"
|
|
604
|
-
)
|
|
605
|
-
]).meta({
|
|
577
|
+
var SchemaHashSchema = Sha256HashSchema.meta({
|
|
606
578
|
title: "Schema Hash",
|
|
607
|
-
description: "
|
|
608
|
-
examples: [
|
|
609
|
-
"ac08c3cf2e175e55961d6affdb38bc24591b84ceef7f3707c69ae3d52c148b2f",
|
|
610
|
-
"0xac08c3cf2e175e55961d6affdb38bc24591b84ceef7f3707c69ae3d52c148b2f"
|
|
611
|
-
]
|
|
579
|
+
description: "SHA-256 hash of the JSON Schema this record was validated against"
|
|
612
580
|
});
|
|
613
581
|
var SchemaInfoSchema = zod.z.strictObject({
|
|
614
582
|
hash: SchemaHashSchema,
|
|
615
|
-
type: RecordSchemaTypeSchema
|
|
616
|
-
title: "Schema Type",
|
|
617
|
-
description: "Type/category of this schema"
|
|
618
|
-
}),
|
|
583
|
+
type: RecordSchemaTypeSchema,
|
|
619
584
|
version: SemanticVersionSchema.meta({
|
|
620
585
|
title: "Schema Version",
|
|
621
586
|
description: "Version of the schema, using semantic versioning"
|
|
622
587
|
})
|
|
623
588
|
}).meta({
|
|
624
|
-
title: "Schema Information"
|
|
625
|
-
|
|
626
|
-
var RecordCreatorSchema = zod.z.strictObject({
|
|
627
|
-
name: zod.z.string().meta({
|
|
628
|
-
title: "Creator Name",
|
|
629
|
-
description: "Company or individual name that created this record",
|
|
630
|
-
examples: ["Carrot Foundation"]
|
|
631
|
-
}),
|
|
632
|
-
id: UuidSchema.meta({
|
|
633
|
-
title: "Creator ID",
|
|
634
|
-
description: "Unique identifier for the creator"
|
|
635
|
-
})
|
|
636
|
-
}).meta({
|
|
637
|
-
title: "Creator",
|
|
638
|
-
description: "Entity that created this record"
|
|
639
|
-
});
|
|
640
|
-
var RecordRelationshipSchema = zod.z.strictObject({
|
|
641
|
-
target_uri: IpfsUriSchema.meta({
|
|
642
|
-
title: "Target IPFS URI",
|
|
643
|
-
description: "Target IPFS URI of the referenced record"
|
|
644
|
-
}),
|
|
645
|
-
type: RecordRelationshipTypeSchema.meta({
|
|
646
|
-
title: "Relationship Type",
|
|
647
|
-
description: "Type of relationship to the referenced record"
|
|
648
|
-
}),
|
|
649
|
-
description: zod.z.string().optional().meta({
|
|
650
|
-
title: "Relationship Description",
|
|
651
|
-
description: "Human-readable description of the relationship",
|
|
652
|
-
examples: [
|
|
653
|
-
"This record supersedes the previous version",
|
|
654
|
-
"Related carbon credit batch",
|
|
655
|
-
"Source document for this verification",
|
|
656
|
-
"Child record derived from this parent",
|
|
657
|
-
"Updated version of original record"
|
|
658
|
-
]
|
|
659
|
-
})
|
|
660
|
-
}).meta({
|
|
661
|
-
title: "Relationship",
|
|
662
|
-
description: "Relationship to another IPFS record"
|
|
589
|
+
title: "Schema Information",
|
|
590
|
+
description: "Information about the schema used to validate this record"
|
|
663
591
|
});
|
|
664
592
|
var RecordEnvironmentSchema = zod.z.strictObject({
|
|
665
593
|
blockchain_network: zod.z.enum(["mainnet", "testnet"]).meta({
|
|
@@ -675,8 +603,8 @@ var RecordEnvironmentSchema = zod.z.strictObject({
|
|
|
675
603
|
description: "Name of the data set for this record"
|
|
676
604
|
})
|
|
677
605
|
}).meta({
|
|
678
|
-
title: "Environment",
|
|
679
|
-
description: "Environment information"
|
|
606
|
+
title: "Record Environment",
|
|
607
|
+
description: "Environment information for the record"
|
|
680
608
|
});
|
|
681
609
|
var BaseIpfsSchema = zod.z.strictObject({
|
|
682
610
|
$schema: zod.z.url("Must be a valid URI").meta({
|
|
@@ -689,14 +617,8 @@ var BaseIpfsSchema = zod.z.strictObject({
|
|
|
689
617
|
title: "Created At",
|
|
690
618
|
description: "ISO 8601 creation timestamp for this record"
|
|
691
619
|
}),
|
|
692
|
-
external_id: ExternalIdSchema
|
|
693
|
-
|
|
694
|
-
description: "Off-chain reference ID (UUID from Carrot backend)"
|
|
695
|
-
}),
|
|
696
|
-
external_url: ExternalUrlSchema.meta({
|
|
697
|
-
title: "External URL",
|
|
698
|
-
description: "External URL of the content"
|
|
699
|
-
}),
|
|
620
|
+
external_id: ExternalIdSchema,
|
|
621
|
+
external_url: ExternalUrlSchema,
|
|
700
622
|
original_content_hash: Sha256HashSchema.meta({
|
|
701
623
|
title: "Original Content Hash",
|
|
702
624
|
description: "SHA-256 hash of the original JSON content including private data before schema validation"
|
|
@@ -705,11 +627,6 @@ var BaseIpfsSchema = zod.z.strictObject({
|
|
|
705
627
|
title: "Content Hash",
|
|
706
628
|
description: "SHA-256 hash of RFC 8785 canonicalized JSON after schema validation"
|
|
707
629
|
}),
|
|
708
|
-
creator: RecordCreatorSchema.optional(),
|
|
709
|
-
relationships: zod.z.array(RecordRelationshipSchema).optional().meta({
|
|
710
|
-
title: "Relationships",
|
|
711
|
-
description: "References to other IPFS records this record relates to"
|
|
712
|
-
}),
|
|
713
630
|
environment: RecordEnvironmentSchema.optional(),
|
|
714
631
|
data: zod.z.record(zod.z.string(), zod.z.unknown()).optional().meta({
|
|
715
632
|
title: "Custom Data",
|
|
@@ -719,6 +636,11 @@ var BaseIpfsSchema = zod.z.strictObject({
|
|
|
719
636
|
title: "Base IPFS Record",
|
|
720
637
|
description: "Base fields for all Carrot IPFS records, providing common structure for any JSON content stored in IPFS"
|
|
721
638
|
});
|
|
639
|
+
var BLOCKCHAIN_NETWORK_CONFIG = {
|
|
640
|
+
mainnet: { chain_id: 137, network_name: "Polygon" },
|
|
641
|
+
testnet: { chain_id: 80002, network_name: "Amoy" }
|
|
642
|
+
};
|
|
643
|
+
var ALLOWED_BLOCKCHAIN_NETWORKS = Object.values(BLOCKCHAIN_NETWORK_CONFIG);
|
|
722
644
|
var NftSchemaTypeSchema = RecordSchemaTypeSchema.extract([
|
|
723
645
|
"MassID",
|
|
724
646
|
"RecycledID",
|
|
@@ -737,14 +659,27 @@ var BlockchainReferenceSchema = zod.z.strictObject({
|
|
|
737
659
|
title: "Chain ID",
|
|
738
660
|
description: "Blockchain chain ID"
|
|
739
661
|
}),
|
|
740
|
-
network_name:
|
|
741
|
-
title: "Network Name",
|
|
742
|
-
description: "Name of the blockchain network"
|
|
743
|
-
}),
|
|
662
|
+
network_name: BlockchainNetworkNameSchema,
|
|
744
663
|
token_id: TokenIdSchema.meta({
|
|
745
664
|
title: "Token ID",
|
|
746
665
|
description: "NFT token ID"
|
|
747
666
|
})
|
|
667
|
+
}).superRefine((value, ctx) => {
|
|
668
|
+
const matchedNetwork = ALLOWED_BLOCKCHAIN_NETWORKS.find(
|
|
669
|
+
(network) => network.chain_id === value.chain_id && network.network_name === value.network_name
|
|
670
|
+
);
|
|
671
|
+
if (!matchedNetwork) {
|
|
672
|
+
ctx.addIssue({
|
|
673
|
+
code: "custom",
|
|
674
|
+
message: "chain_id and network_name must match a supported network: 137/Polygon (mainnet) or 80002/Amoy (testnet)",
|
|
675
|
+
path: ["chain_id"]
|
|
676
|
+
});
|
|
677
|
+
ctx.addIssue({
|
|
678
|
+
code: "custom",
|
|
679
|
+
message: "chain_id and network_name must match a supported network: 137/Polygon (mainnet) or 80002/Amoy (testnet)",
|
|
680
|
+
path: ["network_name"]
|
|
681
|
+
});
|
|
682
|
+
}
|
|
748
683
|
}).meta({
|
|
749
684
|
title: "Blockchain Information",
|
|
750
685
|
description: "Blockchain-specific information for the NFT"
|
|
@@ -889,6 +824,26 @@ var NftIpfsSchema = BaseIpfsSchema.safeExtend({
|
|
|
889
824
|
]
|
|
890
825
|
]
|
|
891
826
|
})
|
|
827
|
+
}).superRefine((value, ctx) => {
|
|
828
|
+
const environmentNetwork = value.environment?.blockchain_network;
|
|
829
|
+
if (!environmentNetwork) {
|
|
830
|
+
return;
|
|
831
|
+
}
|
|
832
|
+
const config = BLOCKCHAIN_NETWORK_CONFIG[environmentNetwork];
|
|
833
|
+
if (value.blockchain.chain_id !== config.chain_id) {
|
|
834
|
+
ctx.addIssue({
|
|
835
|
+
code: "custom",
|
|
836
|
+
message: `blockchain.chain_id must be ${config.chain_id} when environment.blockchain_network is ${environmentNetwork}`,
|
|
837
|
+
path: ["blockchain", "chain_id"]
|
|
838
|
+
});
|
|
839
|
+
}
|
|
840
|
+
if (value.blockchain.network_name !== config.network_name) {
|
|
841
|
+
ctx.addIssue({
|
|
842
|
+
code: "custom",
|
|
843
|
+
message: `blockchain.network_name must be ${config.network_name} when environment.blockchain_network is ${environmentNetwork}`,
|
|
844
|
+
path: ["blockchain", "network_name"]
|
|
845
|
+
});
|
|
846
|
+
}
|
|
892
847
|
}).meta({
|
|
893
848
|
title: "NFT IPFS Record",
|
|
894
849
|
description: "NFT-specific fields for Carrot IPFS records"
|
|
@@ -901,7 +856,7 @@ function buildSchemaUrl(schemaPath) {
|
|
|
901
856
|
return `${getSchemaBaseUrl()}/${cleanPath}`;
|
|
902
857
|
}
|
|
903
858
|
function getSchemaVersionOrDefault() {
|
|
904
|
-
return "0.1.
|
|
859
|
+
return "0.1.41";
|
|
905
860
|
}
|
|
906
861
|
var MethodologyAttributeSchema = NftAttributeSchema.safeExtend({
|
|
907
862
|
trait_type: zod.z.literal("Methodology"),
|
|
@@ -1019,10 +974,6 @@ var AuditRuleDefinitionSchema = zod.z.strictObject({
|
|
|
1019
974
|
"https://github.com/carrot-foundation/methodologies/blob/main/bold-carbon/rules/waste-mass-unique.js"
|
|
1020
975
|
]
|
|
1021
976
|
}),
|
|
1022
|
-
mandatory: zod.z.boolean().meta({
|
|
1023
|
-
title: "Mandatory",
|
|
1024
|
-
description: "Whether this rule is mandatory for methodology compliance"
|
|
1025
|
-
}),
|
|
1026
977
|
execution_order: PositiveIntegerSchema.meta({
|
|
1027
978
|
title: "Rule Execution Order",
|
|
1028
979
|
description: "Sequential order in which this rule must be executed"
|
|
@@ -3560,7 +3511,6 @@ exports.IsoAdministrativeDivisionCodeSchema = IsoAdministrativeDivisionCodeSchem
|
|
|
3560
3511
|
exports.IsoCountryCodeSchema = IsoCountryCodeSchema;
|
|
3561
3512
|
exports.IsoDateSchema = IsoDateSchema;
|
|
3562
3513
|
exports.IsoTimestampSchema = IsoTimestampSchema;
|
|
3563
|
-
exports.Keccak256HashSchema = Keccak256HashSchema;
|
|
3564
3514
|
exports.LatitudeSchema = LatitudeSchema;
|
|
3565
3515
|
exports.LocationSchema = LocationSchema;
|
|
3566
3516
|
exports.LongitudeSchema = LongitudeSchema;
|
|
@@ -3599,7 +3549,6 @@ exports.PercentageSchema = PercentageSchema;
|
|
|
3599
3549
|
exports.PositiveIntegerSchema = PositiveIntegerSchema;
|
|
3600
3550
|
exports.ReceiptIdentitySchema = ReceiptIdentitySchema;
|
|
3601
3551
|
exports.RecordEnvironmentSchema = RecordEnvironmentSchema;
|
|
3602
|
-
exports.RecordRelationshipTypeSchema = RecordRelationshipTypeSchema;
|
|
3603
3552
|
exports.RecordSchemaTypeSchema = RecordSchemaTypeSchema;
|
|
3604
3553
|
exports.RecycledIDAttributesSchema = RecycledIDAttributesSchema;
|
|
3605
3554
|
exports.RecycledIDDataSchema = RecycledIDDataSchema;
|