@thru/programs 0.2.22 → 0.2.23
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/multicall/index.cjs +2579 -0
- package/dist/multicall/index.cjs.map +1 -0
- package/dist/multicall/index.d.cts +253 -0
- package/dist/multicall/index.d.ts +253 -0
- package/dist/multicall/index.js +2573 -0
- package/dist/multicall/index.js.map +1 -0
- package/dist/passkey-manager/index.cjs +582 -706
- package/dist/passkey-manager/index.cjs.map +1 -1
- package/dist/passkey-manager/index.d.cts +20 -14
- package/dist/passkey-manager/index.d.ts +20 -14
- package/dist/passkey-manager/index.js +551 -673
- package/dist/passkey-manager/index.js.map +1 -1
- package/package.json +7 -2
- package/src/multicall/abi/thru/common/primitives/types.ts +2265 -0
- package/src/multicall/abi/thru/program/multicall/types.ts +1232 -0
- package/src/multicall/index.test.ts +46 -0
- package/src/multicall/index.ts +81 -0
- package/src/passkey-manager/abi/thru/blockchain/state_proof/types.ts +95 -19
- package/src/passkey-manager/abi/thru/common/primitives/types.ts +111 -37
- package/src/passkey-manager/abi/thru/program/passkey_manager/types.ts +248 -660
- package/src/passkey-manager/challenge.ts +52 -12
- package/src/passkey-manager/constants.ts +0 -1
- package/src/passkey-manager/index.ts +4 -4
- package/src/passkey-manager/instructions/add-authority.ts +8 -2
- package/src/passkey-manager/instructions/remove-authority.ts +9 -2
- package/src/passkey-manager/instructions/validate.ts +60 -14
- package/src/passkey-manager/target-instruction.ts +29 -0
- package/src/passkey-manager/types.ts +16 -0
- package/src/passkey-manager/validate.test.ts +173 -0
- package/tsup.config.ts +1 -0
- package/src/passkey-manager/instructions/invoke.ts +0 -25
- package/src/passkey-manager/instructions/shared.ts +0 -12
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
/* WARNING: Do not modify this file directly. It is generated from ABI definitions. */
|
|
3
3
|
|
|
4
4
|
import { StateProof } from "../../blockchain/state_proof/types";
|
|
5
|
-
import { Pubkey } from "../../common/primitives/types";
|
|
5
|
+
import { InstructionData, Pubkey } from "../../common/primitives/types";
|
|
6
6
|
|
|
7
7
|
type __TnIrNode =
|
|
8
8
|
| { readonly op: "zero" }
|
|
@@ -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 = {
|
|
@@ -518,6 +524,10 @@ const __tnValidateRegistry: Record<
|
|
|
518
524
|
string,
|
|
519
525
|
(buffer: Uint8Array, params: Record<string, bigint>) => __TnValidateResult
|
|
520
526
|
> = {};
|
|
527
|
+
const __tnDynamicValidateRegistry: Record<
|
|
528
|
+
string,
|
|
529
|
+
(buffer: Uint8Array) => __TnValidateResult
|
|
530
|
+
> = {};
|
|
521
531
|
|
|
522
532
|
function __tnRegisterFootprint(
|
|
523
533
|
typeName: string,
|
|
@@ -533,6 +543,13 @@ function __tnRegisterValidate(
|
|
|
533
543
|
__tnValidateRegistry[typeName] = fn;
|
|
534
544
|
}
|
|
535
545
|
|
|
546
|
+
function __tnRegisterDynamicValidate(
|
|
547
|
+
typeName: string,
|
|
548
|
+
fn: (buffer: Uint8Array) => __TnValidateResult
|
|
549
|
+
): void {
|
|
550
|
+
__tnDynamicValidateRegistry[typeName] = fn;
|
|
551
|
+
}
|
|
552
|
+
|
|
536
553
|
function __tnInvokeFootprint(
|
|
537
554
|
typeName: string,
|
|
538
555
|
params: Record<string, bigint>
|
|
@@ -552,8 +569,17 @@ function __tnInvokeValidate(
|
|
|
552
569
|
return fn(buffer, params);
|
|
553
570
|
}
|
|
554
571
|
|
|
572
|
+
function __tnInvokeDynamicValidate(
|
|
573
|
+
typeName: string,
|
|
574
|
+
buffer: Uint8Array
|
|
575
|
+
): __TnValidateResult {
|
|
576
|
+
const fn = __tnDynamicValidateRegistry[typeName];
|
|
577
|
+
if (!fn) throw new Error(`IR runtime missing dynamic validate helper for ${typeName}`);
|
|
578
|
+
return fn(buffer);
|
|
579
|
+
}
|
|
580
|
+
|
|
555
581
|
function __tnEvalFootprint(node: __TnIrNode, ctx: __TnIrContext): bigint {
|
|
556
|
-
return __tnEvalIrNode(node, ctx);
|
|
582
|
+
return __tnEvalIrNode(node, ctx, __tnToBigInt(0));
|
|
557
583
|
}
|
|
558
584
|
|
|
559
585
|
function __tnTryEvalFootprint(
|
|
@@ -568,7 +594,7 @@ function __tnTryEvalIr(
|
|
|
568
594
|
ctx: __TnIrContext
|
|
569
595
|
): __TnEvalResult {
|
|
570
596
|
try {
|
|
571
|
-
return { ok: true, value: __tnEvalIrNode(node, ctx) };
|
|
597
|
+
return { ok: true, value: __tnEvalIrNode(node, ctx, __tnToBigInt(0)) };
|
|
572
598
|
} catch (err) {
|
|
573
599
|
return { ok: false, code: __tnNormalizeIrError(err) };
|
|
574
600
|
}
|
|
@@ -599,7 +625,11 @@ function __tnValidateIrTree(
|
|
|
599
625
|
return { ok: true, consumed: required };
|
|
600
626
|
}
|
|
601
627
|
|
|
602
|
-
function __tnEvalIrNode(
|
|
628
|
+
function __tnEvalIrNode(
|
|
629
|
+
node: __TnIrNode,
|
|
630
|
+
ctx: __TnIrContext,
|
|
631
|
+
baseOffset: bigint
|
|
632
|
+
): bigint {
|
|
603
633
|
switch (node.op) {
|
|
604
634
|
case "zero":
|
|
605
635
|
return __tnToBigInt(0);
|
|
@@ -617,17 +647,22 @@ function __tnEvalIrNode(node: __TnIrNode, ctx: __TnIrContext): bigint {
|
|
|
617
647
|
return val;
|
|
618
648
|
}
|
|
619
649
|
case "add":
|
|
620
|
-
|
|
621
|
-
__tnEvalIrNode(node.left, ctx)
|
|
622
|
-
__tnEvalIrNode(
|
|
623
|
-
|
|
650
|
+
{
|
|
651
|
+
const left = __tnEvalIrNode(node.left, ctx, baseOffset);
|
|
652
|
+
const right = __tnEvalIrNode(
|
|
653
|
+
node.right,
|
|
654
|
+
ctx,
|
|
655
|
+
__tnCheckedAdd(baseOffset, left)
|
|
656
|
+
);
|
|
657
|
+
return __tnCheckedAdd(left, right);
|
|
658
|
+
}
|
|
624
659
|
case "mul":
|
|
625
660
|
return __tnCheckedMul(
|
|
626
|
-
__tnEvalIrNode(node.left, ctx),
|
|
627
|
-
__tnEvalIrNode(node.right, ctx)
|
|
661
|
+
__tnEvalIrNode(node.left, ctx, baseOffset),
|
|
662
|
+
__tnEvalIrNode(node.right, ctx, baseOffset)
|
|
628
663
|
);
|
|
629
664
|
case "align":
|
|
630
|
-
return __tnAlign(__tnEvalIrNode(node.node, ctx), node.alignment);
|
|
665
|
+
return __tnAlign(__tnEvalIrNode(node.node, ctx, baseOffset), node.alignment);
|
|
631
666
|
case "switch": {
|
|
632
667
|
const tagVal = ctx.params[node.tag];
|
|
633
668
|
if (tagVal === undefined) {
|
|
@@ -640,10 +675,10 @@ function __tnEvalIrNode(node: __TnIrNode, ctx: __TnIrContext): bigint {
|
|
|
640
675
|
const tagNumber = Number(tagVal);
|
|
641
676
|
for (const caseNode of node.cases) {
|
|
642
677
|
if (caseNode.value === tagNumber) {
|
|
643
|
-
return __tnEvalIrNode(caseNode.node, ctx);
|
|
678
|
+
return __tnEvalIrNode(caseNode.node, ctx, baseOffset);
|
|
644
679
|
}
|
|
645
680
|
}
|
|
646
|
-
if (node.default) return __tnEvalIrNode(node.default, ctx);
|
|
681
|
+
if (node.default) return __tnEvalIrNode(node.default, ctx, baseOffset);
|
|
647
682
|
__tnRaiseIrError(
|
|
648
683
|
"tn.ir.invalid_tag",
|
|
649
684
|
`Unhandled IR switch value ${tagNumber} for '${node.tag}'`
|
|
@@ -663,9 +698,10 @@ function __tnEvalIrNode(node: __TnIrNode, ctx: __TnIrContext): bigint {
|
|
|
663
698
|
nestedParams[arg.name] = val;
|
|
664
699
|
}
|
|
665
700
|
if (ctx.buffer) {
|
|
701
|
+
const nestedOffset = __tnBigIntToNumber(baseOffset, "IR nested offset");
|
|
666
702
|
const nestedResult = __tnInvokeValidate(
|
|
667
703
|
node.typeName,
|
|
668
|
-
ctx.buffer,
|
|
704
|
+
ctx.buffer.subarray(nestedOffset),
|
|
669
705
|
nestedParams
|
|
670
706
|
);
|
|
671
707
|
if (!nestedResult.ok) {
|
|
@@ -685,6 +721,36 @@ function __tnEvalIrNode(node: __TnIrNode, ctx: __TnIrContext): bigint {
|
|
|
685
721
|
}
|
|
686
722
|
return __tnInvokeFootprint(node.typeName, nestedParams);
|
|
687
723
|
}
|
|
724
|
+
case "sumOverArray": {
|
|
725
|
+
if (!ctx.buffer) {
|
|
726
|
+
__tnRaiseIrError(
|
|
727
|
+
"tn.ir.missing_buffer",
|
|
728
|
+
`Jagged array '${node.fieldName}' requires buffer-backed validation`
|
|
729
|
+
);
|
|
730
|
+
}
|
|
731
|
+
const count = __tnBigIntToNumber(
|
|
732
|
+
__tnEvalIrNode(node.count, ctx, baseOffset),
|
|
733
|
+
`Jagged array '${node.fieldName}' count`
|
|
734
|
+
);
|
|
735
|
+
let cursor = __tnBigIntToNumber(baseOffset, "IR jagged array offset");
|
|
736
|
+
let total = __tnToBigInt(0);
|
|
737
|
+
for (let i = 0; i < count; i++) {
|
|
738
|
+
const result = __tnInvokeDynamicValidate(
|
|
739
|
+
node.elementTypeName,
|
|
740
|
+
ctx.buffer.subarray(cursor)
|
|
741
|
+
);
|
|
742
|
+
if (!result.ok || result.consumed === undefined) {
|
|
743
|
+
const code = result.code ?? "tn.ir.runtime_error";
|
|
744
|
+
__tnRaiseIrError(
|
|
745
|
+
code,
|
|
746
|
+
`Jagged array '${node.fieldName}' element ${i} failed validation`
|
|
747
|
+
);
|
|
748
|
+
}
|
|
749
|
+
cursor += __tnBigIntToNumber(result.consumed, "IR jagged element size");
|
|
750
|
+
total = __tnCheckedAdd(total, result.consumed);
|
|
751
|
+
}
|
|
752
|
+
return total;
|
|
753
|
+
}
|
|
688
754
|
default:
|
|
689
755
|
__tnRaiseIrError(
|
|
690
756
|
"tn.ir.runtime_error",
|
|
@@ -719,6 +785,18 @@ function __tnNormalizeIrError(err: unknown): string {
|
|
|
719
785
|
return "tn.ir.runtime_error";
|
|
720
786
|
}
|
|
721
787
|
|
|
788
|
+
__tnRegisterFootprint("InstructionData", (params) => InstructionData.__tnInvokeFootprint(params));
|
|
789
|
+
__tnRegisterValidate("InstructionData", (buffer, params) => InstructionData.__tnInvokeValidate(buffer, params));
|
|
790
|
+
__tnRegisterDynamicValidate("InstructionData", (buffer) => { const result = InstructionData.validate(buffer); return { ok: result.ok, code: result.code, consumed: result.consumed === undefined ? undefined : __tnToBigInt(result.consumed) }; });
|
|
791
|
+
|
|
792
|
+
__tnRegisterFootprint("Pubkey", (params) => Pubkey.__tnInvokeFootprint(params));
|
|
793
|
+
__tnRegisterValidate("Pubkey", (buffer, params) => Pubkey.__tnInvokeValidate(buffer, params));
|
|
794
|
+
__tnRegisterDynamicValidate("Pubkey", (buffer) => { const result = Pubkey.validate(buffer); return { ok: result.ok, code: result.code, consumed: result.consumed === undefined ? undefined : __tnToBigInt(result.consumed) }; });
|
|
795
|
+
|
|
796
|
+
__tnRegisterFootprint("StateProof", (params) => StateProof.__tnInvokeFootprint(params));
|
|
797
|
+
__tnRegisterValidate("StateProof", (buffer, params) => StateProof.__tnInvokeValidate(buffer, params));
|
|
798
|
+
__tnRegisterDynamicValidate("StateProof", (buffer) => { const result = StateProof.validate(buffer); return { ok: result.ok, code: result.code, consumed: result.consumed === undefined ? undefined : __tnToBigInt(result.consumed) }; });
|
|
799
|
+
|
|
722
800
|
/* ----- TYPE DEFINITION FOR Authority ----- */
|
|
723
801
|
|
|
724
802
|
const __tn_ir_Authority = {
|
|
@@ -840,9 +918,6 @@ export class Authority {
|
|
|
840
918
|
|
|
841
919
|
}
|
|
842
920
|
|
|
843
|
-
__tnRegisterFootprint("Authority", (params) => Authority.__tnInvokeFootprint(params));
|
|
844
|
-
__tnRegisterValidate("Authority", (buffer, params) => Authority.__tnInvokeValidate(buffer, params));
|
|
845
|
-
|
|
846
921
|
export class AuthorityBuilder {
|
|
847
922
|
private buffer: Uint8Array;
|
|
848
923
|
private view: DataView;
|
|
@@ -883,6 +958,10 @@ export class AuthorityBuilder {
|
|
|
883
958
|
}
|
|
884
959
|
}
|
|
885
960
|
|
|
961
|
+
__tnRegisterFootprint("Authority", (params) => Authority.__tnInvokeFootprint(params));
|
|
962
|
+
__tnRegisterValidate("Authority", (buffer, params) => Authority.__tnInvokeValidate(buffer, params));
|
|
963
|
+
__tnRegisterDynamicValidate("Authority", (buffer) => { const result = Authority.validate(buffer); return { ok: result.ok, code: result.code, consumed: result.consumed === undefined ? undefined : __tnToBigInt(result.consumed) }; });
|
|
964
|
+
|
|
886
965
|
/* ----- TYPE DEFINITION FOR P256Point ----- */
|
|
887
966
|
|
|
888
967
|
const __tn_ir_P256Point = {
|
|
@@ -980,12 +1059,13 @@ export class P256Point {
|
|
|
980
1059
|
|
|
981
1060
|
__tnRegisterFootprint("P256Point", (params) => P256Point.__tnInvokeFootprint(params));
|
|
982
1061
|
__tnRegisterValidate("P256Point", (buffer, params) => P256Point.__tnInvokeValidate(buffer, params));
|
|
1062
|
+
__tnRegisterDynamicValidate("P256Point", (buffer) => { const result = P256Point.validate(buffer); return { ok: result.ok, code: result.code, consumed: result.consumed === undefined ? undefined : __tnToBigInt(result.consumed) }; });
|
|
983
1063
|
|
|
984
1064
|
/* ----- TYPE DEFINITION FOR RemoveAuthorityArgs ----- */
|
|
985
1065
|
|
|
986
1066
|
const __tn_ir_RemoveAuthorityArgs = {
|
|
987
1067
|
typeName: "RemoveAuthorityArgs",
|
|
988
|
-
root: { op: "const", value:
|
|
1068
|
+
root: { op: "const", value: 3n }
|
|
989
1069
|
} as const;
|
|
990
1070
|
|
|
991
1071
|
export class RemoveAuthorityArgs {
|
|
@@ -1009,13 +1089,31 @@ export class RemoveAuthorityArgs {
|
|
|
1009
1089
|
return RemoveAuthorityArgs.from_array(buffer);
|
|
1010
1090
|
}
|
|
1011
1091
|
|
|
1012
|
-
|
|
1092
|
+
get_wallet_account_idx(): number {
|
|
1093
|
+
const offset = 0;
|
|
1094
|
+
return this.view.getUint16(offset, true); /* little-endian */
|
|
1095
|
+
}
|
|
1096
|
+
|
|
1097
|
+
set_wallet_account_idx(value: number): void {
|
|
1013
1098
|
const offset = 0;
|
|
1099
|
+
this.view.setUint16(offset, value, true); /* little-endian */
|
|
1100
|
+
}
|
|
1101
|
+
|
|
1102
|
+
get wallet_account_idx(): number {
|
|
1103
|
+
return this.get_wallet_account_idx();
|
|
1104
|
+
}
|
|
1105
|
+
|
|
1106
|
+
set wallet_account_idx(value: number) {
|
|
1107
|
+
this.set_wallet_account_idx(value);
|
|
1108
|
+
}
|
|
1109
|
+
|
|
1110
|
+
get_auth_idx(): number {
|
|
1111
|
+
const offset = 2;
|
|
1014
1112
|
return this.view.getUint8(offset);
|
|
1015
1113
|
}
|
|
1016
1114
|
|
|
1017
1115
|
set_auth_idx(value: number): void {
|
|
1018
|
-
const offset =
|
|
1116
|
+
const offset = 2;
|
|
1019
1117
|
this.view.setUint8(offset, value);
|
|
1020
1118
|
}
|
|
1021
1119
|
|
|
@@ -1057,16 +1155,17 @@ export class RemoveAuthorityArgs {
|
|
|
1057
1155
|
}
|
|
1058
1156
|
|
|
1059
1157
|
static validate(buffer: Uint8Array, _opts?: { params?: never }): { ok: boolean; code?: string; consumed?: number } {
|
|
1060
|
-
if (buffer.length <
|
|
1061
|
-
return { ok: true, consumed:
|
|
1158
|
+
if (buffer.length < 3) return { ok: false, code: "tn.buffer_too_small", consumed: 3 };
|
|
1159
|
+
return { ok: true, consumed: 3 };
|
|
1062
1160
|
}
|
|
1063
1161
|
|
|
1064
|
-
static new(auth_idx: number): RemoveAuthorityArgs {
|
|
1065
|
-
const buffer = new Uint8Array(
|
|
1162
|
+
static new(wallet_account_idx: number, auth_idx: number): RemoveAuthorityArgs {
|
|
1163
|
+
const buffer = new Uint8Array(3);
|
|
1066
1164
|
const view = new DataView(buffer.buffer);
|
|
1067
1165
|
|
|
1068
1166
|
let offset = 0;
|
|
1069
|
-
view.
|
|
1167
|
+
view.setUint16(0, wallet_account_idx, true); /* wallet_account_idx (little-endian) */
|
|
1168
|
+
view.setUint8(2, auth_idx); /* auth_idx */
|
|
1070
1169
|
|
|
1071
1170
|
return new RemoveAuthorityArgs(buffer);
|
|
1072
1171
|
}
|
|
@@ -1085,20 +1184,22 @@ export class RemoveAuthorityArgs {
|
|
|
1085
1184
|
|
|
1086
1185
|
}
|
|
1087
1186
|
|
|
1088
|
-
__tnRegisterFootprint("RemoveAuthorityArgs", (params) => RemoveAuthorityArgs.__tnInvokeFootprint(params));
|
|
1089
|
-
__tnRegisterValidate("RemoveAuthorityArgs", (buffer, params) => RemoveAuthorityArgs.__tnInvokeValidate(buffer, params));
|
|
1090
|
-
|
|
1091
1187
|
export class RemoveAuthorityArgsBuilder {
|
|
1092
1188
|
private buffer: Uint8Array;
|
|
1093
1189
|
private view: DataView;
|
|
1094
1190
|
|
|
1095
1191
|
constructor() {
|
|
1096
|
-
this.buffer = new Uint8Array(
|
|
1192
|
+
this.buffer = new Uint8Array(3);
|
|
1097
1193
|
this.view = new DataView(this.buffer.buffer, this.buffer.byteOffset, this.buffer.byteLength);
|
|
1098
1194
|
}
|
|
1099
1195
|
|
|
1196
|
+
set_wallet_account_idx(value: number): this {
|
|
1197
|
+
this.view.setUint16(0, value, true);
|
|
1198
|
+
return this;
|
|
1199
|
+
}
|
|
1200
|
+
|
|
1100
1201
|
set_auth_idx(value: number): this {
|
|
1101
|
-
this.view.setUint8(
|
|
1202
|
+
this.view.setUint8(2, value);
|
|
1102
1203
|
return this;
|
|
1103
1204
|
}
|
|
1104
1205
|
|
|
@@ -1119,6 +1220,10 @@ export class RemoveAuthorityArgsBuilder {
|
|
|
1119
1220
|
}
|
|
1120
1221
|
}
|
|
1121
1222
|
|
|
1223
|
+
__tnRegisterFootprint("RemoveAuthorityArgs", (params) => RemoveAuthorityArgs.__tnInvokeFootprint(params));
|
|
1224
|
+
__tnRegisterValidate("RemoveAuthorityArgs", (buffer, params) => RemoveAuthorityArgs.__tnInvokeValidate(buffer, params));
|
|
1225
|
+
__tnRegisterDynamicValidate("RemoveAuthorityArgs", (buffer) => { const result = RemoveAuthorityArgs.validate(buffer); return { ok: result.ok, code: result.code, consumed: result.consumed === undefined ? undefined : __tnToBigInt(result.consumed) }; });
|
|
1226
|
+
|
|
1122
1227
|
/* ----- TYPE DEFINITION FOR Seed32 ----- */
|
|
1123
1228
|
|
|
1124
1229
|
const __tn_ir_Seed32 = {
|
|
@@ -1216,6 +1321,7 @@ export class Seed32 {
|
|
|
1216
1321
|
|
|
1217
1322
|
__tnRegisterFootprint("Seed32", (params) => Seed32.__tnInvokeFootprint(params));
|
|
1218
1323
|
__tnRegisterValidate("Seed32", (buffer, params) => Seed32.__tnInvokeValidate(buffer, params));
|
|
1324
|
+
__tnRegisterDynamicValidate("Seed32", (buffer) => { const result = Seed32.validate(buffer); return { ok: result.ok, code: result.code, consumed: result.consumed === undefined ? undefined : __tnToBigInt(result.consumed) }; });
|
|
1219
1325
|
|
|
1220
1326
|
/* ----- TYPE DEFINITION FOR TransferArgs ----- */
|
|
1221
1327
|
|
|
@@ -1359,9 +1465,6 @@ export class TransferArgs {
|
|
|
1359
1465
|
|
|
1360
1466
|
}
|
|
1361
1467
|
|
|
1362
|
-
__tnRegisterFootprint("TransferArgs", (params) => TransferArgs.__tnInvokeFootprint(params));
|
|
1363
|
-
__tnRegisterValidate("TransferArgs", (buffer, params) => TransferArgs.__tnInvokeValidate(buffer, params));
|
|
1364
|
-
|
|
1365
1468
|
export class TransferArgsBuilder {
|
|
1366
1469
|
private buffer: Uint8Array;
|
|
1367
1470
|
private view: DataView;
|
|
@@ -1404,11 +1507,15 @@ export class TransferArgsBuilder {
|
|
|
1404
1507
|
}
|
|
1405
1508
|
}
|
|
1406
1509
|
|
|
1510
|
+
__tnRegisterFootprint("TransferArgs", (params) => TransferArgs.__tnInvokeFootprint(params));
|
|
1511
|
+
__tnRegisterValidate("TransferArgs", (buffer, params) => TransferArgs.__tnInvokeValidate(buffer, params));
|
|
1512
|
+
__tnRegisterDynamicValidate("TransferArgs", (buffer) => { const result = TransferArgs.validate(buffer); return { ok: result.ok, code: result.code, consumed: result.consumed === undefined ? undefined : __tnToBigInt(result.consumed) }; });
|
|
1513
|
+
|
|
1407
1514
|
/* ----- TYPE DEFINITION FOR ValidateArgs ----- */
|
|
1408
1515
|
|
|
1409
1516
|
const __tn_ir_ValidateArgs = {
|
|
1410
1517
|
typeName: "ValidateArgs",
|
|
1411
|
-
root: { op: "align", alignment: 1, node: { op: "add", left: { op: "add", left: { op: "add", left: { op: "add", left: { op: "add", left: { op: "add", left: { op: "add", left: { op: "align", alignment: 2, node: { op: "const", value: 2n } }, right: { op: "align", alignment: 1, node: { op: "const", value: 1n } } }, right: { op: "align", alignment: 1, node: { op: "const", value: 32n } } }, right: { op: "align", alignment: 1, node: { op: "const", value: 32n } } }, right: { op: "align", alignment: 2, node: { op: "const", value: 2n } } }, right: { op: "align", alignment: 2, node: { op: "const", value: 2n } } }, right: { op: "align", alignment: 1, node: { op: "mul", left: { op: "field", param: "authenticator_data.authenticator_data_len" }, right: { op: "const", value: 1n } } } }, right: { op: "align", alignment: 1, node: { op: "mul", left: { op: "field", param: "client_data.client_data_len" }, right: { op: "const", value: 1n } } } } }
|
|
1518
|
+
root: { op: "align", alignment: 1, node: { op: "add", left: { op: "add", left: { op: "add", left: { op: "add", left: { op: "add", left: { op: "add", left: { op: "add", left: { op: "add", left: { op: "align", alignment: 2, node: { op: "const", value: 2n } }, right: { op: "align", alignment: 1, node: { op: "const", value: 1n } } }, right: { op: "align", alignment: 1, node: { op: "const", value: 32n } } }, right: { op: "align", alignment: 1, node: { op: "const", value: 32n } } }, right: { op: "align", alignment: 2, node: { op: "const", value: 2n } } }, right: { op: "align", alignment: 2, node: { op: "const", value: 2n } } }, right: { op: "align", alignment: 1, node: { op: "mul", left: { op: "field", param: "authenticator_data.authenticator_data_len" }, right: { op: "const", value: 1n } } } }, right: { op: "align", alignment: 1, node: { op: "mul", left: { op: "field", param: "client_data.client_data_len" }, right: { op: "const", value: 1n } } } }, right: { op: "align", alignment: 1, node: { op: "call", typeName: "InstructionData", args: [{ name: "data.data_size", source: "data.data_size" }] } } } }
|
|
1412
1519
|
} as const;
|
|
1413
1520
|
|
|
1414
1521
|
export class ValidateArgs {
|
|
@@ -1466,16 +1573,6 @@ export class ValidateArgs {
|
|
|
1466
1573
|
throw new Error("ValidateArgs: field reference '" + path + "' is not available; provide fieldContext when creating this view");
|
|
1467
1574
|
}
|
|
1468
1575
|
|
|
1469
|
-
static builder(): ValidateArgsBuilder {
|
|
1470
|
-
return new ValidateArgsBuilder();
|
|
1471
|
-
}
|
|
1472
|
-
|
|
1473
|
-
static fromBuilder(builder: ValidateArgsBuilder): ValidateArgs | null {
|
|
1474
|
-
const buffer = builder.build();
|
|
1475
|
-
const params = builder.dynamicParams();
|
|
1476
|
-
return ValidateArgs.from_array(buffer, { params });
|
|
1477
|
-
}
|
|
1478
|
-
|
|
1479
1576
|
static readonly flexibleArrayWriters = Object.freeze([
|
|
1480
1577
|
{ field: "authenticator_data", method: "authenticator_data", sizeField: "authenticator_data_len", paramKey: "authenticator_data_len", elementSize: 1 },
|
|
1481
1578
|
{ field: "client_data", method: "client_data", sizeField: "client_data_len", paramKey: "client_data_len", elementSize: 1 },
|
|
@@ -1522,6 +1619,7 @@ export class ValidateArgs {
|
|
|
1522
1619
|
offsets["client_data"] = __tnCursorMutable;
|
|
1523
1620
|
if (__tnCursorMutable + __tnArrayBytes_client_data > __tnLength) return null;
|
|
1524
1621
|
__tnCursorMutable += __tnArrayBytes_client_data;
|
|
1622
|
+
return null;
|
|
1525
1623
|
return { params: null, offsets: offsets, derived: null };
|
|
1526
1624
|
}
|
|
1527
1625
|
|
|
@@ -1751,6 +1849,34 @@ export class ValidateArgs {
|
|
|
1751
1849
|
set client_data(value: number[]) {
|
|
1752
1850
|
this.set_client_data(value);
|
|
1753
1851
|
}
|
|
1852
|
+
|
|
1853
|
+
get_target_instruction(): InstructionData {
|
|
1854
|
+
const offset = this.__tnGetDynamicOffset("target_instruction");
|
|
1855
|
+
const tail = this.buffer.subarray(offset);
|
|
1856
|
+
const validation = InstructionData.validate(tail);
|
|
1857
|
+
if (!validation.ok || validation.consumed === undefined) {
|
|
1858
|
+
throw new Error("ValidateArgs: failed to read field 'target_instruction' (invalid nested payload)");
|
|
1859
|
+
}
|
|
1860
|
+
const length = validation.consumed;
|
|
1861
|
+
const slice = tail.subarray(0, length);
|
|
1862
|
+
const opts = validation.params ? { params: validation.params } : undefined;
|
|
1863
|
+
return InstructionData.from_array(slice, opts)!;
|
|
1864
|
+
}
|
|
1865
|
+
|
|
1866
|
+
set_target_instruction(value: InstructionData): void {
|
|
1867
|
+
/* Copy bytes from source struct to this field */
|
|
1868
|
+
const sourceBytes = (value as any).buffer as Uint8Array;
|
|
1869
|
+
const offset = this.__tnGetDynamicOffset("target_instruction");
|
|
1870
|
+
this.buffer.set(sourceBytes, offset);
|
|
1871
|
+
}
|
|
1872
|
+
|
|
1873
|
+
get target_instruction(): InstructionData {
|
|
1874
|
+
return this.get_target_instruction();
|
|
1875
|
+
}
|
|
1876
|
+
|
|
1877
|
+
set target_instruction(value: InstructionData) {
|
|
1878
|
+
this.set_target_instruction(value);
|
|
1879
|
+
}
|
|
1754
1880
|
private static __tnFootprintInternal(__tnParams: Record<string, bigint>): bigint {
|
|
1755
1881
|
return __tnEvalFootprint(__tn_ir_ValidateArgs.root, { params: __tnParams });
|
|
1756
1882
|
}
|
|
@@ -1884,164 +2010,7 @@ export namespace ValidateArgs {
|
|
|
1884
2010
|
|
|
1885
2011
|
__tnRegisterFootprint("ValidateArgs", (params) => ValidateArgs.__tnInvokeFootprint(params));
|
|
1886
2012
|
__tnRegisterValidate("ValidateArgs", (buffer, params) => ValidateArgs.__tnInvokeValidate(buffer, params));
|
|
1887
|
-
|
|
1888
|
-
export class ValidateArgsBuilder {
|
|
1889
|
-
private buffer: Uint8Array;
|
|
1890
|
-
private view: DataView;
|
|
1891
|
-
private __tnCachedParams: ValidateArgs.Params | null = null;
|
|
1892
|
-
private __tnLastBuffer: Uint8Array | null = null;
|
|
1893
|
-
private __tnLastParams: ValidateArgs.Params | null = null;
|
|
1894
|
-
private __tnFam_authenticator_data: Uint8Array | null = null;
|
|
1895
|
-
private __tnFam_authenticator_dataCount: number | null = null;
|
|
1896
|
-
private __tnFamWriter_authenticator_data?: __TnFamWriterResult<ValidateArgsBuilder>;
|
|
1897
|
-
private __tnFam_client_data: Uint8Array | null = null;
|
|
1898
|
-
private __tnFam_client_dataCount: number | null = null;
|
|
1899
|
-
private __tnFamWriter_client_data?: __TnFamWriterResult<ValidateArgsBuilder>;
|
|
1900
|
-
|
|
1901
|
-
constructor() {
|
|
1902
|
-
this.buffer = new Uint8Array(71);
|
|
1903
|
-
this.view = new DataView(this.buffer.buffer, this.buffer.byteOffset, this.buffer.byteLength);
|
|
1904
|
-
}
|
|
1905
|
-
|
|
1906
|
-
private __tnInvalidate(): void {
|
|
1907
|
-
this.__tnCachedParams = null;
|
|
1908
|
-
this.__tnLastBuffer = null;
|
|
1909
|
-
this.__tnLastParams = null;
|
|
1910
|
-
}
|
|
1911
|
-
|
|
1912
|
-
set_wallet_account_idx(value: number): this {
|
|
1913
|
-
this.view.setUint16(0, value, true);
|
|
1914
|
-
this.__tnInvalidate();
|
|
1915
|
-
return this;
|
|
1916
|
-
}
|
|
1917
|
-
|
|
1918
|
-
set_auth_idx(value: number): this {
|
|
1919
|
-
this.view.setUint8(2, value);
|
|
1920
|
-
this.__tnInvalidate();
|
|
1921
|
-
return this;
|
|
1922
|
-
}
|
|
1923
|
-
|
|
1924
|
-
set_signature_r(value: Uint8Array): this {
|
|
1925
|
-
if (value.length !== 32) throw new Error("signature_r expects 32 bytes");
|
|
1926
|
-
this.buffer.set(value, 3);
|
|
1927
|
-
this.__tnInvalidate();
|
|
1928
|
-
return this;
|
|
1929
|
-
}
|
|
1930
|
-
|
|
1931
|
-
set_signature_s(value: Uint8Array): this {
|
|
1932
|
-
if (value.length !== 32) throw new Error("signature_s expects 32 bytes");
|
|
1933
|
-
this.buffer.set(value, 35);
|
|
1934
|
-
this.__tnInvalidate();
|
|
1935
|
-
return this;
|
|
1936
|
-
}
|
|
1937
|
-
|
|
1938
|
-
set_authenticator_data_len(value: number): this {
|
|
1939
|
-
this.view.setUint16(67, value, true);
|
|
1940
|
-
this.__tnInvalidate();
|
|
1941
|
-
return this;
|
|
1942
|
-
}
|
|
1943
|
-
|
|
1944
|
-
set_client_data_len(value: number): this {
|
|
1945
|
-
this.view.setUint16(69, value, true);
|
|
1946
|
-
this.__tnInvalidate();
|
|
1947
|
-
return this;
|
|
1948
|
-
}
|
|
1949
|
-
|
|
1950
|
-
authenticator_data(): __TnFamWriterResult<ValidateArgsBuilder> {
|
|
1951
|
-
if (!this.__tnFamWriter_authenticator_data) {
|
|
1952
|
-
this.__tnFamWriter_authenticator_data = __tnCreateFamWriter(this, "authenticator_data", (payload) => {
|
|
1953
|
-
const bytes = new Uint8Array(payload);
|
|
1954
|
-
const elementCount = bytes.length;
|
|
1955
|
-
this.__tnFam_authenticator_data = bytes;
|
|
1956
|
-
this.__tnFam_authenticator_dataCount = elementCount;
|
|
1957
|
-
this.set_authenticator_data_len(elementCount);
|
|
1958
|
-
this.__tnInvalidate();
|
|
1959
|
-
});
|
|
1960
|
-
}
|
|
1961
|
-
return this.__tnFamWriter_authenticator_data!;
|
|
1962
|
-
}
|
|
1963
|
-
|
|
1964
|
-
client_data(): __TnFamWriterResult<ValidateArgsBuilder> {
|
|
1965
|
-
if (!this.__tnFamWriter_client_data) {
|
|
1966
|
-
this.__tnFamWriter_client_data = __tnCreateFamWriter(this, "client_data", (payload) => {
|
|
1967
|
-
const bytes = new Uint8Array(payload);
|
|
1968
|
-
const elementCount = bytes.length;
|
|
1969
|
-
this.__tnFam_client_data = bytes;
|
|
1970
|
-
this.__tnFam_client_dataCount = elementCount;
|
|
1971
|
-
this.set_client_data_len(elementCount);
|
|
1972
|
-
this.__tnInvalidate();
|
|
1973
|
-
});
|
|
1974
|
-
}
|
|
1975
|
-
return this.__tnFamWriter_client_data!;
|
|
1976
|
-
}
|
|
1977
|
-
|
|
1978
|
-
build(): Uint8Array {
|
|
1979
|
-
const params = this.__tnComputeParams();
|
|
1980
|
-
const size = ValidateArgs.footprintFromParams(params);
|
|
1981
|
-
const buffer = new Uint8Array(size);
|
|
1982
|
-
this.__tnWriteInto(buffer);
|
|
1983
|
-
this.__tnValidateOrThrow(buffer, params);
|
|
1984
|
-
return buffer;
|
|
1985
|
-
}
|
|
1986
|
-
|
|
1987
|
-
buildInto(target: Uint8Array, offset = 0): Uint8Array {
|
|
1988
|
-
const params = this.__tnComputeParams();
|
|
1989
|
-
const size = ValidateArgs.footprintFromParams(params);
|
|
1990
|
-
if (target.length - offset < size) throw new Error("ValidateArgsBuilder: target buffer too small");
|
|
1991
|
-
const slice = target.subarray(offset, offset + size);
|
|
1992
|
-
this.__tnWriteInto(slice);
|
|
1993
|
-
this.__tnValidateOrThrow(slice, params);
|
|
1994
|
-
return target;
|
|
1995
|
-
}
|
|
1996
|
-
|
|
1997
|
-
finish(): ValidateArgs {
|
|
1998
|
-
const buffer = this.build();
|
|
1999
|
-
const params = this.__tnLastParams ?? this.__tnComputeParams();
|
|
2000
|
-
const view = ValidateArgs.from_array(buffer, { params });
|
|
2001
|
-
if (!view) throw new Error("ValidateArgsBuilder: failed to finalize view");
|
|
2002
|
-
return view;
|
|
2003
|
-
}
|
|
2004
|
-
|
|
2005
|
-
finishView(): ValidateArgs {
|
|
2006
|
-
return this.finish();
|
|
2007
|
-
}
|
|
2008
|
-
|
|
2009
|
-
dynamicParams(): ValidateArgs.Params {
|
|
2010
|
-
return this.__tnComputeParams();
|
|
2011
|
-
}
|
|
2012
|
-
|
|
2013
|
-
private __tnComputeParams(): ValidateArgs.Params {
|
|
2014
|
-
if (this.__tnCachedParams) return this.__tnCachedParams;
|
|
2015
|
-
const params = ValidateArgs.Params.fromValues({
|
|
2016
|
-
authenticator_data_authenticator_data_len: (() => { if (this.__tnFam_authenticator_dataCount === null) throw new Error("ValidateArgsBuilder: field 'authenticator_data' must be written before computing params"); return __tnToBigInt(this.__tnFam_authenticator_dataCount); })(),
|
|
2017
|
-
client_data_client_data_len: (() => { if (this.__tnFam_client_dataCount === null) throw new Error("ValidateArgsBuilder: field 'client_data' must be written before computing params"); return __tnToBigInt(this.__tnFam_client_dataCount); })(),
|
|
2018
|
-
});
|
|
2019
|
-
this.__tnCachedParams = params;
|
|
2020
|
-
return params;
|
|
2021
|
-
}
|
|
2022
|
-
|
|
2023
|
-
private __tnWriteInto(target: Uint8Array): void {
|
|
2024
|
-
target.set(this.buffer, 0);
|
|
2025
|
-
let cursor = this.buffer.length;
|
|
2026
|
-
const __tnLocal_authenticator_data_bytes = this.__tnFam_authenticator_data;
|
|
2027
|
-
if (!__tnLocal_authenticator_data_bytes) throw new Error("ValidateArgsBuilder: field 'authenticator_data' must be written before build");
|
|
2028
|
-
target.set(__tnLocal_authenticator_data_bytes, cursor);
|
|
2029
|
-
cursor += __tnLocal_authenticator_data_bytes.length;
|
|
2030
|
-
const __tnLocal_client_data_bytes = this.__tnFam_client_data;
|
|
2031
|
-
if (!__tnLocal_client_data_bytes) throw new Error("ValidateArgsBuilder: field 'client_data' must be written before build");
|
|
2032
|
-
target.set(__tnLocal_client_data_bytes, cursor);
|
|
2033
|
-
cursor += __tnLocal_client_data_bytes.length;
|
|
2034
|
-
}
|
|
2035
|
-
|
|
2036
|
-
private __tnValidateOrThrow(buffer: Uint8Array, params: ValidateArgs.Params): void {
|
|
2037
|
-
const result = ValidateArgs.validate(buffer, { params });
|
|
2038
|
-
if (!result.ok) {
|
|
2039
|
-
throw new Error(`${ ValidateArgs }Builder: builder produced invalid buffer (code=${result.code ?? "unknown"})`);
|
|
2040
|
-
}
|
|
2041
|
-
this.__tnLastParams = result.params ?? params;
|
|
2042
|
-
this.__tnLastBuffer = buffer;
|
|
2043
|
-
}
|
|
2044
|
-
}
|
|
2013
|
+
__tnRegisterDynamicValidate("ValidateArgs", (buffer) => { const result = ValidateArgs.validate(buffer); return { ok: result.ok, code: result.code, consumed: result.consumed === undefined ? undefined : __tnToBigInt(result.consumed) }; });
|
|
2045
2014
|
|
|
2046
2015
|
/* ----- TYPE DEFINITION FOR WalletAccount ----- */
|
|
2047
2016
|
|
|
@@ -2166,9 +2135,6 @@ export class WalletAccount {
|
|
|
2166
2135
|
|
|
2167
2136
|
}
|
|
2168
2137
|
|
|
2169
|
-
__tnRegisterFootprint("WalletAccount", (params) => WalletAccount.__tnInvokeFootprint(params));
|
|
2170
|
-
__tnRegisterValidate("WalletAccount", (buffer, params) => WalletAccount.__tnInvokeValidate(buffer, params));
|
|
2171
|
-
|
|
2172
2138
|
export class WalletAccountBuilder {
|
|
2173
2139
|
private buffer: Uint8Array;
|
|
2174
2140
|
private view: DataView;
|
|
@@ -2206,6 +2172,10 @@ export class WalletAccountBuilder {
|
|
|
2206
2172
|
}
|
|
2207
2173
|
}
|
|
2208
2174
|
|
|
2175
|
+
__tnRegisterFootprint("WalletAccount", (params) => WalletAccount.__tnInvokeFootprint(params));
|
|
2176
|
+
__tnRegisterValidate("WalletAccount", (buffer, params) => WalletAccount.__tnInvokeValidate(buffer, params));
|
|
2177
|
+
__tnRegisterDynamicValidate("WalletAccount", (buffer) => { const result = WalletAccount.validate(buffer); return { ok: result.ok, code: result.code, consumed: result.consumed === undefined ? undefined : __tnToBigInt(result.consumed) }; });
|
|
2178
|
+
|
|
2209
2179
|
/* ----- TYPE DEFINITION FOR WalletCreatedEventData ----- */
|
|
2210
2180
|
|
|
2211
2181
|
const __tn_ir_WalletCreatedEventData = {
|
|
@@ -2324,9 +2294,6 @@ export class WalletCreatedEventData {
|
|
|
2324
2294
|
|
|
2325
2295
|
}
|
|
2326
2296
|
|
|
2327
|
-
__tnRegisterFootprint("WalletCreatedEventData", (params) => WalletCreatedEventData.__tnInvokeFootprint(params));
|
|
2328
|
-
__tnRegisterValidate("WalletCreatedEventData", (buffer, params) => WalletCreatedEventData.__tnInvokeValidate(buffer, params));
|
|
2329
|
-
|
|
2330
2297
|
export class WalletCreatedEventDataBuilder {
|
|
2331
2298
|
private buffer: Uint8Array;
|
|
2332
2299
|
private view: DataView;
|
|
@@ -2365,6 +2332,10 @@ export class WalletCreatedEventDataBuilder {
|
|
|
2365
2332
|
}
|
|
2366
2333
|
}
|
|
2367
2334
|
|
|
2335
|
+
__tnRegisterFootprint("WalletCreatedEventData", (params) => WalletCreatedEventData.__tnInvokeFootprint(params));
|
|
2336
|
+
__tnRegisterValidate("WalletCreatedEventData", (buffer, params) => WalletCreatedEventData.__tnInvokeValidate(buffer, params));
|
|
2337
|
+
__tnRegisterDynamicValidate("WalletCreatedEventData", (buffer) => { const result = WalletCreatedEventData.validate(buffer); return { ok: result.ok, code: result.code, consumed: result.consumed === undefined ? undefined : __tnToBigInt(result.consumed) }; });
|
|
2338
|
+
|
|
2368
2339
|
/* ----- TYPE DEFINITION FOR WalletTransferEventData ----- */
|
|
2369
2340
|
|
|
2370
2341
|
const __tn_ir_WalletTransferEventData = {
|
|
@@ -2501,9 +2472,6 @@ export class WalletTransferEventData {
|
|
|
2501
2472
|
|
|
2502
2473
|
}
|
|
2503
2474
|
|
|
2504
|
-
__tnRegisterFootprint("WalletTransferEventData", (params) => WalletTransferEventData.__tnInvokeFootprint(params));
|
|
2505
|
-
__tnRegisterValidate("WalletTransferEventData", (buffer, params) => WalletTransferEventData.__tnInvokeValidate(buffer, params));
|
|
2506
|
-
|
|
2507
2475
|
export class WalletTransferEventDataBuilder {
|
|
2508
2476
|
private buffer: Uint8Array;
|
|
2509
2477
|
private view: DataView;
|
|
@@ -2548,6 +2516,10 @@ export class WalletTransferEventDataBuilder {
|
|
|
2548
2516
|
}
|
|
2549
2517
|
}
|
|
2550
2518
|
|
|
2519
|
+
__tnRegisterFootprint("WalletTransferEventData", (params) => WalletTransferEventData.__tnInvokeFootprint(params));
|
|
2520
|
+
__tnRegisterValidate("WalletTransferEventData", (buffer, params) => WalletTransferEventData.__tnInvokeValidate(buffer, params));
|
|
2521
|
+
__tnRegisterDynamicValidate("WalletTransferEventData", (buffer) => { const result = WalletTransferEventData.validate(buffer); return { ok: result.ok, code: result.code, consumed: result.consumed === undefined ? undefined : __tnToBigInt(result.consumed) }; });
|
|
2522
|
+
|
|
2551
2523
|
/* ----- TYPE DEFINITION FOR WalletValidatedEventData ----- */
|
|
2552
2524
|
|
|
2553
2525
|
const __tn_ir_WalletValidatedEventData = {
|
|
@@ -2663,9 +2635,6 @@ export class WalletValidatedEventData {
|
|
|
2663
2635
|
|
|
2664
2636
|
}
|
|
2665
2637
|
|
|
2666
|
-
__tnRegisterFootprint("WalletValidatedEventData", (params) => WalletValidatedEventData.__tnInvokeFootprint(params));
|
|
2667
|
-
__tnRegisterValidate("WalletValidatedEventData", (buffer, params) => WalletValidatedEventData.__tnInvokeValidate(buffer, params));
|
|
2668
|
-
|
|
2669
2638
|
export class WalletValidatedEventDataBuilder {
|
|
2670
2639
|
private buffer: Uint8Array;
|
|
2671
2640
|
private view: DataView;
|
|
@@ -2704,11 +2673,15 @@ export class WalletValidatedEventDataBuilder {
|
|
|
2704
2673
|
}
|
|
2705
2674
|
}
|
|
2706
2675
|
|
|
2676
|
+
__tnRegisterFootprint("WalletValidatedEventData", (params) => WalletValidatedEventData.__tnInvokeFootprint(params));
|
|
2677
|
+
__tnRegisterValidate("WalletValidatedEventData", (buffer, params) => WalletValidatedEventData.__tnInvokeValidate(buffer, params));
|
|
2678
|
+
__tnRegisterDynamicValidate("WalletValidatedEventData", (buffer) => { const result = WalletValidatedEventData.validate(buffer); return { ok: result.ok, code: result.code, consumed: result.consumed === undefined ? undefined : __tnToBigInt(result.consumed) }; });
|
|
2679
|
+
|
|
2707
2680
|
/* ----- TYPE DEFINITION FOR AddAuthorityArgs ----- */
|
|
2708
2681
|
|
|
2709
2682
|
const __tn_ir_AddAuthorityArgs = {
|
|
2710
2683
|
typeName: "AddAuthorityArgs",
|
|
2711
|
-
root: { op: "const", value:
|
|
2684
|
+
root: { op: "const", value: 67n }
|
|
2712
2685
|
} as const;
|
|
2713
2686
|
|
|
2714
2687
|
export class AddAuthorityArgs {
|
|
@@ -2732,8 +2705,26 @@ export class AddAuthorityArgs {
|
|
|
2732
2705
|
return AddAuthorityArgs.from_array(buffer);
|
|
2733
2706
|
}
|
|
2734
2707
|
|
|
2735
|
-
|
|
2708
|
+
get_wallet_account_idx(): number {
|
|
2709
|
+
const offset = 0;
|
|
2710
|
+
return this.view.getUint16(offset, true); /* little-endian */
|
|
2711
|
+
}
|
|
2712
|
+
|
|
2713
|
+
set_wallet_account_idx(value: number): void {
|
|
2736
2714
|
const offset = 0;
|
|
2715
|
+
this.view.setUint16(offset, value, true); /* little-endian */
|
|
2716
|
+
}
|
|
2717
|
+
|
|
2718
|
+
get wallet_account_idx(): number {
|
|
2719
|
+
return this.get_wallet_account_idx();
|
|
2720
|
+
}
|
|
2721
|
+
|
|
2722
|
+
set wallet_account_idx(value: number) {
|
|
2723
|
+
this.set_wallet_account_idx(value);
|
|
2724
|
+
}
|
|
2725
|
+
|
|
2726
|
+
get_authority(): Authority {
|
|
2727
|
+
const offset = 2;
|
|
2737
2728
|
const slice = this.buffer.subarray(offset, offset + 65);
|
|
2738
2729
|
return Authority.from_array(slice)!;
|
|
2739
2730
|
}
|
|
@@ -2741,7 +2732,7 @@ export class AddAuthorityArgs {
|
|
|
2741
2732
|
set_authority(value: Authority): void {
|
|
2742
2733
|
/* Copy bytes from source struct to this field */
|
|
2743
2734
|
const sourceBytes = (value as any).buffer as Uint8Array;
|
|
2744
|
-
const offset =
|
|
2735
|
+
const offset = 2;
|
|
2745
2736
|
this.buffer.set(sourceBytes, offset);
|
|
2746
2737
|
}
|
|
2747
2738
|
|
|
@@ -2783,8 +2774,8 @@ export class AddAuthorityArgs {
|
|
|
2783
2774
|
}
|
|
2784
2775
|
|
|
2785
2776
|
static validate(buffer: Uint8Array, _opts?: { params?: never }): { ok: boolean; code?: string; consumed?: number } {
|
|
2786
|
-
if (buffer.length <
|
|
2787
|
-
return { ok: true, consumed:
|
|
2777
|
+
if (buffer.length < 67) return { ok: false, code: "tn.buffer_too_small", consumed: 67 };
|
|
2778
|
+
return { ok: true, consumed: 67 };
|
|
2788
2779
|
}
|
|
2789
2780
|
|
|
2790
2781
|
static from_array(buffer: Uint8Array): AddAuthorityArgs | null {
|
|
@@ -2801,21 +2792,23 @@ export class AddAuthorityArgs {
|
|
|
2801
2792
|
|
|
2802
2793
|
}
|
|
2803
2794
|
|
|
2804
|
-
__tnRegisterFootprint("AddAuthorityArgs", (params) => AddAuthorityArgs.__tnInvokeFootprint(params));
|
|
2805
|
-
__tnRegisterValidate("AddAuthorityArgs", (buffer, params) => AddAuthorityArgs.__tnInvokeValidate(buffer, params));
|
|
2806
|
-
|
|
2807
2795
|
export class AddAuthorityArgsBuilder {
|
|
2808
2796
|
private buffer: Uint8Array;
|
|
2809
2797
|
private view: DataView;
|
|
2810
2798
|
|
|
2811
2799
|
constructor() {
|
|
2812
|
-
this.buffer = new Uint8Array(
|
|
2800
|
+
this.buffer = new Uint8Array(67);
|
|
2813
2801
|
this.view = new DataView(this.buffer.buffer, this.buffer.byteOffset, this.buffer.byteLength);
|
|
2814
2802
|
}
|
|
2815
2803
|
|
|
2804
|
+
set_wallet_account_idx(value: number): this {
|
|
2805
|
+
this.view.setUint16(0, value, true);
|
|
2806
|
+
return this;
|
|
2807
|
+
}
|
|
2808
|
+
|
|
2816
2809
|
set_authority(value: Uint8Array): this {
|
|
2817
2810
|
if (value.length !== 65) throw new Error("authority expects 65 bytes");
|
|
2818
|
-
this.buffer.set(value,
|
|
2811
|
+
this.buffer.set(value, 2);
|
|
2819
2812
|
return this;
|
|
2820
2813
|
}
|
|
2821
2814
|
|
|
@@ -2836,7 +2829,11 @@ export class AddAuthorityArgsBuilder {
|
|
|
2836
2829
|
}
|
|
2837
2830
|
}
|
|
2838
2831
|
|
|
2839
|
-
|
|
2832
|
+
__tnRegisterFootprint("AddAuthorityArgs", (params) => AddAuthorityArgs.__tnInvokeFootprint(params));
|
|
2833
|
+
__tnRegisterValidate("AddAuthorityArgs", (buffer, params) => AddAuthorityArgs.__tnInvokeValidate(buffer, params));
|
|
2834
|
+
__tnRegisterDynamicValidate("AddAuthorityArgs", (buffer) => { const result = AddAuthorityArgs.validate(buffer); return { ok: result.ok, code: result.code, consumed: result.consumed === undefined ? undefined : __tnToBigInt(result.consumed) }; });
|
|
2835
|
+
|
|
2836
|
+
/* ----- TYPE DEFINITION FOR CredentialLookup ----- */
|
|
2840
2837
|
|
|
2841
2838
|
const __tn_ir_CredentialLookup = {
|
|
2842
2839
|
typeName: "CredentialLookup",
|
|
@@ -2933,9 +2930,6 @@ export class CredentialLookup {
|
|
|
2933
2930
|
|
|
2934
2931
|
}
|
|
2935
2932
|
|
|
2936
|
-
__tnRegisterFootprint("CredentialLookup", (params) => CredentialLookup.__tnInvokeFootprint(params));
|
|
2937
|
-
__tnRegisterValidate("CredentialLookup", (buffer, params) => CredentialLookup.__tnInvokeValidate(buffer, params));
|
|
2938
|
-
|
|
2939
2933
|
export class CredentialLookupBuilder {
|
|
2940
2934
|
private buffer: Uint8Array;
|
|
2941
2935
|
private view: DataView;
|
|
@@ -2968,6 +2962,10 @@ export class CredentialLookupBuilder {
|
|
|
2968
2962
|
}
|
|
2969
2963
|
}
|
|
2970
2964
|
|
|
2965
|
+
__tnRegisterFootprint("CredentialLookup", (params) => CredentialLookup.__tnInvokeFootprint(params));
|
|
2966
|
+
__tnRegisterValidate("CredentialLookup", (buffer, params) => CredentialLookup.__tnInvokeValidate(buffer, params));
|
|
2967
|
+
__tnRegisterDynamicValidate("CredentialLookup", (buffer) => { const result = CredentialLookup.validate(buffer); return { ok: result.ok, code: result.code, consumed: result.consumed === undefined ? undefined : __tnToBigInt(result.consumed) }; });
|
|
2968
|
+
|
|
2971
2969
|
/* ----- TYPE DEFINITION FOR CredentialRegisteredEventData ----- */
|
|
2972
2970
|
|
|
2973
2971
|
const __tn_ir_CredentialRegisteredEventData = {
|
|
@@ -3086,9 +3084,6 @@ export class CredentialRegisteredEventData {
|
|
|
3086
3084
|
|
|
3087
3085
|
}
|
|
3088
3086
|
|
|
3089
|
-
__tnRegisterFootprint("CredentialRegisteredEventData", (params) => CredentialRegisteredEventData.__tnInvokeFootprint(params));
|
|
3090
|
-
__tnRegisterValidate("CredentialRegisteredEventData", (buffer, params) => CredentialRegisteredEventData.__tnInvokeValidate(buffer, params));
|
|
3091
|
-
|
|
3092
3087
|
export class CredentialRegisteredEventDataBuilder {
|
|
3093
3088
|
private buffer: Uint8Array;
|
|
3094
3089
|
private view: DataView;
|
|
@@ -3127,407 +3122,9 @@ export class CredentialRegisteredEventDataBuilder {
|
|
|
3127
3122
|
}
|
|
3128
3123
|
}
|
|
3129
3124
|
|
|
3130
|
-
|
|
3131
|
-
|
|
3132
|
-
const
|
|
3133
|
-
typeName: "InvokeArgs",
|
|
3134
|
-
root: { op: "align", alignment: 1, node: { op: "add", left: { op: "add", left: { op: "align", alignment: 1, node: { op: "const", value: 32n } }, right: { op: "align", alignment: 2, node: { op: "const", value: 2n } } }, right: { op: "align", alignment: 1, node: { op: "mul", left: { op: "field", param: "instr.instr_len" }, right: { op: "const", value: 1n } } } } }
|
|
3135
|
-
} as const;
|
|
3136
|
-
|
|
3137
|
-
export class InvokeArgs {
|
|
3138
|
-
private view: DataView;
|
|
3139
|
-
private __tnFieldContext: Record<string, number | bigint> | null = null;
|
|
3140
|
-
private __tnParams: InvokeArgs.Params;
|
|
3141
|
-
|
|
3142
|
-
private constructor(private buffer: Uint8Array, params?: InvokeArgs.Params, fieldContext?: Record<string, number | bigint>) {
|
|
3143
|
-
this.view = new DataView(buffer.buffer, buffer.byteOffset, buffer.byteLength);
|
|
3144
|
-
this.__tnFieldContext = fieldContext ?? null;
|
|
3145
|
-
if (params) {
|
|
3146
|
-
this.__tnParams = params;
|
|
3147
|
-
} else {
|
|
3148
|
-
const derived = InvokeArgs.__tnExtractParams(this.view, buffer);
|
|
3149
|
-
if (!derived) {
|
|
3150
|
-
throw new Error("InvokeArgs: failed to derive dynamic parameters");
|
|
3151
|
-
}
|
|
3152
|
-
this.__tnParams = derived.params;
|
|
3153
|
-
}
|
|
3154
|
-
}
|
|
3155
|
-
|
|
3156
|
-
static __tnCreateView(buffer: Uint8Array, opts?: { params?: InvokeArgs.Params, fieldContext?: Record<string, number | bigint> }): InvokeArgs {
|
|
3157
|
-
if (!buffer || buffer.length === undefined) throw new Error("InvokeArgs.__tnCreateView requires a Uint8Array");
|
|
3158
|
-
let params = opts?.params ?? null;
|
|
3159
|
-
if (!params) {
|
|
3160
|
-
const view = new DataView(buffer.buffer, buffer.byteOffset, buffer.byteLength);
|
|
3161
|
-
const derived = InvokeArgs.__tnExtractParams(view, buffer);
|
|
3162
|
-
if (!derived) throw new Error("InvokeArgs.__tnCreateView: failed to derive params");
|
|
3163
|
-
params = derived.params;
|
|
3164
|
-
}
|
|
3165
|
-
const instance = new InvokeArgs(new Uint8Array(buffer), params, opts?.fieldContext);
|
|
3166
|
-
return instance;
|
|
3167
|
-
}
|
|
3168
|
-
|
|
3169
|
-
dynamicParams(): InvokeArgs.Params {
|
|
3170
|
-
return this.__tnParams;
|
|
3171
|
-
}
|
|
3172
|
-
|
|
3173
|
-
withFieldContext(context: Record<string, number | bigint>): this {
|
|
3174
|
-
this.__tnFieldContext = context;
|
|
3175
|
-
return this;
|
|
3176
|
-
}
|
|
3177
|
-
|
|
3178
|
-
private __tnResolveFieldRef(path: string): number {
|
|
3179
|
-
const getterName = `get_${path.replace(/[.]/g, '_')}`;
|
|
3180
|
-
const getter = (this as any)[getterName];
|
|
3181
|
-
if (typeof getter === "function") {
|
|
3182
|
-
const value = getter.call(this);
|
|
3183
|
-
return typeof value === "bigint" ? __tnBigIntToNumber(value, "InvokeArgs::__tnResolveFieldRef") : value;
|
|
3184
|
-
}
|
|
3185
|
-
if (this.__tnFieldContext && Object.prototype.hasOwnProperty.call(this.__tnFieldContext, path)) {
|
|
3186
|
-
const contextValue = this.__tnFieldContext[path];
|
|
3187
|
-
return typeof contextValue === "bigint" ? __tnBigIntToNumber(contextValue, "InvokeArgs::__tnResolveFieldRef") : contextValue;
|
|
3188
|
-
}
|
|
3189
|
-
throw new Error("InvokeArgs: field reference '" + path + "' is not available; provide fieldContext when creating this view");
|
|
3190
|
-
}
|
|
3191
|
-
|
|
3192
|
-
static builder(): InvokeArgsBuilder {
|
|
3193
|
-
return new InvokeArgsBuilder();
|
|
3194
|
-
}
|
|
3195
|
-
|
|
3196
|
-
static fromBuilder(builder: InvokeArgsBuilder): InvokeArgs | null {
|
|
3197
|
-
const buffer = builder.build();
|
|
3198
|
-
const params = builder.dynamicParams();
|
|
3199
|
-
return InvokeArgs.from_array(buffer, { params });
|
|
3200
|
-
}
|
|
3201
|
-
|
|
3202
|
-
static readonly flexibleArrayWriters = Object.freeze([
|
|
3203
|
-
{ field: "instr", method: "instr", sizeField: "instr_len", paramKey: "instr_len", elementSize: 1 },
|
|
3204
|
-
] as const);
|
|
3205
|
-
|
|
3206
|
-
private static __tnExtractParams(view: DataView, buffer: Uint8Array): { params: InvokeArgs.Params; derived: Record<string, bigint> | null } | null {
|
|
3207
|
-
if (buffer.length < 34) {
|
|
3208
|
-
return null;
|
|
3209
|
-
}
|
|
3210
|
-
const __tnParam_instr_instr_len = __tnToBigInt(view.getUint16(32, true));
|
|
3211
|
-
const __tnExtractedParams = InvokeArgs.Params.fromValues({
|
|
3212
|
-
instr_instr_len: __tnParam_instr_instr_len,
|
|
3213
|
-
});
|
|
3214
|
-
return { params: __tnExtractedParams, derived: null };
|
|
3215
|
-
}
|
|
3216
|
-
|
|
3217
|
-
get_program_pubkey(): Pubkey {
|
|
3218
|
-
const offset = 0;
|
|
3219
|
-
const slice = this.buffer.subarray(offset, offset + 32);
|
|
3220
|
-
return Pubkey.from_array(slice)!;
|
|
3221
|
-
}
|
|
3222
|
-
|
|
3223
|
-
set_program_pubkey(value: Pubkey): void {
|
|
3224
|
-
/* Copy bytes from source struct to this field */
|
|
3225
|
-
const sourceBytes = (value as any).buffer as Uint8Array;
|
|
3226
|
-
const offset = 0;
|
|
3227
|
-
this.buffer.set(sourceBytes, offset);
|
|
3228
|
-
}
|
|
3229
|
-
|
|
3230
|
-
get program_pubkey(): Pubkey {
|
|
3231
|
-
return this.get_program_pubkey();
|
|
3232
|
-
}
|
|
3233
|
-
|
|
3234
|
-
set program_pubkey(value: Pubkey) {
|
|
3235
|
-
this.set_program_pubkey(value);
|
|
3236
|
-
}
|
|
3237
|
-
|
|
3238
|
-
get_instr_len(): number {
|
|
3239
|
-
const offset = 32;
|
|
3240
|
-
return this.view.getUint16(offset, true); /* little-endian */
|
|
3241
|
-
}
|
|
3242
|
-
|
|
3243
|
-
set_instr_len(value: number): void {
|
|
3244
|
-
const offset = 32;
|
|
3245
|
-
this.view.setUint16(offset, value, true); /* little-endian */
|
|
3246
|
-
}
|
|
3247
|
-
|
|
3248
|
-
get instr_len(): number {
|
|
3249
|
-
return this.get_instr_len();
|
|
3250
|
-
}
|
|
3251
|
-
|
|
3252
|
-
set instr_len(value: number) {
|
|
3253
|
-
this.set_instr_len(value);
|
|
3254
|
-
}
|
|
3255
|
-
|
|
3256
|
-
get_instr_length(): number {
|
|
3257
|
-
return this.__tnResolveFieldRef("instr_len");
|
|
3258
|
-
}
|
|
3259
|
-
|
|
3260
|
-
get_instr_at(index: number): number {
|
|
3261
|
-
const offset = 34;
|
|
3262
|
-
return this.view.getUint8(offset + index * 1);
|
|
3263
|
-
}
|
|
3264
|
-
|
|
3265
|
-
get_instr(): number[] {
|
|
3266
|
-
const len = this.get_instr_length();
|
|
3267
|
-
const result: number[] = [];
|
|
3268
|
-
for (let i = 0; i < len; i++) {
|
|
3269
|
-
result.push(this.get_instr_at(i));
|
|
3270
|
-
}
|
|
3271
|
-
return result;
|
|
3272
|
-
}
|
|
3273
|
-
|
|
3274
|
-
set_instr_at(index: number, value: number): void {
|
|
3275
|
-
const offset = 34;
|
|
3276
|
-
this.view.setUint8((offset + index * 1), value);
|
|
3277
|
-
}
|
|
3278
|
-
|
|
3279
|
-
set_instr(value: number[]): void {
|
|
3280
|
-
const len = Math.min(this.get_instr_length(), value.length);
|
|
3281
|
-
for (let i = 0; i < len; i++) {
|
|
3282
|
-
this.set_instr_at(i, value[i]);
|
|
3283
|
-
}
|
|
3284
|
-
}
|
|
3285
|
-
|
|
3286
|
-
get instr(): number[] {
|
|
3287
|
-
return this.get_instr();
|
|
3288
|
-
}
|
|
3289
|
-
|
|
3290
|
-
set instr(value: number[]) {
|
|
3291
|
-
this.set_instr(value);
|
|
3292
|
-
}
|
|
3293
|
-
private static __tnFootprintInternal(__tnParams: Record<string, bigint>): bigint {
|
|
3294
|
-
return __tnEvalFootprint(__tn_ir_InvokeArgs.root, { params: __tnParams });
|
|
3295
|
-
}
|
|
3296
|
-
|
|
3297
|
-
private static __tnValidateInternal(buffer: Uint8Array, __tnParams: Record<string, bigint>): { ok: boolean; code?: string; consumed?: bigint } {
|
|
3298
|
-
return __tnValidateIrTree(__tn_ir_InvokeArgs, buffer, __tnParams);
|
|
3299
|
-
}
|
|
3300
|
-
|
|
3301
|
-
static __tnInvokeFootprint(__tnParams: Record<string, bigint>): bigint {
|
|
3302
|
-
return this.__tnFootprintInternal(__tnParams);
|
|
3303
|
-
}
|
|
3304
|
-
|
|
3305
|
-
static __tnInvokeValidate(buffer: Uint8Array, __tnParams: Record<string, bigint>): __TnValidateResult {
|
|
3306
|
-
return this.__tnValidateInternal(buffer, __tnParams);
|
|
3307
|
-
}
|
|
3308
|
-
|
|
3309
|
-
static footprintIr(instr_instr_len: number | bigint): bigint {
|
|
3310
|
-
const params = InvokeArgs.Params.fromValues({
|
|
3311
|
-
instr_instr_len: instr_instr_len,
|
|
3312
|
-
});
|
|
3313
|
-
return this.footprintIrFromParams(params);
|
|
3314
|
-
}
|
|
3315
|
-
|
|
3316
|
-
private static __tnPackParams(params: InvokeArgs.Params): Record<string, bigint> {
|
|
3317
|
-
const record: Record<string, bigint> = Object.create(null);
|
|
3318
|
-
record["instr.instr_len"] = params.instr_instr_len;
|
|
3319
|
-
return record;
|
|
3320
|
-
}
|
|
3321
|
-
|
|
3322
|
-
static footprintIrFromParams(params: InvokeArgs.Params): bigint {
|
|
3323
|
-
const __tnParams = this.__tnPackParams(params);
|
|
3324
|
-
return this.__tnFootprintInternal(__tnParams);
|
|
3325
|
-
}
|
|
3326
|
-
|
|
3327
|
-
static footprintFromParams(params: InvokeArgs.Params): number {
|
|
3328
|
-
const irResult = this.footprintIrFromParams(params);
|
|
3329
|
-
const maxSafe = __tnToBigInt(Number.MAX_SAFE_INTEGER);
|
|
3330
|
-
if (__tnBigIntGreaterThan(irResult, maxSafe)) throw new Error('footprint exceeds Number.MAX_SAFE_INTEGER for InvokeArgs');
|
|
3331
|
-
return __tnBigIntToNumber(irResult, 'InvokeArgs::footprintFromParams');
|
|
3332
|
-
}
|
|
3333
|
-
|
|
3334
|
-
static footprintFromValues(input: { instr_instr_len: number | bigint }): number {
|
|
3335
|
-
const params = InvokeArgs.params(input);
|
|
3336
|
-
return this.footprintFromParams(params);
|
|
3337
|
-
}
|
|
3338
|
-
|
|
3339
|
-
static footprint(params: InvokeArgs.Params): number {
|
|
3340
|
-
return this.footprintFromParams(params);
|
|
3341
|
-
}
|
|
3342
|
-
|
|
3343
|
-
static validate(buffer: Uint8Array, opts?: { params?: InvokeArgs.Params }): { ok: boolean; code?: string; consumed?: number; params?: InvokeArgs.Params } {
|
|
3344
|
-
if (!buffer || buffer.length === undefined) {
|
|
3345
|
-
return { ok: false, code: "tn.invalid_buffer" };
|
|
3346
|
-
}
|
|
3347
|
-
const view = new DataView(buffer.buffer, buffer.byteOffset, buffer.byteLength);
|
|
3348
|
-
let params = opts?.params ?? null;
|
|
3349
|
-
if (!params) {
|
|
3350
|
-
const extracted = this.__tnExtractParams(view, buffer);
|
|
3351
|
-
if (!extracted) return { ok: false, code: "tn.param_extraction_failed" };
|
|
3352
|
-
params = extracted.params;
|
|
3353
|
-
}
|
|
3354
|
-
const __tnParamsRec = this.__tnPackParams(params);
|
|
3355
|
-
const irResult = this.__tnValidateInternal(buffer, __tnParamsRec);
|
|
3356
|
-
if (!irResult.ok) {
|
|
3357
|
-
return { ok: false, code: irResult.code, consumed: irResult.consumed ? __tnBigIntToNumber(irResult.consumed, 'InvokeArgs::validate') : undefined, params };
|
|
3358
|
-
}
|
|
3359
|
-
const consumed = irResult.consumed ? __tnBigIntToNumber(irResult.consumed, 'InvokeArgs::validate') : undefined;
|
|
3360
|
-
return { ok: true, consumed, params };
|
|
3361
|
-
}
|
|
3362
|
-
|
|
3363
|
-
static from_array(buffer: Uint8Array, opts?: { params?: InvokeArgs.Params }): InvokeArgs | null {
|
|
3364
|
-
if (!buffer || buffer.length === undefined) {
|
|
3365
|
-
return null;
|
|
3366
|
-
}
|
|
3367
|
-
const view = new DataView(buffer.buffer, buffer.byteOffset, buffer.byteLength);
|
|
3368
|
-
let params = opts?.params ?? null;
|
|
3369
|
-
if (!params) {
|
|
3370
|
-
const derived = this.__tnExtractParams(view, buffer);
|
|
3371
|
-
if (!derived) return null;
|
|
3372
|
-
params = derived.params;
|
|
3373
|
-
}
|
|
3374
|
-
const validation = this.validate(buffer, { params });
|
|
3375
|
-
if (!validation.ok) {
|
|
3376
|
-
return null;
|
|
3377
|
-
}
|
|
3378
|
-
const cached = validation.params ?? params;
|
|
3379
|
-
const state = new InvokeArgs(buffer, cached);
|
|
3380
|
-
return state;
|
|
3381
|
-
}
|
|
3382
|
-
|
|
3383
|
-
|
|
3384
|
-
}
|
|
3385
|
-
|
|
3386
|
-
export namespace InvokeArgs {
|
|
3387
|
-
export type Params = {
|
|
3388
|
-
/** ABI path: instr.instr_len */
|
|
3389
|
-
readonly instr_instr_len: bigint;
|
|
3390
|
-
};
|
|
3391
|
-
|
|
3392
|
-
export const ParamKeys = Object.freeze({
|
|
3393
|
-
instr_instr_len: "instr.instr_len",
|
|
3394
|
-
} as const);
|
|
3395
|
-
|
|
3396
|
-
export const Params = {
|
|
3397
|
-
fromValues(input: { instr_instr_len: number | bigint }): Params {
|
|
3398
|
-
return {
|
|
3399
|
-
instr_instr_len: __tnToBigInt(input.instr_instr_len),
|
|
3400
|
-
};
|
|
3401
|
-
},
|
|
3402
|
-
fromBuilder(source: { dynamicParams(): Params } | { params: Params } | Params): Params {
|
|
3403
|
-
if ((source as { dynamicParams?: () => Params }).dynamicParams) {
|
|
3404
|
-
return (source as { dynamicParams(): Params }).dynamicParams();
|
|
3405
|
-
}
|
|
3406
|
-
if ((source as { params?: Params }).params) {
|
|
3407
|
-
return (source as { params: Params }).params;
|
|
3408
|
-
}
|
|
3409
|
-
return source as Params;
|
|
3410
|
-
}
|
|
3411
|
-
};
|
|
3412
|
-
|
|
3413
|
-
export function params(input: { instr_instr_len: number | bigint }): Params {
|
|
3414
|
-
return Params.fromValues(input);
|
|
3415
|
-
}
|
|
3416
|
-
}
|
|
3417
|
-
|
|
3418
|
-
__tnRegisterFootprint("InvokeArgs", (params) => InvokeArgs.__tnInvokeFootprint(params));
|
|
3419
|
-
__tnRegisterValidate("InvokeArgs", (buffer, params) => InvokeArgs.__tnInvokeValidate(buffer, params));
|
|
3420
|
-
|
|
3421
|
-
export class InvokeArgsBuilder {
|
|
3422
|
-
private buffer: Uint8Array;
|
|
3423
|
-
private view: DataView;
|
|
3424
|
-
private __tnCachedParams: InvokeArgs.Params | null = null;
|
|
3425
|
-
private __tnLastBuffer: Uint8Array | null = null;
|
|
3426
|
-
private __tnLastParams: InvokeArgs.Params | null = null;
|
|
3427
|
-
private __tnFam_instr: Uint8Array | null = null;
|
|
3428
|
-
private __tnFam_instrCount: number | null = null;
|
|
3429
|
-
private __tnFamWriter_instr?: __TnFamWriterResult<InvokeArgsBuilder>;
|
|
3430
|
-
|
|
3431
|
-
constructor() {
|
|
3432
|
-
this.buffer = new Uint8Array(34);
|
|
3433
|
-
this.view = new DataView(this.buffer.buffer, this.buffer.byteOffset, this.buffer.byteLength);
|
|
3434
|
-
}
|
|
3435
|
-
|
|
3436
|
-
private __tnInvalidate(): void {
|
|
3437
|
-
this.__tnCachedParams = null;
|
|
3438
|
-
this.__tnLastBuffer = null;
|
|
3439
|
-
this.__tnLastParams = null;
|
|
3440
|
-
}
|
|
3441
|
-
|
|
3442
|
-
set_program_pubkey(value: Uint8Array): this {
|
|
3443
|
-
if (value.length !== 32) throw new Error("program_pubkey expects 32 bytes");
|
|
3444
|
-
this.buffer.set(value, 0);
|
|
3445
|
-
this.__tnInvalidate();
|
|
3446
|
-
return this;
|
|
3447
|
-
}
|
|
3448
|
-
|
|
3449
|
-
set_instr_len(value: number): this {
|
|
3450
|
-
this.view.setUint16(32, value, true);
|
|
3451
|
-
this.__tnInvalidate();
|
|
3452
|
-
return this;
|
|
3453
|
-
}
|
|
3454
|
-
|
|
3455
|
-
instr(): __TnFamWriterResult<InvokeArgsBuilder> {
|
|
3456
|
-
if (!this.__tnFamWriter_instr) {
|
|
3457
|
-
this.__tnFamWriter_instr = __tnCreateFamWriter(this, "instr", (payload) => {
|
|
3458
|
-
const bytes = new Uint8Array(payload);
|
|
3459
|
-
const elementCount = bytes.length;
|
|
3460
|
-
this.__tnFam_instr = bytes;
|
|
3461
|
-
this.__tnFam_instrCount = elementCount;
|
|
3462
|
-
this.set_instr_len(elementCount);
|
|
3463
|
-
this.__tnInvalidate();
|
|
3464
|
-
});
|
|
3465
|
-
}
|
|
3466
|
-
return this.__tnFamWriter_instr!;
|
|
3467
|
-
}
|
|
3468
|
-
|
|
3469
|
-
build(): Uint8Array {
|
|
3470
|
-
const params = this.__tnComputeParams();
|
|
3471
|
-
const size = InvokeArgs.footprintFromParams(params);
|
|
3472
|
-
const buffer = new Uint8Array(size);
|
|
3473
|
-
this.__tnWriteInto(buffer);
|
|
3474
|
-
this.__tnValidateOrThrow(buffer, params);
|
|
3475
|
-
return buffer;
|
|
3476
|
-
}
|
|
3477
|
-
|
|
3478
|
-
buildInto(target: Uint8Array, offset = 0): Uint8Array {
|
|
3479
|
-
const params = this.__tnComputeParams();
|
|
3480
|
-
const size = InvokeArgs.footprintFromParams(params);
|
|
3481
|
-
if (target.length - offset < size) throw new Error("InvokeArgsBuilder: target buffer too small");
|
|
3482
|
-
const slice = target.subarray(offset, offset + size);
|
|
3483
|
-
this.__tnWriteInto(slice);
|
|
3484
|
-
this.__tnValidateOrThrow(slice, params);
|
|
3485
|
-
return target;
|
|
3486
|
-
}
|
|
3487
|
-
|
|
3488
|
-
finish(): InvokeArgs {
|
|
3489
|
-
const buffer = this.build();
|
|
3490
|
-
const params = this.__tnLastParams ?? this.__tnComputeParams();
|
|
3491
|
-
const view = InvokeArgs.from_array(buffer, { params });
|
|
3492
|
-
if (!view) throw new Error("InvokeArgsBuilder: failed to finalize view");
|
|
3493
|
-
return view;
|
|
3494
|
-
}
|
|
3495
|
-
|
|
3496
|
-
finishView(): InvokeArgs {
|
|
3497
|
-
return this.finish();
|
|
3498
|
-
}
|
|
3499
|
-
|
|
3500
|
-
dynamicParams(): InvokeArgs.Params {
|
|
3501
|
-
return this.__tnComputeParams();
|
|
3502
|
-
}
|
|
3503
|
-
|
|
3504
|
-
private __tnComputeParams(): InvokeArgs.Params {
|
|
3505
|
-
if (this.__tnCachedParams) return this.__tnCachedParams;
|
|
3506
|
-
const params = InvokeArgs.Params.fromValues({
|
|
3507
|
-
instr_instr_len: (() => { if (this.__tnFam_instrCount === null) throw new Error("InvokeArgsBuilder: field 'instr' must be written before computing params"); return __tnToBigInt(this.__tnFam_instrCount); })(),
|
|
3508
|
-
});
|
|
3509
|
-
this.__tnCachedParams = params;
|
|
3510
|
-
return params;
|
|
3511
|
-
}
|
|
3512
|
-
|
|
3513
|
-
private __tnWriteInto(target: Uint8Array): void {
|
|
3514
|
-
target.set(this.buffer, 0);
|
|
3515
|
-
let cursor = this.buffer.length;
|
|
3516
|
-
const __tnLocal_instr_bytes = this.__tnFam_instr;
|
|
3517
|
-
if (!__tnLocal_instr_bytes) throw new Error("InvokeArgsBuilder: field 'instr' must be written before build");
|
|
3518
|
-
target.set(__tnLocal_instr_bytes, cursor);
|
|
3519
|
-
cursor += __tnLocal_instr_bytes.length;
|
|
3520
|
-
}
|
|
3521
|
-
|
|
3522
|
-
private __tnValidateOrThrow(buffer: Uint8Array, params: InvokeArgs.Params): void {
|
|
3523
|
-
const result = InvokeArgs.validate(buffer, { params });
|
|
3524
|
-
if (!result.ok) {
|
|
3525
|
-
throw new Error(`${ InvokeArgs }Builder: builder produced invalid buffer (code=${result.code ?? "unknown"})`);
|
|
3526
|
-
}
|
|
3527
|
-
this.__tnLastParams = result.params ?? params;
|
|
3528
|
-
this.__tnLastBuffer = buffer;
|
|
3529
|
-
}
|
|
3530
|
-
}
|
|
3125
|
+
__tnRegisterFootprint("CredentialRegisteredEventData", (params) => CredentialRegisteredEventData.__tnInvokeFootprint(params));
|
|
3126
|
+
__tnRegisterValidate("CredentialRegisteredEventData", (buffer, params) => CredentialRegisteredEventData.__tnInvokeValidate(buffer, params));
|
|
3127
|
+
__tnRegisterDynamicValidate("CredentialRegisteredEventData", (buffer) => { const result = CredentialRegisteredEventData.validate(buffer); return { ok: result.ok, code: result.code, consumed: result.consumed === undefined ? undefined : __tnToBigInt(result.consumed) }; });
|
|
3531
3128
|
|
|
3532
3129
|
/* ----- TYPE DEFINITION FOR PasskeyEvent ----- */
|
|
3533
3130
|
|
|
@@ -3824,9 +3421,6 @@ export namespace PasskeyEvent {
|
|
|
3824
3421
|
}
|
|
3825
3422
|
}
|
|
3826
3423
|
|
|
3827
|
-
__tnRegisterFootprint("PasskeyEvent", (params) => PasskeyEvent.__tnInvokeFootprint(params));
|
|
3828
|
-
__tnRegisterValidate("PasskeyEvent", (buffer, params) => PasskeyEvent.__tnInvokeValidate(buffer, params));
|
|
3829
|
-
|
|
3830
3424
|
export class PasskeyEventBuilder {
|
|
3831
3425
|
private __tnPrefixBuffer: Uint8Array;
|
|
3832
3426
|
private __tnPrefixView: DataView;
|
|
@@ -3941,6 +3535,10 @@ export class PasskeyEventBuilder {
|
|
|
3941
3535
|
}
|
|
3942
3536
|
}
|
|
3943
3537
|
|
|
3538
|
+
__tnRegisterFootprint("PasskeyEvent", (params) => PasskeyEvent.__tnInvokeFootprint(params));
|
|
3539
|
+
__tnRegisterValidate("PasskeyEvent", (buffer, params) => PasskeyEvent.__tnInvokeValidate(buffer, params));
|
|
3540
|
+
__tnRegisterDynamicValidate("PasskeyEvent", (buffer) => { const result = PasskeyEvent.validate(buffer); return { ok: result.ok, code: result.code, consumed: result.consumed === undefined ? undefined : __tnToBigInt(result.consumed) }; });
|
|
3541
|
+
|
|
3944
3542
|
/* ----- TYPE DEFINITION FOR CreateArgs ----- */
|
|
3945
3543
|
|
|
3946
3544
|
const __tn_ir_CreateArgs = {
|
|
@@ -4105,9 +3703,6 @@ export class CreateArgs {
|
|
|
4105
3703
|
|
|
4106
3704
|
}
|
|
4107
3705
|
|
|
4108
|
-
__tnRegisterFootprint("CreateArgs", (params) => CreateArgs.__tnInvokeFootprint(params));
|
|
4109
|
-
__tnRegisterValidate("CreateArgs", (buffer, params) => CreateArgs.__tnInvokeValidate(buffer, params));
|
|
4110
|
-
|
|
4111
3706
|
export class CreateArgsBuilder {
|
|
4112
3707
|
private buffer: Uint8Array;
|
|
4113
3708
|
private view: DataView;
|
|
@@ -4214,6 +3809,10 @@ export class CreateArgsBuilder {
|
|
|
4214
3809
|
}
|
|
4215
3810
|
}
|
|
4216
3811
|
|
|
3812
|
+
__tnRegisterFootprint("CreateArgs", (params) => CreateArgs.__tnInvokeFootprint(params));
|
|
3813
|
+
__tnRegisterValidate("CreateArgs", (buffer, params) => CreateArgs.__tnInvokeValidate(buffer, params));
|
|
3814
|
+
__tnRegisterDynamicValidate("CreateArgs", (buffer) => { const result = CreateArgs.validate(buffer); return { ok: result.ok, code: result.code, consumed: result.consumed === undefined ? undefined : __tnToBigInt(result.consumed) }; });
|
|
3815
|
+
|
|
4217
3816
|
/* ----- TYPE DEFINITION FOR RegisterCredentialArgs ----- */
|
|
4218
3817
|
|
|
4219
3818
|
const __tn_ir_RegisterCredentialArgs = {
|
|
@@ -4375,9 +3974,6 @@ export class RegisterCredentialArgs {
|
|
|
4375
3974
|
|
|
4376
3975
|
}
|
|
4377
3976
|
|
|
4378
|
-
__tnRegisterFootprint("RegisterCredentialArgs", (params) => RegisterCredentialArgs.__tnInvokeFootprint(params));
|
|
4379
|
-
__tnRegisterValidate("RegisterCredentialArgs", (buffer, params) => RegisterCredentialArgs.__tnInvokeValidate(buffer, params));
|
|
4380
|
-
|
|
4381
3977
|
export class RegisterCredentialArgsBuilder {
|
|
4382
3978
|
private buffer: Uint8Array;
|
|
4383
3979
|
private view: DataView;
|
|
@@ -4483,6 +4079,10 @@ export class RegisterCredentialArgsBuilder {
|
|
|
4483
4079
|
}
|
|
4484
4080
|
}
|
|
4485
4081
|
|
|
4082
|
+
__tnRegisterFootprint("RegisterCredentialArgs", (params) => RegisterCredentialArgs.__tnInvokeFootprint(params));
|
|
4083
|
+
__tnRegisterValidate("RegisterCredentialArgs", (buffer, params) => RegisterCredentialArgs.__tnInvokeValidate(buffer, params));
|
|
4084
|
+
__tnRegisterDynamicValidate("RegisterCredentialArgs", (buffer) => { const result = RegisterCredentialArgs.validate(buffer); return { ok: result.ok, code: result.code, consumed: result.consumed === undefined ? undefined : __tnToBigInt(result.consumed) }; });
|
|
4085
|
+
|
|
4486
4086
|
/* ----- TYPE DEFINITION FOR PasskeyInstruction ----- */
|
|
4487
4087
|
|
|
4488
4088
|
const __tn_ir_PasskeyInstruction = {
|
|
@@ -4525,11 +4125,6 @@ export class PasskeyInstruction_payload_Inner {
|
|
|
4525
4125
|
return TransferArgs.__tnCreateView(new Uint8Array(this.buffer), { fieldContext: this.__tnFieldContext ?? undefined });
|
|
4526
4126
|
}
|
|
4527
4127
|
|
|
4528
|
-
asInvoke(): InvokeArgs | null {
|
|
4529
|
-
if (!this.descriptor || this.descriptor.tag !== 3) return null;
|
|
4530
|
-
return InvokeArgs.__tnCreateView(new Uint8Array(this.buffer), { fieldContext: this.__tnFieldContext ?? undefined });
|
|
4531
|
-
}
|
|
4532
|
-
|
|
4533
4128
|
asAddAuthority(): AddAuthorityArgs | null {
|
|
4534
4129
|
if (!this.descriptor || this.descriptor.tag !== 4) return null;
|
|
4535
4130
|
return AddAuthorityArgs.__tnCreateView(new Uint8Array(this.buffer), { fieldContext: this.__tnFieldContext ?? undefined });
|
|
@@ -4605,7 +4200,7 @@ export class PasskeyInstruction {
|
|
|
4605
4200
|
tag: 1,
|
|
4606
4201
|
payloadSize: null,
|
|
4607
4202
|
payloadType: "PasskeyInstruction::payload::validate",
|
|
4608
|
-
createPayloadBuilder: () =>
|
|
4203
|
+
createPayloadBuilder: () => null,
|
|
4609
4204
|
},
|
|
4610
4205
|
{
|
|
4611
4206
|
name: "transfer",
|
|
@@ -4614,24 +4209,17 @@ export class PasskeyInstruction {
|
|
|
4614
4209
|
payloadType: "PasskeyInstruction::payload::transfer",
|
|
4615
4210
|
createPayloadBuilder: () => __tnMaybeCallBuilder(TransferArgs),
|
|
4616
4211
|
},
|
|
4617
|
-
{
|
|
4618
|
-
name: "invoke",
|
|
4619
|
-
tag: 3,
|
|
4620
|
-
payloadSize: null,
|
|
4621
|
-
payloadType: "PasskeyInstruction::payload::invoke",
|
|
4622
|
-
createPayloadBuilder: () => __tnMaybeCallBuilder(InvokeArgs),
|
|
4623
|
-
},
|
|
4624
4212
|
{
|
|
4625
4213
|
name: "add_authority",
|
|
4626
4214
|
tag: 4,
|
|
4627
|
-
payloadSize:
|
|
4215
|
+
payloadSize: 67,
|
|
4628
4216
|
payloadType: "PasskeyInstruction::payload::add_authority",
|
|
4629
4217
|
createPayloadBuilder: () => __tnMaybeCallBuilder(AddAuthorityArgs),
|
|
4630
4218
|
},
|
|
4631
4219
|
{
|
|
4632
4220
|
name: "remove_authority",
|
|
4633
4221
|
tag: 5,
|
|
4634
|
-
payloadSize:
|
|
4222
|
+
payloadSize: 3,
|
|
4635
4223
|
payloadType: "PasskeyInstruction::payload::remove_authority",
|
|
4636
4224
|
createPayloadBuilder: () => __tnMaybeCallBuilder(RemoveAuthorityArgs),
|
|
4637
4225
|
},
|
|
@@ -4660,7 +4248,6 @@ export class PasskeyInstruction {
|
|
|
4660
4248
|
case 0: break;
|
|
4661
4249
|
case 1: break;
|
|
4662
4250
|
case 2: break;
|
|
4663
|
-
case 3: break;
|
|
4664
4251
|
case 4: break;
|
|
4665
4252
|
case 5: break;
|
|
4666
4253
|
case 6: break;
|
|
@@ -4857,9 +4444,6 @@ export namespace PasskeyInstruction {
|
|
|
4857
4444
|
}
|
|
4858
4445
|
}
|
|
4859
4446
|
|
|
4860
|
-
__tnRegisterFootprint("PasskeyInstruction", (params) => PasskeyInstruction.__tnInvokeFootprint(params));
|
|
4861
|
-
__tnRegisterValidate("PasskeyInstruction", (buffer, params) => PasskeyInstruction.__tnInvokeValidate(buffer, params));
|
|
4862
|
-
|
|
4863
4447
|
export class PasskeyInstructionBuilder {
|
|
4864
4448
|
private __tnPrefixBuffer: Uint8Array;
|
|
4865
4449
|
private __tnPrefixView: DataView;
|
|
@@ -4975,3 +4559,7 @@ export class PasskeyInstructionBuilder {
|
|
|
4975
4559
|
}
|
|
4976
4560
|
}
|
|
4977
4561
|
|
|
4562
|
+
__tnRegisterFootprint("PasskeyInstruction", (params) => PasskeyInstruction.__tnInvokeFootprint(params));
|
|
4563
|
+
__tnRegisterValidate("PasskeyInstruction", (buffer, params) => PasskeyInstruction.__tnInvokeValidate(buffer, params));
|
|
4564
|
+
__tnRegisterDynamicValidate("PasskeyInstruction", (buffer) => { const result = PasskeyInstruction.validate(buffer); return { ok: result.ok, code: result.code, consumed: result.consumed === undefined ? undefined : __tnToBigInt(result.consumed) }; });
|
|
4565
|
+
|