@codama/spec 1.6.0-rc.1 → 1.6.0-rc.2

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.
@@ -1,3 +1,1907 @@
1
- export { SPEC_VERSION, getEnumeration, getNode, getSpec, getUnion, isChildAttribute } from './chunk-AU77NZTG.browser.mjs';
1
+ // src/api/attribute.ts
2
+ function attribute(name, type, options = {}) {
3
+ return Object.freeze({
4
+ name,
5
+ type,
6
+ ...options.optional ? { optional: true } : {},
7
+ ...options.docs !== void 0 ? { docs: options.docs } : {}
8
+ });
9
+ }
10
+ function optionalAttribute(name, type, options = {}) {
11
+ return attribute(name, type, { ...options, optional: true });
12
+ }
13
+
14
+ // src/api/compounds.ts
15
+ function array(inner) {
16
+ return Object.freeze({ kind: "array", of: inner });
17
+ }
18
+
19
+ // src/api/defineEnumeration.ts
20
+ function variant(name, options = {}) {
21
+ return Object.freeze({
22
+ name,
23
+ ...options.docs !== void 0 ? { docs: options.docs } : {}
24
+ });
25
+ }
26
+ function defineEnumeration(name, options) {
27
+ if (options.variants.length === 0) {
28
+ throw new Error(`defineEnumeration("${name}"): variants must be non-empty`);
29
+ }
30
+ const seen = /* @__PURE__ */ new Set();
31
+ for (const v of options.variants) {
32
+ if (seen.has(v.name)) {
33
+ throw new Error(`defineEnumeration("${name}"): duplicate variant "${v.name}"`);
34
+ }
35
+ seen.add(v.name);
36
+ }
37
+ return Object.freeze({
38
+ name,
39
+ variants: Object.freeze([...options.variants]),
40
+ ...options.docs !== void 0 ? { docs: options.docs } : {}
41
+ });
42
+ }
43
+
44
+ // src/api/defineNode.ts
45
+ function defineNode(kind, options) {
46
+ return Object.freeze({
47
+ kind,
48
+ ...options.docs !== void 0 ? { docs: options.docs } : {},
49
+ attributes: Object.freeze([...options.attributes]),
50
+ examples: Object.freeze([...options.examples ?? []])
51
+ });
52
+ }
53
+
54
+ // src/api/defineUnion.ts
55
+ function defineUnion(name, options) {
56
+ const normalised = options.members.map(normaliseMember);
57
+ return Object.freeze({
58
+ name,
59
+ members: Object.freeze(normalised),
60
+ ...options.docs !== void 0 ? { docs: options.docs } : {}
61
+ });
62
+ }
63
+ function normaliseMember(input) {
64
+ if (typeof input === "string") {
65
+ return Object.freeze({ kind: "node", name: input });
66
+ }
67
+ if (input.kind === "node") return Object.freeze({ kind: "node", name: input.name });
68
+ if (input.kind === "union") return Object.freeze({ kind: "union", name: input.name });
69
+ throw new Error(
70
+ `defineUnion: members must be node kind strings, node(...) or union(...) references; got ${JSON.stringify(input)}`
71
+ );
72
+ }
73
+
74
+ // src/api/primitives.ts
75
+ function string() {
76
+ return Object.freeze({ kind: "string" });
77
+ }
78
+ function stringIdentifier() {
79
+ return Object.freeze({ kind: "string", constraint: "identifier" });
80
+ }
81
+ function stringVersion() {
82
+ return Object.freeze({ kind: "string", constraint: "version" });
83
+ }
84
+ function codamaVersion() {
85
+ return Object.freeze({ kind: "codamaVersion" });
86
+ }
87
+ var integer = (width) => Object.freeze({ kind: "integer", width });
88
+ var u32 = () => integer("u32");
89
+ var u64 = () => integer("u64");
90
+ var i64 = () => integer("i64");
91
+ var float = (width) => Object.freeze({ kind: "float", width });
92
+ var f64 = () => float("f64");
93
+ function boolean() {
94
+ return Object.freeze({ kind: "boolean" });
95
+ }
96
+ function literal(value) {
97
+ return Object.freeze({ kind: "literal", value });
98
+ }
99
+ function literalUnion(...values) {
100
+ if (values.length === 0) {
101
+ throw new Error("literalUnion: at least one value required");
102
+ }
103
+ const seen = /* @__PURE__ */ new Set();
104
+ for (const v of values) {
105
+ if (seen.has(v)) {
106
+ throw new Error(`literalUnion: duplicate value ${JSON.stringify(v)}`);
107
+ }
108
+ seen.add(v);
109
+ }
110
+ return Object.freeze({ kind: "literalUnion", values: Object.freeze([...values]) });
111
+ }
112
+ function enumeration(name) {
113
+ return Object.freeze({ kind: "enumeration", name });
114
+ }
115
+ function node(name) {
116
+ return Object.freeze({ kind: "node", name });
117
+ }
118
+ function union(name) {
119
+ return Object.freeze({ kind: "union", name });
120
+ }
121
+ function nestedTypeNode(name) {
122
+ return Object.freeze({ kind: "nestedTypeNode", name });
123
+ }
124
+
125
+ // src/api/semanticAliases.ts
126
+ function byteSize() {
127
+ return u64();
128
+ }
129
+ function docs() {
130
+ return array(string());
131
+ }
132
+
133
+ // src/api/validate.ts
134
+ function validate(spec) {
135
+ const errors = [];
136
+ const nodeKinds = new Set(spec.nodes.map((n) => n.kind));
137
+ const unionNames = new Set(spec.unions.map((u) => u.name));
138
+ const enumerationNames = new Set(spec.enumerations.map((e) => e.name));
139
+ const wrappers = new Set(spec.nestedTypeNodeWrappers);
140
+ const registrations = /* @__PURE__ */ new Map();
141
+ const record = (name, kind) => {
142
+ const list = registrations.get(name);
143
+ if (list) list.push(kind);
144
+ else registrations.set(name, [kind]);
145
+ };
146
+ for (const n of spec.nodes) record(n.kind, "node");
147
+ for (const u of spec.unions) record(u.name, "union");
148
+ for (const e of spec.enumerations) record(e.name, "enumeration");
149
+ for (const [name, kinds] of registrations) {
150
+ if (kinds.length > 1) errors.push(formatCollisionError(name, kinds));
151
+ }
152
+ for (const n of spec.nodes) {
153
+ if (!/^[a-z][A-Za-z0-9]*Node$/.test(n.kind)) {
154
+ errors.push(`Node kind "${n.kind}" does not match the camelCase ...Node naming convention.`);
155
+ }
156
+ const seenAttrs = /* @__PURE__ */ new Set();
157
+ for (const a of n.attributes) {
158
+ if (seenAttrs.has(a.name)) {
159
+ errors.push(`Node "${n.kind}" declares attribute "${a.name}" more than once.`);
160
+ }
161
+ seenAttrs.add(a.name);
162
+ walkTypeExpr(
163
+ a.type,
164
+ (expr) => checkRef(expr, n.kind, a.name, errors, nodeKinds, unionNames, enumerationNames)
165
+ );
166
+ }
167
+ }
168
+ for (const u of spec.unions) {
169
+ if (u.members.length === 0) {
170
+ errors.push(`Union "${u.name}" has no members.`);
171
+ }
172
+ const seenMembers = /* @__PURE__ */ new Set();
173
+ for (const m of u.members) {
174
+ const key = `${m.kind}:${m.name}`;
175
+ if (seenMembers.has(key)) {
176
+ errors.push(`Union "${u.name}" lists member ${key} more than once.`);
177
+ }
178
+ seenMembers.add(key);
179
+ if (m.kind === "node" && !nodeKinds.has(m.name)) {
180
+ errors.push(`Union "${u.name}" references undefined node "${m.name}".`);
181
+ }
182
+ if (m.kind === "union" && !unionNames.has(m.name)) {
183
+ errors.push(`Union "${u.name}" references undefined union "${m.name}".`);
184
+ }
185
+ }
186
+ }
187
+ for (const wrapper of wrappers) {
188
+ if (!nodeKinds.has(wrapper)) {
189
+ errors.push(`Nested-type-node wrapper "${wrapper}" is not a defined node.`);
190
+ }
191
+ }
192
+ return errors;
193
+ }
194
+ function formatCollisionError(name, kinds) {
195
+ const counts = /* @__PURE__ */ new Map();
196
+ for (const k of kinds) counts.set(k, (counts.get(k) ?? 0) + 1);
197
+ const breakdown = [...counts.entries()].sort((a, b) => a[0].localeCompare(b[0])).map(([k, n]) => `${n} ${k}${n > 1 ? "s" : ""}`).join(", ");
198
+ return `Name "${name}" is registered ${kinds.length} times (${breakdown}); names must be unique across nodes, unions, and enumerations.`;
199
+ }
200
+ function walkTypeExpr(expr, visit) {
201
+ visit(expr);
202
+ if (expr.kind === "array") {
203
+ walkTypeExpr(expr.of, visit);
204
+ } else if (expr.kind === "tuple") {
205
+ for (const item of expr.items) walkTypeExpr(item, visit);
206
+ }
207
+ }
208
+ function checkRef(expr, nodeKind, attrName, errors, nodeKinds, unionNames, enumerationNames) {
209
+ const where = `Node "${nodeKind}", attribute "${attrName}":`;
210
+ switch (expr.kind) {
211
+ case "node":
212
+ if (!nodeKinds.has(expr.name)) {
213
+ errors.push(`${where} references undefined node "${expr.name}".`);
214
+ }
215
+ break;
216
+ case "union":
217
+ if (!unionNames.has(expr.name)) {
218
+ errors.push(`${where} references undefined union "${expr.name}".`);
219
+ }
220
+ break;
221
+ case "enumeration":
222
+ if (!enumerationNames.has(expr.name)) {
223
+ errors.push(`${where} references undefined enumeration "${expr.name}".`);
224
+ }
225
+ break;
226
+ case "nestedTypeNode":
227
+ if (!nodeKinds.has(expr.name)) {
228
+ errors.push(`${where} nestedTypeNode references undefined node "${expr.name}".`);
229
+ }
230
+ break;
231
+ }
232
+ }
233
+ function isChildAttribute(type) {
234
+ switch (type.kind) {
235
+ case "node":
236
+ case "nestedTypeNode":
237
+ case "union":
238
+ return true;
239
+ case "array":
240
+ return isChildAttribute(type.of);
241
+ case "tuple":
242
+ return type.items.some(isChildAttribute);
243
+ default:
244
+ return false;
245
+ }
246
+ }
247
+
248
+ // src/v1/enumerations.ts
249
+ var endianness = defineEnumeration("Endianness", {
250
+ docs: "The byte order of a numeric serialization.",
251
+ variants: [
252
+ variant("be", { docs: "Big-endian: the most significant byte is written first." }),
253
+ variant("le", { docs: "Little-endian: the least significant byte is written first." })
254
+ ]
255
+ });
256
+ var numberFormat = defineEnumeration("NumberFormat", {
257
+ docs: "The wire format of a numeric serialization.",
258
+ variants: [
259
+ variant("f32", { docs: "IEEE-754 32-bit floating point." }),
260
+ variant("f64", { docs: "IEEE-754 64-bit floating point." }),
261
+ variant("i8", { docs: "Signed 8-bit integer." }),
262
+ variant("i16", { docs: "Signed 16-bit integer." }),
263
+ variant("i32", { docs: "Signed 32-bit integer." }),
264
+ variant("i64", { docs: "Signed 64-bit integer." }),
265
+ variant("i128", { docs: "Signed 128-bit integer." }),
266
+ variant("shortU16", {
267
+ docs: "Solana compact-u16 encoding: a variable-length unsigned integer occupying 1 to 3 bytes."
268
+ }),
269
+ variant("u8", { docs: "Unsigned 8-bit integer." }),
270
+ variant("u16", { docs: "Unsigned 16-bit integer." }),
271
+ variant("u32", { docs: "Unsigned 32-bit integer." }),
272
+ variant("u64", { docs: "Unsigned 64-bit integer." }),
273
+ variant("u128", { docs: "Unsigned 128-bit integer." })
274
+ ]
275
+ });
276
+ var bytesEncoding = defineEnumeration("BytesEncoding", {
277
+ docs: "How a string of bytes is encoded for transport.",
278
+ variants: [
279
+ variant("base16", { docs: "Hexadecimal encoding (two characters per byte)." }),
280
+ variant("base58", { docs: "Base58 encoding, the standard for Solana addresses." }),
281
+ variant("base64", { docs: "Base64 encoding (RFC 4648)." }),
282
+ variant("utf8", { docs: "UTF-8 text encoding." })
283
+ ]
284
+ });
285
+ var instructionLifecycle = defineEnumeration("InstructionLifecycle", {
286
+ docs: "The lifecycle stage of an instruction.",
287
+ variants: [
288
+ variant("archived", {
289
+ docs: "No longer included in client SDKs. Retained in the IDL for historical reference only."
290
+ }),
291
+ variant("deprecated", {
292
+ docs: "Still callable but discouraged. Clients should migrate to a replacement instruction."
293
+ }),
294
+ variant("draft", {
295
+ docs: "Work-in-progress. The instruction may change before it stabilises."
296
+ }),
297
+ variant("live", { docs: "Stable and supported for production use." })
298
+ ]
299
+ });
300
+ var defaultValueStrategy = defineEnumeration("DefaultValueStrategy", {
301
+ docs: "How an attribute that carries a default value is exposed in generated APIs.",
302
+ variants: [
303
+ variant("omitted", {
304
+ docs: "The attribute is not exposed as a parameter in the generated API; the default value is always used."
305
+ }),
306
+ variant("optional", {
307
+ docs: "The attribute is exposed as an optional parameter; callers may override the default value."
308
+ })
309
+ ]
310
+ });
311
+ var optionalAccountStrategy = defineEnumeration("OptionalAccountStrategy", {
312
+ docs: "How an absent optional account is represented when serialising an instruction.",
313
+ variants: [
314
+ variant("omitted", {
315
+ docs: "The account slot is left out of the instruction entirely. Subsequent accounts shift up."
316
+ }),
317
+ variant("programId", {
318
+ docs: "The account slot is filled with the program ID as a placeholder, preserving positional indices."
319
+ })
320
+ ]
321
+ });
322
+ var preOffsetStrategy = defineEnumeration("PreOffsetStrategy", {
323
+ docs: "How a pre-offset modifier interprets its offset value before serialising the wrapped type.",
324
+ variants: [
325
+ variant("absolute", {
326
+ docs: "Move the cursor to the absolute byte position given by the offset."
327
+ }),
328
+ variant("padded", {
329
+ docs: "Pad with zero bytes from the current cursor up to the offset bytes ahead."
330
+ }),
331
+ variant("relative", {
332
+ docs: "Advance the cursor by the offset bytes relative to its current position."
333
+ })
334
+ ]
335
+ });
336
+ var postOffsetStrategy = defineEnumeration("PostOffsetStrategy", {
337
+ docs: "How a post-offset modifier interprets its offset value after serialising the wrapped type.",
338
+ variants: [
339
+ variant("absolute", {
340
+ docs: "Move the cursor to the absolute byte position given by the offset."
341
+ }),
342
+ variant("padded", {
343
+ docs: "Pad with zero bytes from the current cursor up to the offset bytes ahead."
344
+ }),
345
+ variant("preOffset", {
346
+ docs: "Restore the cursor to where it was before the wrapped type ran (cancelling its pre-offset)."
347
+ }),
348
+ variant("relative", {
349
+ docs: "Advance the cursor by the offset bytes relative to its current position."
350
+ })
351
+ ]
352
+ });
353
+ var programOrigin = defineEnumeration("ProgramOrigin", {
354
+ docs: "The toolchain that originally generated a program description.",
355
+ variants: [
356
+ variant("anchor", { docs: "The program was originally described by an Anchor IDL." }),
357
+ variant("shank", { docs: "The program was originally described by a Shank IDL." })
358
+ ]
359
+ });
360
+ var ALL_ENUMERATIONS = [
361
+ bytesEncoding,
362
+ defaultValueStrategy,
363
+ endianness,
364
+ instructionLifecycle,
365
+ numberFormat,
366
+ optionalAccountStrategy,
367
+ postOffsetStrategy,
368
+ preOffsetStrategy,
369
+ programOrigin
370
+ ];
371
+
372
+ // src/v1/nestedTypeNodeWrappers.ts
373
+ var NESTED_TYPE_NODE_WRAPPERS = [
374
+ "fixedSizeTypeNode",
375
+ "sizePrefixTypeNode",
376
+ "preOffsetTypeNode",
377
+ "postOffsetTypeNode",
378
+ "sentinelTypeNode",
379
+ "hiddenPrefixTypeNode",
380
+ "hiddenSuffixTypeNode"
381
+ ];
382
+
383
+ // src/v1/nodes/AccountNode.ts
384
+ var accountNode = defineNode("accountNode", {
385
+ docs: "An on-chain account: its name, data structure, optional fixed size, optional PDA, and optional discriminators.",
386
+ attributes: [
387
+ attribute("name", stringIdentifier(), {
388
+ docs: "The name of the account."
389
+ }),
390
+ optionalAttribute("size", byteSize(), {
391
+ docs: "The size of the account in bytes, when the data length is fixed."
392
+ }),
393
+ optionalAttribute("docs", docs(), {
394
+ docs: "Markdown documentation for the account."
395
+ }),
396
+ attribute("data", nestedTypeNode("structTypeNode"), {
397
+ docs: "The struct describing the account data."
398
+ }),
399
+ optionalAttribute("pda", node("pdaLinkNode"), {
400
+ docs: "A link to the PDA the account is derived from, if applicable."
401
+ }),
402
+ optionalAttribute("discriminators", array(union("DiscriminatorNode")), {
403
+ docs: "Discriminators that distinguish this account from others in the program. When multiple are listed, they are combined with a logical AND."
404
+ })
405
+ ]
406
+ });
407
+
408
+ // src/v1/nodes/ConstantNode.ts
409
+ var constantNode = defineNode("constantNode", {
410
+ docs: "A named constant exposed by the program: a typed value associated with a name.",
411
+ attributes: [
412
+ attribute("name", stringIdentifier(), {
413
+ docs: "The name of the constant."
414
+ }),
415
+ optionalAttribute("docs", docs(), {
416
+ docs: "Markdown documentation for the constant."
417
+ }),
418
+ attribute("type", union("TypeNode"), {
419
+ docs: "The type of the constant."
420
+ }),
421
+ attribute("value", union("ValueNode"), {
422
+ docs: "The concrete value of the constant."
423
+ })
424
+ ]
425
+ });
426
+
427
+ // src/v1/nodes/contextualValueNodes/AccountBumpValueNode.ts
428
+ var accountBumpValueNode = defineNode("accountBumpValueNode", {
429
+ docs: "Refers to the bump seed of a named PDA-derived account in the surrounding instruction.",
430
+ attributes: [
431
+ attribute("name", stringIdentifier(), {
432
+ docs: "The name of the account whose bump seed is referenced."
433
+ })
434
+ ]
435
+ });
436
+
437
+ // src/v1/nodes/contextualValueNodes/AccountValueNode.ts
438
+ var accountValueNode = defineNode("accountValueNode", {
439
+ docs: "Refers to a named account in the surrounding instruction.",
440
+ attributes: [
441
+ attribute("name", stringIdentifier(), {
442
+ docs: "The name of the referenced account."
443
+ })
444
+ ]
445
+ });
446
+
447
+ // src/v1/nodes/contextualValueNodes/ArgumentValueNode.ts
448
+ var argumentValueNode = defineNode("argumentValueNode", {
449
+ docs: "Refers to a named argument of the surrounding instruction.",
450
+ attributes: [
451
+ attribute("name", stringIdentifier(), {
452
+ docs: "The name of the referenced argument."
453
+ })
454
+ ]
455
+ });
456
+
457
+ // src/v1/nodes/contextualValueNodes/ConditionalValueNode.ts
458
+ var conditionalValueNode = defineNode("conditionalValueNode", {
459
+ docs: "A branching contextual value. The condition resolves to a value at instruction time; that result selects between `ifTrue` and `ifFalse`.",
460
+ attributes: [
461
+ attribute("condition", union("ConditionalValueCondition"), {
462
+ docs: "The value whose evaluation drives the branch."
463
+ }),
464
+ optionalAttribute("value", union("ValueNode"), {
465
+ docs: "When present, the condition result is compared for equality against this value; otherwise the result is treated as a boolean."
466
+ }),
467
+ optionalAttribute("ifTrue", union("InstructionInputValueNode"), {
468
+ docs: "The value used when the condition resolves truthy (or matches `value`)."
469
+ }),
470
+ optionalAttribute("ifFalse", union("InstructionInputValueNode"), {
471
+ docs: "The value used when the condition resolves falsy (or does not match `value`)."
472
+ })
473
+ ]
474
+ });
475
+
476
+ // src/v1/nodes/contextualValueNodes/ContextualValueNode.ts
477
+ var STANDALONE_CONTEXTUAL_VALUE_NODE_KINDS = [
478
+ "accountBumpValueNode",
479
+ "accountValueNode",
480
+ "argumentValueNode",
481
+ "conditionalValueNode",
482
+ "identityValueNode",
483
+ "payerValueNode",
484
+ "pdaValueNode",
485
+ "programIdValueNode",
486
+ "resolverValueNode"
487
+ ];
488
+ var standaloneContextualValueNodeUnion = defineUnion("StandaloneContextualValueNode", {
489
+ docs: "Every contextual-value node usable as a top-level value.",
490
+ members: [...STANDALONE_CONTEXTUAL_VALUE_NODE_KINDS]
491
+ });
492
+ var contextualValueNodeUnion = defineUnion("ContextualValueNode", {
493
+ docs: "The composable form: any standalone contextual-value node.",
494
+ members: [union("StandaloneContextualValueNode")]
495
+ });
496
+ var registeredContextualValueNodeUnion = defineUnion("RegisteredContextualValueNode", {
497
+ docs: "Every node tagged as a contextual-value node, including helper variants.",
498
+ members: [union("StandaloneContextualValueNode"), "pdaSeedValueNode"]
499
+ });
500
+ var instructionInputValueNodeUnion = defineUnion("InstructionInputValueNode", {
501
+ docs: "Anything that can be used as the input value for an instruction account or argument default \u2014 a value, contextual reference, or program link.",
502
+ members: [union("ContextualValueNode"), "programLinkNode", union("ValueNode")]
503
+ });
504
+ var conditionalValueConditionUnion = defineUnion("ConditionalValueCondition", {
505
+ docs: "The condition forms accepted by a `conditionalValueNode`.",
506
+ members: ["accountValueNode", "argumentValueNode", "resolverValueNode"]
507
+ });
508
+ var resolverDependencyUnion = defineUnion("ResolverDependency", {
509
+ docs: "The dependency forms accepted by a `resolverValueNode`.",
510
+ members: ["accountValueNode", "argumentValueNode"]
511
+ });
512
+ var pdaSeedValueValueUnion = defineUnion("PdaSeedValueValue", {
513
+ docs: "The value forms accepted by a `pdaSeedValueNode`.",
514
+ members: ["accountValueNode", "argumentValueNode", union("ValueNode")]
515
+ });
516
+ var pdaValuePdaUnion = defineUnion("PdaValuePda", {
517
+ docs: "A `pdaValueNode` may reference a PDA either by link or inline.",
518
+ members: ["pdaLinkNode", "pdaNode"]
519
+ });
520
+ var pdaValueProgramIdUnion = defineUnion("PdaValueProgramId", {
521
+ docs: "The program-id forms accepted by a `pdaValueNode`.",
522
+ members: ["accountValueNode", "argumentValueNode"]
523
+ });
524
+
525
+ // src/v1/nodes/contextualValueNodes/IdentityValueNode.ts
526
+ var identityValueNode = defineNode("identityValueNode", {
527
+ docs: "Refers to the wallet identity providing the instruction context.",
528
+ attributes: []
529
+ });
530
+
531
+ // src/v1/nodes/contextualValueNodes/PayerValueNode.ts
532
+ var payerValueNode = defineNode("payerValueNode", {
533
+ docs: "Refers to the wallet paying for the surrounding transaction.",
534
+ attributes: []
535
+ });
536
+
537
+ // src/v1/nodes/contextualValueNodes/PdaSeedValueNode.ts
538
+ var pdaSeedValueNode = defineNode("pdaSeedValueNode", {
539
+ docs: "Pairs a PDA seed name with the value to substitute when deriving the PDA.",
540
+ attributes: [
541
+ attribute("name", stringIdentifier(), {
542
+ docs: "The name of the seed being filled in."
543
+ }),
544
+ attribute("value", union("PdaSeedValueValue"), {
545
+ docs: "The value to substitute for the seed."
546
+ })
547
+ ]
548
+ });
549
+
550
+ // src/v1/nodes/contextualValueNodes/PdaValueNode.ts
551
+ var pdaValueNode = defineNode("pdaValueNode", {
552
+ docs: "Resolves to a PDA derived from a list of seed values.",
553
+ attributes: [
554
+ attribute("pda", union("PdaValuePda"), {
555
+ docs: "The PDA being derived \u2014 either a link to a defined PDA or an inline `pdaNode`."
556
+ }),
557
+ attribute("seeds", array(node("pdaSeedValueNode")), {
558
+ docs: "The seed values used to derive the PDA, paired with their seed names."
559
+ }),
560
+ optionalAttribute("programId", union("PdaValueProgramId"), {
561
+ docs: "The program ID used to derive the PDA. When omitted, the PDA\u2019s declared program is used."
562
+ })
563
+ ]
564
+ });
565
+
566
+ // src/v1/nodes/contextualValueNodes/ProgramIdValueNode.ts
567
+ var programIdValueNode = defineNode("programIdValueNode", {
568
+ docs: "Refers to the program ID of the surrounding instruction.",
569
+ attributes: []
570
+ });
571
+
572
+ // src/v1/nodes/contextualValueNodes/ResolverValueNode.ts
573
+ var resolverValueNode = defineNode("resolverValueNode", {
574
+ docs: "A custom resolver: a named function provided by the consumer that produces a value, optionally depending on other accounts and arguments.",
575
+ attributes: [
576
+ attribute("name", stringIdentifier(), {
577
+ docs: "The name of the resolver function."
578
+ }),
579
+ optionalAttribute("docs", docs(), {
580
+ docs: "Markdown documentation for the resolver."
581
+ }),
582
+ optionalAttribute("dependsOn", array(union("ResolverDependency")), {
583
+ docs: "The accounts and arguments the resolver depends on. Used by clients to ensure the dependencies are resolved first."
584
+ })
585
+ ]
586
+ });
587
+
588
+ // src/v1/nodes/contextualValueNodes/index.ts
589
+ var ALL_CONTEXTUAL_VALUE_NODES = [
590
+ accountBumpValueNode,
591
+ accountValueNode,
592
+ argumentValueNode,
593
+ conditionalValueNode,
594
+ identityValueNode,
595
+ payerValueNode,
596
+ pdaSeedValueNode,
597
+ pdaValueNode,
598
+ programIdValueNode,
599
+ resolverValueNode
600
+ ];
601
+ var ALL_CONTEXTUAL_VALUE_NODE_UNIONS = [
602
+ standaloneContextualValueNodeUnion,
603
+ contextualValueNodeUnion,
604
+ registeredContextualValueNodeUnion,
605
+ instructionInputValueNodeUnion,
606
+ conditionalValueConditionUnion,
607
+ resolverDependencyUnion,
608
+ pdaSeedValueValueUnion,
609
+ pdaValuePdaUnion,
610
+ pdaValueProgramIdUnion
611
+ ];
612
+
613
+ // src/v1/nodes/countNodes/CountNode.ts
614
+ var registeredCountNodeUnion = defineUnion("RegisteredCountNode", {
615
+ docs: "Every node tagged as a count strategy.",
616
+ members: ["fixedCountNode", "prefixedCountNode", "remainderCountNode"]
617
+ });
618
+ var countNodeUnion = defineUnion("CountNode", {
619
+ docs: "The composable form: any registered count node.",
620
+ members: [union("RegisteredCountNode")]
621
+ });
622
+
623
+ // src/v1/nodes/countNodes/FixedCountNode.ts
624
+ var fixedCountNode = defineNode("fixedCountNode", {
625
+ docs: "A count strategy that fixes the number of items at a constant value.",
626
+ attributes: [
627
+ attribute("value", u64(), {
628
+ docs: "The fixed number of items."
629
+ })
630
+ ]
631
+ });
632
+
633
+ // src/v1/nodes/countNodes/PrefixedCountNode.ts
634
+ var prefixedCountNode = defineNode("prefixedCountNode", {
635
+ docs: "A count strategy where the number of items is read from a numeric prefix.",
636
+ attributes: [
637
+ attribute("prefix", nestedTypeNode("numberTypeNode"), {
638
+ docs: "The numeric type used as the count prefix."
639
+ })
640
+ ]
641
+ });
642
+
643
+ // src/v1/nodes/countNodes/RemainderCountNode.ts
644
+ var remainderCountNode = defineNode("remainderCountNode", {
645
+ docs: "A count strategy where items are read until the buffer is exhausted.",
646
+ attributes: []
647
+ });
648
+
649
+ // src/v1/nodes/countNodes/index.ts
650
+ var ALL_COUNT_NODES = [fixedCountNode, prefixedCountNode, remainderCountNode];
651
+ var ALL_COUNT_NODE_UNIONS = [registeredCountNodeUnion, countNodeUnion];
652
+
653
+ // src/v1/nodes/DefinedTypeNode.ts
654
+ var definedTypeNode = defineNode("definedTypeNode", {
655
+ docs: "A reusable named type that can be referenced by `definedTypeLinkNode` from elsewhere in the IDL.",
656
+ attributes: [
657
+ attribute("name", stringIdentifier(), {
658
+ docs: "The name of the defined type."
659
+ }),
660
+ optionalAttribute("docs", docs(), {
661
+ docs: "Markdown documentation for the type."
662
+ }),
663
+ attribute("type", union("TypeNode"), {
664
+ docs: "The type definition."
665
+ })
666
+ ]
667
+ });
668
+
669
+ // src/v1/nodes/discriminatorNodes/ConstantDiscriminatorNode.ts
670
+ var constantDiscriminatorNode = defineNode("constantDiscriminatorNode", {
671
+ docs: "Identifies a node by a constant value at a known byte offset (e.g. a magic header).",
672
+ attributes: [
673
+ attribute("offset", u64(), {
674
+ docs: "The byte offset at which the constant begins."
675
+ }),
676
+ attribute("constant", node("constantValueNode"), {
677
+ docs: "The constant value expected at the offset."
678
+ })
679
+ ]
680
+ });
681
+
682
+ // src/v1/nodes/discriminatorNodes/DiscriminatorNode.ts
683
+ var registeredDiscriminatorNodeUnion = defineUnion("RegisteredDiscriminatorNode", {
684
+ docs: "Every node tagged as a discriminator strategy.",
685
+ members: ["constantDiscriminatorNode", "fieldDiscriminatorNode", "sizeDiscriminatorNode"]
686
+ });
687
+ var discriminatorNodeUnion = defineUnion("DiscriminatorNode", {
688
+ docs: "The composable form: any registered discriminator node.",
689
+ members: [union("RegisteredDiscriminatorNode")]
690
+ });
691
+
692
+ // src/v1/nodes/discriminatorNodes/FieldDiscriminatorNode.ts
693
+ var fieldDiscriminatorNode = defineNode("fieldDiscriminatorNode", {
694
+ docs: "Identifies a node by the value of a named field at a known byte offset.",
695
+ attributes: [
696
+ attribute("name", stringIdentifier(), {
697
+ docs: "The name of the discriminating field."
698
+ }),
699
+ attribute("offset", u64(), {
700
+ docs: "The byte offset of the field."
701
+ })
702
+ ]
703
+ });
704
+
705
+ // src/v1/nodes/discriminatorNodes/SizeDiscriminatorNode.ts
706
+ var sizeDiscriminatorNode = defineNode("sizeDiscriminatorNode", {
707
+ docs: "Identifies a node by its expected total byte size.",
708
+ attributes: [
709
+ attribute("size", u64(), {
710
+ docs: "The expected byte size."
711
+ })
712
+ ]
713
+ });
714
+
715
+ // src/v1/nodes/discriminatorNodes/index.ts
716
+ var ALL_DISCRIMINATOR_NODES = [
717
+ constantDiscriminatorNode,
718
+ fieldDiscriminatorNode,
719
+ sizeDiscriminatorNode
720
+ ];
721
+ var ALL_DISCRIMINATOR_NODE_UNIONS = [registeredDiscriminatorNodeUnion, discriminatorNodeUnion];
722
+
723
+ // src/v1/nodes/ErrorNode.ts
724
+ var errorNode = defineNode("errorNode", {
725
+ docs: "A program error \u2014 a numeric code paired with a name and human-readable message.",
726
+ attributes: [
727
+ attribute("name", stringIdentifier(), {
728
+ docs: "The name of the error."
729
+ }),
730
+ attribute("code", u32(), {
731
+ docs: "The numeric error code returned by the program."
732
+ }),
733
+ attribute("message", string(), {
734
+ docs: "A human-readable description of the error."
735
+ }),
736
+ optionalAttribute("docs", docs(), {
737
+ docs: "Markdown documentation for the error."
738
+ })
739
+ ]
740
+ });
741
+
742
+ // src/v1/nodes/EventNode.ts
743
+ var eventNode = defineNode("eventNode", {
744
+ docs: "A program event: its data shape and optional discriminators used to identify it on the wire.",
745
+ attributes: [
746
+ attribute("name", stringIdentifier(), {
747
+ docs: "The name of the event."
748
+ }),
749
+ optionalAttribute("docs", docs(), {
750
+ docs: "Markdown documentation for the event."
751
+ }),
752
+ attribute("data", union("TypeNode"), {
753
+ docs: "The type describing the event payload."
754
+ }),
755
+ optionalAttribute("discriminators", array(union("DiscriminatorNode")), {
756
+ docs: "Discriminators that distinguish this event from others. When multiple are listed, they are combined with a logical AND."
757
+ })
758
+ ]
759
+ });
760
+
761
+ // src/v1/nodes/InstructionAccountNode.ts
762
+ var instructionAccountNode = defineNode("instructionAccountNode", {
763
+ docs: "An account participating in an instruction, with its name, signing/writability flags, and an optional default value.",
764
+ attributes: [
765
+ attribute("name", stringIdentifier(), {
766
+ docs: "The name of the account."
767
+ }),
768
+ attribute("isWritable", boolean(), {
769
+ docs: "Whether the instruction may write to the account."
770
+ }),
771
+ attribute("isSigner", literalUnion(true, false, "either"), {
772
+ docs: 'Whether the account must sign the transaction. The literal `"either"` indicates a slot that may or may not sign depending on context.'
773
+ }),
774
+ optionalAttribute("isOptional", boolean(), {
775
+ docs: "Whether the account slot may be omitted by callers."
776
+ }),
777
+ optionalAttribute("docs", docs(), {
778
+ docs: "Markdown documentation for the account slot."
779
+ }),
780
+ optionalAttribute("defaultValue", union("InstructionInputValueNode"), {
781
+ docs: "A default value used to fill the slot when the caller does not provide one."
782
+ })
783
+ ]
784
+ });
785
+
786
+ // src/v1/nodes/InstructionArgumentNode.ts
787
+ var instructionArgumentNode = defineNode("instructionArgumentNode", {
788
+ docs: "A named argument of an instruction, with its type and an optional default value.",
789
+ attributes: [
790
+ attribute("name", stringIdentifier(), {
791
+ docs: "The name of the argument."
792
+ }),
793
+ optionalAttribute("defaultValueStrategy", enumeration("DefaultValueStrategy"), {
794
+ docs: "How a configured default value is exposed in generated APIs. Required when `defaultValue` is set."
795
+ }),
796
+ optionalAttribute("docs", docs(), {
797
+ docs: "Markdown documentation for the argument."
798
+ }),
799
+ attribute("type", union("TypeNode"), {
800
+ docs: "The type of the argument."
801
+ }),
802
+ optionalAttribute("defaultValue", union("InstructionInputValueNode"), {
803
+ docs: "A default value used when the argument is omitted by callers."
804
+ })
805
+ ]
806
+ });
807
+
808
+ // src/v1/nodes/InstructionByteDeltaNode.ts
809
+ var instructionByteDeltaNode = defineNode("instructionByteDeltaNode", {
810
+ docs: "A byte-size delta applied when computing rent or buffer size \u2014 typically used by instructions that resize accounts.",
811
+ attributes: [
812
+ attribute("withHeader", boolean(), {
813
+ docs: "Whether the delta includes the account header overhead."
814
+ }),
815
+ optionalAttribute("subtract", boolean(), {
816
+ docs: "When `true`, the delta is subtracted from the running size instead of added. Defaults to `false`."
817
+ }),
818
+ attribute("value", union("InstructionByteDeltaValue"), {
819
+ docs: "The source of the delta value \u2014 a literal number, a referenced account or argument, or a resolver."
820
+ })
821
+ ]
822
+ });
823
+
824
+ // src/v1/nodes/InstructionNode.ts
825
+ var instructionNode = defineNode("instructionNode", {
826
+ docs: "A program instruction: its accounts, arguments, byte-delta hints, discriminators, optional status, and optional sub-instructions.",
827
+ attributes: [
828
+ attribute("name", stringIdentifier(), {
829
+ docs: "The name of the instruction."
830
+ }),
831
+ optionalAttribute("docs", docs(), {
832
+ docs: "Markdown documentation for the instruction."
833
+ }),
834
+ optionalAttribute("optionalAccountStrategy", enumeration("OptionalAccountStrategy"), {
835
+ docs: "How absent optional accounts are represented when serialising the instruction."
836
+ }),
837
+ attribute("accounts", array(node("instructionAccountNode")), {
838
+ docs: "The accounts the instruction operates on, in order."
839
+ }),
840
+ attribute("arguments", array(node("instructionArgumentNode")), {
841
+ docs: "The serialised arguments of the instruction, in order."
842
+ }),
843
+ optionalAttribute("extraArguments", array(node("instructionArgumentNode")), {
844
+ docs: "Additional arguments exposed in the generated client API but not serialised on the wire."
845
+ }),
846
+ optionalAttribute("remainingAccounts", array(node("instructionRemainingAccountsNode")), {
847
+ docs: "Variable-length tails of accounts appended after the named account slots."
848
+ }),
849
+ optionalAttribute("byteDeltas", array(node("instructionByteDeltaNode")), {
850
+ docs: "Byte-size adjustments applied when computing rent or buffer size \u2014 for instructions that resize accounts."
851
+ }),
852
+ optionalAttribute("discriminators", array(union("DiscriminatorNode")), {
853
+ docs: "Discriminators that distinguish this instruction from others. When multiple are listed, they are combined with a logical AND."
854
+ }),
855
+ optionalAttribute("status", node("instructionStatusNode"), {
856
+ docs: "The lifecycle status of the instruction."
857
+ }),
858
+ optionalAttribute("subInstructions", array(node("instructionNode")), {
859
+ docs: "Inner instructions invoked through CPI as part of executing this instruction."
860
+ })
861
+ ]
862
+ });
863
+
864
+ // src/v1/nodes/InstructionNodeUnions.ts
865
+ var instructionByteDeltaValueUnion = defineUnion("InstructionByteDeltaValue", {
866
+ docs: "The value forms accepted by an `instructionByteDeltaNode`.",
867
+ members: ["accountLinkNode", "argumentValueNode", "numberValueNode", "resolverValueNode"]
868
+ });
869
+ var instructionRemainingAccountsValueUnion = defineUnion("InstructionRemainingAccountsValue", {
870
+ docs: "The value forms accepted by an `instructionRemainingAccountsNode`.",
871
+ members: ["argumentValueNode", "resolverValueNode"]
872
+ });
873
+
874
+ // src/v1/nodes/InstructionRemainingAccountsNode.ts
875
+ var instructionRemainingAccountsNode = defineNode("instructionRemainingAccountsNode", {
876
+ docs: 'A "remaining accounts" slot in an instruction \u2014 a variable-length tail of accounts derived from a value.',
877
+ attributes: [
878
+ optionalAttribute("isOptional", boolean(), {
879
+ docs: "Whether the remaining-accounts tail may be empty."
880
+ }),
881
+ optionalAttribute("isSigner", literalUnion(true, false, "either"), {
882
+ docs: 'Whether each remaining account must sign the transaction. The literal `"either"` indicates a slot that may or may not sign depending on context.'
883
+ }),
884
+ optionalAttribute("isWritable", boolean(), {
885
+ docs: "Whether the instruction may write to each remaining account."
886
+ }),
887
+ optionalAttribute("docs", docs(), {
888
+ docs: "Markdown documentation for the remaining-accounts slot."
889
+ }),
890
+ attribute("value", union("InstructionRemainingAccountsValue"), {
891
+ docs: "The source of the remaining-accounts list \u2014 a referenced argument or a resolver."
892
+ })
893
+ ]
894
+ });
895
+
896
+ // src/v1/nodes/InstructionStatusNode.ts
897
+ var instructionStatusNode = defineNode("instructionStatusNode", {
898
+ docs: "The lifecycle stage of an instruction (draft, live, deprecated, archived) with an optional accompanying message.",
899
+ attributes: [
900
+ attribute("lifecycle", enumeration("InstructionLifecycle"), {
901
+ docs: "The lifecycle stage."
902
+ }),
903
+ optionalAttribute("message", string(), {
904
+ docs: "Free-form prose accompanying the status \u2014 e.g. a deprecation notice with migration guidance."
905
+ })
906
+ ]
907
+ });
908
+
909
+ // src/v1/nodes/linkNodes/AccountLinkNode.ts
910
+ var accountLinkNode = defineNode("accountLinkNode", {
911
+ docs: "A reference to an account defined elsewhere \u2014 possibly in a different program.",
912
+ attributes: [
913
+ optionalAttribute("program", node("programLinkNode"), {
914
+ docs: "The program the referenced account belongs to. When omitted, the surrounding program is assumed."
915
+ }),
916
+ attribute("name", stringIdentifier(), {
917
+ docs: "The name of the referenced account."
918
+ })
919
+ ]
920
+ });
921
+
922
+ // src/v1/nodes/linkNodes/DefinedTypeLinkNode.ts
923
+ var definedTypeLinkNode = defineNode("definedTypeLinkNode", {
924
+ docs: "A reference to a defined type \u2014 possibly in a different program.",
925
+ attributes: [
926
+ optionalAttribute("program", node("programLinkNode"), {
927
+ docs: "The program the referenced type is defined in. When omitted, the surrounding program is assumed."
928
+ }),
929
+ attribute("name", stringIdentifier(), {
930
+ docs: "The name of the referenced defined type."
931
+ })
932
+ ]
933
+ });
934
+
935
+ // src/v1/nodes/linkNodes/InstructionAccountLinkNode.ts
936
+ var instructionAccountLinkNode = defineNode("instructionAccountLinkNode", {
937
+ docs: "A reference to an account of another instruction.",
938
+ attributes: [
939
+ optionalAttribute("instruction", node("instructionLinkNode"), {
940
+ docs: "The instruction the referenced account belongs to. When omitted, the surrounding instruction is assumed."
941
+ }),
942
+ attribute("name", stringIdentifier(), {
943
+ docs: "The name of the referenced instruction account."
944
+ })
945
+ ]
946
+ });
947
+
948
+ // src/v1/nodes/linkNodes/InstructionArgumentLinkNode.ts
949
+ var instructionArgumentLinkNode = defineNode("instructionArgumentLinkNode", {
950
+ docs: "A reference to an argument of another instruction.",
951
+ attributes: [
952
+ optionalAttribute("instruction", node("instructionLinkNode"), {
953
+ docs: "The instruction the referenced argument belongs to. When omitted, the surrounding instruction is assumed."
954
+ }),
955
+ attribute("name", stringIdentifier(), {
956
+ docs: "The name of the referenced instruction argument."
957
+ })
958
+ ]
959
+ });
960
+
961
+ // src/v1/nodes/linkNodes/InstructionLinkNode.ts
962
+ var instructionLinkNode = defineNode("instructionLinkNode", {
963
+ docs: "A reference to an instruction defined elsewhere \u2014 possibly in a different program.",
964
+ attributes: [
965
+ optionalAttribute("program", node("programLinkNode"), {
966
+ docs: "The program the referenced instruction belongs to. When omitted, the surrounding program is assumed."
967
+ }),
968
+ attribute("name", stringIdentifier(), {
969
+ docs: "The name of the referenced instruction."
970
+ })
971
+ ]
972
+ });
973
+
974
+ // src/v1/nodes/linkNodes/LinkNode.ts
975
+ var registeredLinkNodeUnion = defineUnion("RegisteredLinkNode", {
976
+ docs: "Every node tagged as a link to another part of the IDL.",
977
+ members: [
978
+ "accountLinkNode",
979
+ "definedTypeLinkNode",
980
+ "instructionAccountLinkNode",
981
+ "instructionArgumentLinkNode",
982
+ "instructionLinkNode",
983
+ "pdaLinkNode",
984
+ "programLinkNode"
985
+ ]
986
+ });
987
+ var linkNodeUnion = defineUnion("LinkNode", {
988
+ docs: "The composable form: any registered link node.",
989
+ members: [union("RegisteredLinkNode")]
990
+ });
991
+
992
+ // src/v1/nodes/linkNodes/PdaLinkNode.ts
993
+ var pdaLinkNode = defineNode("pdaLinkNode", {
994
+ docs: "A reference to a PDA defined elsewhere \u2014 possibly in a different program.",
995
+ attributes: [
996
+ optionalAttribute("program", node("programLinkNode"), {
997
+ docs: "The program the referenced PDA belongs to. When omitted, the surrounding program is assumed."
998
+ }),
999
+ attribute("name", stringIdentifier(), {
1000
+ docs: "The name of the referenced PDA."
1001
+ })
1002
+ ]
1003
+ });
1004
+
1005
+ // src/v1/nodes/linkNodes/ProgramLinkNode.ts
1006
+ var programLinkNode = defineNode("programLinkNode", {
1007
+ docs: "A reference to a program by name.",
1008
+ attributes: [
1009
+ attribute("name", stringIdentifier(), {
1010
+ docs: "The name of the referenced program."
1011
+ })
1012
+ ]
1013
+ });
1014
+
1015
+ // src/v1/nodes/linkNodes/index.ts
1016
+ var ALL_LINK_NODES = [
1017
+ accountLinkNode,
1018
+ definedTypeLinkNode,
1019
+ instructionAccountLinkNode,
1020
+ instructionArgumentLinkNode,
1021
+ instructionLinkNode,
1022
+ pdaLinkNode,
1023
+ programLinkNode
1024
+ ];
1025
+ var ALL_LINK_NODE_UNIONS = [registeredLinkNodeUnion, linkNodeUnion];
1026
+
1027
+ // src/v1/nodes/PdaNode.ts
1028
+ var pdaNode = defineNode("pdaNode", {
1029
+ docs: "A program-derived address: its name, optional program ID override, and the seeds used to derive it.",
1030
+ attributes: [
1031
+ attribute("name", stringIdentifier(), {
1032
+ docs: "The name of the PDA."
1033
+ }),
1034
+ optionalAttribute("docs", docs(), {
1035
+ docs: "Markdown documentation for the PDA."
1036
+ }),
1037
+ optionalAttribute("programId", string(), {
1038
+ docs: "The base58-encoded program ID used to derive the PDA. When omitted, the surrounding program is assumed."
1039
+ }),
1040
+ attribute("seeds", array(union("PdaSeedNode")), {
1041
+ docs: "The seeds used to derive the PDA, in order."
1042
+ })
1043
+ ]
1044
+ });
1045
+
1046
+ // src/v1/nodes/pdaSeedNodes/ConstantPdaSeedNode.ts
1047
+ var constantPdaSeedNode = defineNode("constantPdaSeedNode", {
1048
+ docs: "A PDA seed with a constant value (e.g. a UTF-8 string or a fixed byte sequence).",
1049
+ attributes: [
1050
+ attribute("type", union("TypeNode"), {
1051
+ docs: "The type of the seed value."
1052
+ }),
1053
+ attribute("value", union("ConstantPdaSeedValue"), {
1054
+ docs: "The constant value to use as the seed \u2014 either a literal value or the program ID placeholder."
1055
+ })
1056
+ ]
1057
+ });
1058
+
1059
+ // src/v1/nodes/pdaSeedNodes/PdaSeedNode.ts
1060
+ var registeredPdaSeedNodeUnion = defineUnion("RegisteredPdaSeedNode", {
1061
+ docs: "Every node tagged as a PDA seed.",
1062
+ members: ["constantPdaSeedNode", "variablePdaSeedNode"]
1063
+ });
1064
+ var pdaSeedNodeUnion = defineUnion("PdaSeedNode", {
1065
+ docs: "The composable form: any registered PDA seed node.",
1066
+ members: [union("RegisteredPdaSeedNode")]
1067
+ });
1068
+ var constantPdaSeedValueUnion = defineUnion("ConstantPdaSeedValue", {
1069
+ docs: "The value forms a `constantPdaSeedNode` may carry \u2014 either a literal value or the program ID placeholder.",
1070
+ members: ["programIdValueNode", union("ValueNode")]
1071
+ });
1072
+
1073
+ // src/v1/nodes/pdaSeedNodes/VariablePdaSeedNode.ts
1074
+ var variablePdaSeedNode = defineNode("variablePdaSeedNode", {
1075
+ docs: "A PDA seed whose value is provided at derivation time, identified by name.",
1076
+ attributes: [
1077
+ attribute("name", stringIdentifier(), {
1078
+ docs: "The name of the seed variable."
1079
+ }),
1080
+ optionalAttribute("docs", docs(), {
1081
+ docs: "Markdown documentation for the seed variable."
1082
+ }),
1083
+ attribute("type", union("TypeNode"), {
1084
+ docs: "The expected type of the seed value."
1085
+ })
1086
+ ]
1087
+ });
1088
+
1089
+ // src/v1/nodes/pdaSeedNodes/index.ts
1090
+ var ALL_PDA_SEED_NODES = [constantPdaSeedNode, variablePdaSeedNode];
1091
+ var ALL_PDA_SEED_NODE_UNIONS = [
1092
+ registeredPdaSeedNodeUnion,
1093
+ pdaSeedNodeUnion,
1094
+ constantPdaSeedValueUnion
1095
+ ];
1096
+
1097
+ // src/v1/nodes/ProgramNode.ts
1098
+ var programNode = defineNode("programNode", {
1099
+ docs: "A Solana program: its identity, version, accounts, instructions, defined types, PDAs, events, errors, and constants.",
1100
+ attributes: [
1101
+ attribute("name", stringIdentifier(), {
1102
+ docs: "The name of the program."
1103
+ }),
1104
+ attribute("publicKey", string(), {
1105
+ docs: "The base58-encoded program ID."
1106
+ }),
1107
+ attribute("version", stringVersion(), {
1108
+ docs: "The version of the program, in semver form."
1109
+ }),
1110
+ optionalAttribute("origin", enumeration("ProgramOrigin"), {
1111
+ docs: "The toolchain that originally generated the program description, if known."
1112
+ }),
1113
+ optionalAttribute("docs", docs(), {
1114
+ docs: "Markdown documentation for the program."
1115
+ }),
1116
+ attribute("accounts", array(node("accountNode")), {
1117
+ docs: "The accounts owned by the program."
1118
+ }),
1119
+ attribute("instructions", array(node("instructionNode")), {
1120
+ docs: "The instructions exposed by the program."
1121
+ }),
1122
+ attribute("definedTypes", array(node("definedTypeNode")), {
1123
+ docs: "The reusable types defined by the program."
1124
+ }),
1125
+ attribute("pdas", array(node("pdaNode")), {
1126
+ docs: "The PDAs derived by the program."
1127
+ }),
1128
+ attribute("events", array(node("eventNode")), {
1129
+ docs: "The events emitted by the program."
1130
+ }),
1131
+ attribute("errors", array(node("errorNode")), {
1132
+ docs: "The errors returned by the program."
1133
+ }),
1134
+ attribute("constants", array(node("constantNode")), {
1135
+ docs: "The constants exposed by the program."
1136
+ })
1137
+ ]
1138
+ });
1139
+
1140
+ // src/v1/nodes/RootNode.ts
1141
+ var rootNode = defineNode("rootNode", {
1142
+ docs: "The root of a Codama IDL document. Pairs a primary program with any number of additional programs and tags the document with the spec version.",
1143
+ attributes: [
1144
+ attribute("standard", literal("codama"), {
1145
+ docs: "A literal marker identifying the document as a Codama IDL."
1146
+ }),
1147
+ attribute("version", codamaVersion(), {
1148
+ docs: "The Codama spec version this document conforms to."
1149
+ }),
1150
+ attribute("program", node("programNode"), {
1151
+ docs: "The primary program described by the document."
1152
+ }),
1153
+ attribute("additionalPrograms", array(node("programNode")), {
1154
+ docs: "Additional programs referenced by the primary program."
1155
+ })
1156
+ ]
1157
+ });
1158
+
1159
+ // src/v1/nodes/typeNodes/AmountTypeNode.ts
1160
+ var amountTypeNode = defineNode("amountTypeNode", {
1161
+ docs: "Wraps a number type to provide additional context such as decimal places and a unit. Useful for amounts representing financial values.",
1162
+ attributes: [
1163
+ attribute("decimals", u32(), {
1164
+ docs: "The number of decimal places the wrapped integer carries. For example, an integer value of 12345 with 2 decimal places represents 123.45."
1165
+ }),
1166
+ optionalAttribute("unit", string(), {
1167
+ docs: 'The unit of the amount \u2014 e.g. "USD" or "%".'
1168
+ }),
1169
+ attribute("number", nestedTypeNode("numberTypeNode"), {
1170
+ docs: "The number type the amount wraps."
1171
+ })
1172
+ ]
1173
+ });
1174
+
1175
+ // src/v1/nodes/typeNodes/ArrayTypeNode.ts
1176
+ var arrayTypeNode = defineNode("arrayTypeNode", {
1177
+ docs: "A homogeneous list of items. The item type is defined by `item`; the length is determined by the `count` strategy.",
1178
+ attributes: [
1179
+ attribute("item", union("TypeNode"), {
1180
+ docs: "The type of each item in the array."
1181
+ }),
1182
+ attribute("count", union("CountNode"), {
1183
+ docs: "The strategy used to determine the number of items."
1184
+ })
1185
+ ]
1186
+ });
1187
+
1188
+ // src/v1/nodes/typeNodes/BooleanTypeNode.ts
1189
+ var booleanTypeNode = defineNode("booleanTypeNode", {
1190
+ docs: "A boolean serialised as a numeric value. The wrapped number type determines the byte width.",
1191
+ attributes: [
1192
+ attribute("size", nestedTypeNode("numberTypeNode"), {
1193
+ docs: "The numeric type used to serialise the boolean."
1194
+ })
1195
+ ]
1196
+ });
1197
+
1198
+ // src/v1/nodes/typeNodes/BytesTypeNode.ts
1199
+ var bytesTypeNode = defineNode("bytesTypeNode", {
1200
+ docs: "A raw sequence of bytes. Typically used inside a fixed-size, size-prefixed, or sentinel-terminated wrapper.",
1201
+ attributes: []
1202
+ });
1203
+
1204
+ // src/v1/nodes/typeNodes/DateTimeTypeNode.ts
1205
+ var dateTimeTypeNode = defineNode("dateTimeTypeNode", {
1206
+ docs: "A timestamp encoded as a number, typically seconds since the Unix epoch. The wrapped number type determines the byte width.",
1207
+ attributes: [
1208
+ attribute("number", nestedTypeNode("numberTypeNode"), {
1209
+ docs: "The numeric type used to serialise the timestamp."
1210
+ })
1211
+ ]
1212
+ });
1213
+
1214
+ // src/v1/nodes/typeNodes/EnumEmptyVariantTypeNode.ts
1215
+ var enumEmptyVariantTypeNode = defineNode("enumEmptyVariantTypeNode", {
1216
+ docs: "A unit-style variant of an enum that carries no payload.",
1217
+ attributes: [
1218
+ attribute("name", stringIdentifier(), {
1219
+ docs: "The name of the variant."
1220
+ }),
1221
+ optionalAttribute("discriminator", u32(), {
1222
+ docs: "Explicit discriminator value. When omitted, the discriminator is inferred from the variant position."
1223
+ })
1224
+ ]
1225
+ });
1226
+
1227
+ // src/v1/nodes/typeNodes/EnumStructVariantTypeNode.ts
1228
+ var enumStructVariantTypeNode = defineNode("enumStructVariantTypeNode", {
1229
+ docs: "A variant of an enum that carries a struct payload (named fields).",
1230
+ attributes: [
1231
+ attribute("name", stringIdentifier(), {
1232
+ docs: "The name of the variant."
1233
+ }),
1234
+ optionalAttribute("discriminator", u32(), {
1235
+ docs: "Explicit discriminator value. When omitted, the discriminator is inferred from the variant position."
1236
+ }),
1237
+ attribute("struct", nestedTypeNode("structTypeNode"), {
1238
+ docs: "The struct of named fields carried by the variant."
1239
+ })
1240
+ ]
1241
+ });
1242
+
1243
+ // src/v1/nodes/typeNodes/EnumTupleVariantTypeNode.ts
1244
+ var enumTupleVariantTypeNode = defineNode("enumTupleVariantTypeNode", {
1245
+ docs: "A variant of an enum that carries a tuple payload (positional fields).",
1246
+ attributes: [
1247
+ attribute("name", stringIdentifier(), {
1248
+ docs: "The name of the variant."
1249
+ }),
1250
+ optionalAttribute("discriminator", u32(), {
1251
+ docs: "Explicit discriminator value. When omitted, the discriminator is inferred from the variant position."
1252
+ }),
1253
+ attribute("tuple", nestedTypeNode("tupleTypeNode"), {
1254
+ docs: "The tuple of positional fields carried by the variant."
1255
+ })
1256
+ ]
1257
+ });
1258
+
1259
+ // src/v1/nodes/typeNodes/EnumTypeNode.ts
1260
+ var enumTypeNode = defineNode("enumTypeNode", {
1261
+ docs: "A tagged union: a numeric discriminator followed by one of several variant payloads.",
1262
+ attributes: [
1263
+ attribute("variants", array(union("EnumVariantTypeNode")), {
1264
+ docs: "The variants of the enum, in declaration order."
1265
+ }),
1266
+ attribute("size", nestedTypeNode("numberTypeNode"), {
1267
+ docs: "The numeric type used to serialise the discriminator."
1268
+ })
1269
+ ]
1270
+ });
1271
+
1272
+ // src/v1/nodes/typeNodes/FixedSizeTypeNode.ts
1273
+ var fixedSizeTypeNode = defineNode("fixedSizeTypeNode", {
1274
+ docs: "Wraps another type and asserts a fixed total byte size. Padding or truncation is applied as needed.",
1275
+ attributes: [
1276
+ attribute("size", u64(), {
1277
+ docs: "The total byte size the wrapped type must occupy."
1278
+ }),
1279
+ attribute("type", union("TypeNode"), {
1280
+ docs: "The wrapped type whose serialisation is constrained."
1281
+ })
1282
+ ]
1283
+ });
1284
+
1285
+ // src/v1/nodes/typeNodes/HiddenPrefixTypeNode.ts
1286
+ var hiddenPrefixTypeNode = defineNode("hiddenPrefixTypeNode", {
1287
+ docs: "Prefixes another type with a list of constant values that are written and read but not surfaced as fields to consumers.",
1288
+ attributes: [
1289
+ attribute("type", union("TypeNode"), {
1290
+ docs: "The wrapped type whose serialisation is preceded by the hidden prefix."
1291
+ }),
1292
+ attribute("prefix", array(node("constantValueNode")), {
1293
+ docs: "The constant values written before the wrapped type, in order."
1294
+ })
1295
+ ]
1296
+ });
1297
+
1298
+ // src/v1/nodes/typeNodes/HiddenSuffixTypeNode.ts
1299
+ var hiddenSuffixTypeNode = defineNode("hiddenSuffixTypeNode", {
1300
+ docs: "Suffixes another type with a list of constant values that are written and read but not surfaced as fields to consumers.",
1301
+ attributes: [
1302
+ attribute("type", union("TypeNode"), {
1303
+ docs: "The wrapped type whose serialisation is followed by the hidden suffix."
1304
+ }),
1305
+ attribute("suffix", array(node("constantValueNode")), {
1306
+ docs: "The constant values written after the wrapped type, in order."
1307
+ })
1308
+ ]
1309
+ });
1310
+
1311
+ // src/v1/nodes/typeNodes/MapTypeNode.ts
1312
+ var mapTypeNode = defineNode("mapTypeNode", {
1313
+ docs: "A keyed map. The key and value types are described by their respective type nodes; the entry count is determined by a count strategy.",
1314
+ attributes: [
1315
+ attribute("key", union("TypeNode"), {
1316
+ docs: "The type of each entry key."
1317
+ }),
1318
+ attribute("value", union("TypeNode"), {
1319
+ docs: "The type of each entry value."
1320
+ }),
1321
+ attribute("count", union("CountNode"), {
1322
+ docs: "The strategy used to determine the number of entries."
1323
+ })
1324
+ ]
1325
+ });
1326
+
1327
+ // src/v1/nodes/typeNodes/NumberTypeNode.ts
1328
+ var numberTypeNode = defineNode("numberTypeNode", {
1329
+ docs: "A numeric type with a fixed wire format and byte order.",
1330
+ attributes: [
1331
+ attribute("format", enumeration("NumberFormat"), {
1332
+ docs: "The wire format used to serialise the number."
1333
+ }),
1334
+ attribute("endian", enumeration("Endianness"), {
1335
+ docs: "The byte order used to serialise the number."
1336
+ })
1337
+ ]
1338
+ });
1339
+
1340
+ // src/v1/nodes/typeNodes/OptionTypeNode.ts
1341
+ var optionTypeNode = defineNode("optionTypeNode", {
1342
+ docs: "A value that may be present or absent (Some/None), with an explicit numeric prefix indicating presence.",
1343
+ attributes: [
1344
+ optionalAttribute("fixed", boolean(), {
1345
+ docs: "When `true`, the absent variant still occupies the byte size of the present variant (zero-padded). Defaults to `false`."
1346
+ }),
1347
+ attribute("item", union("TypeNode"), {
1348
+ docs: "The type carried by the option when present."
1349
+ }),
1350
+ attribute("prefix", nestedTypeNode("numberTypeNode"), {
1351
+ docs: "The numeric type used as the presence flag."
1352
+ })
1353
+ ]
1354
+ });
1355
+
1356
+ // src/v1/nodes/typeNodes/PostOffsetTypeNode.ts
1357
+ var postOffsetTypeNode = defineNode("postOffsetTypeNode", {
1358
+ docs: "After serialising the wrapped type, advance the cursor by `offset` bytes interpreted via the chosen strategy.",
1359
+ attributes: [
1360
+ attribute("offset", i64(), {
1361
+ docs: "The signed byte offset to apply after the wrapped type runs."
1362
+ }),
1363
+ attribute("strategy", enumeration("PostOffsetStrategy"), {
1364
+ docs: "How the `offset` value is interpreted."
1365
+ }),
1366
+ attribute("type", union("TypeNode"), {
1367
+ docs: "The wrapped type whose serialisation is followed by the offset."
1368
+ })
1369
+ ]
1370
+ });
1371
+
1372
+ // src/v1/nodes/typeNodes/PreOffsetTypeNode.ts
1373
+ var preOffsetTypeNode = defineNode("preOffsetTypeNode", {
1374
+ docs: "Before serialising the wrapped type, advance the cursor by `offset` bytes interpreted via the chosen strategy.",
1375
+ attributes: [
1376
+ attribute("offset", i64(), {
1377
+ docs: "The signed byte offset to apply before the wrapped type runs."
1378
+ }),
1379
+ attribute("strategy", enumeration("PreOffsetStrategy"), {
1380
+ docs: "How the `offset` value is interpreted."
1381
+ }),
1382
+ attribute("type", union("TypeNode"), {
1383
+ docs: "The wrapped type whose serialisation is preceded by the offset."
1384
+ })
1385
+ ]
1386
+ });
1387
+
1388
+ // src/v1/nodes/typeNodes/PublicKeyTypeNode.ts
1389
+ var publicKeyTypeNode = defineNode("publicKeyTypeNode", {
1390
+ docs: "A 32-byte Solana public key.",
1391
+ attributes: []
1392
+ });
1393
+
1394
+ // src/v1/nodes/typeNodes/RemainderOptionTypeNode.ts
1395
+ var remainderOptionTypeNode = defineNode("remainderOptionTypeNode", {
1396
+ docs: "A value that may be present or absent. Presence is signalled by whether any bytes remain to be read, with no explicit prefix.",
1397
+ attributes: [
1398
+ attribute("item", union("TypeNode"), {
1399
+ docs: "The type carried by the option when present."
1400
+ })
1401
+ ]
1402
+ });
1403
+
1404
+ // src/v1/nodes/typeNodes/SentinelTypeNode.ts
1405
+ var sentinelTypeNode = defineNode("sentinelTypeNode", {
1406
+ docs: "Wraps another type and delimits it with a constant sentinel value written immediately after the wrapped type.",
1407
+ attributes: [
1408
+ attribute("type", union("TypeNode"), {
1409
+ docs: "The wrapped type whose extent is delimited by the sentinel."
1410
+ }),
1411
+ attribute("sentinel", node("constantValueNode"), {
1412
+ docs: "The constant value written immediately after the wrapped type to mark its end."
1413
+ })
1414
+ ]
1415
+ });
1416
+
1417
+ // src/v1/nodes/typeNodes/SetTypeNode.ts
1418
+ var setTypeNode = defineNode("setTypeNode", {
1419
+ docs: "A unique-valued collection. The item type is defined by `item`; the size is determined by the `count` strategy.",
1420
+ attributes: [
1421
+ attribute("item", union("TypeNode"), {
1422
+ docs: "The type of each item in the set."
1423
+ }),
1424
+ attribute("count", union("CountNode"), {
1425
+ docs: "The strategy used to determine the number of items."
1426
+ })
1427
+ ]
1428
+ });
1429
+
1430
+ // src/v1/nodes/typeNodes/SizePrefixTypeNode.ts
1431
+ var sizePrefixTypeNode = defineNode("sizePrefixTypeNode", {
1432
+ docs: "Wraps another type with a numeric prefix indicating the byte length of the wrapped type.",
1433
+ attributes: [
1434
+ attribute("type", union("TypeNode"), {
1435
+ docs: "The wrapped type whose serialisation is preceded by its size."
1436
+ }),
1437
+ attribute("prefix", nestedTypeNode("numberTypeNode"), {
1438
+ docs: "The numeric type used as the size prefix."
1439
+ })
1440
+ ]
1441
+ });
1442
+
1443
+ // src/v1/nodes/typeNodes/SolAmountTypeNode.ts
1444
+ var solAmountTypeNode = defineNode("solAmountTypeNode", {
1445
+ docs: "A SOL amount expressed in lamports under the wrapped numeric type.",
1446
+ attributes: [
1447
+ attribute("number", nestedTypeNode("numberTypeNode"), {
1448
+ docs: "The numeric type used to serialise the lamport amount."
1449
+ })
1450
+ ]
1451
+ });
1452
+
1453
+ // src/v1/nodes/typeNodes/StringTypeNode.ts
1454
+ var stringTypeNode = defineNode("stringTypeNode", {
1455
+ docs: "A string value. The encoding describes how its bytes are written; the byte length is determined by an enclosing wrapper such as `sizePrefixTypeNode` or `fixedSizeTypeNode`.",
1456
+ attributes: [
1457
+ attribute("encoding", enumeration("BytesEncoding"), {
1458
+ docs: "The byte encoding used to serialise the string."
1459
+ })
1460
+ ]
1461
+ });
1462
+
1463
+ // src/v1/nodes/typeNodes/StructFieldTypeNode.ts
1464
+ var structFieldTypeNode = defineNode("structFieldTypeNode", {
1465
+ docs: "A named field within a struct type.",
1466
+ attributes: [
1467
+ attribute("name", stringIdentifier(), {
1468
+ docs: "The name of the field."
1469
+ }),
1470
+ optionalAttribute("defaultValueStrategy", enumeration("DefaultValueStrategy"), {
1471
+ docs: "How a configured default value is exposed in generated APIs. Required when `defaultValue` is set."
1472
+ }),
1473
+ optionalAttribute("docs", docs(), {
1474
+ docs: "Markdown documentation for the field."
1475
+ }),
1476
+ attribute("type", union("TypeNode"), {
1477
+ docs: "The type of the field."
1478
+ }),
1479
+ optionalAttribute("defaultValue", union("ValueNode"), {
1480
+ docs: "A default value used when the field is omitted by callers."
1481
+ })
1482
+ ]
1483
+ });
1484
+
1485
+ // src/v1/nodes/typeNodes/StructTypeNode.ts
1486
+ var structTypeNode = defineNode("structTypeNode", {
1487
+ docs: "A composite type made of an ordered list of named fields. Fields are encoded and decoded in declaration order.",
1488
+ attributes: [
1489
+ attribute("fields", array(node("structFieldTypeNode")), {
1490
+ docs: "The fields of the struct, in declaration order."
1491
+ })
1492
+ ]
1493
+ });
1494
+
1495
+ // src/v1/nodes/typeNodes/TupleTypeNode.ts
1496
+ var tupleTypeNode = defineNode("tupleTypeNode", {
1497
+ docs: "A heterogeneous fixed-length sequence in which each positional slot has its own type.",
1498
+ attributes: [
1499
+ attribute("items", array(union("TypeNode")), {
1500
+ docs: "The type of each positional slot, in order."
1501
+ })
1502
+ ]
1503
+ });
1504
+
1505
+ // src/v1/nodes/typeNodes/TypeNode.ts
1506
+ var STANDALONE_TYPE_NODE_KINDS = [
1507
+ "amountTypeNode",
1508
+ "arrayTypeNode",
1509
+ "booleanTypeNode",
1510
+ "bytesTypeNode",
1511
+ "dateTimeTypeNode",
1512
+ "enumTypeNode",
1513
+ "fixedSizeTypeNode",
1514
+ "hiddenPrefixTypeNode",
1515
+ "hiddenSuffixTypeNode",
1516
+ "mapTypeNode",
1517
+ "numberTypeNode",
1518
+ "optionTypeNode",
1519
+ "postOffsetTypeNode",
1520
+ "preOffsetTypeNode",
1521
+ "publicKeyTypeNode",
1522
+ "remainderOptionTypeNode",
1523
+ "sentinelTypeNode",
1524
+ "setTypeNode",
1525
+ "sizePrefixTypeNode",
1526
+ "solAmountTypeNode",
1527
+ "stringTypeNode",
1528
+ "structTypeNode",
1529
+ "tupleTypeNode",
1530
+ "zeroableOptionTypeNode"
1531
+ ];
1532
+ var standaloneTypeNodeUnion = defineUnion("StandaloneTypeNode", {
1533
+ docs: "Every type node that can be used as a top-level type.",
1534
+ members: [...STANDALONE_TYPE_NODE_KINDS]
1535
+ });
1536
+ var enumVariantTypeNodeUnion = defineUnion("EnumVariantTypeNode", {
1537
+ docs: "The variant flavours of an `enumTypeNode`.",
1538
+ members: ["enumEmptyVariantTypeNode", "enumStructVariantTypeNode", "enumTupleVariantTypeNode"]
1539
+ });
1540
+ var typeNodeUnion = defineUnion("TypeNode", {
1541
+ docs: "The composable form: any standalone type, or a reference to a defined type via `definedTypeLinkNode`.",
1542
+ members: [union("StandaloneTypeNode"), "definedTypeLinkNode"]
1543
+ });
1544
+ var registeredTypeNodeUnion = defineUnion("RegisteredTypeNode", {
1545
+ docs: "Every node tagged as a type-shaped node, including variants and struct fields.",
1546
+ members: [union("StandaloneTypeNode"), union("EnumVariantTypeNode"), "structFieldTypeNode"]
1547
+ });
1548
+
1549
+ // src/v1/nodes/typeNodes/ZeroableOptionTypeNode.ts
1550
+ var zeroableOptionTypeNode = defineNode("zeroableOptionTypeNode", {
1551
+ docs: "An optional value whose absence is signalled by a designated zero value rather than a presence flag.",
1552
+ attributes: [
1553
+ attribute("item", union("TypeNode"), {
1554
+ docs: "The type carried by the option when present."
1555
+ }),
1556
+ optionalAttribute("zeroValue", node("constantValueNode"), {
1557
+ docs: "The constant value that signals absence. When omitted, the all-zero byte pattern of the item type is used."
1558
+ })
1559
+ ]
1560
+ });
1561
+
1562
+ // src/v1/nodes/typeNodes/index.ts
1563
+ var ALL_TYPE_NODES = [
1564
+ amountTypeNode,
1565
+ arrayTypeNode,
1566
+ booleanTypeNode,
1567
+ bytesTypeNode,
1568
+ dateTimeTypeNode,
1569
+ enumEmptyVariantTypeNode,
1570
+ enumStructVariantTypeNode,
1571
+ enumTupleVariantTypeNode,
1572
+ enumTypeNode,
1573
+ fixedSizeTypeNode,
1574
+ hiddenPrefixTypeNode,
1575
+ hiddenSuffixTypeNode,
1576
+ mapTypeNode,
1577
+ numberTypeNode,
1578
+ optionTypeNode,
1579
+ postOffsetTypeNode,
1580
+ preOffsetTypeNode,
1581
+ publicKeyTypeNode,
1582
+ remainderOptionTypeNode,
1583
+ sentinelTypeNode,
1584
+ setTypeNode,
1585
+ sizePrefixTypeNode,
1586
+ solAmountTypeNode,
1587
+ stringTypeNode,
1588
+ structFieldTypeNode,
1589
+ structTypeNode,
1590
+ tupleTypeNode,
1591
+ zeroableOptionTypeNode
1592
+ ];
1593
+ var ALL_TYPE_NODE_UNIONS = [
1594
+ standaloneTypeNodeUnion,
1595
+ enumVariantTypeNodeUnion,
1596
+ typeNodeUnion,
1597
+ registeredTypeNodeUnion
1598
+ ];
1599
+
1600
+ // src/v1/nodes/valueNodes/ArrayValueNode.ts
1601
+ var arrayValueNode = defineNode("arrayValueNode", {
1602
+ docs: "A concrete array value: a list of value nodes.",
1603
+ attributes: [
1604
+ attribute("items", array(union("ValueNode")), {
1605
+ docs: "The items of the array, in order."
1606
+ })
1607
+ ]
1608
+ });
1609
+
1610
+ // src/v1/nodes/valueNodes/BooleanValueNode.ts
1611
+ var booleanValueNode = defineNode("booleanValueNode", {
1612
+ docs: "A concrete boolean value.",
1613
+ attributes: [
1614
+ attribute("boolean", boolean(), {
1615
+ docs: "The boolean value."
1616
+ })
1617
+ ]
1618
+ });
1619
+
1620
+ // src/v1/nodes/valueNodes/BytesValueNode.ts
1621
+ var bytesValueNode = defineNode("bytesValueNode", {
1622
+ docs: "A concrete bytes value, encoded as text in the chosen encoding.",
1623
+ attributes: [
1624
+ attribute("data", string(), {
1625
+ docs: "The bytes encoded as a text string per the `encoding` attribute."
1626
+ }),
1627
+ attribute("encoding", enumeration("BytesEncoding"), {
1628
+ docs: "The encoding used to represent the bytes as text."
1629
+ })
1630
+ ]
1631
+ });
1632
+
1633
+ // src/v1/nodes/valueNodes/ConstantValueNode.ts
1634
+ var constantValueNode = defineNode("constantValueNode", {
1635
+ docs: "A typed constant: a type node paired with a concrete value node.",
1636
+ attributes: [
1637
+ attribute("type", union("TypeNode"), {
1638
+ docs: "The type of the constant."
1639
+ }),
1640
+ attribute("value", union("ValueNode"), {
1641
+ docs: "The concrete value of the constant."
1642
+ })
1643
+ ]
1644
+ });
1645
+
1646
+ // src/v1/nodes/valueNodes/EnumValueNode.ts
1647
+ var enumValueNode = defineNode("enumValueNode", {
1648
+ docs: "A concrete value of a defined enum: a variant identifier plus an optional payload.",
1649
+ attributes: [
1650
+ attribute("variant", stringIdentifier(), {
1651
+ docs: "The name of the selected variant."
1652
+ }),
1653
+ attribute("enum", node("definedTypeLinkNode"), {
1654
+ docs: "A link to the defined enum type the value belongs to."
1655
+ }),
1656
+ optionalAttribute("value", union("EnumValuePayload"), {
1657
+ docs: "The variant payload \u2014 a struct value for struct variants or a tuple value for tuple variants. Omitted for unit variants."
1658
+ })
1659
+ ]
1660
+ });
1661
+
1662
+ // src/v1/nodes/valueNodes/MapEntryValueNode.ts
1663
+ var mapEntryValueNode = defineNode("mapEntryValueNode", {
1664
+ docs: "A single (key, value) pair inside a `mapValueNode`.",
1665
+ attributes: [
1666
+ attribute("key", union("ValueNode"), {
1667
+ docs: "The entry key."
1668
+ }),
1669
+ attribute("value", union("ValueNode"), {
1670
+ docs: "The entry value."
1671
+ })
1672
+ ]
1673
+ });
1674
+
1675
+ // src/v1/nodes/valueNodes/MapValueNode.ts
1676
+ var mapValueNode = defineNode("mapValueNode", {
1677
+ docs: "A concrete map value: a list of (key, value) entries.",
1678
+ attributes: [
1679
+ attribute("entries", array(node("mapEntryValueNode")), {
1680
+ docs: "The entries of the map, in order."
1681
+ })
1682
+ ]
1683
+ });
1684
+
1685
+ // src/v1/nodes/valueNodes/NoneValueNode.ts
1686
+ var noneValueNode = defineNode("noneValueNode", {
1687
+ docs: 'The "absent" value for an optional type.',
1688
+ attributes: []
1689
+ });
1690
+
1691
+ // src/v1/nodes/valueNodes/NumberValueNode.ts
1692
+ var numberValueNode = defineNode("numberValueNode", {
1693
+ docs: "A concrete numeric value. Stored as a 64-bit float; consumers narrow to a specific integer or float width based on the surrounding type context.",
1694
+ attributes: [
1695
+ attribute("number", f64(), {
1696
+ docs: "The numeric value."
1697
+ })
1698
+ ]
1699
+ });
1700
+
1701
+ // src/v1/nodes/valueNodes/PublicKeyValueNode.ts
1702
+ var publicKeyValueNode = defineNode("publicKeyValueNode", {
1703
+ docs: "A concrete public key, with an optional symbolic identifier for the address.",
1704
+ attributes: [
1705
+ attribute("publicKey", string(), {
1706
+ docs: "The base58-encoded public key."
1707
+ }),
1708
+ optionalAttribute("identifier", stringIdentifier(), {
1709
+ docs: "A symbolic name for the address, useful in generated client code."
1710
+ })
1711
+ ]
1712
+ });
1713
+
1714
+ // src/v1/nodes/valueNodes/SetValueNode.ts
1715
+ var setValueNode = defineNode("setValueNode", {
1716
+ docs: "A concrete set value: a list of unique value nodes.",
1717
+ attributes: [
1718
+ attribute("items", array(union("ValueNode")), {
1719
+ docs: "The items of the set."
1720
+ })
1721
+ ]
1722
+ });
1723
+
1724
+ // src/v1/nodes/valueNodes/SomeValueNode.ts
1725
+ var someValueNode = defineNode("someValueNode", {
1726
+ docs: 'The "present" value for an optional type, wrapping a concrete value node.',
1727
+ attributes: [
1728
+ attribute("value", union("ValueNode"), {
1729
+ docs: "The wrapped value."
1730
+ })
1731
+ ]
1732
+ });
1733
+
1734
+ // src/v1/nodes/valueNodes/StringValueNode.ts
1735
+ var stringValueNode = defineNode("stringValueNode", {
1736
+ docs: "A concrete string value.",
1737
+ attributes: [
1738
+ attribute("string", string(), {
1739
+ docs: "The string value."
1740
+ })
1741
+ ]
1742
+ });
1743
+
1744
+ // src/v1/nodes/valueNodes/StructFieldValueNode.ts
1745
+ var structFieldValueNode = defineNode("structFieldValueNode", {
1746
+ docs: "A named field of a `structValueNode`.",
1747
+ attributes: [
1748
+ attribute("name", stringIdentifier(), {
1749
+ docs: "The name of the field."
1750
+ }),
1751
+ attribute("value", union("ValueNode"), {
1752
+ docs: "The concrete value of the field."
1753
+ })
1754
+ ]
1755
+ });
1756
+
1757
+ // src/v1/nodes/valueNodes/StructValueNode.ts
1758
+ var structValueNode = defineNode("structValueNode", {
1759
+ docs: "A concrete struct value: a list of named field values.",
1760
+ attributes: [
1761
+ attribute("fields", array(node("structFieldValueNode")), {
1762
+ docs: "The named fields of the struct value."
1763
+ })
1764
+ ]
1765
+ });
1766
+
1767
+ // src/v1/nodes/valueNodes/TupleValueNode.ts
1768
+ var tupleValueNode = defineNode("tupleValueNode", {
1769
+ docs: "A concrete tuple value: a fixed-length sequence of positional value nodes.",
1770
+ attributes: [
1771
+ attribute("items", array(union("ValueNode")), {
1772
+ docs: "The positional items of the tuple, in order."
1773
+ })
1774
+ ]
1775
+ });
1776
+
1777
+ // src/v1/nodes/valueNodes/ValueNode.ts
1778
+ var STANDALONE_VALUE_NODE_KINDS = [
1779
+ "arrayValueNode",
1780
+ "booleanValueNode",
1781
+ "bytesValueNode",
1782
+ "constantValueNode",
1783
+ "enumValueNode",
1784
+ "mapValueNode",
1785
+ "noneValueNode",
1786
+ "numberValueNode",
1787
+ "publicKeyValueNode",
1788
+ "setValueNode",
1789
+ "someValueNode",
1790
+ "stringValueNode",
1791
+ "structValueNode",
1792
+ "tupleValueNode"
1793
+ ];
1794
+ var standaloneValueNodeUnion = defineUnion("StandaloneValueNode", {
1795
+ docs: "Every value node that can be used as a top-level value.",
1796
+ members: [...STANDALONE_VALUE_NODE_KINDS]
1797
+ });
1798
+ var valueNodeUnion = defineUnion("ValueNode", {
1799
+ docs: "The composable form: any standalone value node.",
1800
+ members: [union("StandaloneValueNode")]
1801
+ });
1802
+ var registeredValueNodeUnion = defineUnion("RegisteredValueNode", {
1803
+ docs: "Every node tagged as a value-shaped node, including container variants.",
1804
+ members: [union("StandaloneValueNode"), "mapEntryValueNode", "structFieldValueNode"]
1805
+ });
1806
+ var enumValuePayloadUnion = defineUnion("EnumValuePayload", {
1807
+ docs: "The payload kinds an `enumValueNode` may carry \u2014 struct fields or positional tuple slots.",
1808
+ members: ["structValueNode", "tupleValueNode"]
1809
+ });
1810
+
1811
+ // src/v1/nodes/valueNodes/index.ts
1812
+ var ALL_VALUE_NODES = [
1813
+ arrayValueNode,
1814
+ booleanValueNode,
1815
+ bytesValueNode,
1816
+ constantValueNode,
1817
+ enumValueNode,
1818
+ mapEntryValueNode,
1819
+ mapValueNode,
1820
+ noneValueNode,
1821
+ numberValueNode,
1822
+ publicKeyValueNode,
1823
+ setValueNode,
1824
+ someValueNode,
1825
+ stringValueNode,
1826
+ structFieldValueNode,
1827
+ structValueNode,
1828
+ tupleValueNode
1829
+ ];
1830
+ var ALL_VALUE_NODE_UNIONS = [
1831
+ standaloneValueNodeUnion,
1832
+ valueNodeUnion,
1833
+ registeredValueNodeUnion,
1834
+ enumValuePayloadUnion
1835
+ ];
1836
+
1837
+ // src/v1/nodes/index.ts
1838
+ var ALL_NODES = [
1839
+ ...ALL_TYPE_NODES,
1840
+ ...ALL_VALUE_NODES,
1841
+ ...ALL_LINK_NODES,
1842
+ ...ALL_PDA_SEED_NODES,
1843
+ ...ALL_COUNT_NODES,
1844
+ ...ALL_DISCRIMINATOR_NODES,
1845
+ ...ALL_CONTEXTUAL_VALUE_NODES,
1846
+ // Top-level nodes — directly under `nodes/`, no subdirectory.
1847
+ accountNode,
1848
+ constantNode,
1849
+ definedTypeNode,
1850
+ errorNode,
1851
+ eventNode,
1852
+ instructionAccountNode,
1853
+ instructionArgumentNode,
1854
+ instructionByteDeltaNode,
1855
+ instructionNode,
1856
+ instructionRemainingAccountsNode,
1857
+ instructionStatusNode,
1858
+ pdaNode,
1859
+ programNode,
1860
+ rootNode
1861
+ ];
1862
+ var ALL_UNIONS = [
1863
+ ...ALL_TYPE_NODE_UNIONS,
1864
+ ...ALL_VALUE_NODE_UNIONS,
1865
+ ...ALL_LINK_NODE_UNIONS,
1866
+ ...ALL_PDA_SEED_NODE_UNIONS,
1867
+ ...ALL_COUNT_NODE_UNIONS,
1868
+ ...ALL_DISCRIMINATOR_NODE_UNIONS,
1869
+ ...ALL_CONTEXTUAL_VALUE_NODE_UNIONS,
1870
+ // Inline-helper unions used by instruction-shaped nodes.
1871
+ instructionByteDeltaValueUnion,
1872
+ instructionRemainingAccountsValueUnion
1873
+ ];
1874
+
1875
+ // src/v1/index.ts
1876
+ var SPEC_VERSION = "1.6.0";
1877
+ var cached;
1878
+ function getSpec() {
1879
+ if (cached) return cached;
1880
+ const built = {
1881
+ version: SPEC_VERSION,
1882
+ enumerations: ALL_ENUMERATIONS,
1883
+ nodes: ALL_NODES,
1884
+ unions: ALL_UNIONS,
1885
+ nestedTypeNodeWrappers: NESTED_TYPE_NODE_WRAPPERS
1886
+ };
1887
+ const errors = validate(built);
1888
+ if (errors.length > 0) {
1889
+ throw new Error(`Invalid Codama v1 spec:
1890
+ ${errors.map((e) => ` - ${e}`).join("\n")}`);
1891
+ }
1892
+ cached = built;
1893
+ return cached;
1894
+ }
1895
+ function getNode(kind) {
1896
+ return getSpec().nodes.find((n) => n.kind === kind);
1897
+ }
1898
+ function getUnion(name) {
1899
+ return getSpec().unions.find((u) => u.name === name);
1900
+ }
1901
+ function getEnumeration(name) {
1902
+ return getSpec().enumerations.find((e) => e.name === name);
1903
+ }
1904
+
1905
+ export { SPEC_VERSION, getEnumeration, getNode, getSpec, getUnion, isChildAttribute };
2
1906
  //# sourceMappingURL=index.browser.mjs.map
3
1907
  //# sourceMappingURL=index.browser.mjs.map