Skip to content

Commit 9963486

Browse files
authored
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]).
1 parent 1aad2a0 commit 9963486

8 files changed

Lines changed: 86 additions & 9 deletions

File tree

CHANGES.md

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,15 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## [Unreleased]
99

10+
## [3.3.1] 2023-10-26
11+
12+
### Fixes
13+
14+
- The smart contract owner whose account id is not the same as the contract account id can set ERC-20 metadata
15+
by [@aleksuss] ([#858]).
16+
17+
[#858]: https://github.com/aurora-is-near/aurora-engine/pull/858
18+
1019
## [3.3.0] 2023-10-23
1120

1221
### Changes
@@ -538,7 +547,8 @@ struct SubmitResult {
538547

539548
## [1.0.0] - 2021-05-12
540549

541-
[Unreleased]: https://github.com/aurora-is-near/aurora-engine/compare/3.3.0...develop
550+
[Unreleased]: https://github.com/aurora-is-near/aurora-engine/compare/3.3.1...develop
551+
[3.3.1]: https://github.com/aurora-is-near/aurora-engine/compare/3.3.0...3.3.1
542552
[3.3.0]: https://github.com/aurora-is-near/aurora-engine/compare/3.2.0...3.3.0
543553
[3.2.0]: https://github.com/aurora-is-near/aurora-engine/compare/3.1.0...3.2.0
544554
[3.1.0]: https://github.com/aurora-is-near/aurora-engine/compare/3.0.0...3.1.0

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
3.3.0
1+
3.3.1

engine-tests/src/tests/erc20.rs

Lines changed: 67 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,17 @@ use crate::prelude::{Address, U256};
33
use crate::utils::{
44
self,
55
solidity::erc20::{self, ERC20Constructor, ERC20},
6-
Signer,
6+
str_to_account_id, Signer,
77
};
88
use aurora_engine::engine::EngineErrorKind;
99
use aurora_engine::parameters::TransactionStatus;
1010
use aurora_engine_sdk as sdk;
1111
use aurora_engine_types::account_id::AccountId;
12+
use aurora_engine_types::borsh::BorshSerialize;
1213
use aurora_engine_types::parameters::connector::{
1314
Erc20Identifier, Erc20Metadata, SetErc20MetadataArgs,
1415
};
16+
use aurora_engine_types::parameters::engine::SetOwnerArgs;
1517
use bstr::ByteSlice;
1618
use libsecp256k1::SecretKey;
1719
use std::str::FromStr;
@@ -297,6 +299,70 @@ fn test_erc20_get_and_set_metadata() {
297299
assert_eq!(metadata, new_metadata);
298300
}
299301

302+
#[test]
303+
fn test_erc20_get_and_set_metadata_by_owner() {
304+
let mut runner = utils::deploy_runner();
305+
let token_account_id = "token";
306+
let erc20_address = runner.deploy_erc20_token(token_account_id);
307+
let caller = runner.aurora_account_id.clone();
308+
309+
// Change the owner of the aurora contract
310+
let new_owner = "new_owner";
311+
let set_owner_args = SetOwnerArgs {
312+
new_owner: str_to_account_id(new_owner),
313+
};
314+
315+
let result = runner.call("set_owner", &caller, set_owner_args.try_to_vec().unwrap());
316+
assert!(result.is_ok());
317+
318+
let caller = new_owner;
319+
320+
// Getting ERC-20 metadata by Address.
321+
let result = runner.one_shot().call(
322+
"get_erc20_metadata",
323+
caller,
324+
serde_json::to_vec::<Erc20Identifier>(&erc20_address.into()).unwrap(),
325+
);
326+
327+
assert!(result.is_ok());
328+
329+
let metadata: Erc20Metadata =
330+
serde_json::from_slice(&result.unwrap().return_data.as_value().unwrap()).unwrap();
331+
assert_eq!(metadata, Erc20Metadata::default());
332+
333+
let new_metadata = Erc20Metadata {
334+
name: "USD Token".to_string(),
335+
symbol: "USDT".to_string(),
336+
decimals: 20,
337+
};
338+
339+
let result = runner.call(
340+
"set_erc20_metadata",
341+
caller,
342+
serde_json::to_vec(&SetErc20MetadataArgs {
343+
erc20_identifier: erc20_address.into(),
344+
metadata: new_metadata.clone(),
345+
})
346+
.unwrap(),
347+
);
348+
assert!(result.is_ok());
349+
350+
// Getting ERC-20 metadata by NEP-141 account id.
351+
let result = runner.one_shot().call(
352+
"get_erc20_metadata",
353+
caller,
354+
serde_json::to_vec::<Erc20Identifier>(
355+
&AccountId::from_str(token_account_id).unwrap().into(),
356+
)
357+
.unwrap(),
358+
);
359+
assert!(result.is_ok());
360+
361+
let metadata: Erc20Metadata =
362+
serde_json::from_slice(&result.unwrap().return_data.as_value().unwrap()).unwrap();
363+
assert_eq!(metadata, new_metadata);
364+
}
365+
300366
fn get_address_erc20_balance(
301367
runner: &utils::AuroraRunner,
302368
signer: &Signer,

engine-tests/src/tests/sanity.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -434,8 +434,9 @@ fn test_solidity_pure_bench() {
434434
.unwrap();
435435

436436
assert!(
437-
result.gas_used > 38_000_000,
438-
"Over 38 million EVM gas is used"
437+
result.gas_used > 37_000_000,
438+
"Over 37 million EVM gas is used {}",
439+
result.gas_used
439440
);
440441
let near_gas = profile.all_gas();
441442
assert!(

engine/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "aurora-engine"
3-
version = "3.3.0"
3+
version = "3.3.1"
44
authors.workspace = true
55
edition.workspace = true
66
homepage.workspace = true

engine/src/contract_methods/connector/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -381,7 +381,7 @@ pub fn set_erc20_metadata<I: IO + Copy, E: Env, H: PromiseHandler>(
381381
let current_account_id = env.current_account_id();
382382
let mut engine: Engine<_, E, AuroraModExp> = Engine::new_with_state(
383383
state,
384-
predecessor_address(&env.predecessor_account_id()),
384+
predecessor_address(&current_account_id),
385385
current_account_id,
386386
io,
387387
env,

engine/src/pausables.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ pub trait Authorizer {
4141

4242
/// Can check if a subset of precompiles is currently paused or not.
4343
pub trait PausedPrecompilesChecker {
44-
/// Checks if all of the `precompiles` are paused.
44+
/// Checks if all the `precompiles` are paused.
4545
///
4646
/// The `precompiles` mask can be a subset and every 1 bit is meant to be checked and every 0 bit is ignored.
4747
fn is_paused(&self, precompiles: PrecompileFlags) -> bool;

0 commit comments

Comments
 (0)