@aztec/stdlib 0.0.1-commit.d1cd2107c → 0.0.1-commit.d1da697d6
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 +138 -1
- package/dest/abi/abi.d.ts.map +1 -1
- package/dest/abi/abi.js +10 -2
- 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 +5 -44
- package/dest/abi/decoder.d.ts.map +1 -1
- package/dest/abi/decoder.js +12 -67
- 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/selector.d.ts +2 -2
- package/dest/abi/selector.d.ts.map +1 -1
- package/dest/abi/selector.js +1 -1
- package/dest/avm/avm.d.ts +300 -300
- package/dest/avm/revert_code.d.ts +8 -18
- package/dest/avm/revert_code.d.ts.map +1 -1
- package/dest/avm/revert_code.js +15 -30
- package/dest/block/l2_block_source.d.ts +90 -10
- package/dest/block/l2_block_source.d.ts.map +1 -1
- package/dest/block/l2_block_source.js +1 -0
- package/dest/block/l2_block_stream/l2_tips_store_base.d.ts +1 -1
- package/dest/block/l2_block_stream/l2_tips_store_base.d.ts.map +1 -1
- package/dest/block/l2_block_stream/l2_tips_store_base.js +17 -4
- package/dest/block/test/l2_tips_store_test_suite.d.ts +1 -1
- package/dest/block/test/l2_tips_store_test_suite.d.ts.map +1 -1
- package/dest/block/test/l2_tips_store_test_suite.js +3 -2
- package/dest/checkpoint/checkpoint.d.ts +7 -1
- package/dest/checkpoint/checkpoint.d.ts.map +1 -1
- package/dest/checkpoint/checkpoint.js +9 -1
- package/dest/checkpoint/checkpoint_data.d.ts +71 -5
- package/dest/checkpoint/checkpoint_data.d.ts.map +1 -1
- package/dest/checkpoint/checkpoint_data.js +10 -0
- package/dest/checkpoint/validate.js +2 -2
- package/dest/config/index.d.ts +2 -1
- package/dest/config/index.d.ts.map +1 -1
- package/dest/config/index.js +1 -0
- package/dest/config/pipelining-config.d.ts +19 -0
- package/dest/config/pipelining-config.d.ts.map +1 -0
- package/dest/config/pipelining-config.js +18 -0
- package/dest/contract/contract_address.d.ts +3 -3
- package/dest/contract/contract_address.js +3 -3
- package/dest/contract/contract_class_id.d.ts +2 -2
- package/dest/contract/contract_class_id.js +2 -2
- package/dest/contract/index.d.ts +1 -3
- package/dest/contract/index.d.ts.map +1 -1
- package/dest/contract/index.js +0 -2
- package/dest/contract/interfaces/contract_class.d.ts +3 -156
- package/dest/contract/interfaces/contract_class.d.ts.map +1 -1
- package/dest/contract/interfaces/contract_class.js +1 -28
- package/dest/epoch-helpers/index.d.ts +11 -1
- package/dest/epoch-helpers/index.d.ts.map +1 -1
- package/dest/epoch-helpers/index.js +16 -2
- package/dest/file-store/factory.d.ts +4 -3
- package/dest/file-store/factory.d.ts.map +1 -1
- package/dest/file-store/factory.js +2 -2
- package/dest/file-store/http.d.ts +9 -2
- package/dest/file-store/http.d.ts.map +1 -1
- package/dest/file-store/http.js +20 -9
- package/dest/file-store/index.d.ts +2 -1
- package/dest/file-store/index.d.ts.map +1 -1
- package/dest/gas/gas_settings.d.ts +40 -3
- package/dest/gas/gas_settings.d.ts.map +1 -1
- package/dest/gas/gas_settings.js +50 -6
- 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/archiver.d.ts +1 -1
- package/dest/interfaces/archiver.d.ts.map +1 -1
- package/dest/interfaces/archiver.js +5 -3
- package/dest/interfaces/aztec-node-admin.d.ts +10 -6
- package/dest/interfaces/aztec-node-admin.d.ts.map +1 -1
- package/dest/interfaces/aztec-node-admin.js +2 -1
- package/dest/interfaces/aztec-node.d.ts +3 -2
- package/dest/interfaces/aztec-node.d.ts.map +1 -1
- package/dest/interfaces/aztec-node.js +2 -0
- package/dest/interfaces/block-builder.d.ts +32 -11
- package/dest/interfaces/block-builder.d.ts.map +1 -1
- package/dest/interfaces/block-builder.js +6 -4
- package/dest/interfaces/configs.d.ts +7 -2
- package/dest/interfaces/configs.d.ts.map +1 -1
- package/dest/interfaces/configs.js +1 -0
- package/dest/interfaces/l2_logs_source.d.ts +5 -3
- package/dest/interfaces/l2_logs_source.d.ts.map +1 -1
- package/dest/interfaces/merkle_tree_operations.d.ts +9 -19
- package/dest/interfaces/merkle_tree_operations.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/proving-job.d.ts +200 -200
- package/dest/interfaces/validator.d.ts +2 -10
- package/dest/interfaces/validator.d.ts.map +1 -1
- package/dest/interfaces/validator.js +0 -1
- package/dest/interfaces/world_state.d.ts +5 -4
- package/dest/interfaces/world_state.d.ts.map +1 -1
- package/dest/logs/extended_directional_app_tagging_secret.d.ts +4 -4
- package/dest/logs/extended_directional_app_tagging_secret.d.ts.map +1 -1
- package/dest/logs/extended_directional_app_tagging_secret.js +12 -5
- package/dest/logs/index.d.ts +2 -1
- package/dest/logs/index.d.ts.map +1 -1
- package/dest/logs/index.js +1 -0
- 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/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 +4 -1
- package/dest/logs/siloed_tag.d.ts.map +1 -1
- package/dest/logs/siloed_tag.js +7 -3
- 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/l1_to_l2_message_source.d.ts +4 -2
- package/dest/messaging/l1_to_l2_message_source.d.ts.map +1 -1
- 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/checkpoint_proposal.d.ts +1 -1
- package/dest/p2p/checkpoint_proposal.d.ts.map +1 -1
- package/dest/p2p/checkpoint_proposal.js +13 -11
- package/dest/proofs/chonk_proof.d.ts +46 -2
- package/dest/proofs/chonk_proof.d.ts.map +1 -1
- package/dest/proofs/chonk_proof.js +85 -10
- package/dest/tests/factories.d.ts +2 -4
- package/dest/tests/factories.d.ts.map +1 -1
- package/dest/tests/factories.js +11 -28
- package/dest/tests/mocks.d.ts +1 -1
- package/dest/tests/mocks.d.ts.map +1 -1
- package/dest/tests/mocks.js +2 -2
- 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/global_variable_builder.d.ts +14 -2
- package/dest/tx/global_variable_builder.d.ts.map +1 -1
- 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 +14 -2
- package/dest/tx/profiling.d.ts.map +1 -1
- package/dest/tx/profiling.js +13 -3
- package/dest/tx/simulated_tx.d.ts +111 -3
- package/dest/tx/simulated_tx.d.ts.map +1 -1
- package/dest/tx/simulated_tx.js +2 -2
- package/dest/tx/tx_receipt.d.ts +14 -5
- package/dest/tx/tx_receipt.d.ts.map +1 -1
- package/dest/tx/tx_receipt.js +14 -18
- package/dest/tx/validator/error_texts.d.ts +5 -1
- package/dest/tx/validator/error_texts.d.ts.map +1 -1
- package/dest/tx/validator/error_texts.js +6 -0
- package/dest/update-checker/package_version.d.ts +2 -2
- package/dest/update-checker/package_version.d.ts.map +1 -1
- package/dest/update-checker/package_version.js +16 -3
- 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/package.json +8 -8
- package/src/abi/abi.ts +25 -2
- package/src/abi/buffer.ts +25 -4
- package/src/abi/decoder.ts +23 -78
- 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/selector.ts +1 -1
- package/src/avm/revert_code.ts +25 -39
- package/src/block/l2_block_source.ts +20 -9
- package/src/block/l2_block_stream/l2_tips_store_base.ts +24 -12
- package/src/block/test/l2_tips_store_test_suite.ts +8 -1
- package/src/checkpoint/checkpoint.ts +11 -1
- package/src/checkpoint/checkpoint_data.ts +40 -4
- package/src/checkpoint/validate.ts +2 -2
- package/src/config/index.ts +1 -0
- package/src/config/pipelining-config.ts +31 -0
- package/src/contract/contract_address.ts +3 -3
- package/src/contract/contract_class_id.ts +2 -2
- package/src/contract/index.ts +0 -2
- package/src/contract/interfaces/contract_class.ts +2 -82
- package/src/epoch-helpers/index.ts +27 -0
- package/src/file-store/factory.ts +13 -4
- package/src/file-store/http.ts +29 -10
- package/src/file-store/index.ts +1 -0
- package/src/gas/README.md +123 -0
- package/src/gas/gas_settings.ts +65 -12
- package/src/hash/hash.ts +34 -0
- package/src/interfaces/archiver.ts +5 -3
- package/src/interfaces/aztec-node-admin.ts +4 -3
- package/src/interfaces/aztec-node.ts +10 -1
- package/src/interfaces/block-builder.ts +39 -13
- package/src/interfaces/configs.ts +4 -1
- package/src/interfaces/l2_logs_source.ts +4 -1
- package/src/interfaces/merkle_tree_operations.ts +8 -18
- package/src/interfaces/prover-client.ts +8 -0
- package/src/interfaces/validator.ts +1 -5
- package/src/interfaces/world_state.ts +4 -3
- package/src/logs/extended_directional_app_tagging_secret.ts +19 -8
- package/src/logs/index.ts +1 -0
- 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/shared_secret_derivation.ts +21 -10
- package/src/logs/siloed_tag.ts +7 -2
- 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/l1_to_l2_message_source.ts +3 -1
- 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/checkpoint_proposal.ts +23 -20
- package/src/proofs/chonk_proof.ts +91 -5
- package/src/tests/factories.ts +5 -34
- package/src/tests/mocks.ts +2 -2
- package/src/tx/capsule.ts +10 -2
- package/src/tx/global_variable_builder.ts +15 -0
- package/src/tx/private_execution_result.ts +5 -5
- package/src/tx/profiling.ts +11 -2
- package/src/tx/simulated_tx.ts +5 -1
- package/src/tx/tx_receipt.ts +18 -16
- package/src/tx/validator/error_texts.ts +8 -0
- package/src/update-checker/package_version.ts +19 -6
- package/src/validators/errors.ts +9 -0
- package/src/versioning/versioning.ts +4 -1
- package/dest/contract/private_function_membership_proof.d.ts +0 -32
- package/dest/contract/private_function_membership_proof.d.ts.map +0 -1
- package/dest/contract/private_function_membership_proof.js +0 -124
- package/dest/contract/utility_function_membership_proof.d.ts +0 -27
- package/dest/contract/utility_function_membership_proof.d.ts.map +0 -1
- package/dest/contract/utility_function_membership_proof.js +0 -87
- package/src/contract/private_function_membership_proof.ts +0 -167
- package/src/contract/utility_function_membership_proof.ts +0 -118
package/dest/tx/tx_receipt.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import { BlockNumberSchema } from '@aztec/foundation/branded-types';
|
|
1
|
+
import { BlockNumberSchema, EpochNumberSchema } from '@aztec/foundation/branded-types';
|
|
2
2
|
import { z } from 'zod';
|
|
3
|
-
import { RevertCode } from '../avm/revert_code.js';
|
|
4
3
|
import { BlockHash } from '../block/block_hash.js';
|
|
5
4
|
import { DebugLog } from '../logs/debug_log.js';
|
|
6
5
|
import { schemas } from '../schemas/schemas.js';
|
|
@@ -24,9 +23,13 @@ import { TxHash } from './tx_hash.js';
|
|
|
24
23
|
];
|
|
25
24
|
/** Execution result - only set when tx is in a block. */ export var TxExecutionResult = /*#__PURE__*/ function(TxExecutionResult) {
|
|
26
25
|
TxExecutionResult["SUCCESS"] = "success";
|
|
27
|
-
TxExecutionResult["
|
|
28
|
-
|
|
29
|
-
TxExecutionResult["
|
|
26
|
+
TxExecutionResult["REVERTED"] = "reverted";
|
|
27
|
+
/** @deprecated Use REVERTED instead. */ // eslint-disable-next-line @typescript-eslint/no-duplicate-enum-values
|
|
28
|
+
TxExecutionResult["APP_LOGIC_REVERTED"] = "reverted";
|
|
29
|
+
/** @deprecated Use REVERTED instead. */ // eslint-disable-next-line @typescript-eslint/no-duplicate-enum-values
|
|
30
|
+
TxExecutionResult["TEARDOWN_REVERTED"] = "reverted";
|
|
31
|
+
/** @deprecated Use REVERTED instead. */ // eslint-disable-next-line @typescript-eslint/no-duplicate-enum-values
|
|
32
|
+
TxExecutionResult["BOTH_REVERTED"] = "reverted";
|
|
30
33
|
return TxExecutionResult;
|
|
31
34
|
}({});
|
|
32
35
|
/**
|
|
@@ -42,8 +45,9 @@ import { TxHash } from './tx_hash.js';
|
|
|
42
45
|
transactionFee;
|
|
43
46
|
blockHash;
|
|
44
47
|
blockNumber;
|
|
48
|
+
epochNumber;
|
|
45
49
|
debugLogs;
|
|
46
|
-
constructor(/** A unique identifier for a transaction. */ txHash, /** The transaction's block finalization status. */ status, /** The execution result of the transaction, only set when tx is in a block. */ executionResult, /** Description of transaction error, if any. */ error, /** The transaction fee paid for the transaction. */ transactionFee, /** The hash of the block containing the transaction. */ blockHash, /** The block number in which the transaction was included. */ blockNumber, /**
|
|
50
|
+
constructor(/** A unique identifier for a transaction. */ txHash, /** The transaction's block finalization status. */ status, /** The execution result of the transaction, only set when tx is in a block. */ executionResult, /** Description of transaction error, if any. */ error, /** The transaction fee paid for the transaction. */ transactionFee, /** The hash of the block containing the transaction. */ blockHash, /** The block number in which the transaction was included. */ blockNumber, /** The epoch number in which the transaction was included. */ epochNumber, /**
|
|
47
51
|
* Debug logs collected during public function execution. Served only when the node is in test mode and placed on
|
|
48
52
|
* the receipt only because it's a convenient place for it (the logs are printed out by the wallet when a mined
|
|
49
53
|
* tx receipt is obtained).
|
|
@@ -55,6 +59,7 @@ import { TxHash } from './tx_hash.js';
|
|
|
55
59
|
this.transactionFee = transactionFee;
|
|
56
60
|
this.blockHash = blockHash;
|
|
57
61
|
this.blockNumber = blockNumber;
|
|
62
|
+
this.epochNumber = epochNumber;
|
|
58
63
|
this.debugLogs = debugLogs;
|
|
59
64
|
}
|
|
60
65
|
/** Returns true if the transaction was executed successfully. */ hasExecutionSucceeded() {
|
|
@@ -83,24 +88,15 @@ import { TxHash } from './tx_hash.js';
|
|
|
83
88
|
error: z.string().optional(),
|
|
84
89
|
blockHash: BlockHash.schema.optional(),
|
|
85
90
|
blockNumber: BlockNumberSchema.optional(),
|
|
91
|
+
epochNumber: EpochNumberSchema.optional(),
|
|
86
92
|
transactionFee: schemas.BigInt.optional(),
|
|
87
93
|
debugLogs: z.array(DebugLog.schema).optional()
|
|
88
94
|
}).transform((fields)=>TxReceipt.from(fields));
|
|
89
95
|
}
|
|
90
96
|
static from(fields) {
|
|
91
|
-
return new TxReceipt(fields.txHash, fields.status, fields.executionResult, fields.error, fields.transactionFee, fields.blockHash, fields.blockNumber, fields.debugLogs);
|
|
97
|
+
return new TxReceipt(fields.txHash, fields.status, fields.executionResult, fields.error, fields.transactionFee, fields.blockHash, fields.blockNumber, fields.epochNumber, fields.debugLogs);
|
|
92
98
|
}
|
|
93
99
|
static executionResultFromRevertCode(revertCode) {
|
|
94
|
-
|
|
95
|
-
return "success";
|
|
96
|
-
} else if (revertCode.equals(RevertCode.APP_LOGIC_REVERTED)) {
|
|
97
|
-
return "app_logic_reverted";
|
|
98
|
-
} else if (revertCode.equals(RevertCode.TEARDOWN_REVERTED)) {
|
|
99
|
-
return "teardown_reverted";
|
|
100
|
-
} else if (revertCode.equals(RevertCode.BOTH_REVERTED)) {
|
|
101
|
-
return "both_reverted";
|
|
102
|
-
} else {
|
|
103
|
-
throw new Error(`Unknown revert code: ${revertCode.getCode()}`);
|
|
104
|
-
}
|
|
100
|
+
return revertCode.isOK() ? "success" : "reverted";
|
|
105
101
|
}
|
|
106
102
|
}
|
|
@@ -25,5 +25,9 @@ export declare const TX_ERROR_CONTRACT_CLASS_LOG_SORTING = "Incorrectly sorted c
|
|
|
25
25
|
export declare const TX_ERROR_INCORRECT_HASH = "Incorrect tx hash";
|
|
26
26
|
export declare const TX_ERROR_SIZE_ABOVE_LIMIT = "Transaction size above size limit";
|
|
27
27
|
export declare const TX_ERROR_BLOCK_HEADER = "Block header not found";
|
|
28
|
+
export declare const TX_ERROR_INCORRECT_CONTRACT_ADDRESS = "Incorrect contract instance deployment address";
|
|
29
|
+
export declare const TX_ERROR_MALFORMED_CONTRACT_INSTANCE_LOG = "Failed to parse contract instance deployment log";
|
|
30
|
+
export declare const TX_ERROR_INCORRECT_CONTRACT_CLASS_ID = "Incorrect contract class id";
|
|
31
|
+
export declare const TX_ERROR_MALFORMED_CONTRACT_CLASS_LOG = "Failed to parse contract class registration log";
|
|
28
32
|
export declare const TX_ERROR_DURING_VALIDATION = "Unexpected error during validation";
|
|
29
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
33
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZXJyb3JfdGV4dHMuZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uL3NyYy90eC92YWxpZGF0b3IvZXJyb3JfdGV4dHMudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQ0EsZUFBTyxNQUFNLGlDQUFpQyw2QkFBNkIsQ0FBQztBQUM1RSxlQUFPLE1BQU0sdUNBQXVDLG1DQUFtQyxDQUFDO0FBQ3hGLGVBQU8sTUFBTSwrQkFBK0IsOENBQThDLENBQUM7QUFDM0YsZUFBTyxNQUFNLDJCQUEyQix3RUFBd0UsQ0FBQztBQUdqSCxlQUFPLE1BQU0sbUNBQW1DLHFDQUFxQyxDQUFDO0FBQ3RGLGVBQU8sTUFBTSx3Q0FBd0MsNENBQTRDLENBQUM7QUFDbEcsZUFBTyxNQUFNLHFDQUFxQyw4REFBOEQsQ0FBQztBQUNqSCxlQUFPLE1BQU0sOEJBQThCLCtDQUErQyxDQUFDO0FBQzNGLGVBQU8sTUFBTSxvQ0FBb0MscURBQXFELENBQUM7QUFHdkcsZUFBTyxNQUFNLGtDQUFrQyw4QkFBOEIsQ0FBQztBQUM5RSxlQUFPLE1BQU0sMkJBQTJCLHVCQUF1QixDQUFDO0FBR2hFLGVBQU8sTUFBTSxxQ0FBcUMsaUNBQWlDLENBQUM7QUFDcEYsZUFBTyxNQUFNLDhCQUE4QiwwQkFBMEIsQ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CAAqC,oDAAoD,CAAC;AAGvG,eAAO,MAAM,0BAA0B,uCAAuC,CAAC"}
|
|
@@ -33,5 +33,11 @@ export const TX_ERROR_INCORRECT_HASH = 'Incorrect tx hash';
|
|
|
33
33
|
export const TX_ERROR_SIZE_ABOVE_LIMIT = 'Transaction size above size limit';
|
|
34
34
|
// Block header
|
|
35
35
|
export const TX_ERROR_BLOCK_HEADER = 'Block header not found';
|
|
36
|
+
// Contract instance
|
|
37
|
+
export const TX_ERROR_INCORRECT_CONTRACT_ADDRESS = 'Incorrect contract instance deployment address';
|
|
38
|
+
export const TX_ERROR_MALFORMED_CONTRACT_INSTANCE_LOG = 'Failed to parse contract instance deployment log';
|
|
39
|
+
// Contract class
|
|
40
|
+
export const TX_ERROR_INCORRECT_CONTRACT_CLASS_ID = 'Incorrect contract class id';
|
|
41
|
+
export const TX_ERROR_MALFORMED_CONTRACT_CLASS_LOG = 'Failed to parse contract class registration log';
|
|
36
42
|
// General
|
|
37
43
|
export const TX_ERROR_DURING_VALIDATION = 'Unexpected error during validation';
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
/** Returns the package version from the release-please manifest, or undefined if not found. */
|
|
1
|
+
/** Returns the package version from the release-please manifest or the package.json, or undefined if not found. */
|
|
2
2
|
export declare function getPackageVersion(): string | undefined;
|
|
3
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
3
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicGFja2FnZV92ZXJzaW9uLmQudHMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvdXBkYXRlLWNoZWNrZXIvcGFja2FnZV92ZXJzaW9uLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUtBLG1IQUFtSDtBQUNuSCx3QkFBZ0IsaUJBQWlCLElBQUksTUFBTSxHQUFHLFNBQVMsQ0F1QnREIn0=
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"package_version.d.ts","sourceRoot":"","sources":["../../src/update-checker/package_version.ts"],"names":[],"mappings":"AAKA
|
|
1
|
+
{"version":3,"file":"package_version.d.ts","sourceRoot":"","sources":["../../src/update-checker/package_version.ts"],"names":[],"mappings":"AAKA,mHAAmH;AACnH,wBAAgB,iBAAiB,IAAI,MAAM,GAAG,SAAS,CAuBtD"}
|
|
@@ -1,11 +1,24 @@
|
|
|
1
1
|
import { fileURLToPath } from '@aztec/foundation/url';
|
|
2
2
|
import { readFileSync } from 'fs';
|
|
3
3
|
import { dirname, resolve } from 'path';
|
|
4
|
-
/** Returns the package version from the release-please manifest, or undefined if not found. */ export function getPackageVersion() {
|
|
4
|
+
/** Returns the package version from the release-please manifest or the package.json, or undefined if not found. */ export function getPackageVersion() {
|
|
5
|
+
const dir = dirname(fileURLToPath(import.meta.url));
|
|
6
|
+
// Try the release-please manifest first (works in dev/repo checkout).
|
|
5
7
|
try {
|
|
6
|
-
const releasePleaseManifestPath = resolve(
|
|
8
|
+
const releasePleaseManifestPath = resolve(dir, '../../../../.release-please-manifest.json');
|
|
7
9
|
return JSON.parse(readFileSync(releasePleaseManifestPath).toString())['.'];
|
|
8
10
|
} catch {
|
|
9
|
-
|
|
11
|
+
// Not in a repo checkout, fall through.
|
|
10
12
|
}
|
|
13
|
+
// Fall back to the stdlib package.json version (works in npm-installed packages).
|
|
14
|
+
try {
|
|
15
|
+
const packageJsonPath = resolve(dir, '../../package.json');
|
|
16
|
+
const version = JSON.parse(readFileSync(packageJsonPath).toString()).version;
|
|
17
|
+
if (version && version !== '0.1.0') {
|
|
18
|
+
return version;
|
|
19
|
+
}
|
|
20
|
+
} catch {
|
|
21
|
+
// No package.json found either.
|
|
22
|
+
}
|
|
23
|
+
return undefined;
|
|
11
24
|
}
|
|
@@ -19,6 +19,11 @@ export declare class TransactionsNotAvailableError extends ValidatorError {
|
|
|
19
19
|
export declare class FailedToReExecuteTransactionsError extends ValidatorError {
|
|
20
20
|
constructor(txHashes: TxHash[]);
|
|
21
21
|
}
|
|
22
|
+
export declare class ReExInitialStateMismatchError extends ValidatorError {
|
|
23
|
+
readonly expectedArchiveRoot: Fr;
|
|
24
|
+
readonly actualArchiveRoot: Fr;
|
|
25
|
+
constructor(expectedArchiveRoot: Fr, actualArchiveRoot: Fr);
|
|
26
|
+
}
|
|
22
27
|
export declare class ReExStateMismatchError extends ValidatorError {
|
|
23
28
|
readonly expectedArchiveRoot: Fr;
|
|
24
29
|
readonly actualArchiveRoot: Fr;
|
|
@@ -30,4 +35,4 @@ export declare class ReExFailedTxsError extends ValidatorError {
|
|
|
30
35
|
export declare class ReExTimeoutError extends ValidatorError {
|
|
31
36
|
constructor();
|
|
32
37
|
}
|
|
33
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
38
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZXJyb3JzLmQudHMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvdmFsaWRhdG9ycy9lcnJvcnMudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsT0FBTyxLQUFLLEVBQUUsVUFBVSxFQUFFLE1BQU0saUNBQWlDLENBQUM7QUFDbEUsT0FBTyxLQUFLLEVBQUUsRUFBRSxFQUFFLE1BQU0sZ0NBQWdDLENBQUM7QUFDekQsT0FBTyxLQUFLLEVBQUUsTUFBTSxFQUFFLE1BQU0sa0JBQWtCLENBQUM7QUFFL0MscUJBQWEsY0FBZSxTQUFRLEtBQUs7SUFDdkMsWUFBWSxPQUFPLEVBQUUsTUFBTSxFQUUxQjtDQUNGO0FBRUQscUJBQWEsK0JBQWdDLFNBQVEsY0FBYztJQUNqRSxjQUVDO0NBQ0Y7QUFFRCxxQkFBYSx1QkFBd0IsU0FBUSxjQUFjO2FBRXZDLGNBQWMsRUFBRSxNQUFNO2FBQ3RCLGFBQWEsRUFBRSxNQUFNO2FBQ3JCLElBQUksRUFBRSxVQUFV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AAE,MAAM;aACrB,IAAI,EAAE,UAAU;IAHlC,YACkB,cAAc,EAAE,MAAM,EACtB,aAAa,EAAE,MAAM,EACrB,IAAI,EAAE,UAAU,EAGjC;CACF;AAED,qBAAa,6BAA8B,SAAQ,cAAc;IAC/D,YAAY,QAAQ,EAAE,MAAM,EAAE,EAE7B;CACF;AAED,qBAAa,kCAAmC,SAAQ,cAAc;IACpE,YAAY,QAAQ,EAAE,MAAM,EAAE,EAE7B;CACF;AAED,qBAAa,6BAA8B,SAAQ,cAAc;aAE7C,mBAAmB,EAAE,EAAE;aACvB,iBAAiB,EAAE,EAAE;IAFvC,YACkB,mBAAmB,EAAE,EAAE,EACvB,iBAAiB,EAAE,EAAE,EAGtC;CACF;AAED,qBAAa,sBAAuB,SAAQ,cAAc;aAEtC,mBAAmB,EAAE,EAAE;aACvB,iBAAiB,EAAE,EAAE;IAFvC,YACkB,mBAAmB,EAAE,EAAE,EACvB,iBAAiB,EAAE,EAAE,EAGtC;CACF;AAED,qBAAa,kBAAmB,SAAQ,cAAc;IACpD,YAAY,YAAY,EAAE,MAAM,EAE/B;CACF;AAED,qBAAa,gBAAiB,SAAQ,cAAc;IAClD,cAEC;CACF"}
|
|
@@ -26,6 +26,13 @@ export class FailedToReExecuteTransactionsError extends ValidatorError {
|
|
|
26
26
|
super(`Failed to re-execute transactions: ${txHashes.join(', ')}`);
|
|
27
27
|
}
|
|
28
28
|
}
|
|
29
|
+
export class ReExInitialStateMismatchError extends ValidatorError {
|
|
30
|
+
expectedArchiveRoot;
|
|
31
|
+
actualArchiveRoot;
|
|
32
|
+
constructor(expectedArchiveRoot, actualArchiveRoot){
|
|
33
|
+
super('Re-execution initial state mismatch'), this.expectedArchiveRoot = expectedArchiveRoot, this.actualArchiveRoot = actualArchiveRoot;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
29
36
|
export class ReExStateMismatchError extends ValidatorError {
|
|
30
37
|
expectedArchiveRoot;
|
|
31
38
|
actualArchiveRoot;
|
|
@@ -22,11 +22,13 @@ export declare function checkCompressedComponentVersion(compressed: string, expe
|
|
|
22
22
|
/** Checks that two component versions match. Undefined fields are ignored. */
|
|
23
23
|
export declare function validatePartialComponentVersionsMatch(expected: Partial<ComponentsVersions>, actual: Partial<ComponentsVersions>): void;
|
|
24
24
|
/** Returns a Koa middleware that injects the versioning info as headers. */
|
|
25
|
-
export declare function getVersioningMiddleware(versions: Partial<ComponentsVersions
|
|
25
|
+
export declare function getVersioningMiddleware(versions: Partial<ComponentsVersions>, opts?: {
|
|
26
|
+
packageVersion?: string;
|
|
27
|
+
}): (ctx: Koa.Context, next: () => Promise<void>) => Promise<void>;
|
|
26
28
|
/** Returns a json rpc client handler that rejects responses with mismatching versions. */
|
|
27
29
|
export declare function getVersioningResponseHandler(versions: Partial<ComponentsVersions>): ({ headers }: {
|
|
28
30
|
headers: {
|
|
29
31
|
get: (header: string) => string | null | undefined;
|
|
30
32
|
};
|
|
31
33
|
}) => Promise<void>;
|
|
32
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
34
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidmVyc2lvbmluZy5kLnRzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vc3JjL3ZlcnNpb25pbmcvdmVyc2lvbmluZy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxPQUFPLEtBQUssRUFBRSxFQUFFLEVBQUUsTUFBTSxnQ0FBZ0MsQ0FBQztBQUN6RCxPQUFPLEtBQUssRUFBRSxVQUFVLEVBQUUsTUFBTSwrQkFBK0IsQ0FBQztBQUdoRSxPQUFPLEtBQUssR0FBRyxNQUFNLEtBQUssQ0FBQztBQUUzQixPQUFPLEtBQUssRUFBRSxXQUFXLEVBQUUsTUFBTSwyQkFBMkIsQ0FBQztBQUU3RCw4SUFBOEk7QUFDOUksTUFBTSxNQUFNLGtCQUFrQixHQUFHO0lBQy9CLFNBQVMsRUF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,CAAC,QAiBpC;AAED,4EAA4E;AAC5E,wBAAgB,uBAAuB,CAAC,QAAQ,EAAE,OAAO,CAAC,kBAAkB,CAAC,EAAE,IAAI,CAAC,EAAE;IAAE,cAAc,CAAC,EAAE,MAAM,CAAA;CAAE,kEAkBhH;AAED,0FAA0F;AAC1F,wBAAgB,4BAA4B,CAAC,QAAQ,EAAE,OAAO,CAAC,kBAAkB,CAAC;;;;oBAajF"}
|
|
@@ -65,7 +65,7 @@ export class ComponentsVersionsError extends Error {
|
|
|
65
65
|
}
|
|
66
66
|
}
|
|
67
67
|
}
|
|
68
|
-
/** Returns a Koa middleware that injects the versioning info as headers. */ export function getVersioningMiddleware(versions) {
|
|
68
|
+
/** Returns a Koa middleware that injects the versioning info as headers. */ export function getVersioningMiddleware(versions, opts) {
|
|
69
69
|
return async (ctx, next)=>{
|
|
70
70
|
try {
|
|
71
71
|
await next();
|
|
@@ -78,6 +78,9 @@ export class ComponentsVersionsError extends Error {
|
|
|
78
78
|
ctx.set(`x-aztec-${key}`, value.toString());
|
|
79
79
|
}
|
|
80
80
|
}
|
|
81
|
+
if (opts?.packageVersion) {
|
|
82
|
+
ctx.set('x-aztec-packageVersion', opts.packageVersion);
|
|
83
|
+
}
|
|
81
84
|
}
|
|
82
85
|
};
|
|
83
86
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aztec/stdlib",
|
|
3
|
-
"version": "0.0.1-commit.
|
|
3
|
+
"version": "0.0.1-commit.d1da697d6",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"inherits": [
|
|
6
6
|
"../package.common.json",
|
|
@@ -92,13 +92,13 @@
|
|
|
92
92
|
},
|
|
93
93
|
"dependencies": {
|
|
94
94
|
"@aws-sdk/client-s3": "^3.892.0",
|
|
95
|
-
"@aztec/bb.js": "0.0.1-commit.
|
|
96
|
-
"@aztec/blob-lib": "0.0.1-commit.
|
|
97
|
-
"@aztec/constants": "0.0.1-commit.
|
|
98
|
-
"@aztec/ethereum": "0.0.1-commit.
|
|
99
|
-
"@aztec/foundation": "0.0.1-commit.
|
|
100
|
-
"@aztec/l1-artifacts": "0.0.1-commit.
|
|
101
|
-
"@aztec/noir-noirc_abi": "0.0.1-commit.
|
|
95
|
+
"@aztec/bb.js": "0.0.1-commit.d1da697d6",
|
|
96
|
+
"@aztec/blob-lib": "0.0.1-commit.d1da697d6",
|
|
97
|
+
"@aztec/constants": "0.0.1-commit.d1da697d6",
|
|
98
|
+
"@aztec/ethereum": "0.0.1-commit.d1da697d6",
|
|
99
|
+
"@aztec/foundation": "0.0.1-commit.d1da697d6",
|
|
100
|
+
"@aztec/l1-artifacts": "0.0.1-commit.d1da697d6",
|
|
101
|
+
"@aztec/noir-noirc_abi": "0.0.1-commit.d1da697d6",
|
|
102
102
|
"@google-cloud/storage": "^7.15.0",
|
|
103
103
|
"axios": "^1.13.5",
|
|
104
104
|
"json-stringify-deterministic": "1.0.12",
|
package/src/abi/abi.ts
CHANGED
|
@@ -224,7 +224,13 @@ export const FunctionDebugMetadataSchema = z.object({
|
|
|
224
224
|
acir_locations: z.record(z.number()),
|
|
225
225
|
brillig_locations: z.record(z.record(z.number())),
|
|
226
226
|
}),
|
|
227
|
-
files: z.record(
|
|
227
|
+
files: z.record(
|
|
228
|
+
z.object({
|
|
229
|
+
source: z.string(),
|
|
230
|
+
path: z.string(),
|
|
231
|
+
function_locations: z.array(z.object({ start: z.number(), name: z.string() })),
|
|
232
|
+
}),
|
|
233
|
+
),
|
|
228
234
|
}) satisfies z.ZodType<FunctionDebugMetadata>;
|
|
229
235
|
|
|
230
236
|
/** The artifact entry of a function. */
|
|
@@ -305,6 +311,14 @@ export interface ProgramDebugInfo {
|
|
|
305
311
|
debug_infos: Array<DebugInfo>;
|
|
306
312
|
}
|
|
307
313
|
|
|
314
|
+
/** The range a function occupies in a file. */
|
|
315
|
+
export type FunctionLocation = {
|
|
316
|
+
/** The byte where the function starts. */
|
|
317
|
+
start: number;
|
|
318
|
+
/** The name of the function. */
|
|
319
|
+
name: string;
|
|
320
|
+
};
|
|
321
|
+
|
|
308
322
|
/** Maps a file ID to its metadata for debugging purposes. */
|
|
309
323
|
export type DebugFileMap = Record<
|
|
310
324
|
FileId,
|
|
@@ -313,6 +327,8 @@ export type DebugFileMap = Record<
|
|
|
313
327
|
source: string;
|
|
314
328
|
/** The path of the file. */
|
|
315
329
|
path: string;
|
|
330
|
+
/** The range each function occupies in the file. */
|
|
331
|
+
function_locations: FunctionLocation[];
|
|
316
332
|
}
|
|
317
333
|
>;
|
|
318
334
|
|
|
@@ -367,7 +383,14 @@ export const ContractArtifactSchema = zodFor<ContractArtifact>()(
|
|
|
367
383
|
globals: z.record(z.array(AbiValueSchema)),
|
|
368
384
|
}),
|
|
369
385
|
storageLayout: z.record(z.object({ slot: schemas.Fr })),
|
|
370
|
-
fileMap: z.record(
|
|
386
|
+
fileMap: z.record(
|
|
387
|
+
z.coerce.number(),
|
|
388
|
+
z.object({
|
|
389
|
+
source: z.string(),
|
|
390
|
+
path: z.string(),
|
|
391
|
+
function_locations: z.array(z.object({ start: z.number(), name: z.string() })),
|
|
392
|
+
}),
|
|
393
|
+
),
|
|
371
394
|
}),
|
|
372
395
|
);
|
|
373
396
|
|
package/src/abi/buffer.ts
CHANGED
|
@@ -26,11 +26,32 @@ export function bufferAsFields(input: Buffer, targetLength: number): Fr[] {
|
|
|
26
26
|
}
|
|
27
27
|
|
|
28
28
|
/**
|
|
29
|
-
* Recovers a buffer from an array of fields.
|
|
30
|
-
*
|
|
31
|
-
*
|
|
29
|
+
* Recovers a buffer from an array of fields previously encoded with bufferAsFields.
|
|
30
|
+
*
|
|
31
|
+
* The first field encodes the byte length of the original buffer. The remaining fields
|
|
32
|
+
* each carry 31 bytes of payload (the leading byte of each 32-byte field element is skipped).
|
|
33
|
+
*
|
|
34
|
+
* If the declared byte length exceeds the bytes available from the payload fields, the result
|
|
35
|
+
* is zero-padded to the full declared length. This is important for correctness when the field
|
|
36
|
+
* array has been truncated (e.g. contract class logs reconstructed from blobs using a short
|
|
37
|
+
* emittedLength): without padding, the resulting buffer would be shorter than declared, causing
|
|
38
|
+
* bytecode commitment computations to diverge from what the circuit produced.
|
|
39
|
+
*
|
|
40
|
+
* @param fields - An output from bufferAsFields: [byteLength, ...payloadFields].
|
|
41
|
+
* @returns A buffer of exactly `byteLength` bytes.
|
|
32
42
|
*/
|
|
33
43
|
export function bufferFromFields(fields: Fr[]): Buffer {
|
|
34
44
|
const [length, ...payload] = fields;
|
|
35
|
-
|
|
45
|
+
const byteLength = length.toNumber();
|
|
46
|
+
const raw = Buffer.concat(payload.map(f => f.toBuffer().subarray(1)));
|
|
47
|
+
if (raw.length >= byteLength) {
|
|
48
|
+
return raw.subarray(0, byteLength);
|
|
49
|
+
}
|
|
50
|
+
// Pad with zeros if the declared length exceeds the available payload bytes.
|
|
51
|
+
// This ensures the returned buffer always matches the declared length, so that
|
|
52
|
+
// downstream bytecode commitment computations are consistent even when the
|
|
53
|
+
// source field array was truncated (e.g. reconstructed from blob with a short emittedLength).
|
|
54
|
+
const result = Buffer.alloc(byteLength);
|
|
55
|
+
raw.copy(result);
|
|
56
|
+
return result;
|
|
36
57
|
}
|
package/src/abi/decoder.ts
CHANGED
|
@@ -1,8 +1,17 @@
|
|
|
1
1
|
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
2
|
+
import { EthAddress } from '@aztec/foundation/eth-address';
|
|
2
3
|
|
|
3
4
|
import { AztecAddress } from '../aztec-address/index.js';
|
|
4
|
-
import type {
|
|
5
|
-
import {
|
|
5
|
+
import type { AbiType } from './abi.js';
|
|
6
|
+
import { FunctionSelector } from './function_selector.js';
|
|
7
|
+
import {
|
|
8
|
+
isAztecAddressStruct,
|
|
9
|
+
isEthAddressStruct,
|
|
10
|
+
isFunctionSelectorStruct,
|
|
11
|
+
isOptionStruct,
|
|
12
|
+
isWrappedFieldStruct,
|
|
13
|
+
parseSignedInt,
|
|
14
|
+
} from './utils.js';
|
|
6
15
|
|
|
7
16
|
/**
|
|
8
17
|
* The type of our decoded ABI.
|
|
@@ -12,6 +21,9 @@ export type AbiDecoded =
|
|
|
12
21
|
| boolean
|
|
13
22
|
| string
|
|
14
23
|
| AztecAddress
|
|
24
|
+
| EthAddress
|
|
25
|
+
| FunctionSelector
|
|
26
|
+
| Fr
|
|
15
27
|
| AbiDecoded[]
|
|
16
28
|
| { [key: string]: AbiDecoded }
|
|
17
29
|
| undefined;
|
|
@@ -58,6 +70,15 @@ class AbiDecoder {
|
|
|
58
70
|
if (isAztecAddressStruct(abiType)) {
|
|
59
71
|
return new AztecAddress(this.getNextField().toBuffer());
|
|
60
72
|
}
|
|
73
|
+
if (isEthAddressStruct(abiType)) {
|
|
74
|
+
return EthAddress.fromField(this.getNextField());
|
|
75
|
+
}
|
|
76
|
+
if (isFunctionSelectorStruct(abiType)) {
|
|
77
|
+
return FunctionSelector.fromField(this.getNextField());
|
|
78
|
+
}
|
|
79
|
+
if (isWrappedFieldStruct(abiType)) {
|
|
80
|
+
return this.getNextField();
|
|
81
|
+
}
|
|
61
82
|
if (isOptionStruct(abiType)) {
|
|
62
83
|
const isSome = this.decodeNext(abiType.fields[0].type);
|
|
63
84
|
const value = this.decodeNext(abiType.fields[1].type);
|
|
@@ -123,79 +144,3 @@ class AbiDecoder {
|
|
|
123
144
|
export function decodeFromAbi(typ: AbiType[], buffer: Fr[]) {
|
|
124
145
|
return new AbiDecoder(typ, buffer.slice()).decode();
|
|
125
146
|
}
|
|
126
|
-
|
|
127
|
-
/**
|
|
128
|
-
* Decodes the signature of a function from the name and parameters.
|
|
129
|
-
*/
|
|
130
|
-
export class FunctionSignatureDecoder {
|
|
131
|
-
private separator: string;
|
|
132
|
-
constructor(
|
|
133
|
-
private name: string,
|
|
134
|
-
private parameters: ABIParameter[],
|
|
135
|
-
private includeNames = false,
|
|
136
|
-
) {
|
|
137
|
-
this.separator = includeNames ? ', ' : ',';
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
/**
|
|
141
|
-
* Decodes a single function parameter type for the function signature.
|
|
142
|
-
* @param param - The parameter type to decode.
|
|
143
|
-
* @returns A string representing the parameter type.
|
|
144
|
-
*/
|
|
145
|
-
private getParameterType(param: AbiType): string {
|
|
146
|
-
switch (param.kind) {
|
|
147
|
-
case 'field':
|
|
148
|
-
return 'Field';
|
|
149
|
-
case 'integer':
|
|
150
|
-
return param.sign === 'signed' ? `i${param.width}` : `u${param.width}`;
|
|
151
|
-
case 'boolean':
|
|
152
|
-
return 'bool';
|
|
153
|
-
case 'array':
|
|
154
|
-
return `[${this.getParameterType(param.type)};${param.length}]`;
|
|
155
|
-
case 'string':
|
|
156
|
-
return `str<${param.length}>`;
|
|
157
|
-
case 'struct':
|
|
158
|
-
return `(${param.fields.map(field => `${this.decodeParameter(field)}`).join(this.separator)})`;
|
|
159
|
-
default:
|
|
160
|
-
throw new Error(`Unsupported type: ${param.kind}`);
|
|
161
|
-
}
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
/**
|
|
165
|
-
* Decodes a single function parameter for the function signature.
|
|
166
|
-
* @param param - The parameter to decode.
|
|
167
|
-
* @returns A string representing the parameter type and optionally its name.
|
|
168
|
-
*/
|
|
169
|
-
private decodeParameter(param: ABIVariable): string {
|
|
170
|
-
const type = this.getParameterType(param.type);
|
|
171
|
-
return this.includeNames ? `${param.name}: ${type}` : type;
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
/**
|
|
175
|
-
* Decodes all the parameters and build the function signature
|
|
176
|
-
* @returns The function signature.
|
|
177
|
-
*/
|
|
178
|
-
public decode(): string {
|
|
179
|
-
return `${this.name}(${this.parameters.map(param => this.decodeParameter(param)).join(this.separator)})`;
|
|
180
|
-
}
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
/**
|
|
184
|
-
* Decodes a function signature from the name and parameters.
|
|
185
|
-
* @param name - The name of the function.
|
|
186
|
-
* @param parameters - The parameters of the function.
|
|
187
|
-
* @returns - The function signature.
|
|
188
|
-
*/
|
|
189
|
-
export function decodeFunctionSignature(name: string, parameters: ABIParameter[]) {
|
|
190
|
-
return new FunctionSignatureDecoder(name, parameters).decode();
|
|
191
|
-
}
|
|
192
|
-
|
|
193
|
-
/**
|
|
194
|
-
* Decodes a function signature from the name and parameters including parameter names.
|
|
195
|
-
* @param name - The name of the function.
|
|
196
|
-
* @param parameters - The parameters of the function.
|
|
197
|
-
* @returns - The user-friendly function signature.
|
|
198
|
-
*/
|
|
199
|
-
export function decodeFunctionSignatureWithParameterNames(name: string, parameters: ABIParameter[]) {
|
|
200
|
-
return new FunctionSignatureDecoder(name, parameters, true).decode();
|
|
201
|
-
}
|
|
@@ -6,7 +6,7 @@ import { type ZodFor, hexSchemaFor } from '@aztec/foundation/schemas';
|
|
|
6
6
|
import { BufferReader, FieldReader, TypeRegistry } from '@aztec/foundation/serialize';
|
|
7
7
|
|
|
8
8
|
import type { ABIParameter } from './abi.js';
|
|
9
|
-
import { decodeFunctionSignature } from './
|
|
9
|
+
import { decodeFunctionSignature } from './function_signature_decoder.js';
|
|
10
10
|
import { Selector } from './selector.js';
|
|
11
11
|
|
|
12
12
|
/* eslint-disable @typescript-eslint/no-unsafe-declaration-merging */
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import type { ABIParameter, ABIVariable, AbiType } from './abi.js';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Decodes the signature of a function from the name and parameters.
|
|
5
|
+
*/
|
|
6
|
+
export class FunctionSignatureDecoder {
|
|
7
|
+
private separator: string;
|
|
8
|
+
constructor(
|
|
9
|
+
private name: string,
|
|
10
|
+
private parameters: ABIParameter[],
|
|
11
|
+
private includeNames = false,
|
|
12
|
+
) {
|
|
13
|
+
this.separator = includeNames ? ', ' : ',';
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Decodes a single function parameter type for the function signature.
|
|
18
|
+
* @param param - The parameter type to decode.
|
|
19
|
+
* @returns A string representing the parameter type.
|
|
20
|
+
*/
|
|
21
|
+
private getParameterType(param: AbiType): string {
|
|
22
|
+
switch (param.kind) {
|
|
23
|
+
case 'field':
|
|
24
|
+
return 'Field';
|
|
25
|
+
case 'integer':
|
|
26
|
+
return param.sign === 'signed' ? `i${param.width}` : `u${param.width}`;
|
|
27
|
+
case 'boolean':
|
|
28
|
+
return 'bool';
|
|
29
|
+
case 'array':
|
|
30
|
+
return `[${this.getParameterType(param.type)};${param.length}]`;
|
|
31
|
+
case 'string':
|
|
32
|
+
return `str<${param.length}>`;
|
|
33
|
+
case 'struct':
|
|
34
|
+
return `(${param.fields.map(field => `${this.decodeParameter(field)}`).join(this.separator)})`;
|
|
35
|
+
default:
|
|
36
|
+
throw new Error(`Unsupported type: ${param.kind}`);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Decodes a single function parameter for the function signature.
|
|
42
|
+
* @param param - The parameter to decode.
|
|
43
|
+
* @returns A string representing the parameter type and optionally its name.
|
|
44
|
+
*/
|
|
45
|
+
private decodeParameter(param: ABIVariable): string {
|
|
46
|
+
const type = this.getParameterType(param.type);
|
|
47
|
+
return this.includeNames ? `${param.name}: ${type}` : type;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Decodes all the parameters and build the function signature
|
|
52
|
+
* @returns The function signature.
|
|
53
|
+
*/
|
|
54
|
+
public decode(): string {
|
|
55
|
+
return `${this.name}(${this.parameters.map(param => this.decodeParameter(param)).join(this.separator)})`;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Decodes a function signature from the name and parameters.
|
|
61
|
+
* @param name - The name of the function.
|
|
62
|
+
* @param parameters - The parameters of the function.
|
|
63
|
+
* @returns - The function signature.
|
|
64
|
+
*/
|
|
65
|
+
export function decodeFunctionSignature(name: string, parameters: ABIParameter[]) {
|
|
66
|
+
return new FunctionSignatureDecoder(name, parameters).decode();
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* Decodes a function signature from the name and parameters including parameter names.
|
|
71
|
+
* @param name - The name of the function.
|
|
72
|
+
* @param parameters - The parameters of the function.
|
|
73
|
+
* @returns - The user-friendly function signature.
|
|
74
|
+
*/
|
|
75
|
+
export function decodeFunctionSignatureWithParameterNames(name: string, parameters: ABIParameter[]) {
|
|
76
|
+
return new FunctionSignatureDecoder(name, parameters, true).decode();
|
|
77
|
+
}
|
package/src/abi/index.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';
|
package/src/abi/selector.ts
CHANGED
|
@@ -4,7 +4,7 @@ import { bufferToHex } from '@aztec/foundation/string';
|
|
|
4
4
|
|
|
5
5
|
import { inspect } from 'util';
|
|
6
6
|
|
|
7
|
-
/** A selector is the
|
|
7
|
+
/** A selector is the low 4 bytes of the poseidon2 hash of a signature. */
|
|
8
8
|
export abstract class Selector {
|
|
9
9
|
/** The size of the selector in bytes. */
|
|
10
10
|
public static SIZE = 4;
|