mirror of
https://github.com/luxfi/evm.git
synced 2026-09-24 00:27:44 +00:00
bump js dependencies (#1193)
* bump dependencies * bump node version in CI * update build script
This commit is contained in:
@@ -79,7 +79,7 @@ jobs:
|
||||
- name: Use Node.js
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: "18.15"
|
||||
node-version: "20.13"
|
||||
- name: NPM Clean Install
|
||||
run: npm ci
|
||||
working-directory: ./contracts
|
||||
@@ -121,7 +121,7 @@ jobs:
|
||||
- name: Use Node.js
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: "18.15"
|
||||
node-version: "20.13"
|
||||
- name: NPM Clean Install
|
||||
run: npm ci
|
||||
working-directory: ./contracts
|
||||
|
||||
@@ -144,3 +144,7 @@ dist
|
||||
.pnp.*
|
||||
|
||||
local_rpc.json
|
||||
|
||||
# TypeChain files
|
||||
/typechain
|
||||
/typechain-types
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
//SPDX-License-Identifier: MIT
|
||||
pragma solidity ^0.8.0;
|
||||
pragma solidity ^0.8.24;
|
||||
|
||||
import "./interfaces/IAllowList.sol";
|
||||
import "@openzeppelin/contracts/access/Ownable.sol";
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
//SPDX-License-Identifier: MIT
|
||||
pragma solidity ^0.8.0;
|
||||
pragma solidity ^0.8.24;
|
||||
|
||||
import "@openzeppelin/contracts/token/ERC20/ERC20.sol";
|
||||
import "./AllowList.sol";
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
//SPDX-License-Identifier: MIT
|
||||
pragma solidity ^0.8.0;
|
||||
pragma solidity ^0.8.24;
|
||||
|
||||
import "@openzeppelin/contracts/access/Ownable.sol";
|
||||
import "./interfaces/IAllowList.sol";
|
||||
@@ -19,6 +19,4 @@ contract ExampleDeployerList is AllowList {
|
||||
}
|
||||
|
||||
// This is an empty contract that can be used to test contract deployment
|
||||
contract Example {
|
||||
|
||||
}
|
||||
contract Example {}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
//SPDX-License-Identifier: MIT
|
||||
pragma solidity ^0.8.0;
|
||||
pragma solidity ^0.8.24;
|
||||
pragma experimental ABIEncoderV2;
|
||||
|
||||
import "@openzeppelin/contracts/access/Ownable.sol";
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
//SPDX-License-Identifier: MIT
|
||||
pragma solidity ^0.8.0;
|
||||
pragma solidity ^0.8.24;
|
||||
|
||||
import "./interfaces/IRewardManager.sol";
|
||||
import "@openzeppelin/contracts/access/Ownable.sol";
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
//SPDX-License-Identifier: MIT
|
||||
pragma solidity ^0.8.0;
|
||||
pragma solidity ^0.8.24;
|
||||
|
||||
import "./AllowList.sol";
|
||||
import "./interfaces/IAllowList.sol";
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
//SPDX-License-Identifier: MIT
|
||||
pragma solidity ^0.8.0;
|
||||
pragma solidity ^0.8.24;
|
||||
pragma experimental ABIEncoderV2;
|
||||
|
||||
import "./interfaces/IWarpMessenger.sol";
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
//SPDX-License-Identifier: MIT
|
||||
pragma solidity ^0.8.0;
|
||||
pragma solidity ^0.8.24;
|
||||
|
||||
interface IAllowList {
|
||||
event RoleSet(uint256 indexed role, address indexed account, address indexed sender, uint256 oldRole);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
//SPDX-License-Identifier: MIT
|
||||
pragma solidity ^0.8.0;
|
||||
pragma solidity ^0.8.24;
|
||||
import "./IAllowList.sol";
|
||||
|
||||
interface IFeeManager is IAllowList {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
//SPDX-License-Identifier: MIT
|
||||
pragma solidity ^0.8.0;
|
||||
pragma solidity ^0.8.24;
|
||||
import "./IAllowList.sol";
|
||||
|
||||
interface INativeMinter is IAllowList {
|
||||
|
||||
@@ -1,10 +1,14 @@
|
||||
//SPDX-License-Identifier: MIT
|
||||
pragma solidity ^0.8.0;
|
||||
pragma solidity ^0.8.24;
|
||||
import "./IAllowList.sol";
|
||||
|
||||
interface IRewardManager is IAllowList {
|
||||
// RewardAddressChanged is the event logged whenever reward address is modified
|
||||
event RewardAddressChanged(address indexed sender, address indexed oldRewardAddress, address indexed newRewardAddress);
|
||||
event RewardAddressChanged(
|
||||
address indexed sender,
|
||||
address indexed oldRewardAddress,
|
||||
address indexed newRewardAddress
|
||||
);
|
||||
|
||||
// FeeRecipientsAllowed is the event logged whenever fee recipient is modified
|
||||
event FeeRecipientsAllowed(address indexed sender);
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
pragma solidity ^0.8.0;
|
||||
pragma solidity ^0.8.24;
|
||||
|
||||
struct WarpMessage {
|
||||
bytes32 sourceChainID;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
//SPDX-License-Identifier: MIT
|
||||
pragma solidity ^0.8.0;
|
||||
pragma solidity ^0.8.24;
|
||||
|
||||
import "../AllowList.sol";
|
||||
import "ds-test/src/test.sol";
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
//SPDX-License-Identifier: MIT
|
||||
pragma solidity ^0.8.0;
|
||||
pragma solidity ^0.8.24;
|
||||
|
||||
import "../ERC20NativeMinter.sol";
|
||||
import "../interfaces/INativeMinter.sol";
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
//SPDX-License-Identifier: MIT
|
||||
pragma solidity ^0.8.0;
|
||||
pragma solidity ^0.8.24;
|
||||
|
||||
import "../ExampleDeployerList.sol";
|
||||
import "../interfaces/IAllowList.sol";
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
//SPDX-License-Identifier: MIT
|
||||
pragma solidity ^0.8.0;
|
||||
pragma solidity ^0.8.24;
|
||||
pragma experimental ABIEncoderV2;
|
||||
|
||||
import "../ExampleFeeManager.sol";
|
||||
@@ -25,6 +25,7 @@ contract ExampleFeeManagerTest is AllowListTest {
|
||||
ExampleFeeManager example = new ExampleFeeManager();
|
||||
|
||||
assertRole(manager.readAllowList(address(this)), AllowList.Role.Admin);
|
||||
assertRole(manager.readAllowList(address(example)), AllowList.Role.None);
|
||||
|
||||
try example.enableWAGMIFees() {
|
||||
assertTrue(false, "enableWAGMIFees should fail");
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
//SPDX-License-Identifier: MIT
|
||||
pragma solidity ^0.8.0;
|
||||
pragma solidity ^0.8.24;
|
||||
|
||||
import "../ExampleRewardManager.sol";
|
||||
import "../interfaces/IRewardManager.sol";
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
//SPDX-License-Identifier: MIT
|
||||
pragma solidity ^0.8.0;
|
||||
pragma solidity ^0.8.24;
|
||||
|
||||
import "../ExampleTxAllowList.sol";
|
||||
import "../AllowList.sol";
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import "@nomiclabs/hardhat-waffle"
|
||||
import "@nomiclabs/hardhat-ethers"
|
||||
import "@nomicfoundation/hardhat-toolbox";
|
||||
import "./tasks"
|
||||
|
||||
// HardHat users must populate these environment variables in order to connect to their subnet-evm instance
|
||||
@@ -11,19 +10,10 @@ export default {
|
||||
solidity: {
|
||||
compilers: [
|
||||
{
|
||||
version: "0.5.16"
|
||||
},
|
||||
{
|
||||
version: "0.6.2"
|
||||
},
|
||||
{
|
||||
version: "0.6.4"
|
||||
},
|
||||
{
|
||||
version: "0.7.0"
|
||||
},
|
||||
{
|
||||
version: "0.8.0"
|
||||
version: "0.8.24",
|
||||
settings: {
|
||||
evmVersion: "shanghai",
|
||||
},
|
||||
},
|
||||
]
|
||||
},
|
||||
|
||||
Generated
+3449
-4172
File diff suppressed because it is too large
Load Diff
+16
-17
@@ -1,13 +1,20 @@
|
||||
{
|
||||
"name": "@avalabs/subnet-evm-contracts",
|
||||
"devDependencies": {
|
||||
"@types/chai": "^4.3.11",
|
||||
"@nomicfoundation/hardhat-chai-matchers": "^2.0.6",
|
||||
"@nomicfoundation/hardhat-toolbox": "^5.0.0",
|
||||
"@types/chai": "^4.3.16",
|
||||
"@types/mocha": "^9.1.1",
|
||||
"@types/node": "^20.12.12",
|
||||
"chai": "^4.4.1",
|
||||
"ds-test": "https://github.com/dapphub/ds-test.git",
|
||||
"hardhat": "^2.22.4",
|
||||
"prettier": "^3.2.4",
|
||||
"prettier-plugin-solidity": "^1.3.1"
|
||||
"prettier-plugin-solidity": "^1.3.1",
|
||||
"ts-node": "^10.9.2",
|
||||
"typescript": "^5.4.5"
|
||||
},
|
||||
"version": "1.2.0",
|
||||
"version": "1.2.1",
|
||||
"description": "",
|
||||
"main": "dist/index.js",
|
||||
"types": "dist/index.d.ts",
|
||||
@@ -19,7 +26,7 @@
|
||||
},
|
||||
"license": "BSD-3-Clause",
|
||||
"scripts": {
|
||||
"build": "rm -rf dist/ && tsc -b && npx hardhat compile",
|
||||
"build": "rm -rf dist/ && npx hardhat compile && tsc -b ",
|
||||
"compile": "npx hardhat compile",
|
||||
"console": "npx hardhat console",
|
||||
"test": "npx hardhat test",
|
||||
@@ -28,19 +35,11 @@
|
||||
"release:prepare": "rm -rf ./dist ./node_modules && npm install && npm run build"
|
||||
},
|
||||
"dependencies": {
|
||||
"@nomiclabs/hardhat-ethers": "^2.2.3",
|
||||
"@nomiclabs/hardhat-waffle": "^2.0.6",
|
||||
"@types/node": "^16.11.7",
|
||||
"@avalabs/avalanchejs": "^3.17.0",
|
||||
"ethers": "^5.7.2",
|
||||
"hardhat": "2.19.4",
|
||||
"ts-node": "^10.9.2",
|
||||
"typescript": "^5.3.3",
|
||||
"@openzeppelin/contracts": "^4.9.5",
|
||||
"ds-test": "https://github.com/dapphub/ds-test.git"
|
||||
"@avalabs/avalanchejs": "^4.0.5",
|
||||
"@openzeppelin/contracts": "^4.9.6"
|
||||
},
|
||||
"engines": {
|
||||
"npm": ">6.0.0",
|
||||
"node": ">=18.15.0"
|
||||
"npm": ">7.0.0",
|
||||
"node": ">=20.13.0"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,15 +1,10 @@
|
||||
import {
|
||||
Contract,
|
||||
ContractFactory
|
||||
} from "ethers"
|
||||
import { ethers } from "hardhat"
|
||||
import { ERC20NativeMinter } from "typechain-types"
|
||||
|
||||
const main = async (): Promise<any> => {
|
||||
const Token: ContractFactory = await ethers.getContractFactory("ERC20NativeMinter")
|
||||
const token: Contract = await Token.deploy()
|
||||
|
||||
await token.deployed()
|
||||
console.log(`Token deployed to: ${token.address}`)
|
||||
const token: ERC20NativeMinter = await ethers.deployContract("ERC20NativeMinter")
|
||||
await token.waitForDeployment()
|
||||
console.log(`Token deployed to: ${token.target}`)
|
||||
}
|
||||
|
||||
main()
|
||||
|
||||
@@ -1,15 +1,10 @@
|
||||
import {
|
||||
Contract,
|
||||
ContractFactory
|
||||
} from "ethers"
|
||||
import { ethers } from "hardhat"
|
||||
import { ExampleDeployerList } from "typechain-types"
|
||||
|
||||
const main = async (): Promise<any> => {
|
||||
const contractFactory: ContractFactory = await ethers.getContractFactory("ExampleDeployerList")
|
||||
const contract: Contract = await contractFactory.deploy()
|
||||
|
||||
await contract.deployed()
|
||||
console.log(`Contract deployed to: ${contract.address}`)
|
||||
const contract: ExampleDeployerList = await ethers.deployContract("ExampleDeployerList")
|
||||
await contract.waitForDeployment()
|
||||
console.log(`Contract deployed to: ${contract.target}`)
|
||||
}
|
||||
|
||||
main()
|
||||
|
||||
@@ -1,16 +1,11 @@
|
||||
import {
|
||||
Contract,
|
||||
ContractFactory
|
||||
} from "ethers"
|
||||
import { ethers } from "hardhat"
|
||||
|
||||
import { ExampleRewardManager } from "typechain-types"
|
||||
|
||||
const main = async (): Promise<any> => {
|
||||
const Contract: ContractFactory = await ethers.getContractFactory("ExampleRewardManager")
|
||||
const contract: Contract = await Contract.deploy()
|
||||
const contract: ExampleRewardManager = await ethers.deployContract("ExampleRewardManager")
|
||||
|
||||
await contract.deployed()
|
||||
console.log(`Contract deployed to: ${contract.address}`)
|
||||
await contract.waitForDeployment()
|
||||
console.log(`Contract deployed to: ${contract.target}`)
|
||||
}
|
||||
|
||||
main()
|
||||
|
||||
@@ -1,15 +1,11 @@
|
||||
import {
|
||||
Contract,
|
||||
ContractFactory
|
||||
} from "ethers"
|
||||
import { ethers } from "hardhat"
|
||||
import { ExampleTxAllowList } from "typechain-types"
|
||||
|
||||
const main = async (): Promise<any> => {
|
||||
const contractFactory: ContractFactory = await ethers.getContractFactory("ExampleTxAllowList")
|
||||
const contract: Contract = await contractFactory.deploy()
|
||||
const contract: ExampleTxAllowList = await ethers.deployContract("ExampleTxAllowList")
|
||||
|
||||
await contract.deployed()
|
||||
console.log(`Contract deployed to: ${contract.address}`)
|
||||
await contract.waitForDeployment()
|
||||
console.log(`Contract deployed to: ${contract.target}`)
|
||||
}
|
||||
|
||||
main()
|
||||
|
||||
+6
-8
@@ -1,6 +1,4 @@
|
||||
import { task } from "hardhat/config"
|
||||
import { SignerWithAddress } from "@nomiclabs/hardhat-ethers/signers"
|
||||
import { BigNumber } from "ethers"
|
||||
|
||||
const BLACKHOLE_ADDRESS = "0x0100000000000000000000000000000000000000"
|
||||
const CONTRACT_ALLOW_LIST_ADDRESS = "0x0200000000000000000000000000000000000000"
|
||||
@@ -22,16 +20,16 @@ const getRole = async (allowList, address) => {
|
||||
}
|
||||
|
||||
task("accounts", "Prints the list of accounts", async (args, hre): Promise<void> => {
|
||||
const accounts: SignerWithAddress[] = await hre.ethers.getSigners()
|
||||
accounts.forEach((account: SignerWithAddress): void => {
|
||||
const accounts = await hre.ethers.getSigners()
|
||||
accounts.forEach((account): void => {
|
||||
console.log(account.address)
|
||||
})
|
||||
})
|
||||
|
||||
task("balances", "Prints the list of account balances", async (args, hre): Promise<void> => {
|
||||
const accounts: SignerWithAddress[] = await hre.ethers.getSigners()
|
||||
const accounts = await hre.ethers.getSigners()
|
||||
for (const account of accounts) {
|
||||
const balance: BigNumber = await hre.ethers.provider.getBalance(
|
||||
const balance = await hre.ethers.provider.getBalance(
|
||||
account.address
|
||||
)
|
||||
console.log(`${account.address} has balance ${balance.toString()}`)
|
||||
@@ -43,7 +41,7 @@ task("balance", "get the balance")
|
||||
.addParam("address", "the address you want to know balance of")
|
||||
.setAction(async (args, hre) => {
|
||||
const balance = await hre.ethers.provider.getBalance(args.address)
|
||||
const balanceInCoin = hre.ethers.utils.formatEther(balance)
|
||||
const balanceInCoin = hre.ethers.formatEther(balance)
|
||||
console.log(`balance: ${balanceInCoin} Coin`)
|
||||
})
|
||||
|
||||
@@ -171,7 +169,7 @@ task("minter:burn", "Burns native tokens")
|
||||
const [owner] = await hre.ethers.getSigners()
|
||||
const transactionHash = await owner.sendTransaction({
|
||||
to: BLACKHOLE_ADDRESS,
|
||||
value: hre.ethers.utils.parseEther(args.amount),
|
||||
value: hre.ethers.parseEther(args.amount),
|
||||
})
|
||||
console.log(transactionHash)
|
||||
})
|
||||
|
||||
@@ -2,10 +2,11 @@
|
||||
// See the file LICENSE for licensing terms.
|
||||
|
||||
import { ethers } from "hardhat"
|
||||
|
||||
import { Roles, test } from "./utils"
|
||||
import { SignerWithAddress } from "@nomiclabs/hardhat-ethers/signers";
|
||||
import { expect } from "chai";
|
||||
import { Contract } from "ethers"
|
||||
import { Contract, Signer } from "ethers"
|
||||
import { IAllowList } from "typechain-types";
|
||||
|
||||
const ADMIN_ADDRESS: string = "0x8db97C7cEcE249c2b98bDC0226Cc4C2A57BF52FC"
|
||||
const OTHER_SIGNER = "0x0Fa8EA536Be85F32724D57A37758761B86416123"
|
||||
@@ -21,8 +22,8 @@ describe("ExampleDeployerList", function () {
|
||||
.then(contract => {
|
||||
this.testContract = contract
|
||||
return Promise.all([
|
||||
contract.deployed().then(() => contract),
|
||||
allowListPromise.then(allowList => allowList.setAdmin(contract.address)).then(tx => tx.wait()),
|
||||
contract.waitForDeployment().then(() => contract),
|
||||
allowListPromise.then(allowList => allowList.setAdmin(contract.target)).then(tx => tx.wait()),
|
||||
])
|
||||
})
|
||||
.then(([contract]) => contract.setUp())
|
||||
@@ -53,38 +54,48 @@ describe("ExampleDeployerList", function () {
|
||||
})
|
||||
|
||||
describe("IAllowList", function () {
|
||||
let owner: SignerWithAddress
|
||||
let contract: Contract
|
||||
let owner: Signer
|
||||
let ownerAddress: string
|
||||
let contract: IAllowList
|
||||
before(async function () {
|
||||
owner = await ethers.getSigner(ADMIN_ADDRESS);
|
||||
ownerAddress = await owner.getAddress()
|
||||
contract = await ethers.getContractAt("IAllowList", DEPLOYER_ALLOWLIST_ADDRESS, owner)
|
||||
});
|
||||
|
||||
it("should emit event after set admin", async function () {
|
||||
let testAddress = "0x0111000000000000000000000000000000000001"
|
||||
await expect(contract.setAdmin(testAddress))
|
||||
let tx = await contract.setAdmin(testAddress)
|
||||
let receipt = await tx.wait()
|
||||
await expect(receipt)
|
||||
.to.emit(contract, 'RoleSet')
|
||||
.withArgs(Roles.Admin, testAddress, owner.address, Roles.None)
|
||||
.withArgs(Roles.Admin, testAddress, ownerAddress, Roles.None)
|
||||
})
|
||||
|
||||
it("should emit event after set manager", async function () {
|
||||
let testAddress = "0x0222000000000000000000000000000000000002"
|
||||
await expect(contract.setManager(testAddress))
|
||||
let tx = await contract.setManager(testAddress)
|
||||
let receipt = await tx.wait()
|
||||
await expect(receipt)
|
||||
.to.emit(contract, 'RoleSet')
|
||||
.withArgs(Roles.Manager, testAddress, owner.address, Roles.None)
|
||||
.withArgs(Roles.Manager, testAddress, ownerAddress, Roles.None)
|
||||
})
|
||||
|
||||
it("should emit event after set enabled", async function () {
|
||||
let testAddress = "0x0333000000000000000000000000000000000003"
|
||||
await expect(contract.setEnabled(testAddress))
|
||||
let tx = await contract.setEnabled(testAddress)
|
||||
let receipt = await tx.wait()
|
||||
await expect(receipt)
|
||||
.to.emit(contract, 'RoleSet')
|
||||
.withArgs(Roles.Enabled, testAddress, owner.address, Roles.None)
|
||||
.withArgs(Roles.Enabled, testAddress, ownerAddress, Roles.None)
|
||||
})
|
||||
|
||||
it("should emit event after set none", async function () {
|
||||
let testAddress = "0x0333000000000000000000000000000000000003"
|
||||
await expect(contract.setNone(testAddress))
|
||||
let tx = await contract.setNone(testAddress)
|
||||
let receipt = await tx.wait()
|
||||
await expect(receipt)
|
||||
.to.emit(contract, 'RoleSet')
|
||||
.withArgs(Roles.None, testAddress, owner.address, Roles.Enabled)
|
||||
.withArgs(Roles.None, testAddress, ownerAddress, Roles.Enabled)
|
||||
})
|
||||
})
|
||||
|
||||
@@ -3,9 +3,9 @@
|
||||
|
||||
import { ethers } from "hardhat"
|
||||
import { test } from "./utils"
|
||||
import { SignerWithAddress } from "@nomiclabs/hardhat-ethers/signers";
|
||||
import { expect } from "chai";
|
||||
import { Contract } from "ethers"
|
||||
import { Contract, Signer } from "ethers"
|
||||
import { INativeMinter } from "typechain-types";
|
||||
|
||||
const ADMIN_ADDRESS: string = "0x8db97C7cEcE249c2b98bDC0226Cc4C2A57BF52FC"
|
||||
const MINT_PRECOMPILE_ADDRESS = "0x0200000000000000000000000000000000000001"
|
||||
@@ -19,11 +19,11 @@ describe("ERC20NativeMinter", function () {
|
||||
.then(factory => factory.deploy())
|
||||
.then(contract => {
|
||||
this.testContract = contract
|
||||
return contract.deployed().then(() => contract)
|
||||
return contract.waitForDeployment().then(() => contract)
|
||||
})
|
||||
.then(contract => contract.setUp())
|
||||
.then(tx => Promise.all([nativeMinterPromise, tx.wait()]))
|
||||
.then(([nativeMinter]) => nativeMinter.setAdmin(this.testContract.address))
|
||||
.then(([nativeMinter]) => nativeMinter.setAdmin(this.testContract.target))
|
||||
.then(tx => tx.wait())
|
||||
})
|
||||
|
||||
@@ -42,18 +42,22 @@ describe("ERC20NativeMinter", function () {
|
||||
|
||||
|
||||
describe("INativeMinter", function () {
|
||||
let owner: SignerWithAddress
|
||||
let contract: Contract
|
||||
let owner: Signer
|
||||
let ownerAddress: string
|
||||
let contract: INativeMinter
|
||||
before(async function () {
|
||||
owner = await ethers.getSigner(ADMIN_ADDRESS);
|
||||
ownerAddress = await owner.getAddress()
|
||||
contract = await ethers.getContractAt("INativeMinter", MINT_PRECOMPILE_ADDRESS, owner)
|
||||
});
|
||||
|
||||
it("should emit NativeCoinMinted event", async function () {
|
||||
let testAddress = "0x0444400000000000000000000000000000000004"
|
||||
let amount = 1000
|
||||
await expect(contract.mintNativeCoin(testAddress, amount))
|
||||
let tx = await contract.mintNativeCoin(testAddress, amount)
|
||||
let receipt = await tx.wait()
|
||||
await expect(receipt)
|
||||
.to.emit(contract, 'NativeCoinMinted')
|
||||
.withArgs(owner.address, testAddress, amount)
|
||||
.withArgs(ownerAddress, testAddress, amount)
|
||||
})
|
||||
})
|
||||
|
||||
@@ -4,8 +4,8 @@
|
||||
import { expect } from "chai"
|
||||
import { ethers } from "hardhat"
|
||||
import { test } from "./utils"
|
||||
import { SignerWithAddress } from "@nomiclabs/hardhat-ethers/signers";
|
||||
import { Contract } from "ethers"
|
||||
import { Contract, Signer } from "ethers"
|
||||
import { IFeeManager } from "typechain-types"
|
||||
|
||||
const ADMIN_ADDRESS: string = "0x8db97C7cEcE249c2b98bDC0226Cc4C2A57BF52FC"
|
||||
const FEE_MANAGER = "0x0200000000000000000000000000000000000003"
|
||||
@@ -21,11 +21,11 @@ describe("ExampleFeeManager", function () {
|
||||
.then(factory => factory.deploy())
|
||||
.then(contract => {
|
||||
this.testContract = contract
|
||||
return contract.deployed().then(() => contract)
|
||||
return contract.waitForDeployment().then(() => contract)
|
||||
})
|
||||
.then(contract => contract.setUp())
|
||||
.then(tx => Promise.all([feeManagerPromise, tx.wait()]))
|
||||
.then(([feeManager]) => feeManager.setAdmin(this.testContract.address))
|
||||
.then(([feeManager]) => feeManager.setAdmin(this.testContract.target))
|
||||
.then(tx => tx.wait())
|
||||
})
|
||||
|
||||
@@ -79,10 +79,12 @@ const WAGMI_FEES = {
|
||||
}
|
||||
|
||||
describe("IFeeManager", function () {
|
||||
let owner: SignerWithAddress
|
||||
let contract: Contract
|
||||
let owner: Signer
|
||||
let ownerAddress: string
|
||||
let contract: IFeeManager
|
||||
before(async function () {
|
||||
owner = await ethers.getSigner(ADMIN_ADDRESS);
|
||||
ownerAddress = await owner.getAddress()
|
||||
contract = await ethers.getContractAt("IFeeManager", FEE_MANAGER, owner)
|
||||
// reset to C fees
|
||||
let tx = await contract.setFeeConfig(
|
||||
@@ -98,7 +100,7 @@ describe("IFeeManager", function () {
|
||||
});
|
||||
|
||||
it("should emit fee config changed event", async function () {
|
||||
await expect(contract.setFeeConfig(
|
||||
let tx = await (contract.setFeeConfig(
|
||||
WAGMI_FEES.gasLimit,
|
||||
WAGMI_FEES.targetBlockRate,
|
||||
WAGMI_FEES.minBaseFee,
|
||||
@@ -108,9 +110,11 @@ describe("IFeeManager", function () {
|
||||
WAGMI_FEES.maxBlockGasCost,
|
||||
WAGMI_FEES.blockGasCostStep)
|
||||
)
|
||||
let receipt = await tx.wait()
|
||||
await expect(receipt)
|
||||
.to.emit(contract, 'FeeConfigChanged')
|
||||
.withArgs(
|
||||
owner.address,
|
||||
ownerAddress,
|
||||
// old config
|
||||
[C_FEES.gasLimit, C_FEES.targetBlockRate, C_FEES.minBaseFee, C_FEES.targetGas, C_FEES.baseFeeChangeDenominator, C_FEES.minBlockGasCost, C_FEES.maxBlockGasCost, C_FEES.blockGasCostStep],
|
||||
// new config
|
||||
|
||||
@@ -3,9 +3,9 @@
|
||||
|
||||
import { ethers } from "hardhat"
|
||||
import { test } from "./utils"
|
||||
import { SignerWithAddress } from "@nomiclabs/hardhat-ethers/signers";
|
||||
import { expect } from "chai";
|
||||
import { Contract } from "ethers"
|
||||
import { Contract, Signer } from "ethers"
|
||||
import { IRewardManager } from "typechain-types";
|
||||
|
||||
// make sure this is always an admin for reward manager precompile
|
||||
const ADMIN_ADDRESS = "0x8db97C7cEcE249c2b98bDC0226Cc4C2A57BF52FC"
|
||||
@@ -17,15 +17,15 @@ describe("ExampleRewardManager", function () {
|
||||
const signer = await ethers.getSigner(ADMIN_ADDRESS)
|
||||
const rewardManagerPromise = ethers.getContractAt("IRewardManager", REWARD_MANAGER_ADDRESS, signer)
|
||||
|
||||
return ethers.getContractFactory("ExampleRewardManagerTest", { signer })
|
||||
return ethers.getContractFactory("ExampleRewardManagerTest", signer)
|
||||
.then(factory => factory.deploy())
|
||||
.then(contract => {
|
||||
this.testContract = contract
|
||||
return contract.deployed().then(() => contract)
|
||||
return contract.waitForDeployment().then(() => contract)
|
||||
})
|
||||
.then(contract => contract.setUp())
|
||||
.then(tx => Promise.all([rewardManagerPromise, tx.wait()]))
|
||||
.then(([rewardManager]) => rewardManager.setAdmin(this.testContract.address))
|
||||
.then(([rewardManager]) => rewardManager.setAdmin(this.testContract.target))
|
||||
.then(tx => tx.wait())
|
||||
})
|
||||
|
||||
@@ -49,29 +49,37 @@ describe("ExampleRewardManager", function () {
|
||||
});
|
||||
|
||||
describe("IRewardManager", function () {
|
||||
let owner: SignerWithAddress
|
||||
let contract: Contract
|
||||
let owner: Signer
|
||||
let ownerAddress: string
|
||||
let contract: IRewardManager
|
||||
before(async function () {
|
||||
owner = await ethers.getSigner(ADMIN_ADDRESS);
|
||||
ownerAddress = await owner.getAddress()
|
||||
contract = await ethers.getContractAt("IRewardManager", REWARD_MANAGER_ADDRESS, owner)
|
||||
});
|
||||
|
||||
it("should emit reward address changed event ", async function () {
|
||||
let testAddress = "0x0444400000000000000000000000000000000004"
|
||||
await expect(contract.setRewardAddress(testAddress))
|
||||
.to.emit(contract, 'RewardAddressChanged')
|
||||
.withArgs(owner.address, BLACKHOLE_ADDRESS, testAddress)
|
||||
let tx = await contract.setRewardAddress(testAddress)
|
||||
let receipt = await tx.wait()
|
||||
await expect(receipt)
|
||||
.to.be.emit(contract, 'RewardAddressChanged')
|
||||
.withArgs(ownerAddress, BLACKHOLE_ADDRESS, testAddress)
|
||||
})
|
||||
|
||||
it("should emit fee recipients allowed event ", async function () {
|
||||
await expect(contract.allowFeeRecipients())
|
||||
.to.emit(contract, 'FeeRecipientsAllowed')
|
||||
.withArgs(owner.address)
|
||||
let tx = await contract.allowFeeRecipients()
|
||||
let receipt = await tx.wait()
|
||||
await expect(receipt)
|
||||
.to.be.emit(contract, 'FeeRecipientsAllowed')
|
||||
.withArgs(ownerAddress)
|
||||
})
|
||||
|
||||
it("should emit rewards disabled event ", async function () {
|
||||
await expect(contract.disableRewards())
|
||||
.to.emit(contract, 'RewardsDisabled')
|
||||
.withArgs(owner.address)
|
||||
let tx = await contract.disableRewards()
|
||||
let receipt = await tx.wait()
|
||||
await expect(receipt)
|
||||
.to.be.emit(contract, 'RewardsDisabled')
|
||||
.withArgs(ownerAddress)
|
||||
})
|
||||
})
|
||||
|
||||
@@ -3,9 +3,9 @@
|
||||
|
||||
import { ethers } from "hardhat"
|
||||
import { Roles, test } from "./utils"
|
||||
import { SignerWithAddress } from "@nomiclabs/hardhat-ethers/signers";
|
||||
import { expect } from "chai";
|
||||
import { Contract } from "ethers"
|
||||
import { Contract, Signer } from "ethers"
|
||||
import { IAllowList } from "typechain-types";
|
||||
|
||||
// make sure this is always an admin for minter precompile
|
||||
const ADMIN_ADDRESS = "0x8db97C7cEcE249c2b98bDC0226Cc4C2A57BF52FC"
|
||||
@@ -22,8 +22,8 @@ describe("ExampleTxAllowList", function () {
|
||||
.then(contract => {
|
||||
this.testContract = contract
|
||||
return Promise.all([
|
||||
contract.deployed().then(() => contract),
|
||||
allowListPromise.then(allowList => allowList.setAdmin(contract.address)).then(tx => tx.wait()),
|
||||
contract.waitForDeployment().then(() => contract),
|
||||
allowListPromise.then(allowList => allowList.setAdmin(contract.target)).then(tx => tx.wait()),
|
||||
])
|
||||
})
|
||||
.then(([contract]) => contract.setUp())
|
||||
@@ -88,38 +88,48 @@ describe("ExampleTxAllowList", function () {
|
||||
})
|
||||
|
||||
describe("IAllowList", function () {
|
||||
let owner: SignerWithAddress
|
||||
let contract: Contract
|
||||
let owner: Signer
|
||||
let ownerAddress: string
|
||||
let contract: IAllowList
|
||||
before(async function () {
|
||||
owner = await ethers.getSigner(ADMIN_ADDRESS);
|
||||
ownerAddress = await owner.getAddress()
|
||||
contract = await ethers.getContractAt("IAllowList", TX_ALLOW_LIST_ADDRESS, owner)
|
||||
});
|
||||
|
||||
it("should emit event after set admin", async function () {
|
||||
let testAddress = "0x0111000000000000000000000000000000000001"
|
||||
await expect(contract.setAdmin(testAddress))
|
||||
let tx = await contract.setAdmin(testAddress)
|
||||
let receipt = await tx.wait()
|
||||
await expect(receipt)
|
||||
.to.emit(contract, 'RoleSet')
|
||||
.withArgs(Roles.Admin, testAddress, owner.address, Roles.None)
|
||||
.withArgs(Roles.Admin, testAddress, ownerAddress, Roles.None)
|
||||
})
|
||||
|
||||
it("should emit event after set manager", async function () {
|
||||
let testAddress = "0x0222000000000000000000000000000000000002"
|
||||
await expect(contract.setManager(testAddress))
|
||||
let tx = await contract.setManager(testAddress)
|
||||
let receipt = await tx.wait()
|
||||
await expect(receipt)
|
||||
.to.emit(contract, 'RoleSet')
|
||||
.withArgs(Roles.Manager, testAddress, owner.address, Roles.None)
|
||||
.withArgs(Roles.Manager, testAddress, ownerAddress, Roles.None)
|
||||
})
|
||||
|
||||
it("should emit event after set enabled", async function () {
|
||||
let testAddress = "0x0333000000000000000000000000000000000003"
|
||||
await expect(contract.setEnabled(testAddress))
|
||||
let tx = await contract.setEnabled(testAddress)
|
||||
let receipt = await tx.wait()
|
||||
await expect(receipt)
|
||||
.to.emit(contract, 'RoleSet')
|
||||
.withArgs(Roles.Enabled, testAddress, owner.address, Roles.None)
|
||||
.withArgs(Roles.Enabled, testAddress, ownerAddress, Roles.None)
|
||||
})
|
||||
|
||||
it("should emit event after set none", async function () {
|
||||
let testAddress = "0x0333000000000000000000000000000000000003"
|
||||
await expect(contract.setNone(testAddress))
|
||||
let tx = await contract.setNone(testAddress)
|
||||
let receipt = await tx.wait()
|
||||
await expect(receipt)
|
||||
.to.emit(contract, 'RoleSet')
|
||||
.withArgs(Roles.None, testAddress, owner.address, Roles.Enabled)
|
||||
.withArgs(Roles.None, testAddress, ownerAddress, Roles.Enabled)
|
||||
})
|
||||
})
|
||||
|
||||
+10
-12
@@ -1,5 +1,5 @@
|
||||
import { ethers } from "hardhat"
|
||||
import { CallOverrides } from "ethers"
|
||||
import { Overrides } from "ethers"
|
||||
import assert from "assert"
|
||||
|
||||
/*
|
||||
@@ -40,12 +40,12 @@ import assert from "assert"
|
||||
type FnNameOrObject = string | string[] | MethodObject | MethodObject[]
|
||||
|
||||
// Limit `from` property to be a `string` instead of `string | Promise<string>`
|
||||
type Overrides = CallOverrides & { from?: string }
|
||||
type CallOverrides = Overrides & { from?: string }
|
||||
|
||||
type MethodObject = { method: string, debug?: boolean, overrides?: Overrides, shouldFail?: boolean }
|
||||
type MethodObject = { method: string, debug?: boolean, overrides?: CallOverrides, shouldFail?: boolean }
|
||||
|
||||
// This type is after all default values have been applied
|
||||
type MethodWithDebugAndOverrides = MethodObject & { debug: boolean, overrides: Overrides, shouldFail: boolean }
|
||||
type MethodWithDebugAndOverrides = MethodObject & { debug: boolean, overrides: CallOverrides, shouldFail: boolean }
|
||||
|
||||
// `test` is used very similarly to `it` from Mocha
|
||||
export const test = (name, fnNameOrObject, overrides = {}) => it(name, buildTestFn(fnNameOrObject, overrides))
|
||||
@@ -83,7 +83,9 @@ const buildTestFn = (fnNameOrObject: FnNameOrObject, overrides = {}, debug = fal
|
||||
: this.testContract
|
||||
const tx = await contract[fn.method](fn.overrides).catch(err => {
|
||||
if (fn.shouldFail) {
|
||||
if (fn.debug) console.error(`smart contract call failed with error:\n${err}\n`)
|
||||
if (fn.debug){
|
||||
console.error(`smart contract call failed with error:\n${err}\n`)
|
||||
}
|
||||
|
||||
return { failed: true }
|
||||
}
|
||||
@@ -101,8 +103,8 @@ const buildTestFn = (fnNameOrObject: FnNameOrObject, overrides = {}, debug = fal
|
||||
})
|
||||
|
||||
// `txReceipt.status` will be `0` if the transaction failed.
|
||||
// `contract.callStatic.failed()` will return `true` if any of the `DSTest` assertions failed.
|
||||
const failed = txReceipt.status === 0 ? true : await contract.callStatic.failed()
|
||||
// `contract.failed` will return `true` if any of the `DSTest` assertions failed.
|
||||
const failed = txReceipt.status === 0 ? true : await contract.failed.staticCall()
|
||||
if (fn.debug || failed) {
|
||||
console.log('')
|
||||
|
||||
@@ -117,11 +119,7 @@ const buildTestFn = (fnNameOrObject: FnNameOrObject, overrides = {}, debug = fal
|
||||
console.log('')
|
||||
}
|
||||
|
||||
if (fn.shouldFail) {
|
||||
assert(failed, `${fn.method} should have failed`)
|
||||
} else {
|
||||
assert(!failed, `${fn.method} failed`)
|
||||
}
|
||||
assert(!failed, `${fn.method} failed`)
|
||||
}), Promise.resolve())
|
||||
}
|
||||
}
|
||||
|
||||
+9
-10
@@ -1,12 +1,10 @@
|
||||
// (c) 2019-2022, Ava Labs, Inc. All rights reserved.
|
||||
// See the file LICENSE for licensing terms.
|
||||
|
||||
import { SignerWithAddress } from "@nomiclabs/hardhat-ethers/signers";
|
||||
import { expect } from "chai";
|
||||
import {
|
||||
Contract,
|
||||
} from "ethers"
|
||||
import { ethers } from "hardhat"
|
||||
import { ethers } from "hardhat";
|
||||
import { Contract, Signer } from "ethers";
|
||||
import { IWarpMessenger } from "typechain-types";
|
||||
|
||||
const WARP_ADDRESS = "0x0200000000000000000000000000000000000005";
|
||||
let senderAddress = process.env["SENDER_ADDRESS"];
|
||||
@@ -16,8 +14,8 @@ let expectedUnsignedMessage = process.env["EXPECTED_UNSIGNED_MESSAGE"];
|
||||
let sourceID = process.env["SOURCE_CHAIN_ID"];
|
||||
|
||||
describe("IWarpMessenger", function () {
|
||||
let owner: SignerWithAddress
|
||||
let contract: Contract
|
||||
let owner: Signer;
|
||||
let contract: IWarpMessenger;
|
||||
before(async function () {
|
||||
owner = await ethers.getSigner(senderAddress);
|
||||
contract = await ethers.getContractAt("IWarpMessenger", WARP_ADDRESS, owner)
|
||||
@@ -27,9 +25,10 @@ describe("IWarpMessenger", function () {
|
||||
console.log(`Sending warp message with payload ${payload}, expected unsigned message ${expectedUnsignedMessage}`);
|
||||
|
||||
// Get ID of payload by taking sha256 of unsigned message
|
||||
let messageID = ethers.utils.sha256(expectedUnsignedMessage);
|
||||
|
||||
await expect(contract.sendWarpMessage(payload))
|
||||
let messageID = ethers.sha256(expectedUnsignedMessage);
|
||||
let tx = await contract.sendWarpMessage(payload)
|
||||
let receipt = await tx.wait()
|
||||
await expect(receipt)
|
||||
.to.emit(contract, 'SendWarpMessage')
|
||||
.withArgs(senderAddress, messageID, expectedUnsignedMessage);
|
||||
})
|
||||
|
||||
@@ -4,13 +4,14 @@
|
||||
"baseUrl": ".",
|
||||
"module": "commonjs",
|
||||
"target": "es2020",
|
||||
"lib": ["es2016"],
|
||||
"typeRoots": ["./typings/**", "./node_modules/@types"],
|
||||
"esModuleInterop": true,
|
||||
"forceConsistentCasingInFileNames": true,
|
||||
"skipLibCheck": true,
|
||||
"resolveJsonModule": true,
|
||||
},
|
||||
"include": ["./scripts", "./test", "./typechain-types"],
|
||||
"files": ["./hardhat.config.ts"],
|
||||
"exclude": ["node_modules", "artifacts", "cache"],
|
||||
"typeAcquisition": {
|
||||
"enable": true,
|
||||
|
||||
Reference in New Issue
Block a user