Skip to content

Commit

Permalink
Release 3.3.1 (#860)
Browse files Browse the repository at this point in the history
## 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]).
  • Loading branch information
aleksuss authored Oct 26, 2023
1 parent 1aad2a0 commit 9963486
Show file tree
Hide file tree
Showing 8 changed files with 86 additions and 9 deletions.
12 changes: 11 additions & 1 deletion CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3.3.0
3.3.1
68 changes: 67 additions & 1 deletion engine-tests/src/tests/erc20.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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::<Erc20Identifier>(&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::<Erc20Identifier>(
&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,
Expand Down
5 changes: 3 additions & 2 deletions engine-tests/src/tests/sanity.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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!(
Expand Down
2 changes: 1 addition & 1 deletion engine/Cargo.toml
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion engine/src/contract_methods/connector/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,7 @@ pub fn set_erc20_metadata<I: IO + Copy, E: Env, H: PromiseHandler>(
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(&current_account_id),
current_account_id,
io,
env,
Expand Down
2 changes: 1 addition & 1 deletion engine/src/pausables.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 9963486

Please sign in to comment.