Skip to content

Commit

Permalink
Release 1.4.3. (aurora-is-near#172)
Browse files Browse the repository at this point in the history
* Fix scheduled nightly clippy. (aurora-is-near#160)
* Always compile tests with the `mainnet` feature. (aurora-is-near#162)
* Move eth-connector tests to under `src/tests`. (aurora-is-near#164)
* EIP-2718: Support typed transaction envelopes. (aurora-is-near#165)
* Remove deprecated EIP-712 prover implementation. (aurora-is-near#168)
* ERC-20: Allow admin to change token metadata. (aurora-is-near#171)

Co-authored-by: Evgeny Ukhanov <[email protected]>
Co-authored-by: Kirill <[email protected]>
Co-authored-by: Michael Birch <[email protected]>
  • Loading branch information
4 people authored Jul 8, 2021
1 parent 3787f01 commit d2f2e32
Show file tree
Hide file tree
Showing 26 changed files with 3,216 additions and 477 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/scheduled_lints.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,9 @@ jobs:
toolchain: nightly
override: true
components: clippy
- run: make etc/eth-contracts/res/EvmErc20.bin
- name: Run cargo clippy
uses: actions-rs/cargo@v1
with:
command: clippy
args: --no-default-features --features=contract -- -D warnings
args: --no-default-features --features=mainnet -- -D warnings
3 changes: 3 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [1.4.3] - 2021-07-08

## [1.4.2] - 2021-06-25

## [1.4.1] - 2021-06-23
Expand All @@ -19,6 +21,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [1.0.0] - 2021-05-12

[1.4.3]: https://github.com/aurora-is-near/aurora-engine/compare/1.4.2...1.4.3
[1.4.2]: https://github.com/aurora-is-near/aurora-engine/compare/1.4.1...1.4.2
[1.4.1]: https://github.com/aurora-is-near/aurora-engine/compare/1.4.0...1.4.1
[1.4.0]: https://github.com/aurora-is-near/aurora-engine/compare/1.3.0...1.4.0
Expand Down
7 changes: 5 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ target/wasm32-unknown-unknown/debug/aurora_engine.wasm: Cargo.toml Cargo.lock $(
$(CARGO) build --target wasm32-unknown-unknown --no-default-features --features=$(FEATURES) -Z avoid-dev-deps

test-build: etc/eth-contracts/artifacts/contracts/test/StateTest.sol/StateTest.json etc/eth-contracts/res/EvmErc20.bin
RUSTFLAGS='-C link-arg=-s' $(CARGO) build --target wasm32-unknown-unknown --release --no-default-features --features=contract,integration-test,meta-call -Z avoid-dev-deps
RUSTFLAGS='-C link-arg=-s' $(CARGO) build --target wasm32-unknown-unknown --release --no-default-features --features=mainnet,integration-test,meta-call -Z avoid-dev-deps
ln -sf target/wasm32-unknown-unknown/release/aurora_engine.wasm release.wasm
ls -l target/wasm32-unknown-unknown/release/aurora_engine.wasm

Expand All @@ -50,7 +50,7 @@ test-build: etc/eth-contracts/artifacts/contracts/test/StateTest.sol/StateTest.j
deploy: release.wasm
$(NEAR) deploy --account-id=$(or $(NEAR_EVM_ACCOUNT),aurora.test.near) --wasm-file=$<

check: test check-format check-clippy
check: test test-sol check-format check-clippy

check-format:
$(CARGO) fmt -- --check
Expand All @@ -62,6 +62,9 @@ check-clippy:
test: test-build
$(CARGO) test --features meta-call

test-sol:
cd etc/eth-contracts && yarn && yarn test

format:
$(CARGO) fmt

Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.4.2
1.4.3
25 changes: 23 additions & 2 deletions etc/eth-contracts/contracts/EvmErc20.sol
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,37 @@ import "./IExit.sol";
* `ERC20` functions.
*/
contract EvmErc20 is ERC20, AdminControlled, IExit {
string private _name;
string private _symbol;
uint8 private _decimals;

constructor (string memory name, string memory symbol, uint8 decimal, address admin) ERC20(name, symbol) AdminControlled(admin, 0) {
_decimals = decimal;
constructor (string memory metadata_name, string memory metadata_symbol, uint8 metadata_decimals, address admin)
ERC20(metadata_name, metadata_symbol)
AdminControlled(admin, 0)
{
_name = metadata_name;
_symbol = metadata_symbol;
_decimals = metadata_decimals;
}

function name() public view override returns (string memory) {
return _name;
}

function symbol() public view override returns (string memory) {
return _symbol;
}

function decimals() public view override returns (uint8) {
return _decimals;
}

function setMetadata(string memory metadata_name, string memory metadata_symbol, uint8 metadata_decimals) external onlyAdmin {
_name = metadata_name;
_symbol = metadata_symbol;
_decimals = metadata_decimals;
}

function mint(address account, uint256 amount) public onlyAdmin {
_mint(account, amount);
}
Expand Down
2 changes: 1 addition & 1 deletion etc/eth-contracts/hardhat.config.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
require('@nomiclabs/hardhat-ethers');
require('@nomiclabs/hardhat-waffle');
require('solidity-coverage');

/**
Expand Down
4 changes: 3 additions & 1 deletion etc/eth-contracts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
},
"devDependencies": {
"@nomiclabs/hardhat-ethers": "^2.0.1",
"@nomiclabs/hardhat-waffle": "^2.0.1",
"chai": "^4.3.3",
"eslint": "^6.3.0",
"eslint-config-standard": "^14.1.0",
Expand All @@ -15,6 +16,7 @@
"eslint-plugin-promise": "^4.0.1",
"eslint-plugin-standard": "^4.0.0",
"eth-gas-reporter": "^0.2.11",
"ethereum-waffle": "^3.4.0",
"ethers": "^5.0.31",
"hardhat": "^2.1.1",
"rainbow-bridge-lib": "^2.0.0",
Expand All @@ -25,7 +27,7 @@
"scripts": {
"compile": "hardhat compile",
"build": "yarn compile && node main.js ./artifacts/contracts/EvmErc20.sol/EvmErc20.json",
"test": "hardhat test",
"test": "yarn hardhat test",
"coverage": "hardhat coverage",
"lint:js": "eslint .",
"lint:js:fix": "eslint . --fix",
Expand Down
95 changes: 95 additions & 0 deletions etc/eth-contracts/test/EvmErc20.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
const { ethers } = require('hardhat');
const { expect } = require('chai');

describe('EthCustodian contract', () => {
let user1;
let deployerAccount;
let adminAccount;

let evmErc20Factory;
let evmErc20Contract;

const metadataName = 'EMPTY_TOKEN';
const metadataSymbol = 'EMPTY_SYMBOL';
const metadataDecimals = 0;

beforeEach(async () => {
[deployerAccount, user1] = await ethers.getSigners();

// Make the deployer admin
adminAccount = deployerAccount;

evmErc20Factory = await ethers.getContractFactory('EvmErc20');
evmErc20Contract = await evmErc20Factory
.connect(adminAccount)
.deploy(
metadataName,
metadataSymbol,
metadataDecimals,
adminAccount.address,
);
});

describe('AdminControlled', () => {
it('Only admin is allowed to update the metadata', async () => {
const newMetadataName = 'NEW_CUSTOM_TOKEN';
const newMetadataSymbol = 'NEW_CSTM';
const newMetadataDecimals = 18;

await expect(
evmErc20Contract
.connect(user1)
.setMetadata(
newMetadataName,
newMetadataSymbol,
newMetadataDecimals,
),
)
.to
.be
.reverted;

expect(await evmErc20Contract.name()).to.equal(metadataName);
expect(await evmErc20Contract.symbol()).to.equal(metadataSymbol);
expect(await evmErc20Contract.decimals()).to.equal(metadataDecimals);

await evmErc20Contract
.connect(adminAccount)
.setMetadata(
newMetadataName,
newMetadataSymbol,
newMetadataDecimals,
);

expect(await evmErc20Contract.name()).to.equal(newMetadataName);
expect(await evmErc20Contract.symbol()).to.equal(newMetadataSymbol);
expect(await evmErc20Contract.decimals()).to.equal(newMetadataDecimals);
});
});

describe('Metadata', () => {
it('Should match the deployed metadata', async () => {
expect(await evmErc20Contract.name()).to.equal(metadataName);
expect(await evmErc20Contract.symbol()).to.equal(metadataSymbol);
expect(await evmErc20Contract.decimals()).to.equal(metadataDecimals);
});

it('Should update the metadata', async () => {
const newMetadataName = 'NEW_CUSTOM_TOKEN';
const newMetadataSymbol = 'NEW_CSTM';
const newMetadataDecimals = 18;

await evmErc20Contract
.connect(adminAccount)
.setMetadata(
newMetadataName,
newMetadataSymbol,
newMetadataDecimals,
);

expect(await evmErc20Contract.name()).to.equal(newMetadataName);
expect(await evmErc20Contract.symbol()).to.equal(newMetadataSymbol);
expect(await evmErc20Contract.decimals()).to.equal(newMetadataDecimals);
});
});
});
Loading

0 comments on commit d2f2e32

Please sign in to comment.