See #1358 for more information
Currently public functions have no context object, which leads them to have completely different code paths to the private counter part, even if the goal of the function is the same.
Currently a private function looks as follows:
fn transfer(
//*********************************/
// Should eventually be hidden:
inputs: PrivateContextInputs,
//*********************************/
amount: u120,
sender: Field,
recipient: Field,
) -> distinct pub abi::PrivateCircuitPublicInputs {
let mut context = Context::new(inputs, abi::hash_args([amount as Field, sender, recipient]));
As a reminder, here's that struct:
struct PrivateContextInputs {
call_context : CallContext,
roots: CommitmentTreesRoots,
contract_deployment_data: ContractDeploymentData,
private_global_variables: PrivateGlobalVariables,
}
While a public function looks like this:
fn transfer(
amount: u120,
sender: Field,
recipient: Field,
) {
...logic
However, there is also a PublicContextInputs struct:
struct PublicContextInputs {
call_context: CallContext,
block_data: ConstantHistoricBlockData,
public_global_variables: PublicGlobalVariables,
}
That contains a call context object.
We should be able to call methods like context.this_address() and context.this_portal_address() with the same syntax in Private and Public contexts.
Note: these contexts will eventually be hidden from the developer, they will be wrapped in macros / handled at the compiler level
See #1358 for more information
Currently public functions have no context object, which leads them to have completely different code paths to the private counter part, even if the goal of the function is the same.
Currently a private function looks as follows:
As a reminder, here's that struct:
While a public function looks like this:
However, there is also a PublicContextInputs struct:
That contains a call context object.
We should be able to call methods like
context.this_address()andcontext.this_portal_address()with the same syntax in Private and Public contexts.Note: these contexts will eventually be hidden from the developer, they will be wrapped in macros / handled at the compiler level