@aztec/stdlib 0.0.1-commit.e0f15ab9b → 0.0.1-commit.e304674f1
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/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/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 +80 -3
- 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/epoch-helpers/index.d.ts +5 -1
- package/dest/epoch-helpers/index.d.ts.map +1 -1
- package/dest/epoch-helpers/index.js +6 -0
- 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 +4 -1
- package/dest/hash/hash.d.ts.map +1 -1
- package/dest/hash/hash.js +5 -0
- package/dest/interfaces/archiver.d.ts +1 -1
- package/dest/interfaces/archiver.d.ts.map +1 -1
- package/dest/interfaces/archiver.js +3 -1
- package/dest/interfaces/aztec-node-admin.d.ts +4 -14
- package/dest/interfaces/aztec-node-admin.d.ts.map +1 -1
- package/dest/interfaces/aztec-node-admin.js +3 -3
- package/dest/interfaces/proving-job.d.ts +166 -166
- package/dest/interfaces/slasher.d.ts +1 -10
- package/dest/interfaces/slasher.d.ts.map +1 -1
- package/dest/interfaces/slasher.js +0 -2
- package/dest/interfaces/validator.d.ts +4 -15
- package/dest/interfaces/validator.d.ts.map +1 -1
- package/dest/interfaces/validator.js +0 -1
- package/dest/l1-contracts/index.d.ts +2 -2
- package/dest/l1-contracts/index.d.ts.map +1 -1
- package/dest/l1-contracts/index.js +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/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/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/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 +2 -2
- package/dest/p2p/checkpoint_proposal.d.ts.map +1 -1
- package/dest/p2p/checkpoint_proposal.js +3 -15
- 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/slashing/index.d.ts +2 -3
- package/dest/slashing/index.d.ts.map +1 -1
- package/dest/slashing/index.js +1 -2
- package/dest/slashing/serialization.d.ts +2 -6
- package/dest/slashing/serialization.d.ts.map +1 -1
- package/dest/slashing/serialization.js +0 -60
- package/dest/slashing/types.d.ts +4 -90
- package/dest/slashing/types.d.ts.map +1 -1
- package/dest/slashing/types.js +0 -14
- package/dest/slashing/{tally.d.ts → votes.d.ts} +1 -1
- package/dest/slashing/{tally.d.ts.map → votes.d.ts.map} +1 -1
- package/dest/slashing/{tally.js → votes.js} +1 -1
- package/dest/tests/factories.d.ts +1 -1
- package/dest/tests/factories.d.ts.map +1 -1
- package/dest/tests/factories.js +11 -1
- package/dest/tests/mocks.d.ts +1 -1
- package/dest/tests/mocks.d.ts.map +1 -1
- package/dest/tests/mocks.js +13 -18
- package/dest/timetable/index.d.ts +2 -1
- package/dest/timetable/index.d.ts.map +1 -1
- package/dest/timetable/index.js +6 -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/simulated_tx.d.ts +3 -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 +8 -4
- package/dest/tx/tx_receipt.d.ts.map +1 -1
- package/dest/tx/tx_receipt.js +8 -15
- package/dest/world-state/genesis_data.d.ts +11 -0
- package/dest/world-state/genesis_data.d.ts.map +1 -0
- package/dest/world-state/genesis_data.js +4 -0
- package/dest/world-state/index.d.ts +2 -1
- package/dest/world-state/index.d.ts.map +1 -1
- package/dest/world-state/index.js +1 -0
- package/package.json +8 -8
- 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 +10 -2
- 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/epoch-helpers/index.ts +13 -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/gas_settings.ts +65 -12
- package/src/hash/hash.ts +5 -0
- package/src/interfaces/archiver.ts +3 -1
- package/src/interfaces/aztec-node-admin.ts +5 -7
- package/src/interfaces/slasher.ts +0 -6
- package/src/interfaces/validator.ts +2 -9
- package/src/l1-contracts/index.ts +1 -1
- package/src/logs/extended_directional_app_tagging_secret.ts +19 -8
- 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/messaging/l1_to_l2_message.ts +12 -9
- package/src/note/note_dao.ts +1 -4
- package/src/p2p/checkpoint_proposal.ts +10 -26
- package/src/proofs/chonk_proof.ts +91 -5
- package/src/slashing/index.ts +1 -2
- package/src/slashing/serialization.ts +1 -81
- package/src/slashing/types.ts +3 -35
- package/src/slashing/{tally.ts → votes.ts} +1 -1
- package/src/tests/factories.ts +5 -1
- package/src/tests/mocks.ts +14 -12
- package/src/timetable/index.ts +7 -2
- package/src/tx/capsule.ts +10 -2
- package/src/tx/global_variable_builder.ts +15 -0
- package/src/tx/simulated_tx.ts +5 -1
- package/src/tx/tx_receipt.ts +11 -14
- package/src/world-state/genesis_data.ts +15 -0
- package/src/world-state/index.ts +1 -0
- package/dest/l1-contracts/slash_factory.d.ts +0 -45
- package/dest/l1-contracts/slash_factory.d.ts.map +0 -1
- package/dest/l1-contracts/slash_factory.js +0 -158
- package/dest/slashing/empire.d.ts +0 -31
- package/dest/slashing/empire.d.ts.map +0 -1
- package/dest/slashing/empire.js +0 -87
- package/src/l1-contracts/slash_factory.ts +0 -180
- package/src/slashing/empire.ts +0 -104
package/dest/abi/decoder.d.ts
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
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
|
/**
|
|
@@ -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,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZGVjb2Rlci5kLnRzI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QUFFLGNBRXpEIn0=
|
|
@@ -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,15 @@ import { isAztecAddressStruct, isOptionStruct, 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
|
+
}
|
|
45
56
|
if (isOptionStruct(abiType)) {
|
|
46
57
|
const isSome = this.decodeNext(abiType.fields[0].type);
|
|
47
58
|
const value = this.decodeNext(abiType.fields[1].type);
|
|
@@ -102,69 +113,3 @@ import { isAztecAddressStruct, isOptionStruct, parseSignedInt } from './utils.js
|
|
|
102
113
|
*/ export function decodeFromAbi(typ, buffer) {
|
|
103
114
|
return new AbiDecoder(typ, buffer.slice()).decode();
|
|
104
115
|
}
|
|
105
|
-
/**
|
|
106
|
-
* Decodes the signature of a function from the name and parameters.
|
|
107
|
-
*/ export class FunctionSignatureDecoder {
|
|
108
|
-
name;
|
|
109
|
-
parameters;
|
|
110
|
-
includeNames;
|
|
111
|
-
separator;
|
|
112
|
-
constructor(name, parameters, includeNames = false){
|
|
113
|
-
this.name = name;
|
|
114
|
-
this.parameters = parameters;
|
|
115
|
-
this.includeNames = includeNames;
|
|
116
|
-
this.separator = includeNames ? ', ' : ',';
|
|
117
|
-
}
|
|
118
|
-
/**
|
|
119
|
-
* Decodes a single function parameter type for the function signature.
|
|
120
|
-
* @param param - The parameter type to decode.
|
|
121
|
-
* @returns A string representing the parameter type.
|
|
122
|
-
*/ getParameterType(param) {
|
|
123
|
-
switch(param.kind){
|
|
124
|
-
case 'field':
|
|
125
|
-
return 'Field';
|
|
126
|
-
case 'integer':
|
|
127
|
-
return param.sign === 'signed' ? `i${param.width}` : `u${param.width}`;
|
|
128
|
-
case 'boolean':
|
|
129
|
-
return 'bool';
|
|
130
|
-
case 'array':
|
|
131
|
-
return `[${this.getParameterType(param.type)};${param.length}]`;
|
|
132
|
-
case 'string':
|
|
133
|
-
return `str<${param.length}>`;
|
|
134
|
-
case 'struct':
|
|
135
|
-
return `(${param.fields.map((field)=>`${this.decodeParameter(field)}`).join(this.separator)})`;
|
|
136
|
-
default:
|
|
137
|
-
throw new Error(`Unsupported type: ${param.kind}`);
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
/**
|
|
141
|
-
* Decodes a single function parameter for the function signature.
|
|
142
|
-
* @param param - The parameter to decode.
|
|
143
|
-
* @returns A string representing the parameter type and optionally its name.
|
|
144
|
-
*/ decodeParameter(param) {
|
|
145
|
-
const type = this.getParameterType(param.type);
|
|
146
|
-
return this.includeNames ? `${param.name}: ${type}` : type;
|
|
147
|
-
}
|
|
148
|
-
/**
|
|
149
|
-
* Decodes all the parameters and build the function signature
|
|
150
|
-
* @returns The function signature.
|
|
151
|
-
*/ decode() {
|
|
152
|
-
return `${this.name}(${this.parameters.map((param)=>this.decodeParameter(param)).join(this.separator)})`;
|
|
153
|
-
}
|
|
154
|
-
}
|
|
155
|
-
/**
|
|
156
|
-
* Decodes a function signature from the name and parameters.
|
|
157
|
-
* @param name - The name of the function.
|
|
158
|
-
* @param parameters - The parameters of the function.
|
|
159
|
-
* @returns - The function signature.
|
|
160
|
-
*/ export function decodeFunctionSignature(name, parameters) {
|
|
161
|
-
return new FunctionSignatureDecoder(name, parameters).decode();
|
|
162
|
-
}
|
|
163
|
-
/**
|
|
164
|
-
* Decodes a function signature from the name and parameters including parameter names.
|
|
165
|
-
* @param name - The name of the function.
|
|
166
|
-
* @param parameters - The parameters of the function.
|
|
167
|
-
* @returns - The user-friendly function signature.
|
|
168
|
-
*/ export function decodeFunctionSignatureWithParameterNames(name, parameters) {
|
|
169
|
-
return new FunctionSignatureDecoder(name, parameters, true).decode();
|
|
170
|
-
}
|
|
@@ -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/selector.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
2
2
|
import { inspect } from 'util';
|
|
3
|
-
/** A selector is the
|
|
3
|
+
/** A selector is the low 4 bytes of the poseidon2 hash of a signature. */
|
|
4
4
|
export declare abstract class Selector {
|
|
5
5
|
value: number;
|
|
6
6
|
/** The size of the selector in bytes. */
|
|
@@ -36,4 +36,4 @@ export declare abstract class Selector {
|
|
|
36
36
|
*/
|
|
37
37
|
toField(): Fr;
|
|
38
38
|
}
|
|
39
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
39
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic2VsZWN0b3IuZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9hYmkvc2VsZWN0b3IudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQ0EsT0FBTyxFQUFFLEVBQUUsRUFBRSxNQUFNLGdDQUFnQyxDQUFDO0FBR3BELE9BQU8sRUFBRSxPQUFPLEVBQUUsTUFBTSxNQUFNLENBQUM7QUFFL0IsMEVBQTBFO0FBQzFFLDhCQUFzQixRQUFRO0lBSW9CLEtBQUssRUFBRSxNQUFNO0lBSDdELHlDQUF5QztJQUN6QyxPQUFjLElBQUksU0FBSztJQUV2QixZQUFZLDRCQUE0QixDQUFRLEtBQUssRUFBRSxNQUFNLEVBSTVEO0lBRUQ7OztPQUdHO0lBQ0ksT0FBTyxJQUFJLE9BQU8sQ0FFeEI7SUFFRDs7OztPQUlHO0lBQ0gsUUFBUSxDQUFDLFVBQVUsU0FBZ0IsR0FBRyxNQUFNLENBRTNDO0lBRUQ7OztPQUdHO0lBQ0gsUUFBUSxJQUFJLE1BQU0sQ0FFakI7SUFFRCxDQUFDLE9BQU8sQ0FBQyxNQUFNLENBQUMsV0FFZjtJQUVEOzs7O09BSUc7SUFDSCxNQUFNLENBQUMsS0FBSyxFQUFFLFFBQVEsR0FBRyxPQUFPLENBRS9CO0lBRUQ7Ozs7T0FJRztJQUNJLE9BQU8sT0FFYjtDQUNGIn0=
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"selector.d.ts","sourceRoot":"","sources":["../../src/abi/selector.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,EAAE,EAAE,MAAM,gCAAgC,CAAC;AAGpD,OAAO,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AAE/B,
|
|
1
|
+
{"version":3,"file":"selector.d.ts","sourceRoot":"","sources":["../../src/abi/selector.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,EAAE,EAAE,MAAM,gCAAgC,CAAC;AAGpD,OAAO,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AAE/B,0EAA0E;AAC1E,8BAAsB,QAAQ;IAIoB,KAAK,EAAE,MAAM;IAH7D,yCAAyC;IACzC,OAAc,IAAI,SAAK;IAEvB,YAAY,4BAA4B,CAAQ,KAAK,EAAE,MAAM,EAI5D;IAED;;;OAGG;IACI,OAAO,IAAI,OAAO,CAExB;IAED;;;;OAIG;IACH,QAAQ,CAAC,UAAU,SAAgB,GAAG,MAAM,CAE3C;IAED;;;OAGG;IACH,QAAQ,IAAI,MAAM,CAEjB;IAED,CAAC,OAAO,CAAC,MAAM,CAAC,WAEf;IAED;;;;OAIG;IACH,MAAM,CAAC,KAAK,EAAE,QAAQ,GAAG,OAAO,CAE/B;IAED;;;;OAIG;IACI,OAAO,OAEb;CACF"}
|
package/dest/abi/selector.js
CHANGED
|
@@ -4,7 +4,7 @@ import { Fr } from '@aztec/foundation/curves/bn254';
|
|
|
4
4
|
import { bufferToHex } from '@aztec/foundation/string';
|
|
5
5
|
import { inspect } from 'util';
|
|
6
6
|
_computedKey = inspect.custom;
|
|
7
|
-
/** A selector is the
|
|
7
|
+
/** A selector is the low 4 bytes of the poseidon2 hash of a signature. */ export class Selector {
|
|
8
8
|
value;
|
|
9
9
|
/** The size of the selector in bytes. */ static SIZE = 4;
|
|
10
10
|
constructor(/** Value of the selector */ value){
|
|
@@ -2,26 +2,12 @@ import { Fr } from '@aztec/foundation/curves/bn254';
|
|
|
2
2
|
import type { ZodFor } from '@aztec/foundation/schemas';
|
|
3
3
|
import { BufferReader, FieldReader } from '@aztec/foundation/serialize';
|
|
4
4
|
import { inspect } from 'util';
|
|
5
|
-
/**
|
|
6
|
-
* Tracks which revertible phases of a transaction's public execution reverted.
|
|
7
|
-
*
|
|
8
|
-
* A transaction executes in three sequential phases:
|
|
9
|
-
* 1. SETUP – non-revertible; if this fails the entire transaction is rejected.
|
|
10
|
-
* 2. APP_LOGIC – revertible; its state changes are rolled back on failure.
|
|
11
|
-
* 3. TEARDOWN – revertible; always runs (even after app-logic revert) so the fee-payment contract can clean up.
|
|
12
|
-
*
|
|
13
|
-
* Only APP_LOGIC and TEARDOWN can produce a revert code. SETUP failures throw instead and discard the transaction
|
|
14
|
-
* entirely.
|
|
15
|
-
*/
|
|
5
|
+
/** Whether a transaction's public execution reverted. */
|
|
16
6
|
export declare enum RevertCodeEnum {
|
|
17
7
|
/** All phases completed successfully; no state was rolled back. */
|
|
18
8
|
OK = 0,
|
|
19
|
-
/**
|
|
20
|
-
|
|
21
|
-
/** TEARDOWN reverted; its state changes were discarded. APP_LOGIC succeeded. */
|
|
22
|
-
TEARDOWN_REVERTED = 2,
|
|
23
|
-
/** Both APP_LOGIC and TEARDOWN reverted; only SETUP effects are kept. */
|
|
24
|
-
BOTH_REVERTED = 3
|
|
9
|
+
/** One or more revertible phases reverted; their state changes were discarded. */
|
|
10
|
+
REVERTED = 1
|
|
25
11
|
}
|
|
26
12
|
/**
|
|
27
13
|
* Wrapper class over a field to safely represent a revert code.
|
|
@@ -30,8 +16,12 @@ export declare class RevertCode {
|
|
|
30
16
|
private code;
|
|
31
17
|
private constructor();
|
|
32
18
|
static readonly OK: RevertCode;
|
|
19
|
+
static readonly REVERTED: RevertCode;
|
|
20
|
+
/** @deprecated Use REVERTED instead. */
|
|
33
21
|
static readonly APP_LOGIC_REVERTED: RevertCode;
|
|
22
|
+
/** @deprecated Use REVERTED instead. */
|
|
34
23
|
static readonly TEARDOWN_REVERTED: RevertCode;
|
|
24
|
+
/** @deprecated Use REVERTED instead. */
|
|
35
25
|
static readonly BOTH_REVERTED: RevertCode;
|
|
36
26
|
getCode(): RevertCodeEnum;
|
|
37
27
|
equals(other: RevertCode): boolean;
|
|
@@ -67,4 +57,4 @@ export declare class RevertCode {
|
|
|
67
57
|
static random(): RevertCode;
|
|
68
58
|
[inspect.custom](): string;
|
|
69
59
|
}
|
|
70
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
60
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicmV2ZXJ0X2NvZGUuZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9hdm0vcmV2ZXJ0X2NvZGUudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsT0FBTyxFQUFFLEVBQUUsRUFBRSxNQUFNLGdDQUFnQyxDQUFDO0FBQ3BELE9BQU8sS0FBSyxFQUFFLE1BQU0sRUFBRSxNQUFNLDJCQUEyQixDQUFDO0FBQ3hELE9BQU8sRUFBRSxZQUFZLEVBQUUsV0FBVyxFQUFFLE1BQU0sNkJBQTZCLENBQUM7QUFFeEUsT0FBTyxFQUFFLE9BQU8sRUFBRSxNQUFNLE1BQU0sQ0FBQztBQUcvQix5REFBeUQ7QUFDekQsb0JBQVksY0FBYztJQUN4QixtRUFBbUU7SUFDbkUsRUFBRSxJQUFJO0lBQ04sa0ZBQWtGO0lBQ2xGLFFBQVEsSUFBSTtDQUNiO0FBT0Q7O0dBRUc7QUFDSCxxQkFBYSxVQUFVO0lBQ3JCLE9BQU8sQ0FBQyxJQUFJLENBQVM7SUFDckIsT0FBTyxlQUVOO0lBQ0QsTUFBTSxDQUFDLFFBQVEsQ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QWMsU0FBUyxDQUFDLEtBQUssRUFBRSxFQUFFLEdBQUcsVUFBVSxDQUU3QztJQUVELE9BQWMsVUFBVSxDQUFDLE1BQU0sRUFBRSxFQUFFLEVBQUUsR0FBRyxXQUFXLEdBQUcsVUFBVSxDQUcvRDtJQUVELE9BQWMsVUFBVSxDQUFDLE1BQU0sRUFBRSxNQUFNLEdBQUcsWUFBWSxHQUFHLFVBQVUsQ0FJbEU7SUFFRCxPQUFPLENBQUMsTUFBTSxDQUFDLFFBQVEsQ0FBQyxXQUFXLENBQUs7SUFDeEMsTUFBTSxDQUFDLE1BQU0sSUFBSSxVQUFVLENBRTFCO0lBRUQsQ0FBQyxPQUFPLENBQUMsTUFBTSxDQUFDLFdBRWY7Q0FDRiJ9
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"revert_code.d.ts","sourceRoot":"","sources":["../../src/avm/revert_code.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAE,MAAM,gCAAgC,CAAC;AACpD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,2BAA2B,CAAC;AACxD,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAC;AAExE,OAAO,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AAG/B
|
|
1
|
+
{"version":3,"file":"revert_code.d.ts","sourceRoot":"","sources":["../../src/avm/revert_code.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAE,MAAM,gCAAgC,CAAC;AACpD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,2BAA2B,CAAC;AACxD,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAC;AAExE,OAAO,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AAG/B,yDAAyD;AACzD,oBAAY,cAAc;IACxB,mEAAmE;IACnE,EAAE,IAAI;IACN,kFAAkF;IAClF,QAAQ,IAAI;CACb;AAOD;;GAEG;AACH,qBAAa,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MAAM,CAAC,QAAQ,CAAC,WAAW,CAAK;IACxC,MAAM,CAAC,MAAM,IAAI,UAAU,CAE1B;IAED,CAAC,OAAO,CAAC,MAAM,CAAC,WAEf;CACF"}
|
package/dest/avm/revert_code.js
CHANGED
|
@@ -3,25 +3,13 @@ import { Fr } from '@aztec/foundation/curves/bn254';
|
|
|
3
3
|
import { BufferReader, FieldReader } from '@aztec/foundation/serialize';
|
|
4
4
|
import { inspect } from 'util';
|
|
5
5
|
import { z } from 'zod';
|
|
6
|
-
/**
|
|
7
|
-
* Tracks which revertible phases of a transaction's public execution reverted.
|
|
8
|
-
*
|
|
9
|
-
* A transaction executes in three sequential phases:
|
|
10
|
-
* 1. SETUP – non-revertible; if this fails the entire transaction is rejected.
|
|
11
|
-
* 2. APP_LOGIC – revertible; its state changes are rolled back on failure.
|
|
12
|
-
* 3. TEARDOWN – revertible; always runs (even after app-logic revert) so the fee-payment contract can clean up.
|
|
13
|
-
*
|
|
14
|
-
* Only APP_LOGIC and TEARDOWN can produce a revert code. SETUP failures throw instead and discard the transaction
|
|
15
|
-
* entirely.
|
|
16
|
-
*/ export var RevertCodeEnum = /*#__PURE__*/ function(RevertCodeEnum) {
|
|
6
|
+
/** Whether a transaction's public execution reverted. */ export var RevertCodeEnum = /*#__PURE__*/ function(RevertCodeEnum) {
|
|
17
7
|
/** All phases completed successfully; no state was rolled back. */ RevertCodeEnum[RevertCodeEnum["OK"] = 0] = "OK";
|
|
18
|
-
/**
|
|
19
|
-
/** TEARDOWN reverted; its state changes were discarded. APP_LOGIC succeeded. */ RevertCodeEnum[RevertCodeEnum["TEARDOWN_REVERTED"] = 2] = "TEARDOWN_REVERTED";
|
|
20
|
-
/** Both APP_LOGIC and TEARDOWN reverted; only SETUP effects are kept. */ RevertCodeEnum[RevertCodeEnum["BOTH_REVERTED"] = 3] = "BOTH_REVERTED";
|
|
8
|
+
/** One or more revertible phases reverted; their state changes were discarded. */ RevertCodeEnum[RevertCodeEnum["REVERTED"] = 1] = "REVERTED";
|
|
21
9
|
return RevertCodeEnum;
|
|
22
10
|
}({});
|
|
23
|
-
function
|
|
24
|
-
return value
|
|
11
|
+
/** Returns a valid RevertCodeEnum, coercing any value >= 1 to REVERTED. */ function toRevertCodeEnum(value) {
|
|
12
|
+
return value >= 1 ? 1 : 0;
|
|
25
13
|
}
|
|
26
14
|
_computedKey = inspect.custom;
|
|
27
15
|
/**
|
|
@@ -32,9 +20,10 @@ _computedKey = inspect.custom;
|
|
|
32
20
|
this.code = e.valueOf();
|
|
33
21
|
}
|
|
34
22
|
static OK = new RevertCode(0);
|
|
35
|
-
static
|
|
36
|
-
static
|
|
37
|
-
static
|
|
23
|
+
static REVERTED = new RevertCode(1);
|
|
24
|
+
/** @deprecated Use REVERTED instead. */ static APP_LOGIC_REVERTED = RevertCode.REVERTED;
|
|
25
|
+
/** @deprecated Use REVERTED instead. */ static TEARDOWN_REVERTED = RevertCode.REVERTED;
|
|
26
|
+
/** @deprecated Use REVERTED instead. */ static BOTH_REVERTED = RevertCode.REVERTED;
|
|
38
27
|
getCode() {
|
|
39
28
|
return this.code;
|
|
40
29
|
}
|
|
@@ -49,11 +38,7 @@ _computedKey = inspect.custom;
|
|
|
49
38
|
case 0:
|
|
50
39
|
return 'OK';
|
|
51
40
|
case 1:
|
|
52
|
-
return '
|
|
53
|
-
case 2:
|
|
54
|
-
return 'Teardown reverted';
|
|
55
|
-
case 3:
|
|
56
|
-
return 'Both reverted';
|
|
41
|
+
return 'Reverted';
|
|
57
42
|
default:
|
|
58
43
|
return `Unknown RevertCode: ${this.code}`;
|
|
59
44
|
}
|
|
@@ -62,7 +47,7 @@ _computedKey = inspect.custom;
|
|
|
62
47
|
return this.code;
|
|
63
48
|
}
|
|
64
49
|
static get schema() {
|
|
65
|
-
return z.
|
|
50
|
+
return z.number().int().min(0).transform((value)=>new RevertCode(toRevertCodeEnum(value)));
|
|
66
51
|
}
|
|
67
52
|
/**
|
|
68
53
|
* Creates a RevertCode from a plain object without Zod validation.
|
|
@@ -75,10 +60,10 @@ _computedKey = inspect.custom;
|
|
|
75
60
|
return obj;
|
|
76
61
|
}
|
|
77
62
|
const code = typeof obj === 'number' ? obj : obj.code ?? obj;
|
|
78
|
-
if (
|
|
63
|
+
if (typeof code !== 'number' || code < 0) {
|
|
79
64
|
throw new Error(`Invalid RevertCode: ${code}`);
|
|
80
65
|
}
|
|
81
|
-
return new RevertCode(code);
|
|
66
|
+
return new RevertCode(toRevertCodeEnum(code));
|
|
82
67
|
}
|
|
83
68
|
/**
|
|
84
69
|
* Having different serialization methods allows for
|
|
@@ -106,10 +91,10 @@ _computedKey = inspect.custom;
|
|
|
106
91
|
return this.toBuffer().length;
|
|
107
92
|
}
|
|
108
93
|
static fromNumber(code) {
|
|
109
|
-
if (
|
|
94
|
+
if (code < 0) {
|
|
110
95
|
throw new Error(`Invalid RevertCode: ${code}`);
|
|
111
96
|
}
|
|
112
|
-
return new RevertCode(code);
|
|
97
|
+
return new RevertCode(toRevertCodeEnum(code));
|
|
113
98
|
}
|
|
114
99
|
static fromField(field) {
|
|
115
100
|
return RevertCode.fromNumber(field.toNumber());
|
|
@@ -123,7 +108,7 @@ _computedKey = inspect.custom;
|
|
|
123
108
|
const code = reader.readBytes(RevertCode.PACKED_SIZE_IN_BYTES).readUInt8(0);
|
|
124
109
|
return RevertCode.fromNumber(code);
|
|
125
110
|
}
|
|
126
|
-
static NUM_OPTIONS =
|
|
111
|
+
static NUM_OPTIONS = 2;
|
|
127
112
|
static random() {
|
|
128
113
|
return new RevertCode(Math.floor(Math.random() * RevertCode.NUM_OPTIONS));
|
|
129
114
|
}
|