diff --git a/docs/docs/dev_docs/contracts/syntax/state_variables.md b/docs/docs/dev_docs/contracts/syntax/state_variables.md index 34ff144f67f7..b11d30dd952f 100644 --- a/docs/docs/dev_docs/contracts/syntax/state_variables.md +++ b/docs/docs/dev_docs/contracts/syntax/state_variables.md @@ -28,7 +28,7 @@ The BoolSerialisationMethods is part of the Aztec stdlib: It contains methods that instruct its PublicState wrapper how to serialize and deserialize a boolean to and from a Field, which is the data type being saved in the public state tree. -The Aztec stdlib provides serialization methods for various common types. Check [here](https://github.com/AztecProtocol/aztec-packages/blob/master/yarn-project/aztec-nr/aztec/src/types/type_serialisation) for the complete list. +The Aztec stdlib provides serialization methods for various common types. Check [here](https://github.com/AztecProtocol/aztec-packages/blob/master/yarn-project/aztec-nr/aztec/src/types/type_serialization) for the complete list. ### Custom types @@ -36,7 +36,7 @@ It's possible to create a public state for any types. Simply define methods that The methods should be implemented in a struct that conforms to the following interface: -#include_code TypeSerialisationInterface /yarn-project/aztec-nr/aztec/src/types/type_serialisation.nr rust +#include_code TypeSerialisationInterface /yarn-project/aztec-nr/aztec/src/types/type_serialization.nr rust For example, to create a public state for the following type: diff --git a/yarn-project/aztec-nr/aztec/src/account.nr b/yarn-project/aztec-nr/aztec/src/account.nr index 9f0eb720099e..faabe7283677 100644 --- a/yarn-project/aztec-nr/aztec/src/account.nr +++ b/yarn-project/aztec-nr/aztec/src/account.nr @@ -2,7 +2,7 @@ use crate::entrypoint::EntrypointPayload; use crate::context::{PrivateContext, PublicContext, Context}; use crate::oracle::compute_selector::compute_selector; use crate::state_vars::{map::Map, public_state::PublicState}; -use crate::types::type_serialisation::bool_serialisation::{BoolSerialisationMethods,BOOL_SERIALIZED_LEN}; +use crate::types::type_serialization::bool_serialization::{BoolSerialisationMethods,BOOL_SERIALIZED_LEN}; use crate::auth::IS_VALID_SELECTOR; struct AccountActions { diff --git a/yarn-project/aztec-nr/aztec/src/state_vars/public_state.nr b/yarn-project/aztec-nr/aztec/src/state_vars/public_state.nr index e989a8bc0eb5..56f2de4190ae 100644 --- a/yarn-project/aztec-nr/aztec/src/state_vars/public_state.nr +++ b/yarn-project/aztec-nr/aztec/src/state_vars/public_state.nr @@ -1,12 +1,12 @@ use crate::context::{Context}; use crate::oracle::storage::storage_read; use crate::oracle::storage::storage_write; -use crate::types::type_serialisation::TypeSerialisationInterface; +use crate::types::type_serialization::TypeSerialisationInterface; use dep::std::option::Option; struct PublicState { storage_slot: Field, - serialisation_methods: TypeSerialisationInterface, + serialization_methods: TypeSerialisationInterface, } impl PublicState { @@ -14,21 +14,21 @@ impl PublicState { // Note: Passing the contexts to new(...) just to have an interface compatible with a Map. _: Context, storage_slot: Field, - serialisation_methods: TypeSerialisationInterface, + serialization_methods: TypeSerialisationInterface, ) -> Self { assert(storage_slot != 0, "Storage slot 0 not allowed. Storage slots must start from 1."); PublicState { storage_slot, - serialisation_methods, + serialization_methods, } } fn read(self) -> T { - storage_read(self.storage_slot, self.serialisation_methods.deserialize) + storage_read(self.storage_slot, self.serialization_methods.deserialize) } fn write(self, value: T) { - let serialize = self.serialisation_methods.serialize; + let serialize = self.serialization_methods.serialize; let fields = serialize(value); storage_write(self.storage_slot, fields); } diff --git a/yarn-project/aztec-nr/aztec/src/types.nr b/yarn-project/aztec-nr/aztec/src/types.nr index 802ce648c491..a93267973be8 100644 --- a/yarn-project/aztec-nr/aztec/src/types.nr +++ b/yarn-project/aztec-nr/aztec/src/types.nr @@ -1,4 +1,4 @@ mod address; mod point; mod vec; // This can/should be moved out into an official noir library -mod type_serialisation; \ No newline at end of file +mod type_serialization; \ No newline at end of file diff --git a/yarn-project/aztec-nr/aztec/src/types/point.nr b/yarn-project/aztec-nr/aztec/src/types/point.nr index 697929d57be1..c55369a8ae23 100644 --- a/yarn-project/aztec-nr/aztec/src/types/point.nr +++ b/yarn-project/aztec-nr/aztec/src/types/point.nr @@ -1,4 +1,4 @@ -use crate::types::type_serialisation::TypeSerialisationInterface; +use crate::types::type_serialization::TypeSerialisationInterface; struct Point { x: Field, diff --git a/yarn-project/aztec-nr/aztec/src/types/type_serialisation/bool_serialisation.nr b/yarn-project/aztec-nr/aztec/src/types/type_serialisation/bool_serialization.nr similarity index 84% rename from yarn-project/aztec-nr/aztec/src/types/type_serialisation/bool_serialisation.nr rename to yarn-project/aztec-nr/aztec/src/types/type_serialisation/bool_serialization.nr index 90b9114586d5..7680d40797b5 100644 --- a/yarn-project/aztec-nr/aztec/src/types/type_serialisation/bool_serialisation.nr +++ b/yarn-project/aztec-nr/aztec/src/types/type_serialisation/bool_serialization.nr @@ -1,4 +1,4 @@ -use crate::types::type_serialisation::TypeSerialisationInterface; +use crate::types::type_serialization::TypeSerialisationInterface; global BOOL_SERIALIZED_LEN: Field = 1; diff --git a/yarn-project/aztec-nr/aztec/src/types/type_serialisation/field_serialisation.nr b/yarn-project/aztec-nr/aztec/src/types/type_serialisation/field_serialization.nr similarity index 84% rename from yarn-project/aztec-nr/aztec/src/types/type_serialisation/field_serialisation.nr rename to yarn-project/aztec-nr/aztec/src/types/type_serialisation/field_serialization.nr index 36b6423284f2..d8fc2be17873 100644 --- a/yarn-project/aztec-nr/aztec/src/types/type_serialisation/field_serialisation.nr +++ b/yarn-project/aztec-nr/aztec/src/types/type_serialisation/field_serialization.nr @@ -1,4 +1,4 @@ -use crate::types::type_serialisation::TypeSerialisationInterface; +use crate::types::type_serialization::TypeSerialisationInterface; global FIELD_SERIALIZED_LEN: Field = 1; diff --git a/yarn-project/aztec-nr/aztec/src/types/type_serialisation/u32_serialisation.nr b/yarn-project/aztec-nr/aztec/src/types/type_serialisation/u32_serialization.nr similarity index 84% rename from yarn-project/aztec-nr/aztec/src/types/type_serialisation/u32_serialisation.nr rename to yarn-project/aztec-nr/aztec/src/types/type_serialisation/u32_serialization.nr index 5bef7f90dc52..44201df676f7 100644 --- a/yarn-project/aztec-nr/aztec/src/types/type_serialisation/u32_serialisation.nr +++ b/yarn-project/aztec-nr/aztec/src/types/type_serialisation/u32_serialization.nr @@ -1,4 +1,4 @@ -use crate::types::type_serialisation::TypeSerialisationInterface; +use crate::types::type_serialization::TypeSerialisationInterface; global U32_SERIALIZED_LEN: Field = 1; diff --git a/yarn-project/aztec-nr/aztec/src/types/type_serialisation.nr b/yarn-project/aztec-nr/aztec/src/types/type_serialization.nr similarity index 53% rename from yarn-project/aztec-nr/aztec/src/types/type_serialisation.nr rename to yarn-project/aztec-nr/aztec/src/types/type_serialization.nr index 075f1dc05ff3..cb4d293dde20 100644 --- a/yarn-project/aztec-nr/aztec/src/types/type_serialisation.nr +++ b/yarn-project/aztec-nr/aztec/src/types/type_serialization.nr @@ -1,9 +1,9 @@ -mod bool_serialisation; -mod field_serialisation; -mod u32_serialisation; +mod bool_serialization; +mod field_serialization; +mod u32_serialization; /** - * Before Noir supports traits, a way of specifying the serialisation and deserialisation methods for a type. + * Before Noir supports traits, a way of specifying the serialization and deserialization methods for a type. */ // docs:start:TypeSerialisationInterface struct TypeSerialisationInterface { diff --git a/yarn-project/foundation/src/fields/coordinate.ts b/yarn-project/foundation/src/fields/coordinate.ts index 73847419771b..aada6d1ff806 100644 --- a/yarn-project/foundation/src/fields/coordinate.ts +++ b/yarn-project/foundation/src/fields/coordinate.ts @@ -38,7 +38,7 @@ export class Coordinate { /** * serializes the oblect to buffer of 2 fields. - * @returns A buffer serialisation of the object. + * @returns A buffer serialization of the object. */ toFieldsBuffer(): Buffer { return Buffer.concat([this.fields[0].toBuffer(), this.fields[1].toBuffer()]); @@ -46,7 +46,7 @@ export class Coordinate { /** * serializes the coordinate to a single 32 byte buffer. - * @returns A buffer serialisation of the object. + * @returns A buffer serialization of the object. */ toBuffer(): Buffer { const buf0 = this.fields[0].toBuffer(); diff --git a/yarn-project/foundation/src/json-rpc/convert.ts b/yarn-project/foundation/src/json-rpc/convert.ts index 53a3fe0d3b30..af378fa4cc11 100644 --- a/yarn-project/foundation/src/json-rpc/convert.ts +++ b/yarn-project/foundation/src/json-rpc/convert.ts @@ -88,7 +88,7 @@ export function convertFromJsonObj(cc: ClassConverter, obj: any): any { if (cc.isRegisteredClassName(obj.type)) { return cc.toClassObj(obj); } else { - throw new Error(`Object ${obj.type} not registered for serialisation FROM JSON`); + throw new Error(`Object ${obj.type} not registered for serialization FROM JSON`); } } @@ -154,7 +154,7 @@ export function convertToJsonObj(cc: ClassConverter, obj: any): any { return newObj; } else { // Throw if this is a non-primitive class that was not registered - throw new Error(`Object ${obj.constructor.name} not registered for serialisation TO JSON`); + throw new Error(`Object ${obj.constructor.name} not registered for serialization TO JSON`); } } diff --git a/yarn-project/noir-compiler/src/contract-interface-gen/noir.ts b/yarn-project/noir-compiler/src/contract-interface-gen/noir.ts index cc020b52947a..c043d85d4829 100644 --- a/yarn-project/noir-compiler/src/contract-interface-gen/noir.ts +++ b/yarn-project/noir-compiler/src/contract-interface-gen/noir.ts @@ -124,7 +124,7 @@ function collectParametersForSerialisation(parameters: ABIVariable[]) { /** * Generates Noir code for serialising the parameters into an array of fields. * @param parameters - Parameters to serialize. - * @returns The serialisation code. + * @returns The serialization code. */ function generateSerialisation(parameters: ABIParameter[]) { const flattened = collectParametersForSerialisation(parameters); @@ -142,7 +142,7 @@ function generateSerialisation(parameters: ABIParameter[]) { function generateFunctionInterface(functionData: FunctionAbi, kind: 'private' | 'public') { const { name, parameters } = functionData; const selector = FunctionSelector.fromNameAndParameters(name, parameters); - const serialisation = generateSerialisation(parameters); + const serialization = generateSerialisation(parameters); const contextType = kind === 'private' ? '&mut PrivateContext' : 'PublicContext'; const callStatement = generateCallStatement(selector, functionData.functionType); const allParams = ['self', `context: ${contextType}`, ...parameters.map(p => generateParameter(p, functionData))]; @@ -154,7 +154,7 @@ function generateFunctionInterface(functionData: FunctionAbi, kind: 'private' | fn ${name}( ${allParams.join(',\n ')} ) ${retType}{ -${serialisation} +${serialization} ${callStatement} } `; diff --git a/yarn-project/noir-contracts/src/contracts/card_game_contract/src/game.nr b/yarn-project/noir-contracts/src/contracts/card_game_contract/src/game.nr index 19ddbae1d894..dfc48b349546 100644 --- a/yarn-project/noir-contracts/src/contracts/card_game_contract/src/game.nr +++ b/yarn-project/noir-contracts/src/contracts/card_game_contract/src/game.nr @@ -1,4 +1,4 @@ -use dep::aztec::types::type_serialisation::TypeSerialisationInterface; +use dep::aztec::types::type_serialization::TypeSerialisationInterface; use crate::cards::Card; global NUMBER_OF_PLAYERS = 2; diff --git a/yarn-project/noir-contracts/src/contracts/child_contract/src/main.nr b/yarn-project/noir-contracts/src/contracts/child_contract/src/main.nr index 7ae67f4b27dd..e65f5e61048b 100644 --- a/yarn-project/noir-contracts/src/contracts/child_contract/src/main.nr +++ b/yarn-project/noir-contracts/src/contracts/child_contract/src/main.nr @@ -10,7 +10,7 @@ contract Child { compute_selector::compute_selector, }, state_vars::public_state::PublicState, - types::type_serialisation::field_serialisation::{FieldSerialisationMethods, FIELD_SERIALIZED_LEN}, + types::type_serialization::field_serialization::{FieldSerialisationMethods, FIELD_SERIALIZED_LEN}, }; struct Storage { diff --git a/yarn-project/noir-contracts/src/contracts/docs_example_contract/src/actions.nr b/yarn-project/noir-contracts/src/contracts/docs_example_contract/src/actions.nr index ae6a34f0804c..28c43227c250 100644 --- a/yarn-project/noir-contracts/src/contracts/docs_example_contract/src/actions.nr +++ b/yarn-project/noir-contracts/src/contracts/docs_example_contract/src/actions.nr @@ -6,7 +6,7 @@ use dep::aztec::state_vars::{ immutable_singleton::ImmutableSingleton, map::Map, public_state::PublicState, set::Set, singleton::Singleton, }; -use dep::aztec::types::type_serialisation::bool_serialisation::BOOL_SERIALIZED_LEN; +use dep::aztec::types::type_serialization::bool_serialization::BOOL_SERIALIZED_LEN; use dep::std::option::Option; use crate::types::{ diff --git a/yarn-project/noir-contracts/src/contracts/docs_example_contract/src/main.nr b/yarn-project/noir-contracts/src/contracts/docs_example_contract/src/main.nr index 0d456bfd2f7a..31709e84c77e 100644 --- a/yarn-project/noir-contracts/src/contracts/docs_example_contract/src/main.nr +++ b/yarn-project/noir-contracts/src/contracts/docs_example_contract/src/main.nr @@ -13,7 +13,7 @@ contract DocsExample { }, }; // docs:start:state_vars-PublicStateBoolImport - use dep::aztec::types::type_serialisation::bool_serialisation::{ + use dep::aztec::types::type_serialization::bool_serialization::{ BoolSerialisationMethods, BOOL_SERIALIZED_LEN, }; // docs:end:state_vars-PublicStateBoolImport diff --git a/yarn-project/noir-contracts/src/contracts/docs_example_contract/src/types/queen.nr b/yarn-project/noir-contracts/src/contracts/docs_example_contract/src/types/queen.nr index ff0d260d7ff8..44062efdb578 100644 --- a/yarn-project/noir-contracts/src/contracts/docs_example_contract/src/types/queen.nr +++ b/yarn-project/noir-contracts/src/contracts/docs_example_contract/src/types/queen.nr @@ -1,4 +1,4 @@ -use dep::aztec::types::type_serialisation::TypeSerialisationInterface; +use dep::aztec::types::type_serialization::TypeSerialisationInterface; // docs:start:state_vars-CustomStruct struct Queen { diff --git a/yarn-project/noir-contracts/src/contracts/lending_contract/src/asset.nr b/yarn-project/noir-contracts/src/contracts/lending_contract/src/asset.nr index d77b292fd54f..1fe90d641bed 100644 --- a/yarn-project/noir-contracts/src/contracts/lending_contract/src/asset.nr +++ b/yarn-project/noir-contracts/src/contracts/lending_contract/src/asset.nr @@ -1,4 +1,4 @@ -use dep::aztec::types::type_serialisation::TypeSerialisationInterface; +use dep::aztec::types::type_serialization::TypeSerialisationInterface; // Struct to be used to represent "totals". Generally, there should be one per asset. // It stores the global values that are shared among all users, such as an accumulator diff --git a/yarn-project/noir-contracts/src/contracts/lending_contract/src/main.nr b/yarn-project/noir-contracts/src/contracts/lending_contract/src/main.nr index 5abaf073453b..f4cd82b550a7 100644 --- a/yarn-project/noir-contracts/src/contracts/lending_contract/src/main.nr +++ b/yarn-project/noir-contracts/src/contracts/lending_contract/src/main.nr @@ -20,8 +20,8 @@ contract Lending { map::Map, public_state::PublicState, }, - types::type_serialisation::{ - field_serialisation::{FieldSerialisationMethods, FIELD_SERIALIZED_LEN}, + types::type_serialization::{ + field_serialization::{FieldSerialisationMethods, FIELD_SERIALIZED_LEN}, TypeSerialisationInterface, }, }; diff --git a/yarn-project/noir-contracts/src/contracts/non_native_token_contract/src/main.nr b/yarn-project/noir-contracts/src/contracts/non_native_token_contract/src/main.nr index 86ec474e02b4..61e6da1201e4 100644 --- a/yarn-project/noir-contracts/src/contracts/non_native_token_contract/src/main.nr +++ b/yarn-project/noir-contracts/src/contracts/non_native_token_contract/src/main.nr @@ -40,7 +40,7 @@ contract NonNativeToken { }, oracle::compute_selector::compute_selector, state_vars::{map::Map, public_state::PublicState, set::Set}, - types::type_serialisation::field_serialisation::{ + types::type_serialization::field_serialization::{ FieldSerialisationMethods, FIELD_SERIALIZED_LEN, }, }; diff --git a/yarn-project/noir-contracts/src/contracts/price_feed_contract/src/asset.nr b/yarn-project/noir-contracts/src/contracts/price_feed_contract/src/asset.nr index 83d0bf050e8e..0061f1b94fc2 100644 --- a/yarn-project/noir-contracts/src/contracts/price_feed_contract/src/asset.nr +++ b/yarn-project/noir-contracts/src/contracts/price_feed_contract/src/asset.nr @@ -1,4 +1,4 @@ -use dep::aztec::types::type_serialisation::TypeSerialisationInterface; +use dep::aztec::types::type_serialization::TypeSerialisationInterface; struct Asset { price: u120, diff --git a/yarn-project/noir-contracts/src/contracts/public_token_contract/src/main.nr b/yarn-project/noir-contracts/src/contracts/public_token_contract/src/main.nr index 12d2b7af52d3..773e5eea1c55 100644 --- a/yarn-project/noir-contracts/src/contracts/public_token_contract/src/main.nr +++ b/yarn-project/noir-contracts/src/contracts/public_token_contract/src/main.nr @@ -12,7 +12,7 @@ contract PublicToken { map::Map, public_state::PublicState, }, - types::type_serialisation::field_serialisation::{ + types::type_serialization::field_serialization::{ FieldSerialisationMethods, FIELD_SERIALIZED_LEN, }, }; diff --git a/yarn-project/noir-contracts/src/contracts/stateful_test_contract/src/main.nr b/yarn-project/noir-contracts/src/contracts/stateful_test_contract/src/main.nr index 387e290d237f..ee0f40d1bc55 100644 --- a/yarn-project/noir-contracts/src/contracts/stateful_test_contract/src/main.nr +++ b/yarn-project/noir-contracts/src/contracts/stateful_test_contract/src/main.nr @@ -13,7 +13,7 @@ contract StatefulTest { utils as note_utils, }, state_vars::{map::Map, public_state::PublicState, set::Set}, - types::type_serialisation::field_serialisation::{ + types::type_serialization::field_serialization::{ FieldSerialisationMethods, FIELD_SERIALIZED_LEN, }, }; diff --git a/yarn-project/noir-contracts/src/contracts/token_bridge_contract/src/main.nr b/yarn-project/noir-contracts/src/contracts/token_bridge_contract/src/main.nr index 8d72b7d90a19..0a215fb46bbf 100644 --- a/yarn-project/noir-contracts/src/contracts/token_bridge_contract/src/main.nr +++ b/yarn-project/noir-contracts/src/contracts/token_bridge_contract/src/main.nr @@ -10,7 +10,7 @@ contract TokenBridge { use dep::aztec::{ context::{Context}, state_vars::{public_state::PublicState}, - types::type_serialisation::field_serialisation::{ + types::type_serialization::field_serialization::{ FieldSerialisationMethods, FIELD_SERIALIZED_LEN, }, types::address::{AztecAddress, EthereumAddress}, diff --git a/yarn-project/noir-contracts/src/contracts/token_contract/src/main.nr b/yarn-project/noir-contracts/src/contracts/token_contract/src/main.nr index 0377b722bb76..09e876f0fcc6 100644 --- a/yarn-project/noir-contracts/src/contracts/token_contract/src/main.nr +++ b/yarn-project/noir-contracts/src/contracts/token_contract/src/main.nr @@ -29,7 +29,7 @@ contract Token { }, context::{PrivateContext, PublicContext, Context}, state_vars::{map::Map, public_state::PublicState, set::Set}, - types::type_serialisation::field_serialisation::{ + types::type_serialization::field_serialization::{ FieldSerialisationMethods, FIELD_SERIALIZED_LEN, }, types::address::{AztecAddress},