From 99634869db649e865a67d588024700fe0dcc80b0 Mon Sep 17 00:00:00 2001 From: Oleksandr Anyshchenko Date: Thu, 26 Oct 2023 19:39:49 +0100 Subject: [PATCH] Release 3.3.1 (#860) ## Release 3.3.1 ### Fixes - The smart contract owner whose account id is not the same as the contract account id can set ERC-20 metadata by [@aleksuss] ([#858]). --- CHANGES.md | 12 +++- Cargo.lock | 2 +- VERSION | 2 +- engine-tests/src/tests/erc20.rs | 68 +++++++++++++++++++- engine-tests/src/tests/sanity.rs | 5 +- engine/Cargo.toml | 2 +- engine/src/contract_methods/connector/mod.rs | 2 +- engine/src/pausables.rs | 2 +- 8 files changed, 86 insertions(+), 9 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index 918e3f461..48935660a 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -7,6 +7,15 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +## [3.3.1] 2023-10-26 + +### Fixes + +- The smart contract owner whose account id is not the same as the contract account id can set ERC-20 metadata + by [@aleksuss] ([#858]). + +[#858]: https://github.com/aurora-is-near/aurora-engine/pull/858 + ## [3.3.0] 2023-10-23 ### Changes @@ -538,7 +547,8 @@ struct SubmitResult { ## [1.0.0] - 2021-05-12 -[Unreleased]: https://github.com/aurora-is-near/aurora-engine/compare/3.3.0...develop +[Unreleased]: https://github.com/aurora-is-near/aurora-engine/compare/3.3.1...develop +[3.3.1]: https://github.com/aurora-is-near/aurora-engine/compare/3.3.0...3.3.1 [3.3.0]: https://github.com/aurora-is-near/aurora-engine/compare/3.2.0...3.3.0 [3.2.0]: https://github.com/aurora-is-near/aurora-engine/compare/3.1.0...3.2.0 [3.1.0]: https://github.com/aurora-is-near/aurora-engine/compare/3.0.0...3.1.0 diff --git a/Cargo.lock b/Cargo.lock index f6f9389fd..eaaf3fa4f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -279,7 +279,7 @@ dependencies = [ [[package]] name = "aurora-engine" -version = "3.3.0" +version = "3.3.1" dependencies = [ "aurora-engine-hashchain", "aurora-engine-modexp", diff --git a/VERSION b/VERSION index 15a279981..bea438e9a 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -3.3.0 +3.3.1 diff --git a/engine-tests/src/tests/erc20.rs b/engine-tests/src/tests/erc20.rs index d93e371df..ecd1bfeed 100644 --- a/engine-tests/src/tests/erc20.rs +++ b/engine-tests/src/tests/erc20.rs @@ -3,15 +3,17 @@ use crate::prelude::{Address, U256}; use crate::utils::{ self, solidity::erc20::{self, ERC20Constructor, ERC20}, - Signer, + str_to_account_id, Signer, }; use aurora_engine::engine::EngineErrorKind; use aurora_engine::parameters::TransactionStatus; use aurora_engine_sdk as sdk; use aurora_engine_types::account_id::AccountId; +use aurora_engine_types::borsh::BorshSerialize; use aurora_engine_types::parameters::connector::{ Erc20Identifier, Erc20Metadata, SetErc20MetadataArgs, }; +use aurora_engine_types::parameters::engine::SetOwnerArgs; use bstr::ByteSlice; use libsecp256k1::SecretKey; use std::str::FromStr; @@ -297,6 +299,70 @@ fn test_erc20_get_and_set_metadata() { assert_eq!(metadata, new_metadata); } +#[test] +fn test_erc20_get_and_set_metadata_by_owner() { + let mut runner = utils::deploy_runner(); + let token_account_id = "token"; + let erc20_address = runner.deploy_erc20_token(token_account_id); + let caller = runner.aurora_account_id.clone(); + + // Change the owner of the aurora contract + let new_owner = "new_owner"; + let set_owner_args = SetOwnerArgs { + new_owner: str_to_account_id(new_owner), + }; + + let result = runner.call("set_owner", &caller, set_owner_args.try_to_vec().unwrap()); + assert!(result.is_ok()); + + let caller = new_owner; + + // Getting ERC-20 metadata by Address. + let result = runner.one_shot().call( + "get_erc20_metadata", + caller, + serde_json::to_vec::(&erc20_address.into()).unwrap(), + ); + + assert!(result.is_ok()); + + let metadata: Erc20Metadata = + serde_json::from_slice(&result.unwrap().return_data.as_value().unwrap()).unwrap(); + assert_eq!(metadata, Erc20Metadata::default()); + + let new_metadata = Erc20Metadata { + name: "USD Token".to_string(), + symbol: "USDT".to_string(), + decimals: 20, + }; + + let result = runner.call( + "set_erc20_metadata", + caller, + serde_json::to_vec(&SetErc20MetadataArgs { + erc20_identifier: erc20_address.into(), + metadata: new_metadata.clone(), + }) + .unwrap(), + ); + assert!(result.is_ok()); + + // Getting ERC-20 metadata by NEP-141 account id. + let result = runner.one_shot().call( + "get_erc20_metadata", + caller, + serde_json::to_vec::( + &AccountId::from_str(token_account_id).unwrap().into(), + ) + .unwrap(), + ); + assert!(result.is_ok()); + + let metadata: Erc20Metadata = + serde_json::from_slice(&result.unwrap().return_data.as_value().unwrap()).unwrap(); + assert_eq!(metadata, new_metadata); +} + fn get_address_erc20_balance( runner: &utils::AuroraRunner, signer: &Signer, diff --git a/engine-tests/src/tests/sanity.rs b/engine-tests/src/tests/sanity.rs index 241918b61..3dfa74211 100644 --- a/engine-tests/src/tests/sanity.rs +++ b/engine-tests/src/tests/sanity.rs @@ -434,8 +434,9 @@ fn test_solidity_pure_bench() { .unwrap(); assert!( - result.gas_used > 38_000_000, - "Over 38 million EVM gas is used" + result.gas_used > 37_000_000, + "Over 37 million EVM gas is used {}", + result.gas_used ); let near_gas = profile.all_gas(); assert!( diff --git a/engine/Cargo.toml b/engine/Cargo.toml index 342d67c8c..4e81fba75 100644 --- a/engine/Cargo.toml +++ b/engine/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "aurora-engine" -version = "3.3.0" +version = "3.3.1" authors.workspace = true edition.workspace = true homepage.workspace = true diff --git a/engine/src/contract_methods/connector/mod.rs b/engine/src/contract_methods/connector/mod.rs index 41d58dc70..893f27a63 100644 --- a/engine/src/contract_methods/connector/mod.rs +++ b/engine/src/contract_methods/connector/mod.rs @@ -381,7 +381,7 @@ pub fn set_erc20_metadata( let current_account_id = env.current_account_id(); let mut engine: Engine<_, E, AuroraModExp> = Engine::new_with_state( state, - predecessor_address(&env.predecessor_account_id()), + predecessor_address(¤t_account_id), current_account_id, io, env, diff --git a/engine/src/pausables.rs b/engine/src/pausables.rs index 4d3bc3b46..9b8e4b257 100644 --- a/engine/src/pausables.rs +++ b/engine/src/pausables.rs @@ -41,7 +41,7 @@ pub trait Authorizer { /// Can check if a subset of precompiles is currently paused or not. pub trait PausedPrecompilesChecker { - /// Checks if all of the `precompiles` are paused. + /// Checks if all the `precompiles` are paused. /// /// The `precompiles` mask can be a subset and every 1 bit is meant to be checked and every 0 bit is ignored. fn is_paused(&self, precompiles: PrecompileFlags) -> bool;