Skip to content

Commit

Permalink
Dependency updates (#678)
Browse files Browse the repository at this point in the history
This PR just does some dependency updates and fixes from Solidity warnings that we started seeing since v0.8.

This is just some housekeeping in preparation for the v0.15.4 release.

### Test Plan

CI - no changes.
  • Loading branch information
nlordell authored Dec 1, 2021
1 parent 3a607c2 commit de30b0b
Show file tree
Hide file tree
Showing 16 changed files with 2,805 additions and 3,020 deletions.
1 change: 1 addition & 0 deletions ethcontract-mock/src/details/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -993,6 +993,7 @@ impl<P: Tokenize + Send + 'static, R: Tokenize + Send + 'static> ExpectationApi
}
}

#[allow(clippy::enum_variant_names)]
enum Predicate<P: Tokenize + Send + 'static> {
None,
Predicate(Box<dyn predicates::Predicate<P> + Send>),
Expand Down
3 changes: 0 additions & 3 deletions ethcontract/src/contract/event.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@ use web3::Transport;
#[derive(Debug)]
#[must_use = "event builders do nothing unless you stream them"]
pub struct EventBuilder<T: Transport, E: Tokenize> {
/// The underlying web3 instance.
web3: Web3<T>,
/// The event ABI data for encoding topic filters and decoding logs.
event: AbiEvent,
/// The web3 filter builder used for creating a log filter.
Expand All @@ -41,7 +39,6 @@ impl<T: Transport, E: Tokenize> EventBuilder<T, E> {
/// and address.
pub fn new(web3: Web3<T>, event: AbiEvent, address: Address) -> Self {
EventBuilder {
web3: web3.clone(),
event,
filter: LogFilterBuilder::new(web3).address(vec![address]),
topics: RawTopicFilter::default(),
Expand Down
1 change: 1 addition & 0 deletions examples/hardhat/contracts/DeployedContract.sol
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

/**
Expand Down
4 changes: 2 additions & 2 deletions examples/hardhat/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
},
"homepage": "https://github.com/gnosis/ethcontract-rs",
"devDependencies": {
"hardhat": "^2.6.6",
"hardhat-deploy": "^0.9.4"
"hardhat": "^2.7.0",
"hardhat-deploy": "^0.9.14"
}
}
1,076 changes: 561 additions & 515 deletions examples/hardhat/yarn.lock

Large diffs are not rendered by default.

53 changes: 27 additions & 26 deletions examples/truffle/contracts/AbiTypes.sol
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

/**
Expand All @@ -7,58 +8,58 @@ contract AbiTypes {
function getVoid() public pure {}

function getU8() public view returns (uint8) {
return uint8(this.getU256() & 0xff);
return uint8(getU256() & 0xff);
}
function getU16() public view returns (uint16) {
return uint16(this.getU256() & 0xffff);
return uint16(getU256() & 0xffff);
}
function getU32() public view returns (uint32) {
return uint32(this.getU256() & 0xffffffff);
return uint32(getU256() & 0xffffffff);
}
function getU64() public view returns (uint64) {
return uint64(this.getU256() & 0xffffffffffffffff);
return uint64(getU256() & 0xffffffffffffffff);
}
function getU128() public view returns (uint128) {
return uint128(this.getU256() & 0xffffffffffffffffffffffffffffffff);
return uint128(getU256() & 0xffffffffffffffffffffffffffffffff);
}
function getU256() public view returns (uint256) {
return uint256(blockhash(block.number - 1));
}

function getI8() public view returns (int8) {
return int8(this.getI256() & 0xff);
return int8(getI256() & 0xff);
}
function getI16() public view returns (int16) {
return int16(this.getI256() & 0xffff);
return int16(getI256() & 0xffff);
}
function getI32() public view returns (int32) {
return int32(this.getI256() & 0xffffffff);
return int32(getI256() & 0xffffffff);
}
function getI64() public view returns (int64) {
return int64(this.getI256() & 0xffffffffffffffff);
return int64(getI256() & 0xffffffffffffffff);
}
function getI128() public view returns (int128) {
return int128(this.getI256() & 0xffffffffffffffffffffffffffffffff);
return int128(getI256() & 0xffffffffffffffffffffffffffffffff);
}
function getI256() public view returns (int256) {
return int256(this.getU256());
return int256(getU256());
}

function getBool() public view returns (bool) {
return this.getU256() & 0x1 != 0;
return getU256() & 0x1 != 0;
}
function getBytes() public view returns (bytes memory) {
return abi.encodePacked(this.getU32());
return abi.encodePacked(getU32());
}
function getFixedBytes() public view returns (bytes6) {
return bytes6(uint48(this.getU64() & 0xffffffffffff));
return bytes6(uint48(getU64() & 0xffffffffffff));
}
function getAddress() public view returns (address) {
return address(uint160(this.getU256()));
return address(uint160(getU256()));
}
function getString() public view returns (string memory) {
bytes16 alphabet = "0123456789abcdef";
uint64 value = this.getU64();
uint64 value = getU64();
bytes memory buf = new bytes(16);
for (uint256 i = 16; i > 0; i--) {
buf[i-1] = alphabet[value & 0xf];
Expand All @@ -68,7 +69,7 @@ contract AbiTypes {
}

function getArray() public view returns (uint64[] memory) {
uint256 value = this.getU256();
uint256 value = getU256();
uint64[] memory buf = new uint64[](4);
for (uint256 i = 4; i > 0; i--) {
buf[i-1] = uint64(value & 0xffffffffffffffff);
Expand All @@ -77,7 +78,7 @@ contract AbiTypes {
return buf;
}
function getFixedArray() public view returns (int32[3] memory) {
uint256 value = this.getU256();
uint256 value = getU256();
int32[3] memory buf = [int32(0), int32(0), int32(0)];
for (uint256 i = 3; i > 0; i--) {
buf[i-1] = int32(uint32(value & 0xffffffff));
Expand Down Expand Up @@ -118,29 +119,29 @@ contract AbiTypes {
function abiv2Struct(S calldata s) public pure returns (S calldata) {
return s;
}
function abiv2ArrayOfStruct(S[] calldata s) public view returns (S[] calldata) {
function abiv2ArrayOfStruct(S[] calldata s) public pure returns (S[] calldata) {
return s;
}
function abiv2ArrayOfArrayOfStruct(S[][3] calldata s) public view returns (S[][3] calldata) {
function abiv2ArrayOfArrayOfStruct(S[][3] calldata s) public pure returns (S[][3] calldata) {
return s;
}

function roundtripBytes(bytes calldata a) public view returns (bytes calldata) {
function roundtripBytes(bytes calldata a) public pure returns (bytes calldata) {
return a;
}
function roundtripFixedBytes(bytes3 a) public view returns (bytes3) {
function roundtripFixedBytes(bytes3 a) public pure returns (bytes3) {
return a;
}
function roundtripU8Array(uint8[] calldata a) public view returns (uint8[] calldata) {
function roundtripU8Array(uint8[] calldata a) public pure returns (uint8[] calldata) {
return a;
}
function roundtripFixedU8Array(uint8[3] calldata a) public view returns (uint8[3] calldata) {
function roundtripFixedU8Array(uint8[3] calldata a) public pure returns (uint8[3] calldata) {
return a;
}
function multipleResults() public view returns (uint8, uint8, uint8) {
function multipleResults() public pure returns (uint8, uint8, uint8) {
return (1, 2, 3);
}
function multipleResultsStruct() public view returns (S memory, S memory) {
function multipleResultsStruct() public pure returns (S memory, S memory) {
return (S(0, 1), S(2, 3));
}
}
1 change: 1 addition & 0 deletions examples/truffle/contracts/DeployedContract.sol
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

/**
Expand Down
3 changes: 2 additions & 1 deletion examples/truffle/contracts/DocumentedContract.sol
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

/**
Expand All @@ -14,7 +15,7 @@ contract DocumentedContract {
/*
* @dev Creates a new owned instance of `DocumentedContract`.
*/
constructor(address owner_) public {
constructor(address owner_) {
owner = owner_;
}

Expand Down
3 changes: 2 additions & 1 deletion examples/truffle/contracts/LinkedContract.sol
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import "./SimpleLibrary.sol";
Expand All @@ -7,7 +8,7 @@ contract LinkedContract {

uint256 public value;

constructor(uint256 value_) public {
constructor(uint256 value_) {
value = value_;
}

Expand Down
3 changes: 2 additions & 1 deletion examples/truffle/contracts/Migrations.sol
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

contract Migrations {
address public owner;
uint public last_completed_migration;

constructor() public {
constructor() {
owner = msg.sender;
}

Expand Down
1 change: 1 addition & 0 deletions examples/truffle/contracts/OverloadedMethods.sol
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

/**
Expand Down
1 change: 1 addition & 0 deletions examples/truffle/contracts/Revert.sol
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

contract Revert {
Expand Down
3 changes: 2 additions & 1 deletion examples/truffle/contracts/RustCoin.sol
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import "@openzeppelin/contracts/token/ERC20/ERC20.sol";

contract RustCoin is ERC20 {
constructor() ERC20("Rust Coin", "RUST") public {
constructor() ERC20("Rust Coin", "RUST") {
_mint(msg.sender, 1337 * (10 ** uint256(decimals())));
}

Expand Down
1 change: 1 addition & 0 deletions examples/truffle/contracts/SimpleLibrary.sol
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

library SimpleLibrary {
Expand Down
10 changes: 5 additions & 5 deletions examples/truffle/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"private": "true",
"description": "Test contracts for ethcontract-rs runtime and proc macro.",
"scripts": {
"build": "truffle build && yarn run network:inject",
"build": "truffle compile && yarn run network:inject",
"deploy": "truffle migrate --network rinkeby && truffle verify --network rinkeby && yarn run network:extract",
"network:extract": "CONF_FILE=$(pwd)/.network-restore.conf.js node node_modules/@gnosis.pm/util-contracts/src/extract_network_info.js",
"network:inject": "CONF_FILE=$(pwd)/.network-restore.conf.js node node_modules/@gnosis.pm/util-contracts/src/inject_network_info.js",
Expand All @@ -23,9 +23,9 @@
"homepage": "https://github.com/gnosis/ethcontract-rs",
"devDependencies": {
"@gnosis.pm/util-contracts": "^3.0.1",
"@openzeppelin/contracts": "4.3.2",
"@truffle/hdwallet-provider": "^1.4.3",
"truffle": "^5.4.15",
"truffle-plugin-verify": "^0.5.15"
"@openzeppelin/contracts": "^4.4.0",
"@truffle/hdwallet-provider": "^1.5.1",
"truffle": "^5.4.22",
"truffle-plugin-verify": "^0.5.18"
}
}
Loading

0 comments on commit de30b0b

Please sign in to comment.