Skip to content
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
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,7 @@ base64 = "0.13.0"
[features]
default = ["sha2", "std"]
std = ["borsh/std", "evm/std", "primitive-types/std", "rlp/std", "sha3/std", "ethabi/std", "logos/std", "bn/std"]
engine = []
contract = ["engine"]
contract = []
evm_bully = []
log = []
meta-call = ["contract"]
Expand Down
2 changes: 1 addition & 1 deletion etc/state-migration-test/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,4 @@ rpath = false

[dependencies]
borsh = { version = "0.8.2", default-features = false }
aurora-engine = { path = "../../", default-features = false, features = ["sha2", "engine"] }
aurora-engine = { path = "../../", default-features = false, features = ["sha2"] }
1 change: 0 additions & 1 deletion src/deposit_event.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ impl DepositedEvent {
}

/// Parses raw Ethereum logs proof's entry data
#[cfg(feature = "engine")]
pub fn from_log_entry_data(data: &[u8]) -> Self {
let event = EthEvent::fetch_log_entry_data(DEPOSITED_EVENT, Self::event_params(), data);
let sender = event.log.params[0].value.clone().into_address().unwrap().0;
Expand Down
5 changes: 0 additions & 5 deletions src/fungible_token.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
use crate::prelude::format;
use crate::types::*;
use borsh::{BorshDeserialize, BorshSerialize};
#[cfg(feature = "engine")]
use {
crate::connector,
crate::engine,
Expand All @@ -12,9 +11,7 @@ use {
crate::storage,
};

#[cfg(feature = "engine")]
const GAS_FOR_RESOLVE_TRANSFER: Gas = 5_000_000_000_000;
#[cfg(feature = "engine")]
const GAS_FOR_FT_ON_TRANSFER: Gas = 10_000_000_000_000;

#[derive(Debug, Default, BorshDeserialize, BorshSerialize)]
Expand All @@ -29,7 +26,6 @@ pub struct FungibleToken {
pub account_storage_usage: StorageUsage,
}

#[cfg(feature = "engine")]
impl FungibleToken {
pub fn new() -> Self {
Self::default()
Expand Down Expand Up @@ -382,7 +378,6 @@ impl FungibleToken {
} else {
let min_balance = self.storage_balance_bounds().min;
if amount < min_balance {
#[cfg(feature = "log")]
sdk::panic_utf8(b"ERR_ATTACHED_DEPOSIT_NOT_ENOUGH");
}

Expand Down
1 change: 0 additions & 1 deletion src/json.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
use super::prelude::*;

use alloc::collections::BTreeMap;
use core::convert::From;
use rjson::{Array, Null, Object, Value};

Expand Down
10 changes: 1 addition & 9 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ extern crate core;

use crate::parameters::PromiseCreateArgs;

#[cfg(feature = "engine")]
mod map;
#[cfg(feature = "meta-call")]
pub mod meta_parsing;
Expand All @@ -20,27 +19,20 @@ pub mod storage;
pub mod transaction;
pub mod types;

#[cfg(feature = "engine")]
mod admin_controlled;
#[cfg(feature = "engine")]
#[cfg_attr(not(feature = "contract"), allow(dead_code))]
mod connector;
mod deposit_event;
#[cfg(feature = "engine")]
pub mod engine;
#[cfg(any(feature = "engine", test))]
mod fungible_token;
#[cfg(feature = "engine")]
mod json;
mod log_entry;
mod precompiles;
#[cfg(feature = "engine")]
mod prover;
#[cfg(feature = "engine")]
pub mod sdk;

#[cfg(test)]
mod benches;
#[cfg(feature = "engine")]
mod state;
#[cfg(test)]
mod test_utils;
Expand Down
36 changes: 1 addition & 35 deletions src/parameters.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ use borsh::{BorshDeserialize, BorshSerialize};

use crate::prelude::{String, Vec};
use crate::types::{AccountId, Balance, RawAddress, RawH256, RawU256};
#[cfg(feature = "engine")]
use crate::{
admin_controlled::PausedMask,
json,
Expand Down Expand Up @@ -142,7 +141,6 @@ pub struct NEP141FtOnTransferArgs {
pub msg: String,
}

#[cfg(feature = "engine")]
impl TryFrom<json::JsonValue> for NEP141FtOnTransferArgs {
type Error = json::JsonError;

Expand All @@ -155,7 +153,6 @@ impl TryFrom<json::JsonValue> for NEP141FtOnTransferArgs {
}
}

#[cfg(feature = "engine")]
impl TryFrom<NEP141FtOnTransferArgs> for String {
type Error = json::ParseError;

Expand Down Expand Up @@ -183,7 +180,6 @@ pub struct PromiseCreateArgs {
pub attached_gas: u64,
}
/// Eth-connector deposit arguments
#[cfg(feature = "engine")]
#[derive(BorshSerialize, BorshDeserialize)]
pub struct DepositCallArgs {
/// Proof data
Expand All @@ -193,15 +189,13 @@ pub struct DepositCallArgs {
}

/// Eth-connector isUsedProof arguments
#[cfg(feature = "engine")]
#[derive(BorshSerialize, BorshDeserialize)]
pub struct IsUsedProofCallArgs {
/// Proof data
pub proof: Proof,
}

/// withdraw result for eth-connector
#[cfg(feature = "engine")]
#[derive(BorshSerialize)]
pub struct WithdrawResult {
pub amount: Balance,
Expand All @@ -210,7 +204,6 @@ pub struct WithdrawResult {
}

/// ft_resolve_transfer eth-connector call args
#[cfg(feature = "engine")]
#[derive(BorshSerialize)]
pub struct FtResolveTransfer {
pub receiver_id: AccountId,
Expand All @@ -219,18 +212,15 @@ pub struct FtResolveTransfer {
}

/// Fungible token storage balance
#[cfg(feature = "engine")]
#[derive(Default)]
pub struct StorageBalance {
pub total: Balance,
pub available: Balance,
}

#[cfg(feature = "engine")]
impl StorageBalance {
pub fn to_json_bytes(&self) -> Vec<u8> {
use alloc::format;
format!(
crate::prelude::format!(
"{{\"total\": \"{}\", \"available\": \"{}\",}}",
self.total.to_string(),
self.available.to_string()
Expand All @@ -241,7 +231,6 @@ impl StorageBalance {
}

/// resolve_transfer eth-connector call args
#[cfg(feature = "engine")]
#[derive(BorshSerialize, BorshDeserialize)]
pub struct ResolveTransferCallArgs {
pub sender_id: AccountId,
Expand All @@ -250,7 +239,6 @@ pub struct ResolveTransferCallArgs {
}

/// Finish deposit NEAR eth-connector call args
#[cfg(feature = "engine")]
#[derive(BorshSerialize, BorshDeserialize)]
pub struct FinishDepositCallArgs {
pub new_owner_id: AccountId,
Expand All @@ -262,15 +250,13 @@ pub struct FinishDepositCallArgs {
}

/// Deposit ETH args
#[cfg(feature = "engine")]
#[derive(Default, BorshDeserialize, BorshSerialize, Clone)]
pub struct DepositEthCallArgs {
pub proof: Proof,
pub relayer_eth_account: EthAddress,
}

/// Finish deposit NEAR eth-connector call args
#[cfg(feature = "engine")]
#[derive(BorshSerialize, BorshDeserialize)]
pub struct FinishDepositEthCallArgs {
pub new_owner_id: EthAddress,
Expand All @@ -291,7 +277,6 @@ pub struct InitCallArgs {
pub type SetContractDataCallArgs = InitCallArgs;

/// transfer eth-connector call args
#[cfg(feature = "engine")]
#[derive(BorshSerialize, BorshDeserialize)]
pub struct TransferCallCallArgs {
pub receiver_id: AccountId,
Expand All @@ -300,7 +285,6 @@ pub struct TransferCallCallArgs {
pub msg: String,
}

#[cfg(feature = "engine")]
impl From<json::JsonValue> for TransferCallCallArgs {
fn from(v: json::JsonValue) -> Self {
Self {
Expand All @@ -313,13 +297,11 @@ impl From<json::JsonValue> for TransferCallCallArgs {
}

/// storage_balance_of eth-connector call args
#[cfg(feature = "engine")]
#[derive(BorshSerialize, BorshDeserialize)]
pub struct StorageBalanceOfCallArgs {
pub account_id: AccountId,
}

#[cfg(feature = "engine")]
impl From<json::JsonValue> for StorageBalanceOfCallArgs {
fn from(v: json::JsonValue) -> Self {
Self {
Expand All @@ -329,14 +311,12 @@ impl From<json::JsonValue> for StorageBalanceOfCallArgs {
}

/// storage_deposit eth-connector call args
#[cfg(feature = "engine")]
#[derive(BorshSerialize, BorshDeserialize)]
pub struct StorageDepositCallArgs {
pub account_id: Option<AccountId>,
pub registration_only: Option<bool>,
}

#[cfg(feature = "engine")]
impl From<json::JsonValue> for StorageDepositCallArgs {
fn from(v: json::JsonValue) -> Self {
Self {
Expand All @@ -347,13 +327,11 @@ impl From<json::JsonValue> for StorageDepositCallArgs {
}

/// storage_withdraw eth-connector call args
#[cfg(feature = "engine")]
#[derive(BorshSerialize, BorshDeserialize)]
pub struct StorageWithdrawCallArgs {
pub amount: Option<u128>,
}

#[cfg(feature = "engine")]
impl From<json::JsonValue> for StorageWithdrawCallArgs {
fn from(v: json::JsonValue) -> Self {
Self {
Expand All @@ -363,15 +341,13 @@ impl From<json::JsonValue> for StorageWithdrawCallArgs {
}

/// transfer args for json invocation
#[cfg(feature = "engine")]
#[derive(BorshSerialize, BorshDeserialize)]
pub struct TransferCallArgs {
pub receiver_id: AccountId,
pub amount: Balance,
pub memo: Option<String>,
}

#[cfg(feature = "engine")]
impl From<json::JsonValue> for TransferCallArgs {
fn from(v: json::JsonValue) -> Self {
Self {
Expand All @@ -383,27 +359,23 @@ impl From<json::JsonValue> for TransferCallArgs {
}

/// withdraw NEAR eth-connector call args
#[cfg(feature = "engine")]
#[derive(BorshSerialize, BorshDeserialize)]
pub struct WithdrawCallArgs {
pub recipient_address: EthAddress,
pub amount: Balance,
}

/// balance_of args for json invocation
#[cfg(feature = "engine")]
#[derive(BorshSerialize, BorshDeserialize)]
pub struct BalanceOfCallArgs {
pub account_id: AccountId,
}

#[cfg(feature = "engine")]
#[derive(BorshSerialize, BorshDeserialize)]
pub struct BalanceOfEthCallArgs {
pub address: EthAddress,
}

#[cfg(feature = "engine")]
impl From<json::JsonValue> for BalanceOfCallArgs {
fn from(v: json::JsonValue) -> Self {
Self {
Expand All @@ -412,24 +384,20 @@ impl From<json::JsonValue> for BalanceOfCallArgs {
}
}

#[cfg(feature = "engine")]
#[derive(BorshSerialize, BorshDeserialize)]
pub struct RegisterRelayerCallArgs {
pub address: EthAddress,
}

#[cfg(feature = "engine")]
#[derive(BorshSerialize, BorshDeserialize)]
pub struct PauseEthConnectorCallArgs {
pub paused_mask: PausedMask,
}

#[cfg(feature = "engine")]
pub trait ExpectUtf8<T> {
fn expect_utf8(self, message: &[u8]) -> T;
}

#[cfg(feature = "engine")]
impl<T> ExpectUtf8<T> for Option<T> {
fn expect_utf8(self, message: &[u8]) -> T {
match self {
Expand All @@ -439,7 +407,6 @@ impl<T> ExpectUtf8<T> for Option<T> {
}
}

#[cfg(feature = "engine")]
impl<T, E> ExpectUtf8<T> for core::result::Result<T, E> {
fn expect_utf8(self, message: &[u8]) -> T {
match self {
Expand All @@ -449,7 +416,6 @@ impl<T, E> ExpectUtf8<T> for core::result::Result<T, E> {
}
}

#[cfg(feature = "engine")]
impl From<json::JsonValue> for ResolveTransferCallArgs {
fn from(v: json::JsonValue) -> Self {
Self {
Expand Down
1 change: 0 additions & 1 deletion src/precompiles/blake2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ mod consts {
pub(super) struct Blake2F<S>(PhantomData<S>);

impl<S> Blake2F<S> {
#[cfg_attr(not(feature = "engine"), allow(dead_code))]
pub(super) const ADDRESS: [u8; 20] = super::make_address(0, 9);
}

Expand Down
3 changes: 0 additions & 3 deletions src/precompiles/bn128.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,8 @@ mod consts {
pub(super) mod addresses {
use crate::precompiles;

#[cfg_attr(not(feature = "engine"), allow(dead_code))]
pub const ADD: [u8; 20] = precompiles::make_address(0, 6);
#[cfg_attr(not(feature = "engine"), allow(dead_code))]
pub const MUL: [u8; 20] = precompiles::make_address(0, 7);
#[cfg_attr(not(feature = "engine"), allow(dead_code))]
pub const PAIR: [u8; 20] = precompiles::make_address(0, 8);
}

Expand Down
2 changes: 0 additions & 2 deletions src/precompiles/hash.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ mod consts {
pub struct SHA256<S>(PhantomData<S>);

impl<S> SHA256<S> {
#[cfg_attr(not(feature = "engine"), allow(dead_code))]
pub(super) const ADDRESS: [u8; 20] = super::make_address(0, 2);
}

Expand Down Expand Up @@ -90,7 +89,6 @@ impl<S: AuroraState> Precompile<S> for SHA256<S> {
pub struct RIPEMD160<S>(PhantomData<S>);

impl<S> RIPEMD160<S> {
#[cfg_attr(not(feature = "engine"), allow(dead_code))]
pub(super) const ADDRESS: [u8; 20] = super::make_address(0, 3);
}

Expand Down
1 change: 0 additions & 1 deletion src/precompiles/identity.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ mod consts {
pub struct Identity<S>(PhantomData<S>);

impl<S> Identity<S> {
#[cfg_attr(not(feature = "engine"), allow(dead_code))]
pub(super) const ADDRESS: [u8; 20] = super::make_address(0, 4);
}

Expand Down
Loading