diff --git a/.gitignore b/.gitignore index 14fa77d..7dc5c9b 100644 --- a/.gitignore +++ b/.gitignore @@ -12,8 +12,6 @@ libtool ltmain.sh m4 missing -node_modules -package-lock.json py-compile stamp-h1 test-driver diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..cada53b --- /dev/null +++ b/.gitmodules @@ -0,0 +1,15 @@ +[submodule "eth/solidity/lib/polygon-contract"] + path = eth/solidity/lib/polygon-contract + url = https://github.com/xaya/polygon-contract +[submodule "eth/solidity/lib/openzeppelin-contracts"] + path = eth/solidity/lib/openzeppelin-contracts + url = https://github.com/OpenZeppelin/openzeppelin-contracts +[submodule "eth/solidity/lib/base64"] + path = eth/solidity/lib/base64 + url = https://github.com/Brechtpd/base64 +[submodule "eth/solidity/lib/wchi"] + path = eth/solidity/lib/wchi + url = https://github.com/xaya/wchi +[submodule "eth/solidity/lib/forge-std"] + path = eth/solidity/lib/forge-std + url = https://github.com/foundry-rs/forge-std diff --git a/Makefile.am b/Makefile.am index 088a7b2..d3accf3 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1,5 +1,3 @@ ACLOCAL_AMFLAGS = ${ACLOCAL_FLAGS} -Im4 SUBDIRS = src xayax xayacore eth - -EXTRA_DIST = node_modules diff --git a/docker/Dockerfile b/docker/Dockerfile index 112a798..dae9190 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -5,25 +5,32 @@ # libxayagame directly, it depends on libxayautil and many of the same base # packages like SQLite or libjson-rpc-cpp, so that reusing them for the # build from the existing package makes sense. -FROM xaya/libxayagame AS build -RUN apk add --no-cache \ +# +# It seems very hard to get the pre-built foundry binaries to run on Alpine, +# so we base the image on Ubuntu instead. +FROM xaya/libxayagame:ubuntu AS build +RUN apt update && apt -y install \ autoconf \ autoconf-archive \ automake \ - boost-dev \ - build-base \ - ca-certificates \ + libboost-all-dev \ + build-essential \ cmake \ + curl \ git \ - gflags-dev \ + libgflags-dev \ libtool \ - mariadb-dev \ - npm \ - pkgconfig \ - py3-pip \ + libmariadb-dev \ + pkg-config \ + python3-pip \ python3-dev -RUN pip3 install --break-system-packages web3 -RUN npm install -g truffle +RUN pip3 install web3 + +# Install Foundry. It seems pretty hard to get "foundryup" to run inside +# Docker, so we just download and manually install a specific release. +ARG FOUNDRY_RELEASE="nightly-adb6abae69c7a0d766db123f66686cc890c22dd0" +WORKDIR /usr/local/bin +RUN curl -L "https://github.com/foundry-rs/foundry/releases/download/${FOUNDRY_RELEASE}/foundry_nightly_linux_amd64.tar.gz" | tar zxv # Build and install libunivalue. ARG UNIVALUE_VERSION="v1.0.5" @@ -51,8 +58,6 @@ RUN ./autogen.sh && ./configure && make && make install-strip WORKDIR /usr/src/xayax COPY . . RUN make distclean || true -RUN npm install -RUN ln -s ../../node_modules eth/solidity/node_modules RUN ./autogen.sh && ./configure # Build the solidity contracts first, so that they are already # available for the python script that generates contract-constants.cpp. @@ -70,7 +75,7 @@ RUN for b in /usr/local/bin/xayax-*; \ COPY docker/entrypoint.sh bin/ # Construct the final image. -FROM alpine +FROM ubuntu:22.04 COPY --from=build /jail /usr/local/ COPY --from=build /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ LABEL description="Xaya X connector binaries" diff --git a/docker/entrypoint.sh b/docker/entrypoint.sh index 21a2502..8b91572 100755 --- a/docker/entrypoint.sh +++ b/docker/entrypoint.sh @@ -1,4 +1,4 @@ -#!/bin/sh -e +#!/bin/bash -e # If no HOST is explicitly set, try to detect it automatically. if [[ -z $HOST ]] diff --git a/eth/ethchain.cpp b/eth/ethchain.cpp index a874514..96bb420 100644 --- a/eth/ethchain.cpp +++ b/eth/ethchain.cpp @@ -80,6 +80,10 @@ const std::map CHAIN_IDS = {137, "polygon"}, {80'001, "mumbai"}, {1'337, "ganache"}, + /* This is anvil from Foundry, but in essence does the same as ganache + (i.e. local regtest-like testing on EVM chains). Which it is does not + matter from the game's point of view. */ + {31'337, "ganache"}, }; /** diff --git a/eth/gen-contract-constants.py b/eth/gen-contract-constants.py index 0fd3f2d..4296aad 100755 --- a/eth/gen-contract-constants.py +++ b/eth/gen-contract-constants.py @@ -46,10 +46,15 @@ def genSignature (abi, typ, name): i["type"] for i in inp ]) + ")" +def contractPath (nm): + """ + Returns the path of the contract build artefact. + """ + + return os.path.join ("solidity", "out", f"{nm}.sol", f"{nm}.json") + # Load the XayaAccounts ABI to generate signature hashes. -with open (os.path.join ("solidity", "node_modules", "@xaya", - "eth-account-registry", "build", "contracts", - "XayaAccounts.json")) as f: +with open (contractPath ("XayaAccounts"), "rt") as f: accAbi = json.load (f)["abi"] sgn = genSignature (accAbi, "event", "Move") print ("const std::string MOVE_EVENT = \"" @@ -63,17 +68,15 @@ def outputFcnSelector (abi, name, var): + hexWithPrefix (Web3.keccak (sgn.encode ("ascii"))[:4]) + "\";") outputFcnSelector (accAbi, "wchiToken", "ACCOUNT_WCHI_FCN") -with open (os.path.join ("solidity", "build", "contracts", - "CallForwarder.json")) as f: +with open (contractPath ("CallForwarder"), "rt") as f: abi = json.load (f)["abi"] outputFcnSelector (abi, "execute", "FORWARDER_EXECUTE_FCN") # Store the deploying bytecode for our overlay contracts. def outputContract (name, var): - with open (os.path.join ("solidity", "build", "contracts", - f"{name}.json")) as f: + with open (contractPath (name), "rt") as f: data = json.load (f) - print (f"const std::string {var} = \"{data['bytecode']}\";") + print (f"const std::string {var} = \"{data['bytecode']['object']}\";") outputContract ("CallForwarder", "CALL_FORWARDER_CODE") outputContract ("TrackingAccounts", "TRACKING_ACCOUNTS_CODE") diff --git a/eth/pending.cpp b/eth/pending.cpp index 302a8ab..0ee03ff 100644 --- a/eth/pending.cpp +++ b/eth/pending.cpp @@ -128,6 +128,7 @@ PendingDataExtractor::GetMoves (EthRpcClient& rpc, possible, while returning any move events generated. */ Json::Value tx(Json::objectValue); tx["to"] = from.GetChecksummed (); + tx["from"] = from.GetChecksummed (); tx["value"] = data["value"]; tx["data"] = AbiEncoder::ConcatHex (FORWARDER_EXECUTE_FCN, execArgs.Finalise ()); diff --git a/eth/solidity/.gitignore b/eth/solidity/.gitignore index 378eac2..1e4ded7 100644 --- a/eth/solidity/.gitignore +++ b/eth/solidity/.gitignore @@ -1 +1,2 @@ -build +cache +out diff --git a/eth/solidity/Makefile.am b/eth/solidity/Makefile.am index d7df03c..3e5fa70 100644 --- a/eth/solidity/Makefile.am +++ b/eth/solidity/Makefile.am @@ -1,8 +1,8 @@ all-local: - truffle compile + forge build check-local: - truffle test + forge test clean-local: - rm -rf build + rm -rf cache out diff --git a/eth/solidity/foundry.toml b/eth/solidity/foundry.toml new file mode 100644 index 0000000..955e1c7 --- /dev/null +++ b/eth/solidity/foundry.toml @@ -0,0 +1,6 @@ +[profile.default] +src = "src" +out = "out" +libs = ["lib"] +optimizer = true +optimizer_runs = 1_000 diff --git a/eth/solidity/lib/base64 b/eth/solidity/lib/base64 new file mode 160000 index 0000000..dcbf852 --- /dev/null +++ b/eth/solidity/lib/base64 @@ -0,0 +1 @@ +Subproject commit dcbf852ba545b3d15de0ac0ef88dce934c090c8e diff --git a/eth/solidity/lib/forge-std b/eth/solidity/lib/forge-std new file mode 160000 index 0000000..1de6eec --- /dev/null +++ b/eth/solidity/lib/forge-std @@ -0,0 +1 @@ +Subproject commit 1de6eecf821de7fe2c908cc48d3ab3dced20717f diff --git a/eth/solidity/lib/openzeppelin-contracts b/eth/solidity/lib/openzeppelin-contracts new file mode 160000 index 0000000..dc44c9f --- /dev/null +++ b/eth/solidity/lib/openzeppelin-contracts @@ -0,0 +1 @@ +Subproject commit dc44c9f1a4c3b10af99492eed84f83ed244203f6 diff --git a/eth/solidity/lib/polygon-contract b/eth/solidity/lib/polygon-contract new file mode 160000 index 0000000..ddca994 --- /dev/null +++ b/eth/solidity/lib/polygon-contract @@ -0,0 +1 @@ +Subproject commit ddca9946f7ee85fc36c4632d2c028854384b8b70 diff --git a/eth/solidity/lib/wchi b/eth/solidity/lib/wchi new file mode 160000 index 0000000..a68ca6a --- /dev/null +++ b/eth/solidity/lib/wchi @@ -0,0 +1 @@ +Subproject commit a68ca6a5ad4e308ee9da1f24ec7c2feeb676070d diff --git a/eth/solidity/node_modules b/eth/solidity/node_modules deleted file mode 120000 index da10d6d..0000000 --- a/eth/solidity/node_modules +++ /dev/null @@ -1 +0,0 @@ -../../node_modules/ \ No newline at end of file diff --git a/eth/solidity/remappings.txt b/eth/solidity/remappings.txt new file mode 100644 index 0000000..5ddccdb --- /dev/null +++ b/eth/solidity/remappings.txt @@ -0,0 +1,4 @@ +base64-sol/=lib/base64/ +@openzeppelin/contracts/=lib/openzeppelin-contracts/contracts/ +@xaya/eth-account-registry/contracts/=lib/polygon-contract/contracts/ +@xaya/wchi/contracts/=lib/wchi/contracts/ diff --git a/eth/solidity/src/BuildWCHI.sol b/eth/solidity/src/BuildWCHI.sol new file mode 100644 index 0000000..063bb6c --- /dev/null +++ b/eth/solidity/src/BuildWCHI.sol @@ -0,0 +1,9 @@ +// SPDX-License-Identifier: MIT +// Copyright (C) 2024 The Xaya developers + +pragma solidity ^0.7.6; + +/* This file is here just to force Forge to build the WCHI contract, + which is used for the Python testing package. */ + +import "@xaya/wchi/contracts/WCHI.sol"; diff --git a/eth/solidity/src/BuildXayaPolicy.sol b/eth/solidity/src/BuildXayaPolicy.sol new file mode 100644 index 0000000..bc20c81 --- /dev/null +++ b/eth/solidity/src/BuildXayaPolicy.sol @@ -0,0 +1,11 @@ +// SPDX-License-Identifier: MIT +// Copyright (C) 2024 The Xaya developers + +pragma solidity ^0.8.4; + +/* This file is here just to force Forge to build the XayaPolicy and NftMetadata + contracts, too, whose build artefacts we need for the Python testing + package. */ + +import "@xaya/eth-account-registry/contracts/NftMetadata.sol"; +import "@xaya/eth-account-registry/contracts/XayaPolicy.sol"; diff --git a/eth/solidity/contracts/CallForwarder.sol b/eth/solidity/src/CallForwarder.sol similarity index 100% rename from eth/solidity/contracts/CallForwarder.sol rename to eth/solidity/src/CallForwarder.sol diff --git a/eth/solidity/contracts/TrackingAccounts.sol b/eth/solidity/src/TrackingAccounts.sol similarity index 100% rename from eth/solidity/contracts/TrackingAccounts.sol rename to eth/solidity/src/TrackingAccounts.sol diff --git a/eth/solidity/test/MoveTracking.t.sol b/eth/solidity/test/MoveTracking.t.sol new file mode 100644 index 0000000..fec2938 --- /dev/null +++ b/eth/solidity/test/MoveTracking.t.sol @@ -0,0 +1,140 @@ +// SPDX-License-Identifier: MIT +// Copyright (C) 2021-2024 The Xaya developers + +pragma solidity ^0.8.4; + +import "./MultiMover.sol"; +import "./TestToken.sol"; +import "../src/CallForwarder.sol"; +import "../src/TrackingAccounts.sol"; + +import "@xaya/eth-account-registry/contracts/TestPolicy.sol"; + +import "@openzeppelin/contracts/token/ERC20/IERC20.sol"; + +import { Test } from "forge-std/Test.sol"; + +/** + * @dev Unit tests for call forwarding and tracking moves with the + * instrumentation contracts. + */ +contract MoveTrackingTest is Test +{ + + address public constant operator = address (1); + + IERC20 public wchi; + + TrackingAccounts public xa; + CallForwarder public fwd; + MultiMover public mover; + + function setUp () public + { + wchi = new TestToken (operator, 78e6 * 1e8); + IXayaPolicy policy = new TestPolicy (); + + vm.startPrank (operator); + xa = new TrackingAccounts (wchi); + xa.schedulePolicyChange (policy); + vm.warp (xa.policyTimelock () + 1); + xa.enactPolicyChange (); + vm.stopPrank (); + + fwd = new CallForwarder (xa); + mover = new MultiMover (xa); + + /* The TestPolicy imposes a WCHI fee for moves, so we need to make sure that + the fwd contract has WCHI and the necessary approvals. */ + vm.startPrank (operator); + wchi.transfer (address (fwd), 1e8); + wchi.transfer (address (mover), 1e8); + vm.startPrank (address (fwd)); + wchi.approve (address (xa), type (uint256).max); + wchi.approve (address (mover), type (uint256).max); + xa.setApprovalForAll (address (mover), true); + vm.stopPrank (); + + /* The test name is owned by the fwd contract, and can thus be moved + by a forwarded call. */ + vm.prank (address (fwd)); + xa.register ("p", "test"); + } + + function test_trackDirectMoves () public + { + TrackingAccounts.MoveData[] memory res = fwd.execute (address (xa), + abi.encodeWithSelector (TrackingAccounts.move.selector, + "p", "test", "x", type (uint256).max, 0, address (0))); + assertEq (res.length, 1); + assertEq (res[0].ns, "p"); + assertEq (res[0].name, "test"); + assertEq (res[0].move, "x"); + assertEq (res[0].nonce, 0); + assertEq (res[0].mover, address (fwd)); + assertEq (res[0].amount, 0); + assertEq (res[0].receiver, address (0)); + + res = fwd.execute (address (xa), + abi.encodeWithSelector (TrackingAccounts.move.selector, + "p", "test", "y", type (uint256).max, 0, address (0))); + assertEq (res.length, 1); + assertEq (res[0].move, "y"); + assertEq (res[0].nonce, 1); + } + + function test_revertingMove () public + { + vm.expectRevert (); + fwd.execute (address (xa), + abi.encodeWithSelector (TrackingAccounts.move.selector, + "p", "test", "", type (uint256).max, 0, address (0))); + } + + function test_moveWithChiPayment () public + { + address to = address (2); + TrackingAccounts.MoveData[] memory res = fwd.execute (address (xa), + abi.encodeWithSelector (TrackingAccounts.move.selector, + "p", "test", "x", type (uint256).max, 42, to)); + assertEq (res.length, 1); + assertEq (res[0].amount, 42); + assertEq (res[0].receiver, to); + assertEq (wchi.balanceOf (to), 42); + } + + function test_multipleMoves () public + { + string[] memory ns = new string[] (1); + ns[0] = "p"; + string[] memory name = new string[] (1); + name[0] = "test"; + string[] memory values = new string[] (2); + values[0] = "x"; + values[1] = "y"; + + TrackingAccounts.MoveData[] memory res = fwd.execute (address (mover), + abi.encodeWithSelector (MultiMover.send.selector, ns, name, values)); + assertEq (res.length, 2); + assertEq (res[0].move, "x"); + assertEq (res[0].nonce, 0); + assertEq (res[1].move, "y"); + assertEq (res[1].nonce, 1); + } + + function test_ethPayment () public + { + bytes memory inner = abi.encodeWithSelector (MultiMover.requireEth.selector, + "p", "test", "x"); + (bool sent, bytes memory data) = address (fwd).call {value: 20} ( + abi.encodeWithSelector (CallForwarder.execute.selector, + address (mover), inner)); + assertTrue (sent); + + TrackingAccounts.MoveData[] memory res + = abi.decode (data, (TrackingAccounts.MoveData[])); + assertEq (res.length, 1); + assertEq (res[0].move, "x"); + } + +} diff --git a/eth/solidity/contracts/MultiMover.sol b/eth/solidity/test/MultiMover.sol similarity index 100% rename from eth/solidity/contracts/MultiMover.sol rename to eth/solidity/test/MultiMover.sol diff --git a/eth/solidity/test/TestToken.sol b/eth/solidity/test/TestToken.sol new file mode 100644 index 0000000..45d79eb --- /dev/null +++ b/eth/solidity/test/TestToken.sol @@ -0,0 +1,21 @@ +// SPDX-License-Identifier: MIT +// Copyright (C) 2024 The Xaya developers + +pragma solidity ^0.8.4; + +import "@openzeppelin/contracts/token/ERC20/ERC20.sol"; + +/** + * @dev Simple test token (representing WCHI) that just mints all the + * supply to a given address. + */ +contract TestToken is ERC20 +{ + + constructor (address holder, uint supply) + ERC20 ("Wrapped CHI", "WCHI") + { + _mint (holder, supply); + } + +} diff --git a/eth/solidity/test/movetracking.js b/eth/solidity/test/movetracking.js deleted file mode 100644 index 2f8a84a..0000000 --- a/eth/solidity/test/movetracking.js +++ /dev/null @@ -1,166 +0,0 @@ -// SPDX-License-Identifier: MIT -// Copyright (C) 2021-2022 Autonomous Worlds Ltd - -const truffleAssert = require ("truffle-assertions"); -const truffleContract = require ("@truffle/contract"); -const { time } = require ("@openzeppelin/test-helpers"); - -/* We want to use chai-subset for checking the MoveData structs easily, - but due to an open issue with Truffle we can only apply the plugin - if we use our own Chai (for these assertions at least): - - https://github.com/trufflesuite/truffle/issues/2090 -*/ -const chai = require ("chai"); -const chaiSubset = require ("chai-subset"); -chai.use (chaiSubset); - -const loadXayaContract = (pkg, name) => { - const path = "@xaya/" + pkg + "/build/contracts/" + name + ".json"; - const data = require (path); - const res = truffleContract (data); - res.setProvider (web3.currentProvider); - return res; -}; - -const WCHI = loadXayaContract ("wchi", "WCHI"); -const TestPolicy = loadXayaContract ("eth-account-registry", "TestPolicy"); - -const TrackingAccounts = artifacts.require ("TrackingAccounts"); -const CallForwarder = artifacts.require ("CallForwarder"); -const MultiMover = artifacts.require ("MultiMover"); - -const zeroAddr = "0x0000000000000000000000000000000000000000"; -const maxUint256 = "115792089237316195423570985008687907853269984665640564039457584007913129639935"; -const bnMaxUint256 = web3.utils.toBN (maxUint256); -const noNonce = bnMaxUint256; - -/*** ************************************************************************ */ - -contract ("CallForwarder", accounts => { - const operator = accounts[0]; - const op = {"from": operator}; - - let wchi, policy; - before (async () => { - wchi = await WCHI.new (op); - policy = await TestPolicy.new (op); - }); - - let xa, fwd, mover; - beforeEach (async () => { - xa = await TrackingAccounts.new (wchi.address, op); - await wchi.approve (xa.address, bnMaxUint256, op); - - await xa.schedulePolicyChange (policy.address, op); - time.increase ((await xa.policyTimelock ()) + 1); - await xa.enactPolicyChange (op); - - fwd = await CallForwarder.new (xa.address, op); - mover = await MultiMover.new (xa.address, op); - - /* The test name is owned by the fwd contract, and can thus be moved - by a forwarded call. */ - await xa.register ("p", "test", op); - const token = await xa.tokenIdForName ("p", "test"); - await xa.transferFrom (operator, fwd.address, token, op); - - /* The TestPolicy imposes a WCHI fee for moves, so we need to make sure - that the fwd contract has WCHI and the necessary approvals. */ - await wchi.transfer (fwd.address, 100, op); - await wchi.transfer (mover.address, 100, op); - const execFwd = (to, call) => { - const data = call.encodeABI (); - return fwd.execute (to, data, op); - }; - await execFwd (wchi.address, - wchi.contract.methods.approve (xa.address, 100)); - await execFwd (wchi.address, - wchi.contract.methods.approve (mover.address, 100)); - await execFwd (xa.address, - xa.contract.methods.setApprovalForAll (mover.address, true)); - }); - - /* Helper method that performs a (simulated) call through the - forwarder contract. to is the target address and call the - web3 contract method instance. */ - const forward = (to, call) => { - const data = call.encodeABI (); - return fwd.execute.call (to, data); - }; - - /* ************************************************************************ */ - - it ("should track direct moves", async () => { - let res; - res = await forward (xa.address, - xa.contract.methods.move ( - "p", "test", "x", noNonce, 0, zeroAddr)); - assert.lengthOf (res, 1); - chai.expect (res[0]).to.containSubset ({ - "ns": "p", - "name": "test", - "move": "x", - "nonce": "0", - "mover": fwd.address, - "amount": "0", - "receiver": zeroAddr, - }); - - res = await forward (xa.address, - xa.contract.methods.move ( - "p", "test", "y", noNonce, 0, zeroAddr)); - assert.lengthOf (res, 1); - chai.expect (res[0]).to.containSubset ({ - "move": "y", - }); - }); - - it ("should handle moves that revert", async () => { - await truffleAssert.reverts ( - forward (xa.address, - xa.contract.methods.move ( - "p", "test", "", noNonce, 0, zeroAddr))); - }); - - it ("should track moves with CHI payment", async () => { - const to = accounts[1]; - const res = await forward (xa.address, - xa.contract.methods.move ( - "p", "test", "x", noNonce, 42, to)); - assert.lengthOf (res, 1); - chai.expect (res[0]).to.containSubset ({ - "amount": "42", - "receiver": to, - }); - }); - - it ("should handle multiple moves in a transaction", async () => { - const res = await forward (mover.address, - mover.contract.methods.send ( - ["p"], ["test"], ["x", "y"])); - assert.lengthOf (res, 2); - chai.expect (res[0]).to.containSubset ({ - "move": "x", - "nonce": "0", - }); - chai.expect (res[1]).to.containSubset ({ - "move": "y", - "nonce": "1", - }); - }); - - it ("should handle ETH payments with forwarded calls", async () => { - const call = mover.contract.methods.requireEth ("p", "test", "x"); - const data = call.encodeABI (); - - const res = await fwd.execute.call (mover.address, data, {"value": 20}); - assert.lengthOf (res, 1); - chai.expect (res[0]).to.containSubset ({ - "move": "x", - }); - }); - - /* ************************************************************************ */ - -}); diff --git a/eth/solidity/truffle-config.js b/eth/solidity/truffle-config.js deleted file mode 100644 index 20ba80d..0000000 --- a/eth/solidity/truffle-config.js +++ /dev/null @@ -1,15 +0,0 @@ -module.exports = { - compilers: { - solc: { - version: "^0.8.4", - settings: { - optimizer: { - enabled: true, - runs: 100 - } - }, - evmVersion: "london" - } - }, - plugins: ["solidity-coverage"] -}; diff --git a/eth/tests/ethtest.py b/eth/tests/ethtest.py index d180ed1..5c561b7 100644 --- a/eth/tests/ethtest.py +++ b/eth/tests/ethtest.py @@ -1,4 +1,4 @@ -# Copyright (C) 2021 The Xaya developers +# Copyright (C) 2021-2024 The Xaya developers # Distributed under the MIT software license, see the accompanying # file COPYING or http://www.opensource.org/licenses/mit-license.php. @@ -29,7 +29,7 @@ def getXayaXExtraArgs (self): @contextmanager def environment (self): with super ().environment (): - self.w3 = self.env.ganache.w3 + self.w3 = self.env.evm.w3 yield def createBaseChain (self): @@ -64,17 +64,17 @@ def deployMultiMover (self, env=None): """ scriptPath = os.path.dirname (os.path.abspath (__file__)) - contracts = os.path.join (scriptPath, "..", - "solidity", "build", "contracts") + outdir = os.path.join (scriptPath, "..", "solidity", "out") - with open (os.path.join (contracts, "MultiMover.json")) as f: + with open (os.path.join (outdir, "MultiMover.sol", "MultiMover.json"), + "rt") as f: data = json.load (f) if env is None: env = self.env contracts = env.contracts - deployed = env.ganache.deployContract (contracts.account, data, - contracts.registry.address) + deployed = env.evm.deployContract (contracts.account, data, + contracts.registry.address) contracts.registry.functions\ .setApprovalForAll (deployed.address, True)\ diff --git a/eth/tests/pending.py b/eth/tests/pending.py index a8853d0..049be77 100755 --- a/eth/tests/pending.py +++ b/eth/tests/pending.py @@ -187,7 +187,7 @@ def extractMvids (data): }, ]) - # FIXME: It seems Ganache is not resurrecting transactions. + # FIXME: It seems Anvil is not resurrecting transactions. # Look into this and see what to do for testing reorgs. if False: snapshot.restore () diff --git a/package.json b/package.json deleted file mode 100644 index 20e634b..0000000 --- a/package.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "devDependencies": { - "chai": "", - "chai-subset": "", - "truffle-assertions": "", - "@openzeppelin/test-helpers": "", - "@truffle/contract": "", - "@xaya/wchi": "1.0.0", - "@xaya/eth-account-registry": "1.0.0" - } -} diff --git a/xayax/Makefile.am b/xayax/Makefile.am index 512fce3..1fb5e94 100644 --- a/xayax/Makefile.am +++ b/xayax/Makefile.am @@ -13,8 +13,6 @@ xayax_PYTHON = __init__.py \ testcase.py xayax_DATA = $(CONTRACTS) -xayamod = $(top_srcdir)/node_modules/@xaya -$(WCHI_CONTRACTS): %: $(xayamod)/wchi/build/contracts/% - cp $< $@ -$(ACCOUNTS_CONTRACTS): %: $(xayamod)/eth-account-registry/build/contracts/% - cp $< $@ +forgeout = $(top_builddir)/eth/solidity/out +$(CONTRACTS): %.json: $(forgeout)/%.sol + cp $