@thru/programs 0.2.29 → 0.2.31
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/amm/index.cjs +6424 -0
- package/dist/amm/index.cjs.map +1 -0
- package/dist/amm/index.d.cts +1424 -0
- package/dist/amm/index.d.ts +1424 -0
- package/dist/amm/index.js +6360 -0
- package/dist/amm/index.js.map +1 -0
- package/dist/chunk-P5OABVJI.js +28 -0
- package/dist/chunk-P5OABVJI.js.map +1 -0
- package/dist/multicall/index.cjs +1 -1
- package/dist/multicall/index.cjs.map +1 -1
- package/dist/multicall/index.d.cts +2 -2
- package/dist/multicall/index.d.ts +2 -2
- package/dist/multicall/index.js +1 -1
- package/dist/multicall/index.js.map +1 -1
- package/dist/passkey-manager/index.cjs +33 -27
- package/dist/passkey-manager/index.cjs.map +1 -1
- package/dist/passkey-manager/index.d.cts +4 -3
- package/dist/passkey-manager/index.d.ts +4 -3
- package/dist/passkey-manager/index.js +9 -28
- package/dist/passkey-manager/index.js.map +1 -1
- package/dist/token/index.cjs +1760 -275
- package/dist/token/index.cjs.map +1 -1
- package/dist/token/index.d.cts +124 -20
- package/dist/token/index.d.ts +124 -20
- package/dist/token/index.js +1760 -275
- package/dist/token/index.js.map +1 -1
- package/package.json +9 -2
- package/src/amm/abi/thru/common/primitives/types.ts +2269 -0
- package/src/amm/abi/thru/program/amm/types.ts +5621 -0
- package/src/amm/index.test.ts +255 -0
- package/src/amm/index.ts +434 -0
- package/src/helpers/bytes.ts +25 -0
- package/src/multicall/abi/thru/common/primitives/types.ts +5 -6
- package/src/multicall/abi/thru/program/multicall/types.ts +1 -2
- package/src/passkey-manager/abi/thru/blockchain/state_proof/types.ts +0 -1
- package/src/passkey-manager/abi/thru/common/primitives/types.ts +0 -1
- package/src/passkey-manager/abi/thru/program/passkey_manager/types.ts +4 -5
- package/src/passkey-manager/encoding.ts +2 -26
- package/src/token/abi/thru/blockchain/state_proof/types.ts +101 -21
- package/src/token/abi/thru/common/primitives/types.ts +1295 -167
- package/src/token/abi/thru/program/token/types.ts +647 -237
- package/tsup.config.ts +1 -0
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
export function bytesEqual(a: Uint8Array, b: Uint8Array): boolean {
|
|
2
|
+
if (a.length !== b.length) return false;
|
|
3
|
+
for (let i = 0; i < a.length; i++) {
|
|
4
|
+
if (a[i] !== b[i]) return false;
|
|
5
|
+
}
|
|
6
|
+
return true;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export function compareBytes(a: Uint8Array, b: Uint8Array): number {
|
|
10
|
+
const len = Math.min(a.length, b.length);
|
|
11
|
+
for (let i = 0; i < len; i++) {
|
|
12
|
+
if (a[i] !== b[i]) return a[i] - b[i];
|
|
13
|
+
}
|
|
14
|
+
return a.length - b.length;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export function uniqueAccounts(accounts: Uint8Array[]): Uint8Array[] {
|
|
18
|
+
const unique: Uint8Array[] = [];
|
|
19
|
+
for (const account of accounts) {
|
|
20
|
+
if (!unique.some((candidate) => bytesEqual(candidate, account))) {
|
|
21
|
+
unique.push(account);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
return unique;
|
|
25
|
+
}
|
|
@@ -1106,7 +1106,7 @@ export class DurationBuilder {
|
|
|
1106
1106
|
this.view = new DataView(this.buffer.buffer, this.buffer.byteOffset, this.buffer.byteLength);
|
|
1107
1107
|
}
|
|
1108
1108
|
|
|
1109
|
-
set_seconds(value:
|
|
1109
|
+
set_seconds(value: bigint): this {
|
|
1110
1110
|
const cast = __tnToBigInt(value);
|
|
1111
1111
|
this.view.setBigInt64(0, cast, true);
|
|
1112
1112
|
return this;
|
|
@@ -1270,7 +1270,7 @@ export class FixedPointBuilder {
|
|
|
1270
1270
|
this.view = new DataView(this.buffer.buffer, this.buffer.byteOffset, this.buffer.byteLength);
|
|
1271
1271
|
}
|
|
1272
1272
|
|
|
1273
|
-
set_mantissa(value:
|
|
1273
|
+
set_mantissa(value: bigint): this {
|
|
1274
1274
|
const cast = __tnToBigInt(value);
|
|
1275
1275
|
this.view.setBigInt64(0, cast, true);
|
|
1276
1276
|
return this;
|
|
@@ -1756,7 +1756,7 @@ export class InstructionDataBuilder {
|
|
|
1756
1756
|
return this;
|
|
1757
1757
|
}
|
|
1758
1758
|
|
|
1759
|
-
set_data_size(value:
|
|
1759
|
+
set_data_size(value: bigint): this {
|
|
1760
1760
|
const cast = __tnToBigInt(value);
|
|
1761
1761
|
this.view.setBigUint64(2, cast, true);
|
|
1762
1762
|
this.__tnInvalidate();
|
|
@@ -1770,7 +1770,7 @@ export class InstructionDataBuilder {
|
|
|
1770
1770
|
const elementCount = bytes.length;
|
|
1771
1771
|
this.__tnFam_data = bytes;
|
|
1772
1772
|
this.__tnFam_dataCount = elementCount;
|
|
1773
|
-
this.set_data_size(elementCount);
|
|
1773
|
+
this.set_data_size(__tnToBigInt(elementCount));
|
|
1774
1774
|
this.__tnInvalidate();
|
|
1775
1775
|
});
|
|
1776
1776
|
}
|
|
@@ -2241,7 +2241,7 @@ export class TimestampBuilder {
|
|
|
2241
2241
|
this.view = new DataView(this.buffer.buffer, this.buffer.byteOffset, this.buffer.byteLength);
|
|
2242
2242
|
}
|
|
2243
2243
|
|
|
2244
|
-
set_seconds(value:
|
|
2244
|
+
set_seconds(value: bigint): this {
|
|
2245
2245
|
const cast = __tnToBigInt(value);
|
|
2246
2246
|
this.view.setBigInt64(0, cast, true);
|
|
2247
2247
|
return this;
|
|
@@ -2267,4 +2267,3 @@ export class TimestampBuilder {
|
|
|
2267
2267
|
__tnRegisterFootprint("Timestamp", (params) => Timestamp.__tnInvokeFootprint(params));
|
|
2268
2268
|
__tnRegisterValidate("Timestamp", (buffer, params) => Timestamp.__tnInvokeValidate(buffer, params));
|
|
2269
2269
|
__tnRegisterDynamicValidate("Timestamp", (buffer) => { const result = Timestamp.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 }; });
|
|
2270
|
-
|
|
@@ -1335,7 +1335,7 @@ export class MulticallErrorBuilder {
|
|
|
1335
1335
|
this.view = new DataView(this.buffer.buffer, this.buffer.byteOffset, this.buffer.byteLength);
|
|
1336
1336
|
}
|
|
1337
1337
|
|
|
1338
|
-
set_code(value:
|
|
1338
|
+
set_code(value: bigint): this {
|
|
1339
1339
|
const cast = __tnToBigInt(value);
|
|
1340
1340
|
this.view.setBigUint64(0, cast, true);
|
|
1341
1341
|
return this;
|
|
@@ -1361,4 +1361,3 @@ export class MulticallErrorBuilder {
|
|
|
1361
1361
|
__tnRegisterFootprint("MulticallError", (params) => MulticallError.__tnInvokeFootprint(params));
|
|
1362
1362
|
__tnRegisterValidate("MulticallError", (buffer, params) => MulticallError.__tnInvokeValidate(buffer, params));
|
|
1363
1363
|
__tnRegisterDynamicValidate("MulticallError", (buffer) => { const result = MulticallError.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 }; });
|
|
1364
|
-
|
|
@@ -1745,4 +1745,3 @@ export class StateProofBuilder {
|
|
|
1745
1745
|
__tnRegisterFootprint("StateProof", (params) => StateProof.__tnInvokeFootprint(params));
|
|
1746
1746
|
__tnRegisterValidate("StateProof", (buffer, params) => StateProof.__tnInvokeValidate(buffer, params));
|
|
1747
1747
|
__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 }; });
|
|
1748
|
-
|
|
@@ -2267,4 +2267,3 @@ export class TimestampBuilder {
|
|
|
2267
2267
|
__tnRegisterFootprint("Timestamp", (params) => Timestamp.__tnInvokeFootprint(params));
|
|
2268
2268
|
__tnRegisterValidate("Timestamp", (buffer, params) => Timestamp.__tnInvokeValidate(buffer, params));
|
|
2269
2269
|
__tnRegisterDynamicValidate("Timestamp", (buffer) => { const result = Timestamp.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 }; });
|
|
2270
|
-
|
|
@@ -1122,7 +1122,7 @@ export class AuthorityRecordBuilder {
|
|
|
1122
1122
|
|
|
1123
1123
|
__tnRegisterFootprint("AuthorityRecord", (params) => AuthorityRecord.__tnInvokeFootprint(params));
|
|
1124
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) }; });
|
|
1125
|
+
__tnRegisterDynamicValidate("AuthorityRecord", (buffer) => { const result = AuthorityRecord.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 }; });
|
|
1126
1126
|
|
|
1127
1127
|
/* ----- TYPE DEFINITION FOR P256Point ----- */
|
|
1128
1128
|
|
|
@@ -3993,7 +3993,7 @@ export class PasskeyEventBuilder {
|
|
|
3993
3993
|
private __tnComputeParams(): PasskeyEvent.Params {
|
|
3994
3994
|
if (this.__tnCachedParams) return this.__tnCachedParams;
|
|
3995
3995
|
const params = PasskeyEvent.Params.fromValues({
|
|
3996
|
-
payload_event_type: (() => { return __tnToBigInt(this.
|
|
3996
|
+
payload_event_type: (() => { if (this.__tnField_event_type === null) throw new Error("PasskeyEventBuilder: missing enum tag"); return __tnToBigInt(this.__tnField_event_type); })(),
|
|
3997
3997
|
});
|
|
3998
3998
|
this.__tnCachedParams = params;
|
|
3999
3999
|
return params;
|
|
@@ -4083,8 +4083,8 @@ export class CreateArgs {
|
|
|
4083
4083
|
const __tnRead_wallet_account_idx = view.getUint16(__tnCursorMutable, true);
|
|
4084
4084
|
__tnFieldValue_wallet_account_idx = __tnRead_wallet_account_idx;
|
|
4085
4085
|
__tnCursorMutable += 2;
|
|
4086
|
-
if (__tnCursorMutable +
|
|
4087
|
-
__tnCursorMutable +=
|
|
4086
|
+
if (__tnCursorMutable + 73 > __tnLength) return null;
|
|
4087
|
+
__tnCursorMutable += 73;
|
|
4088
4088
|
if (__tnCursorMutable + 32 > __tnLength) return null;
|
|
4089
4089
|
__tnCursorMutable += 32;
|
|
4090
4090
|
const __tnTyperefResult_state_proof = __tnInvokeDynamicValidate("StateProof", buffer.subarray(__tnCursorMutable));
|
|
@@ -5360,4 +5360,3 @@ export class PasskeyInstructionBuilder {
|
|
|
5360
5360
|
__tnRegisterFootprint("PasskeyInstruction", (params) => PasskeyInstruction.__tnInvokeFootprint(params));
|
|
5361
5361
|
__tnRegisterValidate("PasskeyInstruction", (buffer, params) => PasskeyInstruction.__tnInvokeValidate(buffer, params));
|
|
5362
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 }; });
|
|
5363
|
-
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { hexToBytes as sharedHexToBytes } from '@thru/sdk/helpers';
|
|
2
2
|
|
|
3
|
+
export { bytesEqual, compareBytes, uniqueAccounts } from '../helpers/bytes';
|
|
4
|
+
|
|
3
5
|
export function arrayBufferToBase64Url(buffer: ArrayBuffer | SharedArrayBuffer): string {
|
|
4
6
|
const bytes = new Uint8Array(buffer);
|
|
5
7
|
let base64 = '';
|
|
@@ -57,29 +59,3 @@ export function bytesToHex(bytes: Uint8Array): string {
|
|
|
57
59
|
export function hexToBytes(hex: string): Uint8Array {
|
|
58
60
|
return sharedHexToBytes(hex);
|
|
59
61
|
}
|
|
60
|
-
|
|
61
|
-
export function bytesEqual(a: Uint8Array, b: Uint8Array): boolean {
|
|
62
|
-
if (a.length !== b.length) return false;
|
|
63
|
-
for (let i = 0; i < a.length; i++) {
|
|
64
|
-
if (a[i] !== b[i]) return false;
|
|
65
|
-
}
|
|
66
|
-
return true;
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
export function compareBytes(a: Uint8Array, b: Uint8Array): number {
|
|
70
|
-
const len = Math.min(a.length, b.length);
|
|
71
|
-
for (let i = 0; i < len; i++) {
|
|
72
|
-
if (a[i] !== b[i]) return a[i] - b[i];
|
|
73
|
-
}
|
|
74
|
-
return a.length - b.length;
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
export function uniqueAccounts(accounts: Uint8Array[]): Uint8Array[] {
|
|
78
|
-
const unique: Uint8Array[] = [];
|
|
79
|
-
for (const account of accounts) {
|
|
80
|
-
if (!unique.some((candidate) => bytesEqual(candidate, account))) {
|
|
81
|
-
unique.push(account);
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
return unique;
|
|
85
|
-
}
|
|
@@ -32,6 +32,12 @@ type __TnIrNode =
|
|
|
32
32
|
readonly op: "call";
|
|
33
33
|
readonly typeName: string;
|
|
34
34
|
readonly args: readonly { readonly name: string; readonly source: string }[];
|
|
35
|
+
}
|
|
36
|
+
| {
|
|
37
|
+
readonly op: "sumOverArray";
|
|
38
|
+
readonly count: __TnIrNode;
|
|
39
|
+
readonly elementTypeName: string;
|
|
40
|
+
readonly fieldName: string;
|
|
35
41
|
};
|
|
36
42
|
|
|
37
43
|
type __TnIrContext = {
|
|
@@ -40,7 +46,12 @@ type __TnIrContext = {
|
|
|
40
46
|
typeName?: string;
|
|
41
47
|
};
|
|
42
48
|
|
|
43
|
-
type __TnValidateResult = {
|
|
49
|
+
type __TnValidateResult = {
|
|
50
|
+
ok: boolean;
|
|
51
|
+
code?: string;
|
|
52
|
+
consumed?: bigint;
|
|
53
|
+
params?: Record<string, bigint>;
|
|
54
|
+
};
|
|
44
55
|
type __TnEvalResult =
|
|
45
56
|
| { ok: true; value: bigint }
|
|
46
57
|
| { ok: false; code: string };
|
|
@@ -517,6 +528,10 @@ const __tnValidateRegistry: Record<
|
|
|
517
528
|
string,
|
|
518
529
|
(buffer: Uint8Array, params: Record<string, bigint>) => __TnValidateResult
|
|
519
530
|
> = {};
|
|
531
|
+
const __tnDynamicValidateRegistry: Record<
|
|
532
|
+
string,
|
|
533
|
+
(buffer: Uint8Array) => __TnValidateResult
|
|
534
|
+
> = {};
|
|
520
535
|
|
|
521
536
|
function __tnRegisterFootprint(
|
|
522
537
|
typeName: string,
|
|
@@ -532,6 +547,13 @@ function __tnRegisterValidate(
|
|
|
532
547
|
__tnValidateRegistry[typeName] = fn;
|
|
533
548
|
}
|
|
534
549
|
|
|
550
|
+
function __tnRegisterDynamicValidate(
|
|
551
|
+
typeName: string,
|
|
552
|
+
fn: (buffer: Uint8Array) => __TnValidateResult
|
|
553
|
+
): void {
|
|
554
|
+
__tnDynamicValidateRegistry[typeName] = fn;
|
|
555
|
+
}
|
|
556
|
+
|
|
535
557
|
function __tnInvokeFootprint(
|
|
536
558
|
typeName: string,
|
|
537
559
|
params: Record<string, bigint>
|
|
@@ -551,8 +573,17 @@ function __tnInvokeValidate(
|
|
|
551
573
|
return fn(buffer, params);
|
|
552
574
|
}
|
|
553
575
|
|
|
576
|
+
function __tnInvokeDynamicValidate(
|
|
577
|
+
typeName: string,
|
|
578
|
+
buffer: Uint8Array
|
|
579
|
+
): __TnValidateResult {
|
|
580
|
+
const fn = __tnDynamicValidateRegistry[typeName];
|
|
581
|
+
if (!fn) throw new Error(`IR runtime missing dynamic validate helper for ${typeName}`);
|
|
582
|
+
return fn(buffer);
|
|
583
|
+
}
|
|
584
|
+
|
|
554
585
|
function __tnEvalFootprint(node: __TnIrNode, ctx: __TnIrContext): bigint {
|
|
555
|
-
return __tnEvalIrNode(node, ctx);
|
|
586
|
+
return __tnEvalIrNode(node, ctx, __tnToBigInt(0));
|
|
556
587
|
}
|
|
557
588
|
|
|
558
589
|
function __tnTryEvalFootprint(
|
|
@@ -567,7 +598,7 @@ function __tnTryEvalIr(
|
|
|
567
598
|
ctx: __TnIrContext
|
|
568
599
|
): __TnEvalResult {
|
|
569
600
|
try {
|
|
570
|
-
return { ok: true, value: __tnEvalIrNode(node, ctx) };
|
|
601
|
+
return { ok: true, value: __tnEvalIrNode(node, ctx, __tnToBigInt(0)) };
|
|
571
602
|
} catch (err) {
|
|
572
603
|
return { ok: false, code: __tnNormalizeIrError(err) };
|
|
573
604
|
}
|
|
@@ -598,7 +629,11 @@ function __tnValidateIrTree(
|
|
|
598
629
|
return { ok: true, consumed: required };
|
|
599
630
|
}
|
|
600
631
|
|
|
601
|
-
function __tnEvalIrNode(
|
|
632
|
+
function __tnEvalIrNode(
|
|
633
|
+
node: __TnIrNode,
|
|
634
|
+
ctx: __TnIrContext,
|
|
635
|
+
baseOffset: bigint
|
|
636
|
+
): bigint {
|
|
602
637
|
switch (node.op) {
|
|
603
638
|
case "zero":
|
|
604
639
|
return __tnToBigInt(0);
|
|
@@ -616,17 +651,22 @@ function __tnEvalIrNode(node: __TnIrNode, ctx: __TnIrContext): bigint {
|
|
|
616
651
|
return val;
|
|
617
652
|
}
|
|
618
653
|
case "add":
|
|
619
|
-
|
|
620
|
-
__tnEvalIrNode(node.left, ctx)
|
|
621
|
-
__tnEvalIrNode(
|
|
622
|
-
|
|
654
|
+
{
|
|
655
|
+
const left = __tnEvalIrNode(node.left, ctx, baseOffset);
|
|
656
|
+
const right = __tnEvalIrNode(
|
|
657
|
+
node.right,
|
|
658
|
+
ctx,
|
|
659
|
+
__tnCheckedAdd(baseOffset, left)
|
|
660
|
+
);
|
|
661
|
+
return __tnCheckedAdd(left, right);
|
|
662
|
+
}
|
|
623
663
|
case "mul":
|
|
624
664
|
return __tnCheckedMul(
|
|
625
|
-
__tnEvalIrNode(node.left, ctx),
|
|
626
|
-
__tnEvalIrNode(node.right, ctx)
|
|
665
|
+
__tnEvalIrNode(node.left, ctx, baseOffset),
|
|
666
|
+
__tnEvalIrNode(node.right, ctx, baseOffset)
|
|
627
667
|
);
|
|
628
668
|
case "align":
|
|
629
|
-
return __tnAlign(__tnEvalIrNode(node.node, ctx), node.alignment);
|
|
669
|
+
return __tnAlign(__tnEvalIrNode(node.node, ctx, baseOffset), node.alignment);
|
|
630
670
|
case "switch": {
|
|
631
671
|
const tagVal = ctx.params[node.tag];
|
|
632
672
|
if (tagVal === undefined) {
|
|
@@ -639,10 +679,10 @@ function __tnEvalIrNode(node: __TnIrNode, ctx: __TnIrContext): bigint {
|
|
|
639
679
|
const tagNumber = Number(tagVal);
|
|
640
680
|
for (const caseNode of node.cases) {
|
|
641
681
|
if (caseNode.value === tagNumber) {
|
|
642
|
-
return __tnEvalIrNode(caseNode.node, ctx);
|
|
682
|
+
return __tnEvalIrNode(caseNode.node, ctx, baseOffset);
|
|
643
683
|
}
|
|
644
684
|
}
|
|
645
|
-
if (node.default) return __tnEvalIrNode(node.default, ctx);
|
|
685
|
+
if (node.default) return __tnEvalIrNode(node.default, ctx, baseOffset);
|
|
646
686
|
__tnRaiseIrError(
|
|
647
687
|
"tn.ir.invalid_tag",
|
|
648
688
|
`Unhandled IR switch value ${tagNumber} for '${node.tag}'`
|
|
@@ -662,9 +702,10 @@ function __tnEvalIrNode(node: __TnIrNode, ctx: __TnIrContext): bigint {
|
|
|
662
702
|
nestedParams[arg.name] = val;
|
|
663
703
|
}
|
|
664
704
|
if (ctx.buffer) {
|
|
705
|
+
const nestedOffset = __tnBigIntToNumber(baseOffset, "IR nested offset");
|
|
665
706
|
const nestedResult = __tnInvokeValidate(
|
|
666
707
|
node.typeName,
|
|
667
|
-
ctx.buffer,
|
|
708
|
+
ctx.buffer.subarray(nestedOffset),
|
|
668
709
|
nestedParams
|
|
669
710
|
);
|
|
670
711
|
if (!nestedResult.ok) {
|
|
@@ -684,6 +725,36 @@ function __tnEvalIrNode(node: __TnIrNode, ctx: __TnIrContext): bigint {
|
|
|
684
725
|
}
|
|
685
726
|
return __tnInvokeFootprint(node.typeName, nestedParams);
|
|
686
727
|
}
|
|
728
|
+
case "sumOverArray": {
|
|
729
|
+
if (!ctx.buffer) {
|
|
730
|
+
__tnRaiseIrError(
|
|
731
|
+
"tn.ir.missing_buffer",
|
|
732
|
+
`Jagged array '${node.fieldName}' requires buffer-backed validation`
|
|
733
|
+
);
|
|
734
|
+
}
|
|
735
|
+
const count = __tnBigIntToNumber(
|
|
736
|
+
__tnEvalIrNode(node.count, ctx, baseOffset),
|
|
737
|
+
`Jagged array '${node.fieldName}' count`
|
|
738
|
+
);
|
|
739
|
+
let cursor = __tnBigIntToNumber(baseOffset, "IR jagged array offset");
|
|
740
|
+
let total = __tnToBigInt(0);
|
|
741
|
+
for (let i = 0; i < count; i++) {
|
|
742
|
+
const result = __tnInvokeDynamicValidate(
|
|
743
|
+
node.elementTypeName,
|
|
744
|
+
ctx.buffer.subarray(cursor)
|
|
745
|
+
);
|
|
746
|
+
if (!result.ok || result.consumed === undefined) {
|
|
747
|
+
const code = result.code ?? "tn.ir.runtime_error";
|
|
748
|
+
__tnRaiseIrError(
|
|
749
|
+
code,
|
|
750
|
+
`Jagged array '${node.fieldName}' element ${i} failed validation`
|
|
751
|
+
);
|
|
752
|
+
}
|
|
753
|
+
cursor += __tnBigIntToNumber(result.consumed, "IR jagged element size");
|
|
754
|
+
total = __tnCheckedAdd(total, result.consumed);
|
|
755
|
+
}
|
|
756
|
+
return total;
|
|
757
|
+
}
|
|
687
758
|
default:
|
|
688
759
|
__tnRaiseIrError(
|
|
689
760
|
"tn.ir.runtime_error",
|
|
@@ -718,6 +789,14 @@ function __tnNormalizeIrError(err: unknown): string {
|
|
|
718
789
|
return "tn.ir.runtime_error";
|
|
719
790
|
}
|
|
720
791
|
|
|
792
|
+
__tnRegisterFootprint("Hash", (params) => Hash.__tnInvokeFootprint(params));
|
|
793
|
+
__tnRegisterValidate("Hash", (buffer, params) => Hash.__tnInvokeValidate(buffer, params));
|
|
794
|
+
__tnRegisterDynamicValidate("Hash", (buffer) => { const result = Hash.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
|
+
|
|
796
|
+
__tnRegisterFootprint("Pubkey", (params) => Pubkey.__tnInvokeFootprint(params));
|
|
797
|
+
__tnRegisterValidate("Pubkey", (buffer, params) => Pubkey.__tnInvokeValidate(buffer, params));
|
|
798
|
+
__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 }; });
|
|
799
|
+
|
|
721
800
|
/* ----- TYPE DEFINITION FOR StateProofHeader ----- */
|
|
722
801
|
|
|
723
802
|
const __tn_ir_StateProofHeader = {
|
|
@@ -833,9 +912,6 @@ export class StateProofHeader {
|
|
|
833
912
|
|
|
834
913
|
}
|
|
835
914
|
|
|
836
|
-
__tnRegisterFootprint("StateProofHeader", (params) => StateProofHeader.__tnInvokeFootprint(params));
|
|
837
|
-
__tnRegisterValidate("StateProofHeader", (buffer, params) => StateProofHeader.__tnInvokeValidate(buffer, params));
|
|
838
|
-
|
|
839
915
|
export class StateProofHeaderBuilder {
|
|
840
916
|
private buffer: Uint8Array;
|
|
841
917
|
private view: DataView;
|
|
@@ -845,7 +921,7 @@ export class StateProofHeaderBuilder {
|
|
|
845
921
|
this.view = new DataView(this.buffer.buffer, this.buffer.byteOffset, this.buffer.byteLength);
|
|
846
922
|
}
|
|
847
923
|
|
|
848
|
-
set_type_slot(value:
|
|
924
|
+
set_type_slot(value: bigint): this {
|
|
849
925
|
const cast = __tnToBigInt(value);
|
|
850
926
|
this.view.setBigUint64(0, cast, true);
|
|
851
927
|
return this;
|
|
@@ -874,6 +950,10 @@ export class StateProofHeaderBuilder {
|
|
|
874
950
|
}
|
|
875
951
|
}
|
|
876
952
|
|
|
953
|
+
__tnRegisterFootprint("StateProofHeader", (params) => StateProofHeader.__tnInvokeFootprint(params));
|
|
954
|
+
__tnRegisterValidate("StateProofHeader", (buffer, params) => StateProofHeader.__tnInvokeValidate(buffer, params));
|
|
955
|
+
__tnRegisterDynamicValidate("StateProofHeader", (buffer) => { const result = StateProofHeader.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 }; });
|
|
956
|
+
|
|
877
957
|
/* ----- TYPE DEFINITION FOR StateProof ----- */
|
|
878
958
|
|
|
879
959
|
const __tn_ir_StateProof = {
|
|
@@ -1548,9 +1628,6 @@ export namespace StateProof {
|
|
|
1548
1628
|
}
|
|
1549
1629
|
}
|
|
1550
1630
|
|
|
1551
|
-
__tnRegisterFootprint("StateProof", (params) => StateProof.__tnInvokeFootprint(params));
|
|
1552
|
-
__tnRegisterValidate("StateProof", (buffer, params) => StateProof.__tnInvokeValidate(buffer, params));
|
|
1553
|
-
|
|
1554
1631
|
export class StateProofBuilder {
|
|
1555
1632
|
private __tnPrefixBuffer: Uint8Array;
|
|
1556
1633
|
private __tnPrefixView: DataView;
|
|
@@ -1665,3 +1742,6 @@ export class StateProofBuilder {
|
|
|
1665
1742
|
}
|
|
1666
1743
|
}
|
|
1667
1744
|
|
|
1745
|
+
__tnRegisterFootprint("StateProof", (params) => StateProof.__tnInvokeFootprint(params));
|
|
1746
|
+
__tnRegisterValidate("StateProof", (buffer, params) => StateProof.__tnInvokeValidate(buffer, params));
|
|
1747
|
+
__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 }; });
|