@thru/programs 0.2.27 → 0.2.29
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 +166 -24
- package/dist/multicall/index.cjs.map +1 -1
- package/dist/multicall/index.d.cts +39 -3
- package/dist/multicall/index.d.ts +39 -3
- package/dist/multicall/index.js +166 -25
- package/dist/multicall/index.js.map +1 -1
- package/dist/passkey-manager/index.cjs +1235 -345
- package/dist/passkey-manager/index.cjs.map +1 -1
- package/dist/passkey-manager/index.d.cts +45 -11
- package/dist/passkey-manager/index.d.ts +45 -11
- package/dist/passkey-manager/index.js +1225 -346
- package/dist/passkey-manager/index.js.map +1 -1
- package/package.json +2 -2
- package/src/multicall/abi/thru/common/primitives/types.ts +14 -9
- package/src/multicall/abi/thru/program/multicall/types.ts +136 -4
- package/src/multicall/index.ts +6 -17
- package/src/passkey-manager/abi/thru/blockchain/state_proof/types.ts +11 -6
- package/src/passkey-manager/abi/thru/common/primitives/types.ts +19 -14
- package/src/passkey-manager/abi/thru/program/passkey_manager/types.ts +1069 -271
- package/src/passkey-manager/accounts.ts +79 -40
- package/src/passkey-manager/constants.ts +10 -1
- package/src/passkey-manager/index.ts +18 -2
- package/src/passkey-manager/instructions/add-authority.ts +31 -3
- package/src/passkey-manager/instructions/create.ts +106 -11
- package/src/passkey-manager/instructions/invoke.ts +9 -0
- package/src/passkey-manager/instructions/shared.ts +15 -0
- package/src/passkey-manager/instructions/transfer.ts +1 -1
- package/src/passkey-manager/instructions/validate.ts +13 -43
- package/src/passkey-manager/types.ts +7 -2
- package/src/passkey-manager/validate.test.ts +71 -3
|
@@ -47,7 +47,12 @@ type __TnIrContext = {
|
|
|
47
47
|
typeName?: string;
|
|
48
48
|
};
|
|
49
49
|
|
|
50
|
-
type __TnValidateResult = {
|
|
50
|
+
type __TnValidateResult = {
|
|
51
|
+
ok: boolean;
|
|
52
|
+
code?: string;
|
|
53
|
+
consumed?: bigint;
|
|
54
|
+
params?: Record<string, bigint>;
|
|
55
|
+
};
|
|
51
56
|
type __TnEvalResult =
|
|
52
57
|
| { ok: true; value: bigint }
|
|
53
58
|
| { ok: false; code: string };
|
|
@@ -787,15 +792,15 @@ function __tnNormalizeIrError(err: unknown): string {
|
|
|
787
792
|
|
|
788
793
|
__tnRegisterFootprint("InstructionData", (params) => InstructionData.__tnInvokeFootprint(params));
|
|
789
794
|
__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) }; });
|
|
795
|
+
__tnRegisterDynamicValidate("InstructionData", (buffer) => { const result = InstructionData.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 }; });
|
|
791
796
|
|
|
792
797
|
__tnRegisterFootprint("Pubkey", (params) => Pubkey.__tnInvokeFootprint(params));
|
|
793
798
|
__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) }; });
|
|
799
|
+
__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 }; });
|
|
795
800
|
|
|
796
801
|
__tnRegisterFootprint("StateProof", (params) => StateProof.__tnInvokeFootprint(params));
|
|
797
802
|
__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) }; });
|
|
803
|
+
__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 }; });
|
|
799
804
|
|
|
800
805
|
/* ----- TYPE DEFINITION FOR Authority ----- */
|
|
801
806
|
|
|
@@ -960,7 +965,164 @@ export class AuthorityBuilder {
|
|
|
960
965
|
|
|
961
966
|
__tnRegisterFootprint("Authority", (params) => Authority.__tnInvokeFootprint(params));
|
|
962
967
|
__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) }; });
|
|
968
|
+
__tnRegisterDynamicValidate("Authority", (buffer) => { const result = Authority.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 }; });
|
|
969
|
+
|
|
970
|
+
/* ----- TYPE DEFINITION FOR AuthorityRecord ----- */
|
|
971
|
+
|
|
972
|
+
const __tn_ir_AuthorityRecord = {
|
|
973
|
+
typeName: "AuthorityRecord",
|
|
974
|
+
root: { op: "const", value: 73n }
|
|
975
|
+
} as const;
|
|
976
|
+
|
|
977
|
+
export class AuthorityRecord {
|
|
978
|
+
private view: DataView;
|
|
979
|
+
|
|
980
|
+
private constructor(private buffer: Uint8Array) {
|
|
981
|
+
this.view = new DataView(buffer.buffer, buffer.byteOffset, buffer.byteLength);
|
|
982
|
+
}
|
|
983
|
+
|
|
984
|
+
static __tnCreateView(buffer: Uint8Array, opts?: { fieldContext?: Record<string, number | bigint> }): AuthorityRecord {
|
|
985
|
+
if (!buffer || buffer.length === undefined) throw new Error("AuthorityRecord.__tnCreateView requires a Uint8Array");
|
|
986
|
+
return new AuthorityRecord(new Uint8Array(buffer));
|
|
987
|
+
}
|
|
988
|
+
|
|
989
|
+
static builder(): AuthorityRecordBuilder {
|
|
990
|
+
return new AuthorityRecordBuilder();
|
|
991
|
+
}
|
|
992
|
+
|
|
993
|
+
static fromBuilder(builder: AuthorityRecordBuilder): AuthorityRecord | null {
|
|
994
|
+
const buffer = builder.build();
|
|
995
|
+
return AuthorityRecord.from_array(buffer);
|
|
996
|
+
}
|
|
997
|
+
|
|
998
|
+
get_authority(): Authority {
|
|
999
|
+
const offset = 0;
|
|
1000
|
+
const slice = this.buffer.subarray(offset, offset + 65);
|
|
1001
|
+
return Authority.from_array(slice)!;
|
|
1002
|
+
}
|
|
1003
|
+
|
|
1004
|
+
set_authority(value: Authority): void {
|
|
1005
|
+
/* Copy bytes from source struct to this field */
|
|
1006
|
+
const sourceBytes = (value as any).buffer as Uint8Array;
|
|
1007
|
+
const offset = 0;
|
|
1008
|
+
this.buffer.set(sourceBytes, offset);
|
|
1009
|
+
}
|
|
1010
|
+
|
|
1011
|
+
get authority(): Authority {
|
|
1012
|
+
return this.get_authority();
|
|
1013
|
+
}
|
|
1014
|
+
|
|
1015
|
+
set authority(value: Authority) {
|
|
1016
|
+
this.set_authority(value);
|
|
1017
|
+
}
|
|
1018
|
+
|
|
1019
|
+
get_expires_at_block_time_seconds(): bigint {
|
|
1020
|
+
const offset = 65;
|
|
1021
|
+
return this.view.getBigUint64(offset, true); /* little-endian */
|
|
1022
|
+
}
|
|
1023
|
+
|
|
1024
|
+
set_expires_at_block_time_seconds(value: bigint): void {
|
|
1025
|
+
const offset = 65;
|
|
1026
|
+
this.view.setBigUint64(offset, value, true); /* little-endian */
|
|
1027
|
+
}
|
|
1028
|
+
|
|
1029
|
+
get expires_at_block_time_seconds(): bigint {
|
|
1030
|
+
return this.get_expires_at_block_time_seconds();
|
|
1031
|
+
}
|
|
1032
|
+
|
|
1033
|
+
set expires_at_block_time_seconds(value: bigint) {
|
|
1034
|
+
this.set_expires_at_block_time_seconds(value);
|
|
1035
|
+
}
|
|
1036
|
+
|
|
1037
|
+
private static __tnFootprintInternal(__tnParams: Record<string, bigint>): bigint {
|
|
1038
|
+
return __tnEvalFootprint(__tn_ir_AuthorityRecord.root, { params: __tnParams });
|
|
1039
|
+
}
|
|
1040
|
+
|
|
1041
|
+
private static __tnValidateInternal(buffer: Uint8Array, __tnParams: Record<string, bigint>): { ok: boolean; code?: string; consumed?: bigint } {
|
|
1042
|
+
return __tnValidateIrTree(__tn_ir_AuthorityRecord, buffer, __tnParams);
|
|
1043
|
+
}
|
|
1044
|
+
|
|
1045
|
+
static __tnInvokeFootprint(__tnParams: Record<string, bigint>): bigint {
|
|
1046
|
+
return this.__tnFootprintInternal(__tnParams);
|
|
1047
|
+
}
|
|
1048
|
+
|
|
1049
|
+
static __tnInvokeValidate(buffer: Uint8Array, __tnParams: Record<string, bigint>): __TnValidateResult {
|
|
1050
|
+
return this.__tnValidateInternal(buffer, __tnParams);
|
|
1051
|
+
}
|
|
1052
|
+
|
|
1053
|
+
static footprintIr(): bigint {
|
|
1054
|
+
return this.__tnFootprintInternal(Object.create(null));
|
|
1055
|
+
}
|
|
1056
|
+
|
|
1057
|
+
static footprint(): number {
|
|
1058
|
+
const irResult = this.footprintIr();
|
|
1059
|
+
const maxSafe = __tnToBigInt(Number.MAX_SAFE_INTEGER);
|
|
1060
|
+
if (__tnBigIntGreaterThan(irResult, maxSafe)) {
|
|
1061
|
+
throw new Error('footprint exceeds Number.MAX_SAFE_INTEGER for AuthorityRecord');
|
|
1062
|
+
}
|
|
1063
|
+
return __tnBigIntToNumber(irResult, 'AuthorityRecord::footprint');
|
|
1064
|
+
}
|
|
1065
|
+
|
|
1066
|
+
static validate(buffer: Uint8Array, _opts?: { params?: never }): { ok: boolean; code?: string; consumed?: number } {
|
|
1067
|
+
if (buffer.length < 73) return { ok: false, code: "tn.buffer_too_small", consumed: 73 };
|
|
1068
|
+
return { ok: true, consumed: 73 };
|
|
1069
|
+
}
|
|
1070
|
+
|
|
1071
|
+
static from_array(buffer: Uint8Array): AuthorityRecord | null {
|
|
1072
|
+
if (!buffer || buffer.length === undefined) {
|
|
1073
|
+
return null;
|
|
1074
|
+
}
|
|
1075
|
+
const view = new DataView(buffer.buffer, buffer.byteOffset, buffer.byteLength);
|
|
1076
|
+
const validation = this.validate(buffer);
|
|
1077
|
+
if (!validation.ok) {
|
|
1078
|
+
return null;
|
|
1079
|
+
}
|
|
1080
|
+
return new AuthorityRecord(buffer);
|
|
1081
|
+
}
|
|
1082
|
+
|
|
1083
|
+
}
|
|
1084
|
+
|
|
1085
|
+
export class AuthorityRecordBuilder {
|
|
1086
|
+
private buffer: Uint8Array;
|
|
1087
|
+
private view: DataView;
|
|
1088
|
+
|
|
1089
|
+
constructor() {
|
|
1090
|
+
this.buffer = new Uint8Array(73);
|
|
1091
|
+
this.view = new DataView(this.buffer.buffer, this.buffer.byteOffset, this.buffer.byteLength);
|
|
1092
|
+
}
|
|
1093
|
+
|
|
1094
|
+
set_authority(value: Uint8Array): this {
|
|
1095
|
+
if (value.length !== 65) throw new Error("authority expects 65 bytes");
|
|
1096
|
+
this.buffer.set(value, 0);
|
|
1097
|
+
return this;
|
|
1098
|
+
}
|
|
1099
|
+
|
|
1100
|
+
set_expires_at_block_time_seconds(value: bigint): this {
|
|
1101
|
+
const cast = __tnToBigInt(value);
|
|
1102
|
+
this.view.setBigUint64(65, cast, true);
|
|
1103
|
+
return this;
|
|
1104
|
+
}
|
|
1105
|
+
|
|
1106
|
+
build(): Uint8Array {
|
|
1107
|
+
return this.buffer.slice();
|
|
1108
|
+
}
|
|
1109
|
+
|
|
1110
|
+
buildInto(target: Uint8Array, offset = 0): Uint8Array {
|
|
1111
|
+
if (target.length - offset < this.buffer.length) throw new Error("target buffer too small");
|
|
1112
|
+
target.set(this.buffer, offset);
|
|
1113
|
+
return target;
|
|
1114
|
+
}
|
|
1115
|
+
|
|
1116
|
+
finish(): AuthorityRecord {
|
|
1117
|
+
const view = AuthorityRecord.from_array(this.buffer.slice());
|
|
1118
|
+
if (!view) throw new Error("failed to build AuthorityRecord");
|
|
1119
|
+
return view;
|
|
1120
|
+
}
|
|
1121
|
+
}
|
|
1122
|
+
|
|
1123
|
+
__tnRegisterFootprint("AuthorityRecord", (params) => AuthorityRecord.__tnInvokeFootprint(params));
|
|
1124
|
+
__tnRegisterValidate("AuthorityRecord", (buffer, params) => AuthorityRecord.__tnInvokeValidate(buffer, params));
|
|
1125
|
+
__tnRegisterDynamicValidate("AuthorityRecord", (buffer) => { const result = AuthorityRecord.validate(buffer); return { ok: result.ok, code: result.code, consumed: result.consumed === undefined ? undefined : __tnToBigInt(result.consumed) }; });
|
|
964
1126
|
|
|
965
1127
|
/* ----- TYPE DEFINITION FOR P256Point ----- */
|
|
966
1128
|
|
|
@@ -1059,7 +1221,7 @@ export class P256Point {
|
|
|
1059
1221
|
|
|
1060
1222
|
__tnRegisterFootprint("P256Point", (params) => P256Point.__tnInvokeFootprint(params));
|
|
1061
1223
|
__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) }; });
|
|
1224
|
+
__tnRegisterDynamicValidate("P256Point", (buffer) => { const result = P256Point.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 }; });
|
|
1063
1225
|
|
|
1064
1226
|
/* ----- TYPE DEFINITION FOR RemoveAuthorityArgs ----- */
|
|
1065
1227
|
|
|
@@ -1222,7 +1384,7 @@ export class RemoveAuthorityArgsBuilder {
|
|
|
1222
1384
|
|
|
1223
1385
|
__tnRegisterFootprint("RemoveAuthorityArgs", (params) => RemoveAuthorityArgs.__tnInvokeFootprint(params));
|
|
1224
1386
|
__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) }; });
|
|
1387
|
+
__tnRegisterDynamicValidate("RemoveAuthorityArgs", (buffer) => { const result = RemoveAuthorityArgs.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 }; });
|
|
1226
1388
|
|
|
1227
1389
|
/* ----- TYPE DEFINITION FOR Seed32 ----- */
|
|
1228
1390
|
|
|
@@ -1321,7 +1483,7 @@ export class Seed32 {
|
|
|
1321
1483
|
|
|
1322
1484
|
__tnRegisterFootprint("Seed32", (params) => Seed32.__tnInvokeFootprint(params));
|
|
1323
1485
|
__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) }; });
|
|
1486
|
+
__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 }; });
|
|
1325
1487
|
|
|
1326
1488
|
/* ----- TYPE DEFINITION FOR TransferArgs ----- */
|
|
1327
1489
|
|
|
@@ -1484,7 +1646,7 @@ export class TransferArgsBuilder {
|
|
|
1484
1646
|
return this;
|
|
1485
1647
|
}
|
|
1486
1648
|
|
|
1487
|
-
set_amount(value:
|
|
1649
|
+
set_amount(value: bigint): this {
|
|
1488
1650
|
const cast = __tnToBigInt(value);
|
|
1489
1651
|
this.view.setBigUint64(4, cast, true);
|
|
1490
1652
|
return this;
|
|
@@ -1509,7 +1671,7 @@ export class TransferArgsBuilder {
|
|
|
1509
1671
|
|
|
1510
1672
|
__tnRegisterFootprint("TransferArgs", (params) => TransferArgs.__tnInvokeFootprint(params));
|
|
1511
1673
|
__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) }; });
|
|
1674
|
+
__tnRegisterDynamicValidate("TransferArgs", (buffer) => { const result = TransferArgs.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 }; });
|
|
1513
1675
|
|
|
1514
1676
|
/* ----- TYPE DEFINITION FOR ValidateArgs ----- */
|
|
1515
1677
|
|
|
@@ -1573,6 +1735,16 @@ export class ValidateArgs {
|
|
|
1573
1735
|
throw new Error("ValidateArgs: field reference '" + path + "' is not available; provide fieldContext when creating this view");
|
|
1574
1736
|
}
|
|
1575
1737
|
|
|
1738
|
+
static builder(): ValidateArgsBuilder {
|
|
1739
|
+
return new ValidateArgsBuilder();
|
|
1740
|
+
}
|
|
1741
|
+
|
|
1742
|
+
static fromBuilder(builder: ValidateArgsBuilder): ValidateArgs | null {
|
|
1743
|
+
const buffer = builder.build();
|
|
1744
|
+
const params = builder.dynamicParams();
|
|
1745
|
+
return ValidateArgs.from_array(buffer, { params });
|
|
1746
|
+
}
|
|
1747
|
+
|
|
1576
1748
|
static readonly flexibleArrayWriters = Object.freeze([
|
|
1577
1749
|
{ field: "authenticator_data", method: "authenticator_data", sizeField: "authenticator_data_len", paramKey: "authenticator_data_len", elementSize: 1 },
|
|
1578
1750
|
{ field: "client_data", method: "client_data", sizeField: "client_data_len", paramKey: "client_data_len", elementSize: 1 },
|
|
@@ -1581,6 +1753,7 @@ export class ValidateArgs {
|
|
|
1581
1753
|
static __tnComputeSequentialLayout(view: DataView, buffer: Uint8Array): { params: Record<string, bigint> | null; offsets: Record<string, number> | null; derived: Record<string, bigint> | null } | null {
|
|
1582
1754
|
const offsets: Record<string, number> = Object.create(null);
|
|
1583
1755
|
const __tnLength = buffer.length;
|
|
1756
|
+
let __tnParamSeq_data_data_size: bigint | null = null;
|
|
1584
1757
|
let __tnFieldValue_wallet_account_idx: number | null = null;
|
|
1585
1758
|
let __tnFieldValue_auth_idx: number | null = null;
|
|
1586
1759
|
let __tnFieldValue_authenticator_data_len: number | null = null;
|
|
@@ -1619,8 +1792,17 @@ export class ValidateArgs {
|
|
|
1619
1792
|
offsets["client_data"] = __tnCursorMutable;
|
|
1620
1793
|
if (__tnCursorMutable + __tnArrayBytes_client_data > __tnLength) return null;
|
|
1621
1794
|
__tnCursorMutable += __tnArrayBytes_client_data;
|
|
1622
|
-
|
|
1623
|
-
|
|
1795
|
+
offsets["target_instruction"] = __tnCursorMutable;
|
|
1796
|
+
const __tnTyperefResult_target_instruction = __tnInvokeDynamicValidate("InstructionData", buffer.subarray(__tnCursorMutable));
|
|
1797
|
+
if (!__tnTyperefResult_target_instruction.ok || __tnTyperefResult_target_instruction.consumed === undefined) return null;
|
|
1798
|
+
const __tnTyperefParams_target_instruction = __tnTyperefResult_target_instruction.params ?? null;
|
|
1799
|
+
if (!__tnTyperefParams_target_instruction || __tnTyperefParams_target_instruction["data_data_size"] === undefined) return null;
|
|
1800
|
+
__tnParamSeq_data_data_size = __tnTyperefParams_target_instruction["data_data_size"];
|
|
1801
|
+
__tnCursorMutable += __tnBigIntToNumber(__tnTyperefResult_target_instruction.consumed, "ValidateArgs::target_instruction");
|
|
1802
|
+
const params: Record<string, bigint> = Object.create(null);
|
|
1803
|
+
if (__tnParamSeq_data_data_size === null) return null;
|
|
1804
|
+
params["data_data_size"] = __tnParamSeq_data_data_size as bigint;
|
|
1805
|
+
return { params, offsets: offsets, derived: null };
|
|
1624
1806
|
}
|
|
1625
1807
|
|
|
1626
1808
|
private static __tnExtractParams(view: DataView, buffer: Uint8Array): { params: ValidateArgs.Params; derived: Record<string, bigint> | null } | null {
|
|
@@ -1632,9 +1814,15 @@ export class ValidateArgs {
|
|
|
1632
1814
|
return null;
|
|
1633
1815
|
}
|
|
1634
1816
|
const __tnParam_client_data_client_data_len = __tnToBigInt(view.getUint16(69, true));
|
|
1817
|
+
const __tnLayout = ValidateArgs.__tnComputeSequentialLayout(view, buffer);
|
|
1818
|
+
if (!__tnLayout || !__tnLayout.params) return null;
|
|
1819
|
+
const __tnSeqParams = __tnLayout.params;
|
|
1820
|
+
const __tnParamSeq_data_data_size = __tnSeqParams["data_data_size"];
|
|
1821
|
+
if (__tnParamSeq_data_data_size === undefined) return null;
|
|
1635
1822
|
const __tnExtractedParams = ValidateArgs.Params.fromValues({
|
|
1636
1823
|
authenticator_data_authenticator_data_len: __tnParam_authenticator_data_authenticator_data_len,
|
|
1637
1824
|
client_data_client_data_len: __tnParam_client_data_client_data_len,
|
|
1825
|
+
data_data_size: __tnParamSeq_data_data_size as bigint,
|
|
1638
1826
|
});
|
|
1639
1827
|
return { params: __tnExtractedParams, derived: null };
|
|
1640
1828
|
}
|
|
@@ -1893,10 +2081,11 @@ export class ValidateArgs {
|
|
|
1893
2081
|
return this.__tnValidateInternal(buffer, __tnParams);
|
|
1894
2082
|
}
|
|
1895
2083
|
|
|
1896
|
-
static footprintIr(authenticator_data_authenticator_data_len: number | bigint, client_data_client_data_len: number | bigint): bigint {
|
|
2084
|
+
static footprintIr(authenticator_data_authenticator_data_len: number | bigint, client_data_client_data_len: number | bigint, data_data_size: number | bigint): bigint {
|
|
1897
2085
|
const params = ValidateArgs.Params.fromValues({
|
|
1898
2086
|
authenticator_data_authenticator_data_len: authenticator_data_authenticator_data_len,
|
|
1899
2087
|
client_data_client_data_len: client_data_client_data_len,
|
|
2088
|
+
data_data_size: data_data_size,
|
|
1900
2089
|
});
|
|
1901
2090
|
return this.footprintIrFromParams(params);
|
|
1902
2091
|
}
|
|
@@ -1905,6 +2094,7 @@ export class ValidateArgs {
|
|
|
1905
2094
|
const record: Record<string, bigint> = Object.create(null);
|
|
1906
2095
|
record["authenticator_data.authenticator_data_len"] = params.authenticator_data_authenticator_data_len;
|
|
1907
2096
|
record["client_data.client_data_len"] = params.client_data_client_data_len;
|
|
2097
|
+
record["data.data_size"] = params.data_data_size;
|
|
1908
2098
|
return record;
|
|
1909
2099
|
}
|
|
1910
2100
|
|
|
@@ -1920,7 +2110,7 @@ export class ValidateArgs {
|
|
|
1920
2110
|
return __tnBigIntToNumber(irResult, 'ValidateArgs::footprintFromParams');
|
|
1921
2111
|
}
|
|
1922
2112
|
|
|
1923
|
-
static footprintFromValues(input: { authenticator_data_authenticator_data_len: number | bigint, client_data_client_data_len: number | bigint }): number {
|
|
2113
|
+
static footprintFromValues(input: { authenticator_data_authenticator_data_len: number | bigint, client_data_client_data_len: number | bigint, data_data_size: number | bigint }): number {
|
|
1924
2114
|
const params = ValidateArgs.params(input);
|
|
1925
2115
|
return this.footprintFromParams(params);
|
|
1926
2116
|
}
|
|
@@ -1978,18 +2168,22 @@ export namespace ValidateArgs {
|
|
|
1978
2168
|
readonly authenticator_data_authenticator_data_len: bigint;
|
|
1979
2169
|
/** ABI path: client_data.client_data_len */
|
|
1980
2170
|
readonly client_data_client_data_len: bigint;
|
|
2171
|
+
/** ABI path: data.data_size */
|
|
2172
|
+
readonly data_data_size: bigint;
|
|
1981
2173
|
};
|
|
1982
2174
|
|
|
1983
2175
|
export const ParamKeys = Object.freeze({
|
|
1984
2176
|
authenticator_data_authenticator_data_len: "authenticator_data.authenticator_data_len",
|
|
1985
2177
|
client_data_client_data_len: "client_data.client_data_len",
|
|
2178
|
+
data_data_size: "data.data_size",
|
|
1986
2179
|
} as const);
|
|
1987
2180
|
|
|
1988
2181
|
export const Params = {
|
|
1989
|
-
fromValues(input: { authenticator_data_authenticator_data_len: number | bigint, client_data_client_data_len: number | bigint }): Params {
|
|
2182
|
+
fromValues(input: { authenticator_data_authenticator_data_len: number | bigint, client_data_client_data_len: number | bigint, data_data_size: number | bigint }): Params {
|
|
1990
2183
|
return {
|
|
1991
2184
|
authenticator_data_authenticator_data_len: __tnToBigInt(input.authenticator_data_authenticator_data_len),
|
|
1992
2185
|
client_data_client_data_len: __tnToBigInt(input.client_data_client_data_len),
|
|
2186
|
+
data_data_size: __tnToBigInt(input.data_data_size),
|
|
1993
2187
|
};
|
|
1994
2188
|
},
|
|
1995
2189
|
fromBuilder(source: { dynamicParams(): Params } | { params: Params } | Params): Params {
|
|
@@ -2003,178 +2197,467 @@ export namespace ValidateArgs {
|
|
|
2003
2197
|
}
|
|
2004
2198
|
};
|
|
2005
2199
|
|
|
2006
|
-
export function params(input: { authenticator_data_authenticator_data_len: number | bigint, client_data_client_data_len: number | bigint }): Params {
|
|
2200
|
+
export function params(input: { authenticator_data_authenticator_data_len: number | bigint, client_data_client_data_len: number | bigint, data_data_size: number | bigint }): Params {
|
|
2007
2201
|
return Params.fromValues(input);
|
|
2008
2202
|
}
|
|
2009
2203
|
}
|
|
2010
2204
|
|
|
2011
|
-
|
|
2012
|
-
|
|
2013
|
-
__tnRegisterDynamicValidate("ValidateArgs", (buffer) => { const result = ValidateArgs.validate(buffer); return { ok: result.ok, code: result.code, consumed: result.consumed === undefined ? undefined : __tnToBigInt(result.consumed) }; });
|
|
2014
|
-
|
|
2015
|
-
/* ----- TYPE DEFINITION FOR WalletAccount ----- */
|
|
2016
|
-
|
|
2017
|
-
const __tn_ir_WalletAccount = {
|
|
2018
|
-
typeName: "WalletAccount",
|
|
2019
|
-
root: { op: "const", value: 9n }
|
|
2020
|
-
} as const;
|
|
2021
|
-
|
|
2022
|
-
export class WalletAccount {
|
|
2205
|
+
export class ValidateArgsBuilder {
|
|
2206
|
+
private buffer: Uint8Array;
|
|
2023
2207
|
private view: DataView;
|
|
2208
|
+
private __tnCachedParams: ValidateArgs.Params | null = null;
|
|
2209
|
+
private __tnLastBuffer: Uint8Array | null = null;
|
|
2210
|
+
private __tnLastParams: ValidateArgs.Params | null = null;
|
|
2211
|
+
private __tnFam_authenticator_data: Uint8Array | null = null;
|
|
2212
|
+
private __tnFam_authenticator_dataCount: number | null = null;
|
|
2213
|
+
private __tnFamWriter_authenticator_data?: __TnFamWriterResult<ValidateArgsBuilder>;
|
|
2214
|
+
private __tnFam_client_data: Uint8Array | null = null;
|
|
2215
|
+
private __tnFam_client_dataCount: number | null = null;
|
|
2216
|
+
private __tnFamWriter_client_data?: __TnFamWriterResult<ValidateArgsBuilder>;
|
|
2217
|
+
private __tnTail_target_instruction: Uint8Array | null = null;
|
|
2218
|
+
private __tnTailParams_target_instruction: Record<string, bigint> | null = null;
|
|
2024
2219
|
|
|
2025
|
-
|
|
2026
|
-
this.
|
|
2027
|
-
|
|
2028
|
-
|
|
2029
|
-
static __tnCreateView(buffer: Uint8Array, opts?: { fieldContext?: Record<string, number | bigint> }): WalletAccount {
|
|
2030
|
-
if (!buffer || buffer.length === undefined) throw new Error("WalletAccount.__tnCreateView requires a Uint8Array");
|
|
2031
|
-
return new WalletAccount(new Uint8Array(buffer));
|
|
2220
|
+
constructor() {
|
|
2221
|
+
this.buffer = new Uint8Array(71);
|
|
2222
|
+
this.view = new DataView(this.buffer.buffer, this.buffer.byteOffset, this.buffer.byteLength);
|
|
2032
2223
|
}
|
|
2033
2224
|
|
|
2034
|
-
|
|
2035
|
-
|
|
2225
|
+
private __tnInvalidate(): void {
|
|
2226
|
+
this.__tnCachedParams = null;
|
|
2227
|
+
this.__tnLastBuffer = null;
|
|
2228
|
+
this.__tnLastParams = null;
|
|
2036
2229
|
}
|
|
2037
2230
|
|
|
2038
|
-
|
|
2039
|
-
|
|
2040
|
-
|
|
2231
|
+
set_wallet_account_idx(value: number): this {
|
|
2232
|
+
this.view.setUint16(0, value, true);
|
|
2233
|
+
this.__tnInvalidate();
|
|
2234
|
+
return this;
|
|
2041
2235
|
}
|
|
2042
2236
|
|
|
2043
|
-
|
|
2044
|
-
|
|
2045
|
-
|
|
2237
|
+
set_auth_idx(value: number): this {
|
|
2238
|
+
this.view.setUint8(2, value);
|
|
2239
|
+
this.__tnInvalidate();
|
|
2240
|
+
return this;
|
|
2046
2241
|
}
|
|
2047
2242
|
|
|
2048
|
-
|
|
2049
|
-
|
|
2050
|
-
this.
|
|
2243
|
+
set_signature_r(value: Uint8Array): this {
|
|
2244
|
+
if (value.length !== 32) throw new Error("signature_r expects 32 bytes");
|
|
2245
|
+
this.buffer.set(value, 3);
|
|
2246
|
+
this.__tnInvalidate();
|
|
2247
|
+
return this;
|
|
2051
2248
|
}
|
|
2052
2249
|
|
|
2053
|
-
|
|
2054
|
-
|
|
2250
|
+
set_signature_s(value: Uint8Array): this {
|
|
2251
|
+
if (value.length !== 32) throw new Error("signature_s expects 32 bytes");
|
|
2252
|
+
this.buffer.set(value, 35);
|
|
2253
|
+
this.__tnInvalidate();
|
|
2254
|
+
return this;
|
|
2055
2255
|
}
|
|
2056
2256
|
|
|
2057
|
-
|
|
2058
|
-
this.
|
|
2257
|
+
set_authenticator_data_len(value: number): this {
|
|
2258
|
+
this.view.setUint16(67, value, true);
|
|
2259
|
+
this.__tnInvalidate();
|
|
2260
|
+
return this;
|
|
2059
2261
|
}
|
|
2060
2262
|
|
|
2061
|
-
|
|
2062
|
-
|
|
2063
|
-
|
|
2263
|
+
set_client_data_len(value: number): this {
|
|
2264
|
+
this.view.setUint16(69, value, true);
|
|
2265
|
+
this.__tnInvalidate();
|
|
2266
|
+
return this;
|
|
2064
2267
|
}
|
|
2065
2268
|
|
|
2066
|
-
|
|
2067
|
-
|
|
2068
|
-
|
|
2269
|
+
authenticator_data(): __TnFamWriterResult<ValidateArgsBuilder> {
|
|
2270
|
+
if (!this.__tnFamWriter_authenticator_data) {
|
|
2271
|
+
this.__tnFamWriter_authenticator_data = __tnCreateFamWriter(this, "authenticator_data", (payload) => {
|
|
2272
|
+
const bytes = new Uint8Array(payload);
|
|
2273
|
+
const elementCount = bytes.length;
|
|
2274
|
+
this.__tnFam_authenticator_data = bytes;
|
|
2275
|
+
this.__tnFam_authenticator_dataCount = elementCount;
|
|
2276
|
+
this.set_authenticator_data_len(elementCount);
|
|
2277
|
+
this.__tnInvalidate();
|
|
2278
|
+
});
|
|
2279
|
+
}
|
|
2280
|
+
return this.__tnFamWriter_authenticator_data!;
|
|
2281
|
+
}
|
|
2282
|
+
|
|
2283
|
+
client_data(): __TnFamWriterResult<ValidateArgsBuilder> {
|
|
2284
|
+
if (!this.__tnFamWriter_client_data) {
|
|
2285
|
+
this.__tnFamWriter_client_data = __tnCreateFamWriter(this, "client_data", (payload) => {
|
|
2286
|
+
const bytes = new Uint8Array(payload);
|
|
2287
|
+
const elementCount = bytes.length;
|
|
2288
|
+
this.__tnFam_client_data = bytes;
|
|
2289
|
+
this.__tnFam_client_dataCount = elementCount;
|
|
2290
|
+
this.set_client_data_len(elementCount);
|
|
2291
|
+
this.__tnInvalidate();
|
|
2292
|
+
});
|
|
2293
|
+
}
|
|
2294
|
+
return this.__tnFamWriter_client_data!;
|
|
2069
2295
|
}
|
|
2070
2296
|
|
|
2071
|
-
|
|
2072
|
-
|
|
2297
|
+
set_target_instruction(value: InstructionData | __TnStructFieldInput): this {
|
|
2298
|
+
const bytes = __tnResolveStructFieldInput(value as __TnStructFieldInput, "ValidateArgsBuilder::target_instruction");
|
|
2299
|
+
const validation = __tnInvokeDynamicValidate("InstructionData", bytes);
|
|
2300
|
+
if (!validation.ok || validation.consumed === undefined) throw new Error("ValidateArgsBuilder: field 'target_instruction' failed validation");
|
|
2301
|
+
if (__tnBigIntToNumber(validation.consumed, "ValidateArgsBuilder::target_instruction") !== bytes.length) throw new Error("ValidateArgsBuilder: field 'target_instruction' validation did not consume the full buffer");
|
|
2302
|
+
this.__tnTail_target_instruction = bytes;
|
|
2303
|
+
this.__tnTailParams_target_instruction = validation.params ?? null;
|
|
2304
|
+
this.__tnInvalidate();
|
|
2305
|
+
return this;
|
|
2073
2306
|
}
|
|
2074
2307
|
|
|
2075
|
-
|
|
2076
|
-
this.
|
|
2308
|
+
build(): Uint8Array {
|
|
2309
|
+
const params = this.__tnComputeParams();
|
|
2310
|
+
const size = ValidateArgs.footprintFromParams(params);
|
|
2311
|
+
const buffer = new Uint8Array(size);
|
|
2312
|
+
this.__tnWriteInto(buffer);
|
|
2313
|
+
this.__tnValidateOrThrow(buffer, params);
|
|
2314
|
+
return buffer;
|
|
2077
2315
|
}
|
|
2078
2316
|
|
|
2079
|
-
|
|
2080
|
-
|
|
2317
|
+
buildInto(target: Uint8Array, offset = 0): Uint8Array {
|
|
2318
|
+
const params = this.__tnComputeParams();
|
|
2319
|
+
const size = ValidateArgs.footprintFromParams(params);
|
|
2320
|
+
if (target.length - offset < size) throw new Error("ValidateArgsBuilder: target buffer too small");
|
|
2321
|
+
const slice = target.subarray(offset, offset + size);
|
|
2322
|
+
this.__tnWriteInto(slice);
|
|
2323
|
+
this.__tnValidateOrThrow(slice, params);
|
|
2324
|
+
return target;
|
|
2081
2325
|
}
|
|
2082
2326
|
|
|
2083
|
-
|
|
2084
|
-
|
|
2327
|
+
finish(): ValidateArgs {
|
|
2328
|
+
const buffer = this.build();
|
|
2329
|
+
const params = this.__tnLastParams ?? this.__tnComputeParams();
|
|
2330
|
+
const view = ValidateArgs.from_array(buffer, { params });
|
|
2331
|
+
if (!view) throw new Error("ValidateArgsBuilder: failed to finalize view");
|
|
2332
|
+
return view;
|
|
2085
2333
|
}
|
|
2086
2334
|
|
|
2087
|
-
|
|
2088
|
-
return this.
|
|
2335
|
+
finishView(): ValidateArgs {
|
|
2336
|
+
return this.finish();
|
|
2089
2337
|
}
|
|
2090
2338
|
|
|
2091
|
-
|
|
2092
|
-
return this.
|
|
2339
|
+
dynamicParams(): ValidateArgs.Params {
|
|
2340
|
+
return this.__tnComputeParams();
|
|
2093
2341
|
}
|
|
2094
2342
|
|
|
2095
|
-
|
|
2096
|
-
return this.
|
|
2343
|
+
private __tnComputeParams(): ValidateArgs.Params {
|
|
2344
|
+
if (this.__tnCachedParams) return this.__tnCachedParams;
|
|
2345
|
+
const params = ValidateArgs.Params.fromValues({
|
|
2346
|
+
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); })(),
|
|
2347
|
+
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); })(),
|
|
2348
|
+
data_data_size: (() => { const params = this.__tnTailParams_target_instruction; if (!params || params["data_data_size"] === undefined) throw new Error("ValidateArgsBuilder: field 'target_instruction' must be written before computing params"); return params["data_data_size"]; })(),
|
|
2349
|
+
});
|
|
2350
|
+
this.__tnCachedParams = params;
|
|
2351
|
+
return params;
|
|
2097
2352
|
}
|
|
2098
2353
|
|
|
2099
|
-
|
|
2100
|
-
|
|
2101
|
-
|
|
2102
|
-
|
|
2103
|
-
|
|
2354
|
+
private __tnWriteInto(target: Uint8Array): void {
|
|
2355
|
+
target.set(this.buffer, 0);
|
|
2356
|
+
let cursor = this.buffer.length;
|
|
2357
|
+
const __tnLocal_authenticator_data_bytes = this.__tnFam_authenticator_data;
|
|
2358
|
+
if (!__tnLocal_authenticator_data_bytes) throw new Error("ValidateArgsBuilder: field 'authenticator_data' must be written before build");
|
|
2359
|
+
target.set(__tnLocal_authenticator_data_bytes, cursor);
|
|
2360
|
+
cursor += __tnLocal_authenticator_data_bytes.length;
|
|
2361
|
+
const __tnLocal_client_data_bytes = this.__tnFam_client_data;
|
|
2362
|
+
if (!__tnLocal_client_data_bytes) throw new Error("ValidateArgsBuilder: field 'client_data' must be written before build");
|
|
2363
|
+
target.set(__tnLocal_client_data_bytes, cursor);
|
|
2364
|
+
cursor += __tnLocal_client_data_bytes.length;
|
|
2365
|
+
const __tnLocal_target_instruction_bytes = this.__tnTail_target_instruction;
|
|
2366
|
+
if (!__tnLocal_target_instruction_bytes) throw new Error("ValidateArgsBuilder: field 'target_instruction' must be written before build");
|
|
2367
|
+
target.set(__tnLocal_target_instruction_bytes, cursor);
|
|
2368
|
+
cursor += __tnLocal_target_instruction_bytes.length;
|
|
2369
|
+
}
|
|
2370
|
+
|
|
2371
|
+
private __tnValidateOrThrow(buffer: Uint8Array, params: ValidateArgs.Params): void {
|
|
2372
|
+
const result = ValidateArgs.validate(buffer, { params });
|
|
2373
|
+
if (!result.ok) {
|
|
2374
|
+
throw new Error(`${ ValidateArgs }Builder: builder produced invalid buffer (code=${result.code ?? "unknown"})`);
|
|
2104
2375
|
}
|
|
2105
|
-
|
|
2376
|
+
this.__tnLastParams = result.params ?? params;
|
|
2377
|
+
this.__tnLastBuffer = buffer;
|
|
2106
2378
|
}
|
|
2379
|
+
}
|
|
2107
2380
|
|
|
2108
|
-
|
|
2109
|
-
|
|
2110
|
-
|
|
2111
|
-
}
|
|
2381
|
+
__tnRegisterFootprint("ValidateArgs", (params) => ValidateArgs.__tnInvokeFootprint(params));
|
|
2382
|
+
__tnRegisterValidate("ValidateArgs", (buffer, params) => ValidateArgs.__tnInvokeValidate(buffer, params));
|
|
2383
|
+
__tnRegisterDynamicValidate("ValidateArgs", (buffer) => { const result = ValidateArgs.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 }; });
|
|
2112
2384
|
|
|
2113
|
-
|
|
2114
|
-
const buffer = new Uint8Array(9);
|
|
2115
|
-
const view = new DataView(buffer.buffer);
|
|
2385
|
+
/* ----- TYPE DEFINITION FOR WalletAccount ----- */
|
|
2116
2386
|
|
|
2117
|
-
|
|
2118
|
-
|
|
2119
|
-
|
|
2387
|
+
const __tn_ir_WalletAccount = {
|
|
2388
|
+
typeName: "WalletAccount",
|
|
2389
|
+
root: { op: "align", alignment: 1, node: { op: "add", left: { op: "add", left: { op: "align", alignment: 1, node: { op: "const", value: 1n } }, right: { op: "align", alignment: 8, node: { op: "const", value: 8n } } }, right: { op: "align", alignment: 1, node: { op: "mul", left: { op: "add", left: { op: "field", param: "authorities.num_auth" }, right: { op: "const", value: 1n } }, right: { op: "const", value: 73n } } } } }
|
|
2390
|
+
} as const;
|
|
2120
2391
|
|
|
2121
|
-
|
|
2122
|
-
|
|
2392
|
+
export class WalletAccount {
|
|
2393
|
+
private view: DataView;
|
|
2394
|
+
private __tnFieldContext: Record<string, number | bigint> | null = null;
|
|
2395
|
+
private __tnParams: WalletAccount.Params;
|
|
2123
2396
|
|
|
2124
|
-
|
|
2125
|
-
|
|
2126
|
-
|
|
2397
|
+
private constructor(private buffer: Uint8Array, params?: WalletAccount.Params, fieldContext?: Record<string, number | bigint>) {
|
|
2398
|
+
this.view = new DataView(buffer.buffer, buffer.byteOffset, buffer.byteLength);
|
|
2399
|
+
this.__tnFieldContext = fieldContext ?? null;
|
|
2400
|
+
if (params) {
|
|
2401
|
+
this.__tnParams = params;
|
|
2402
|
+
} else {
|
|
2403
|
+
const derived = WalletAccount.__tnExtractParams(this.view, buffer);
|
|
2404
|
+
if (!derived) {
|
|
2405
|
+
throw new Error("WalletAccount: failed to derive dynamic parameters");
|
|
2406
|
+
}
|
|
2407
|
+
this.__tnParams = derived.params;
|
|
2127
2408
|
}
|
|
2128
|
-
|
|
2129
|
-
|
|
2130
|
-
|
|
2409
|
+
}
|
|
2410
|
+
|
|
2411
|
+
static __tnCreateView(buffer: Uint8Array, opts?: { params?: WalletAccount.Params, fieldContext?: Record<string, number | bigint> }): WalletAccount {
|
|
2412
|
+
if (!buffer || buffer.length === undefined) throw new Error("WalletAccount.__tnCreateView requires a Uint8Array");
|
|
2413
|
+
let params = opts?.params ?? null;
|
|
2414
|
+
if (!params) {
|
|
2415
|
+
const view = new DataView(buffer.buffer, buffer.byteOffset, buffer.byteLength);
|
|
2416
|
+
const derived = WalletAccount.__tnExtractParams(view, buffer);
|
|
2417
|
+
if (!derived) throw new Error("WalletAccount.__tnCreateView: failed to derive params");
|
|
2418
|
+
params = derived.params;
|
|
2419
|
+
}
|
|
2420
|
+
const instance = new WalletAccount(new Uint8Array(buffer), params, opts?.fieldContext);
|
|
2421
|
+
return instance;
|
|
2422
|
+
}
|
|
2423
|
+
|
|
2424
|
+
dynamicParams(): WalletAccount.Params {
|
|
2425
|
+
return this.__tnParams;
|
|
2426
|
+
}
|
|
2427
|
+
|
|
2428
|
+
withFieldContext(context: Record<string, number | bigint>): this {
|
|
2429
|
+
this.__tnFieldContext = context;
|
|
2430
|
+
return this;
|
|
2431
|
+
}
|
|
2432
|
+
|
|
2433
|
+
private __tnResolveFieldRef(path: string): number {
|
|
2434
|
+
const getterName = `get_${path.replace(/[.]/g, '_')}`;
|
|
2435
|
+
const getter = (this as any)[getterName];
|
|
2436
|
+
if (typeof getter === "function") {
|
|
2437
|
+
const value = getter.call(this);
|
|
2438
|
+
return typeof value === "bigint" ? __tnBigIntToNumber(value, "WalletAccount::__tnResolveFieldRef") : value;
|
|
2439
|
+
}
|
|
2440
|
+
if (this.__tnFieldContext && Object.prototype.hasOwnProperty.call(this.__tnFieldContext, path)) {
|
|
2441
|
+
const contextValue = this.__tnFieldContext[path];
|
|
2442
|
+
return typeof contextValue === "bigint" ? __tnBigIntToNumber(contextValue, "WalletAccount::__tnResolveFieldRef") : contextValue;
|
|
2443
|
+
}
|
|
2444
|
+
throw new Error("WalletAccount: field reference '" + path + "' is not available; provide fieldContext when creating this view");
|
|
2445
|
+
}
|
|
2446
|
+
|
|
2447
|
+
private static __tnExtractParams(view: DataView, buffer: Uint8Array): { params: WalletAccount.Params; derived: Record<string, bigint> | null } | null {
|
|
2448
|
+
if (buffer.length < 1) {
|
|
2131
2449
|
return null;
|
|
2132
2450
|
}
|
|
2133
|
-
|
|
2451
|
+
const __tnParam_authorities_num_auth = __tnToBigInt(view.getUint8(0));
|
|
2452
|
+
const __tnExtractedParams = WalletAccount.Params.fromValues({
|
|
2453
|
+
authorities_num_auth: __tnParam_authorities_num_auth,
|
|
2454
|
+
});
|
|
2455
|
+
return { params: __tnExtractedParams, derived: null };
|
|
2134
2456
|
}
|
|
2135
2457
|
|
|
2136
|
-
|
|
2458
|
+
get_num_auth(): number {
|
|
2459
|
+
const offset = 0;
|
|
2460
|
+
return this.view.getUint8(offset);
|
|
2461
|
+
}
|
|
2137
2462
|
|
|
2138
|
-
|
|
2139
|
-
|
|
2140
|
-
|
|
2463
|
+
set_num_auth(value: number): void {
|
|
2464
|
+
const offset = 0;
|
|
2465
|
+
this.view.setUint8(offset, value);
|
|
2466
|
+
}
|
|
2141
2467
|
|
|
2142
|
-
|
|
2143
|
-
this.
|
|
2144
|
-
this.view = new DataView(this.buffer.buffer, this.buffer.byteOffset, this.buffer.byteLength);
|
|
2468
|
+
get num_auth(): number {
|
|
2469
|
+
return this.get_num_auth();
|
|
2145
2470
|
}
|
|
2146
2471
|
|
|
2147
|
-
|
|
2148
|
-
this.
|
|
2149
|
-
return this;
|
|
2472
|
+
set num_auth(value: number) {
|
|
2473
|
+
this.set_num_auth(value);
|
|
2150
2474
|
}
|
|
2151
2475
|
|
|
2152
|
-
|
|
2153
|
-
const
|
|
2154
|
-
this.view.
|
|
2155
|
-
return this;
|
|
2476
|
+
get_nonce(): bigint {
|
|
2477
|
+
const offset = 1;
|
|
2478
|
+
return this.view.getBigUint64(offset, true); /* little-endian */
|
|
2156
2479
|
}
|
|
2157
2480
|
|
|
2158
|
-
|
|
2159
|
-
|
|
2481
|
+
set_nonce(value: bigint): void {
|
|
2482
|
+
const offset = 1;
|
|
2483
|
+
this.view.setBigUint64(offset, value, true); /* little-endian */
|
|
2160
2484
|
}
|
|
2161
2485
|
|
|
2162
|
-
|
|
2163
|
-
|
|
2164
|
-
target.set(this.buffer, offset);
|
|
2165
|
-
return target;
|
|
2486
|
+
get nonce(): bigint {
|
|
2487
|
+
return this.get_nonce();
|
|
2166
2488
|
}
|
|
2167
2489
|
|
|
2168
|
-
|
|
2169
|
-
|
|
2170
|
-
|
|
2171
|
-
|
|
2490
|
+
set nonce(value: bigint) {
|
|
2491
|
+
this.set_nonce(value);
|
|
2492
|
+
}
|
|
2493
|
+
|
|
2494
|
+
get_authorities_length(): number {
|
|
2495
|
+
return (this.__tnResolveFieldRef("num_auth") + 1);
|
|
2496
|
+
}
|
|
2497
|
+
|
|
2498
|
+
get_authorities_at(index: number): AuthorityRecord {
|
|
2499
|
+
const offset = 9;
|
|
2500
|
+
const slice = this.buffer.subarray((offset + index * 73), (offset + (index + 1) * 73));
|
|
2501
|
+
return AuthorityRecord.from_array(slice)!;
|
|
2502
|
+
}
|
|
2503
|
+
|
|
2504
|
+
get_authorities(): AuthorityRecord[] {
|
|
2505
|
+
const len = this.get_authorities_length();
|
|
2506
|
+
const result: AuthorityRecord[] = [];
|
|
2507
|
+
for (let i = 0; i < len; i++) {
|
|
2508
|
+
result.push(this.get_authorities_at(i));
|
|
2509
|
+
}
|
|
2510
|
+
return result;
|
|
2511
|
+
}
|
|
2512
|
+
|
|
2513
|
+
set_authorities_at(index: number, value: AuthorityRecord): void {
|
|
2514
|
+
const offset = 9;
|
|
2515
|
+
const slice = this.buffer.subarray(offset + index * 73, offset + (index + 1) * 73);
|
|
2516
|
+
slice.set(value['buffer']);
|
|
2517
|
+
}
|
|
2518
|
+
|
|
2519
|
+
set_authorities(value: AuthorityRecord[]): void {
|
|
2520
|
+
const len = Math.min(this.get_authorities_length(), value.length);
|
|
2521
|
+
for (let i = 0; i < len; i++) {
|
|
2522
|
+
this.set_authorities_at(i, value[i]);
|
|
2523
|
+
}
|
|
2524
|
+
}
|
|
2525
|
+
|
|
2526
|
+
get authorities(): AuthorityRecord[] {
|
|
2527
|
+
return this.get_authorities();
|
|
2528
|
+
}
|
|
2529
|
+
|
|
2530
|
+
set authorities(value: AuthorityRecord[]) {
|
|
2531
|
+
this.set_authorities(value);
|
|
2532
|
+
}
|
|
2533
|
+
private static __tnFootprintInternal(__tnParams: Record<string, bigint>): bigint {
|
|
2534
|
+
return __tnEvalFootprint(__tn_ir_WalletAccount.root, { params: __tnParams });
|
|
2535
|
+
}
|
|
2536
|
+
|
|
2537
|
+
private static __tnValidateInternal(buffer: Uint8Array, __tnParams: Record<string, bigint>): { ok: boolean; code?: string; consumed?: bigint } {
|
|
2538
|
+
return __tnValidateIrTree(__tn_ir_WalletAccount, buffer, __tnParams);
|
|
2539
|
+
}
|
|
2540
|
+
|
|
2541
|
+
static __tnInvokeFootprint(__tnParams: Record<string, bigint>): bigint {
|
|
2542
|
+
return this.__tnFootprintInternal(__tnParams);
|
|
2543
|
+
}
|
|
2544
|
+
|
|
2545
|
+
static __tnInvokeValidate(buffer: Uint8Array, __tnParams: Record<string, bigint>): __TnValidateResult {
|
|
2546
|
+
return this.__tnValidateInternal(buffer, __tnParams);
|
|
2547
|
+
}
|
|
2548
|
+
|
|
2549
|
+
static footprintIr(authorities_num_auth: number | bigint): bigint {
|
|
2550
|
+
const params = WalletAccount.Params.fromValues({
|
|
2551
|
+
authorities_num_auth: authorities_num_auth,
|
|
2552
|
+
});
|
|
2553
|
+
return this.footprintIrFromParams(params);
|
|
2554
|
+
}
|
|
2555
|
+
|
|
2556
|
+
private static __tnPackParams(params: WalletAccount.Params): Record<string, bigint> {
|
|
2557
|
+
const record: Record<string, bigint> = Object.create(null);
|
|
2558
|
+
record["authorities.num_auth"] = params.authorities_num_auth;
|
|
2559
|
+
return record;
|
|
2560
|
+
}
|
|
2561
|
+
|
|
2562
|
+
static footprintIrFromParams(params: WalletAccount.Params): bigint {
|
|
2563
|
+
const __tnParams = this.__tnPackParams(params);
|
|
2564
|
+
return this.__tnFootprintInternal(__tnParams);
|
|
2565
|
+
}
|
|
2566
|
+
|
|
2567
|
+
static footprintFromParams(params: WalletAccount.Params): number {
|
|
2568
|
+
const irResult = this.footprintIrFromParams(params);
|
|
2569
|
+
const maxSafe = __tnToBigInt(Number.MAX_SAFE_INTEGER);
|
|
2570
|
+
if (__tnBigIntGreaterThan(irResult, maxSafe)) throw new Error('footprint exceeds Number.MAX_SAFE_INTEGER for WalletAccount');
|
|
2571
|
+
return __tnBigIntToNumber(irResult, 'WalletAccount::footprintFromParams');
|
|
2572
|
+
}
|
|
2573
|
+
|
|
2574
|
+
static footprintFromValues(input: { authorities_num_auth: number | bigint }): number {
|
|
2575
|
+
const params = WalletAccount.params(input);
|
|
2576
|
+
return this.footprintFromParams(params);
|
|
2577
|
+
}
|
|
2578
|
+
|
|
2579
|
+
static footprint(params: WalletAccount.Params): number {
|
|
2580
|
+
return this.footprintFromParams(params);
|
|
2581
|
+
}
|
|
2582
|
+
|
|
2583
|
+
static validate(buffer: Uint8Array, opts?: { params?: WalletAccount.Params }): { ok: boolean; code?: string; consumed?: number; params?: WalletAccount.Params } {
|
|
2584
|
+
if (!buffer || buffer.length === undefined) {
|
|
2585
|
+
return { ok: false, code: "tn.invalid_buffer" };
|
|
2586
|
+
}
|
|
2587
|
+
const view = new DataView(buffer.buffer, buffer.byteOffset, buffer.byteLength);
|
|
2588
|
+
let params = opts?.params ?? null;
|
|
2589
|
+
if (!params) {
|
|
2590
|
+
const extracted = this.__tnExtractParams(view, buffer);
|
|
2591
|
+
if (!extracted) return { ok: false, code: "tn.param_extraction_failed" };
|
|
2592
|
+
params = extracted.params;
|
|
2593
|
+
}
|
|
2594
|
+
const __tnParamsRec = this.__tnPackParams(params);
|
|
2595
|
+
const irResult = this.__tnValidateInternal(buffer, __tnParamsRec);
|
|
2596
|
+
if (!irResult.ok) {
|
|
2597
|
+
return { ok: false, code: irResult.code, consumed: irResult.consumed ? __tnBigIntToNumber(irResult.consumed, 'WalletAccount::validate') : undefined, params };
|
|
2598
|
+
}
|
|
2599
|
+
const consumed = irResult.consumed ? __tnBigIntToNumber(irResult.consumed, 'WalletAccount::validate') : undefined;
|
|
2600
|
+
return { ok: true, consumed, params };
|
|
2601
|
+
}
|
|
2602
|
+
|
|
2603
|
+
static from_array(buffer: Uint8Array, opts?: { params?: WalletAccount.Params }): WalletAccount | null {
|
|
2604
|
+
if (!buffer || buffer.length === undefined) {
|
|
2605
|
+
return null;
|
|
2606
|
+
}
|
|
2607
|
+
const view = new DataView(buffer.buffer, buffer.byteOffset, buffer.byteLength);
|
|
2608
|
+
let params = opts?.params ?? null;
|
|
2609
|
+
if (!params) {
|
|
2610
|
+
const derived = this.__tnExtractParams(view, buffer);
|
|
2611
|
+
if (!derived) return null;
|
|
2612
|
+
params = derived.params;
|
|
2613
|
+
}
|
|
2614
|
+
const validation = this.validate(buffer, { params });
|
|
2615
|
+
if (!validation.ok) {
|
|
2616
|
+
return null;
|
|
2617
|
+
}
|
|
2618
|
+
const cached = validation.params ?? params;
|
|
2619
|
+
const state = new WalletAccount(buffer, cached);
|
|
2620
|
+
return state;
|
|
2621
|
+
}
|
|
2622
|
+
|
|
2623
|
+
|
|
2624
|
+
}
|
|
2625
|
+
|
|
2626
|
+
export namespace WalletAccount {
|
|
2627
|
+
export type Params = {
|
|
2628
|
+
/** ABI path: authorities.num_auth */
|
|
2629
|
+
readonly authorities_num_auth: bigint;
|
|
2630
|
+
};
|
|
2631
|
+
|
|
2632
|
+
export const ParamKeys = Object.freeze({
|
|
2633
|
+
authorities_num_auth: "authorities.num_auth",
|
|
2634
|
+
} as const);
|
|
2635
|
+
|
|
2636
|
+
export const Params = {
|
|
2637
|
+
fromValues(input: { authorities_num_auth: number | bigint }): Params {
|
|
2638
|
+
return {
|
|
2639
|
+
authorities_num_auth: __tnToBigInt(input.authorities_num_auth),
|
|
2640
|
+
};
|
|
2641
|
+
},
|
|
2642
|
+
fromBuilder(source: { dynamicParams(): Params } | { params: Params } | Params): Params {
|
|
2643
|
+
if ((source as { dynamicParams?: () => Params }).dynamicParams) {
|
|
2644
|
+
return (source as { dynamicParams(): Params }).dynamicParams();
|
|
2645
|
+
}
|
|
2646
|
+
if ((source as { params?: Params }).params) {
|
|
2647
|
+
return (source as { params: Params }).params;
|
|
2648
|
+
}
|
|
2649
|
+
return source as Params;
|
|
2650
|
+
}
|
|
2651
|
+
};
|
|
2652
|
+
|
|
2653
|
+
export function params(input: { authorities_num_auth: number | bigint }): Params {
|
|
2654
|
+
return Params.fromValues(input);
|
|
2172
2655
|
}
|
|
2173
2656
|
}
|
|
2174
2657
|
|
|
2175
2658
|
__tnRegisterFootprint("WalletAccount", (params) => WalletAccount.__tnInvokeFootprint(params));
|
|
2176
2659
|
__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) }; });
|
|
2660
|
+
__tnRegisterDynamicValidate("WalletAccount", (buffer) => { const result = WalletAccount.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 }; });
|
|
2178
2661
|
|
|
2179
2662
|
/* ----- TYPE DEFINITION FOR WalletCreatedEventData ----- */
|
|
2180
2663
|
|
|
@@ -2334,7 +2817,7 @@ export class WalletCreatedEventDataBuilder {
|
|
|
2334
2817
|
|
|
2335
2818
|
__tnRegisterFootprint("WalletCreatedEventData", (params) => WalletCreatedEventData.__tnInvokeFootprint(params));
|
|
2336
2819
|
__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) }; });
|
|
2820
|
+
__tnRegisterDynamicValidate("WalletCreatedEventData", (buffer) => { const result = WalletCreatedEventData.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 }; });
|
|
2338
2821
|
|
|
2339
2822
|
/* ----- TYPE DEFINITION FOR WalletTransferEventData ----- */
|
|
2340
2823
|
|
|
@@ -2493,7 +2976,7 @@ export class WalletTransferEventDataBuilder {
|
|
|
2493
2976
|
return this;
|
|
2494
2977
|
}
|
|
2495
2978
|
|
|
2496
|
-
set_amount(value:
|
|
2979
|
+
set_amount(value: bigint): this {
|
|
2497
2980
|
const cast = __tnToBigInt(value);
|
|
2498
2981
|
this.view.setBigUint64(64, cast, true);
|
|
2499
2982
|
return this;
|
|
@@ -2518,7 +3001,7 @@ export class WalletTransferEventDataBuilder {
|
|
|
2518
3001
|
|
|
2519
3002
|
__tnRegisterFootprint("WalletTransferEventData", (params) => WalletTransferEventData.__tnInvokeFootprint(params));
|
|
2520
3003
|
__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) }; });
|
|
3004
|
+
__tnRegisterDynamicValidate("WalletTransferEventData", (buffer) => { const result = WalletTransferEventData.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 }; });
|
|
2522
3005
|
|
|
2523
3006
|
/* ----- TYPE DEFINITION FOR WalletValidatedEventData ----- */
|
|
2524
3007
|
|
|
@@ -2650,7 +3133,7 @@ export class WalletValidatedEventDataBuilder {
|
|
|
2650
3133
|
return this;
|
|
2651
3134
|
}
|
|
2652
3135
|
|
|
2653
|
-
set_new_nonce(value:
|
|
3136
|
+
set_new_nonce(value: bigint): this {
|
|
2654
3137
|
const cast = __tnToBigInt(value);
|
|
2655
3138
|
this.view.setBigUint64(32, cast, true);
|
|
2656
3139
|
return this;
|
|
@@ -2675,13 +3158,13 @@ export class WalletValidatedEventDataBuilder {
|
|
|
2675
3158
|
|
|
2676
3159
|
__tnRegisterFootprint("WalletValidatedEventData", (params) => WalletValidatedEventData.__tnInvokeFootprint(params));
|
|
2677
3160
|
__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) }; });
|
|
3161
|
+
__tnRegisterDynamicValidate("WalletValidatedEventData", (buffer) => { const result = WalletValidatedEventData.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 }; });
|
|
2679
3162
|
|
|
2680
3163
|
/* ----- TYPE DEFINITION FOR AddAuthorityArgs ----- */
|
|
2681
3164
|
|
|
2682
3165
|
const __tn_ir_AddAuthorityArgs = {
|
|
2683
3166
|
typeName: "AddAuthorityArgs",
|
|
2684
|
-
root: { op: "const", value:
|
|
3167
|
+
root: { op: "const", value: 75n }
|
|
2685
3168
|
} as const;
|
|
2686
3169
|
|
|
2687
3170
|
export class AddAuthorityArgs {
|
|
@@ -2723,25 +3206,25 @@ export class AddAuthorityArgs {
|
|
|
2723
3206
|
this.set_wallet_account_idx(value);
|
|
2724
3207
|
}
|
|
2725
3208
|
|
|
2726
|
-
|
|
3209
|
+
get_authority_record(): AuthorityRecord {
|
|
2727
3210
|
const offset = 2;
|
|
2728
|
-
const slice = this.buffer.subarray(offset, offset +
|
|
2729
|
-
return
|
|
3211
|
+
const slice = this.buffer.subarray(offset, offset + 73);
|
|
3212
|
+
return AuthorityRecord.from_array(slice)!;
|
|
2730
3213
|
}
|
|
2731
3214
|
|
|
2732
|
-
|
|
3215
|
+
set_authority_record(value: AuthorityRecord): void {
|
|
2733
3216
|
/* Copy bytes from source struct to this field */
|
|
2734
3217
|
const sourceBytes = (value as any).buffer as Uint8Array;
|
|
2735
3218
|
const offset = 2;
|
|
2736
3219
|
this.buffer.set(sourceBytes, offset);
|
|
2737
3220
|
}
|
|
2738
3221
|
|
|
2739
|
-
get
|
|
2740
|
-
return this.
|
|
3222
|
+
get authority_record(): AuthorityRecord {
|
|
3223
|
+
return this.get_authority_record();
|
|
2741
3224
|
}
|
|
2742
3225
|
|
|
2743
|
-
set
|
|
2744
|
-
this.
|
|
3226
|
+
set authority_record(value: AuthorityRecord) {
|
|
3227
|
+
this.set_authority_record(value);
|
|
2745
3228
|
}
|
|
2746
3229
|
|
|
2747
3230
|
private static __tnFootprintInternal(__tnParams: Record<string, bigint>): bigint {
|
|
@@ -2774,8 +3257,8 @@ export class AddAuthorityArgs {
|
|
|
2774
3257
|
}
|
|
2775
3258
|
|
|
2776
3259
|
static validate(buffer: Uint8Array, _opts?: { params?: never }): { ok: boolean; code?: string; consumed?: number } {
|
|
2777
|
-
if (buffer.length <
|
|
2778
|
-
return { ok: true, consumed:
|
|
3260
|
+
if (buffer.length < 75) return { ok: false, code: "tn.buffer_too_small", consumed: 75 };
|
|
3261
|
+
return { ok: true, consumed: 75 };
|
|
2779
3262
|
}
|
|
2780
3263
|
|
|
2781
3264
|
static from_array(buffer: Uint8Array): AddAuthorityArgs | null {
|
|
@@ -2797,7 +3280,7 @@ export class AddAuthorityArgsBuilder {
|
|
|
2797
3280
|
private view: DataView;
|
|
2798
3281
|
|
|
2799
3282
|
constructor() {
|
|
2800
|
-
this.buffer = new Uint8Array(
|
|
3283
|
+
this.buffer = new Uint8Array(75);
|
|
2801
3284
|
this.view = new DataView(this.buffer.buffer, this.buffer.byteOffset, this.buffer.byteLength);
|
|
2802
3285
|
}
|
|
2803
3286
|
|
|
@@ -2806,8 +3289,8 @@ export class AddAuthorityArgsBuilder {
|
|
|
2806
3289
|
return this;
|
|
2807
3290
|
}
|
|
2808
3291
|
|
|
2809
|
-
|
|
2810
|
-
if (value.length !==
|
|
3292
|
+
set_authority_record(value: Uint8Array): this {
|
|
3293
|
+
if (value.length !== 73) throw new Error("authority_record expects 73 bytes");
|
|
2811
3294
|
this.buffer.set(value, 2);
|
|
2812
3295
|
return this;
|
|
2813
3296
|
}
|
|
@@ -2831,7 +3314,7 @@ export class AddAuthorityArgsBuilder {
|
|
|
2831
3314
|
|
|
2832
3315
|
__tnRegisterFootprint("AddAuthorityArgs", (params) => AddAuthorityArgs.__tnInvokeFootprint(params));
|
|
2833
3316
|
__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) }; });
|
|
3317
|
+
__tnRegisterDynamicValidate("AddAuthorityArgs", (buffer) => { const result = AddAuthorityArgs.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 }; });
|
|
2835
3318
|
|
|
2836
3319
|
/* ----- TYPE DEFINITION FOR CredentialLookup ----- */
|
|
2837
3320
|
|
|
@@ -2964,7 +3447,7 @@ export class CredentialLookupBuilder {
|
|
|
2964
3447
|
|
|
2965
3448
|
__tnRegisterFootprint("CredentialLookup", (params) => CredentialLookup.__tnInvokeFootprint(params));
|
|
2966
3449
|
__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) }; });
|
|
3450
|
+
__tnRegisterDynamicValidate("CredentialLookup", (buffer) => { const result = CredentialLookup.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 }; });
|
|
2968
3451
|
|
|
2969
3452
|
/* ----- TYPE DEFINITION FOR CredentialRegisteredEventData ----- */
|
|
2970
3453
|
|
|
@@ -3124,7 +3607,7 @@ export class CredentialRegisteredEventDataBuilder {
|
|
|
3124
3607
|
|
|
3125
3608
|
__tnRegisterFootprint("CredentialRegisteredEventData", (params) => CredentialRegisteredEventData.__tnInvokeFootprint(params));
|
|
3126
3609
|
__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) }; });
|
|
3610
|
+
__tnRegisterDynamicValidate("CredentialRegisteredEventData", (buffer) => { const result = CredentialRegisteredEventData.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 }; });
|
|
3128
3611
|
|
|
3129
3612
|
/* ----- TYPE DEFINITION FOR PasskeyEvent ----- */
|
|
3130
3613
|
|
|
@@ -3193,7 +3676,7 @@ export class PasskeyEvent {
|
|
|
3193
3676
|
}
|
|
3194
3677
|
}
|
|
3195
3678
|
|
|
3196
|
-
static __tnCreateView(buffer: Uint8Array, opts?: { params?: PasskeyEvent.Params }): PasskeyEvent {
|
|
3679
|
+
static __tnCreateView(buffer: Uint8Array, opts?: { params?: PasskeyEvent.Params, fieldContext?: Record<string, number | bigint> }): PasskeyEvent {
|
|
3197
3680
|
if (!buffer || buffer.length === undefined) throw new Error("PasskeyEvent.__tnCreateView requires a Uint8Array");
|
|
3198
3681
|
let params = opts?.params ?? null;
|
|
3199
3682
|
if (!params) {
|
|
@@ -3537,25 +4020,47 @@ export class PasskeyEventBuilder {
|
|
|
3537
4020
|
|
|
3538
4021
|
__tnRegisterFootprint("PasskeyEvent", (params) => PasskeyEvent.__tnInvokeFootprint(params));
|
|
3539
4022
|
__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) }; });
|
|
4023
|
+
__tnRegisterDynamicValidate("PasskeyEvent", (buffer) => { const result = PasskeyEvent.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 }; });
|
|
3541
4024
|
|
|
3542
4025
|
/* ----- TYPE DEFINITION FOR CreateArgs ----- */
|
|
3543
4026
|
|
|
3544
4027
|
const __tn_ir_CreateArgs = {
|
|
3545
4028
|
typeName: "CreateArgs",
|
|
3546
|
-
root: { op: "align", alignment: 1, node: { 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:
|
|
4029
|
+
root: { op: "align", alignment: 1, node: { 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: 73n } } }, right: { op: "align", alignment: 1, node: { op: "const", value: 32n } } }, right: { op: "align", alignment: 1, node: { op: "call", typeName: "StateProof", args: [{ name: "proof_body.hdr.type_slot", source: "proof_body.hdr.type_slot" }, { name: "proof_body.payload_size", source: "proof_body.payload_size" }] } } } }
|
|
3547
4030
|
} as const;
|
|
3548
4031
|
|
|
3549
4032
|
export class CreateArgs {
|
|
3550
4033
|
private view: DataView;
|
|
4034
|
+
private __tnParams: CreateArgs.Params;
|
|
3551
4035
|
|
|
3552
|
-
private constructor(private buffer: Uint8Array) {
|
|
4036
|
+
private constructor(private buffer: Uint8Array, params?: CreateArgs.Params) {
|
|
3553
4037
|
this.view = new DataView(buffer.buffer, buffer.byteOffset, buffer.byteLength);
|
|
4038
|
+
if (params) {
|
|
4039
|
+
this.__tnParams = params;
|
|
4040
|
+
} else {
|
|
4041
|
+
const derived = CreateArgs.__tnExtractParams(this.view, buffer);
|
|
4042
|
+
if (!derived) {
|
|
4043
|
+
throw new Error("CreateArgs: failed to derive dynamic parameters");
|
|
4044
|
+
}
|
|
4045
|
+
this.__tnParams = derived.params;
|
|
4046
|
+
}
|
|
3554
4047
|
}
|
|
3555
4048
|
|
|
3556
|
-
static __tnCreateView(buffer: Uint8Array, opts?: { fieldContext?: Record<string, number | bigint> }): CreateArgs {
|
|
4049
|
+
static __tnCreateView(buffer: Uint8Array, opts?: { params?: CreateArgs.Params, fieldContext?: Record<string, number | bigint> }): CreateArgs {
|
|
3557
4050
|
if (!buffer || buffer.length === undefined) throw new Error("CreateArgs.__tnCreateView requires a Uint8Array");
|
|
3558
|
-
|
|
4051
|
+
let params = opts?.params ?? null;
|
|
4052
|
+
if (!params) {
|
|
4053
|
+
const view = new DataView(buffer.buffer, buffer.byteOffset, buffer.byteLength);
|
|
4054
|
+
const derived = CreateArgs.__tnExtractParams(view, buffer);
|
|
4055
|
+
if (!derived) throw new Error("CreateArgs.__tnCreateView: failed to derive params");
|
|
4056
|
+
params = derived.params;
|
|
4057
|
+
}
|
|
4058
|
+
const instance = new CreateArgs(new Uint8Array(buffer), params);
|
|
4059
|
+
return instance;
|
|
4060
|
+
}
|
|
4061
|
+
|
|
4062
|
+
dynamicParams(): CreateArgs.Params {
|
|
4063
|
+
return this.__tnParams;
|
|
3559
4064
|
}
|
|
3560
4065
|
|
|
3561
4066
|
static builder(): CreateArgsBuilder {
|
|
@@ -3564,7 +4069,53 @@ export class CreateArgs {
|
|
|
3564
4069
|
|
|
3565
4070
|
static fromBuilder(builder: CreateArgsBuilder): CreateArgs | null {
|
|
3566
4071
|
const buffer = builder.build();
|
|
3567
|
-
|
|
4072
|
+
const params = builder.dynamicParams();
|
|
4073
|
+
return CreateArgs.from_array(buffer, { params });
|
|
4074
|
+
}
|
|
4075
|
+
|
|
4076
|
+
static __tnComputeSequentialLayout(view: DataView, buffer: Uint8Array): { params: Record<string, bigint> | null; offsets: Record<string, number> | null; derived: Record<string, bigint> | null } | null {
|
|
4077
|
+
const __tnLength = buffer.length;
|
|
4078
|
+
let __tnParamSeq_proof_body_hdr_type_slot: bigint | null = null;
|
|
4079
|
+
let __tnParamSeq_proof_body_payload_size: bigint | null = null;
|
|
4080
|
+
let __tnFieldValue_wallet_account_idx: number | null = null;
|
|
4081
|
+
let __tnCursorMutable = 0;
|
|
4082
|
+
if (__tnCursorMutable + 2 > __tnLength) return null;
|
|
4083
|
+
const __tnRead_wallet_account_idx = view.getUint16(__tnCursorMutable, true);
|
|
4084
|
+
__tnFieldValue_wallet_account_idx = __tnRead_wallet_account_idx;
|
|
4085
|
+
__tnCursorMutable += 2;
|
|
4086
|
+
if (__tnCursorMutable + 65 > __tnLength) return null;
|
|
4087
|
+
__tnCursorMutable += 65;
|
|
4088
|
+
if (__tnCursorMutable + 32 > __tnLength) return null;
|
|
4089
|
+
__tnCursorMutable += 32;
|
|
4090
|
+
const __tnTyperefResult_state_proof = __tnInvokeDynamicValidate("StateProof", buffer.subarray(__tnCursorMutable));
|
|
4091
|
+
if (!__tnTyperefResult_state_proof.ok || __tnTyperefResult_state_proof.consumed === undefined) return null;
|
|
4092
|
+
const __tnTyperefParams_state_proof = __tnTyperefResult_state_proof.params ?? null;
|
|
4093
|
+
if (!__tnTyperefParams_state_proof || __tnTyperefParams_state_proof["proof_body_hdr_type_slot"] === undefined) return null;
|
|
4094
|
+
__tnParamSeq_proof_body_hdr_type_slot = __tnTyperefParams_state_proof["proof_body_hdr_type_slot"];
|
|
4095
|
+
if (!__tnTyperefParams_state_proof || __tnTyperefParams_state_proof["proof_body_payload_size"] === undefined) return null;
|
|
4096
|
+
__tnParamSeq_proof_body_payload_size = __tnTyperefParams_state_proof["proof_body_payload_size"];
|
|
4097
|
+
__tnCursorMutable += __tnBigIntToNumber(__tnTyperefResult_state_proof.consumed, "CreateArgs::state_proof");
|
|
4098
|
+
const params: Record<string, bigint> = Object.create(null);
|
|
4099
|
+
if (__tnParamSeq_proof_body_hdr_type_slot === null) return null;
|
|
4100
|
+
params["proof_body_hdr_type_slot"] = __tnParamSeq_proof_body_hdr_type_slot as bigint;
|
|
4101
|
+
if (__tnParamSeq_proof_body_payload_size === null) return null;
|
|
4102
|
+
params["proof_body_payload_size"] = __tnParamSeq_proof_body_payload_size as bigint;
|
|
4103
|
+
return { params, offsets: null, derived: null };
|
|
4104
|
+
}
|
|
4105
|
+
|
|
4106
|
+
private static __tnExtractParams(view: DataView, buffer: Uint8Array): { params: CreateArgs.Params; derived: Record<string, bigint> | null } | null {
|
|
4107
|
+
const __tnLayout = CreateArgs.__tnComputeSequentialLayout(view, buffer);
|
|
4108
|
+
if (!__tnLayout || !__tnLayout.params) return null;
|
|
4109
|
+
const __tnSeqParams = __tnLayout.params;
|
|
4110
|
+
const __tnParamSeq_proof_body_hdr_type_slot = __tnSeqParams["proof_body_hdr_type_slot"];
|
|
4111
|
+
if (__tnParamSeq_proof_body_hdr_type_slot === undefined) return null;
|
|
4112
|
+
const __tnParamSeq_proof_body_payload_size = __tnSeqParams["proof_body_payload_size"];
|
|
4113
|
+
if (__tnParamSeq_proof_body_payload_size === undefined) return null;
|
|
4114
|
+
const __tnExtractedParams = CreateArgs.Params.fromValues({
|
|
4115
|
+
proof_body_hdr_type_slot: __tnParamSeq_proof_body_hdr_type_slot as bigint,
|
|
4116
|
+
proof_body_payload_size: __tnParamSeq_proof_body_payload_size as bigint,
|
|
4117
|
+
});
|
|
4118
|
+
return { params: __tnExtractedParams, derived: null };
|
|
3568
4119
|
}
|
|
3569
4120
|
|
|
3570
4121
|
get_wallet_account_idx(): number {
|
|
@@ -3585,29 +4136,29 @@ export class CreateArgs {
|
|
|
3585
4136
|
this.set_wallet_account_idx(value);
|
|
3586
4137
|
}
|
|
3587
4138
|
|
|
3588
|
-
|
|
4139
|
+
get_authority_record(): AuthorityRecord {
|
|
3589
4140
|
const offset = 2;
|
|
3590
|
-
const slice = this.buffer.subarray(offset, offset +
|
|
3591
|
-
return
|
|
4141
|
+
const slice = this.buffer.subarray(offset, offset + 73);
|
|
4142
|
+
return AuthorityRecord.from_array(slice)!;
|
|
3592
4143
|
}
|
|
3593
4144
|
|
|
3594
|
-
|
|
4145
|
+
set_authority_record(value: AuthorityRecord): void {
|
|
3595
4146
|
/* Copy bytes from source struct to this field */
|
|
3596
4147
|
const sourceBytes = (value as any).buffer as Uint8Array;
|
|
3597
4148
|
const offset = 2;
|
|
3598
4149
|
this.buffer.set(sourceBytes, offset);
|
|
3599
4150
|
}
|
|
3600
4151
|
|
|
3601
|
-
get
|
|
3602
|
-
return this.
|
|
4152
|
+
get authority_record(): AuthorityRecord {
|
|
4153
|
+
return this.get_authority_record();
|
|
3603
4154
|
}
|
|
3604
4155
|
|
|
3605
|
-
set
|
|
3606
|
-
this.
|
|
4156
|
+
set authority_record(value: AuthorityRecord) {
|
|
4157
|
+
this.set_authority_record(value);
|
|
3607
4158
|
}
|
|
3608
4159
|
|
|
3609
4160
|
get_seed(): Seed32 {
|
|
3610
|
-
const offset =
|
|
4161
|
+
const offset = 75;
|
|
3611
4162
|
const slice = this.buffer.subarray(offset, offset + 32);
|
|
3612
4163
|
return Seed32.from_array(slice)!;
|
|
3613
4164
|
}
|
|
@@ -3615,7 +4166,7 @@ export class CreateArgs {
|
|
|
3615
4166
|
set_seed(value: Seed32): void {
|
|
3616
4167
|
/* Copy bytes from source struct to this field */
|
|
3617
4168
|
const sourceBytes = (value as any).buffer as Uint8Array;
|
|
3618
|
-
const offset =
|
|
4169
|
+
const offset = 75;
|
|
3619
4170
|
this.buffer.set(sourceBytes, offset);
|
|
3620
4171
|
}
|
|
3621
4172
|
|
|
@@ -3628,7 +4179,7 @@ export class CreateArgs {
|
|
|
3628
4179
|
}
|
|
3629
4180
|
|
|
3630
4181
|
get_state_proof(): StateProof {
|
|
3631
|
-
const offset =
|
|
4182
|
+
const offset = 107;
|
|
3632
4183
|
const tail = this.buffer.subarray(offset);
|
|
3633
4184
|
const validation = StateProof.validate(tail);
|
|
3634
4185
|
if (!validation.ok || validation.consumed === undefined) {
|
|
@@ -3643,7 +4194,7 @@ export class CreateArgs {
|
|
|
3643
4194
|
set_state_proof(value: StateProof): void {
|
|
3644
4195
|
/* Copy bytes from source struct to this field */
|
|
3645
4196
|
const sourceBytes = (value as any).buffer as Uint8Array;
|
|
3646
|
-
const offset =
|
|
4197
|
+
const offset = 107;
|
|
3647
4198
|
this.buffer.set(sourceBytes, offset);
|
|
3648
4199
|
}
|
|
3649
4200
|
|
|
@@ -3654,7 +4205,6 @@ export class CreateArgs {
|
|
|
3654
4205
|
set state_proof(value: StateProof) {
|
|
3655
4206
|
this.set_state_proof(value);
|
|
3656
4207
|
}
|
|
3657
|
-
|
|
3658
4208
|
private static __tnFootprintInternal(__tnParams: Record<string, bigint>): bigint {
|
|
3659
4209
|
return __tnEvalFootprint(__tn_ir_CreateArgs.root, { params: __tnParams });
|
|
3660
4210
|
}
|
|
@@ -3671,50 +4221,136 @@ export class CreateArgs {
|
|
|
3671
4221
|
return this.__tnValidateInternal(buffer, __tnParams);
|
|
3672
4222
|
}
|
|
3673
4223
|
|
|
3674
|
-
static footprintIr(): bigint {
|
|
3675
|
-
|
|
4224
|
+
static footprintIr(proof_body_hdr_type_slot: number | bigint, proof_body_payload_size: number | bigint): bigint {
|
|
4225
|
+
const params = CreateArgs.Params.fromValues({
|
|
4226
|
+
proof_body_hdr_type_slot: proof_body_hdr_type_slot,
|
|
4227
|
+
proof_body_payload_size: proof_body_payload_size,
|
|
4228
|
+
});
|
|
4229
|
+
return this.footprintIrFromParams(params);
|
|
3676
4230
|
}
|
|
3677
4231
|
|
|
3678
|
-
static
|
|
3679
|
-
const
|
|
3680
|
-
|
|
3681
|
-
|
|
3682
|
-
|
|
3683
|
-
}
|
|
3684
|
-
return __tnBigIntToNumber(irResult, 'CreateArgs::footprint');
|
|
4232
|
+
private static __tnPackParams(params: CreateArgs.Params): Record<string, bigint> {
|
|
4233
|
+
const record: Record<string, bigint> = Object.create(null);
|
|
4234
|
+
record["proof_body.hdr.type_slot"] = params.proof_body_hdr_type_slot;
|
|
4235
|
+
record["proof_body.payload_size"] = params.proof_body_payload_size;
|
|
4236
|
+
return record;
|
|
3685
4237
|
}
|
|
3686
4238
|
|
|
3687
|
-
static
|
|
3688
|
-
|
|
3689
|
-
return
|
|
4239
|
+
static footprintIrFromParams(params: CreateArgs.Params): bigint {
|
|
4240
|
+
const __tnParams = this.__tnPackParams(params);
|
|
4241
|
+
return this.__tnFootprintInternal(__tnParams);
|
|
3690
4242
|
}
|
|
3691
4243
|
|
|
3692
|
-
static
|
|
4244
|
+
static footprintFromParams(params: CreateArgs.Params): number {
|
|
4245
|
+
const irResult = this.footprintIrFromParams(params);
|
|
4246
|
+
const maxSafe = __tnToBigInt(Number.MAX_SAFE_INTEGER);
|
|
4247
|
+
if (__tnBigIntGreaterThan(irResult, maxSafe)) throw new Error('footprint exceeds Number.MAX_SAFE_INTEGER for CreateArgs');
|
|
4248
|
+
return __tnBigIntToNumber(irResult, 'CreateArgs::footprintFromParams');
|
|
4249
|
+
}
|
|
4250
|
+
|
|
4251
|
+
static footprintFromValues(input: { proof_body_hdr_type_slot: number | bigint, proof_body_payload_size: number | bigint }): number {
|
|
4252
|
+
const params = CreateArgs.params(input);
|
|
4253
|
+
return this.footprintFromParams(params);
|
|
4254
|
+
}
|
|
4255
|
+
|
|
4256
|
+
static footprint(params: CreateArgs.Params): number {
|
|
4257
|
+
return this.footprintFromParams(params);
|
|
4258
|
+
}
|
|
4259
|
+
|
|
4260
|
+
static validate(buffer: Uint8Array, opts?: { params?: CreateArgs.Params }): { ok: boolean; code?: string; consumed?: number; params?: CreateArgs.Params } {
|
|
4261
|
+
if (!buffer || buffer.length === undefined) {
|
|
4262
|
+
return { ok: false, code: "tn.invalid_buffer" };
|
|
4263
|
+
}
|
|
4264
|
+
const view = new DataView(buffer.buffer, buffer.byteOffset, buffer.byteLength);
|
|
4265
|
+
let params = opts?.params ?? null;
|
|
4266
|
+
if (!params) {
|
|
4267
|
+
return { ok: false, code: "tn.param_extraction_failed" };
|
|
4268
|
+
}
|
|
4269
|
+
const __tnParamsRec = this.__tnPackParams(params);
|
|
4270
|
+
const irResult = this.__tnValidateInternal(buffer, __tnParamsRec);
|
|
4271
|
+
if (!irResult.ok) {
|
|
4272
|
+
return { ok: false, code: irResult.code, consumed: irResult.consumed ? __tnBigIntToNumber(irResult.consumed, 'CreateArgs::validate') : undefined, params };
|
|
4273
|
+
}
|
|
4274
|
+
const consumed = irResult.consumed ? __tnBigIntToNumber(irResult.consumed, 'CreateArgs::validate') : undefined;
|
|
4275
|
+
return { ok: true, consumed, params };
|
|
4276
|
+
}
|
|
4277
|
+
|
|
4278
|
+
static from_array(buffer: Uint8Array, opts?: { params?: CreateArgs.Params }): CreateArgs | null {
|
|
3693
4279
|
if (!buffer || buffer.length === undefined) {
|
|
3694
4280
|
return null;
|
|
3695
4281
|
}
|
|
3696
4282
|
const view = new DataView(buffer.buffer, buffer.byteOffset, buffer.byteLength);
|
|
3697
|
-
|
|
4283
|
+
let params = opts?.params ?? null;
|
|
4284
|
+
if (!params) {
|
|
4285
|
+
__tnLogWarn('CreateArgs::from_array requires params when IR extraction is unavailable');
|
|
4286
|
+
return null;
|
|
4287
|
+
}
|
|
4288
|
+
const validation = this.validate(buffer, { params });
|
|
3698
4289
|
if (!validation.ok) {
|
|
3699
4290
|
return null;
|
|
3700
4291
|
}
|
|
3701
|
-
|
|
4292
|
+
const cached = validation.params ?? params;
|
|
4293
|
+
const state = new CreateArgs(buffer, cached);
|
|
4294
|
+
return state;
|
|
3702
4295
|
}
|
|
3703
4296
|
|
|
4297
|
+
|
|
4298
|
+
}
|
|
4299
|
+
|
|
4300
|
+
export namespace CreateArgs {
|
|
4301
|
+
export type Params = {
|
|
4302
|
+
/** ABI path: proof_body.hdr.type_slot */
|
|
4303
|
+
readonly proof_body_hdr_type_slot: bigint;
|
|
4304
|
+
/** ABI path: proof_body.payload_size */
|
|
4305
|
+
readonly proof_body_payload_size: bigint;
|
|
4306
|
+
};
|
|
4307
|
+
|
|
4308
|
+
export const ParamKeys = Object.freeze({
|
|
4309
|
+
proof_body_hdr_type_slot: "proof_body.hdr.type_slot",
|
|
4310
|
+
proof_body_payload_size: "proof_body.payload_size",
|
|
4311
|
+
} as const);
|
|
4312
|
+
|
|
4313
|
+
export const Params = {
|
|
4314
|
+
fromValues(input: { proof_body_hdr_type_slot: number | bigint, proof_body_payload_size: number | bigint }): Params {
|
|
4315
|
+
return {
|
|
4316
|
+
proof_body_hdr_type_slot: __tnToBigInt(input.proof_body_hdr_type_slot),
|
|
4317
|
+
proof_body_payload_size: __tnToBigInt(input.proof_body_payload_size),
|
|
4318
|
+
};
|
|
4319
|
+
},
|
|
4320
|
+
fromBuilder(source: { dynamicParams(): Params } | { params: Params } | Params): Params {
|
|
4321
|
+
if ((source as { dynamicParams?: () => Params }).dynamicParams) {
|
|
4322
|
+
return (source as { dynamicParams(): Params }).dynamicParams();
|
|
4323
|
+
}
|
|
4324
|
+
if ((source as { params?: Params }).params) {
|
|
4325
|
+
return (source as { params: Params }).params;
|
|
4326
|
+
}
|
|
4327
|
+
return source as Params;
|
|
4328
|
+
}
|
|
4329
|
+
};
|
|
4330
|
+
|
|
4331
|
+
export function params(input: { proof_body_hdr_type_slot: number | bigint, proof_body_payload_size: number | bigint }): Params {
|
|
4332
|
+
return Params.fromValues(input);
|
|
4333
|
+
}
|
|
3704
4334
|
}
|
|
3705
4335
|
|
|
3706
4336
|
export class CreateArgsBuilder {
|
|
3707
4337
|
private buffer: Uint8Array;
|
|
3708
4338
|
private view: DataView;
|
|
4339
|
+
private __tnCachedParams: CreateArgs.Params | null = null;
|
|
4340
|
+
private __tnLastBuffer: Uint8Array | null = null;
|
|
4341
|
+
private __tnLastParams: CreateArgs.Params | null = null;
|
|
3709
4342
|
private __tnTail_state_proof: Uint8Array | null = null;
|
|
4343
|
+
private __tnTailParams_state_proof: Record<string, bigint> | null = null;
|
|
3710
4344
|
|
|
3711
4345
|
constructor() {
|
|
3712
|
-
this.buffer = new Uint8Array(
|
|
4346
|
+
this.buffer = new Uint8Array(107);
|
|
3713
4347
|
this.view = new DataView(this.buffer.buffer, this.buffer.byteOffset, this.buffer.byteLength);
|
|
3714
4348
|
}
|
|
3715
4349
|
|
|
3716
4350
|
private __tnInvalidate(): void {
|
|
3717
|
-
|
|
4351
|
+
this.__tnCachedParams = null;
|
|
4352
|
+
this.__tnLastBuffer = null;
|
|
4353
|
+
this.__tnLastParams = null;
|
|
3718
4354
|
}
|
|
3719
4355
|
|
|
3720
4356
|
set_wallet_account_idx(value: number): this {
|
|
@@ -3723,8 +4359,8 @@ export class CreateArgsBuilder {
|
|
|
3723
4359
|
return this;
|
|
3724
4360
|
}
|
|
3725
4361
|
|
|
3726
|
-
|
|
3727
|
-
if (value.length !==
|
|
4362
|
+
set_authority_record(value: Uint8Array): this {
|
|
4363
|
+
if (value.length !== 73) throw new Error("authority_record expects 73 bytes");
|
|
3728
4364
|
this.buffer.set(value, 2);
|
|
3729
4365
|
this.__tnInvalidate();
|
|
3730
4366
|
return this;
|
|
@@ -3732,40 +4368,45 @@ export class CreateArgsBuilder {
|
|
|
3732
4368
|
|
|
3733
4369
|
set_seed(value: Uint8Array): this {
|
|
3734
4370
|
if (value.length !== 32) throw new Error("seed expects 32 bytes");
|
|
3735
|
-
this.buffer.set(value,
|
|
4371
|
+
this.buffer.set(value, 75);
|
|
3736
4372
|
this.__tnInvalidate();
|
|
3737
4373
|
return this;
|
|
3738
4374
|
}
|
|
3739
4375
|
|
|
3740
4376
|
set_state_proof(value: StateProof | __TnStructFieldInput): this {
|
|
3741
4377
|
const bytes = __tnResolveStructFieldInput(value as __TnStructFieldInput, "CreateArgsBuilder::state_proof");
|
|
4378
|
+
const validation = __tnInvokeDynamicValidate("StateProof", bytes);
|
|
4379
|
+
if (!validation.ok || validation.consumed === undefined) throw new Error("CreateArgsBuilder: field 'state_proof' failed validation");
|
|
4380
|
+
if (__tnBigIntToNumber(validation.consumed, "CreateArgsBuilder::state_proof") !== bytes.length) throw new Error("CreateArgsBuilder: field 'state_proof' validation did not consume the full buffer");
|
|
3742
4381
|
this.__tnTail_state_proof = bytes;
|
|
4382
|
+
this.__tnTailParams_state_proof = validation.params ?? null;
|
|
3743
4383
|
this.__tnInvalidate();
|
|
3744
4384
|
return this;
|
|
3745
4385
|
}
|
|
3746
4386
|
|
|
3747
4387
|
build(): Uint8Array {
|
|
3748
|
-
const
|
|
3749
|
-
const size =
|
|
4388
|
+
const params = this.__tnComputeParams();
|
|
4389
|
+
const size = CreateArgs.footprintFromParams(params);
|
|
3750
4390
|
const buffer = new Uint8Array(size);
|
|
3751
|
-
this.__tnWriteInto(buffer
|
|
3752
|
-
this.__tnValidateOrThrow(buffer);
|
|
4391
|
+
this.__tnWriteInto(buffer);
|
|
4392
|
+
this.__tnValidateOrThrow(buffer, params);
|
|
3753
4393
|
return buffer;
|
|
3754
4394
|
}
|
|
3755
4395
|
|
|
3756
4396
|
buildInto(target: Uint8Array, offset = 0): Uint8Array {
|
|
3757
|
-
const
|
|
3758
|
-
const size =
|
|
4397
|
+
const params = this.__tnComputeParams();
|
|
4398
|
+
const size = CreateArgs.footprintFromParams(params);
|
|
3759
4399
|
if (target.length - offset < size) throw new Error("CreateArgsBuilder: target buffer too small");
|
|
3760
4400
|
const slice = target.subarray(offset, offset + size);
|
|
3761
|
-
this.__tnWriteInto(slice
|
|
3762
|
-
this.__tnValidateOrThrow(slice);
|
|
4401
|
+
this.__tnWriteInto(slice);
|
|
4402
|
+
this.__tnValidateOrThrow(slice, params);
|
|
3763
4403
|
return target;
|
|
3764
4404
|
}
|
|
3765
4405
|
|
|
3766
4406
|
finish(): CreateArgs {
|
|
3767
4407
|
const buffer = this.build();
|
|
3768
|
-
const
|
|
4408
|
+
const params = this.__tnLastParams ?? this.__tnComputeParams();
|
|
4409
|
+
const view = CreateArgs.from_array(buffer, { params });
|
|
3769
4410
|
if (!view) throw new Error("CreateArgsBuilder: failed to finalize view");
|
|
3770
4411
|
return view;
|
|
3771
4412
|
}
|
|
@@ -3774,44 +4415,42 @@ export class CreateArgsBuilder {
|
|
|
3774
4415
|
return this.finish();
|
|
3775
4416
|
}
|
|
3776
4417
|
|
|
3777
|
-
|
|
3778
|
-
return
|
|
3779
|
-
(() => {
|
|
3780
|
-
const bytes = this.__tnTail_state_proof;
|
|
3781
|
-
if (!bytes) throw new Error("CreateArgsBuilder: field 'state_proof' must be set before build()");
|
|
3782
|
-
return bytes;
|
|
3783
|
-
})(),
|
|
3784
|
-
];
|
|
4418
|
+
dynamicParams(): CreateArgs.Params {
|
|
4419
|
+
return this.__tnComputeParams();
|
|
3785
4420
|
}
|
|
3786
4421
|
|
|
3787
|
-
private
|
|
3788
|
-
|
|
3789
|
-
|
|
3790
|
-
|
|
3791
|
-
|
|
3792
|
-
|
|
4422
|
+
private __tnComputeParams(): CreateArgs.Params {
|
|
4423
|
+
if (this.__tnCachedParams) return this.__tnCachedParams;
|
|
4424
|
+
const params = CreateArgs.Params.fromValues({
|
|
4425
|
+
proof_body_hdr_type_slot: (() => { const params = this.__tnTailParams_state_proof; if (!params || params["proof_body_hdr_type_slot"] === undefined) throw new Error("CreateArgsBuilder: field 'state_proof' must be written before computing params"); return params["proof_body_hdr_type_slot"]; })(),
|
|
4426
|
+
proof_body_payload_size: (() => { const params = this.__tnTailParams_state_proof; if (!params || params["proof_body_payload_size"] === undefined) throw new Error("CreateArgsBuilder: field 'state_proof' must be written before computing params"); return params["proof_body_payload_size"]; })(),
|
|
4427
|
+
});
|
|
4428
|
+
this.__tnCachedParams = params;
|
|
4429
|
+
return params;
|
|
3793
4430
|
}
|
|
3794
4431
|
|
|
3795
|
-
private __tnWriteInto(target: Uint8Array
|
|
4432
|
+
private __tnWriteInto(target: Uint8Array): void {
|
|
3796
4433
|
target.set(this.buffer, 0);
|
|
3797
4434
|
let cursor = this.buffer.length;
|
|
3798
|
-
|
|
3799
|
-
|
|
3800
|
-
|
|
3801
|
-
|
|
4435
|
+
const __tnLocal_state_proof_bytes = this.__tnTail_state_proof;
|
|
4436
|
+
if (!__tnLocal_state_proof_bytes) throw new Error("CreateArgsBuilder: field 'state_proof' must be written before build");
|
|
4437
|
+
target.set(__tnLocal_state_proof_bytes, cursor);
|
|
4438
|
+
cursor += __tnLocal_state_proof_bytes.length;
|
|
3802
4439
|
}
|
|
3803
4440
|
|
|
3804
|
-
private __tnValidateOrThrow(buffer: Uint8Array): void {
|
|
3805
|
-
const result = CreateArgs.validate(buffer);
|
|
4441
|
+
private __tnValidateOrThrow(buffer: Uint8Array, params: CreateArgs.Params): void {
|
|
4442
|
+
const result = CreateArgs.validate(buffer, { params });
|
|
3806
4443
|
if (!result.ok) {
|
|
3807
|
-
throw new Error(
|
|
4444
|
+
throw new Error(`${ CreateArgs }Builder: builder produced invalid buffer (code=${result.code ?? "unknown"})`);
|
|
3808
4445
|
}
|
|
4446
|
+
this.__tnLastParams = result.params ?? params;
|
|
4447
|
+
this.__tnLastBuffer = buffer;
|
|
3809
4448
|
}
|
|
3810
4449
|
}
|
|
3811
4450
|
|
|
3812
4451
|
__tnRegisterFootprint("CreateArgs", (params) => CreateArgs.__tnInvokeFootprint(params));
|
|
3813
4452
|
__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) }; });
|
|
4453
|
+
__tnRegisterDynamicValidate("CreateArgs", (buffer) => { const result = CreateArgs.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 }; });
|
|
3815
4454
|
|
|
3816
4455
|
/* ----- TYPE DEFINITION FOR RegisterCredentialArgs ----- */
|
|
3817
4456
|
|
|
@@ -3822,14 +4461,36 @@ const __tn_ir_RegisterCredentialArgs = {
|
|
|
3822
4461
|
|
|
3823
4462
|
export class RegisterCredentialArgs {
|
|
3824
4463
|
private view: DataView;
|
|
4464
|
+
private __tnParams: RegisterCredentialArgs.Params;
|
|
3825
4465
|
|
|
3826
|
-
private constructor(private buffer: Uint8Array) {
|
|
4466
|
+
private constructor(private buffer: Uint8Array, params?: RegisterCredentialArgs.Params) {
|
|
3827
4467
|
this.view = new DataView(buffer.buffer, buffer.byteOffset, buffer.byteLength);
|
|
4468
|
+
if (params) {
|
|
4469
|
+
this.__tnParams = params;
|
|
4470
|
+
} else {
|
|
4471
|
+
const derived = RegisterCredentialArgs.__tnExtractParams(this.view, buffer);
|
|
4472
|
+
if (!derived) {
|
|
4473
|
+
throw new Error("RegisterCredentialArgs: failed to derive dynamic parameters");
|
|
4474
|
+
}
|
|
4475
|
+
this.__tnParams = derived.params;
|
|
4476
|
+
}
|
|
3828
4477
|
}
|
|
3829
4478
|
|
|
3830
|
-
static __tnCreateView(buffer: Uint8Array, opts?: { fieldContext?: Record<string, number | bigint> }): RegisterCredentialArgs {
|
|
4479
|
+
static __tnCreateView(buffer: Uint8Array, opts?: { params?: RegisterCredentialArgs.Params, fieldContext?: Record<string, number | bigint> }): RegisterCredentialArgs {
|
|
3831
4480
|
if (!buffer || buffer.length === undefined) throw new Error("RegisterCredentialArgs.__tnCreateView requires a Uint8Array");
|
|
3832
|
-
|
|
4481
|
+
let params = opts?.params ?? null;
|
|
4482
|
+
if (!params) {
|
|
4483
|
+
const view = new DataView(buffer.buffer, buffer.byteOffset, buffer.byteLength);
|
|
4484
|
+
const derived = RegisterCredentialArgs.__tnExtractParams(view, buffer);
|
|
4485
|
+
if (!derived) throw new Error("RegisterCredentialArgs.__tnCreateView: failed to derive params");
|
|
4486
|
+
params = derived.params;
|
|
4487
|
+
}
|
|
4488
|
+
const instance = new RegisterCredentialArgs(new Uint8Array(buffer), params);
|
|
4489
|
+
return instance;
|
|
4490
|
+
}
|
|
4491
|
+
|
|
4492
|
+
dynamicParams(): RegisterCredentialArgs.Params {
|
|
4493
|
+
return this.__tnParams;
|
|
3833
4494
|
}
|
|
3834
4495
|
|
|
3835
4496
|
static builder(): RegisterCredentialArgsBuilder {
|
|
@@ -3838,7 +4499,56 @@ export class RegisterCredentialArgs {
|
|
|
3838
4499
|
|
|
3839
4500
|
static fromBuilder(builder: RegisterCredentialArgsBuilder): RegisterCredentialArgs | null {
|
|
3840
4501
|
const buffer = builder.build();
|
|
3841
|
-
|
|
4502
|
+
const params = builder.dynamicParams();
|
|
4503
|
+
return RegisterCredentialArgs.from_array(buffer, { params });
|
|
4504
|
+
}
|
|
4505
|
+
|
|
4506
|
+
static __tnComputeSequentialLayout(view: DataView, buffer: Uint8Array): { params: Record<string, bigint> | null; offsets: Record<string, number> | null; derived: Record<string, bigint> | null } | null {
|
|
4507
|
+
const __tnLength = buffer.length;
|
|
4508
|
+
let __tnParamSeq_proof_body_hdr_type_slot: bigint | null = null;
|
|
4509
|
+
let __tnParamSeq_proof_body_payload_size: bigint | null = null;
|
|
4510
|
+
let __tnFieldValue_wallet_account_idx: number | null = null;
|
|
4511
|
+
let __tnFieldValue_lookup_account_idx: number | null = null;
|
|
4512
|
+
let __tnCursorMutable = 0;
|
|
4513
|
+
if (__tnCursorMutable + 2 > __tnLength) return null;
|
|
4514
|
+
const __tnRead_wallet_account_idx = view.getUint16(__tnCursorMutable, true);
|
|
4515
|
+
__tnFieldValue_wallet_account_idx = __tnRead_wallet_account_idx;
|
|
4516
|
+
__tnCursorMutable += 2;
|
|
4517
|
+
if (__tnCursorMutable + 2 > __tnLength) return null;
|
|
4518
|
+
const __tnRead_lookup_account_idx = view.getUint16(__tnCursorMutable, true);
|
|
4519
|
+
__tnFieldValue_lookup_account_idx = __tnRead_lookup_account_idx;
|
|
4520
|
+
__tnCursorMutable += 2;
|
|
4521
|
+
if (__tnCursorMutable + 32 > __tnLength) return null;
|
|
4522
|
+
__tnCursorMutable += 32;
|
|
4523
|
+
const __tnTyperefResult_state_proof = __tnInvokeDynamicValidate("StateProof", buffer.subarray(__tnCursorMutable));
|
|
4524
|
+
if (!__tnTyperefResult_state_proof.ok || __tnTyperefResult_state_proof.consumed === undefined) return null;
|
|
4525
|
+
const __tnTyperefParams_state_proof = __tnTyperefResult_state_proof.params ?? null;
|
|
4526
|
+
if (!__tnTyperefParams_state_proof || __tnTyperefParams_state_proof["proof_body_hdr_type_slot"] === undefined) return null;
|
|
4527
|
+
__tnParamSeq_proof_body_hdr_type_slot = __tnTyperefParams_state_proof["proof_body_hdr_type_slot"];
|
|
4528
|
+
if (!__tnTyperefParams_state_proof || __tnTyperefParams_state_proof["proof_body_payload_size"] === undefined) return null;
|
|
4529
|
+
__tnParamSeq_proof_body_payload_size = __tnTyperefParams_state_proof["proof_body_payload_size"];
|
|
4530
|
+
__tnCursorMutable += __tnBigIntToNumber(__tnTyperefResult_state_proof.consumed, "RegisterCredentialArgs::state_proof");
|
|
4531
|
+
const params: Record<string, bigint> = Object.create(null);
|
|
4532
|
+
if (__tnParamSeq_proof_body_hdr_type_slot === null) return null;
|
|
4533
|
+
params["proof_body_hdr_type_slot"] = __tnParamSeq_proof_body_hdr_type_slot as bigint;
|
|
4534
|
+
if (__tnParamSeq_proof_body_payload_size === null) return null;
|
|
4535
|
+
params["proof_body_payload_size"] = __tnParamSeq_proof_body_payload_size as bigint;
|
|
4536
|
+
return { params, offsets: null, derived: null };
|
|
4537
|
+
}
|
|
4538
|
+
|
|
4539
|
+
private static __tnExtractParams(view: DataView, buffer: Uint8Array): { params: RegisterCredentialArgs.Params; derived: Record<string, bigint> | null } | null {
|
|
4540
|
+
const __tnLayout = RegisterCredentialArgs.__tnComputeSequentialLayout(view, buffer);
|
|
4541
|
+
if (!__tnLayout || !__tnLayout.params) return null;
|
|
4542
|
+
const __tnSeqParams = __tnLayout.params;
|
|
4543
|
+
const __tnParamSeq_proof_body_hdr_type_slot = __tnSeqParams["proof_body_hdr_type_slot"];
|
|
4544
|
+
if (__tnParamSeq_proof_body_hdr_type_slot === undefined) return null;
|
|
4545
|
+
const __tnParamSeq_proof_body_payload_size = __tnSeqParams["proof_body_payload_size"];
|
|
4546
|
+
if (__tnParamSeq_proof_body_payload_size === undefined) return null;
|
|
4547
|
+
const __tnExtractedParams = RegisterCredentialArgs.Params.fromValues({
|
|
4548
|
+
proof_body_hdr_type_slot: __tnParamSeq_proof_body_hdr_type_slot as bigint,
|
|
4549
|
+
proof_body_payload_size: __tnParamSeq_proof_body_payload_size as bigint,
|
|
4550
|
+
});
|
|
4551
|
+
return { params: __tnExtractedParams, derived: null };
|
|
3842
4552
|
}
|
|
3843
4553
|
|
|
3844
4554
|
get_wallet_account_idx(): number {
|
|
@@ -3925,7 +4635,6 @@ export class RegisterCredentialArgs {
|
|
|
3925
4635
|
set state_proof(value: StateProof) {
|
|
3926
4636
|
this.set_state_proof(value);
|
|
3927
4637
|
}
|
|
3928
|
-
|
|
3929
4638
|
private static __tnFootprintInternal(__tnParams: Record<string, bigint>): bigint {
|
|
3930
4639
|
return __tnEvalFootprint(__tn_ir_RegisterCredentialArgs.root, { params: __tnParams });
|
|
3931
4640
|
}
|
|
@@ -3942,42 +4651,126 @@ export class RegisterCredentialArgs {
|
|
|
3942
4651
|
return this.__tnValidateInternal(buffer, __tnParams);
|
|
3943
4652
|
}
|
|
3944
4653
|
|
|
3945
|
-
static footprintIr(): bigint {
|
|
3946
|
-
|
|
4654
|
+
static footprintIr(proof_body_hdr_type_slot: number | bigint, proof_body_payload_size: number | bigint): bigint {
|
|
4655
|
+
const params = RegisterCredentialArgs.Params.fromValues({
|
|
4656
|
+
proof_body_hdr_type_slot: proof_body_hdr_type_slot,
|
|
4657
|
+
proof_body_payload_size: proof_body_payload_size,
|
|
4658
|
+
});
|
|
4659
|
+
return this.footprintIrFromParams(params);
|
|
3947
4660
|
}
|
|
3948
4661
|
|
|
3949
|
-
static
|
|
3950
|
-
const
|
|
3951
|
-
|
|
3952
|
-
|
|
3953
|
-
|
|
3954
|
-
|
|
3955
|
-
|
|
4662
|
+
private static __tnPackParams(params: RegisterCredentialArgs.Params): Record<string, bigint> {
|
|
4663
|
+
const record: Record<string, bigint> = Object.create(null);
|
|
4664
|
+
record["proof_body.hdr.type_slot"] = params.proof_body_hdr_type_slot;
|
|
4665
|
+
record["proof_body.payload_size"] = params.proof_body_payload_size;
|
|
4666
|
+
return record;
|
|
4667
|
+
}
|
|
4668
|
+
|
|
4669
|
+
static footprintIrFromParams(params: RegisterCredentialArgs.Params): bigint {
|
|
4670
|
+
const __tnParams = this.__tnPackParams(params);
|
|
4671
|
+
return this.__tnFootprintInternal(__tnParams);
|
|
4672
|
+
}
|
|
4673
|
+
|
|
4674
|
+
static footprintFromParams(params: RegisterCredentialArgs.Params): number {
|
|
4675
|
+
const irResult = this.footprintIrFromParams(params);
|
|
4676
|
+
const maxSafe = __tnToBigInt(Number.MAX_SAFE_INTEGER);
|
|
4677
|
+
if (__tnBigIntGreaterThan(irResult, maxSafe)) throw new Error('footprint exceeds Number.MAX_SAFE_INTEGER for RegisterCredentialArgs');
|
|
4678
|
+
return __tnBigIntToNumber(irResult, 'RegisterCredentialArgs::footprintFromParams');
|
|
4679
|
+
}
|
|
4680
|
+
|
|
4681
|
+
static footprintFromValues(input: { proof_body_hdr_type_slot: number | bigint, proof_body_payload_size: number | bigint }): number {
|
|
4682
|
+
const params = RegisterCredentialArgs.params(input);
|
|
4683
|
+
return this.footprintFromParams(params);
|
|
3956
4684
|
}
|
|
3957
4685
|
|
|
3958
|
-
static
|
|
3959
|
-
|
|
3960
|
-
return { ok: true, consumed: _buffer.length };
|
|
4686
|
+
static footprint(params: RegisterCredentialArgs.Params): number {
|
|
4687
|
+
return this.footprintFromParams(params);
|
|
3961
4688
|
}
|
|
3962
4689
|
|
|
3963
|
-
static
|
|
4690
|
+
static validate(buffer: Uint8Array, opts?: { params?: RegisterCredentialArgs.Params }): { ok: boolean; code?: string; consumed?: number; params?: RegisterCredentialArgs.Params } {
|
|
4691
|
+
if (!buffer || buffer.length === undefined) {
|
|
4692
|
+
return { ok: false, code: "tn.invalid_buffer" };
|
|
4693
|
+
}
|
|
4694
|
+
const view = new DataView(buffer.buffer, buffer.byteOffset, buffer.byteLength);
|
|
4695
|
+
let params = opts?.params ?? null;
|
|
4696
|
+
if (!params) {
|
|
4697
|
+
return { ok: false, code: "tn.param_extraction_failed" };
|
|
4698
|
+
}
|
|
4699
|
+
const __tnParamsRec = this.__tnPackParams(params);
|
|
4700
|
+
const irResult = this.__tnValidateInternal(buffer, __tnParamsRec);
|
|
4701
|
+
if (!irResult.ok) {
|
|
4702
|
+
return { ok: false, code: irResult.code, consumed: irResult.consumed ? __tnBigIntToNumber(irResult.consumed, 'RegisterCredentialArgs::validate') : undefined, params };
|
|
4703
|
+
}
|
|
4704
|
+
const consumed = irResult.consumed ? __tnBigIntToNumber(irResult.consumed, 'RegisterCredentialArgs::validate') : undefined;
|
|
4705
|
+
return { ok: true, consumed, params };
|
|
4706
|
+
}
|
|
4707
|
+
|
|
4708
|
+
static from_array(buffer: Uint8Array, opts?: { params?: RegisterCredentialArgs.Params }): RegisterCredentialArgs | null {
|
|
3964
4709
|
if (!buffer || buffer.length === undefined) {
|
|
3965
4710
|
return null;
|
|
3966
4711
|
}
|
|
3967
4712
|
const view = new DataView(buffer.buffer, buffer.byteOffset, buffer.byteLength);
|
|
3968
|
-
|
|
4713
|
+
let params = opts?.params ?? null;
|
|
4714
|
+
if (!params) {
|
|
4715
|
+
__tnLogWarn('RegisterCredentialArgs::from_array requires params when IR extraction is unavailable');
|
|
4716
|
+
return null;
|
|
4717
|
+
}
|
|
4718
|
+
const validation = this.validate(buffer, { params });
|
|
3969
4719
|
if (!validation.ok) {
|
|
3970
4720
|
return null;
|
|
3971
4721
|
}
|
|
3972
|
-
|
|
4722
|
+
const cached = validation.params ?? params;
|
|
4723
|
+
const state = new RegisterCredentialArgs(buffer, cached);
|
|
4724
|
+
return state;
|
|
3973
4725
|
}
|
|
3974
4726
|
|
|
4727
|
+
|
|
4728
|
+
}
|
|
4729
|
+
|
|
4730
|
+
export namespace RegisterCredentialArgs {
|
|
4731
|
+
export type Params = {
|
|
4732
|
+
/** ABI path: proof_body.hdr.type_slot */
|
|
4733
|
+
readonly proof_body_hdr_type_slot: bigint;
|
|
4734
|
+
/** ABI path: proof_body.payload_size */
|
|
4735
|
+
readonly proof_body_payload_size: bigint;
|
|
4736
|
+
};
|
|
4737
|
+
|
|
4738
|
+
export const ParamKeys = Object.freeze({
|
|
4739
|
+
proof_body_hdr_type_slot: "proof_body.hdr.type_slot",
|
|
4740
|
+
proof_body_payload_size: "proof_body.payload_size",
|
|
4741
|
+
} as const);
|
|
4742
|
+
|
|
4743
|
+
export const Params = {
|
|
4744
|
+
fromValues(input: { proof_body_hdr_type_slot: number | bigint, proof_body_payload_size: number | bigint }): Params {
|
|
4745
|
+
return {
|
|
4746
|
+
proof_body_hdr_type_slot: __tnToBigInt(input.proof_body_hdr_type_slot),
|
|
4747
|
+
proof_body_payload_size: __tnToBigInt(input.proof_body_payload_size),
|
|
4748
|
+
};
|
|
4749
|
+
},
|
|
4750
|
+
fromBuilder(source: { dynamicParams(): Params } | { params: Params } | Params): Params {
|
|
4751
|
+
if ((source as { dynamicParams?: () => Params }).dynamicParams) {
|
|
4752
|
+
return (source as { dynamicParams(): Params }).dynamicParams();
|
|
4753
|
+
}
|
|
4754
|
+
if ((source as { params?: Params }).params) {
|
|
4755
|
+
return (source as { params: Params }).params;
|
|
4756
|
+
}
|
|
4757
|
+
return source as Params;
|
|
4758
|
+
}
|
|
4759
|
+
};
|
|
4760
|
+
|
|
4761
|
+
export function params(input: { proof_body_hdr_type_slot: number | bigint, proof_body_payload_size: number | bigint }): Params {
|
|
4762
|
+
return Params.fromValues(input);
|
|
4763
|
+
}
|
|
3975
4764
|
}
|
|
3976
4765
|
|
|
3977
4766
|
export class RegisterCredentialArgsBuilder {
|
|
3978
4767
|
private buffer: Uint8Array;
|
|
3979
4768
|
private view: DataView;
|
|
4769
|
+
private __tnCachedParams: RegisterCredentialArgs.Params | null = null;
|
|
4770
|
+
private __tnLastBuffer: Uint8Array | null = null;
|
|
4771
|
+
private __tnLastParams: RegisterCredentialArgs.Params | null = null;
|
|
3980
4772
|
private __tnTail_state_proof: Uint8Array | null = null;
|
|
4773
|
+
private __tnTailParams_state_proof: Record<string, bigint> | null = null;
|
|
3981
4774
|
|
|
3982
4775
|
constructor() {
|
|
3983
4776
|
this.buffer = new Uint8Array(36);
|
|
@@ -3985,7 +4778,9 @@ export class RegisterCredentialArgsBuilder {
|
|
|
3985
4778
|
}
|
|
3986
4779
|
|
|
3987
4780
|
private __tnInvalidate(): void {
|
|
3988
|
-
|
|
4781
|
+
this.__tnCachedParams = null;
|
|
4782
|
+
this.__tnLastBuffer = null;
|
|
4783
|
+
this.__tnLastParams = null;
|
|
3989
4784
|
}
|
|
3990
4785
|
|
|
3991
4786
|
set_wallet_account_idx(value: number): this {
|
|
@@ -4009,33 +4804,38 @@ export class RegisterCredentialArgsBuilder {
|
|
|
4009
4804
|
|
|
4010
4805
|
set_state_proof(value: StateProof | __TnStructFieldInput): this {
|
|
4011
4806
|
const bytes = __tnResolveStructFieldInput(value as __TnStructFieldInput, "RegisterCredentialArgsBuilder::state_proof");
|
|
4807
|
+
const validation = __tnInvokeDynamicValidate("StateProof", bytes);
|
|
4808
|
+
if (!validation.ok || validation.consumed === undefined) throw new Error("RegisterCredentialArgsBuilder: field 'state_proof' failed validation");
|
|
4809
|
+
if (__tnBigIntToNumber(validation.consumed, "RegisterCredentialArgsBuilder::state_proof") !== bytes.length) throw new Error("RegisterCredentialArgsBuilder: field 'state_proof' validation did not consume the full buffer");
|
|
4012
4810
|
this.__tnTail_state_proof = bytes;
|
|
4811
|
+
this.__tnTailParams_state_proof = validation.params ?? null;
|
|
4013
4812
|
this.__tnInvalidate();
|
|
4014
4813
|
return this;
|
|
4015
4814
|
}
|
|
4016
4815
|
|
|
4017
4816
|
build(): Uint8Array {
|
|
4018
|
-
const
|
|
4019
|
-
const size =
|
|
4817
|
+
const params = this.__tnComputeParams();
|
|
4818
|
+
const size = RegisterCredentialArgs.footprintFromParams(params);
|
|
4020
4819
|
const buffer = new Uint8Array(size);
|
|
4021
|
-
this.__tnWriteInto(buffer
|
|
4022
|
-
this.__tnValidateOrThrow(buffer);
|
|
4820
|
+
this.__tnWriteInto(buffer);
|
|
4821
|
+
this.__tnValidateOrThrow(buffer, params);
|
|
4023
4822
|
return buffer;
|
|
4024
4823
|
}
|
|
4025
4824
|
|
|
4026
4825
|
buildInto(target: Uint8Array, offset = 0): Uint8Array {
|
|
4027
|
-
const
|
|
4028
|
-
const size =
|
|
4826
|
+
const params = this.__tnComputeParams();
|
|
4827
|
+
const size = RegisterCredentialArgs.footprintFromParams(params);
|
|
4029
4828
|
if (target.length - offset < size) throw new Error("RegisterCredentialArgsBuilder: target buffer too small");
|
|
4030
4829
|
const slice = target.subarray(offset, offset + size);
|
|
4031
|
-
this.__tnWriteInto(slice
|
|
4032
|
-
this.__tnValidateOrThrow(slice);
|
|
4830
|
+
this.__tnWriteInto(slice);
|
|
4831
|
+
this.__tnValidateOrThrow(slice, params);
|
|
4033
4832
|
return target;
|
|
4034
4833
|
}
|
|
4035
4834
|
|
|
4036
4835
|
finish(): RegisterCredentialArgs {
|
|
4037
4836
|
const buffer = this.build();
|
|
4038
|
-
const
|
|
4837
|
+
const params = this.__tnLastParams ?? this.__tnComputeParams();
|
|
4838
|
+
const view = RegisterCredentialArgs.from_array(buffer, { params });
|
|
4039
4839
|
if (!view) throw new Error("RegisterCredentialArgsBuilder: failed to finalize view");
|
|
4040
4840
|
return view;
|
|
4041
4841
|
}
|
|
@@ -4044,44 +4844,42 @@ export class RegisterCredentialArgsBuilder {
|
|
|
4044
4844
|
return this.finish();
|
|
4045
4845
|
}
|
|
4046
4846
|
|
|
4047
|
-
|
|
4048
|
-
return
|
|
4049
|
-
(() => {
|
|
4050
|
-
const bytes = this.__tnTail_state_proof;
|
|
4051
|
-
if (!bytes) throw new Error("RegisterCredentialArgsBuilder: field 'state_proof' must be set before build()");
|
|
4052
|
-
return bytes;
|
|
4053
|
-
})(),
|
|
4054
|
-
];
|
|
4847
|
+
dynamicParams(): RegisterCredentialArgs.Params {
|
|
4848
|
+
return this.__tnComputeParams();
|
|
4055
4849
|
}
|
|
4056
4850
|
|
|
4057
|
-
private
|
|
4058
|
-
|
|
4059
|
-
|
|
4060
|
-
|
|
4061
|
-
|
|
4062
|
-
|
|
4851
|
+
private __tnComputeParams(): RegisterCredentialArgs.Params {
|
|
4852
|
+
if (this.__tnCachedParams) return this.__tnCachedParams;
|
|
4853
|
+
const params = RegisterCredentialArgs.Params.fromValues({
|
|
4854
|
+
proof_body_hdr_type_slot: (() => { const params = this.__tnTailParams_state_proof; if (!params || params["proof_body_hdr_type_slot"] === undefined) throw new Error("RegisterCredentialArgsBuilder: field 'state_proof' must be written before computing params"); return params["proof_body_hdr_type_slot"]; })(),
|
|
4855
|
+
proof_body_payload_size: (() => { const params = this.__tnTailParams_state_proof; if (!params || params["proof_body_payload_size"] === undefined) throw new Error("RegisterCredentialArgsBuilder: field 'state_proof' must be written before computing params"); return params["proof_body_payload_size"]; })(),
|
|
4856
|
+
});
|
|
4857
|
+
this.__tnCachedParams = params;
|
|
4858
|
+
return params;
|
|
4063
4859
|
}
|
|
4064
4860
|
|
|
4065
|
-
private __tnWriteInto(target: Uint8Array
|
|
4861
|
+
private __tnWriteInto(target: Uint8Array): void {
|
|
4066
4862
|
target.set(this.buffer, 0);
|
|
4067
4863
|
let cursor = this.buffer.length;
|
|
4068
|
-
|
|
4069
|
-
|
|
4070
|
-
|
|
4071
|
-
|
|
4864
|
+
const __tnLocal_state_proof_bytes = this.__tnTail_state_proof;
|
|
4865
|
+
if (!__tnLocal_state_proof_bytes) throw new Error("RegisterCredentialArgsBuilder: field 'state_proof' must be written before build");
|
|
4866
|
+
target.set(__tnLocal_state_proof_bytes, cursor);
|
|
4867
|
+
cursor += __tnLocal_state_proof_bytes.length;
|
|
4072
4868
|
}
|
|
4073
4869
|
|
|
4074
|
-
private __tnValidateOrThrow(buffer: Uint8Array): void {
|
|
4075
|
-
const result = RegisterCredentialArgs.validate(buffer);
|
|
4870
|
+
private __tnValidateOrThrow(buffer: Uint8Array, params: RegisterCredentialArgs.Params): void {
|
|
4871
|
+
const result = RegisterCredentialArgs.validate(buffer, { params });
|
|
4076
4872
|
if (!result.ok) {
|
|
4077
|
-
throw new Error(
|
|
4873
|
+
throw new Error(`${ RegisterCredentialArgs }Builder: builder produced invalid buffer (code=${result.code ?? "unknown"})`);
|
|
4078
4874
|
}
|
|
4875
|
+
this.__tnLastParams = result.params ?? params;
|
|
4876
|
+
this.__tnLastBuffer = buffer;
|
|
4079
4877
|
}
|
|
4080
4878
|
}
|
|
4081
4879
|
|
|
4082
4880
|
__tnRegisterFootprint("RegisterCredentialArgs", (params) => RegisterCredentialArgs.__tnInvokeFootprint(params));
|
|
4083
4881
|
__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) }; });
|
|
4882
|
+
__tnRegisterDynamicValidate("RegisterCredentialArgs", (buffer) => { const result = RegisterCredentialArgs.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 }; });
|
|
4085
4883
|
|
|
4086
4884
|
/* ----- TYPE DEFINITION FOR PasskeyInstruction ----- */
|
|
4087
4885
|
|
|
@@ -4160,7 +4958,7 @@ export class PasskeyInstruction {
|
|
|
4160
4958
|
}
|
|
4161
4959
|
}
|
|
4162
4960
|
|
|
4163
|
-
static __tnCreateView(buffer: Uint8Array, opts?: { params?: PasskeyInstruction.Params }): PasskeyInstruction {
|
|
4961
|
+
static __tnCreateView(buffer: Uint8Array, opts?: { params?: PasskeyInstruction.Params, fieldContext?: Record<string, number | bigint> }): PasskeyInstruction {
|
|
4164
4962
|
if (!buffer || buffer.length === undefined) throw new Error("PasskeyInstruction.__tnCreateView requires a Uint8Array");
|
|
4165
4963
|
let params = opts?.params ?? null;
|
|
4166
4964
|
if (!params) {
|
|
@@ -4200,7 +4998,7 @@ export class PasskeyInstruction {
|
|
|
4200
4998
|
tag: 1,
|
|
4201
4999
|
payloadSize: null,
|
|
4202
5000
|
payloadType: "PasskeyInstruction::payload::validate",
|
|
4203
|
-
createPayloadBuilder: () =>
|
|
5001
|
+
createPayloadBuilder: () => __tnMaybeCallBuilder(ValidateArgs),
|
|
4204
5002
|
},
|
|
4205
5003
|
{
|
|
4206
5004
|
name: "transfer",
|
|
@@ -4212,7 +5010,7 @@ export class PasskeyInstruction {
|
|
|
4212
5010
|
{
|
|
4213
5011
|
name: "add_authority",
|
|
4214
5012
|
tag: 4,
|
|
4215
|
-
payloadSize:
|
|
5013
|
+
payloadSize: 75,
|
|
4216
5014
|
payloadType: "PasskeyInstruction::payload::add_authority",
|
|
4217
5015
|
createPayloadBuilder: () => __tnMaybeCallBuilder(AddAuthorityArgs),
|
|
4218
5016
|
},
|
|
@@ -4561,5 +5359,5 @@ export class PasskeyInstructionBuilder {
|
|
|
4561
5359
|
|
|
4562
5360
|
__tnRegisterFootprint("PasskeyInstruction", (params) => PasskeyInstruction.__tnInvokeFootprint(params));
|
|
4563
5361
|
__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) }; });
|
|
5362
|
+
__tnRegisterDynamicValidate("PasskeyInstruction", (buffer) => { const result = PasskeyInstruction.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 }; });
|
|
4565
5363
|
|