@thru/programs 0.2.29 → 0.2.31

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (42) hide show
  1. package/dist/amm/index.cjs +6424 -0
  2. package/dist/amm/index.cjs.map +1 -0
  3. package/dist/amm/index.d.cts +1424 -0
  4. package/dist/amm/index.d.ts +1424 -0
  5. package/dist/amm/index.js +6360 -0
  6. package/dist/amm/index.js.map +1 -0
  7. package/dist/chunk-P5OABVJI.js +28 -0
  8. package/dist/chunk-P5OABVJI.js.map +1 -0
  9. package/dist/multicall/index.cjs +1 -1
  10. package/dist/multicall/index.cjs.map +1 -1
  11. package/dist/multicall/index.d.cts +2 -2
  12. package/dist/multicall/index.d.ts +2 -2
  13. package/dist/multicall/index.js +1 -1
  14. package/dist/multicall/index.js.map +1 -1
  15. package/dist/passkey-manager/index.cjs +33 -27
  16. package/dist/passkey-manager/index.cjs.map +1 -1
  17. package/dist/passkey-manager/index.d.cts +4 -3
  18. package/dist/passkey-manager/index.d.ts +4 -3
  19. package/dist/passkey-manager/index.js +9 -28
  20. package/dist/passkey-manager/index.js.map +1 -1
  21. package/dist/token/index.cjs +1760 -275
  22. package/dist/token/index.cjs.map +1 -1
  23. package/dist/token/index.d.cts +124 -20
  24. package/dist/token/index.d.ts +124 -20
  25. package/dist/token/index.js +1760 -275
  26. package/dist/token/index.js.map +1 -1
  27. package/package.json +9 -2
  28. package/src/amm/abi/thru/common/primitives/types.ts +2269 -0
  29. package/src/amm/abi/thru/program/amm/types.ts +5621 -0
  30. package/src/amm/index.test.ts +255 -0
  31. package/src/amm/index.ts +434 -0
  32. package/src/helpers/bytes.ts +25 -0
  33. package/src/multicall/abi/thru/common/primitives/types.ts +5 -6
  34. package/src/multicall/abi/thru/program/multicall/types.ts +1 -2
  35. package/src/passkey-manager/abi/thru/blockchain/state_proof/types.ts +0 -1
  36. package/src/passkey-manager/abi/thru/common/primitives/types.ts +0 -1
  37. package/src/passkey-manager/abi/thru/program/passkey_manager/types.ts +4 -5
  38. package/src/passkey-manager/encoding.ts +2 -26
  39. package/src/token/abi/thru/blockchain/state_proof/types.ts +101 -21
  40. package/src/token/abi/thru/common/primitives/types.ts +1295 -167
  41. package/src/token/abi/thru/program/token/types.ts +647 -237
  42. package/tsup.config.ts +1 -0
@@ -33,6 +33,12 @@ type __TnIrNode =
33
33
  readonly op: "call";
34
34
  readonly typeName: string;
35
35
  readonly args: readonly { readonly name: string; readonly source: string }[];
36
+ }
37
+ | {
38
+ readonly op: "sumOverArray";
39
+ readonly count: __TnIrNode;
40
+ readonly elementTypeName: string;
41
+ readonly fieldName: string;
36
42
  };
37
43
 
38
44
  type __TnIrContext = {
@@ -41,7 +47,12 @@ type __TnIrContext = {
41
47
  typeName?: string;
42
48
  };
43
49
 
44
- type __TnValidateResult = { ok: boolean; code?: string; consumed?: bigint };
50
+ type __TnValidateResult = {
51
+ ok: boolean;
52
+ code?: string;
53
+ consumed?: bigint;
54
+ params?: Record<string, bigint>;
55
+ };
45
56
  type __TnEvalResult =
46
57
  | { ok: true; value: bigint }
47
58
  | { ok: false; code: string };
@@ -518,6 +529,10 @@ const __tnValidateRegistry: Record<
518
529
  string,
519
530
  (buffer: Uint8Array, params: Record<string, bigint>) => __TnValidateResult
520
531
  > = {};
532
+ const __tnDynamicValidateRegistry: Record<
533
+ string,
534
+ (buffer: Uint8Array) => __TnValidateResult
535
+ > = {};
521
536
 
522
537
  function __tnRegisterFootprint(
523
538
  typeName: string,
@@ -533,6 +548,13 @@ function __tnRegisterValidate(
533
548
  __tnValidateRegistry[typeName] = fn;
534
549
  }
535
550
 
551
+ function __tnRegisterDynamicValidate(
552
+ typeName: string,
553
+ fn: (buffer: Uint8Array) => __TnValidateResult
554
+ ): void {
555
+ __tnDynamicValidateRegistry[typeName] = fn;
556
+ }
557
+
536
558
  function __tnInvokeFootprint(
537
559
  typeName: string,
538
560
  params: Record<string, bigint>
@@ -552,8 +574,17 @@ function __tnInvokeValidate(
552
574
  return fn(buffer, params);
553
575
  }
554
576
 
577
+ function __tnInvokeDynamicValidate(
578
+ typeName: string,
579
+ buffer: Uint8Array
580
+ ): __TnValidateResult {
581
+ const fn = __tnDynamicValidateRegistry[typeName];
582
+ if (!fn) throw new Error(`IR runtime missing dynamic validate helper for ${typeName}`);
583
+ return fn(buffer);
584
+ }
585
+
555
586
  function __tnEvalFootprint(node: __TnIrNode, ctx: __TnIrContext): bigint {
556
- return __tnEvalIrNode(node, ctx);
587
+ return __tnEvalIrNode(node, ctx, __tnToBigInt(0));
557
588
  }
558
589
 
559
590
  function __tnTryEvalFootprint(
@@ -568,7 +599,7 @@ function __tnTryEvalIr(
568
599
  ctx: __TnIrContext
569
600
  ): __TnEvalResult {
570
601
  try {
571
- return { ok: true, value: __tnEvalIrNode(node, ctx) };
602
+ return { ok: true, value: __tnEvalIrNode(node, ctx, __tnToBigInt(0)) };
572
603
  } catch (err) {
573
604
  return { ok: false, code: __tnNormalizeIrError(err) };
574
605
  }
@@ -599,7 +630,11 @@ function __tnValidateIrTree(
599
630
  return { ok: true, consumed: required };
600
631
  }
601
632
 
602
- function __tnEvalIrNode(node: __TnIrNode, ctx: __TnIrContext): bigint {
633
+ function __tnEvalIrNode(
634
+ node: __TnIrNode,
635
+ ctx: __TnIrContext,
636
+ baseOffset: bigint
637
+ ): bigint {
603
638
  switch (node.op) {
604
639
  case "zero":
605
640
  return __tnToBigInt(0);
@@ -617,17 +652,22 @@ function __tnEvalIrNode(node: __TnIrNode, ctx: __TnIrContext): bigint {
617
652
  return val;
618
653
  }
619
654
  case "add":
620
- return __tnCheckedAdd(
621
- __tnEvalIrNode(node.left, ctx),
622
- __tnEvalIrNode(node.right, ctx)
623
- );
655
+ {
656
+ const left = __tnEvalIrNode(node.left, ctx, baseOffset);
657
+ const right = __tnEvalIrNode(
658
+ node.right,
659
+ ctx,
660
+ __tnCheckedAdd(baseOffset, left)
661
+ );
662
+ return __tnCheckedAdd(left, right);
663
+ }
624
664
  case "mul":
625
665
  return __tnCheckedMul(
626
- __tnEvalIrNode(node.left, ctx),
627
- __tnEvalIrNode(node.right, ctx)
666
+ __tnEvalIrNode(node.left, ctx, baseOffset),
667
+ __tnEvalIrNode(node.right, ctx, baseOffset)
628
668
  );
629
669
  case "align":
630
- return __tnAlign(__tnEvalIrNode(node.node, ctx), node.alignment);
670
+ return __tnAlign(__tnEvalIrNode(node.node, ctx, baseOffset), node.alignment);
631
671
  case "switch": {
632
672
  const tagVal = ctx.params[node.tag];
633
673
  if (tagVal === undefined) {
@@ -640,10 +680,10 @@ function __tnEvalIrNode(node: __TnIrNode, ctx: __TnIrContext): bigint {
640
680
  const tagNumber = Number(tagVal);
641
681
  for (const caseNode of node.cases) {
642
682
  if (caseNode.value === tagNumber) {
643
- return __tnEvalIrNode(caseNode.node, ctx);
683
+ return __tnEvalIrNode(caseNode.node, ctx, baseOffset);
644
684
  }
645
685
  }
646
- if (node.default) return __tnEvalIrNode(node.default, ctx);
686
+ if (node.default) return __tnEvalIrNode(node.default, ctx, baseOffset);
647
687
  __tnRaiseIrError(
648
688
  "tn.ir.invalid_tag",
649
689
  `Unhandled IR switch value ${tagNumber} for '${node.tag}'`
@@ -663,9 +703,10 @@ function __tnEvalIrNode(node: __TnIrNode, ctx: __TnIrContext): bigint {
663
703
  nestedParams[arg.name] = val;
664
704
  }
665
705
  if (ctx.buffer) {
706
+ const nestedOffset = __tnBigIntToNumber(baseOffset, "IR nested offset");
666
707
  const nestedResult = __tnInvokeValidate(
667
708
  node.typeName,
668
- ctx.buffer,
709
+ ctx.buffer.subarray(nestedOffset),
669
710
  nestedParams
670
711
  );
671
712
  if (!nestedResult.ok) {
@@ -685,6 +726,36 @@ function __tnEvalIrNode(node: __TnIrNode, ctx: __TnIrContext): bigint {
685
726
  }
686
727
  return __tnInvokeFootprint(node.typeName, nestedParams);
687
728
  }
729
+ case "sumOverArray": {
730
+ if (!ctx.buffer) {
731
+ __tnRaiseIrError(
732
+ "tn.ir.missing_buffer",
733
+ `Jagged array '${node.fieldName}' requires buffer-backed validation`
734
+ );
735
+ }
736
+ const count = __tnBigIntToNumber(
737
+ __tnEvalIrNode(node.count, ctx, baseOffset),
738
+ `Jagged array '${node.fieldName}' count`
739
+ );
740
+ let cursor = __tnBigIntToNumber(baseOffset, "IR jagged array offset");
741
+ let total = __tnToBigInt(0);
742
+ for (let i = 0; i < count; i++) {
743
+ const result = __tnInvokeDynamicValidate(
744
+ node.elementTypeName,
745
+ ctx.buffer.subarray(cursor)
746
+ );
747
+ if (!result.ok || result.consumed === undefined) {
748
+ const code = result.code ?? "tn.ir.runtime_error";
749
+ __tnRaiseIrError(
750
+ code,
751
+ `Jagged array '${node.fieldName}' element ${i} failed validation`
752
+ );
753
+ }
754
+ cursor += __tnBigIntToNumber(result.consumed, "IR jagged element size");
755
+ total = __tnCheckedAdd(total, result.consumed);
756
+ }
757
+ return total;
758
+ }
688
759
  default:
689
760
  __tnRaiseIrError(
690
761
  "tn.ir.runtime_error",
@@ -719,6 +790,14 @@ function __tnNormalizeIrError(err: unknown): string {
719
790
  return "tn.ir.runtime_error";
720
791
  }
721
792
 
793
+ __tnRegisterFootprint("Pubkey", (params) => Pubkey.__tnInvokeFootprint(params));
794
+ __tnRegisterValidate("Pubkey", (buffer, params) => Pubkey.__tnInvokeValidate(buffer, params));
795
+ __tnRegisterDynamicValidate("Pubkey", (buffer) => { const result = Pubkey.validate(buffer); const params = (result as { params?: Record<string, bigint> }).params; return { ok: result.ok, code: result.code, consumed: result.consumed === undefined ? undefined : __tnToBigInt(result.consumed), params }; });
796
+
797
+ __tnRegisterFootprint("StateProof", (params) => StateProof.__tnInvokeFootprint(params));
798
+ __tnRegisterValidate("StateProof", (buffer, params) => StateProof.__tnInvokeValidate(buffer, params));
799
+ __tnRegisterDynamicValidate("StateProof", (buffer) => { const result = StateProof.validate(buffer); const params = (result as { params?: Record<string, bigint> }).params; return { ok: result.ok, code: result.code, consumed: result.consumed === undefined ? undefined : __tnToBigInt(result.consumed), params }; });
800
+
722
801
  /* ----- TYPE DEFINITION FOR BurnInstruction ----- */
723
802
 
724
803
  const __tn_ir_BurnInstruction = {
@@ -880,9 +959,6 @@ export class BurnInstruction {
880
959
 
881
960
  }
882
961
 
883
- __tnRegisterFootprint("BurnInstruction", (params) => BurnInstruction.__tnInvokeFootprint(params));
884
- __tnRegisterValidate("BurnInstruction", (buffer, params) => BurnInstruction.__tnInvokeValidate(buffer, params));
885
-
886
962
  export class BurnInstructionBuilder {
887
963
  private buffer: Uint8Array;
888
964
  private view: DataView;
@@ -907,7 +983,7 @@ export class BurnInstructionBuilder {
907
983
  return this;
908
984
  }
909
985
 
910
- set_amount(value: number): this {
986
+ set_amount(value: bigint): this {
911
987
  const cast = __tnToBigInt(value);
912
988
  this.view.setBigUint64(6, cast, true);
913
989
  return this;
@@ -930,6 +1006,10 @@ export class BurnInstructionBuilder {
930
1006
  }
931
1007
  }
932
1008
 
1009
+ __tnRegisterFootprint("BurnInstruction", (params) => BurnInstruction.__tnInvokeFootprint(params));
1010
+ __tnRegisterValidate("BurnInstruction", (buffer, params) => BurnInstruction.__tnInvokeValidate(buffer, params));
1011
+ __tnRegisterDynamicValidate("BurnInstruction", (buffer) => { const result = BurnInstruction.validate(buffer); const params = (result as { params?: Record<string, bigint> }).params; return { ok: result.ok, code: result.code, consumed: result.consumed === undefined ? undefined : __tnToBigInt(result.consumed), params }; });
1012
+
933
1013
  /* ----- TYPE DEFINITION FOR CloseAccountInstruction ----- */
934
1014
 
935
1015
  const __tn_ir_CloseAccountInstruction = {
@@ -1072,9 +1152,6 @@ export class CloseAccountInstruction {
1072
1152
 
1073
1153
  }
1074
1154
 
1075
- __tnRegisterFootprint("CloseAccountInstruction", (params) => CloseAccountInstruction.__tnInvokeFootprint(params));
1076
- __tnRegisterValidate("CloseAccountInstruction", (buffer, params) => CloseAccountInstruction.__tnInvokeValidate(buffer, params));
1077
-
1078
1155
  export class CloseAccountInstructionBuilder {
1079
1156
  private buffer: Uint8Array;
1080
1157
  private view: DataView;
@@ -1116,6 +1193,10 @@ export class CloseAccountInstructionBuilder {
1116
1193
  }
1117
1194
  }
1118
1195
 
1196
+ __tnRegisterFootprint("CloseAccountInstruction", (params) => CloseAccountInstruction.__tnInvokeFootprint(params));
1197
+ __tnRegisterValidate("CloseAccountInstruction", (buffer, params) => CloseAccountInstruction.__tnInvokeValidate(buffer, params));
1198
+ __tnRegisterDynamicValidate("CloseAccountInstruction", (buffer) => { const result = CloseAccountInstruction.validate(buffer); const params = (result as { params?: Record<string, bigint> }).params; return { ok: result.ok, code: result.code, consumed: result.consumed === undefined ? undefined : __tnToBigInt(result.consumed), params }; });
1199
+
1119
1200
  /* ----- TYPE DEFINITION FOR FreezeAccountInstruction ----- */
1120
1201
 
1121
1202
  const __tn_ir_FreezeAccountInstruction = {
@@ -1258,9 +1339,6 @@ export class FreezeAccountInstruction {
1258
1339
 
1259
1340
  }
1260
1341
 
1261
- __tnRegisterFootprint("FreezeAccountInstruction", (params) => FreezeAccountInstruction.__tnInvokeFootprint(params));
1262
- __tnRegisterValidate("FreezeAccountInstruction", (buffer, params) => FreezeAccountInstruction.__tnInvokeValidate(buffer, params));
1263
-
1264
1342
  export class FreezeAccountInstructionBuilder {
1265
1343
  private buffer: Uint8Array;
1266
1344
  private view: DataView;
@@ -1302,6 +1380,10 @@ export class FreezeAccountInstructionBuilder {
1302
1380
  }
1303
1381
  }
1304
1382
 
1383
+ __tnRegisterFootprint("FreezeAccountInstruction", (params) => FreezeAccountInstruction.__tnInvokeFootprint(params));
1384
+ __tnRegisterValidate("FreezeAccountInstruction", (buffer, params) => FreezeAccountInstruction.__tnInvokeValidate(buffer, params));
1385
+ __tnRegisterDynamicValidate("FreezeAccountInstruction", (buffer) => { const result = FreezeAccountInstruction.validate(buffer); const params = (result as { params?: Record<string, bigint> }).params; return { ok: result.ok, code: result.code, consumed: result.consumed === undefined ? undefined : __tnToBigInt(result.consumed), params }; });
1386
+
1305
1387
  /* ----- TYPE DEFINITION FOR MintToInstruction ----- */
1306
1388
 
1307
1389
  const __tn_ir_MintToInstruction = {
@@ -1463,9 +1545,6 @@ export class MintToInstruction {
1463
1545
 
1464
1546
  }
1465
1547
 
1466
- __tnRegisterFootprint("MintToInstruction", (params) => MintToInstruction.__tnInvokeFootprint(params));
1467
- __tnRegisterValidate("MintToInstruction", (buffer, params) => MintToInstruction.__tnInvokeValidate(buffer, params));
1468
-
1469
1548
  export class MintToInstructionBuilder {
1470
1549
  private buffer: Uint8Array;
1471
1550
  private view: DataView;
@@ -1490,7 +1569,7 @@ export class MintToInstructionBuilder {
1490
1569
  return this;
1491
1570
  }
1492
1571
 
1493
- set_amount(value: number): this {
1572
+ set_amount(value: bigint): this {
1494
1573
  const cast = __tnToBigInt(value);
1495
1574
  this.view.setBigUint64(6, cast, true);
1496
1575
  return this;
@@ -1513,6 +1592,10 @@ export class MintToInstructionBuilder {
1513
1592
  }
1514
1593
  }
1515
1594
 
1595
+ __tnRegisterFootprint("MintToInstruction", (params) => MintToInstruction.__tnInvokeFootprint(params));
1596
+ __tnRegisterValidate("MintToInstruction", (buffer, params) => MintToInstruction.__tnInvokeValidate(buffer, params));
1597
+ __tnRegisterDynamicValidate("MintToInstruction", (buffer) => { const result = MintToInstruction.validate(buffer); const params = (result as { params?: Record<string, bigint> }).params; return { ok: result.ok, code: result.code, consumed: result.consumed === undefined ? undefined : __tnToBigInt(result.consumed), params }; });
1598
+
1516
1599
  /* ----- TYPE DEFINITION FOR Seed32 ----- */
1517
1600
 
1518
1601
  const __tn_ir_Seed32 = {
@@ -1610,6 +1693,7 @@ export class Seed32 {
1610
1693
 
1611
1694
  __tnRegisterFootprint("Seed32", (params) => Seed32.__tnInvokeFootprint(params));
1612
1695
  __tnRegisterValidate("Seed32", (buffer, params) => Seed32.__tnInvokeValidate(buffer, params));
1696
+ __tnRegisterDynamicValidate("Seed32", (buffer) => { const result = Seed32.validate(buffer); const params = (result as { params?: Record<string, bigint> }).params; return { ok: result.ok, code: result.code, consumed: result.consumed === undefined ? undefined : __tnToBigInt(result.consumed), params }; });
1613
1697
 
1614
1698
  /* ----- TYPE DEFINITION FOR ThawAccountEventData ----- */
1615
1699
 
@@ -1750,9 +1834,6 @@ export class ThawAccountEventData {
1750
1834
 
1751
1835
  }
1752
1836
 
1753
- __tnRegisterFootprint("ThawAccountEventData", (params) => ThawAccountEventData.__tnInvokeFootprint(params));
1754
- __tnRegisterValidate("ThawAccountEventData", (buffer, params) => ThawAccountEventData.__tnInvokeValidate(buffer, params));
1755
-
1756
1837
  export class ThawAccountEventDataBuilder {
1757
1838
  private buffer: Uint8Array;
1758
1839
  private view: DataView;
@@ -1797,6 +1878,10 @@ export class ThawAccountEventDataBuilder {
1797
1878
  }
1798
1879
  }
1799
1880
 
1881
+ __tnRegisterFootprint("ThawAccountEventData", (params) => ThawAccountEventData.__tnInvokeFootprint(params));
1882
+ __tnRegisterValidate("ThawAccountEventData", (buffer, params) => ThawAccountEventData.__tnInvokeValidate(buffer, params));
1883
+ __tnRegisterDynamicValidate("ThawAccountEventData", (buffer) => { const result = ThawAccountEventData.validate(buffer); const params = (result as { params?: Record<string, bigint> }).params; return { ok: result.ok, code: result.code, consumed: result.consumed === undefined ? undefined : __tnToBigInt(result.consumed), params }; });
1884
+
1800
1885
  /* ----- TYPE DEFINITION FOR ThawAccountInstruction ----- */
1801
1886
 
1802
1887
  const __tn_ir_ThawAccountInstruction = {
@@ -1939,9 +2024,6 @@ export class ThawAccountInstruction {
1939
2024
 
1940
2025
  }
1941
2026
 
1942
- __tnRegisterFootprint("ThawAccountInstruction", (params) => ThawAccountInstruction.__tnInvokeFootprint(params));
1943
- __tnRegisterValidate("ThawAccountInstruction", (buffer, params) => ThawAccountInstruction.__tnInvokeValidate(buffer, params));
1944
-
1945
2027
  export class ThawAccountInstructionBuilder {
1946
2028
  private buffer: Uint8Array;
1947
2029
  private view: DataView;
@@ -1983,6 +2065,10 @@ export class ThawAccountInstructionBuilder {
1983
2065
  }
1984
2066
  }
1985
2067
 
2068
+ __tnRegisterFootprint("ThawAccountInstruction", (params) => ThawAccountInstruction.__tnInvokeFootprint(params));
2069
+ __tnRegisterValidate("ThawAccountInstruction", (buffer, params) => ThawAccountInstruction.__tnInvokeValidate(buffer, params));
2070
+ __tnRegisterDynamicValidate("ThawAccountInstruction", (buffer) => { const result = ThawAccountInstruction.validate(buffer); const params = (result as { params?: Record<string, bigint> }).params; return { ok: result.ok, code: result.code, consumed: result.consumed === undefined ? undefined : __tnToBigInt(result.consumed), params }; });
2071
+
1986
2072
  /* ----- TYPE DEFINITION FOR TickerField ----- */
1987
2073
 
1988
2074
  const __tn_ir_TickerField = {
@@ -2104,9 +2190,6 @@ export class TickerField {
2104
2190
 
2105
2191
  }
2106
2192
 
2107
- __tnRegisterFootprint("TickerField", (params) => TickerField.__tnInvokeFootprint(params));
2108
- __tnRegisterValidate("TickerField", (buffer, params) => TickerField.__tnInvokeValidate(buffer, params));
2109
-
2110
2193
  export class TickerFieldBuilder {
2111
2194
  private buffer: Uint8Array;
2112
2195
  private view: DataView;
@@ -2147,6 +2230,10 @@ export class TickerFieldBuilder {
2147
2230
  }
2148
2231
  }
2149
2232
 
2233
+ __tnRegisterFootprint("TickerField", (params) => TickerField.__tnInvokeFootprint(params));
2234
+ __tnRegisterValidate("TickerField", (buffer, params) => TickerField.__tnInvokeValidate(buffer, params));
2235
+ __tnRegisterDynamicValidate("TickerField", (buffer) => { const result = TickerField.validate(buffer); const params = (result as { params?: Record<string, bigint> }).params; return { ok: result.ok, code: result.code, consumed: result.consumed === undefined ? undefined : __tnToBigInt(result.consumed), params }; });
2236
+
2150
2237
  /* ----- TYPE DEFINITION FOR TokenAccount ----- */
2151
2238
 
2152
2239
  const __tn_ir_TokenAccount = {
@@ -2301,9 +2388,6 @@ export class TokenAccount {
2301
2388
 
2302
2389
  }
2303
2390
 
2304
- __tnRegisterFootprint("TokenAccount", (params) => TokenAccount.__tnInvokeFootprint(params));
2305
- __tnRegisterValidate("TokenAccount", (buffer, params) => TokenAccount.__tnInvokeValidate(buffer, params));
2306
-
2307
2391
  export class TokenAccountBuilder {
2308
2392
  private buffer: Uint8Array;
2309
2393
  private view: DataView;
@@ -2325,7 +2409,7 @@ export class TokenAccountBuilder {
2325
2409
  return this;
2326
2410
  }
2327
2411
 
2328
- set_amount(value: number): this {
2412
+ set_amount(value: bigint): this {
2329
2413
  const cast = __tnToBigInt(value);
2330
2414
  this.view.setBigUint64(64, cast, true);
2331
2415
  return this;
@@ -2353,6 +2437,10 @@ export class TokenAccountBuilder {
2353
2437
  }
2354
2438
  }
2355
2439
 
2440
+ __tnRegisterFootprint("TokenAccount", (params) => TokenAccount.__tnInvokeFootprint(params));
2441
+ __tnRegisterValidate("TokenAccount", (buffer, params) => TokenAccount.__tnInvokeValidate(buffer, params));
2442
+ __tnRegisterDynamicValidate("TokenAccount", (buffer) => { const result = TokenAccount.validate(buffer); const params = (result as { params?: Record<string, bigint> }).params; return { ok: result.ok, code: result.code, consumed: result.consumed === undefined ? undefined : __tnToBigInt(result.consumed), params }; });
2443
+
2356
2444
  /* ----- TYPE DEFINITION FOR TokenMintAccount ----- */
2357
2445
 
2358
2446
  const __tn_ir_TokenMintAccount = {
@@ -2567,9 +2655,6 @@ export class TokenMintAccount {
2567
2655
 
2568
2656
  }
2569
2657
 
2570
- __tnRegisterFootprint("TokenMintAccount", (params) => TokenMintAccount.__tnInvokeFootprint(params));
2571
- __tnRegisterValidate("TokenMintAccount", (buffer, params) => TokenMintAccount.__tnInvokeValidate(buffer, params));
2572
-
2573
2658
  export class TokenMintAccountBuilder {
2574
2659
  private buffer: Uint8Array;
2575
2660
  private view: DataView;
@@ -2584,7 +2669,7 @@ export class TokenMintAccountBuilder {
2584
2669
  return this;
2585
2670
  }
2586
2671
 
2587
- set_supply(value: number): this {
2672
+ set_supply(value: bigint): this {
2588
2673
  const cast = __tnToBigInt(value);
2589
2674
  this.view.setBigUint64(1, cast, true);
2590
2675
  return this;
@@ -2636,6 +2721,10 @@ export class TokenMintAccountBuilder {
2636
2721
  }
2637
2722
  }
2638
2723
 
2724
+ __tnRegisterFootprint("TokenMintAccount", (params) => TokenMintAccount.__tnInvokeFootprint(params));
2725
+ __tnRegisterValidate("TokenMintAccount", (buffer, params) => TokenMintAccount.__tnInvokeValidate(buffer, params));
2726
+ __tnRegisterDynamicValidate("TokenMintAccount", (buffer) => { const result = TokenMintAccount.validate(buffer); const params = (result as { params?: Record<string, bigint> }).params; return { ok: result.ok, code: result.code, consumed: result.consumed === undefined ? undefined : __tnToBigInt(result.consumed), params }; });
2727
+
2639
2728
  /* ----- TYPE DEFINITION FOR TokenProgramAccount ----- */
2640
2729
 
2641
2730
  const __tn_ir_TokenProgramAccount = {
@@ -2660,7 +2749,7 @@ export class TokenProgramAccount {
2660
2749
  }
2661
2750
  }
2662
2751
 
2663
- static __tnCreateView(buffer: Uint8Array, opts?: { params?: TokenProgramAccount.Params }): TokenProgramAccount {
2752
+ static __tnCreateView(buffer: Uint8Array, opts?: { params?: TokenProgramAccount.Params, fieldContext?: Record<string, number | bigint> }): TokenProgramAccount {
2664
2753
  if (!buffer || buffer.length === undefined) throw new Error("TokenProgramAccount.__tnCreateView requires a Uint8Array");
2665
2754
  let params = opts?.params ?? null;
2666
2755
  if (!params) {
@@ -2680,7 +2769,6 @@ export class TokenProgramAccount {
2680
2769
  static __tnComputeSequentialLayout(view: DataView, buffer: Uint8Array): { params: Record<string, bigint> | null; offsets: Record<string, number> | null; derived: Record<string, bigint> | null } | null {
2681
2770
  const __tnLength = buffer.length;
2682
2771
  let __tnParamSeq_data_payload_size: bigint | null = null;
2683
- let __tnParamSeq_TokenProgramAccount__data_payload_size: bigint | null = null;
2684
2772
  let __tnCursorMutable = 0;
2685
2773
  const __tnSduAvailable_data = __tnLength - __tnCursorMutable;
2686
2774
  let __tnSduSize_data = -1;
@@ -2690,13 +2778,10 @@ export class TokenProgramAccount {
2690
2778
  default: return null;
2691
2779
  }
2692
2780
  __tnParamSeq_data_payload_size = __tnToBigInt(__tnSduSize_data);
2693
- __tnParamSeq_TokenProgramAccount__data_payload_size = __tnToBigInt(__tnSduSize_data);
2694
2781
  __tnCursorMutable += __tnSduSize_data;
2695
2782
  const params: Record<string, bigint> = Object.create(null);
2696
2783
  if (__tnParamSeq_data_payload_size === null) return null;
2697
2784
  params["data_payload_size"] = __tnParamSeq_data_payload_size as bigint;
2698
- if (__tnParamSeq_TokenProgramAccount__data_payload_size === null) return null;
2699
- params["TokenProgramAccount__data_payload_size"] = __tnParamSeq_TokenProgramAccount__data_payload_size as bigint;
2700
2785
  return { params, offsets: null, derived: null };
2701
2786
  }
2702
2787
 
@@ -2706,11 +2791,8 @@ export class TokenProgramAccount {
2706
2791
  const __tnSeqParams = __tnLayout.params;
2707
2792
  const __tnParamSeq_data_payload_size = __tnSeqParams["data_payload_size"];
2708
2793
  if (__tnParamSeq_data_payload_size === undefined) return null;
2709
- const __tnParamSeq_TokenProgramAccount__data_payload_size = __tnSeqParams["TokenProgramAccount__data_payload_size"];
2710
- if (__tnParamSeq_TokenProgramAccount__data_payload_size === undefined) return null;
2711
2794
  const __tnExtractedParams = TokenProgramAccount.Params.fromValues({
2712
2795
  data_payload_size: __tnParamSeq_data_payload_size as bigint,
2713
- TokenProgramAccount__data_payload_size: __tnParamSeq_TokenProgramAccount__data_payload_size as bigint,
2714
2796
  });
2715
2797
  return { params: __tnExtractedParams, derived: null };
2716
2798
  }
@@ -2730,10 +2812,9 @@ export class TokenProgramAccount {
2730
2812
  return this.__tnValidateInternal(buffer, __tnParams);
2731
2813
  }
2732
2814
 
2733
- static footprintIr(data_payload_size: number | bigint, TokenProgramAccount__data_payload_size: number | bigint): bigint {
2815
+ static footprintIr(data_payload_size: number | bigint): bigint {
2734
2816
  const params = TokenProgramAccount.Params.fromValues({
2735
2817
  data_payload_size: data_payload_size,
2736
- TokenProgramAccount__data_payload_size: TokenProgramAccount__data_payload_size,
2737
2818
  });
2738
2819
  return this.footprintIrFromParams(params);
2739
2820
  }
@@ -2741,7 +2822,7 @@ export class TokenProgramAccount {
2741
2822
  private static __tnPackParams(params: TokenProgramAccount.Params): Record<string, bigint> {
2742
2823
  const record: Record<string, bigint> = Object.create(null);
2743
2824
  record["data.payload_size"] = params.data_payload_size;
2744
- record["TokenProgramAccount::data.payload_size"] = params.TokenProgramAccount__data_payload_size;
2825
+ record["TokenProgramAccount::data.payload_size"] = params.data_payload_size;
2745
2826
  return record;
2746
2827
  }
2747
2828
 
@@ -2757,7 +2838,7 @@ export class TokenProgramAccount {
2757
2838
  return __tnBigIntToNumber(irResult, 'TokenProgramAccount::footprintFromParams');
2758
2839
  }
2759
2840
 
2760
- static footprintFromValues(input: { data_payload_size: number | bigint, TokenProgramAccount__data_payload_size: number | bigint }): number {
2841
+ static footprintFromValues(input: { data_payload_size: number | bigint }): number {
2761
2842
  const params = TokenProgramAccount.params(input);
2762
2843
  return this.footprintFromParams(params);
2763
2844
  }
@@ -2813,20 +2894,16 @@ export namespace TokenProgramAccount {
2813
2894
  export type Params = {
2814
2895
  /** ABI path: data.payload_size */
2815
2896
  readonly data_payload_size: bigint;
2816
- /** Runtime payload size (bytes) selecting size-discriminated variant (ABI path: TokenProgramAccount::data.payload_size) */
2817
- readonly TokenProgramAccount__data_payload_size: bigint;
2818
2897
  };
2819
2898
 
2820
2899
  export const ParamKeys = Object.freeze({
2821
2900
  data_payload_size: "data.payload_size",
2822
- TokenProgramAccount__data_payload_size: "TokenProgramAccount::data.payload_size",
2823
2901
  } as const);
2824
2902
 
2825
2903
  export const Params = {
2826
- fromValues(input: { data_payload_size: number | bigint, TokenProgramAccount__data_payload_size: number | bigint }): Params {
2904
+ fromValues(input: { data_payload_size: number | bigint }): Params {
2827
2905
  return {
2828
2906
  data_payload_size: __tnToBigInt(input.data_payload_size),
2829
- TokenProgramAccount__data_payload_size: __tnToBigInt(input.TokenProgramAccount__data_payload_size),
2830
2907
  };
2831
2908
  },
2832
2909
  fromBuilder(source: { dynamicParams(): Params } | { params: Params } | Params): Params {
@@ -2840,13 +2917,14 @@ export namespace TokenProgramAccount {
2840
2917
  }
2841
2918
  };
2842
2919
 
2843
- export function params(input: { data_payload_size: number | bigint, TokenProgramAccount__data_payload_size: number | bigint }): Params {
2920
+ export function params(input: { data_payload_size: number | bigint }): Params {
2844
2921
  return Params.fromValues(input);
2845
2922
  }
2846
2923
  }
2847
2924
 
2848
2925
  __tnRegisterFootprint("TokenProgramAccount", (params) => TokenProgramAccount.__tnInvokeFootprint(params));
2849
2926
  __tnRegisterValidate("TokenProgramAccount", (buffer, params) => TokenProgramAccount.__tnInvokeValidate(buffer, params));
2927
+ __tnRegisterDynamicValidate("TokenProgramAccount", (buffer) => { const result = TokenProgramAccount.validate(buffer); const params = (result as { params?: Record<string, bigint> }).params; return { ok: result.ok, code: result.code, consumed: result.consumed === undefined ? undefined : __tnToBigInt(result.consumed), params }; });
2850
2928
 
2851
2929
  /* ----- TYPE DEFINITION FOR TransferEventData ----- */
2852
2930
 
@@ -3020,9 +3098,6 @@ export class TransferEventData {
3020
3098
 
3021
3099
  }
3022
3100
 
3023
- __tnRegisterFootprint("TransferEventData", (params) => TransferEventData.__tnInvokeFootprint(params));
3024
- __tnRegisterValidate("TransferEventData", (buffer, params) => TransferEventData.__tnInvokeValidate(buffer, params));
3025
-
3026
3101
  export class TransferEventDataBuilder {
3027
3102
  private buffer: Uint8Array;
3028
3103
  private view: DataView;
@@ -3044,19 +3119,19 @@ export class TransferEventDataBuilder {
3044
3119
  return this;
3045
3120
  }
3046
3121
 
3047
- set_amount(value: number): this {
3122
+ set_amount(value: bigint): this {
3048
3123
  const cast = __tnToBigInt(value);
3049
3124
  this.view.setBigUint64(64, cast, true);
3050
3125
  return this;
3051
3126
  }
3052
3127
 
3053
- set_source_post_balance(value: number): this {
3128
+ set_source_post_balance(value: bigint): this {
3054
3129
  const cast = __tnToBigInt(value);
3055
3130
  this.view.setBigUint64(72, cast, true);
3056
3131
  return this;
3057
3132
  }
3058
3133
 
3059
- set_dest_post_balance(value: number): this {
3134
+ set_dest_post_balance(value: bigint): this {
3060
3135
  const cast = __tnToBigInt(value);
3061
3136
  this.view.setBigUint64(80, cast, true);
3062
3137
  return this;
@@ -3079,6 +3154,10 @@ export class TransferEventDataBuilder {
3079
3154
  }
3080
3155
  }
3081
3156
 
3157
+ __tnRegisterFootprint("TransferEventData", (params) => TransferEventData.__tnInvokeFootprint(params));
3158
+ __tnRegisterValidate("TransferEventData", (buffer, params) => TransferEventData.__tnInvokeValidate(buffer, params));
3159
+ __tnRegisterDynamicValidate("TransferEventData", (buffer) => { const result = TransferEventData.validate(buffer); const params = (result as { params?: Record<string, bigint> }).params; return { ok: result.ok, code: result.code, consumed: result.consumed === undefined ? undefined : __tnToBigInt(result.consumed), params }; });
3160
+
3082
3161
  /* ----- TYPE DEFINITION FOR TransferInstruction ----- */
3083
3162
 
3084
3163
  const __tn_ir_TransferInstruction = {
@@ -3221,9 +3300,6 @@ export class TransferInstruction {
3221
3300
 
3222
3301
  }
3223
3302
 
3224
- __tnRegisterFootprint("TransferInstruction", (params) => TransferInstruction.__tnInvokeFootprint(params));
3225
- __tnRegisterValidate("TransferInstruction", (buffer, params) => TransferInstruction.__tnInvokeValidate(buffer, params));
3226
-
3227
3303
  export class TransferInstructionBuilder {
3228
3304
  private buffer: Uint8Array;
3229
3305
  private view: DataView;
@@ -3243,7 +3319,7 @@ export class TransferInstructionBuilder {
3243
3319
  return this;
3244
3320
  }
3245
3321
 
3246
- set_amount(value: number): this {
3322
+ set_amount(value: bigint): this {
3247
3323
  const cast = __tnToBigInt(value);
3248
3324
  this.view.setBigUint64(4, cast, true);
3249
3325
  return this;
@@ -3266,6 +3342,10 @@ export class TransferInstructionBuilder {
3266
3342
  }
3267
3343
  }
3268
3344
 
3345
+ __tnRegisterFootprint("TransferInstruction", (params) => TransferInstruction.__tnInvokeFootprint(params));
3346
+ __tnRegisterValidate("TransferInstruction", (buffer, params) => TransferInstruction.__tnInvokeValidate(buffer, params));
3347
+ __tnRegisterDynamicValidate("TransferInstruction", (buffer) => { const result = TransferInstruction.validate(buffer); const params = (result as { params?: Record<string, bigint> }).params; return { ok: result.ok, code: result.code, consumed: result.consumed === undefined ? undefined : __tnToBigInt(result.consumed), params }; });
3348
+
3269
3349
  /* ----- TYPE DEFINITION FOR BurnEventData ----- */
3270
3350
 
3271
3351
  const __tn_ir_BurnEventData = {
@@ -3459,9 +3539,6 @@ export class BurnEventData {
3459
3539
 
3460
3540
  }
3461
3541
 
3462
- __tnRegisterFootprint("BurnEventData", (params) => BurnEventData.__tnInvokeFootprint(params));
3463
- __tnRegisterValidate("BurnEventData", (buffer, params) => BurnEventData.__tnInvokeValidate(buffer, params));
3464
-
3465
3542
  export class BurnEventDataBuilder {
3466
3543
  private buffer: Uint8Array;
3467
3544
  private view: DataView;
@@ -3489,19 +3566,19 @@ export class BurnEventDataBuilder {
3489
3566
  return this;
3490
3567
  }
3491
3568
 
3492
- set_amount(value: number): this {
3569
+ set_amount(value: bigint): this {
3493
3570
  const cast = __tnToBigInt(value);
3494
3571
  this.view.setBigUint64(96, cast, true);
3495
3572
  return this;
3496
3573
  }
3497
3574
 
3498
- set_account_post_balance(value: number): this {
3575
+ set_account_post_balance(value: bigint): this {
3499
3576
  const cast = __tnToBigInt(value);
3500
3577
  this.view.setBigUint64(104, cast, true);
3501
3578
  return this;
3502
3579
  }
3503
3580
 
3504
- set_mint_supply(value: number): this {
3581
+ set_mint_supply(value: bigint): this {
3505
3582
  const cast = __tnToBigInt(value);
3506
3583
  this.view.setBigUint64(112, cast, true);
3507
3584
  return this;
@@ -3524,6 +3601,10 @@ export class BurnEventDataBuilder {
3524
3601
  }
3525
3602
  }
3526
3603
 
3604
+ __tnRegisterFootprint("BurnEventData", (params) => BurnEventData.__tnInvokeFootprint(params));
3605
+ __tnRegisterValidate("BurnEventData", (buffer, params) => BurnEventData.__tnInvokeValidate(buffer, params));
3606
+ __tnRegisterDynamicValidate("BurnEventData", (buffer) => { const result = BurnEventData.validate(buffer); const params = (result as { params?: Record<string, bigint> }).params; return { ok: result.ok, code: result.code, consumed: result.consumed === undefined ? undefined : __tnToBigInt(result.consumed), params }; });
3607
+
3527
3608
  /* ----- TYPE DEFINITION FOR CloseAccountEventData ----- */
3528
3609
 
3529
3610
  const __tn_ir_CloseAccountEventData = {
@@ -3663,9 +3744,6 @@ export class CloseAccountEventData {
3663
3744
 
3664
3745
  }
3665
3746
 
3666
- __tnRegisterFootprint("CloseAccountEventData", (params) => CloseAccountEventData.__tnInvokeFootprint(params));
3667
- __tnRegisterValidate("CloseAccountEventData", (buffer, params) => CloseAccountEventData.__tnInvokeValidate(buffer, params));
3668
-
3669
3747
  export class CloseAccountEventDataBuilder {
3670
3748
  private buffer: Uint8Array;
3671
3749
  private view: DataView;
@@ -3710,6 +3788,10 @@ export class CloseAccountEventDataBuilder {
3710
3788
  }
3711
3789
  }
3712
3790
 
3791
+ __tnRegisterFootprint("CloseAccountEventData", (params) => CloseAccountEventData.__tnInvokeFootprint(params));
3792
+ __tnRegisterValidate("CloseAccountEventData", (buffer, params) => CloseAccountEventData.__tnInvokeValidate(buffer, params));
3793
+ __tnRegisterDynamicValidate("CloseAccountEventData", (buffer) => { const result = CloseAccountEventData.validate(buffer); const params = (result as { params?: Record<string, bigint> }).params; return { ok: result.ok, code: result.code, consumed: result.consumed === undefined ? undefined : __tnToBigInt(result.consumed), params }; });
3794
+
3713
3795
  /* ----- TYPE DEFINITION FOR FreezeAccountEventData ----- */
3714
3796
 
3715
3797
  const __tn_ir_FreezeAccountEventData = {
@@ -3849,9 +3931,6 @@ export class FreezeAccountEventData {
3849
3931
 
3850
3932
  }
3851
3933
 
3852
- __tnRegisterFootprint("FreezeAccountEventData", (params) => FreezeAccountEventData.__tnInvokeFootprint(params));
3853
- __tnRegisterValidate("FreezeAccountEventData", (buffer, params) => FreezeAccountEventData.__tnInvokeValidate(buffer, params));
3854
-
3855
3934
  export class FreezeAccountEventDataBuilder {
3856
3935
  private buffer: Uint8Array;
3857
3936
  private view: DataView;
@@ -3896,6 +3975,10 @@ export class FreezeAccountEventDataBuilder {
3896
3975
  }
3897
3976
  }
3898
3977
 
3978
+ __tnRegisterFootprint("FreezeAccountEventData", (params) => FreezeAccountEventData.__tnInvokeFootprint(params));
3979
+ __tnRegisterValidate("FreezeAccountEventData", (buffer, params) => FreezeAccountEventData.__tnInvokeValidate(buffer, params));
3980
+ __tnRegisterDynamicValidate("FreezeAccountEventData", (buffer) => { const result = FreezeAccountEventData.validate(buffer); const params = (result as { params?: Record<string, bigint> }).params; return { ok: result.ok, code: result.code, consumed: result.consumed === undefined ? undefined : __tnToBigInt(result.consumed), params }; });
3981
+
3899
3982
  /* ----- TYPE DEFINITION FOR InitializeAccountEventData ----- */
3900
3983
 
3901
3984
  const __tn_ir_InitializeAccountEventData = {
@@ -4035,9 +4118,6 @@ export class InitializeAccountEventData {
4035
4118
 
4036
4119
  }
4037
4120
 
4038
- __tnRegisterFootprint("InitializeAccountEventData", (params) => InitializeAccountEventData.__tnInvokeFootprint(params));
4039
- __tnRegisterValidate("InitializeAccountEventData", (buffer, params) => InitializeAccountEventData.__tnInvokeValidate(buffer, params));
4040
-
4041
4121
  export class InitializeAccountEventDataBuilder {
4042
4122
  private buffer: Uint8Array;
4043
4123
  private view: DataView;
@@ -4082,6 +4162,10 @@ export class InitializeAccountEventDataBuilder {
4082
4162
  }
4083
4163
  }
4084
4164
 
4165
+ __tnRegisterFootprint("InitializeAccountEventData", (params) => InitializeAccountEventData.__tnInvokeFootprint(params));
4166
+ __tnRegisterValidate("InitializeAccountEventData", (buffer, params) => InitializeAccountEventData.__tnInvokeValidate(buffer, params));
4167
+ __tnRegisterDynamicValidate("InitializeAccountEventData", (buffer) => { const result = InitializeAccountEventData.validate(buffer); const params = (result as { params?: Record<string, bigint> }).params; return { ok: result.ok, code: result.code, consumed: result.consumed === undefined ? undefined : __tnToBigInt(result.consumed), params }; });
4168
+
4085
4169
  /* ----- TYPE DEFINITION FOR InitializeMintEventData ----- */
4086
4170
 
4087
4171
  const __tn_ir_InitializeMintEventData = {
@@ -4296,9 +4380,6 @@ export class InitializeMintEventData {
4296
4380
 
4297
4381
  }
4298
4382
 
4299
- __tnRegisterFootprint("InitializeMintEventData", (params) => InitializeMintEventData.__tnInvokeFootprint(params));
4300
- __tnRegisterValidate("InitializeMintEventData", (buffer, params) => InitializeMintEventData.__tnInvokeValidate(buffer, params));
4301
-
4302
4383
  export class InitializeMintEventDataBuilder {
4303
4384
  private buffer: Uint8Array;
4304
4385
  private view: DataView;
@@ -4326,7 +4407,7 @@ export class InitializeMintEventDataBuilder {
4326
4407
  return this;
4327
4408
  }
4328
4409
 
4329
- set_supply(value: number): this {
4410
+ set_supply(value: bigint): this {
4330
4411
  const cast = __tnToBigInt(value);
4331
4412
  this.view.setBigUint64(96, cast, true);
4332
4413
  return this;
@@ -4365,6 +4446,10 @@ export class InitializeMintEventDataBuilder {
4365
4446
  }
4366
4447
  }
4367
4448
 
4449
+ __tnRegisterFootprint("InitializeMintEventData", (params) => InitializeMintEventData.__tnInvokeFootprint(params));
4450
+ __tnRegisterValidate("InitializeMintEventData", (buffer, params) => InitializeMintEventData.__tnInvokeValidate(buffer, params));
4451
+ __tnRegisterDynamicValidate("InitializeMintEventData", (buffer) => { const result = InitializeMintEventData.validate(buffer); const params = (result as { params?: Record<string, bigint> }).params; return { ok: result.ok, code: result.code, consumed: result.consumed === undefined ? undefined : __tnToBigInt(result.consumed), params }; });
4452
+
4368
4453
  /* ----- TYPE DEFINITION FOR MintToEventData ----- */
4369
4454
 
4370
4455
  const __tn_ir_MintToEventData = {
@@ -4558,9 +4643,6 @@ export class MintToEventData {
4558
4643
 
4559
4644
  }
4560
4645
 
4561
- __tnRegisterFootprint("MintToEventData", (params) => MintToEventData.__tnInvokeFootprint(params));
4562
- __tnRegisterValidate("MintToEventData", (buffer, params) => MintToEventData.__tnInvokeValidate(buffer, params));
4563
-
4564
4646
  export class MintToEventDataBuilder {
4565
4647
  private buffer: Uint8Array;
4566
4648
  private view: DataView;
@@ -4588,19 +4670,19 @@ export class MintToEventDataBuilder {
4588
4670
  return this;
4589
4671
  }
4590
4672
 
4591
- set_amount(value: number): this {
4673
+ set_amount(value: bigint): this {
4592
4674
  const cast = __tnToBigInt(value);
4593
4675
  this.view.setBigUint64(96, cast, true);
4594
4676
  return this;
4595
4677
  }
4596
4678
 
4597
- set_dest_post_balance(value: number): this {
4679
+ set_dest_post_balance(value: bigint): this {
4598
4680
  const cast = __tnToBigInt(value);
4599
4681
  this.view.setBigUint64(104, cast, true);
4600
4682
  return this;
4601
4683
  }
4602
4684
 
4603
- set_mint_supply(value: number): this {
4685
+ set_mint_supply(value: bigint): this {
4604
4686
  const cast = __tnToBigInt(value);
4605
4687
  this.view.setBigUint64(112, cast, true);
4606
4688
  return this;
@@ -4623,6 +4705,10 @@ export class MintToEventDataBuilder {
4623
4705
  }
4624
4706
  }
4625
4707
 
4708
+ __tnRegisterFootprint("MintToEventData", (params) => MintToEventData.__tnInvokeFootprint(params));
4709
+ __tnRegisterValidate("MintToEventData", (buffer, params) => MintToEventData.__tnInvokeValidate(buffer, params));
4710
+ __tnRegisterDynamicValidate("MintToEventData", (buffer) => { const result = MintToEventData.validate(buffer); const params = (result as { params?: Record<string, bigint> }).params; return { ok: result.ok, code: result.code, consumed: result.consumed === undefined ? undefined : __tnToBigInt(result.consumed), params }; });
4711
+
4626
4712
  /* ----- TYPE DEFINITION FOR TokenEvent ----- */
4627
4713
 
4628
4714
  const __tn_ir_TokenEvent = {
@@ -4710,7 +4796,7 @@ export class TokenEvent {
4710
4796
  }
4711
4797
  }
4712
4798
 
4713
- static __tnCreateView(buffer: Uint8Array, opts?: { params?: TokenEvent.Params }): TokenEvent {
4799
+ static __tnCreateView(buffer: Uint8Array, opts?: { params?: TokenEvent.Params, fieldContext?: Record<string, number | bigint> }): TokenEvent {
4714
4800
  if (!buffer || buffer.length === undefined) throw new Error("TokenEvent.__tnCreateView requires a Uint8Array");
4715
4801
  let params = opts?.params ?? null;
4716
4802
  if (!params) {
@@ -4801,13 +4887,8 @@ export class TokenEvent {
4801
4887
  return null;
4802
4888
  }
4803
4889
  const __tnParam_payload_event_type = __tnToBigInt(view.getUint8(0));
4804
- if (buffer.length < 1) {
4805
- return null;
4806
- }
4807
- const __tnParam_TokenEvent__payload_event_type = __tnToBigInt(view.getUint8(0));
4808
4890
  const __tnExtractedParams = TokenEvent.Params.fromValues({
4809
4891
  payload_event_type: __tnParam_payload_event_type,
4810
- TokenEvent__payload_event_type: __tnParam_TokenEvent__payload_event_type,
4811
4892
  });
4812
4893
  return { params: __tnExtractedParams, derived: null };
4813
4894
  }
@@ -4861,10 +4942,9 @@ export class TokenEvent {
4861
4942
  return this.__tnValidateInternal(buffer, __tnParams);
4862
4943
  }
4863
4944
 
4864
- static footprintIr(payload_event_type: number | bigint, TokenEvent__payload_event_type: number | bigint): bigint {
4945
+ static footprintIr(payload_event_type: number | bigint): bigint {
4865
4946
  const params = TokenEvent.Params.fromValues({
4866
4947
  payload_event_type: payload_event_type,
4867
- TokenEvent__payload_event_type: TokenEvent__payload_event_type,
4868
4948
  });
4869
4949
  return this.footprintIrFromParams(params);
4870
4950
  }
@@ -4872,7 +4952,7 @@ export class TokenEvent {
4872
4952
  private static __tnPackParams(params: TokenEvent.Params): Record<string, bigint> {
4873
4953
  const record: Record<string, bigint> = Object.create(null);
4874
4954
  record["payload.event_type"] = params.payload_event_type;
4875
- record["TokenEvent::payload.event_type"] = params.TokenEvent__payload_event_type;
4955
+ record["TokenEvent::payload.event_type"] = params.payload_event_type;
4876
4956
  return record;
4877
4957
  }
4878
4958
 
@@ -4888,7 +4968,7 @@ export class TokenEvent {
4888
4968
  return __tnBigIntToNumber(irResult, 'TokenEvent::footprintFromParams');
4889
4969
  }
4890
4970
 
4891
- static footprintFromValues(input: { payload_event_type: number | bigint, TokenEvent__payload_event_type: number | bigint }): number {
4971
+ static footprintFromValues(input: { payload_event_type: number | bigint }): number {
4892
4972
  const params = TokenEvent.params(input);
4893
4973
  return this.footprintFromParams(params);
4894
4974
  }
@@ -4944,24 +5024,16 @@ export namespace TokenEvent {
4944
5024
  export type Params = {
4945
5025
  /** ABI path: payload.event_type */
4946
5026
  readonly payload_event_type: bigint;
4947
- /** ABI path: TokenEvent::payload.event_type */
4948
- readonly TokenEvent__payload_event_type: bigint;
4949
5027
  };
4950
5028
 
4951
5029
  export const ParamKeys = Object.freeze({
4952
5030
  payload_event_type: "payload.event_type",
4953
- TokenEvent__payload_event_type: "TokenEvent::payload.event_type",
4954
5031
  } as const);
4955
5032
 
4956
5033
  export const Params = {
4957
- fromValues(input: { payload_event_type: number | bigint, TokenEvent__payload_event_type?: number | bigint }): Params {
4958
- const payloadEventType = __tnToBigInt(input.payload_event_type);
4959
- const tokenEventPayloadType = input.TokenEvent__payload_event_type !== undefined
4960
- ? __tnToBigInt(input.TokenEvent__payload_event_type)
4961
- : payloadEventType;
5034
+ fromValues(input: { payload_event_type: number | bigint }): Params {
4962
5035
  return {
4963
- payload_event_type: payloadEventType,
4964
- TokenEvent__payload_event_type: tokenEventPayloadType,
5036
+ payload_event_type: __tnToBigInt(input.payload_event_type),
4965
5037
  };
4966
5038
  },
4967
5039
  fromBuilder(source: { dynamicParams(): Params } | { params: Params } | Params): Params {
@@ -4975,14 +5047,11 @@ export namespace TokenEvent {
4975
5047
  }
4976
5048
  };
4977
5049
 
4978
- export function params(input: { payload_event_type: number | bigint, TokenEvent__payload_event_type?: number | bigint }): Params {
5050
+ export function params(input: { payload_event_type: number | bigint }): Params {
4979
5051
  return Params.fromValues(input);
4980
5052
  }
4981
5053
  }
4982
5054
 
4983
- __tnRegisterFootprint("TokenEvent", (params) => TokenEvent.__tnInvokeFootprint(params));
4984
- __tnRegisterValidate("TokenEvent", (buffer, params) => TokenEvent.__tnInvokeValidate(buffer, params));
4985
-
4986
5055
  export class TokenEventBuilder {
4987
5056
  private __tnPrefixBuffer: Uint8Array;
4988
5057
  private __tnPrefixView: DataView;
@@ -5071,10 +5140,8 @@ export class TokenEventBuilder {
5071
5140
 
5072
5141
  private __tnComputeParams(): TokenEvent.Params {
5073
5142
  if (this.__tnCachedParams) return this.__tnCachedParams;
5074
- const eventType = __tnToBigInt(this.__tnPrefixView.getUint8(0));
5075
5143
  const params = TokenEvent.Params.fromValues({
5076
- payload_event_type: eventType,
5077
- TokenEvent__payload_event_type: eventType,
5144
+ payload_event_type: (() => { if (this.__tnField_event_type === null) throw new Error("TokenEventBuilder: missing enum tag"); return __tnToBigInt(this.__tnField_event_type); })(),
5078
5145
  });
5079
5146
  this.__tnCachedParams = params;
5080
5147
  return params;
@@ -5099,6 +5166,10 @@ export class TokenEventBuilder {
5099
5166
  }
5100
5167
  }
5101
5168
 
5169
+ __tnRegisterFootprint("TokenEvent", (params) => TokenEvent.__tnInvokeFootprint(params));
5170
+ __tnRegisterValidate("TokenEvent", (buffer, params) => TokenEvent.__tnInvokeValidate(buffer, params));
5171
+ __tnRegisterDynamicValidate("TokenEvent", (buffer) => { const result = TokenEvent.validate(buffer); const params = (result as { params?: Record<string, bigint> }).params; return { ok: result.ok, code: result.code, consumed: result.consumed === undefined ? undefined : __tnToBigInt(result.consumed), params }; });
5172
+
5102
5173
  /* ----- TYPE DEFINITION FOR InitializeAccountInstruction ----- */
5103
5174
 
5104
5175
  const __tn_ir_InitializeAccountInstruction = {
@@ -5108,14 +5179,36 @@ const __tn_ir_InitializeAccountInstruction = {
5108
5179
 
5109
5180
  export class InitializeAccountInstruction {
5110
5181
  private view: DataView;
5182
+ private __tnParams: InitializeAccountInstruction.Params;
5111
5183
 
5112
- private constructor(private buffer: Uint8Array) {
5184
+ private constructor(private buffer: Uint8Array, params?: InitializeAccountInstruction.Params) {
5113
5185
  this.view = new DataView(buffer.buffer, buffer.byteOffset, buffer.byteLength);
5186
+ if (params) {
5187
+ this.__tnParams = params;
5188
+ } else {
5189
+ const derived = InitializeAccountInstruction.__tnExtractParams(this.view, buffer);
5190
+ if (!derived) {
5191
+ throw new Error("InitializeAccountInstruction: failed to derive dynamic parameters");
5192
+ }
5193
+ this.__tnParams = derived.params;
5194
+ }
5114
5195
  }
5115
5196
 
5116
- static __tnCreateView(buffer: Uint8Array, opts?: { fieldContext?: Record<string, number | bigint> }): InitializeAccountInstruction {
5197
+ static __tnCreateView(buffer: Uint8Array, opts?: { params?: InitializeAccountInstruction.Params, fieldContext?: Record<string, number | bigint> }): InitializeAccountInstruction {
5117
5198
  if (!buffer || buffer.length === undefined) throw new Error("InitializeAccountInstruction.__tnCreateView requires a Uint8Array");
5118
- return new InitializeAccountInstruction(new Uint8Array(buffer));
5199
+ let params = opts?.params ?? null;
5200
+ if (!params) {
5201
+ const view = new DataView(buffer.buffer, buffer.byteOffset, buffer.byteLength);
5202
+ const derived = InitializeAccountInstruction.__tnExtractParams(view, buffer);
5203
+ if (!derived) throw new Error("InitializeAccountInstruction.__tnCreateView: failed to derive params");
5204
+ params = derived.params;
5205
+ }
5206
+ const instance = new InitializeAccountInstruction(new Uint8Array(buffer), params);
5207
+ return instance;
5208
+ }
5209
+
5210
+ dynamicParams(): InitializeAccountInstruction.Params {
5211
+ return this.__tnParams;
5119
5212
  }
5120
5213
 
5121
5214
  static builder(): InitializeAccountInstructionBuilder {
@@ -5124,7 +5217,61 @@ export class InitializeAccountInstruction {
5124
5217
 
5125
5218
  static fromBuilder(builder: InitializeAccountInstructionBuilder): InitializeAccountInstruction | null {
5126
5219
  const buffer = builder.build();
5127
- return InitializeAccountInstruction.from_array(buffer);
5220
+ const params = builder.dynamicParams();
5221
+ return InitializeAccountInstruction.from_array(buffer, { params });
5222
+ }
5223
+
5224
+ static __tnComputeSequentialLayout(view: DataView, buffer: Uint8Array): { params: Record<string, bigint> | null; offsets: Record<string, number> | null; derived: Record<string, bigint> | null } | null {
5225
+ const __tnLength = buffer.length;
5226
+ let __tnParamSeq_proof_body_hdr_type_slot: bigint | null = null;
5227
+ let __tnParamSeq_proof_body_payload_size: bigint | null = null;
5228
+ let __tnFieldValue_token_account_index: number | null = null;
5229
+ let __tnFieldValue_mint_account_index: number | null = null;
5230
+ let __tnFieldValue_owner_account_index: number | null = null;
5231
+ let __tnCursorMutable = 0;
5232
+ if (__tnCursorMutable + 2 > __tnLength) return null;
5233
+ const __tnRead_token_account_index = view.getUint16(__tnCursorMutable, true);
5234
+ __tnFieldValue_token_account_index = __tnRead_token_account_index;
5235
+ __tnCursorMutable += 2;
5236
+ if (__tnCursorMutable + 2 > __tnLength) return null;
5237
+ const __tnRead_mint_account_index = view.getUint16(__tnCursorMutable, true);
5238
+ __tnFieldValue_mint_account_index = __tnRead_mint_account_index;
5239
+ __tnCursorMutable += 2;
5240
+ if (__tnCursorMutable + 2 > __tnLength) return null;
5241
+ const __tnRead_owner_account_index = view.getUint16(__tnCursorMutable, true);
5242
+ __tnFieldValue_owner_account_index = __tnRead_owner_account_index;
5243
+ __tnCursorMutable += 2;
5244
+ if (__tnCursorMutable + 32 > __tnLength) return null;
5245
+ __tnCursorMutable += 32;
5246
+ const __tnTyperefResult_state_proof = __tnInvokeDynamicValidate("StateProof", buffer.subarray(__tnCursorMutable));
5247
+ if (!__tnTyperefResult_state_proof.ok || __tnTyperefResult_state_proof.consumed === undefined) return null;
5248
+ const __tnTyperefParams_state_proof = __tnTyperefResult_state_proof.params ?? null;
5249
+ if (!__tnTyperefParams_state_proof || __tnTyperefParams_state_proof["proof_body_hdr_type_slot"] === undefined) return null;
5250
+ __tnParamSeq_proof_body_hdr_type_slot = __tnTyperefParams_state_proof["proof_body_hdr_type_slot"];
5251
+ if (!__tnTyperefParams_state_proof || __tnTyperefParams_state_proof["proof_body_payload_size"] === undefined) return null;
5252
+ __tnParamSeq_proof_body_payload_size = __tnTyperefParams_state_proof["proof_body_payload_size"];
5253
+ __tnCursorMutable += __tnBigIntToNumber(__tnTyperefResult_state_proof.consumed, "InitializeAccountInstruction::state_proof");
5254
+ const params: Record<string, bigint> = Object.create(null);
5255
+ if (__tnParamSeq_proof_body_hdr_type_slot === null) return null;
5256
+ params["proof_body_hdr_type_slot"] = __tnParamSeq_proof_body_hdr_type_slot as bigint;
5257
+ if (__tnParamSeq_proof_body_payload_size === null) return null;
5258
+ params["proof_body_payload_size"] = __tnParamSeq_proof_body_payload_size as bigint;
5259
+ return { params, offsets: null, derived: null };
5260
+ }
5261
+
5262
+ private static __tnExtractParams(view: DataView, buffer: Uint8Array): { params: InitializeAccountInstruction.Params; derived: Record<string, bigint> | null } | null {
5263
+ const __tnLayout = InitializeAccountInstruction.__tnComputeSequentialLayout(view, buffer);
5264
+ if (!__tnLayout || !__tnLayout.params) return null;
5265
+ const __tnSeqParams = __tnLayout.params;
5266
+ const __tnParamSeq_proof_body_hdr_type_slot = __tnSeqParams["proof_body_hdr_type_slot"];
5267
+ if (__tnParamSeq_proof_body_hdr_type_slot === undefined) return null;
5268
+ const __tnParamSeq_proof_body_payload_size = __tnSeqParams["proof_body_payload_size"];
5269
+ if (__tnParamSeq_proof_body_payload_size === undefined) return null;
5270
+ const __tnExtractedParams = InitializeAccountInstruction.Params.fromValues({
5271
+ proof_body_hdr_type_slot: __tnParamSeq_proof_body_hdr_type_slot as bigint,
5272
+ proof_body_payload_size: __tnParamSeq_proof_body_payload_size as bigint,
5273
+ });
5274
+ return { params: __tnExtractedParams, derived: null };
5128
5275
  }
5129
5276
 
5130
5277
  get_token_account_index(): number {
@@ -5229,7 +5376,6 @@ export class InitializeAccountInstruction {
5229
5376
  set state_proof(value: StateProof) {
5230
5377
  this.set_state_proof(value);
5231
5378
  }
5232
-
5233
5379
  private static __tnFootprintInternal(__tnParams: Record<string, bigint>): bigint {
5234
5380
  return __tnEvalFootprint(__tn_ir_InitializeAccountInstruction.root, { params: __tnParams });
5235
5381
  }
@@ -5246,45 +5392,126 @@ export class InitializeAccountInstruction {
5246
5392
  return this.__tnValidateInternal(buffer, __tnParams);
5247
5393
  }
5248
5394
 
5249
- static footprintIr(): bigint {
5250
- return this.__tnFootprintInternal(Object.create(null));
5395
+ static footprintIr(proof_body_hdr_type_slot: number | bigint, proof_body_payload_size: number | bigint): bigint {
5396
+ const params = InitializeAccountInstruction.Params.fromValues({
5397
+ proof_body_hdr_type_slot: proof_body_hdr_type_slot,
5398
+ proof_body_payload_size: proof_body_payload_size,
5399
+ });
5400
+ return this.footprintIrFromParams(params);
5251
5401
  }
5252
5402
 
5253
- static footprint(): number {
5254
- const irResult = this.footprintIr();
5255
- const maxSafe = __tnToBigInt(Number.MAX_SAFE_INTEGER);
5256
- if (__tnBigIntGreaterThan(irResult, maxSafe)) {
5257
- throw new Error('footprint exceeds Number.MAX_SAFE_INTEGER for InitializeAccountInstruction');
5258
- }
5259
- return __tnBigIntToNumber(irResult, 'InitializeAccountInstruction::footprint');
5403
+ private static __tnPackParams(params: InitializeAccountInstruction.Params): Record<string, bigint> {
5404
+ const record: Record<string, bigint> = Object.create(null);
5405
+ record["proof_body.hdr.type_slot"] = params.proof_body_hdr_type_slot;
5406
+ record["proof_body.payload_size"] = params.proof_body_payload_size;
5407
+ return record;
5260
5408
  }
5261
5409
 
5262
- static validate(_buffer: Uint8Array, _opts?: { params?: never }): { ok: boolean; code?: string; consumed?: number } {
5263
- __tnLogWarn("InitializeAccountInstruction::validate falling back to basic length check");
5264
- return { ok: true, consumed: _buffer.length };
5410
+ static footprintIrFromParams(params: InitializeAccountInstruction.Params): bigint {
5411
+ const __tnParams = this.__tnPackParams(params);
5412
+ return this.__tnFootprintInternal(__tnParams);
5265
5413
  }
5266
5414
 
5267
- static from_array(buffer: Uint8Array): InitializeAccountInstruction | null {
5415
+ static footprintFromParams(params: InitializeAccountInstruction.Params): number {
5416
+ const irResult = this.footprintIrFromParams(params);
5417
+ const maxSafe = __tnToBigInt(Number.MAX_SAFE_INTEGER);
5418
+ if (__tnBigIntGreaterThan(irResult, maxSafe)) throw new Error('footprint exceeds Number.MAX_SAFE_INTEGER for InitializeAccountInstruction');
5419
+ return __tnBigIntToNumber(irResult, 'InitializeAccountInstruction::footprintFromParams');
5420
+ }
5421
+
5422
+ static footprintFromValues(input: { proof_body_hdr_type_slot: number | bigint, proof_body_payload_size: number | bigint }): number {
5423
+ const params = InitializeAccountInstruction.params(input);
5424
+ return this.footprintFromParams(params);
5425
+ }
5426
+
5427
+ static footprint(params: InitializeAccountInstruction.Params): number {
5428
+ return this.footprintFromParams(params);
5429
+ }
5430
+
5431
+ static validate(buffer: Uint8Array, opts?: { params?: InitializeAccountInstruction.Params }): { ok: boolean; code?: string; consumed?: number; params?: InitializeAccountInstruction.Params } {
5432
+ if (!buffer || buffer.length === undefined) {
5433
+ return { ok: false, code: "tn.invalid_buffer" };
5434
+ }
5435
+ const view = new DataView(buffer.buffer, buffer.byteOffset, buffer.byteLength);
5436
+ let params = opts?.params ?? null;
5437
+ if (!params) {
5438
+ return { ok: false, code: "tn.param_extraction_failed" };
5439
+ }
5440
+ const __tnParamsRec = this.__tnPackParams(params);
5441
+ const irResult = this.__tnValidateInternal(buffer, __tnParamsRec);
5442
+ if (!irResult.ok) {
5443
+ return { ok: false, code: irResult.code, consumed: irResult.consumed ? __tnBigIntToNumber(irResult.consumed, 'InitializeAccountInstruction::validate') : undefined, params };
5444
+ }
5445
+ const consumed = irResult.consumed ? __tnBigIntToNumber(irResult.consumed, 'InitializeAccountInstruction::validate') : undefined;
5446
+ return { ok: true, consumed, params };
5447
+ }
5448
+
5449
+ static from_array(buffer: Uint8Array, opts?: { params?: InitializeAccountInstruction.Params }): InitializeAccountInstruction | null {
5268
5450
  if (!buffer || buffer.length === undefined) {
5269
5451
  return null;
5270
5452
  }
5271
5453
  const view = new DataView(buffer.buffer, buffer.byteOffset, buffer.byteLength);
5272
- const validation = this.validate(buffer);
5454
+ let params = opts?.params ?? null;
5455
+ if (!params) {
5456
+ __tnLogWarn('InitializeAccountInstruction::from_array requires params when IR extraction is unavailable');
5457
+ return null;
5458
+ }
5459
+ const validation = this.validate(buffer, { params });
5273
5460
  if (!validation.ok) {
5274
5461
  return null;
5275
5462
  }
5276
- return new InitializeAccountInstruction(buffer);
5463
+ const cached = validation.params ?? params;
5464
+ const state = new InitializeAccountInstruction(buffer, cached);
5465
+ return state;
5277
5466
  }
5278
5467
 
5468
+
5279
5469
  }
5280
5470
 
5281
- __tnRegisterFootprint("InitializeAccountInstruction", (params) => InitializeAccountInstruction.__tnInvokeFootprint(params));
5282
- __tnRegisterValidate("InitializeAccountInstruction", (buffer, params) => InitializeAccountInstruction.__tnInvokeValidate(buffer, params));
5471
+ export namespace InitializeAccountInstruction {
5472
+ export type Params = {
5473
+ /** ABI path: proof_body.hdr.type_slot */
5474
+ readonly proof_body_hdr_type_slot: bigint;
5475
+ /** ABI path: proof_body.payload_size */
5476
+ readonly proof_body_payload_size: bigint;
5477
+ };
5478
+
5479
+ export const ParamKeys = Object.freeze({
5480
+ proof_body_hdr_type_slot: "proof_body.hdr.type_slot",
5481
+ proof_body_payload_size: "proof_body.payload_size",
5482
+ } as const);
5483
+
5484
+ export const Params = {
5485
+ fromValues(input: { proof_body_hdr_type_slot: number | bigint, proof_body_payload_size: number | bigint }): Params {
5486
+ return {
5487
+ proof_body_hdr_type_slot: __tnToBigInt(input.proof_body_hdr_type_slot),
5488
+ proof_body_payload_size: __tnToBigInt(input.proof_body_payload_size),
5489
+ };
5490
+ },
5491
+ fromBuilder(source: { dynamicParams(): Params } | { params: Params } | Params): Params {
5492
+ if ((source as { dynamicParams?: () => Params }).dynamicParams) {
5493
+ return (source as { dynamicParams(): Params }).dynamicParams();
5494
+ }
5495
+ if ((source as { params?: Params }).params) {
5496
+ return (source as { params: Params }).params;
5497
+ }
5498
+ return source as Params;
5499
+ }
5500
+ };
5501
+
5502
+ export function params(input: { proof_body_hdr_type_slot: number | bigint, proof_body_payload_size: number | bigint }): Params {
5503
+ return Params.fromValues(input);
5504
+ }
5505
+ }
5283
5506
 
5284
5507
  export class InitializeAccountInstructionBuilder {
5285
5508
  private buffer: Uint8Array;
5286
5509
  private view: DataView;
5510
+ private __tnCachedParams: InitializeAccountInstruction.Params | null = null;
5511
+ private __tnLastBuffer: Uint8Array | null = null;
5512
+ private __tnLastParams: InitializeAccountInstruction.Params | null = null;
5287
5513
  private __tnTail_state_proof: Uint8Array | null = null;
5514
+ private __tnTailParams_state_proof: Record<string, bigint> | null = null;
5288
5515
 
5289
5516
  constructor() {
5290
5517
  this.buffer = new Uint8Array(38);
@@ -5292,7 +5519,9 @@ export class InitializeAccountInstructionBuilder {
5292
5519
  }
5293
5520
 
5294
5521
  private __tnInvalidate(): void {
5295
- /* Placeholder for future cache invalidation. */
5522
+ this.__tnCachedParams = null;
5523
+ this.__tnLastBuffer = null;
5524
+ this.__tnLastParams = null;
5296
5525
  }
5297
5526
 
5298
5527
  set_token_account_index(value: number): this {
@@ -5322,33 +5551,38 @@ export class InitializeAccountInstructionBuilder {
5322
5551
 
5323
5552
  set_state_proof(value: StateProof | __TnStructFieldInput): this {
5324
5553
  const bytes = __tnResolveStructFieldInput(value as __TnStructFieldInput, "InitializeAccountInstructionBuilder::state_proof");
5554
+ const validation = __tnInvokeDynamicValidate("StateProof", bytes);
5555
+ if (!validation.ok || validation.consumed === undefined) throw new Error("InitializeAccountInstructionBuilder: field 'state_proof' failed validation");
5556
+ if (__tnBigIntToNumber(validation.consumed, "InitializeAccountInstructionBuilder::state_proof") !== bytes.length) throw new Error("InitializeAccountInstructionBuilder: field 'state_proof' validation did not consume the full buffer");
5325
5557
  this.__tnTail_state_proof = bytes;
5558
+ this.__tnTailParams_state_proof = validation.params ?? null;
5326
5559
  this.__tnInvalidate();
5327
5560
  return this;
5328
5561
  }
5329
5562
 
5330
5563
  build(): Uint8Array {
5331
- const fragments = this.__tnCollectTailFragments();
5332
- const size = this.__tnComputeSize(fragments);
5564
+ const params = this.__tnComputeParams();
5565
+ const size = InitializeAccountInstruction.footprintFromParams(params);
5333
5566
  const buffer = new Uint8Array(size);
5334
- this.__tnWriteInto(buffer, fragments);
5335
- this.__tnValidateOrThrow(buffer);
5567
+ this.__tnWriteInto(buffer);
5568
+ this.__tnValidateOrThrow(buffer, params);
5336
5569
  return buffer;
5337
5570
  }
5338
5571
 
5339
5572
  buildInto(target: Uint8Array, offset = 0): Uint8Array {
5340
- const fragments = this.__tnCollectTailFragments();
5341
- const size = this.__tnComputeSize(fragments);
5573
+ const params = this.__tnComputeParams();
5574
+ const size = InitializeAccountInstruction.footprintFromParams(params);
5342
5575
  if (target.length - offset < size) throw new Error("InitializeAccountInstructionBuilder: target buffer too small");
5343
5576
  const slice = target.subarray(offset, offset + size);
5344
- this.__tnWriteInto(slice, fragments);
5345
- this.__tnValidateOrThrow(slice);
5577
+ this.__tnWriteInto(slice);
5578
+ this.__tnValidateOrThrow(slice, params);
5346
5579
  return target;
5347
5580
  }
5348
5581
 
5349
5582
  finish(): InitializeAccountInstruction {
5350
5583
  const buffer = this.build();
5351
- const view = InitializeAccountInstruction.from_array(buffer);
5584
+ const params = this.__tnLastParams ?? this.__tnComputeParams();
5585
+ const view = InitializeAccountInstruction.from_array(buffer, { params });
5352
5586
  if (!view) throw new Error("InitializeAccountInstructionBuilder: failed to finalize view");
5353
5587
  return view;
5354
5588
  }
@@ -5357,41 +5591,43 @@ export class InitializeAccountInstructionBuilder {
5357
5591
  return this.finish();
5358
5592
  }
5359
5593
 
5360
- private __tnCollectTailFragments(): Uint8Array[] {
5361
- return [
5362
- (() => {
5363
- const bytes = this.__tnTail_state_proof;
5364
- if (!bytes) throw new Error("InitializeAccountInstructionBuilder: field 'state_proof' must be set before build()");
5365
- return bytes;
5366
- })(),
5367
- ];
5594
+ dynamicParams(): InitializeAccountInstruction.Params {
5595
+ return this.__tnComputeParams();
5368
5596
  }
5369
5597
 
5370
- private __tnComputeSize(fragments: readonly Uint8Array[]): number {
5371
- let total = this.buffer.length;
5372
- for (const fragment of fragments) {
5373
- total += fragment.length;
5374
- }
5375
- return total;
5598
+ private __tnComputeParams(): InitializeAccountInstruction.Params {
5599
+ if (this.__tnCachedParams) return this.__tnCachedParams;
5600
+ const params = InitializeAccountInstruction.Params.fromValues({
5601
+ proof_body_hdr_type_slot: (() => { const params = this.__tnTailParams_state_proof; if (!params || params["proof_body_hdr_type_slot"] === undefined) throw new Error("InitializeAccountInstructionBuilder: field 'state_proof' must be written before computing params"); return params["proof_body_hdr_type_slot"]; })(),
5602
+ proof_body_payload_size: (() => { const params = this.__tnTailParams_state_proof; if (!params || params["proof_body_payload_size"] === undefined) throw new Error("InitializeAccountInstructionBuilder: field 'state_proof' must be written before computing params"); return params["proof_body_payload_size"]; })(),
5603
+ });
5604
+ this.__tnCachedParams = params;
5605
+ return params;
5376
5606
  }
5377
5607
 
5378
- private __tnWriteInto(target: Uint8Array, fragments: readonly Uint8Array[]): void {
5608
+ private __tnWriteInto(target: Uint8Array): void {
5379
5609
  target.set(this.buffer, 0);
5380
5610
  let cursor = this.buffer.length;
5381
- for (const fragment of fragments) {
5382
- target.set(fragment, cursor);
5383
- cursor += fragment.length;
5384
- }
5611
+ const __tnLocal_state_proof_bytes = this.__tnTail_state_proof;
5612
+ if (!__tnLocal_state_proof_bytes) throw new Error("InitializeAccountInstructionBuilder: field 'state_proof' must be written before build");
5613
+ target.set(__tnLocal_state_proof_bytes, cursor);
5614
+ cursor += __tnLocal_state_proof_bytes.length;
5385
5615
  }
5386
5616
 
5387
- private __tnValidateOrThrow(buffer: Uint8Array): void {
5388
- const result = InitializeAccountInstruction.validate(buffer);
5617
+ private __tnValidateOrThrow(buffer: Uint8Array, params: InitializeAccountInstruction.Params): void {
5618
+ const result = InitializeAccountInstruction.validate(buffer, { params });
5389
5619
  if (!result.ok) {
5390
- throw new Error(`InitializeAccountInstructionBuilder: builder produced invalid buffer (code=${result.code ?? "unknown"})`);
5620
+ throw new Error(`${ InitializeAccountInstruction }Builder: builder produced invalid buffer (code=${result.code ?? "unknown"})`);
5391
5621
  }
5622
+ this.__tnLastParams = result.params ?? params;
5623
+ this.__tnLastBuffer = buffer;
5392
5624
  }
5393
5625
  }
5394
5626
 
5627
+ __tnRegisterFootprint("InitializeAccountInstruction", (params) => InitializeAccountInstruction.__tnInvokeFootprint(params));
5628
+ __tnRegisterValidate("InitializeAccountInstruction", (buffer, params) => InitializeAccountInstruction.__tnInvokeValidate(buffer, params));
5629
+ __tnRegisterDynamicValidate("InitializeAccountInstruction", (buffer) => { const result = InitializeAccountInstruction.validate(buffer); const params = (result as { params?: Record<string, bigint> }).params; return { ok: result.ok, code: result.code, consumed: result.consumed === undefined ? undefined : __tnToBigInt(result.consumed), params }; });
5630
+
5395
5631
  /* ----- TYPE DEFINITION FOR InitializeMintInstruction ----- */
5396
5632
 
5397
5633
  const __tn_ir_InitializeMintInstruction = {
@@ -5401,14 +5637,36 @@ const __tn_ir_InitializeMintInstruction = {
5401
5637
 
5402
5638
  export class InitializeMintInstruction {
5403
5639
  private view: DataView;
5640
+ private __tnParams: InitializeMintInstruction.Params;
5404
5641
 
5405
- private constructor(private buffer: Uint8Array) {
5642
+ private constructor(private buffer: Uint8Array, params?: InitializeMintInstruction.Params) {
5406
5643
  this.view = new DataView(buffer.buffer, buffer.byteOffset, buffer.byteLength);
5644
+ if (params) {
5645
+ this.__tnParams = params;
5646
+ } else {
5647
+ const derived = InitializeMintInstruction.__tnExtractParams(this.view, buffer);
5648
+ if (!derived) {
5649
+ throw new Error("InitializeMintInstruction: failed to derive dynamic parameters");
5650
+ }
5651
+ this.__tnParams = derived.params;
5652
+ }
5407
5653
  }
5408
5654
 
5409
- static __tnCreateView(buffer: Uint8Array, opts?: { fieldContext?: Record<string, number | bigint> }): InitializeMintInstruction {
5655
+ static __tnCreateView(buffer: Uint8Array, opts?: { params?: InitializeMintInstruction.Params, fieldContext?: Record<string, number | bigint> }): InitializeMintInstruction {
5410
5656
  if (!buffer || buffer.length === undefined) throw new Error("InitializeMintInstruction.__tnCreateView requires a Uint8Array");
5411
- return new InitializeMintInstruction(new Uint8Array(buffer));
5657
+ let params = opts?.params ?? null;
5658
+ if (!params) {
5659
+ const view = new DataView(buffer.buffer, buffer.byteOffset, buffer.byteLength);
5660
+ const derived = InitializeMintInstruction.__tnExtractParams(view, buffer);
5661
+ if (!derived) throw new Error("InitializeMintInstruction.__tnCreateView: failed to derive params");
5662
+ params = derived.params;
5663
+ }
5664
+ const instance = new InitializeMintInstruction(new Uint8Array(buffer), params);
5665
+ return instance;
5666
+ }
5667
+
5668
+ dynamicParams(): InitializeMintInstruction.Params {
5669
+ return this.__tnParams;
5412
5670
  }
5413
5671
 
5414
5672
  static builder(): InitializeMintInstructionBuilder {
@@ -5417,7 +5675,69 @@ export class InitializeMintInstruction {
5417
5675
 
5418
5676
  static fromBuilder(builder: InitializeMintInstructionBuilder): InitializeMintInstruction | null {
5419
5677
  const buffer = builder.build();
5420
- return InitializeMintInstruction.from_array(buffer);
5678
+ const params = builder.dynamicParams();
5679
+ return InitializeMintInstruction.from_array(buffer, { params });
5680
+ }
5681
+
5682
+ static __tnComputeSequentialLayout(view: DataView, buffer: Uint8Array): { params: Record<string, bigint> | null; offsets: Record<string, number> | null; derived: Record<string, bigint> | null } | null {
5683
+ const __tnLength = buffer.length;
5684
+ let __tnParamSeq_proof_body_hdr_type_slot: bigint | null = null;
5685
+ let __tnParamSeq_proof_body_payload_size: bigint | null = null;
5686
+ let __tnFieldValue_mint_account_index: number | null = null;
5687
+ let __tnFieldValue_decimals: number | null = null;
5688
+ let __tnFieldValue_has_freeze_authority: number | null = null;
5689
+ let __tnCursorMutable = 0;
5690
+ if (__tnCursorMutable + 2 > __tnLength) return null;
5691
+ const __tnRead_mint_account_index = view.getUint16(__tnCursorMutable, true);
5692
+ __tnFieldValue_mint_account_index = __tnRead_mint_account_index;
5693
+ __tnCursorMutable += 2;
5694
+ if (__tnCursorMutable + 1 > __tnLength) return null;
5695
+ const __tnRead_decimals = view.getUint8(__tnCursorMutable);
5696
+ __tnFieldValue_decimals = __tnRead_decimals;
5697
+ __tnCursorMutable += 1;
5698
+ if (__tnCursorMutable + 32 > __tnLength) return null;
5699
+ __tnCursorMutable += 32;
5700
+ if (__tnCursorMutable + 32 > __tnLength) return null;
5701
+ __tnCursorMutable += 32;
5702
+ if (__tnCursorMutable + 32 > __tnLength) return null;
5703
+ __tnCursorMutable += 32;
5704
+ if (__tnCursorMutable + 1 > __tnLength) return null;
5705
+ const __tnRead_has_freeze_authority = view.getUint8(__tnCursorMutable);
5706
+ __tnFieldValue_has_freeze_authority = __tnRead_has_freeze_authority;
5707
+ __tnCursorMutable += 1;
5708
+ if (__tnCursorMutable + 9 > __tnLength) return null;
5709
+ __tnCursorMutable += 9;
5710
+ if (__tnCursorMutable + 32 > __tnLength) return null;
5711
+ __tnCursorMutable += 32;
5712
+ const __tnTyperefResult_state_proof = __tnInvokeDynamicValidate("StateProof", buffer.subarray(__tnCursorMutable));
5713
+ if (!__tnTyperefResult_state_proof.ok || __tnTyperefResult_state_proof.consumed === undefined) return null;
5714
+ const __tnTyperefParams_state_proof = __tnTyperefResult_state_proof.params ?? null;
5715
+ if (!__tnTyperefParams_state_proof || __tnTyperefParams_state_proof["proof_body_hdr_type_slot"] === undefined) return null;
5716
+ __tnParamSeq_proof_body_hdr_type_slot = __tnTyperefParams_state_proof["proof_body_hdr_type_slot"];
5717
+ if (!__tnTyperefParams_state_proof || __tnTyperefParams_state_proof["proof_body_payload_size"] === undefined) return null;
5718
+ __tnParamSeq_proof_body_payload_size = __tnTyperefParams_state_proof["proof_body_payload_size"];
5719
+ __tnCursorMutable += __tnBigIntToNumber(__tnTyperefResult_state_proof.consumed, "InitializeMintInstruction::state_proof");
5720
+ const params: Record<string, bigint> = Object.create(null);
5721
+ if (__tnParamSeq_proof_body_hdr_type_slot === null) return null;
5722
+ params["proof_body_hdr_type_slot"] = __tnParamSeq_proof_body_hdr_type_slot as bigint;
5723
+ if (__tnParamSeq_proof_body_payload_size === null) return null;
5724
+ params["proof_body_payload_size"] = __tnParamSeq_proof_body_payload_size as bigint;
5725
+ return { params, offsets: null, derived: null };
5726
+ }
5727
+
5728
+ private static __tnExtractParams(view: DataView, buffer: Uint8Array): { params: InitializeMintInstruction.Params; derived: Record<string, bigint> | null } | null {
5729
+ const __tnLayout = InitializeMintInstruction.__tnComputeSequentialLayout(view, buffer);
5730
+ if (!__tnLayout || !__tnLayout.params) return null;
5731
+ const __tnSeqParams = __tnLayout.params;
5732
+ const __tnParamSeq_proof_body_hdr_type_slot = __tnSeqParams["proof_body_hdr_type_slot"];
5733
+ if (__tnParamSeq_proof_body_hdr_type_slot === undefined) return null;
5734
+ const __tnParamSeq_proof_body_payload_size = __tnSeqParams["proof_body_payload_size"];
5735
+ if (__tnParamSeq_proof_body_payload_size === undefined) return null;
5736
+ const __tnExtractedParams = InitializeMintInstruction.Params.fromValues({
5737
+ proof_body_hdr_type_slot: __tnParamSeq_proof_body_hdr_type_slot as bigint,
5738
+ proof_body_payload_size: __tnParamSeq_proof_body_payload_size as bigint,
5739
+ });
5740
+ return { params: __tnExtractedParams, derived: null };
5421
5741
  }
5422
5742
 
5423
5743
  get_mint_account_index(): number {
@@ -5606,7 +5926,6 @@ export class InitializeMintInstruction {
5606
5926
  set state_proof(value: StateProof) {
5607
5927
  this.set_state_proof(value);
5608
5928
  }
5609
-
5610
5929
  private static __tnFootprintInternal(__tnParams: Record<string, bigint>): bigint {
5611
5930
  return __tnEvalFootprint(__tn_ir_InitializeMintInstruction.root, { params: __tnParams });
5612
5931
  }
@@ -5623,45 +5942,126 @@ export class InitializeMintInstruction {
5623
5942
  return this.__tnValidateInternal(buffer, __tnParams);
5624
5943
  }
5625
5944
 
5626
- static footprintIr(): bigint {
5627
- return this.__tnFootprintInternal(Object.create(null));
5945
+ static footprintIr(proof_body_hdr_type_slot: number | bigint, proof_body_payload_size: number | bigint): bigint {
5946
+ const params = InitializeMintInstruction.Params.fromValues({
5947
+ proof_body_hdr_type_slot: proof_body_hdr_type_slot,
5948
+ proof_body_payload_size: proof_body_payload_size,
5949
+ });
5950
+ return this.footprintIrFromParams(params);
5628
5951
  }
5629
5952
 
5630
- static footprint(): number {
5631
- const irResult = this.footprintIr();
5632
- const maxSafe = __tnToBigInt(Number.MAX_SAFE_INTEGER);
5633
- if (__tnBigIntGreaterThan(irResult, maxSafe)) {
5634
- throw new Error('footprint exceeds Number.MAX_SAFE_INTEGER for InitializeMintInstruction');
5635
- }
5636
- return __tnBigIntToNumber(irResult, 'InitializeMintInstruction::footprint');
5953
+ private static __tnPackParams(params: InitializeMintInstruction.Params): Record<string, bigint> {
5954
+ const record: Record<string, bigint> = Object.create(null);
5955
+ record["proof_body.hdr.type_slot"] = params.proof_body_hdr_type_slot;
5956
+ record["proof_body.payload_size"] = params.proof_body_payload_size;
5957
+ return record;
5958
+ }
5959
+
5960
+ static footprintIrFromParams(params: InitializeMintInstruction.Params): bigint {
5961
+ const __tnParams = this.__tnPackParams(params);
5962
+ return this.__tnFootprintInternal(__tnParams);
5637
5963
  }
5638
5964
 
5639
- static validate(_buffer: Uint8Array, _opts?: { params?: never }): { ok: boolean; code?: string; consumed?: number } {
5640
- __tnLogWarn("InitializeMintInstruction::validate falling back to basic length check");
5641
- return { ok: true, consumed: _buffer.length };
5965
+ static footprintFromParams(params: InitializeMintInstruction.Params): number {
5966
+ const irResult = this.footprintIrFromParams(params);
5967
+ const maxSafe = __tnToBigInt(Number.MAX_SAFE_INTEGER);
5968
+ if (__tnBigIntGreaterThan(irResult, maxSafe)) throw new Error('footprint exceeds Number.MAX_SAFE_INTEGER for InitializeMintInstruction');
5969
+ return __tnBigIntToNumber(irResult, 'InitializeMintInstruction::footprintFromParams');
5642
5970
  }
5643
5971
 
5644
- static from_array(buffer: Uint8Array): InitializeMintInstruction | null {
5972
+ static footprintFromValues(input: { proof_body_hdr_type_slot: number | bigint, proof_body_payload_size: number | bigint }): number {
5973
+ const params = InitializeMintInstruction.params(input);
5974
+ return this.footprintFromParams(params);
5975
+ }
5976
+
5977
+ static footprint(params: InitializeMintInstruction.Params): number {
5978
+ return this.footprintFromParams(params);
5979
+ }
5980
+
5981
+ static validate(buffer: Uint8Array, opts?: { params?: InitializeMintInstruction.Params }): { ok: boolean; code?: string; consumed?: number; params?: InitializeMintInstruction.Params } {
5982
+ if (!buffer || buffer.length === undefined) {
5983
+ return { ok: false, code: "tn.invalid_buffer" };
5984
+ }
5985
+ const view = new DataView(buffer.buffer, buffer.byteOffset, buffer.byteLength);
5986
+ let params = opts?.params ?? null;
5987
+ if (!params) {
5988
+ return { ok: false, code: "tn.param_extraction_failed" };
5989
+ }
5990
+ const __tnParamsRec = this.__tnPackParams(params);
5991
+ const irResult = this.__tnValidateInternal(buffer, __tnParamsRec);
5992
+ if (!irResult.ok) {
5993
+ return { ok: false, code: irResult.code, consumed: irResult.consumed ? __tnBigIntToNumber(irResult.consumed, 'InitializeMintInstruction::validate') : undefined, params };
5994
+ }
5995
+ const consumed = irResult.consumed ? __tnBigIntToNumber(irResult.consumed, 'InitializeMintInstruction::validate') : undefined;
5996
+ return { ok: true, consumed, params };
5997
+ }
5998
+
5999
+ static from_array(buffer: Uint8Array, opts?: { params?: InitializeMintInstruction.Params }): InitializeMintInstruction | null {
5645
6000
  if (!buffer || buffer.length === undefined) {
5646
6001
  return null;
5647
6002
  }
5648
6003
  const view = new DataView(buffer.buffer, buffer.byteOffset, buffer.byteLength);
5649
- const validation = this.validate(buffer);
6004
+ let params = opts?.params ?? null;
6005
+ if (!params) {
6006
+ __tnLogWarn('InitializeMintInstruction::from_array requires params when IR extraction is unavailable');
6007
+ return null;
6008
+ }
6009
+ const validation = this.validate(buffer, { params });
5650
6010
  if (!validation.ok) {
5651
6011
  return null;
5652
6012
  }
5653
- return new InitializeMintInstruction(buffer);
6013
+ const cached = validation.params ?? params;
6014
+ const state = new InitializeMintInstruction(buffer, cached);
6015
+ return state;
5654
6016
  }
5655
6017
 
6018
+
5656
6019
  }
5657
6020
 
5658
- __tnRegisterFootprint("InitializeMintInstruction", (params) => InitializeMintInstruction.__tnInvokeFootprint(params));
5659
- __tnRegisterValidate("InitializeMintInstruction", (buffer, params) => InitializeMintInstruction.__tnInvokeValidate(buffer, params));
6021
+ export namespace InitializeMintInstruction {
6022
+ export type Params = {
6023
+ /** ABI path: proof_body.hdr.type_slot */
6024
+ readonly proof_body_hdr_type_slot: bigint;
6025
+ /** ABI path: proof_body.payload_size */
6026
+ readonly proof_body_payload_size: bigint;
6027
+ };
6028
+
6029
+ export const ParamKeys = Object.freeze({
6030
+ proof_body_hdr_type_slot: "proof_body.hdr.type_slot",
6031
+ proof_body_payload_size: "proof_body.payload_size",
6032
+ } as const);
6033
+
6034
+ export const Params = {
6035
+ fromValues(input: { proof_body_hdr_type_slot: number | bigint, proof_body_payload_size: number | bigint }): Params {
6036
+ return {
6037
+ proof_body_hdr_type_slot: __tnToBigInt(input.proof_body_hdr_type_slot),
6038
+ proof_body_payload_size: __tnToBigInt(input.proof_body_payload_size),
6039
+ };
6040
+ },
6041
+ fromBuilder(source: { dynamicParams(): Params } | { params: Params } | Params): Params {
6042
+ if ((source as { dynamicParams?: () => Params }).dynamicParams) {
6043
+ return (source as { dynamicParams(): Params }).dynamicParams();
6044
+ }
6045
+ if ((source as { params?: Params }).params) {
6046
+ return (source as { params: Params }).params;
6047
+ }
6048
+ return source as Params;
6049
+ }
6050
+ };
6051
+
6052
+ export function params(input: { proof_body_hdr_type_slot: number | bigint, proof_body_payload_size: number | bigint }): Params {
6053
+ return Params.fromValues(input);
6054
+ }
6055
+ }
5660
6056
 
5661
6057
  export class InitializeMintInstructionBuilder {
5662
6058
  private buffer: Uint8Array;
5663
6059
  private view: DataView;
6060
+ private __tnCachedParams: InitializeMintInstruction.Params | null = null;
6061
+ private __tnLastBuffer: Uint8Array | null = null;
6062
+ private __tnLastParams: InitializeMintInstruction.Params | null = null;
5664
6063
  private __tnTail_state_proof: Uint8Array | null = null;
6064
+ private __tnTailParams_state_proof: Record<string, bigint> | null = null;
5665
6065
 
5666
6066
  constructor() {
5667
6067
  this.buffer = new Uint8Array(141);
@@ -5669,7 +6069,9 @@ export class InitializeMintInstructionBuilder {
5669
6069
  }
5670
6070
 
5671
6071
  private __tnInvalidate(): void {
5672
- /* Placeholder for future cache invalidation. */
6072
+ this.__tnCachedParams = null;
6073
+ this.__tnLastBuffer = null;
6074
+ this.__tnLastParams = null;
5673
6075
  }
5674
6076
 
5675
6077
  set_mint_account_index(value: number): this {
@@ -5727,33 +6129,38 @@ export class InitializeMintInstructionBuilder {
5727
6129
 
5728
6130
  set_state_proof(value: StateProof | __TnStructFieldInput): this {
5729
6131
  const bytes = __tnResolveStructFieldInput(value as __TnStructFieldInput, "InitializeMintInstructionBuilder::state_proof");
6132
+ const validation = __tnInvokeDynamicValidate("StateProof", bytes);
6133
+ if (!validation.ok || validation.consumed === undefined) throw new Error("InitializeMintInstructionBuilder: field 'state_proof' failed validation");
6134
+ if (__tnBigIntToNumber(validation.consumed, "InitializeMintInstructionBuilder::state_proof") !== bytes.length) throw new Error("InitializeMintInstructionBuilder: field 'state_proof' validation did not consume the full buffer");
5730
6135
  this.__tnTail_state_proof = bytes;
6136
+ this.__tnTailParams_state_proof = validation.params ?? null;
5731
6137
  this.__tnInvalidate();
5732
6138
  return this;
5733
6139
  }
5734
6140
 
5735
6141
  build(): Uint8Array {
5736
- const fragments = this.__tnCollectTailFragments();
5737
- const size = this.__tnComputeSize(fragments);
6142
+ const params = this.__tnComputeParams();
6143
+ const size = InitializeMintInstruction.footprintFromParams(params);
5738
6144
  const buffer = new Uint8Array(size);
5739
- this.__tnWriteInto(buffer, fragments);
5740
- this.__tnValidateOrThrow(buffer);
6145
+ this.__tnWriteInto(buffer);
6146
+ this.__tnValidateOrThrow(buffer, params);
5741
6147
  return buffer;
5742
6148
  }
5743
6149
 
5744
6150
  buildInto(target: Uint8Array, offset = 0): Uint8Array {
5745
- const fragments = this.__tnCollectTailFragments();
5746
- const size = this.__tnComputeSize(fragments);
6151
+ const params = this.__tnComputeParams();
6152
+ const size = InitializeMintInstruction.footprintFromParams(params);
5747
6153
  if (target.length - offset < size) throw new Error("InitializeMintInstructionBuilder: target buffer too small");
5748
6154
  const slice = target.subarray(offset, offset + size);
5749
- this.__tnWriteInto(slice, fragments);
5750
- this.__tnValidateOrThrow(slice);
6155
+ this.__tnWriteInto(slice);
6156
+ this.__tnValidateOrThrow(slice, params);
5751
6157
  return target;
5752
6158
  }
5753
6159
 
5754
6160
  finish(): InitializeMintInstruction {
5755
6161
  const buffer = this.build();
5756
- const view = InitializeMintInstruction.from_array(buffer);
6162
+ const params = this.__tnLastParams ?? this.__tnComputeParams();
6163
+ const view = InitializeMintInstruction.from_array(buffer, { params });
5757
6164
  if (!view) throw new Error("InitializeMintInstructionBuilder: failed to finalize view");
5758
6165
  return view;
5759
6166
  }
@@ -5762,41 +6169,43 @@ export class InitializeMintInstructionBuilder {
5762
6169
  return this.finish();
5763
6170
  }
5764
6171
 
5765
- private __tnCollectTailFragments(): Uint8Array[] {
5766
- return [
5767
- (() => {
5768
- const bytes = this.__tnTail_state_proof;
5769
- if (!bytes) throw new Error("InitializeMintInstructionBuilder: field 'state_proof' must be set before build()");
5770
- return bytes;
5771
- })(),
5772
- ];
6172
+ dynamicParams(): InitializeMintInstruction.Params {
6173
+ return this.__tnComputeParams();
5773
6174
  }
5774
6175
 
5775
- private __tnComputeSize(fragments: readonly Uint8Array[]): number {
5776
- let total = this.buffer.length;
5777
- for (const fragment of fragments) {
5778
- total += fragment.length;
5779
- }
5780
- return total;
6176
+ private __tnComputeParams(): InitializeMintInstruction.Params {
6177
+ if (this.__tnCachedParams) return this.__tnCachedParams;
6178
+ const params = InitializeMintInstruction.Params.fromValues({
6179
+ proof_body_hdr_type_slot: (() => { const params = this.__tnTailParams_state_proof; if (!params || params["proof_body_hdr_type_slot"] === undefined) throw new Error("InitializeMintInstructionBuilder: field 'state_proof' must be written before computing params"); return params["proof_body_hdr_type_slot"]; })(),
6180
+ proof_body_payload_size: (() => { const params = this.__tnTailParams_state_proof; if (!params || params["proof_body_payload_size"] === undefined) throw new Error("InitializeMintInstructionBuilder: field 'state_proof' must be written before computing params"); return params["proof_body_payload_size"]; })(),
6181
+ });
6182
+ this.__tnCachedParams = params;
6183
+ return params;
5781
6184
  }
5782
6185
 
5783
- private __tnWriteInto(target: Uint8Array, fragments: readonly Uint8Array[]): void {
6186
+ private __tnWriteInto(target: Uint8Array): void {
5784
6187
  target.set(this.buffer, 0);
5785
6188
  let cursor = this.buffer.length;
5786
- for (const fragment of fragments) {
5787
- target.set(fragment, cursor);
5788
- cursor += fragment.length;
5789
- }
6189
+ const __tnLocal_state_proof_bytes = this.__tnTail_state_proof;
6190
+ if (!__tnLocal_state_proof_bytes) throw new Error("InitializeMintInstructionBuilder: field 'state_proof' must be written before build");
6191
+ target.set(__tnLocal_state_proof_bytes, cursor);
6192
+ cursor += __tnLocal_state_proof_bytes.length;
5790
6193
  }
5791
6194
 
5792
- private __tnValidateOrThrow(buffer: Uint8Array): void {
5793
- const result = InitializeMintInstruction.validate(buffer);
6195
+ private __tnValidateOrThrow(buffer: Uint8Array, params: InitializeMintInstruction.Params): void {
6196
+ const result = InitializeMintInstruction.validate(buffer, { params });
5794
6197
  if (!result.ok) {
5795
- throw new Error(`InitializeMintInstructionBuilder: builder produced invalid buffer (code=${result.code ?? "unknown"})`);
6198
+ throw new Error(`${ InitializeMintInstruction }Builder: builder produced invalid buffer (code=${result.code ?? "unknown"})`);
5796
6199
  }
6200
+ this.__tnLastParams = result.params ?? params;
6201
+ this.__tnLastBuffer = buffer;
5797
6202
  }
5798
6203
  }
5799
6204
 
6205
+ __tnRegisterFootprint("InitializeMintInstruction", (params) => InitializeMintInstruction.__tnInvokeFootprint(params));
6206
+ __tnRegisterValidate("InitializeMintInstruction", (buffer, params) => InitializeMintInstruction.__tnInvokeValidate(buffer, params));
6207
+ __tnRegisterDynamicValidate("InitializeMintInstruction", (buffer) => { const result = InitializeMintInstruction.validate(buffer); const params = (result as { params?: Record<string, bigint> }).params; return { ok: result.ok, code: result.code, consumed: result.consumed === undefined ? undefined : __tnToBigInt(result.consumed), params }; });
6208
+
5800
6209
  /* ----- TYPE DEFINITION FOR TokenInstruction ----- */
5801
6210
 
5802
6211
  const __tn_ir_TokenInstruction = {
@@ -5884,7 +6293,7 @@ export class TokenInstruction {
5884
6293
  }
5885
6294
  }
5886
6295
 
5887
- static __tnCreateView(buffer: Uint8Array, opts?: { params?: TokenInstruction.Params }): TokenInstruction {
6296
+ static __tnCreateView(buffer: Uint8Array, opts?: { params?: TokenInstruction.Params, fieldContext?: Record<string, number | bigint> }): TokenInstruction {
5888
6297
  if (!buffer || buffer.length === undefined) throw new Error("TokenInstruction.__tnCreateView requires a Uint8Array");
5889
6298
  let params = opts?.params ?? null;
5890
6299
  if (!params) {
@@ -6184,9 +6593,6 @@ export namespace TokenInstruction {
6184
6593
  }
6185
6594
  }
6186
6595
 
6187
- __tnRegisterFootprint("TokenInstruction", (params) => TokenInstruction.__tnInvokeFootprint(params));
6188
- __tnRegisterValidate("TokenInstruction", (buffer, params) => TokenInstruction.__tnInvokeValidate(buffer, params));
6189
-
6190
6596
  export class TokenInstructionBuilder {
6191
6597
  private __tnPrefixBuffer: Uint8Array;
6192
6598
  private __tnPrefixView: DataView;
@@ -6301,3 +6707,7 @@ export class TokenInstructionBuilder {
6301
6707
  this.__tnLastBuffer = buffer;
6302
6708
  }
6303
6709
  }
6710
+
6711
+ __tnRegisterFootprint("TokenInstruction", (params) => TokenInstruction.__tnInvokeFootprint(params));
6712
+ __tnRegisterValidate("TokenInstruction", (buffer, params) => TokenInstruction.__tnInvokeValidate(buffer, params));
6713
+ __tnRegisterDynamicValidate("TokenInstruction", (buffer) => { const result = TokenInstruction.validate(buffer); const params = (result as { params?: Record<string, bigint> }).params; return { ok: result.ok, code: result.code, consumed: result.consumed === undefined ? undefined : __tnToBigInt(result.consumed), params }; });