-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* hardhat e2e tests * fix timeout * fix * add proxy test
- Loading branch information
1 parent
12cc4ed
commit 29e56bb
Showing
16 changed files
with
785 additions
and
88 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -74,3 +74,6 @@ lib | |
## yarn cache | ||
**/.yarn/cache | ||
**/.yarn/install-state.gz | ||
|
||
## openzeppelin cache | ||
**/.openzeppelin/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,63 +1,4 @@ | ||
module.exports = { | ||
env: { | ||
node: true, | ||
}, | ||
parser: '@typescript-eslint/parser', | ||
plugins: [ | ||
'@typescript-eslint', | ||
'import', | ||
'sort-imports-es6-autofix', | ||
], | ||
extends: [ | ||
'eslint:recommended', | ||
'plugin:@typescript-eslint/recommended', | ||
'plugin:import/recommended', | ||
'plugin:import/typescript', | ||
], | ||
rules: { | ||
indent: [2, 2, { SwitchCase: 1 }], | ||
quotes: [2, 'single'], | ||
semi: [1, 'always'], | ||
'no-trailing-spaces': [2], | ||
'quote-props': [2, 'as-needed'], | ||
'eol-last': [2, 'always'], | ||
'object-curly-spacing': [2, 'always'], | ||
'comma-dangle': [2, { | ||
arrays: 'always-multiline', | ||
objects: 'always-multiline', | ||
imports: 'always-multiline', | ||
exports: 'always-multiline', | ||
functions: 'only-multiline', | ||
}], | ||
|
||
/* ---------- turn off ---------- */ | ||
'@typescript-eslint/no-extra-semi': 0, | ||
'@typescript-eslint/no-use-before-define': 0, | ||
'@typescript-eslint/explicit-member-accessibility': 0, | ||
'@typescript-eslint/naming-convention': 0, | ||
'@typescript-eslint/no-explicit-any': 0, // any is sometimes unavoidable | ||
'@typescript-eslint/consistent-type-definitions': 0, // can use Type and Interface | ||
'@typescript-eslint/explicit-function-return-type': 0, // type inference on return type is useful | ||
'@typescript-eslint/no-parameter-properties': 0, | ||
'@typescript-eslint/typedef': 0, | ||
'no-unused-expressions': 0, // short ciucuit if | ||
'max-lines': 0, | ||
'@typescript-eslint/no-empty-function': 'off', | ||
'@typescript-eslint/explicit-module-boundary-types': 'off', | ||
'sort-imports-es6-autofix/sort-imports-es6': 'warn', | ||
'@typescript-eslint/ban-ts-comment': 'off', | ||
'no-useless-escape': 'off', | ||
'@typescript-eslint/no-non-null-asserted-optional-chain': 'off', | ||
'import/no-named-as-default-member': 'off', | ||
'import/no-named-as-default': 'off', | ||
'@typescript-eslint/no-non-null-assertion': 'off', | ||
'@typescript-eslint/no-unused-vars': [ | ||
'warn', | ||
{ | ||
argsIgnorePattern: '^_', | ||
varsIgnorePattern: '^_', | ||
caughtErrorsIgnorePattern: '^_', | ||
}, | ||
], | ||
}, | ||
root: true, | ||
extends: ['../../.eslintrc.js'], | ||
}; |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
pragma solidity =0.8.20; | ||
|
||
contract Echo{ | ||
string public echo; | ||
uint echoCount; | ||
|
||
event NewEcho(string message, uint count); | ||
|
||
constructor() { | ||
echo = "Deployed successfully!"; | ||
} | ||
|
||
function scream(string memory message) public returns(string memory){ | ||
echo = message; | ||
echoCount += 1; | ||
emit NewEcho(message, echoCount); | ||
return message; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
pragma solidity =0.8.20; | ||
|
||
import "hardhat/console.sol"; | ||
import "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol"; | ||
|
||
contract Greeter is Initializable { | ||
string private greeting; | ||
|
||
function initialize(string memory _greeting) public initializer { | ||
console.log("Deploying a Greeter with greeting:", _greeting); | ||
greeting = _greeting; | ||
} | ||
|
||
function greet() public view returns (string memory) { | ||
return greeting; | ||
} | ||
|
||
function setGreeting(string memory _greeting) public { | ||
console.log("Changing greeting from '%s' to '%s'", greeting, _greeting); | ||
greeting = _greeting; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
pragma solidity =0.8.20; | ||
|
||
import "hardhat/console.sol"; | ||
import "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol"; | ||
import "./Greeter.sol"; | ||
|
||
contract GreeterV2 is Greeter { | ||
string private greeting; | ||
|
||
function setGreetingV2(string memory _greeting) public { | ||
string memory newGreeting = string(abi.encodePacked(_greeting, " - V2")); | ||
console.log("<V2> Changing greeting from '%s' to '%s'", greeting, newGreeting); | ||
setGreeting(newGreeting); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
pragma solidity =0.8.20; | ||
|
||
import "@openzeppelin/contracts/token/ERC20/ERC20.sol"; | ||
|
||
contract Token is ERC20 { | ||
constructor(uint256 _initialBalance) ERC20("Token", "TKN") public { | ||
_mint(msg.sender, _initialBalance); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
import { ethers } from 'hardhat'; | ||
import { expect } from 'chai'; | ||
|
||
import { Echo } from '../typechain-types'; | ||
|
||
describe('Echo contract', function () { | ||
let instance: Echo; | ||
|
||
beforeEach(async () => { | ||
instance = await ethers.deployContract('Echo', []); | ||
await instance.waitForDeployment(); | ||
}); | ||
|
||
it('should set the value of the echo when deploying', async () => { | ||
expect(await instance.echo()).to.equal('Deployed successfully!'); | ||
}); | ||
|
||
describe('Operation', function () { | ||
it('should update the echo variable', async () => { | ||
await (await instance.scream('Hello World!')).wait(); | ||
|
||
expect(await instance.echo()).to.equal('Hello World!'); | ||
}); | ||
|
||
it('should emit a NewEcho event', async () => { | ||
const tx = await instance.scream('Hello World!'); | ||
await tx.wait(); | ||
|
||
await expect(tx) | ||
.to.emit(instance, 'NewEcho') | ||
.withArgs('Hello World!', 1); | ||
}); | ||
|
||
it('should increment echo counter in the NewEcho event', async () => { | ||
await (await instance.scream('Hello World!')).wait(); | ||
|
||
const tx = await instance.scream('Hello Goku!'); | ||
await tx.wait(); | ||
|
||
await expect(tx) | ||
.to.emit(instance, 'NewEcho') | ||
.withArgs('Hello Goku!', 2); | ||
}); | ||
|
||
it('should return input value', async () => { | ||
const response = await instance.scream.staticCall('Hello World!'); | ||
|
||
expect(response).to.equal('Hello World!'); | ||
}); | ||
}); | ||
}); |
File renamed without changes.
Oops, something went wrong.