@thru/programs 0.2.22 → 0.2.24

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (32) hide show
  1. package/dist/multicall/index.cjs +2579 -0
  2. package/dist/multicall/index.cjs.map +1 -0
  3. package/dist/multicall/index.d.cts +253 -0
  4. package/dist/multicall/index.d.ts +253 -0
  5. package/dist/multicall/index.js +2573 -0
  6. package/dist/multicall/index.js.map +1 -0
  7. package/dist/passkey-manager/index.cjs +582 -706
  8. package/dist/passkey-manager/index.cjs.map +1 -1
  9. package/dist/passkey-manager/index.d.cts +20 -14
  10. package/dist/passkey-manager/index.d.ts +20 -14
  11. package/dist/passkey-manager/index.js +551 -673
  12. package/dist/passkey-manager/index.js.map +1 -1
  13. package/package.json +7 -2
  14. package/src/multicall/abi/thru/common/primitives/types.ts +2265 -0
  15. package/src/multicall/abi/thru/program/multicall/types.ts +1232 -0
  16. package/src/multicall/index.test.ts +46 -0
  17. package/src/multicall/index.ts +81 -0
  18. package/src/passkey-manager/abi/thru/blockchain/state_proof/types.ts +95 -19
  19. package/src/passkey-manager/abi/thru/common/primitives/types.ts +111 -37
  20. package/src/passkey-manager/abi/thru/program/passkey_manager/types.ts +248 -660
  21. package/src/passkey-manager/challenge.ts +52 -12
  22. package/src/passkey-manager/constants.ts +0 -1
  23. package/src/passkey-manager/index.ts +4 -4
  24. package/src/passkey-manager/instructions/add-authority.ts +8 -2
  25. package/src/passkey-manager/instructions/remove-authority.ts +9 -2
  26. package/src/passkey-manager/instructions/validate.ts +60 -14
  27. package/src/passkey-manager/target-instruction.ts +29 -0
  28. package/src/passkey-manager/types.ts +16 -0
  29. package/src/passkey-manager/validate.test.ts +173 -0
  30. package/tsup.config.ts +1 -0
  31. package/src/passkey-manager/instructions/invoke.ts +0 -25
  32. package/src/passkey-manager/instructions/shared.ts +0 -12
@@ -0,0 +1,253 @@
1
+ type __TnValidateResult$1 = {
2
+ ok: boolean;
3
+ code?: string;
4
+ consumed?: bigint;
5
+ };
6
+ type __TnBuilderLike = {
7
+ build(): Uint8Array;
8
+ };
9
+ type __TnFamWriterResult<Parent> = {
10
+ write(payload: Uint8Array | __TnBuilderLike): {
11
+ finish(): Parent;
12
+ };
13
+ finish(): Parent;
14
+ };
15
+ declare class InstructionData {
16
+ private buffer;
17
+ private view;
18
+ private __tnFieldContext;
19
+ private __tnParams;
20
+ private constructor();
21
+ static __tnCreateView(buffer: Uint8Array, opts?: {
22
+ params?: InstructionData.Params;
23
+ fieldContext?: Record<string, number | bigint>;
24
+ }): InstructionData;
25
+ dynamicParams(): InstructionData.Params;
26
+ withFieldContext(context: Record<string, number | bigint>): this;
27
+ private __tnResolveFieldRef;
28
+ static builder(): InstructionDataBuilder;
29
+ static fromBuilder(builder: InstructionDataBuilder): InstructionData | null;
30
+ static readonly flexibleArrayWriters: readonly [{
31
+ readonly field: "data";
32
+ readonly method: "data";
33
+ readonly sizeField: "data_size";
34
+ readonly paramKey: "data_size";
35
+ readonly elementSize: 1;
36
+ }];
37
+ private static __tnExtractParams;
38
+ get_program_idx(): number;
39
+ set_program_idx(value: number): void;
40
+ get program_idx(): number;
41
+ set program_idx(value: number);
42
+ get_data_size(): bigint;
43
+ set_data_size(value: bigint): void;
44
+ get data_size(): bigint;
45
+ set data_size(value: bigint);
46
+ get_data_length(): number;
47
+ get_data_at(index: number): number;
48
+ get_data(): number[];
49
+ set_data_at(index: number, value: number): void;
50
+ set_data(value: number[]): void;
51
+ get data(): number[];
52
+ set data(value: number[]);
53
+ private static __tnFootprintInternal;
54
+ private static __tnValidateInternal;
55
+ static __tnInvokeFootprint(__tnParams: Record<string, bigint>): bigint;
56
+ static __tnInvokeValidate(buffer: Uint8Array, __tnParams: Record<string, bigint>): __TnValidateResult$1;
57
+ static footprintIr(data_data_size: number | bigint): bigint;
58
+ private static __tnPackParams;
59
+ static footprintIrFromParams(params: InstructionData.Params): bigint;
60
+ static footprintFromParams(params: InstructionData.Params): number;
61
+ static footprintFromValues(input: {
62
+ data_data_size: number | bigint;
63
+ }): number;
64
+ static footprint(params: InstructionData.Params): number;
65
+ static validate(buffer: Uint8Array, opts?: {
66
+ params?: InstructionData.Params;
67
+ }): {
68
+ ok: boolean;
69
+ code?: string;
70
+ consumed?: number;
71
+ params?: InstructionData.Params;
72
+ };
73
+ static from_array(buffer: Uint8Array, opts?: {
74
+ params?: InstructionData.Params;
75
+ }): InstructionData | null;
76
+ }
77
+ declare namespace InstructionData {
78
+ type Params = {
79
+ /** ABI path: data.data_size */
80
+ readonly data_data_size: bigint;
81
+ };
82
+ const ParamKeys: Readonly<{
83
+ readonly data_data_size: "data.data_size";
84
+ }>;
85
+ const Params: {
86
+ fromValues(input: {
87
+ data_data_size: number | bigint;
88
+ }): Params;
89
+ fromBuilder(source: {
90
+ dynamicParams(): Params;
91
+ } | {
92
+ params: Params;
93
+ } | Params): Params;
94
+ };
95
+ function params(input: {
96
+ data_data_size: number | bigint;
97
+ }): Params;
98
+ }
99
+ declare class InstructionDataBuilder {
100
+ private buffer;
101
+ private view;
102
+ private __tnCachedParams;
103
+ private __tnLastBuffer;
104
+ private __tnLastParams;
105
+ private __tnFam_data;
106
+ private __tnFam_dataCount;
107
+ private __tnFamWriter_data?;
108
+ constructor();
109
+ private __tnInvalidate;
110
+ set_program_idx(value: number): this;
111
+ set_data_size(value: number): this;
112
+ data(): __TnFamWriterResult<InstructionDataBuilder>;
113
+ build(): Uint8Array;
114
+ buildInto(target: Uint8Array, offset?: number): Uint8Array;
115
+ finish(): InstructionData;
116
+ finishView(): InstructionData;
117
+ dynamicParams(): InstructionData.Params;
118
+ private __tnComputeParams;
119
+ private __tnWriteInto;
120
+ private __tnValidateOrThrow;
121
+ }
122
+
123
+ type __TnValidateResult = {
124
+ ok: boolean;
125
+ code?: string;
126
+ consumed?: bigint;
127
+ };
128
+ declare class MulticallArgs {
129
+ private buffer;
130
+ private view;
131
+ private __tnFieldContext;
132
+ private __tnParams;
133
+ private constructor();
134
+ static __tnCreateView(buffer: Uint8Array, opts?: {
135
+ params?: MulticallArgs.Params;
136
+ fieldContext?: Record<string, number | bigint>;
137
+ }): MulticallArgs;
138
+ dynamicParams(): MulticallArgs.Params;
139
+ withFieldContext(context: Record<string, number | bigint>): this;
140
+ private __tnResolveFieldRef;
141
+ private static __tnExtractParams;
142
+ get_calls_count(): number;
143
+ set_calls_count(value: number): void;
144
+ get calls_count(): number;
145
+ set calls_count(value: number);
146
+ /** Returns the number of elements in the jagged array. */
147
+ get_calls_length(): number;
148
+ /** Returns the element at the given index, or null if out of bounds.
149
+ * Note: This is O(n) as jagged arrays require sequential traversal. */
150
+ get_calls_at(index: number): InstructionData | null;
151
+ /** Returns a generator over the jagged array elements.
152
+ * This is more efficient than repeated calls to `get_calls_at()` for sequential access. */
153
+ callsIter(): Generator<InstructionData, void, unknown>;
154
+ get_calls(): InstructionData[];
155
+ set_calls(_value: InstructionData[]): void;
156
+ /** Returns the total byte size of all elements in the jagged array. */
157
+ get_calls_size(): number;
158
+ get calls(): InstructionData[];
159
+ set calls(value: InstructionData[]);
160
+ private static __tnFootprintInternal;
161
+ private static __tnValidateInternal;
162
+ static __tnInvokeFootprint(__tnParams: Record<string, bigint>): bigint;
163
+ static __tnInvokeValidate(buffer: Uint8Array, __tnParams: Record<string, bigint>): __TnValidateResult;
164
+ static footprintIr(calls_calls_count: number | bigint): bigint;
165
+ private static __tnPackParams;
166
+ static footprintIrFromParams(params: MulticallArgs.Params): bigint;
167
+ static footprintFromParams(params: MulticallArgs.Params): number;
168
+ static footprintFromValues(input: {
169
+ calls_calls_count: number | bigint;
170
+ }): number;
171
+ static footprint(params: MulticallArgs.Params): number;
172
+ static validate(buffer: Uint8Array, opts?: {
173
+ params?: MulticallArgs.Params;
174
+ }): {
175
+ ok: boolean;
176
+ code?: string;
177
+ consumed?: number;
178
+ params?: MulticallArgs.Params;
179
+ };
180
+ static from_array(buffer: Uint8Array, opts?: {
181
+ params?: MulticallArgs.Params;
182
+ }): MulticallArgs | null;
183
+ }
184
+ declare namespace MulticallArgs {
185
+ type Params = {
186
+ /** ABI path: calls.calls_count */
187
+ readonly calls_calls_count: bigint;
188
+ };
189
+ const ParamKeys: Readonly<{
190
+ readonly calls_calls_count: "calls.calls_count";
191
+ }>;
192
+ const Params: {
193
+ fromValues(input: {
194
+ calls_calls_count: number | bigint;
195
+ }): Params;
196
+ fromBuilder(source: {
197
+ dynamicParams(): Params;
198
+ } | {
199
+ params: Params;
200
+ } | Params): Params;
201
+ };
202
+ function params(input: {
203
+ calls_calls_count: number | bigint;
204
+ }): Params;
205
+ }
206
+ declare class MulticallError {
207
+ private buffer;
208
+ private view;
209
+ private constructor();
210
+ static __tnCreateView(buffer: Uint8Array, opts?: {
211
+ fieldContext?: Record<string, number | bigint>;
212
+ }): MulticallError;
213
+ static builder(): MulticallErrorBuilder;
214
+ static fromBuilder(builder: MulticallErrorBuilder): MulticallError | null;
215
+ get_code(): bigint;
216
+ set_code(value: bigint): void;
217
+ get code(): bigint;
218
+ set code(value: bigint);
219
+ private static __tnFootprintInternal;
220
+ private static __tnValidateInternal;
221
+ static __tnInvokeFootprint(__tnParams: Record<string, bigint>): bigint;
222
+ static __tnInvokeValidate(buffer: Uint8Array, __tnParams: Record<string, bigint>): __TnValidateResult;
223
+ static footprintIr(): bigint;
224
+ static footprint(): number;
225
+ static validate(buffer: Uint8Array, _opts?: {
226
+ params?: never;
227
+ }): {
228
+ ok: boolean;
229
+ code?: string;
230
+ consumed?: number;
231
+ };
232
+ static new(code: bigint): MulticallError;
233
+ static from_array(buffer: Uint8Array): MulticallError | null;
234
+ }
235
+ declare class MulticallErrorBuilder {
236
+ private buffer;
237
+ private view;
238
+ constructor();
239
+ set_code(value: number): this;
240
+ build(): Uint8Array;
241
+ buildInto(target: Uint8Array, offset?: number): Uint8Array;
242
+ finish(): MulticallError;
243
+ }
244
+
245
+ type MulticallCall = {
246
+ programIdx: number;
247
+ instructionData: Uint8Array;
248
+ };
249
+ declare const MULTICALL_PROGRAM_PUBKEY: Uint8Array<ArrayBuffer>;
250
+ declare const MULTICALL_PROGRAM_ADDRESS: string;
251
+ declare function buildMulticallInstruction(calls: MulticallCall[]): Uint8Array;
252
+
253
+ export { InstructionData, InstructionDataBuilder, MULTICALL_PROGRAM_ADDRESS, MULTICALL_PROGRAM_PUBKEY, MulticallArgs, type MulticallCall, MulticallError, buildMulticallInstruction };
@@ -0,0 +1,253 @@
1
+ type __TnValidateResult$1 = {
2
+ ok: boolean;
3
+ code?: string;
4
+ consumed?: bigint;
5
+ };
6
+ type __TnBuilderLike = {
7
+ build(): Uint8Array;
8
+ };
9
+ type __TnFamWriterResult<Parent> = {
10
+ write(payload: Uint8Array | __TnBuilderLike): {
11
+ finish(): Parent;
12
+ };
13
+ finish(): Parent;
14
+ };
15
+ declare class InstructionData {
16
+ private buffer;
17
+ private view;
18
+ private __tnFieldContext;
19
+ private __tnParams;
20
+ private constructor();
21
+ static __tnCreateView(buffer: Uint8Array, opts?: {
22
+ params?: InstructionData.Params;
23
+ fieldContext?: Record<string, number | bigint>;
24
+ }): InstructionData;
25
+ dynamicParams(): InstructionData.Params;
26
+ withFieldContext(context: Record<string, number | bigint>): this;
27
+ private __tnResolveFieldRef;
28
+ static builder(): InstructionDataBuilder;
29
+ static fromBuilder(builder: InstructionDataBuilder): InstructionData | null;
30
+ static readonly flexibleArrayWriters: readonly [{
31
+ readonly field: "data";
32
+ readonly method: "data";
33
+ readonly sizeField: "data_size";
34
+ readonly paramKey: "data_size";
35
+ readonly elementSize: 1;
36
+ }];
37
+ private static __tnExtractParams;
38
+ get_program_idx(): number;
39
+ set_program_idx(value: number): void;
40
+ get program_idx(): number;
41
+ set program_idx(value: number);
42
+ get_data_size(): bigint;
43
+ set_data_size(value: bigint): void;
44
+ get data_size(): bigint;
45
+ set data_size(value: bigint);
46
+ get_data_length(): number;
47
+ get_data_at(index: number): number;
48
+ get_data(): number[];
49
+ set_data_at(index: number, value: number): void;
50
+ set_data(value: number[]): void;
51
+ get data(): number[];
52
+ set data(value: number[]);
53
+ private static __tnFootprintInternal;
54
+ private static __tnValidateInternal;
55
+ static __tnInvokeFootprint(__tnParams: Record<string, bigint>): bigint;
56
+ static __tnInvokeValidate(buffer: Uint8Array, __tnParams: Record<string, bigint>): __TnValidateResult$1;
57
+ static footprintIr(data_data_size: number | bigint): bigint;
58
+ private static __tnPackParams;
59
+ static footprintIrFromParams(params: InstructionData.Params): bigint;
60
+ static footprintFromParams(params: InstructionData.Params): number;
61
+ static footprintFromValues(input: {
62
+ data_data_size: number | bigint;
63
+ }): number;
64
+ static footprint(params: InstructionData.Params): number;
65
+ static validate(buffer: Uint8Array, opts?: {
66
+ params?: InstructionData.Params;
67
+ }): {
68
+ ok: boolean;
69
+ code?: string;
70
+ consumed?: number;
71
+ params?: InstructionData.Params;
72
+ };
73
+ static from_array(buffer: Uint8Array, opts?: {
74
+ params?: InstructionData.Params;
75
+ }): InstructionData | null;
76
+ }
77
+ declare namespace InstructionData {
78
+ type Params = {
79
+ /** ABI path: data.data_size */
80
+ readonly data_data_size: bigint;
81
+ };
82
+ const ParamKeys: Readonly<{
83
+ readonly data_data_size: "data.data_size";
84
+ }>;
85
+ const Params: {
86
+ fromValues(input: {
87
+ data_data_size: number | bigint;
88
+ }): Params;
89
+ fromBuilder(source: {
90
+ dynamicParams(): Params;
91
+ } | {
92
+ params: Params;
93
+ } | Params): Params;
94
+ };
95
+ function params(input: {
96
+ data_data_size: number | bigint;
97
+ }): Params;
98
+ }
99
+ declare class InstructionDataBuilder {
100
+ private buffer;
101
+ private view;
102
+ private __tnCachedParams;
103
+ private __tnLastBuffer;
104
+ private __tnLastParams;
105
+ private __tnFam_data;
106
+ private __tnFam_dataCount;
107
+ private __tnFamWriter_data?;
108
+ constructor();
109
+ private __tnInvalidate;
110
+ set_program_idx(value: number): this;
111
+ set_data_size(value: number): this;
112
+ data(): __TnFamWriterResult<InstructionDataBuilder>;
113
+ build(): Uint8Array;
114
+ buildInto(target: Uint8Array, offset?: number): Uint8Array;
115
+ finish(): InstructionData;
116
+ finishView(): InstructionData;
117
+ dynamicParams(): InstructionData.Params;
118
+ private __tnComputeParams;
119
+ private __tnWriteInto;
120
+ private __tnValidateOrThrow;
121
+ }
122
+
123
+ type __TnValidateResult = {
124
+ ok: boolean;
125
+ code?: string;
126
+ consumed?: bigint;
127
+ };
128
+ declare class MulticallArgs {
129
+ private buffer;
130
+ private view;
131
+ private __tnFieldContext;
132
+ private __tnParams;
133
+ private constructor();
134
+ static __tnCreateView(buffer: Uint8Array, opts?: {
135
+ params?: MulticallArgs.Params;
136
+ fieldContext?: Record<string, number | bigint>;
137
+ }): MulticallArgs;
138
+ dynamicParams(): MulticallArgs.Params;
139
+ withFieldContext(context: Record<string, number | bigint>): this;
140
+ private __tnResolveFieldRef;
141
+ private static __tnExtractParams;
142
+ get_calls_count(): number;
143
+ set_calls_count(value: number): void;
144
+ get calls_count(): number;
145
+ set calls_count(value: number);
146
+ /** Returns the number of elements in the jagged array. */
147
+ get_calls_length(): number;
148
+ /** Returns the element at the given index, or null if out of bounds.
149
+ * Note: This is O(n) as jagged arrays require sequential traversal. */
150
+ get_calls_at(index: number): InstructionData | null;
151
+ /** Returns a generator over the jagged array elements.
152
+ * This is more efficient than repeated calls to `get_calls_at()` for sequential access. */
153
+ callsIter(): Generator<InstructionData, void, unknown>;
154
+ get_calls(): InstructionData[];
155
+ set_calls(_value: InstructionData[]): void;
156
+ /** Returns the total byte size of all elements in the jagged array. */
157
+ get_calls_size(): number;
158
+ get calls(): InstructionData[];
159
+ set calls(value: InstructionData[]);
160
+ private static __tnFootprintInternal;
161
+ private static __tnValidateInternal;
162
+ static __tnInvokeFootprint(__tnParams: Record<string, bigint>): bigint;
163
+ static __tnInvokeValidate(buffer: Uint8Array, __tnParams: Record<string, bigint>): __TnValidateResult;
164
+ static footprintIr(calls_calls_count: number | bigint): bigint;
165
+ private static __tnPackParams;
166
+ static footprintIrFromParams(params: MulticallArgs.Params): bigint;
167
+ static footprintFromParams(params: MulticallArgs.Params): number;
168
+ static footprintFromValues(input: {
169
+ calls_calls_count: number | bigint;
170
+ }): number;
171
+ static footprint(params: MulticallArgs.Params): number;
172
+ static validate(buffer: Uint8Array, opts?: {
173
+ params?: MulticallArgs.Params;
174
+ }): {
175
+ ok: boolean;
176
+ code?: string;
177
+ consumed?: number;
178
+ params?: MulticallArgs.Params;
179
+ };
180
+ static from_array(buffer: Uint8Array, opts?: {
181
+ params?: MulticallArgs.Params;
182
+ }): MulticallArgs | null;
183
+ }
184
+ declare namespace MulticallArgs {
185
+ type Params = {
186
+ /** ABI path: calls.calls_count */
187
+ readonly calls_calls_count: bigint;
188
+ };
189
+ const ParamKeys: Readonly<{
190
+ readonly calls_calls_count: "calls.calls_count";
191
+ }>;
192
+ const Params: {
193
+ fromValues(input: {
194
+ calls_calls_count: number | bigint;
195
+ }): Params;
196
+ fromBuilder(source: {
197
+ dynamicParams(): Params;
198
+ } | {
199
+ params: Params;
200
+ } | Params): Params;
201
+ };
202
+ function params(input: {
203
+ calls_calls_count: number | bigint;
204
+ }): Params;
205
+ }
206
+ declare class MulticallError {
207
+ private buffer;
208
+ private view;
209
+ private constructor();
210
+ static __tnCreateView(buffer: Uint8Array, opts?: {
211
+ fieldContext?: Record<string, number | bigint>;
212
+ }): MulticallError;
213
+ static builder(): MulticallErrorBuilder;
214
+ static fromBuilder(builder: MulticallErrorBuilder): MulticallError | null;
215
+ get_code(): bigint;
216
+ set_code(value: bigint): void;
217
+ get code(): bigint;
218
+ set code(value: bigint);
219
+ private static __tnFootprintInternal;
220
+ private static __tnValidateInternal;
221
+ static __tnInvokeFootprint(__tnParams: Record<string, bigint>): bigint;
222
+ static __tnInvokeValidate(buffer: Uint8Array, __tnParams: Record<string, bigint>): __TnValidateResult;
223
+ static footprintIr(): bigint;
224
+ static footprint(): number;
225
+ static validate(buffer: Uint8Array, _opts?: {
226
+ params?: never;
227
+ }): {
228
+ ok: boolean;
229
+ code?: string;
230
+ consumed?: number;
231
+ };
232
+ static new(code: bigint): MulticallError;
233
+ static from_array(buffer: Uint8Array): MulticallError | null;
234
+ }
235
+ declare class MulticallErrorBuilder {
236
+ private buffer;
237
+ private view;
238
+ constructor();
239
+ set_code(value: number): this;
240
+ build(): Uint8Array;
241
+ buildInto(target: Uint8Array, offset?: number): Uint8Array;
242
+ finish(): MulticallError;
243
+ }
244
+
245
+ type MulticallCall = {
246
+ programIdx: number;
247
+ instructionData: Uint8Array;
248
+ };
249
+ declare const MULTICALL_PROGRAM_PUBKEY: Uint8Array<ArrayBuffer>;
250
+ declare const MULTICALL_PROGRAM_ADDRESS: string;
251
+ declare function buildMulticallInstruction(calls: MulticallCall[]): Uint8Array;
252
+
253
+ export { InstructionData, InstructionDataBuilder, MULTICALL_PROGRAM_ADDRESS, MULTICALL_PROGRAM_PUBKEY, MulticallArgs, type MulticallCall, MulticallError, buildMulticallInstruction };