Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New Release #339

Merged
merged 2 commits into from
Nov 27, 2024
Merged
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
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
2 changes: 1 addition & 1 deletion app-derive/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* (c) 2021 Zondax GmbH
* (c) 2018-2024 Zondax AG
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion app-derive/src/unroll.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* (c) 2021 Zondax GmbH
* (c) 2018-2024 Zondax AG
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion app-derive/src/version.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* (c) 2021 Zondax GmbH
* (c) 2018-2024 Zondax AG
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion app-derive/tests/version.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* (c) 2021 Zondax GmbH
* (c) 2018-2024 Zondax AG
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
4 changes: 2 additions & 2 deletions app/Makefile.version
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Major
APPVERSION_M=1
# Minor
APPVERSION_N=0
APPVERSION_N=1
# Patch
APPVERSION_P=0
APPVERSION_P=0
2 changes: 1 addition & 1 deletion app/rust/src/constants.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* (c) 2021 Zondax GmbH
* (c) 2018-2024 Zondax AG
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion app/rust/src/crypto.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* (c) 2021 Zondax GmbH
* (c) 2018-2024 Zondax AG
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion app/rust/src/dispatcher.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* (c) 2021 Zondax GmbH
* (c) 2018-2024 Zondax AG
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion app/rust/src/handlers.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* (c) 2021 Zondax GmbH
* (c) 2018-2024 Zondax AG
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion app/rust/src/handlers/avax.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* (c) 2022 Zondax GmbH
* (c) 2018-2024 Zondax AG
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion app/rust/src/handlers/avax/message.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* (c) 2022 Zondax GmbH
* (c) 2018-2024 Zondax AG
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion app/rust/src/handlers/avax/sign_hash.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* (c) 2022 Zondax GmbH
* (c) 2018-2024 Zondax AG
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion app/rust/src/handlers/avax/signing.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* (c) 2022 Zondax GmbH
* (c) 2018-2024 Zondax AG
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion app/rust/src/handlers/dev.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* (c) 2021 Zondax GmbH
* (c) 2018-2024 Zondax AG
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion app/rust/src/handlers/dev/debug.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* (c) 2021 Zondax GmbH
* (c) 2018-2024 Zondax AG
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion app/rust/src/handlers/eth.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* (c) 2022 Zondax GmbH
* (c) 2018-2024 Zondax AG
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion app/rust/src/handlers/eth/personal_msg.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* (c) 2022 Zondax GmbH
* (c) 2018-2024 Zondax AG
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion app/rust/src/handlers/eth/provide_erc20.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* (c) 2021 Zondax GmbH
* (c) 2018-2024 Zondax AG
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion app/rust/src/handlers/eth/provide_nft_info.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* (c) 2022 Zondax GmbH
* (c) 2018-2024 Zondax AG
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion app/rust/src/handlers/eth/public_key.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* (c) 2021 Zondax GmbH
* (c) 2018-2024 Zondax AG
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion app/rust/src/handlers/eth/public_key/ui.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* (c) 2022 Zondax GmbH
* (c) 2018-2024 Zondax AG
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion app/rust/src/handlers/eth/set_plugin.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* (c) 2021 Zondax GmbH
* (c) 2018-2024 Zondax AG
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion app/rust/src/handlers/eth/signing.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* (c) 2022 Zondax GmbH
* (c) 2018-2024 Zondax AG
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion app/rust/src/handlers/lock.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* (c) 2021 Zondax GmbH
* (c) 2018-2024 Zondax AG
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion app/rust/src/handlers/public_key.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* (c) 2021 Zondax GmbH
* (c) 2018-2024 Zondax AG
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion app/rust/src/handlers/public_key/ui.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* (c) 2022 Zondax GmbH
* (c) 2018-2024 Zondax AG
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion app/rust/src/handlers/public_key/xpub.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* (c) 2022 Zondax GmbH
* (c) 2018-2024 Zondax AG
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion app/rust/src/handlers/utils.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* (c) 2021 Zondax GmbH
* (c) 2018-2024 Zondax AG
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion app/rust/src/handlers/version.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* (c) 2021 Zondax GmbH
* (c) 2018-2024 Zondax AG
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion app/rust/src/handlers/wallet_id.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* (c) 2021 Zondax GmbH
* (c) 2018-2024 Zondax AG
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion app/rust/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* (c) 2021 Zondax GmbH
* (c) 2018-2024 Zondax AG
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
5 changes: 4 additions & 1 deletion app/rust/src/parser.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* (c) 2021 Zondax GmbH
* (c) 2018-2024 Zondax AG
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -20,18 +20,21 @@ use zemu_sys::ViewError;
mod address;
mod asset_id;
mod avm_output;
mod chain_id;
mod constants;
mod coreth;
mod defer;
mod error;
mod initial_state;
mod inputs;
mod l1_validator;
mod message;
mod network_info;
mod node_id;
mod object_list;
mod operations;
mod outputs;
mod pchain_owner;
mod pvm_output;
mod subnet_auth;
mod subnet_id;
Expand Down
2 changes: 1 addition & 1 deletion app/rust/src/parser/address.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* (c) 2021 Zondax GmbH
* (c) 2018-2024 Zondax AG
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion app/rust/src/parser/asset_id.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* (c) 2021 Zondax GmbH
* (c) 2018-2024 Zondax AG
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion app/rust/src/parser/avm_output.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* (c) 2021 Zondax GmbH
* (c) 2018-2024 Zondax AG
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
89 changes: 89 additions & 0 deletions app/rust/src/parser/chain_id.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
/*******************************************************************************
* (c) 2018-2024 Zondax AG
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
********************************************************************************/
use crate::handlers::handle_ui_message;
use crate::sys::ViewError;
use core::{mem::MaybeUninit, ptr::addr_of_mut};
use nom::bytes::complete::take;

use crate::parser::{DisplayableItem, FromBytes, ParserError};
use crate::utils::hex_encode;

pub const CHAIN_ID_LEN: usize = 32;

#[derive(Clone, Copy, PartialEq, Eq)]
#[cfg_attr(test, derive(Debug))]
pub struct ChainId<'b>(&'b [u8; CHAIN_ID_LEN]);

impl<'b> ChainId<'b> {
pub fn new(id: &'b [u8; CHAIN_ID_LEN]) -> Self {
Self(id)
}
}

impl<'b> FromBytes<'b> for ChainId<'b> {
#[inline(never)]
fn from_bytes_into(
input: &'b [u8],
out: &mut MaybeUninit<Self>,
) -> Result<&'b [u8], nom::Err<ParserError>> {
crate::sys::zemu_log_stack("ChainId::from_bytes_into\x00");

let (rem, chain_id) = take(CHAIN_ID_LEN)(input)?;
// This would not fail as previous line ensures we take
// the right amount of bytes, also the alignemnt is correct
let chain_id = arrayref::array_ref!(chain_id, 0, CHAIN_ID_LEN);

//good ptr and no uninit reads
let out = out.as_mut_ptr();
unsafe {
addr_of_mut!((*out).0).write(&chain_id);
}

Ok(rem)
}
}

impl<'b> DisplayableItem for ChainId<'b> {
fn num_items(&self) -> Result<u8, ViewError> {
Ok(1)
}

fn render_item(
&self,
item_n: u8,
title: &mut [u8],
message: &mut [u8],
page: u8,
) -> Result<u8, ViewError> {
use bolos::{pic_str, PIC};

if item_n != 0 {
return Err(ViewError::NoData);
}
let prefix = pic_str!(b"0x"!);
let label = pic_str!(b"Chain ID");
title[..label.len()].copy_from_slice(label);

// prefix
let mut out = [0; CHAIN_ID_LEN * 2 + 2];
let mut sz = prefix.len();
out[..prefix.len()].copy_from_slice(&prefix[..]);

sz += hex_encode(self.0, &mut out[prefix.len()..]).map_err(|_| ViewError::Unknown)?;

handle_ui_message(&out[..sz], message, page)
}
}
12 changes: 10 additions & 2 deletions app/rust/src/parser/constants.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* (c) 2021 Zondax GmbH
* (c) 2018-2024 Zondax AG
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -19,14 +19,15 @@ pub const NETWORK_ID_MAINNET: u32 = 1;
pub const NETWORK_ID_FUJI: u32 = 5;
pub const NETWORK_ID_LOCAL: u32 = 12345;
pub const NETWORK_ID_CUSTOM: u32 = 1337;
pub const NETWORK_ID_DEVNET: u32 = 76;
pub const ETH_MAINNET_ID: u64 = 1;

// hrp
pub const HRP_MAINNET: &str = "avax";
pub const HRP_TESTNET: &str = "fuji";
pub const HRP_LOCAL: &str = "local";
pub const HRP_CUSTOM: &str = "custom";

pub const HRP_DEVNET: &str = "custom";
emmanuelm41 marked this conversation as resolved.
Show resolved Hide resolved
pub const TRANSFER_TX: u32 = 0;

// pvm transaction types
Expand All @@ -41,6 +42,13 @@ pub const PVM_REMOVE_SUBNET_VALIDATOR: u32 = 0x00000017;
pub const PVM_TRANSFORM_SUBNET: u32 = 0x00000018;
pub const PVM_ADD_PERMISSIONLESS_VALIDATOR: u32 = 0x00000019;
pub const PVM_ADD_PERMISSIONLESS_DELEGATOR: u32 = 0x0000001A;

pub const PVM_CONVERT_SUBNET_L1: u32 = 0x00000023;
pub const PVM_REGISTER_L1_VALIDATOR: u32 = 0x00000024;
pub const PVM_SET_L1_VALIDATOR_WEIGHT: u32 = 0x00000025;
pub const PVM_DISABLE_L1_VALIDATOR: u32 = 0x00000027;
pub const PVM_INCREASE_L1_VALIDATOR_BALANCE: u32 = 0x00000026;

// base tx for p-chain which collides with evm import tx.
// we should check chain-id
pub const PVM_BASE_TX: u32 = 0x00000000;
Expand Down
Loading
Loading