@aztec/stdlib 4.0.0-devnet.2-patch.4 → 4.0.0-devnet.3-patch.0
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/buffer.d.ts +14 -4
- package/dest/abi/buffer.d.ts.map +1 -1
- package/dest/abi/buffer.js +25 -4
- package/dest/abi/decoder.d.ts +6 -45
- package/dest/abi/decoder.d.ts.map +1 -1
- package/dest/abi/decoder.js +17 -70
- package/dest/abi/encoder.d.ts +1 -1
- package/dest/abi/encoder.d.ts.map +1 -1
- package/dest/abi/encoder.js +37 -6
- package/dest/abi/event_metadata_definition.d.ts +3 -1
- package/dest/abi/event_metadata_definition.d.ts.map +1 -1
- package/dest/abi/event_metadata_definition.js +1 -1
- package/dest/abi/function_selector.js +1 -1
- package/dest/abi/function_signature_decoder.d.ts +43 -0
- package/dest/abi/function_signature_decoder.d.ts.map +1 -0
- package/dest/abi/function_signature_decoder.js +66 -0
- package/dest/abi/index.d.ts +2 -1
- package/dest/abi/index.d.ts.map +1 -1
- package/dest/abi/index.js +1 -0
- package/dest/abi/utils.d.ts +14 -1
- package/dest/abi/utils.d.ts.map +1 -1
- package/dest/abi/utils.js +15 -0
- package/dest/avm/avm.d.ts +300 -300
- package/dest/avm/avm_accumulated_data.js +2 -2
- package/dest/avm/avm_circuit_public_inputs.js +2 -2
- package/dest/avm/avm_proving_request.d.ts +166 -166
- package/dest/avm/revert_code.d.ts +16 -1
- package/dest/avm/revert_code.d.ts.map +1 -1
- package/dest/avm/revert_code.js +15 -5
- package/dest/block/l2_block.d.ts +9 -1
- package/dest/block/l2_block.d.ts.map +1 -1
- package/dest/block/l2_block.js +12 -2
- package/dest/block/l2_block_source.d.ts +16 -8
- package/dest/block/l2_block_source.d.ts.map +1 -1
- package/dest/block/l2_block_stream/l2_block_stream.d.ts +1 -1
- package/dest/block/l2_block_stream/l2_block_stream.d.ts.map +1 -1
- package/dest/block/l2_block_stream/l2_block_stream.js +10 -0
- package/dest/checkpoint/checkpoint.d.ts +2 -1
- package/dest/checkpoint/checkpoint.d.ts.map +1 -1
- package/dest/checkpoint/checkpoint.js +9 -4
- package/dest/checkpoint/index.d.ts +2 -1
- package/dest/checkpoint/index.d.ts.map +1 -1
- package/dest/checkpoint/index.js +1 -0
- package/dest/checkpoint/validate.d.ts +36 -0
- package/dest/checkpoint/validate.d.ts.map +1 -0
- package/dest/checkpoint/validate.js +120 -0
- package/dest/config/sequencer-config.d.ts +2 -2
- package/dest/config/sequencer-config.d.ts.map +1 -1
- package/dest/config/sequencer-config.js +11 -0
- package/dest/epoch-helpers/index.d.ts +9 -1
- package/dest/epoch-helpers/index.d.ts.map +1 -1
- package/dest/epoch-helpers/index.js +13 -2
- package/dest/gas/gas_fees.d.ts +1 -1
- package/dest/gas/gas_fees.d.ts.map +1 -1
- package/dest/gas/gas_fees.js +4 -1
- package/dest/hash/hash.d.ts +19 -1
- package/dest/hash/hash.d.ts.map +1 -1
- package/dest/hash/hash.js +29 -0
- package/dest/interfaces/allowed_element.d.ts +26 -20
- package/dest/interfaces/allowed_element.d.ts.map +1 -1
- package/dest/interfaces/allowed_element.js +8 -8
- package/dest/interfaces/archiver.d.ts +1 -1
- package/dest/interfaces/archiver.d.ts.map +1 -1
- package/dest/interfaces/archiver.js +3 -2
- package/dest/interfaces/aztec-node-admin.d.ts +67 -27
- package/dest/interfaces/aztec-node-admin.d.ts.map +1 -1
- package/dest/interfaces/aztec-node.d.ts +12 -6
- package/dest/interfaces/aztec-node.d.ts.map +1 -1
- package/dest/interfaces/aztec-node.js +5 -2
- package/dest/interfaces/block-builder.d.ts +38 -11
- package/dest/interfaces/block-builder.d.ts.map +1 -1
- package/dest/interfaces/block-builder.js +13 -6
- package/dest/interfaces/configs.d.ts +67 -32
- package/dest/interfaces/configs.d.ts.map +1 -1
- package/dest/interfaces/configs.js +7 -2
- package/dest/interfaces/merkle_tree_operations.d.ts +9 -19
- package/dest/interfaces/merkle_tree_operations.d.ts.map +1 -1
- package/dest/interfaces/p2p.d.ts +3 -8
- package/dest/interfaces/p2p.d.ts.map +1 -1
- package/dest/interfaces/prover-client.d.ts +6 -1
- package/dest/interfaces/prover-client.d.ts.map +1 -1
- package/dest/interfaces/prover-client.js +7 -1
- package/dest/interfaces/validator.d.ts +67 -25
- package/dest/interfaces/validator.d.ts.map +1 -1
- package/dest/interfaces/validator.js +6 -2
- package/dest/interfaces/world_state.d.ts +5 -4
- package/dest/interfaces/world_state.d.ts.map +1 -1
- package/dest/kernel/claimed_length_array.js +1 -1
- package/dest/kernel/hints/build_note_hash_read_request_hints.d.ts +3 -3
- package/dest/kernel/hints/build_note_hash_read_request_hints.d.ts.map +1 -1
- package/dest/kernel/hints/build_note_hash_read_request_hints.js +13 -10
- package/dest/kernel/hints/build_nullifier_read_request_hints.d.ts +3 -3
- package/dest/kernel/hints/build_nullifier_read_request_hints.d.ts.map +1 -1
- package/dest/kernel/hints/build_nullifier_read_request_hints.js +13 -10
- package/dest/kernel/hints/build_transient_data_hints.d.ts +5 -2
- package/dest/kernel/hints/build_transient_data_hints.d.ts.map +1 -1
- package/dest/kernel/hints/build_transient_data_hints.js +9 -3
- package/dest/kernel/hints/private_kernel_reset_hints.d.ts +1 -1
- package/dest/kernel/hints/private_kernel_reset_hints.d.ts.map +1 -1
- package/dest/kernel/padded_side_effects.js +1 -1
- package/dest/kernel/private_kernel_tail_circuit_public_inputs.d.ts +2 -1
- package/dest/kernel/private_kernel_tail_circuit_public_inputs.d.ts.map +1 -1
- package/dest/kernel/private_kernel_tail_circuit_public_inputs.js +4 -0
- package/dest/kernel/private_to_avm_accumulated_data.js +2 -2
- package/dest/kernel/private_to_public_accumulated_data.js +2 -2
- package/dest/kernel/private_to_rollup_accumulated_data.js +1 -1
- package/dest/logs/debug_log_store.d.ts +30 -0
- package/dest/logs/debug_log_store.d.ts.map +1 -0
- package/dest/logs/debug_log_store.js +30 -0
- package/dest/logs/extended_directional_app_tagging_secret.d.ts +47 -0
- package/dest/logs/extended_directional_app_tagging_secret.d.ts.map +1 -0
- package/dest/logs/{directional_app_tagging_secret.js → extended_directional_app_tagging_secret.js} +35 -20
- package/dest/logs/index.d.ts +4 -2
- package/dest/logs/index.d.ts.map +1 -1
- package/dest/logs/index.js +3 -1
- package/dest/logs/log_filter.d.ts +4 -1
- package/dest/logs/log_filter.d.ts.map +1 -1
- package/dest/logs/log_filter.js +2 -1
- package/dest/logs/message_context.d.ts +4 -7
- package/dest/logs/message_context.d.ts.map +1 -1
- package/dest/logs/message_context.js +23 -9
- package/dest/logs/pending_tagged_log.d.ts +2 -3
- package/dest/logs/pending_tagged_log.d.ts.map +1 -1
- package/dest/logs/pending_tagged_log.js +2 -2
- package/dest/logs/pre_tag.d.ts +16 -11
- package/dest/logs/pre_tag.d.ts.map +1 -1
- package/dest/logs/pre_tag.js +2 -2
- package/dest/logs/private_log.js +1 -1
- package/dest/logs/public_log.d.ts +4 -3
- package/dest/logs/public_log.d.ts.map +1 -1
- package/dest/logs/public_log.js +9 -2
- package/dest/logs/shared_secret_derivation.d.ts +11 -10
- package/dest/logs/shared_secret_derivation.d.ts.map +1 -1
- package/dest/logs/shared_secret_derivation.js +15 -9
- package/dest/logs/siloed_tag.d.ts +8 -3
- package/dest/logs/siloed_tag.d.ts.map +1 -1
- package/dest/logs/siloed_tag.js +11 -2
- package/dest/logs/tag.js +1 -1
- package/dest/logs/tagging_index_range.d.ts +40 -0
- package/dest/logs/tagging_index_range.d.ts.map +1 -0
- package/dest/logs/tagging_index_range.js +8 -0
- package/dest/logs/tx_scoped_l2_log.d.ts +3 -1
- package/dest/logs/tx_scoped_l2_log.d.ts.map +1 -1
- package/dest/logs/tx_scoped_l2_log.js +7 -0
- package/dest/messaging/l1_to_l2_message.d.ts +3 -2
- package/dest/messaging/l1_to_l2_message.d.ts.map +1 -1
- package/dest/messaging/l1_to_l2_message.js +11 -13
- package/dest/messaging/l2_to_l1_membership.d.ts +32 -6
- package/dest/messaging/l2_to_l1_membership.d.ts.map +1 -1
- package/dest/messaging/l2_to_l1_membership.js +69 -26
- package/dest/noir/index.d.ts +3 -3
- package/dest/noir/index.d.ts.map +1 -1
- package/dest/note/note_dao.d.ts +1 -1
- package/dest/note/note_dao.d.ts.map +1 -1
- package/dest/note/note_dao.js +1 -4
- package/dest/p2p/attestation_utils.d.ts +11 -1
- package/dest/p2p/attestation_utils.d.ts.map +1 -1
- package/dest/p2p/attestation_utils.js +45 -0
- package/dest/p2p/checkpoint_proposal.d.ts +1 -6
- package/dest/p2p/checkpoint_proposal.d.ts.map +1 -1
- package/dest/p2p/checkpoint_proposal.js +13 -23
- package/dest/p2p/client_type.d.ts +2 -5
- package/dest/p2p/client_type.d.ts.map +1 -1
- package/dest/p2p/client_type.js +0 -7
- package/dest/p2p/index.d.ts +1 -2
- package/dest/p2p/index.d.ts.map +1 -1
- package/dest/p2p/index.js +0 -1
- package/dest/p2p/peer_error.d.ts +3 -1
- package/dest/p2p/peer_error.d.ts.map +1 -1
- package/dest/p2p/peer_error.js +5 -0
- package/dest/p2p/topic_type.d.ts +3 -4
- package/dest/p2p/topic_type.d.ts.map +1 -1
- package/dest/p2p/topic_type.js +7 -24
- package/dest/parity/parity_base_private_inputs.js +1 -1
- package/dest/proofs/chonk_proof.d.ts +1 -1
- package/dest/proofs/chonk_proof.d.ts.map +1 -1
- package/dest/proofs/chonk_proof.js +7 -1
- package/dest/rollup/base_rollup_hints.js +2 -2
- package/dest/rollup/block_root_rollup_private_inputs.js +5 -5
- package/dest/rollup/checkpoint_rollup_public_inputs.js +1 -1
- package/dest/rollup/checkpoint_root_rollup_private_inputs.js +3 -3
- package/dest/rollup/root_rollup_public_inputs.js +1 -1
- package/dest/rollup/tree_snapshot_diff_hints.js +2 -2
- package/dest/slashing/tally.d.ts +7 -2
- package/dest/slashing/tally.d.ts.map +1 -1
- package/dest/slashing/tally.js +30 -2
- package/dest/tests/factories.d.ts +3 -1
- package/dest/tests/factories.d.ts.map +1 -1
- package/dest/tests/factories.js +8 -0
- package/dest/tests/mocks.d.ts +5 -3
- package/dest/tests/mocks.d.ts.map +1 -1
- package/dest/tests/mocks.js +18 -13
- package/dest/tx/block_header.d.ts +3 -1
- package/dest/tx/block_header.d.ts.map +1 -1
- package/dest/tx/block_header.js +4 -0
- package/dest/tx/capsule.d.ts +6 -2
- package/dest/tx/capsule.d.ts.map +1 -1
- package/dest/tx/capsule.js +9 -3
- package/dest/tx/private_execution_result.d.ts +6 -6
- package/dest/tx/private_execution_result.d.ts.map +1 -1
- package/dest/tx/private_execution_result.js +6 -6
- package/dest/tx/profiling.d.ts +17 -5
- package/dest/tx/profiling.d.ts.map +1 -1
- package/dest/tx/profiling.js +15 -5
- package/dest/tx/protocol_contracts.js +2 -2
- package/dest/tx/public_simulation_output.d.ts +4 -2
- package/dest/tx/public_simulation_output.d.ts.map +1 -1
- package/dest/tx/public_simulation_output.js +7 -3
- package/dest/tx/simulated_tx.d.ts +5 -2
- package/dest/tx/simulated_tx.d.ts.map +1 -1
- package/dest/tx/simulated_tx.js +4 -1
- package/dest/tx/tx.d.ts +6 -5
- package/dest/tx/tx.d.ts.map +1 -1
- package/dest/tx/tx.js +18 -6
- package/dest/tx/tx_receipt.d.ts +22 -3
- package/dest/tx/tx_receipt.d.ts.map +1 -1
- package/dest/tx/tx_receipt.js +15 -4
- package/dest/tx/validator/error_texts.d.ts +9 -1
- package/dest/tx/validator/error_texts.d.ts.map +1 -1
- package/dest/tx/validator/error_texts.js +10 -0
- package/dest/update-checker/index.d.ts +3 -2
- package/dest/update-checker/index.d.ts.map +1 -1
- package/dest/update-checker/index.js +2 -1
- package/dest/update-checker/package_version.d.ts +3 -0
- package/dest/update-checker/package_version.d.ts.map +1 -0
- package/dest/update-checker/package_version.js +24 -0
- package/dest/update-checker/version_checker.d.ts +25 -0
- package/dest/update-checker/version_checker.d.ts.map +1 -0
- package/dest/update-checker/version_checker.js +50 -0
- package/dest/validators/errors.d.ts +6 -1
- package/dest/validators/errors.d.ts.map +1 -1
- package/dest/validators/errors.js +7 -0
- package/dest/versioning/versioning.d.ts +4 -2
- package/dest/versioning/versioning.d.ts.map +1 -1
- package/dest/versioning/versioning.js +4 -1
- package/dest/vks/vk_data.js +1 -1
- package/package.json +10 -10
- package/src/abi/buffer.ts +25 -4
- package/src/abi/decoder.ts +36 -82
- package/src/abi/encoder.ts +49 -6
- package/src/abi/event_metadata_definition.ts +2 -0
- package/src/abi/function_selector.ts +1 -1
- package/src/abi/function_signature_decoder.ts +77 -0
- package/src/abi/index.ts +1 -0
- package/src/abi/utils.ts +25 -0
- package/src/avm/avm_accumulated_data.ts +6 -6
- package/src/avm/avm_circuit_public_inputs.ts +4 -4
- package/src/avm/revert_code.ts +15 -0
- package/src/block/l2_block.ts +13 -1
- package/src/block/l2_block_source.ts +16 -7
- package/src/block/l2_block_stream/l2_block_stream.ts +21 -0
- package/src/checkpoint/checkpoint.ts +12 -3
- package/src/checkpoint/index.ts +1 -0
- package/src/checkpoint/validate.ts +230 -0
- package/src/config/sequencer-config.ts +16 -1
- package/src/epoch-helpers/index.ts +22 -0
- package/src/gas/README.md +123 -0
- package/src/gas/gas_fees.ts +7 -1
- package/src/hash/hash.ts +34 -0
- package/src/interfaces/allowed_element.ts +29 -9
- package/src/interfaces/archiver.ts +3 -2
- package/src/interfaces/aztec-node.ts +24 -5
- package/src/interfaces/block-builder.ts +60 -14
- package/src/interfaces/configs.ts +29 -8
- package/src/interfaces/merkle_tree_operations.ts +8 -18
- package/src/interfaces/p2p.ts +2 -13
- package/src/interfaces/prover-client.ts +8 -0
- package/src/interfaces/validator.ts +18 -2
- package/src/interfaces/world_state.ts +4 -3
- package/src/kernel/claimed_length_array.ts +2 -2
- package/src/kernel/hints/build_note_hash_read_request_hints.ts +14 -18
- package/src/kernel/hints/build_nullifier_read_request_hints.ts +15 -18
- package/src/kernel/hints/build_transient_data_hints.ts +17 -2
- package/src/kernel/hints/private_kernel_reset_hints.ts +5 -2
- package/src/kernel/hints/read_request_hints.ts +3 -3
- package/src/kernel/padded_side_effects.ts +3 -3
- package/src/kernel/private_kernel_tail_circuit_public_inputs.ts +9 -0
- package/src/kernel/private_to_avm_accumulated_data.ts +4 -4
- package/src/kernel/private_to_public_accumulated_data.ts +10 -10
- package/src/kernel/private_to_rollup_accumulated_data.ts +5 -5
- package/src/logs/debug_log_store.ts +54 -0
- package/src/logs/{directional_app_tagging_secret.ts → extended_directional_app_tagging_secret.ts} +41 -22
- package/src/logs/index.ts +3 -1
- package/src/logs/log_filter.ts +5 -0
- package/src/logs/message_context.ts +17 -7
- package/src/logs/pending_tagged_log.ts +1 -3
- package/src/logs/pre_tag.ts +5 -5
- package/src/logs/private_log.ts +1 -1
- package/src/logs/public_log.ts +15 -3
- package/src/logs/shared_secret_derivation.ts +21 -10
- package/src/logs/siloed_tag.ts +14 -3
- package/src/logs/tag.ts +1 -1
- package/src/logs/tagging_index_range.ts +24 -0
- package/src/logs/tx_scoped_l2_log.ts +16 -0
- package/src/messaging/l1_to_l2_message.ts +12 -9
- package/src/messaging/l2_to_l1_membership.ts +98 -33
- package/src/noir/index.ts +2 -2
- package/src/note/note_dao.ts +1 -4
- package/src/p2p/attestation_utils.ts +56 -0
- package/src/p2p/checkpoint_proposal.ts +23 -37
- package/src/p2p/client_type.ts +0 -6
- package/src/p2p/index.ts +0 -1
- package/src/p2p/peer_error.ts +7 -0
- package/src/p2p/topic_type.ts +8 -15
- package/src/parity/parity_base_private_inputs.ts +1 -1
- package/src/proofs/chonk_proof.ts +9 -1
- package/src/rollup/base_rollup_hints.ts +2 -2
- package/src/rollup/block_root_rollup_private_inputs.ts +8 -8
- package/src/rollup/checkpoint_rollup_public_inputs.ts +2 -2
- package/src/rollup/checkpoint_root_rollup_private_inputs.ts +4 -4
- package/src/rollup/root_rollup_public_inputs.ts +2 -2
- package/src/rollup/tree_snapshot_diff_hints.ts +5 -5
- package/src/slashing/tally.ts +34 -1
- package/src/tests/factories.ts +9 -0
- package/src/tests/mocks.ts +25 -10
- package/src/tx/block_header.ts +6 -0
- package/src/tx/capsule.ts +10 -2
- package/src/tx/private_execution_result.ts +5 -5
- package/src/tx/profiling.ts +14 -5
- package/src/tx/protocol_contracts.ts +2 -2
- package/src/tx/public_simulation_output.ts +4 -0
- package/src/tx/simulated_tx.ts +8 -1
- package/src/tx/tx.ts +20 -11
- package/src/tx/tx_receipt.ts +17 -2
- package/src/tx/validator/error_texts.ts +12 -0
- package/src/update-checker/index.ts +2 -1
- package/src/update-checker/package_version.ts +30 -0
- package/src/update-checker/version_checker.ts +65 -0
- package/src/validators/errors.ts +9 -0
- package/src/versioning/versioning.ts +4 -1
- package/src/vks/vk_data.ts +1 -1
- package/dest/logs/directional_app_tagging_secret.d.ts +0 -40
- package/dest/logs/directional_app_tagging_secret.d.ts.map +0 -1
- package/dest/update-checker/update-checker.d.ts +0 -49
- package/dest/update-checker/update-checker.d.ts.map +0 -1
- package/dest/update-checker/update-checker.js +0 -130
- package/src/update-checker/update-checker.ts +0 -166
package/dest/abi/buffer.d.ts
CHANGED
|
@@ -8,9 +8,19 @@ import { Fr } from '@aztec/foundation/curves/bn254';
|
|
|
8
8
|
*/
|
|
9
9
|
export declare function bufferAsFields(input: Buffer, targetLength: number): Fr[];
|
|
10
10
|
/**
|
|
11
|
-
* Recovers a buffer from an array of fields.
|
|
12
|
-
*
|
|
13
|
-
*
|
|
11
|
+
* Recovers a buffer from an array of fields previously encoded with bufferAsFields.
|
|
12
|
+
*
|
|
13
|
+
* The first field encodes the byte length of the original buffer. The remaining fields
|
|
14
|
+
* each carry 31 bytes of payload (the leading byte of each 32-byte field element is skipped).
|
|
15
|
+
*
|
|
16
|
+
* If the declared byte length exceeds the bytes available from the payload fields, the result
|
|
17
|
+
* is zero-padded to the full declared length. This is important for correctness when the field
|
|
18
|
+
* array has been truncated (e.g. contract class logs reconstructed from blobs using a short
|
|
19
|
+
* emittedLength): without padding, the resulting buffer would be shorter than declared, causing
|
|
20
|
+
* bytecode commitment computations to diverge from what the circuit produced.
|
|
21
|
+
*
|
|
22
|
+
* @param fields - An output from bufferAsFields: [byteLength, ...payloadFields].
|
|
23
|
+
* @returns A buffer of exactly `byteLength` bytes.
|
|
14
24
|
*/
|
|
15
25
|
export declare function bufferFromFields(fields: Fr[]): Buffer;
|
|
16
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
26
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYnVmZmVyLmQudHMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvYWJpL2J1ZmZlci50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxPQUFPLEVBQUUsRUFBRSxFQUFFLE1BQU0sZ0NBQWdDLENBQUM7QUFJcEQ7Ozs7OztHQU1HO0FBQ0gsd0JBQWdCLGNBQWMsQ0FBQyxLQUFLLEVBQUUsTUFBTSxFQUFFLFlBQVksRUFBRSxNQUFNLEdBQUcsRUFBRSxFQUFFLENBY3hFO0FBRUQ7Ozs7Ozs7Ozs7Ozs7O0dBY0c7QUFDSCx3QkFBZ0IsZ0JBQWdCLENBQUMsTUFBTSxFQUFFLEVBQUUsRUFBRSxHQUFHLE1BQU0sQ0FjckQifQ==
|
package/dest/abi/buffer.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"buffer.d.ts","sourceRoot":"","sources":["../../src/abi/buffer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAE,MAAM,gCAAgC,CAAC;AAIpD;;;;;;GAMG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,GAAG,EAAE,EAAE,CAcxE;AAED
|
|
1
|
+
{"version":3,"file":"buffer.d.ts","sourceRoot":"","sources":["../../src/abi/buffer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAE,MAAM,gCAAgC,CAAC;AAIpD;;;;;;GAMG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,GAAG,EAAE,EAAE,CAcxE;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,EAAE,EAAE,GAAG,MAAM,CAcrD"}
|
package/dest/abi/buffer.js
CHANGED
|
@@ -25,10 +25,31 @@ import chunk from 'lodash.chunk';
|
|
|
25
25
|
];
|
|
26
26
|
}
|
|
27
27
|
/**
|
|
28
|
-
* Recovers a buffer from an array of fields.
|
|
29
|
-
*
|
|
30
|
-
*
|
|
28
|
+
* Recovers a buffer from an array of fields previously encoded with bufferAsFields.
|
|
29
|
+
*
|
|
30
|
+
* The first field encodes the byte length of the original buffer. The remaining fields
|
|
31
|
+
* each carry 31 bytes of payload (the leading byte of each 32-byte field element is skipped).
|
|
32
|
+
*
|
|
33
|
+
* If the declared byte length exceeds the bytes available from the payload fields, the result
|
|
34
|
+
* is zero-padded to the full declared length. This is important for correctness when the field
|
|
35
|
+
* array has been truncated (e.g. contract class logs reconstructed from blobs using a short
|
|
36
|
+
* emittedLength): without padding, the resulting buffer would be shorter than declared, causing
|
|
37
|
+
* bytecode commitment computations to diverge from what the circuit produced.
|
|
38
|
+
*
|
|
39
|
+
* @param fields - An output from bufferAsFields: [byteLength, ...payloadFields].
|
|
40
|
+
* @returns A buffer of exactly `byteLength` bytes.
|
|
31
41
|
*/ export function bufferFromFields(fields) {
|
|
32
42
|
const [length, ...payload] = fields;
|
|
33
|
-
|
|
43
|
+
const byteLength = length.toNumber();
|
|
44
|
+
const raw = Buffer.concat(payload.map((f)=>f.toBuffer().subarray(1)));
|
|
45
|
+
if (raw.length >= byteLength) {
|
|
46
|
+
return raw.subarray(0, byteLength);
|
|
47
|
+
}
|
|
48
|
+
// Pad with zeros if the declared length exceeds the available payload bytes.
|
|
49
|
+
// This ensures the returned buffer always matches the declared length, so that
|
|
50
|
+
// downstream bytecode commitment computations are consistent even when the
|
|
51
|
+
// source field array was truncated (e.g. reconstructed from blob with a short emittedLength).
|
|
52
|
+
const result = Buffer.alloc(byteLength);
|
|
53
|
+
raw.copy(result);
|
|
54
|
+
return result;
|
|
34
55
|
}
|
package/dest/abi/decoder.d.ts
CHANGED
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
2
|
+
import { EthAddress } from '@aztec/foundation/eth-address';
|
|
2
3
|
import { AztecAddress } from '../aztec-address/index.js';
|
|
3
|
-
import type {
|
|
4
|
+
import type { AbiType } from './abi.js';
|
|
5
|
+
import { FunctionSelector } from './function_selector.js';
|
|
4
6
|
/**
|
|
5
7
|
* The type of our decoded ABI.
|
|
6
8
|
*/
|
|
7
|
-
export type AbiDecoded = bigint | boolean | string | AztecAddress | AbiDecoded[] | {
|
|
9
|
+
export type AbiDecoded = bigint | boolean | string | AztecAddress | EthAddress | FunctionSelector | Fr | AbiDecoded[] | {
|
|
8
10
|
[key: string]: AbiDecoded;
|
|
9
|
-
};
|
|
11
|
+
} | undefined;
|
|
10
12
|
/**
|
|
11
13
|
* Decodes values in a flattened Field array using a provided ABI.
|
|
12
14
|
* @param abi - The ABI to use as reference.
|
|
@@ -14,45 +16,4 @@ export type AbiDecoded = bigint | boolean | string | AztecAddress | AbiDecoded[]
|
|
|
14
16
|
* @returns
|
|
15
17
|
*/
|
|
16
18
|
export declare function decodeFromAbi(typ: AbiType[], buffer: Fr[]): AbiDecoded;
|
|
17
|
-
|
|
18
|
-
* Decodes the signature of a function from the name and parameters.
|
|
19
|
-
*/
|
|
20
|
-
export declare class FunctionSignatureDecoder {
|
|
21
|
-
private name;
|
|
22
|
-
private parameters;
|
|
23
|
-
private includeNames;
|
|
24
|
-
private separator;
|
|
25
|
-
constructor(name: string, parameters: ABIParameter[], includeNames?: boolean);
|
|
26
|
-
/**
|
|
27
|
-
* Decodes a single function parameter type for the function signature.
|
|
28
|
-
* @param param - The parameter type to decode.
|
|
29
|
-
* @returns A string representing the parameter type.
|
|
30
|
-
*/
|
|
31
|
-
private getParameterType;
|
|
32
|
-
/**
|
|
33
|
-
* Decodes a single function parameter for the function signature.
|
|
34
|
-
* @param param - The parameter to decode.
|
|
35
|
-
* @returns A string representing the parameter type and optionally its name.
|
|
36
|
-
*/
|
|
37
|
-
private decodeParameter;
|
|
38
|
-
/**
|
|
39
|
-
* Decodes all the parameters and build the function signature
|
|
40
|
-
* @returns The function signature.
|
|
41
|
-
*/
|
|
42
|
-
decode(): string;
|
|
43
|
-
}
|
|
44
|
-
/**
|
|
45
|
-
* Decodes a function signature from the name and parameters.
|
|
46
|
-
* @param name - The name of the function.
|
|
47
|
-
* @param parameters - The parameters of the function.
|
|
48
|
-
* @returns - The function signature.
|
|
49
|
-
*/
|
|
50
|
-
export declare function decodeFunctionSignature(name: string, parameters: ABIParameter[]): string;
|
|
51
|
-
/**
|
|
52
|
-
* Decodes a function signature from the name and parameters including parameter names.
|
|
53
|
-
* @param name - The name of the function.
|
|
54
|
-
* @param parameters - The parameters of the function.
|
|
55
|
-
* @returns - The user-friendly function signature.
|
|
56
|
-
*/
|
|
57
|
-
export declare function decodeFunctionSignatureWithParameterNames(name: string, parameters: ABIParameter[]): string;
|
|
58
|
-
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZGVjb2Rlci5kLnRzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vc3JjL2FiaS9kZWNvZGVyLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLE9BQU8sRUFBRSxFQUFFLEVBQUUsTUFBTSxnQ0FBZ0MsQ0FBQztBQUVwRCxPQUFPLEVBQUUsWUFBWSxFQUFFLE1BQU0sMkJBQTJCLENBQUM7QUFDekQsT0FBTyxLQUFLLEVBQUUsWUFBWSxFQUFlLE9BQU8sRUFBRSxNQUFNLFVBQVUsQ0FBQztBQUduRTs7R0FFRztBQUNILE1BQU0sTUFBTSxVQUFVLEdBQUcsTUFBTSxHQUFHLE9BQU8sR0FBRyxNQUFNLEdBQUcsWUFBWSxHQUFHLFVBQVUsRUFBRSxHQUFHO0lBQUUsQ0FBQyxHQUFHLEVBQUUsTUFBTSxHQUFHLFVBQVUsQ0FBQTtDQUFFLENBQUM7QUErRmpIOzs7OztHQUtHO0FBQ0gsd0JBQWdCLGFBQWEsQ0FBQyxHQUFHLEVBQUUsT0FBTyxFQUFFLEVBQUUsTUFBTSxFQUFFLEVBQUUsRUFBRSxjQUV6RDtBQUVEOztHQUVHO0FBQ0gscUJBQWEsd0JBQXdCO0lBR2pDLE9BQU8sQ0FBQyxJQUFJO0lBQ1osT0FBTyxDQUFDLFVBQVU7SUFDbEIsT0FBTyxDQUFDLFlBQVk7SUFKdEIsT0FBTyxDQUFDLFNBQVMsQ0FBUztJQUMxQixZQUNVLElBQUksRUFBRSxNQUFNLEVBQ1osVUFBVSxFQUFFLFlBQVksRUFBRSxFQUMxQixZQUFZLFVBQVEsRUFHN0I7SUFFRDs7OztPQUlHO0lBQ0gsT0FBTyxDQUFDLGdCQUFnQjtJQXNCeEI7Ozs7T0FJRztJQUNILE9BQU8sQ0FBQyxlQUFlO0lBS3ZCOzs7T0FHRztJQUNJLE1BQU0sSUFBSSxNQUFNLENBRXRCO0NBQ0Y7QUFFRDs7Ozs7R0FLRztBQUNILHdCQUFnQix1QkFBdUIsQ0FBQyxJQUFJLEVBQUUsTUFBTSxFQUFFLFVBQVUsRUFBRSxZQUFZLEVBQUUsVUFFL0U7QUFFRDs7Ozs7R0FLRztBQUNILHdCQUFnQix5Q0FBeUMsQ0FBQyxJQUFJLEVBQUUsTUFBTSxFQUFFLFVBQVUsRUFBRSxZQUFZLEVBQUUsVUFFakcifQ==
|
|
19
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZGVjb2Rlci5kLnRzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vc3JjL2FiaS9kZWNvZGVyLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLE9BQU8sRUFBRSxFQUFFLEVBQUUsTUFBTSxnQ0FBZ0MsQ0FBQztBQUNwRCxPQUFPLEVBQUUsVUFBVSxFQUFFLE1BQU0sK0JBQStCLENBQUM7QUFFM0QsT0FBTyxFQUFFLFlBQVksRUFBRSxNQUFNLDJCQUEyQixDQUFDO0FBQ3pELE9BQU8sS0FBSyxFQUFFLE9BQU8sRUFBRSxNQUFNLFVBQVUsQ0FBQztBQUN4QyxPQUFPLEVBQUUsZ0JBQWdCLEVBQUUsTUFBTSx3QkFBd0IsQ0FBQztBQVUxRDs7R0FFRztBQUNILE1BQU0sTUFBTSxVQUFVLEdBQ2xCLE1BQU0sR0FDTixPQUFPLEdBQ1AsTUFBTSxHQUNOLFlBQVksR0FDWixVQUFVLEdBQ1YsZ0JBQWdCLEdBQ2hCLEVBQUUsR0FDRixVQUFVLEVBQUUsR0FDWjtJQUFFLENBQUMsR0FBRyxFQUFFLE1BQU0sR0FBRyxVQUFVLENBQUE7Q0FBRSxHQUM3QixTQUFTLENBQUM7QUE2R2Q7Ozs7O0dBS0c7QUFDSCx3QkFBZ0IsYUFBYSxDQUFDLEdBQUcsRUFBRSxPQUFPLEVBQUUsRUFBRSxNQUFNLEVBQUUsRUFBRSxFQUFFLGNBRXpEIn0=
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"decoder.d.ts","sourceRoot":"","sources":["../../src/abi/decoder.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAE,MAAM,gCAAgC,CAAC;
|
|
1
|
+
{"version":3,"file":"decoder.d.ts","sourceRoot":"","sources":["../../src/abi/decoder.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAE,MAAM,gCAAgC,CAAC;AACpD,OAAO,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAC;AAE3D,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AACzD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,UAAU,CAAC;AACxC,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAU1D;;GAEG;AACH,MAAM,MAAM,UAAU,GAClB,MAAM,GACN,OAAO,GACP,MAAM,GACN,YAAY,GACZ,UAAU,GACV,gBAAgB,GAChB,EAAE,GACF,UAAU,EAAE,GACZ;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,UAAU,CAAA;CAAE,GAC7B,SAAS,CAAC;AA6Gd;;;;;GAKG;AACH,wBAAgB,aAAa,CAAC,GAAG,EAAE,OAAO,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,cAEzD"}
|
package/dest/abi/decoder.js
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
|
+
import { EthAddress } from '@aztec/foundation/eth-address';
|
|
1
2
|
import { AztecAddress } from '../aztec-address/index.js';
|
|
2
|
-
import {
|
|
3
|
+
import { FunctionSelector } from './function_selector.js';
|
|
4
|
+
import { isAztecAddressStruct, isEthAddressStruct, isFunctionSelectorStruct, isOptionStruct, isWrappedFieldStruct, parseSignedInt } from './utils.js';
|
|
3
5
|
/**
|
|
4
6
|
* Decodes values using a provided ABI.
|
|
5
7
|
*/ class AbiDecoder {
|
|
@@ -42,6 +44,20 @@ import { isAztecAddressStruct, parseSignedInt } from './utils.js';
|
|
|
42
44
|
if (isAztecAddressStruct(abiType)) {
|
|
43
45
|
return new AztecAddress(this.getNextField().toBuffer());
|
|
44
46
|
}
|
|
47
|
+
if (isEthAddressStruct(abiType)) {
|
|
48
|
+
return EthAddress.fromField(this.getNextField());
|
|
49
|
+
}
|
|
50
|
+
if (isFunctionSelectorStruct(abiType)) {
|
|
51
|
+
return FunctionSelector.fromField(this.getNextField());
|
|
52
|
+
}
|
|
53
|
+
if (isWrappedFieldStruct(abiType)) {
|
|
54
|
+
return this.getNextField();
|
|
55
|
+
}
|
|
56
|
+
if (isOptionStruct(abiType)) {
|
|
57
|
+
const isSome = this.decodeNext(abiType.fields[0].type);
|
|
58
|
+
const value = this.decodeNext(abiType.fields[1].type);
|
|
59
|
+
return isSome ? value : undefined;
|
|
60
|
+
}
|
|
45
61
|
for (const field of abiType.fields){
|
|
46
62
|
struct[field.name] = this.decodeNext(field.type);
|
|
47
63
|
}
|
|
@@ -97,72 +113,3 @@ import { isAztecAddressStruct, parseSignedInt } from './utils.js';
|
|
|
97
113
|
*/ export function decodeFromAbi(typ, buffer) {
|
|
98
114
|
return new AbiDecoder(typ, buffer.slice()).decode();
|
|
99
115
|
}
|
|
100
|
-
/**
|
|
101
|
-
* Decodes the signature of a function from the name and parameters.
|
|
102
|
-
*/ export class FunctionSignatureDecoder {
|
|
103
|
-
name;
|
|
104
|
-
parameters;
|
|
105
|
-
includeNames;
|
|
106
|
-
separator;
|
|
107
|
-
constructor(name, parameters, includeNames = false){
|
|
108
|
-
this.name = name;
|
|
109
|
-
this.parameters = parameters;
|
|
110
|
-
this.includeNames = includeNames;
|
|
111
|
-
this.separator = includeNames ? ', ' : ',';
|
|
112
|
-
}
|
|
113
|
-
/**
|
|
114
|
-
* Decodes a single function parameter type for the function signature.
|
|
115
|
-
* @param param - The parameter type to decode.
|
|
116
|
-
* @returns A string representing the parameter type.
|
|
117
|
-
*/ getParameterType(param) {
|
|
118
|
-
switch(param.kind){
|
|
119
|
-
case 'field':
|
|
120
|
-
return 'Field';
|
|
121
|
-
case 'integer':
|
|
122
|
-
if (param.sign === 'signed') {
|
|
123
|
-
throw new Error('Unsupported type: signed integer');
|
|
124
|
-
}
|
|
125
|
-
return `u${param.width}`;
|
|
126
|
-
case 'boolean':
|
|
127
|
-
return 'bool';
|
|
128
|
-
case 'array':
|
|
129
|
-
return `[${this.getParameterType(param.type)};${param.length}]`;
|
|
130
|
-
case 'string':
|
|
131
|
-
return `str<${param.length}>`;
|
|
132
|
-
case 'struct':
|
|
133
|
-
return `(${param.fields.map((field)=>`${this.decodeParameter(field)}`).join(this.separator)})`;
|
|
134
|
-
default:
|
|
135
|
-
throw new Error(`Unsupported type: ${param.kind}`);
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
/**
|
|
139
|
-
* Decodes a single function parameter for the function signature.
|
|
140
|
-
* @param param - The parameter to decode.
|
|
141
|
-
* @returns A string representing the parameter type and optionally its name.
|
|
142
|
-
*/ decodeParameter(param) {
|
|
143
|
-
const type = this.getParameterType(param.type);
|
|
144
|
-
return this.includeNames ? `${param.name}: ${type}` : type;
|
|
145
|
-
}
|
|
146
|
-
/**
|
|
147
|
-
* Decodes all the parameters and build the function signature
|
|
148
|
-
* @returns The function signature.
|
|
149
|
-
*/ decode() {
|
|
150
|
-
return `${this.name}(${this.parameters.map((param)=>this.decodeParameter(param)).join(this.separator)})`;
|
|
151
|
-
}
|
|
152
|
-
}
|
|
153
|
-
/**
|
|
154
|
-
* Decodes a function signature from the name and parameters.
|
|
155
|
-
* @param name - The name of the function.
|
|
156
|
-
* @param parameters - The parameters of the function.
|
|
157
|
-
* @returns - The function signature.
|
|
158
|
-
*/ export function decodeFunctionSignature(name, parameters) {
|
|
159
|
-
return new FunctionSignatureDecoder(name, parameters).decode();
|
|
160
|
-
}
|
|
161
|
-
/**
|
|
162
|
-
* Decodes a function signature from the name and parameters including parameter names.
|
|
163
|
-
* @param name - The name of the function.
|
|
164
|
-
* @param parameters - The parameters of the function.
|
|
165
|
-
* @returns - The user-friendly function signature.
|
|
166
|
-
*/ export function decodeFunctionSignatureWithParameterNames(name, parameters) {
|
|
167
|
-
return new FunctionSignatureDecoder(name, parameters, true).decode();
|
|
168
|
-
}
|
package/dest/abi/encoder.d.ts
CHANGED
|
@@ -13,4 +13,4 @@ export declare function encodeArguments(abi: FunctionAbi, args: any[]): Fr[];
|
|
|
13
13
|
* @returns The size of the arguments.
|
|
14
14
|
*/
|
|
15
15
|
export declare function countArgumentsSize(abi: FunctionAbi): number;
|
|
16
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
16
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZW5jb2Rlci5kLnRzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vc3JjL2FiaS9lbmNvZGVyLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLE9BQU8sRUFBRSxFQUFFLEVBQUUsTUFBTSxnQ0FBZ0MsQ0FBQztBQUVwRCxPQUFPLEtBQUssRUFBVyxXQUFXLEVBQUUsTUFBTSxVQUFVLENBQUM7QUE2UXJEOzs7OztHQUtHO0FBQ0gsd0JBQWdCLGVBQWUsQ0FBQyxHQUFHLEVBQUUsV0FBVyxFQUFFLElBQUksRUFBRSxHQUFHLEVBQUUsUUFFNUQ7QUFFRDs7OztHQUlHO0FBQ0gsd0JBQWdCLGtCQUFrQixDQUFDLEdBQUcsRUFBRSxXQUFXLFVBRWxEIn0=
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"encoder.d.ts","sourceRoot":"","sources":["../../src/abi/encoder.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAE,MAAM,gCAAgC,CAAC;AAEpD,OAAO,KAAK,EAAW,WAAW,EAAE,MAAM,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"encoder.d.ts","sourceRoot":"","sources":["../../src/abi/encoder.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAE,MAAM,gCAAgC,CAAC;AAEpD,OAAO,KAAK,EAAW,WAAW,EAAE,MAAM,UAAU,CAAC;AA6QrD;;;;;GAKG;AACH,wBAAgB,eAAe,CAAC,GAAG,EAAE,WAAW,EAAE,IAAI,EAAE,GAAG,EAAE,QAE5D;AAED;;;;GAIG;AACH,wBAAgB,kBAAkB,CAAC,GAAG,EAAE,WAAW,UAElD"}
|
package/dest/abi/encoder.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
2
|
-
import { isAddressStruct, isBoundedVecStruct, isFunctionSelectorStruct, isWrappedFieldStruct } from './utils.js';
|
|
2
|
+
import { isAddressStruct, isBoundedVecStruct, isFunctionSelectorStruct, isOptionStruct, isWrappedFieldStruct } from './utils.js';
|
|
3
3
|
/**
|
|
4
4
|
* Encodes arguments for a function call.
|
|
5
5
|
* Missing support for integer and string.
|
|
@@ -39,6 +39,27 @@ import { isAddressStruct, isBoundedVecStruct, isFunctionSelectorStruct, isWrappe
|
|
|
39
39
|
* @param arg - The value to encode.
|
|
40
40
|
* @param name - Name.
|
|
41
41
|
*/ encodeArgument(abiType, arg, name) {
|
|
42
|
+
if (isOptionStruct(abiType)) {
|
|
43
|
+
const optionType = abiType;
|
|
44
|
+
const [isSomeField, valueField] = optionType.fields;
|
|
45
|
+
if (arg === undefined || arg === null) {
|
|
46
|
+
this.encodeArgument(isSomeField.type, false, `${name}._is_some`);
|
|
47
|
+
this.#encodeDefaultValue(valueField.type);
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
if (typeof arg === 'object' && '_is_some' in arg) {
|
|
51
|
+
this.encodeArgument(isSomeField.type, arg._is_some, `${name}._is_some`);
|
|
52
|
+
if (arg._is_some) {
|
|
53
|
+
this.encodeArgument(valueField.type, arg._value, `${name}._value`);
|
|
54
|
+
} else {
|
|
55
|
+
this.#encodeDefaultValue(valueField.type);
|
|
56
|
+
}
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
this.encodeArgument(isSomeField.type, true, `${name}._is_some`);
|
|
60
|
+
this.encodeArgument(valueField.type, arg, `${name}._value`);
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
42
63
|
if (arg === undefined || arg == null) {
|
|
43
64
|
throw new Error(`Undefined argument ${name ?? 'unnamed'} of type ${abiType.kind}`);
|
|
44
65
|
}
|
|
@@ -129,13 +150,17 @@ import { isAddressStruct, isBoundedVecStruct, isFunctionSelectorStruct, isWrappe
|
|
|
129
150
|
break;
|
|
130
151
|
}
|
|
131
152
|
case 'integer':
|
|
132
|
-
|
|
153
|
+
{
|
|
133
154
|
const value = BigInt(arg);
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
155
|
+
if (abiType.sign === 'signed' && value < 0n) {
|
|
156
|
+
// Convert negative values to two's complement representation
|
|
157
|
+
const twosComplement = value + (1n << BigInt(abiType.width));
|
|
158
|
+
this.flattened.push(new Fr(twosComplement));
|
|
159
|
+
} else {
|
|
160
|
+
this.flattened.push(new Fr(value));
|
|
161
|
+
}
|
|
162
|
+
break;
|
|
137
163
|
}
|
|
138
|
-
break;
|
|
139
164
|
default:
|
|
140
165
|
throw new Error(`Unsupported type: ${abiType.kind}`);
|
|
141
166
|
}
|
|
@@ -212,6 +237,12 @@ import { isAddressStruct, isBoundedVecStruct, isFunctionSelectorStruct, isWrappe
|
|
|
212
237
|
this.encodeArgument(lenField.type, arg.length, 'len');
|
|
213
238
|
}
|
|
214
239
|
}
|
|
240
|
+
/**
|
|
241
|
+
* Appends the flattened zero value for an ABI type.
|
|
242
|
+
* Option::None still serializes the wrapped value, so we need to zero-fill its footprint.
|
|
243
|
+
*/ #encodeDefaultValue(abiType) {
|
|
244
|
+
this.flattened.push(...new Array(ArgumentEncoder.typeSize(abiType)).fill(Fr.ZERO));
|
|
245
|
+
}
|
|
215
246
|
}
|
|
216
247
|
/**
|
|
217
248
|
* Encodes all the arguments for a function call.
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import type { AbiType } from './abi.js';
|
|
2
2
|
import type { EventSelector } from './event_selector.js';
|
|
3
|
+
/** Metadata for a contract event, used to decode emitted event logs back into structured data. */
|
|
3
4
|
export type EventMetadataDefinition = {
|
|
4
5
|
eventSelector: EventSelector;
|
|
5
6
|
abiType: AbiType;
|
|
7
|
+
/** Names of the event's struct members (not serialized Noir Field elements). */
|
|
6
8
|
fieldNames: string[];
|
|
7
9
|
};
|
|
8
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
10
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZXZlbnRfbWV0YWRhdGFfZGVmaW5pdGlvbi5kLnRzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vc3JjL2FiaS9ldmVudF9tZXRhZGF0YV9kZWZpbml0aW9uLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLE9BQU8sS0FBSyxFQUFFLE9BQU8sRUFBRSxNQUFNLFVBQVUsQ0FBQztBQUN4QyxPQUFPLEtBQUssRUFBRSxhQUFhLEVBQUUsTUFBTSxxQkFBcUIsQ0FBQztBQUV6RCxrR0FBa0c7QUFDbEcsTUFBTSxNQUFNLHVCQUF1QixHQUFHO0lBQ3BDLGFBQWEsRUFBRSxhQUFhLENBQUM7SUFDN0IsT0FBTyxFQUFFLE9BQU8sQ0FBQztJQUNqQixnRkFBZ0Y7SUFDaEYsVUFBVSxFQUFFLE1BQU0sRUFBRSxDQUFDO0NBQ3RCLENBQUMifQ==
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"event_metadata_definition.d.ts","sourceRoot":"","sources":["../../src/abi/event_metadata_definition.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,UAAU,CAAC;AACxC,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAEzD,MAAM,MAAM,uBAAuB,GAAG;IACpC,aAAa,EAAE,aAAa,CAAC;IAC7B,OAAO,EAAE,OAAO,CAAC;IACjB,UAAU,EAAE,MAAM,EAAE,CAAC;CACtB,CAAC"}
|
|
1
|
+
{"version":3,"file":"event_metadata_definition.d.ts","sourceRoot":"","sources":["../../src/abi/event_metadata_definition.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,UAAU,CAAC;AACxC,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAEzD,kGAAkG;AAClG,MAAM,MAAM,uBAAuB,GAAG;IACpC,aAAa,EAAE,aAAa,CAAC;IAC7B,OAAO,EAAE,OAAO,CAAC;IACjB,gFAAgF;IAChF,UAAU,EAAE,MAAM,EAAE,CAAC;CACtB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export { };
|
|
1
|
+
/** Metadata for a contract event, used to decode emitted event logs back into structured data. */ export { };
|
|
@@ -3,7 +3,7 @@ import { poseidon2HashBytes } from '@aztec/foundation/crypto/poseidon';
|
|
|
3
3
|
import { randomBytes } from '@aztec/foundation/crypto/random';
|
|
4
4
|
import { hexSchemaFor } from '@aztec/foundation/schemas';
|
|
5
5
|
import { BufferReader, FieldReader, TypeRegistry } from '@aztec/foundation/serialize';
|
|
6
|
-
import { decodeFunctionSignature } from './
|
|
6
|
+
import { decodeFunctionSignature } from './function_signature_decoder.js';
|
|
7
7
|
import { Selector } from './selector.js';
|
|
8
8
|
/** A function selector is the first 4 bytes of the hash of a function signature. */ export class FunctionSelector extends Selector {
|
|
9
9
|
/**
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import type { ABIParameter } from './abi.js';
|
|
2
|
+
/**
|
|
3
|
+
* Decodes the signature of a function from the name and parameters.
|
|
4
|
+
*/
|
|
5
|
+
export declare class FunctionSignatureDecoder {
|
|
6
|
+
private name;
|
|
7
|
+
private parameters;
|
|
8
|
+
private includeNames;
|
|
9
|
+
private separator;
|
|
10
|
+
constructor(name: string, parameters: ABIParameter[], includeNames?: boolean);
|
|
11
|
+
/**
|
|
12
|
+
* Decodes a single function parameter type for the function signature.
|
|
13
|
+
* @param param - The parameter type to decode.
|
|
14
|
+
* @returns A string representing the parameter type.
|
|
15
|
+
*/
|
|
16
|
+
private getParameterType;
|
|
17
|
+
/**
|
|
18
|
+
* Decodes a single function parameter for the function signature.
|
|
19
|
+
* @param param - The parameter to decode.
|
|
20
|
+
* @returns A string representing the parameter type and optionally its name.
|
|
21
|
+
*/
|
|
22
|
+
private decodeParameter;
|
|
23
|
+
/**
|
|
24
|
+
* Decodes all the parameters and build the function signature
|
|
25
|
+
* @returns The function signature.
|
|
26
|
+
*/
|
|
27
|
+
decode(): string;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Decodes a function signature from the name and parameters.
|
|
31
|
+
* @param name - The name of the function.
|
|
32
|
+
* @param parameters - The parameters of the function.
|
|
33
|
+
* @returns - The function signature.
|
|
34
|
+
*/
|
|
35
|
+
export declare function decodeFunctionSignature(name: string, parameters: ABIParameter[]): string;
|
|
36
|
+
/**
|
|
37
|
+
* Decodes a function signature from the name and parameters including parameter names.
|
|
38
|
+
* @param name - The name of the function.
|
|
39
|
+
* @param parameters - The parameters of the function.
|
|
40
|
+
* @returns - The user-friendly function signature.
|
|
41
|
+
*/
|
|
42
|
+
export declare function decodeFunctionSignatureWithParameterNames(name: string, parameters: ABIParameter[]): string;
|
|
43
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZnVuY3Rpb25fc2lnbmF0dXJlX2RlY29kZXIuZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9hYmkvZnVuY3Rpb25fc2lnbmF0dXJlX2RlY29kZXIudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsT0FBTyxLQUFLLEVBQUUsWUFBWSxFQUF3QixNQUFNLFVBQVUsQ0FBQztBQUVuRTs7R0FFRztBQUNILHFCQUFhLHdCQUF3QjtJQUdqQyxPQUFPLENBQUMsSUFBSTtJQUNaLE9BQU8sQ0FBQyxVQUFVO0lBQ2xCLE9BQU8sQ0FBQyxZQUFZO0lBSnRCLE9BQU8sQ0FBQyxTQUFTLENBQVM7SUFDMUIsWUFDVSxJQUFJLEVBQUUsTUFBTSxFQUNaLFVBQVUsRUFBRSxZQUFZLEVBQUUsRUFDMUIsWUFBWSxVQUFRLEVBRzdCO0lBRUQ7Ozs7T0FJRztJQUNILE9BQU8sQ0FBQyxnQkFBZ0I7SUFtQnhCOzs7O09BSUc7SUFDSCxPQUFPLENBQUMsZUFBZTtJQUt2Qjs7O09BR0c7SUFDSSxNQUFNLElBQUksTUFBTSxDQUV0QjtDQUNGO0FBRUQ7Ozs7O0dBS0c7QUFDSCx3QkFBZ0IsdUJBQXVCLENBQUMsSUFBSSxFQUFFLE1BQU0sRUFBRSxVQUFVLEVBQUUsWUFBWSxFQUFFLFVBRS9FO0FBRUQ7Ozs7O0dBS0c7QUFDSCx3QkFBZ0IseUNBQXlDLENBQUMsSUFBSSxFQUFFLE1BQU0sRUFBRSxVQUFVLEVBQUUsWUFBWSxFQUFFLFVBRWpHIn0=
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"function_signature_decoder.d.ts","sourceRoot":"","sources":["../../src/abi/function_signature_decoder.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAwB,MAAM,UAAU,CAAC;AAEnE;;GAEG;AACH,qBAAa,wBAAwB;IAGjC,OAAO,CAAC,IAAI;IACZ,OAAO,CAAC,UAAU;IAClB,OAAO,CAAC,YAAY;IAJtB,OAAO,CAAC,SAAS,CAAS;IAC1B,YACU,IAAI,EAAE,MAAM,EACZ,UAAU,EAAE,YAAY,EAAE,EAC1B,YAAY,UAAQ,EAG7B;IAED;;;;OAIG;IACH,OAAO,CAAC,gBAAgB;IAmBxB;;;;OAIG;IACH,OAAO,CAAC,eAAe;IAKvB;;;OAGG;IACI,MAAM,IAAI,MAAM,CAEtB;CACF;AAED;;;;;GAKG;AACH,wBAAgB,uBAAuB,CAAC,IAAI,EAAE,MAAM,EAAE,UAAU,EAAE,YAAY,EAAE,UAE/E;AAED;;;;;GAKG;AACH,wBAAgB,yCAAyC,CAAC,IAAI,EAAE,MAAM,EAAE,UAAU,EAAE,YAAY,EAAE,UAEjG"}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Decodes the signature of a function from the name and parameters.
|
|
3
|
+
*/ export class FunctionSignatureDecoder {
|
|
4
|
+
name;
|
|
5
|
+
parameters;
|
|
6
|
+
includeNames;
|
|
7
|
+
separator;
|
|
8
|
+
constructor(name, parameters, includeNames = false){
|
|
9
|
+
this.name = name;
|
|
10
|
+
this.parameters = parameters;
|
|
11
|
+
this.includeNames = includeNames;
|
|
12
|
+
this.separator = includeNames ? ', ' : ',';
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Decodes a single function parameter type for the function signature.
|
|
16
|
+
* @param param - The parameter type to decode.
|
|
17
|
+
* @returns A string representing the parameter type.
|
|
18
|
+
*/ getParameterType(param) {
|
|
19
|
+
switch(param.kind){
|
|
20
|
+
case 'field':
|
|
21
|
+
return 'Field';
|
|
22
|
+
case 'integer':
|
|
23
|
+
return param.sign === 'signed' ? `i${param.width}` : `u${param.width}`;
|
|
24
|
+
case 'boolean':
|
|
25
|
+
return 'bool';
|
|
26
|
+
case 'array':
|
|
27
|
+
return `[${this.getParameterType(param.type)};${param.length}]`;
|
|
28
|
+
case 'string':
|
|
29
|
+
return `str<${param.length}>`;
|
|
30
|
+
case 'struct':
|
|
31
|
+
return `(${param.fields.map((field)=>`${this.decodeParameter(field)}`).join(this.separator)})`;
|
|
32
|
+
default:
|
|
33
|
+
throw new Error(`Unsupported type: ${param.kind}`);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Decodes a single function parameter for the function signature.
|
|
38
|
+
* @param param - The parameter to decode.
|
|
39
|
+
* @returns A string representing the parameter type and optionally its name.
|
|
40
|
+
*/ decodeParameter(param) {
|
|
41
|
+
const type = this.getParameterType(param.type);
|
|
42
|
+
return this.includeNames ? `${param.name}: ${type}` : type;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Decodes all the parameters and build the function signature
|
|
46
|
+
* @returns The function signature.
|
|
47
|
+
*/ decode() {
|
|
48
|
+
return `${this.name}(${this.parameters.map((param)=>this.decodeParameter(param)).join(this.separator)})`;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Decodes a function signature from the name and parameters.
|
|
53
|
+
* @param name - The name of the function.
|
|
54
|
+
* @param parameters - The parameters of the function.
|
|
55
|
+
* @returns - The function signature.
|
|
56
|
+
*/ export function decodeFunctionSignature(name, parameters) {
|
|
57
|
+
return new FunctionSignatureDecoder(name, parameters).decode();
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Decodes a function signature from the name and parameters including parameter names.
|
|
61
|
+
* @param name - The name of the function.
|
|
62
|
+
* @param parameters - The parameters of the function.
|
|
63
|
+
* @returns - The user-friendly function signature.
|
|
64
|
+
*/ export function decodeFunctionSignatureWithParameterNames(name, parameters) {
|
|
65
|
+
return new FunctionSignatureDecoder(name, parameters, true).decode();
|
|
66
|
+
}
|
package/dest/abi/index.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export * from './abi.js';
|
|
2
2
|
export * from './buffer.js';
|
|
3
3
|
export * from './decoder.js';
|
|
4
|
+
export * from './function_signature_decoder.js';
|
|
4
5
|
export * from './encoder.js';
|
|
5
6
|
export * from './authorization_selector.js';
|
|
6
7
|
export * from './event_metadata_definition.js';
|
|
@@ -10,4 +11,4 @@ export * from './note_selector.js';
|
|
|
10
11
|
export * from './utils.js';
|
|
11
12
|
export * from './contract_artifact.js';
|
|
12
13
|
export * from './function_call.js';
|
|
13
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
14
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9hYmkvaW5kZXgudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsY0FBYyxVQUFVLENBQUM7QUFDekIsY0FBYyxhQUFhLENBQUM7QUFDNUIsY0FBYyxjQUFjLENBQUM7QUFDN0IsY0FBYyxpQ0FBaUMsQ0FBQztBQUNoRCxjQUFjLGNBQWMsQ0FBQztBQUM3QixjQUFjLDZCQUE2QixDQUFDO0FBQzVDLGNBQWMsZ0NBQWdDLENBQUM7QUFDL0MsY0FBYyxxQkFBcUIsQ0FBQztBQUNwQyxjQUFjLHdCQUF3QixDQUFDO0FBQ3ZDLGNBQWMsb0JBQW9CLENBQUM7QUFDbkMsY0FBYyxZQUFZLENBQUM7QUFDM0IsY0FBYyx3QkFBd0IsQ0FBQztBQUN2QyxjQUFjLG9CQUFvQixDQUFDIn0=
|
package/dest/abi/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/abi/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AACzB,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC;AAC7B,cAAc,cAAc,CAAC;AAC7B,cAAc,6BAA6B,CAAC;AAC5C,cAAc,gCAAgC,CAAC;AAC/C,cAAc,qBAAqB,CAAC;AACpC,cAAc,wBAAwB,CAAC;AACvC,cAAc,oBAAoB,CAAC;AACnC,cAAc,YAAY,CAAC;AAC3B,cAAc,wBAAwB,CAAC;AACvC,cAAc,oBAAoB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/abi/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AACzB,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC;AAC7B,cAAc,iCAAiC,CAAC;AAChD,cAAc,cAAc,CAAC;AAC7B,cAAc,6BAA6B,CAAC;AAC5C,cAAc,gCAAgC,CAAC;AAC/C,cAAc,qBAAqB,CAAC;AACpC,cAAc,wBAAwB,CAAC;AACvC,cAAc,oBAAoB,CAAC;AACnC,cAAc,YAAY,CAAC;AAC3B,cAAc,wBAAwB,CAAC;AACvC,cAAc,oBAAoB,CAAC"}
|
package/dest/abi/index.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export * from './abi.js';
|
|
2
2
|
export * from './buffer.js';
|
|
3
3
|
export * from './decoder.js';
|
|
4
|
+
export * from './function_signature_decoder.js';
|
|
4
5
|
export * from './encoder.js';
|
|
5
6
|
export * from './authorization_selector.js';
|
|
6
7
|
export * from './event_metadata_definition.js';
|
package/dest/abi/utils.d.ts
CHANGED
|
@@ -40,10 +40,23 @@ export declare function isPublicKeysStruct(abiType: AbiType): boolean;
|
|
|
40
40
|
* @returns A boolean indicating whether the ABI type is a BoundedVec struct.
|
|
41
41
|
*/
|
|
42
42
|
export declare function isBoundedVecStruct(abiType: AbiType): boolean;
|
|
43
|
+
/**
|
|
44
|
+
* Returns whether the ABI type is Noir's std::option::Option lowered to a struct.
|
|
45
|
+
* @param abiType - Type to check.
|
|
46
|
+
* @returns A boolean indicating whether the ABI type is an Option struct.
|
|
47
|
+
*/
|
|
48
|
+
export declare function isOptionStruct(abiType: AbiType): boolean;
|
|
49
|
+
/**
|
|
50
|
+
* Returns whether `null` or `undefined` can be mapped to a valid ABI value for this type.
|
|
51
|
+
*
|
|
52
|
+
* @param abiType - Type to check.
|
|
53
|
+
* @returns A boolean indicating whether nullish values are valid shorthand for this ABI type.
|
|
54
|
+
*/
|
|
55
|
+
export declare function canBeMappedFromNullOrUndefined(abiType: AbiType): boolean;
|
|
43
56
|
/**
|
|
44
57
|
* Returns a bigint by parsing a serialized 2's complement signed int.
|
|
45
58
|
* @param b - The signed int as a buffer
|
|
46
59
|
* @returns - a deserialized bigint
|
|
47
60
|
*/
|
|
48
61
|
export declare function parseSignedInt(b: Buffer, width?: number): bigint;
|
|
49
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
62
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidXRpbHMuZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9hYmkvdXRpbHMudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsT0FBTyxLQUFLLEVBQUUsT0FBTyxFQUFFLE1BQU0sVUFBVSxDQUFDO0FBRXhDOzs7O0dBSUc7QUFDSCx3QkFBZ0IsZUFBZSxDQUFDLE9BQU8sRUFBRSxPQUFPLFdBRS9DO0FBRUQ7Ozs7R0FJRztBQUNILHdCQUFnQixrQkFBa0IsQ0FBQyxPQUFPLEVBQUUsT0FBTyxXQUVsRDtBQUVEOzs7O0dBSUc7QUFDSCx3QkFBZ0Isb0JBQW9CLENBQUMsT0FBTyxFQUFFLE9BQU8sV0FFcEQ7QUFFRDs7OztHQUlHO0FBQ0gsd0JBQWdCLHdCQUF3QixDQUFDLE9BQU8sRUFBRSxPQUFPLFdBRXhEO0FBRUQ7OztHQUdHO0FBQ0gsd0JBQWdCLG9CQUFvQixDQUFDLE9BQU8sRUFBRSxPQUFPLFdBT3BEO0FBRUQ7Ozs7R0FJRztBQUNILHdCQUFnQixrQkFBa0IsQ0FBQyxPQUFPLEVBQUUsT0FBTyxXQVVsRDtBQUVEOzs7O0dBSUc7QUFDSCx3QkFBZ0Isa0JBQWtCLENBQUMsT0FBTyxFQUFFLE9BQU8sV0FRbEQ7QUFFRDs7OztHQUlHO0FBQ0gsd0JBQWdCLGNBQWMsQ0FBQyxPQUFPLEVBQUUsT0FBTyxXQVE5QztBQUVEOzs7OztHQUtHO0FBQ0gsd0JBQWdCLDhCQUE4QixDQUFDLE9BQU8sRUFBRSxPQUFPLFdBRTlEO0FBRUQ7Ozs7R0FJRztBQUNILHdCQUFnQixjQUFjLENBQUMsQ0FBQyxFQUFFLE1BQU0sRUFBRSxLQUFLLENBQUMsRUFBRSxNQUFNLFVBcUJ2RCJ9
|
package/dest/abi/utils.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/abi/utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,UAAU,CAAC;AAExC;;;;GAIG;AACH,wBAAgB,eAAe,CAAC,OAAO,EAAE,OAAO,WAE/C;AAED;;;;GAIG;AACH,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,OAAO,WAElD;AAED;;;;GAIG;AACH,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,OAAO,WAEpD;AAED;;;;GAIG;AACH,wBAAgB,wBAAwB,CAAC,OAAO,EAAE,OAAO,WAExD;AAED;;;GAGG;AACH,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,OAAO,WAOpD;AAED;;;;GAIG;AACH,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,OAAO,WAUlD;AAED;;;;GAIG;AACH,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,OAAO,WAQlD;AAED;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,CAAC,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM,UAqBvD"}
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/abi/utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,UAAU,CAAC;AAExC;;;;GAIG;AACH,wBAAgB,eAAe,CAAC,OAAO,EAAE,OAAO,WAE/C;AAED;;;;GAIG;AACH,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,OAAO,WAElD;AAED;;;;GAIG;AACH,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,OAAO,WAEpD;AAED;;;;GAIG;AACH,wBAAgB,wBAAwB,CAAC,OAAO,EAAE,OAAO,WAExD;AAED;;;GAGG;AACH,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,OAAO,WAOpD;AAED;;;;GAIG;AACH,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,OAAO,WAUlD;AAED;;;;GAIG;AACH,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,OAAO,WAQlD;AAED;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,OAAO,EAAE,OAAO,WAQ9C;AAED;;;;;GAKG;AACH,wBAAgB,8BAA8B,CAAC,OAAO,EAAE,OAAO,WAE9D;AAED;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,CAAC,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM,UAqBvD"}
|
package/dest/abi/utils.js
CHANGED
|
@@ -46,6 +46,21 @@
|
|
|
46
46
|
*/ export function isBoundedVecStruct(abiType) {
|
|
47
47
|
return abiType.kind === 'struct' && abiType.path === 'std::collections::bounded_vec::BoundedVec' && abiType.fields.length === 2 && abiType.fields[0].name === 'storage' && abiType.fields[1].name === 'len';
|
|
48
48
|
}
|
|
49
|
+
/**
|
|
50
|
+
* Returns whether the ABI type is Noir's std::option::Option lowered to a struct.
|
|
51
|
+
* @param abiType - Type to check.
|
|
52
|
+
* @returns A boolean indicating whether the ABI type is an Option struct.
|
|
53
|
+
*/ export function isOptionStruct(abiType) {
|
|
54
|
+
return abiType.kind === 'struct' && abiType.path === 'std::option::Option' && abiType.fields.length === 2 && abiType.fields[0].name === '_is_some' && abiType.fields[1].name === '_value';
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Returns whether `null` or `undefined` can be mapped to a valid ABI value for this type.
|
|
58
|
+
*
|
|
59
|
+
* @param abiType - Type to check.
|
|
60
|
+
* @returns A boolean indicating whether nullish values are valid shorthand for this ABI type.
|
|
61
|
+
*/ export function canBeMappedFromNullOrUndefined(abiType) {
|
|
62
|
+
return isOptionStruct(abiType);
|
|
63
|
+
}
|
|
49
64
|
/**
|
|
50
65
|
* Returns a bigint by parsing a serialized 2's complement signed int.
|
|
51
66
|
* @param b - The signed int as a buffer
|