Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
use crate::protocol::{abis::function_selector::FunctionSelector, address::AztecAddress, traits::{Serialize, ToField}};
use crate::protocol::{abis::function_selector::FunctionSelector, address::AztecAddress, traits::Serialize};
use std::meta::derive;

// 3 * 32 + 3
global FUNCTION_CALL_SIZE_IN_BYTES: u32 = 99;

// @dev: If you change the following struct you have to update:
// - account_entrypoint.ts (specifically `getEntrypointAbi()`)
// - default_multi_call_entrypoint.ts (specifically `getEntrypointAbi()`)
Expand All @@ -21,25 +18,3 @@ pub struct FunctionCall {
pub hide_msg_sender: bool,
pub is_static: bool,
}

impl FunctionCall {
pub fn to_be_bytes(self) -> [u8; FUNCTION_CALL_SIZE_IN_BYTES] {
let mut bytes: [u8; FUNCTION_CALL_SIZE_IN_BYTES] = [0; FUNCTION_CALL_SIZE_IN_BYTES];
let args_hash_bytes: [u8; 32] = self.args_hash.to_be_bytes();
for i in 0..32 {
bytes[i] = args_hash_bytes[i];
}
let function_selector_bytes: [u8; 32] = self.function_selector.to_field().to_be_bytes();
for i in 0..32 {
bytes[i + 32] = function_selector_bytes[i];
}
let target_address_bytes: [u8; 32] = self.target_address.to_field().to_be_bytes();
for i in 0..32 {
bytes[i + 64] = target_address_bytes[i];
}
bytes[96] = self.is_public as u8;
bytes[97] = self.hide_msg_sender as u8;
bytes[98] = self.is_static as u8;
bytes
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@ use aztec::{
use std::meta::derive;

global DAPP_MAX_CALLS: u32 = 1;
// FUNCTION_CALL_SIZE_IN_BYTES * DAPP_MAX_CALLS + 32
global DAPP_PAYLOAD_SIZE_IN_BYTES: u32 = 130;

// @dev: If you change the following struct you have to update default_entrypoint.ts
#[derive(Serialize)]
Expand All @@ -31,18 +29,6 @@ impl Hash for DAppPayload {
}

impl DAppPayload {
// Serializes the payload as an array of bytes. Useful for hashing with sha256.
fn to_be_bytes(self) -> [u8; DAPP_PAYLOAD_SIZE_IN_BYTES] {
let mut bytes: BoundedVec<u8, DAPP_PAYLOAD_SIZE_IN_BYTES> = BoundedVec::new();

for i in 0..DAPP_MAX_CALLS {
bytes.extend_from_array(self.function_calls[i].to_be_bytes());
}
bytes.extend_from_array(self.tx_nonce.to_be_bytes::<32>());

bytes.storage()
}

// Executes all private and public calls
pub fn execute_calls(self, context: &mut PrivateContext, target_address: AztecAddress) {
for i in 0..DAPP_MAX_CALLS {
Expand Down
Loading