@aztec/stdlib 3.0.0-nightly.20251112 → 3.0.0-nightly.20251114
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/dest/abi/abi.d.ts +8 -8
- package/dest/abi/abi.d.ts.map +1 -1
- package/dest/abi/abi.js +2 -2
- package/dest/abi/contract_artifact.js +3 -3
- package/dest/avm/avm.d.ts +539 -769
- package/dest/avm/avm.d.ts.map +1 -1
- package/dest/avm/avm.js +196 -2
- package/dest/avm/avm_accumulated_data.d.ts +22 -6
- package/dest/avm/avm_accumulated_data.d.ts.map +1 -1
- package/dest/avm/avm_accumulated_data.js +18 -0
- package/dest/avm/avm_circuit_public_inputs.d.ts +35 -27
- package/dest/avm/avm_circuit_public_inputs.d.ts.map +1 -1
- package/dest/avm/avm_circuit_public_inputs.js +9 -0
- package/dest/avm/avm_proving_request.d.ts +134 -290
- package/dest/avm/avm_proving_request.d.ts.map +1 -1
- package/dest/avm/public_data_write.d.ts +10 -2
- package/dest/avm/public_data_write.d.ts.map +1 -1
- package/dest/avm/public_data_write.js +9 -0
- package/dest/avm/revert_code.d.ts +8 -0
- package/dest/avm/revert_code.d.ts.map +1 -1
- package/dest/avm/revert_code.js +16 -0
- package/dest/aztec-address/index.d.ts +9 -0
- package/dest/aztec-address/index.d.ts.map +1 -1
- package/dest/aztec-address/index.js +16 -0
- package/dest/block/l2_block.d.ts +1 -1
- package/dest/block/l2_block_info.d.ts +3 -3
- package/dest/block/proposal/attestations_and_signers.d.ts +1 -1
- package/dest/block/proposal/committee_attestation.d.ts +1 -1
- package/dest/block/published_l2_block.d.ts +2 -2
- package/dest/block/validate_block_result.d.ts +12 -12
- package/dest/contract/contract_deployment_data.d.ts +10 -2
- package/dest/contract/contract_deployment_data.d.ts.map +1 -1
- package/dest/contract/contract_deployment_data.js +12 -0
- package/dest/contract/interfaces/contract_class.d.ts +19 -19
- package/dest/contract/interfaces/contract_instance.d.ts +32 -200
- package/dest/contract/interfaces/contract_instance.d.ts.map +1 -1
- package/dest/database-version/version_manager.d.ts +1 -1
- package/dest/gas/gas.d.ts +8 -0
- package/dest/gas/gas.d.ts.map +1 -1
- package/dest/gas/gas.js +12 -0
- package/dest/gas/gas_fees.d.ts +8 -0
- package/dest/gas/gas_fees.d.ts.map +1 -1
- package/dest/gas/gas_fees.js +12 -0
- package/dest/gas/gas_settings.d.ts +8 -0
- package/dest/gas/gas_settings.d.ts.map +1 -1
- package/dest/gas/gas_settings.js +12 -0
- package/dest/gas/gas_used.d.ts +12 -1
- package/dest/gas/gas_used.d.ts.map +1 -1
- package/dest/gas/gas_used.js +19 -1
- package/dest/interfaces/aztec-node-admin.d.ts +8 -5
- package/dest/interfaces/aztec-node-admin.d.ts.map +1 -1
- package/dest/interfaces/configs.d.ts +5 -0
- package/dest/interfaces/configs.d.ts.map +1 -1
- package/dest/interfaces/configs.js +1 -0
- package/dest/interfaces/proving-job.d.ts +162 -318
- package/dest/interfaces/proving-job.d.ts.map +1 -1
- package/dest/interfaces/slasher.d.ts +3 -3
- package/dest/interfaces/validator.d.ts +12 -4
- package/dest/interfaces/validator.d.ts.map +1 -1
- package/dest/interfaces/validator.js +2 -1
- package/dest/kernel/private_to_avm_accumulated_data.d.ts +20 -4
- package/dest/kernel/private_to_avm_accumulated_data.d.ts.map +1 -1
- package/dest/kernel/private_to_avm_accumulated_data.js +18 -0
- package/dest/kernel/public_call_request.d.ts +17 -1
- package/dest/kernel/public_call_request.d.ts.map +1 -1
- package/dest/kernel/public_call_request.js +18 -0
- package/dest/keys/public_keys.d.ts +20 -84
- package/dest/keys/public_keys.d.ts.map +1 -1
- package/dest/keys/public_keys.js +12 -0
- package/dest/logs/contract_class_log.d.ts +18 -2
- package/dest/logs/contract_class_log.d.ts.map +1 -1
- package/dest/logs/contract_class_log.js +24 -0
- package/dest/logs/debug_log.d.ts +9 -1
- package/dest/logs/debug_log.d.ts.map +1 -1
- package/dest/logs/debug_log.js +13 -0
- package/dest/logs/directional_app_tagging_secret.d.ts +1 -1
- package/dest/logs/pre_tag.d.ts +1 -1
- package/dest/logs/private_log.d.ts +9 -1
- package/dest/logs/private_log.d.ts.map +1 -1
- package/dest/logs/private_log.js +12 -0
- package/dest/logs/public_log.d.ts +8 -0
- package/dest/logs/public_log.d.ts.map +1 -1
- package/dest/logs/public_log.js +9 -0
- package/dest/logs/tx_scoped_l2_log.d.ts +1 -1
- package/dest/messaging/l2_to_l1_message.d.ts +24 -8
- package/dest/messaging/l2_to_l1_message.d.ts.map +1 -1
- package/dest/messaging/l2_to_l1_message.js +18 -0
- package/dest/noir/index.d.ts +1 -1
- package/dest/noir/index.d.ts.map +1 -1
- package/dest/noir/index.js +1 -2
- package/dest/p2p/consensus_payload.d.ts +5 -5
- package/dest/snapshots/types.d.ts +2 -2
- package/dest/trees/append_only_tree_snapshot.d.ts +9 -1
- package/dest/trees/append_only_tree_snapshot.d.ts.map +1 -1
- package/dest/trees/append_only_tree_snapshot.js +9 -0
- package/dest/trees/nullifier_leaf.d.ts +20 -4
- package/dest/trees/nullifier_leaf.d.ts.map +1 -1
- package/dest/trees/nullifier_leaf.js +24 -0
- package/dest/trees/nullifier_membership_witness.d.ts +2 -2
- package/dest/trees/public_data_leaf.d.ts +23 -7
- package/dest/trees/public_data_leaf.d.ts.map +1 -1
- package/dest/trees/public_data_leaf.js +24 -0
- package/dest/trees/public_data_witness.d.ts +3 -3
- package/dest/tx/content_commitment.d.ts +3 -3
- package/dest/tx/execution_payload.d.ts +45 -0
- package/dest/tx/execution_payload.d.ts.map +1 -0
- package/dest/tx/execution_payload.js +40 -0
- package/dest/tx/global_variables.d.ts +8 -0
- package/dest/tx/global_variables.d.ts.map +1 -1
- package/dest/tx/global_variables.js +9 -0
- package/dest/tx/index.d.ts +1 -0
- package/dest/tx/index.d.ts.map +1 -1
- package/dest/tx/index.js +1 -0
- package/dest/tx/partial_state_reference.d.ts +3 -3
- package/dest/tx/profiling.d.ts +3 -3
- package/dest/tx/profiling.d.ts.map +1 -1
- package/dest/tx/profiling.js +5 -4
- package/dest/tx/protocol_contracts.d.ts +8 -0
- package/dest/tx/protocol_contracts.d.ts.map +1 -1
- package/dest/tx/protocol_contracts.js +9 -0
- package/dest/tx/public_call_request_with_calldata.d.ts +8 -0
- package/dest/tx/public_call_request_with_calldata.d.ts.map +1 -1
- package/dest/tx/public_call_request_with_calldata.js +12 -0
- package/dest/tx/simulated_tx.d.ts +28 -148
- package/dest/tx/simulated_tx.d.ts.map +1 -1
- package/dest/tx/state_reference.d.ts +4 -4
- package/dest/tx/tree_snapshots.d.ts +12 -4
- package/dest/tx/tree_snapshots.d.ts.map +1 -1
- package/dest/tx/tree_snapshots.js +9 -0
- package/dest/tx/tx_context.d.ts +2 -2
- package/dest/validators/schemas.d.ts +3 -3
- package/package.json +8 -8
- package/src/abi/abi.ts +4 -4
- package/src/abi/contract_artifact.ts +3 -3
- package/src/avm/avm.ts +350 -3
- package/src/avm/avm_accumulated_data.ts +40 -0
- package/src/avm/avm_circuit_public_inputs.ts +40 -0
- package/src/avm/public_data_write.ts +11 -0
- package/src/avm/revert_code.ts +18 -0
- package/src/aztec-address/index.ts +18 -0
- package/src/contract/contract_deployment_data.ts +17 -0
- package/src/gas/gas.ts +14 -0
- package/src/gas/gas_fees.ts +14 -0
- package/src/gas/gas_settings.ts +19 -0
- package/src/gas/gas_used.ts +22 -1
- package/src/interfaces/configs.ts +3 -0
- package/src/interfaces/validator.ts +4 -0
- package/src/kernel/private_to_avm_accumulated_data.ts +35 -0
- package/src/kernel/public_call_request.ts +27 -0
- package/src/keys/public_keys.ts +19 -0
- package/src/logs/contract_class_log.ts +32 -0
- package/src/logs/debug_log.ts +20 -1
- package/src/logs/private_log.ts +17 -0
- package/src/logs/public_log.ts +14 -0
- package/src/messaging/l2_to_l1_message.ts +25 -0
- package/src/noir/index.ts +1 -2
- package/src/trees/append_only_tree_snapshot.ts +11 -0
- package/src/trees/nullifier_leaf.ts +32 -0
- package/src/trees/public_data_leaf.ts +32 -0
- package/src/tx/execution_payload.ts +60 -0
- package/src/tx/global_variables.ts +20 -0
- package/src/tx/index.ts +1 -0
- package/src/tx/profiling.ts +4 -6
- package/src/tx/protocol_contracts.ts +16 -0
- package/src/tx/public_call_request_with_calldata.ts +17 -0
- package/src/tx/tree_snapshots.ts +16 -0
package/src/avm/avm.ts
CHANGED
|
@@ -10,15 +10,15 @@ import { computeEffectiveGasFees } from '../fees/transaction_fee.js';
|
|
|
10
10
|
import { Gas } from '../gas/gas.js';
|
|
11
11
|
import { GasFees } from '../gas/gas_fees.js';
|
|
12
12
|
import { GasSettings } from '../gas/gas_settings.js';
|
|
13
|
-
import
|
|
13
|
+
import { GasUsed } from '../gas/gas_used.js';
|
|
14
14
|
import { PublicKeys } from '../keys/public_keys.js';
|
|
15
15
|
import { DebugLog } from '../logs/debug_log.js';
|
|
16
16
|
import { ScopedL2ToL1Message } from '../messaging/l2_to_l1_message.js';
|
|
17
17
|
import { NullishToUndefined, type ZodFor, schemas } from '../schemas/schemas.js';
|
|
18
18
|
import { AppendOnlyTreeSnapshot } from '../trees/append_only_tree_snapshot.js';
|
|
19
19
|
import { MerkleTreeId } from '../trees/merkle_tree_id.js';
|
|
20
|
-
import { NullifierLeafPreimage } from '../trees/nullifier_leaf.js';
|
|
21
|
-
import { PublicDataTreeLeafPreimage } from '../trees/public_data_leaf.js';
|
|
20
|
+
import { NullifierLeaf, NullifierLeafPreimage } from '../trees/nullifier_leaf.js';
|
|
21
|
+
import { PublicDataTreeLeaf, PublicDataTreeLeafPreimage } from '../trees/public_data_leaf.js';
|
|
22
22
|
import {
|
|
23
23
|
GlobalVariables,
|
|
24
24
|
NestedProcessReturnValues,
|
|
@@ -59,6 +59,26 @@ export class AvmContractClassHint {
|
|
|
59
59
|
new AvmContractClassHint(hintKey, classId, artifactHash, privateFunctionsRoot, packedBytecode),
|
|
60
60
|
);
|
|
61
61
|
}
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* Creates an AvmContractClassHint from a plain object without Zod validation.
|
|
65
|
+
* This method is optimized for performance and skips validation, making it suitable
|
|
66
|
+
* for deserializing trusted data (e.g., from C++ via MessagePack).
|
|
67
|
+
* @param obj - Plain object containing AvmContractClassHint fields
|
|
68
|
+
* @returns An AvmContractClassHint instance
|
|
69
|
+
*/
|
|
70
|
+
static fromPlainObject(obj: any): AvmContractClassHint {
|
|
71
|
+
if (obj instanceof AvmContractClassHint) {
|
|
72
|
+
return obj;
|
|
73
|
+
}
|
|
74
|
+
return new AvmContractClassHint(
|
|
75
|
+
obj.hintKey,
|
|
76
|
+
Fr.fromPlainObject(obj.classId),
|
|
77
|
+
Fr.fromPlainObject(obj.artifactHash),
|
|
78
|
+
Fr.fromPlainObject(obj.privateFunctionsRoot),
|
|
79
|
+
obj.packedBytecode instanceof Buffer ? obj.packedBytecode : Buffer.from(obj.packedBytecode),
|
|
80
|
+
);
|
|
81
|
+
}
|
|
62
82
|
}
|
|
63
83
|
|
|
64
84
|
export class AvmBytecodeCommitmentHint {
|
|
@@ -77,6 +97,24 @@ export class AvmBytecodeCommitmentHint {
|
|
|
77
97
|
})
|
|
78
98
|
.transform(({ hintKey, classId, commitment }) => new AvmBytecodeCommitmentHint(hintKey, classId, commitment));
|
|
79
99
|
}
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* Creates an AvmBytecodeCommitmentHint from a plain object without Zod validation.
|
|
103
|
+
* This method is optimized for performance and skips validation, making it suitable
|
|
104
|
+
* for deserializing trusted data (e.g., from C++ via MessagePack).
|
|
105
|
+
* @param obj - Plain object containing AvmBytecodeCommitmentHint fields
|
|
106
|
+
* @returns An AvmBytecodeCommitmentHint instance
|
|
107
|
+
*/
|
|
108
|
+
static fromPlainObject(obj: any): AvmBytecodeCommitmentHint {
|
|
109
|
+
if (obj instanceof AvmBytecodeCommitmentHint) {
|
|
110
|
+
return obj;
|
|
111
|
+
}
|
|
112
|
+
return new AvmBytecodeCommitmentHint(
|
|
113
|
+
obj.hintKey,
|
|
114
|
+
Fr.fromPlainObject(obj.classId),
|
|
115
|
+
Fr.fromPlainObject(obj.commitment),
|
|
116
|
+
);
|
|
117
|
+
}
|
|
80
118
|
}
|
|
81
119
|
|
|
82
120
|
export class AvmContractInstanceHint {
|
|
@@ -126,6 +164,29 @@ export class AvmContractInstanceHint {
|
|
|
126
164
|
),
|
|
127
165
|
);
|
|
128
166
|
}
|
|
167
|
+
|
|
168
|
+
/**
|
|
169
|
+
* Creates an AvmContractInstanceHint from a plain object without Zod validation.
|
|
170
|
+
* This method is optimized for performance and skips validation, making it suitable
|
|
171
|
+
* for deserializing trusted data (e.g., from C++ via MessagePack).
|
|
172
|
+
* @param obj - Plain object containing AvmContractInstanceHint fields
|
|
173
|
+
* @returns An AvmContractInstanceHint instance
|
|
174
|
+
*/
|
|
175
|
+
static fromPlainObject(obj: any): AvmContractInstanceHint {
|
|
176
|
+
if (obj instanceof AvmContractInstanceHint) {
|
|
177
|
+
return obj;
|
|
178
|
+
}
|
|
179
|
+
return new AvmContractInstanceHint(
|
|
180
|
+
obj.hintKey,
|
|
181
|
+
AztecAddress.fromPlainObject(obj.address),
|
|
182
|
+
Fr.fromPlainObject(obj.salt),
|
|
183
|
+
AztecAddress.fromPlainObject(obj.deployer),
|
|
184
|
+
Fr.fromPlainObject(obj.currentContractClassId),
|
|
185
|
+
Fr.fromPlainObject(obj.originalContractClassId),
|
|
186
|
+
Fr.fromPlainObject(obj.initializationHash),
|
|
187
|
+
PublicKeys.fromPlainObject(obj.publicKeys),
|
|
188
|
+
);
|
|
189
|
+
}
|
|
129
190
|
}
|
|
130
191
|
|
|
131
192
|
export class AvmDebugFunctionNameHint {
|
|
@@ -144,6 +205,24 @@ export class AvmDebugFunctionNameHint {
|
|
|
144
205
|
})
|
|
145
206
|
.transform(({ address, selector, name }) => new AvmDebugFunctionNameHint(address, selector, name));
|
|
146
207
|
}
|
|
208
|
+
|
|
209
|
+
/**
|
|
210
|
+
* Creates an AvmDebugFunctionNameHint from a plain object without Zod validation.
|
|
211
|
+
* This method is optimized for performance and skips validation, making it suitable
|
|
212
|
+
* for deserializing trusted data (e.g., from C++ via MessagePack).
|
|
213
|
+
* @param obj - Plain object containing AvmDebugFunctionNameHint fields
|
|
214
|
+
* @returns An AvmDebugFunctionNameHint instance
|
|
215
|
+
*/
|
|
216
|
+
static fromPlainObject(obj: any): AvmDebugFunctionNameHint {
|
|
217
|
+
if (obj instanceof AvmDebugFunctionNameHint) {
|
|
218
|
+
return obj;
|
|
219
|
+
}
|
|
220
|
+
return new AvmDebugFunctionNameHint(
|
|
221
|
+
AztecAddress.fromPlainObject(obj.address),
|
|
222
|
+
Fr.fromPlainObject(obj.selector),
|
|
223
|
+
obj.name,
|
|
224
|
+
);
|
|
225
|
+
}
|
|
147
226
|
}
|
|
148
227
|
|
|
149
228
|
////////////////////////////////////////////////////////////////////////////
|
|
@@ -170,6 +249,25 @@ export class AvmGetSiblingPathHint {
|
|
|
170
249
|
})
|
|
171
250
|
.transform(({ hintKey, treeId, index, path }) => new AvmGetSiblingPathHint(hintKey, treeId, index, path));
|
|
172
251
|
}
|
|
252
|
+
|
|
253
|
+
/**
|
|
254
|
+
* Creates an AvmGetSiblingPathHint from a plain object without Zod validation.
|
|
255
|
+
* This method is optimized for performance and skips validation, making it suitable
|
|
256
|
+
* for deserializing trusted data (e.g., from C++ via MessagePack).
|
|
257
|
+
* @param obj - Plain object containing AvmGetSiblingPathHint fields
|
|
258
|
+
* @returns An AvmGetSiblingPathHint instance
|
|
259
|
+
*/
|
|
260
|
+
static fromPlainObject(obj: any): AvmGetSiblingPathHint {
|
|
261
|
+
if (obj instanceof AvmGetSiblingPathHint) {
|
|
262
|
+
return obj;
|
|
263
|
+
}
|
|
264
|
+
return new AvmGetSiblingPathHint(
|
|
265
|
+
AppendOnlyTreeSnapshot.fromPlainObject(obj.hintKey),
|
|
266
|
+
obj.treeId,
|
|
267
|
+
typeof obj.index === 'bigint' ? obj.index : BigInt(obj.index),
|
|
268
|
+
obj.path.map((p: any) => Fr.fromPlainObject(p)),
|
|
269
|
+
);
|
|
270
|
+
}
|
|
173
271
|
}
|
|
174
272
|
|
|
175
273
|
// Hint for MerkleTreeDB.getPreviousValueIndex.
|
|
@@ -198,6 +296,26 @@ export class AvmGetPreviousValueIndexHint {
|
|
|
198
296
|
new AvmGetPreviousValueIndexHint(hintKey, treeId, value, index, alreadyPresent),
|
|
199
297
|
);
|
|
200
298
|
}
|
|
299
|
+
|
|
300
|
+
/**
|
|
301
|
+
* Creates an AvmGetPreviousValueIndexHint from a plain object without Zod validation.
|
|
302
|
+
* This method is optimized for performance and skips validation, making it suitable
|
|
303
|
+
* for deserializing trusted data (e.g., from C++ via MessagePack).
|
|
304
|
+
* @param obj - Plain object containing AvmGetPreviousValueIndexHint fields
|
|
305
|
+
* @returns An AvmGetPreviousValueIndexHint instance
|
|
306
|
+
*/
|
|
307
|
+
static fromPlainObject(obj: any): AvmGetPreviousValueIndexHint {
|
|
308
|
+
if (obj instanceof AvmGetPreviousValueIndexHint) {
|
|
309
|
+
return obj;
|
|
310
|
+
}
|
|
311
|
+
return new AvmGetPreviousValueIndexHint(
|
|
312
|
+
AppendOnlyTreeSnapshot.fromPlainObject(obj.hintKey),
|
|
313
|
+
obj.treeId,
|
|
314
|
+
Fr.fromPlainObject(obj.value),
|
|
315
|
+
typeof obj.index === 'bigint' ? obj.index : BigInt(obj.index),
|
|
316
|
+
obj.alreadyPresent,
|
|
317
|
+
);
|
|
318
|
+
}
|
|
201
319
|
}
|
|
202
320
|
|
|
203
321
|
type IndexedTreeLeafPreimages = NullifierLeafPreimage | PublicDataTreeLeafPreimage;
|
|
@@ -225,6 +343,24 @@ function AvmGetLeafPreimageHintFactory(klass: IndexedTreeLeafPreimagesClasses) {
|
|
|
225
343
|
})
|
|
226
344
|
.transform(({ hintKey, index, leafPreimage }) => new this(hintKey, index, leafPreimage));
|
|
227
345
|
}
|
|
346
|
+
|
|
347
|
+
/**
|
|
348
|
+
* Creates an instance from a plain object without Zod validation.
|
|
349
|
+
* This method is optimized for performance and skips validation, making it suitable
|
|
350
|
+
* for deserializing trusted data (e.g., from C++ via MessagePack).
|
|
351
|
+
* @param obj - Plain object containing hint fields
|
|
352
|
+
* @returns An instance
|
|
353
|
+
*/
|
|
354
|
+
static fromPlainObject(obj: any): any {
|
|
355
|
+
if (obj instanceof this) {
|
|
356
|
+
return obj;
|
|
357
|
+
}
|
|
358
|
+
return new this(
|
|
359
|
+
AppendOnlyTreeSnapshot.fromPlainObject(obj.hintKey),
|
|
360
|
+
typeof obj.index === 'bigint' ? obj.index : BigInt(obj.index),
|
|
361
|
+
klass.fromPlainObject(obj.leafPreimage),
|
|
362
|
+
);
|
|
363
|
+
}
|
|
228
364
|
};
|
|
229
365
|
}
|
|
230
366
|
|
|
@@ -254,6 +390,25 @@ export class AvmGetLeafValueHint {
|
|
|
254
390
|
})
|
|
255
391
|
.transform(({ hintKey, treeId, index, value }) => new AvmGetLeafValueHint(hintKey, treeId, index, value));
|
|
256
392
|
}
|
|
393
|
+
|
|
394
|
+
/**
|
|
395
|
+
* Creates an AvmGetLeafValueHint from a plain object without Zod validation.
|
|
396
|
+
* This method is optimized for performance and skips validation, making it suitable
|
|
397
|
+
* for deserializing trusted data (e.g., from C++ via MessagePack).
|
|
398
|
+
* @param obj - Plain object containing AvmGetLeafValueHint fields
|
|
399
|
+
* @returns An AvmGetLeafValueHint instance
|
|
400
|
+
*/
|
|
401
|
+
static fromPlainObject(obj: any): AvmGetLeafValueHint {
|
|
402
|
+
if (obj instanceof AvmGetLeafValueHint) {
|
|
403
|
+
return obj;
|
|
404
|
+
}
|
|
405
|
+
return new AvmGetLeafValueHint(
|
|
406
|
+
AppendOnlyTreeSnapshot.fromPlainObject(obj.hintKey),
|
|
407
|
+
obj.treeId,
|
|
408
|
+
typeof obj.index === 'bigint' ? obj.index : BigInt(obj.index),
|
|
409
|
+
Fr.fromPlainObject(obj.value),
|
|
410
|
+
);
|
|
411
|
+
}
|
|
257
412
|
}
|
|
258
413
|
|
|
259
414
|
// Hint for MerkleTreeDB.sequentialInsert.
|
|
@@ -303,6 +458,43 @@ function AvmSequentialInsertHintFactory(klass: IndexedTreeLeafPreimagesClasses)
|
|
|
303
458
|
new this(hintKey, stateAfter, treeId, leaf, lowLeavesWitnessData, insertionWitnessData),
|
|
304
459
|
);
|
|
305
460
|
}
|
|
461
|
+
|
|
462
|
+
/**
|
|
463
|
+
* Creates an instance from a plain object without Zod validation.
|
|
464
|
+
* This method is optimized for performance and skips validation, making it suitable
|
|
465
|
+
* for deserializing trusted data (e.g., from C++ via MessagePack).
|
|
466
|
+
* @param obj - Plain object containing hint fields
|
|
467
|
+
* @returns An instance
|
|
468
|
+
*/
|
|
469
|
+
static fromPlainObject(obj: any): any {
|
|
470
|
+
if (obj instanceof this) {
|
|
471
|
+
return obj;
|
|
472
|
+
}
|
|
473
|
+
// Determine the leaf class based on the klass parameter
|
|
474
|
+
const LeafClass = klass === PublicDataTreeLeafPreimage ? PublicDataTreeLeaf : NullifierLeaf;
|
|
475
|
+
return new this(
|
|
476
|
+
AppendOnlyTreeSnapshot.fromPlainObject(obj.hintKey),
|
|
477
|
+
AppendOnlyTreeSnapshot.fromPlainObject(obj.stateAfter),
|
|
478
|
+
obj.treeId,
|
|
479
|
+
LeafClass.fromPlainObject(obj.leaf),
|
|
480
|
+
{
|
|
481
|
+
leaf: klass.fromPlainObject(obj.lowLeavesWitnessData.leaf),
|
|
482
|
+
index:
|
|
483
|
+
typeof obj.lowLeavesWitnessData.index === 'bigint'
|
|
484
|
+
? obj.lowLeavesWitnessData.index
|
|
485
|
+
: BigInt(obj.lowLeavesWitnessData.index),
|
|
486
|
+
path: obj.lowLeavesWitnessData.path.map((p: any) => Fr.fromPlainObject(p)),
|
|
487
|
+
},
|
|
488
|
+
{
|
|
489
|
+
leaf: klass.fromPlainObject(obj.insertionWitnessData.leaf),
|
|
490
|
+
index:
|
|
491
|
+
typeof obj.insertionWitnessData.index === 'bigint'
|
|
492
|
+
? obj.insertionWitnessData.index
|
|
493
|
+
: BigInt(obj.insertionWitnessData.index),
|
|
494
|
+
path: obj.insertionWitnessData.path.map((p: any) => Fr.fromPlainObject(p)),
|
|
495
|
+
},
|
|
496
|
+
);
|
|
497
|
+
}
|
|
306
498
|
};
|
|
307
499
|
}
|
|
308
500
|
|
|
@@ -333,6 +525,25 @@ export class AvmAppendLeavesHint {
|
|
|
333
525
|
({ hintKey, stateAfter, treeId, leaves }) => new AvmAppendLeavesHint(hintKey, stateAfter, treeId, leaves),
|
|
334
526
|
);
|
|
335
527
|
}
|
|
528
|
+
|
|
529
|
+
/**
|
|
530
|
+
* Creates an AvmAppendLeavesHint from a plain object without Zod validation.
|
|
531
|
+
* This method is optimized for performance and skips validation, making it suitable
|
|
532
|
+
* for deserializing trusted data (e.g., from C++ via MessagePack).
|
|
533
|
+
* @param obj - Plain object containing AvmAppendLeavesHint fields
|
|
534
|
+
* @returns An AvmAppendLeavesHint instance
|
|
535
|
+
*/
|
|
536
|
+
static fromPlainObject(obj: any): AvmAppendLeavesHint {
|
|
537
|
+
if (obj instanceof AvmAppendLeavesHint) {
|
|
538
|
+
return obj;
|
|
539
|
+
}
|
|
540
|
+
return new AvmAppendLeavesHint(
|
|
541
|
+
AppendOnlyTreeSnapshot.fromPlainObject(obj.hintKey),
|
|
542
|
+
AppendOnlyTreeSnapshot.fromPlainObject(obj.stateAfter),
|
|
543
|
+
obj.treeId,
|
|
544
|
+
obj.leaves.map((l: any) => Fr.fromPlainObject(l)),
|
|
545
|
+
);
|
|
546
|
+
}
|
|
336
547
|
}
|
|
337
548
|
|
|
338
549
|
// Hint for checkpoint actions that don't change the state.
|
|
@@ -357,6 +568,20 @@ class AvmCheckpointActionNoStateChangeHint {
|
|
|
357
568
|
new this(actionCounter, oldCheckpointId, newCheckpointId),
|
|
358
569
|
);
|
|
359
570
|
}
|
|
571
|
+
|
|
572
|
+
/**
|
|
573
|
+
* Creates an instance from a plain object without Zod validation.
|
|
574
|
+
* This method is optimized for performance and skips validation, making it suitable
|
|
575
|
+
* for deserializing trusted data (e.g., from C++ via MessagePack).
|
|
576
|
+
* @param obj - Plain object containing hint fields
|
|
577
|
+
* @returns An instance
|
|
578
|
+
*/
|
|
579
|
+
static fromPlainObject(obj: any): any {
|
|
580
|
+
if (obj instanceof this) {
|
|
581
|
+
return obj;
|
|
582
|
+
}
|
|
583
|
+
return new this(obj.actionCounter, obj.oldCheckpointId, obj.newCheckpointId);
|
|
584
|
+
}
|
|
360
585
|
}
|
|
361
586
|
|
|
362
587
|
// Hint for MerkleTreeDB.createCheckpoint.
|
|
@@ -419,6 +644,26 @@ export class AvmRevertCheckpointHint {
|
|
|
419
644
|
new AvmRevertCheckpointHint(actionCounter, oldCheckpointId, newCheckpointId, stateBefore, stateAfter),
|
|
420
645
|
);
|
|
421
646
|
}
|
|
647
|
+
|
|
648
|
+
/**
|
|
649
|
+
* Creates an AvmRevertCheckpointHint from a plain object without Zod validation.
|
|
650
|
+
* This method is optimized for performance and skips validation, making it suitable
|
|
651
|
+
* for deserializing trusted data (e.g., from C++ via MessagePack).
|
|
652
|
+
* @param obj - Plain object containing AvmRevertCheckpointHint fields
|
|
653
|
+
* @returns An AvmRevertCheckpointHint instance
|
|
654
|
+
*/
|
|
655
|
+
static fromPlainObject(obj: any): AvmRevertCheckpointHint {
|
|
656
|
+
if (obj instanceof AvmRevertCheckpointHint) {
|
|
657
|
+
return obj;
|
|
658
|
+
}
|
|
659
|
+
return new AvmRevertCheckpointHint(
|
|
660
|
+
obj.actionCounter,
|
|
661
|
+
obj.oldCheckpointId,
|
|
662
|
+
obj.newCheckpointId,
|
|
663
|
+
TreeSnapshots.fromPlainObject(obj.stateBefore),
|
|
664
|
+
TreeSnapshots.fromPlainObject(obj.stateAfter),
|
|
665
|
+
);
|
|
666
|
+
}
|
|
422
667
|
}
|
|
423
668
|
|
|
424
669
|
export class AvmContractDBCreateCheckpointHint extends AvmCheckpointActionNoStateChangeHint {}
|
|
@@ -506,6 +751,45 @@ export class AvmTxHint {
|
|
|
506
751
|
);
|
|
507
752
|
}
|
|
508
753
|
|
|
754
|
+
/**
|
|
755
|
+
* Creates an AvmTxHint from a plain object without Zod validation.
|
|
756
|
+
* This method is optimized for performance and skips validation, making it suitable
|
|
757
|
+
* for deserializing trusted data (e.g., from C++ via MessagePack).
|
|
758
|
+
* @param obj - Plain object containing AvmTxHint fields
|
|
759
|
+
* @returns An AvmTxHint instance
|
|
760
|
+
*/
|
|
761
|
+
static fromPlainObject(obj: any): AvmTxHint {
|
|
762
|
+
if (obj instanceof AvmTxHint) {
|
|
763
|
+
return obj;
|
|
764
|
+
}
|
|
765
|
+
return new AvmTxHint(
|
|
766
|
+
obj.hash,
|
|
767
|
+
GasSettings.fromPlainObject(obj.gasSettings),
|
|
768
|
+
GasFees.fromPlainObject(obj.effectiveGasFees),
|
|
769
|
+
ContractDeploymentData.fromPlainObject(obj.nonRevertibleContractDeploymentData),
|
|
770
|
+
ContractDeploymentData.fromPlainObject(obj.revertibleContractDeploymentData),
|
|
771
|
+
{
|
|
772
|
+
noteHashes: obj.nonRevertibleAccumulatedData.noteHashes.map((h: any) => Fr.fromPlainObject(h)),
|
|
773
|
+
nullifiers: obj.nonRevertibleAccumulatedData.nullifiers.map((n: any) => Fr.fromPlainObject(n)),
|
|
774
|
+
l2ToL1Messages: obj.nonRevertibleAccumulatedData.l2ToL1Messages.map((m: any) =>
|
|
775
|
+
ScopedL2ToL1Message.fromPlainObject(m),
|
|
776
|
+
),
|
|
777
|
+
},
|
|
778
|
+
{
|
|
779
|
+
noteHashes: obj.revertibleAccumulatedData.noteHashes.map((h: any) => Fr.fromPlainObject(h)),
|
|
780
|
+
nullifiers: obj.revertibleAccumulatedData.nullifiers.map((n: any) => Fr.fromPlainObject(n)),
|
|
781
|
+
l2ToL1Messages: obj.revertibleAccumulatedData.l2ToL1Messages.map((m: any) =>
|
|
782
|
+
ScopedL2ToL1Message.fromPlainObject(m),
|
|
783
|
+
),
|
|
784
|
+
},
|
|
785
|
+
obj.setupEnqueuedCalls.map((c: any) => PublicCallRequestWithCalldata.fromPlainObject(c)),
|
|
786
|
+
obj.appLogicEnqueuedCalls.map((c: any) => PublicCallRequestWithCalldata.fromPlainObject(c)),
|
|
787
|
+
obj.teardownEnqueuedCall ? PublicCallRequestWithCalldata.fromPlainObject(obj.teardownEnqueuedCall) : null,
|
|
788
|
+
Gas.fromPlainObject(obj.gasUsedByPrivate),
|
|
789
|
+
AztecAddress.fromPlainObject(obj.feePayer),
|
|
790
|
+
);
|
|
791
|
+
}
|
|
792
|
+
|
|
509
793
|
static get schema() {
|
|
510
794
|
return z
|
|
511
795
|
.object({
|
|
@@ -592,6 +876,50 @@ export class AvmExecutionHints {
|
|
|
592
876
|
public readonly revertCheckpointHints: AvmRevertCheckpointHint[] = [],
|
|
593
877
|
) {}
|
|
594
878
|
|
|
879
|
+
/**
|
|
880
|
+
* Creates an AvmExecutionHints from a plain object without Zod validation.
|
|
881
|
+
* This method is optimized for performance and skips validation, making it suitable
|
|
882
|
+
* for deserializing trusted data (e.g., from C++ via MessagePack).
|
|
883
|
+
* @param obj - Plain object containing AvmExecutionHints fields
|
|
884
|
+
* @returns An AvmExecutionHints instance
|
|
885
|
+
*/
|
|
886
|
+
static fromPlainObject(obj: any): AvmExecutionHints {
|
|
887
|
+
if (obj instanceof AvmExecutionHints) {
|
|
888
|
+
return obj;
|
|
889
|
+
}
|
|
890
|
+
return new AvmExecutionHints(
|
|
891
|
+
GlobalVariables.fromPlainObject(obj.globalVariables),
|
|
892
|
+
AvmTxHint.fromPlainObject(obj.tx),
|
|
893
|
+
ProtocolContracts.fromPlainObject(obj.protocolContracts),
|
|
894
|
+
obj.contractInstances?.map((i: any) => AvmContractInstanceHint.fromPlainObject(i)) || [],
|
|
895
|
+
obj.contractClasses?.map((c: any) => AvmContractClassHint.fromPlainObject(c)) || [],
|
|
896
|
+
obj.bytecodeCommitments?.map((b: any) => AvmBytecodeCommitmentHint.fromPlainObject(b)) || [],
|
|
897
|
+
obj.debugFunctionNames?.map((d: any) => AvmDebugFunctionNameHint.fromPlainObject(d)) || [],
|
|
898
|
+
obj.contractDBCreateCheckpointHints?.map((h: any) => AvmContractDBCreateCheckpointHint.fromPlainObject(h)) || [],
|
|
899
|
+
obj.contractDBCommitCheckpointHints?.map((h: any) => AvmContractDBCommitCheckpointHint.fromPlainObject(h)) || [],
|
|
900
|
+
obj.contractDBRevertCheckpointHints?.map((h: any) => AvmContractDBRevertCheckpointHint.fromPlainObject(h)) || [],
|
|
901
|
+
obj.startingTreeRoots ? TreeSnapshots.fromPlainObject(obj.startingTreeRoots) : TreeSnapshots.empty(),
|
|
902
|
+
obj.getSiblingPathHints?.map((h: any) => AvmGetSiblingPathHint.fromPlainObject(h)) || [],
|
|
903
|
+
obj.getPreviousValueIndexHints?.map((h: any) => AvmGetPreviousValueIndexHint.fromPlainObject(h)) || [],
|
|
904
|
+
obj.getLeafPreimageHintsPublicDataTree?.map((h: any) =>
|
|
905
|
+
AvmGetLeafPreimageHintPublicDataTree.fromPlainObject(h),
|
|
906
|
+
) || [],
|
|
907
|
+
obj.getLeafPreimageHintsNullifierTree?.map((h: any) => AvmGetLeafPreimageHintNullifierTree.fromPlainObject(h)) ||
|
|
908
|
+
[],
|
|
909
|
+
obj.getLeafValueHints?.map((h: any) => AvmGetLeafValueHint.fromPlainObject(h)) || [],
|
|
910
|
+
obj.sequentialInsertHintsPublicDataTree?.map((h: any) =>
|
|
911
|
+
AvmSequentialInsertHintPublicDataTree.fromPlainObject(h),
|
|
912
|
+
) || [],
|
|
913
|
+
obj.sequentialInsertHintsNullifierTree?.map((h: any) =>
|
|
914
|
+
AvmSequentialInsertHintNullifierTree.fromPlainObject(h),
|
|
915
|
+
) || [],
|
|
916
|
+
obj.appendLeavesHints?.map((h: any) => AvmAppendLeavesHint.fromPlainObject(h)) || [],
|
|
917
|
+
obj.createCheckpointHints?.map((h: any) => AvmCreateCheckpointHint.fromPlainObject(h)) || [],
|
|
918
|
+
obj.commitCheckpointHints?.map((h: any) => AvmCommitCheckpointHint.fromPlainObject(h)) || [],
|
|
919
|
+
obj.revertCheckpointHints?.map((h: any) => AvmRevertCheckpointHint.fromPlainObject(h)) || [],
|
|
920
|
+
);
|
|
921
|
+
}
|
|
922
|
+
|
|
595
923
|
static empty() {
|
|
596
924
|
return new AvmExecutionHints(GlobalVariables.empty(), AvmTxHint.empty(), ProtocolContracts.empty());
|
|
597
925
|
}
|
|
@@ -685,6 +1013,13 @@ export class AvmCircuitInputs {
|
|
|
685
1013
|
return new AvmCircuitInputs(AvmExecutionHints.empty(), AvmCircuitPublicInputs.empty());
|
|
686
1014
|
}
|
|
687
1015
|
|
|
1016
|
+
static fromPlainObject(obj: any): AvmCircuitInputs {
|
|
1017
|
+
return new AvmCircuitInputs(
|
|
1018
|
+
AvmExecutionHints.fromPlainObject(obj.hints),
|
|
1019
|
+
AvmCircuitPublicInputs.fromPlainObject(obj.publicInputs),
|
|
1020
|
+
);
|
|
1021
|
+
}
|
|
1022
|
+
|
|
688
1023
|
static get schema() {
|
|
689
1024
|
return z
|
|
690
1025
|
.object({
|
|
@@ -772,6 +1107,18 @@ export class PublicTxResult {
|
|
|
772
1107
|
),
|
|
773
1108
|
);
|
|
774
1109
|
}
|
|
1110
|
+
|
|
1111
|
+
static fromPlainObject(obj: any): PublicTxResult {
|
|
1112
|
+
return new PublicTxResult(
|
|
1113
|
+
GasUsed.fromPlainObject(obj.gasUsed),
|
|
1114
|
+
RevertCode.fromPlainObject(obj.revertCode),
|
|
1115
|
+
/*revertReason=*/ undefined, // TODO(fcarreiro/mwood): add.
|
|
1116
|
+
/*processedPhases=*/ [], // TODO(fcarreiro/mwood): add.
|
|
1117
|
+
obj.logs?.map(DebugLog.fromPlainObject),
|
|
1118
|
+
obj.hints ? AvmExecutionHints.fromPlainObject(obj.hints) : undefined,
|
|
1119
|
+
AvmCircuitPublicInputs.fromPlainObject(obj.publicInputs),
|
|
1120
|
+
);
|
|
1121
|
+
}
|
|
775
1122
|
}
|
|
776
1123
|
|
|
777
1124
|
export type PublicTxSimulatorConfig = {
|
|
@@ -149,6 +149,35 @@ export class AvmAccumulatedData {
|
|
|
149
149
|
);
|
|
150
150
|
}
|
|
151
151
|
|
|
152
|
+
/**
|
|
153
|
+
* Creates an AvmAccumulatedData instance from a plain object without Zod validation.
|
|
154
|
+
* This method is optimized for performance and skips validation, making it suitable
|
|
155
|
+
* for deserializing trusted data (e.g., from C++ via MessagePack).
|
|
156
|
+
* @param obj - Plain object containing AvmAccumulatedData fields
|
|
157
|
+
* @returns An AvmAccumulatedData instance
|
|
158
|
+
*/
|
|
159
|
+
static fromPlainObject(obj: any): AvmAccumulatedData {
|
|
160
|
+
return new AvmAccumulatedData(
|
|
161
|
+
assertLength(
|
|
162
|
+
obj.noteHashes.map((h: any) => Fr.fromPlainObject(h)),
|
|
163
|
+
MAX_NOTE_HASHES_PER_TX,
|
|
164
|
+
),
|
|
165
|
+
assertLength(
|
|
166
|
+
obj.nullifiers.map((n: any) => Fr.fromPlainObject(n)),
|
|
167
|
+
MAX_NULLIFIERS_PER_TX,
|
|
168
|
+
),
|
|
169
|
+
assertLength(
|
|
170
|
+
obj.l2ToL1Msgs.map((m: any) => ScopedL2ToL1Message.fromPlainObject(m)),
|
|
171
|
+
MAX_L2_TO_L1_MSGS_PER_TX,
|
|
172
|
+
),
|
|
173
|
+
FlatPublicLogs.fromPlainObject(obj.publicLogs),
|
|
174
|
+
assertLength(
|
|
175
|
+
obj.publicDataWrites.map((w: any) => PublicDataWrite.fromPlainObject(w)),
|
|
176
|
+
MAX_TOTAL_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX,
|
|
177
|
+
),
|
|
178
|
+
);
|
|
179
|
+
}
|
|
180
|
+
|
|
152
181
|
isEmpty(): boolean {
|
|
153
182
|
return (
|
|
154
183
|
this.noteHashes.every(x => x.isZero()) &&
|
|
@@ -265,6 +294,17 @@ export class AvmAccumulatedDataArrayLengths {
|
|
|
265
294
|
return new AvmAccumulatedDataArrayLengths(0, 0, 0, 0);
|
|
266
295
|
}
|
|
267
296
|
|
|
297
|
+
/**
|
|
298
|
+
* Creates an AvmAccumulatedDataArrayLengths instance from a plain object without Zod validation.
|
|
299
|
+
* This method is optimized for performance and skips validation, making it suitable
|
|
300
|
+
* for deserializing trusted data (e.g., from C++ via MessagePack).
|
|
301
|
+
* @param obj - Plain object containing AvmAccumulatedDataArrayLengths fields
|
|
302
|
+
* @returns An AvmAccumulatedDataArrayLengths instance
|
|
303
|
+
*/
|
|
304
|
+
static fromPlainObject(obj: any): AvmAccumulatedDataArrayLengths {
|
|
305
|
+
return new AvmAccumulatedDataArrayLengths(obj.noteHashes, obj.nullifiers, obj.l2ToL1Msgs, obj.publicDataWrites);
|
|
306
|
+
}
|
|
307
|
+
|
|
268
308
|
[inspect.custom]() {
|
|
269
309
|
return `AvmAccumulatedDataArrayLengths {
|
|
270
310
|
noteHashes: ${this.noteHashes},
|
|
@@ -276,6 +276,46 @@ export class AvmCircuitPublicInputs {
|
|
|
276
276
|
);
|
|
277
277
|
}
|
|
278
278
|
|
|
279
|
+
/**
|
|
280
|
+
* Creates an AvmCircuitPublicInputs instance from a plain object without Zod validation.
|
|
281
|
+
* This method is optimized for performance and skips validation, making it suitable
|
|
282
|
+
* for deserializing trusted data (e.g., from C++ via MessagePack).
|
|
283
|
+
* @param obj - Plain object containing AvmCircuitPublicInputs fields
|
|
284
|
+
* @returns An AvmCircuitPublicInputs instance
|
|
285
|
+
*/
|
|
286
|
+
static fromPlainObject(obj: any): AvmCircuitPublicInputs {
|
|
287
|
+
return new AvmCircuitPublicInputs(
|
|
288
|
+
GlobalVariables.fromPlainObject(obj.globalVariables),
|
|
289
|
+
ProtocolContracts.fromPlainObject(obj.protocolContracts),
|
|
290
|
+
TreeSnapshots.fromPlainObject(obj.startTreeSnapshots),
|
|
291
|
+
Gas.fromPlainObject(obj.startGasUsed),
|
|
292
|
+
GasSettings.fromPlainObject(obj.gasSettings),
|
|
293
|
+
GasFees.fromPlainObject(obj.effectiveGasFees),
|
|
294
|
+
AztecAddress.fromPlainObject(obj.feePayer),
|
|
295
|
+
Fr.fromPlainObject(obj.proverId),
|
|
296
|
+
PublicCallRequestArrayLengths.fromPlainObject(obj.publicCallRequestArrayLengths),
|
|
297
|
+
assertLength(
|
|
298
|
+
obj.publicSetupCallRequests.map((r: any) => PublicCallRequest.fromPlainObject(r)),
|
|
299
|
+
MAX_ENQUEUED_CALLS_PER_TX,
|
|
300
|
+
),
|
|
301
|
+
assertLength(
|
|
302
|
+
obj.publicAppLogicCallRequests.map((r: any) => PublicCallRequest.fromPlainObject(r)),
|
|
303
|
+
MAX_ENQUEUED_CALLS_PER_TX,
|
|
304
|
+
),
|
|
305
|
+
PublicCallRequest.fromPlainObject(obj.publicTeardownCallRequest),
|
|
306
|
+
PrivateToAvmAccumulatedDataArrayLengths.fromPlainObject(obj.previousNonRevertibleAccumulatedDataArrayLengths),
|
|
307
|
+
PrivateToAvmAccumulatedDataArrayLengths.fromPlainObject(obj.previousRevertibleAccumulatedDataArrayLengths),
|
|
308
|
+
PrivateToAvmAccumulatedData.fromPlainObject(obj.previousNonRevertibleAccumulatedData),
|
|
309
|
+
PrivateToAvmAccumulatedData.fromPlainObject(obj.previousRevertibleAccumulatedData),
|
|
310
|
+
TreeSnapshots.fromPlainObject(obj.endTreeSnapshots),
|
|
311
|
+
Gas.fromPlainObject(obj.endGasUsed),
|
|
312
|
+
AvmAccumulatedDataArrayLengths.fromPlainObject(obj.accumulatedDataArrayLengths),
|
|
313
|
+
AvmAccumulatedData.fromPlainObject(obj.accumulatedData),
|
|
314
|
+
Fr.fromPlainObject(obj.transactionFee),
|
|
315
|
+
obj.reverted,
|
|
316
|
+
);
|
|
317
|
+
}
|
|
318
|
+
|
|
279
319
|
public serializeWithMessagePack(): Buffer {
|
|
280
320
|
return serializeWithMessagePack(this);
|
|
281
321
|
}
|
|
@@ -86,6 +86,17 @@ export class PublicDataWrite {
|
|
|
86
86
|
return new PublicDataWrite(Fr.ZERO, Fr.ZERO);
|
|
87
87
|
}
|
|
88
88
|
|
|
89
|
+
/**
|
|
90
|
+
* Creates a PublicDataWrite instance from a plain object without Zod validation.
|
|
91
|
+
* This method is optimized for performance and skips validation, making it suitable
|
|
92
|
+
* for deserializing trusted data (e.g., from C++ via MessagePack).
|
|
93
|
+
* @param obj - Plain object containing PublicDataWrite fields
|
|
94
|
+
* @returns A PublicDataWrite instance
|
|
95
|
+
*/
|
|
96
|
+
static fromPlainObject(obj: any): PublicDataWrite {
|
|
97
|
+
return new PublicDataWrite(Fr.fromPlainObject(obj.leafSlot), Fr.fromPlainObject(obj.value));
|
|
98
|
+
}
|
|
99
|
+
|
|
89
100
|
static random() {
|
|
90
101
|
return new PublicDataWrite(Fr.random(), Fr.random());
|
|
91
102
|
}
|
package/src/avm/revert_code.ts
CHANGED
|
@@ -69,6 +69,24 @@ export class RevertCode {
|
|
|
69
69
|
return z.nativeEnum(RevertCodeEnum).transform(value => new RevertCode(value));
|
|
70
70
|
}
|
|
71
71
|
|
|
72
|
+
/**
|
|
73
|
+
* Creates a RevertCode from a plain object without Zod validation.
|
|
74
|
+
* This method is optimized for performance and skips validation, making it suitable
|
|
75
|
+
* for deserializing trusted data (e.g., from C++ via MessagePack).
|
|
76
|
+
* @param obj - Plain object, number, or RevertCode instance
|
|
77
|
+
* @returns A RevertCode instance
|
|
78
|
+
*/
|
|
79
|
+
static fromPlainObject(obj: any): RevertCode {
|
|
80
|
+
if (obj instanceof RevertCode) {
|
|
81
|
+
return obj;
|
|
82
|
+
}
|
|
83
|
+
const code = typeof obj === 'number' ? obj : (obj.code ?? obj);
|
|
84
|
+
if (!isRevertCodeEnum(code)) {
|
|
85
|
+
throw new Error(`Invalid RevertCode: ${code}`);
|
|
86
|
+
}
|
|
87
|
+
return new RevertCode(code);
|
|
88
|
+
}
|
|
89
|
+
|
|
72
90
|
/**
|
|
73
91
|
* Having different serialization methods allows for
|
|
74
92
|
* decoupling the serialization for producing the content commitment hash
|
|
@@ -72,6 +72,24 @@ export class AztecAddress {
|
|
|
72
72
|
return new AztecAddress(hexToBuffer(buf));
|
|
73
73
|
}
|
|
74
74
|
|
|
75
|
+
/**
|
|
76
|
+
* Creates an AztecAddress from a plain object without Zod validation.
|
|
77
|
+
* This method is optimized for performance and skips validation, making it suitable
|
|
78
|
+
* for deserializing trusted data (e.g., from C++ via MessagePack).
|
|
79
|
+
* Handles buffers, strings, or existing instances.
|
|
80
|
+
* @param obj - Plain object, buffer, string, or AztecAddress instance
|
|
81
|
+
* @returns An AztecAddress instance
|
|
82
|
+
*/
|
|
83
|
+
static fromPlainObject(obj: any): AztecAddress {
|
|
84
|
+
if (obj instanceof AztecAddress) {
|
|
85
|
+
return obj;
|
|
86
|
+
}
|
|
87
|
+
if (obj instanceof Buffer || Buffer.isBuffer(obj)) {
|
|
88
|
+
return new AztecAddress(obj);
|
|
89
|
+
}
|
|
90
|
+
return AztecAddress.fromString(obj);
|
|
91
|
+
}
|
|
92
|
+
|
|
75
93
|
/**
|
|
76
94
|
* @returns a random valid address (i.e. one that can be encrypted to).
|
|
77
95
|
*/
|
|
@@ -37,6 +37,23 @@ export class ContractDeploymentData {
|
|
|
37
37
|
})
|
|
38
38
|
.transform(ContractDeploymentData.from);
|
|
39
39
|
}
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Creates a ContractDeploymentData from a plain object without Zod validation.
|
|
43
|
+
* This method is optimized for performance and skips validation, making it suitable
|
|
44
|
+
* for deserializing trusted data (e.g., from C++ via MessagePack).
|
|
45
|
+
* @param obj - Plain object containing ContractDeploymentData fields
|
|
46
|
+
* @returns A ContractDeploymentData instance
|
|
47
|
+
*/
|
|
48
|
+
public static fromPlainObject(obj: any): ContractDeploymentData {
|
|
49
|
+
if (obj instanceof ContractDeploymentData) {
|
|
50
|
+
return obj;
|
|
51
|
+
}
|
|
52
|
+
return new ContractDeploymentData(
|
|
53
|
+
obj.contractClassLogs.map((log: any) => ContractClassLog.fromPlainObject(log)),
|
|
54
|
+
obj.privateLogs.map((log: any) => PrivateLog.fromPlainObject(log)),
|
|
55
|
+
);
|
|
56
|
+
}
|
|
40
57
|
}
|
|
41
58
|
|
|
42
59
|
/**
|
package/src/gas/gas.ts
CHANGED
|
@@ -48,6 +48,20 @@ export class Gas {
|
|
|
48
48
|
return new Gas(fields.daGas ?? 0, fields.l2Gas ?? 0);
|
|
49
49
|
}
|
|
50
50
|
|
|
51
|
+
/**
|
|
52
|
+
* Creates a Gas instance from a plain object without Zod validation.
|
|
53
|
+
* This method is optimized for performance and skips validation, making it suitable
|
|
54
|
+
* for deserializing trusted data (e.g., from C++ via MessagePack).
|
|
55
|
+
* @param obj - Plain object containing Gas fields
|
|
56
|
+
* @returns A Gas instance
|
|
57
|
+
*/
|
|
58
|
+
static fromPlainObject(obj: any): Gas {
|
|
59
|
+
if (obj instanceof Gas) {
|
|
60
|
+
return obj;
|
|
61
|
+
}
|
|
62
|
+
return Gas.from(obj);
|
|
63
|
+
}
|
|
64
|
+
|
|
51
65
|
static empty() {
|
|
52
66
|
return new Gas(0, 0);
|
|
53
67
|
}
|