-
Notifications
You must be signed in to change notification settings - Fork 201
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
refactor(evm): embeds #1984
Merged
Merged
refactor(evm): embeds #1984
Changes from 14 commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
3e486c5
chore: remove redundant JSON unmarshalling
k-yang 8b494d7
chore: remove HardhatOutput
k-yang e767345
chore: remove byte array pointer
k-yang 9a1979c
refactor(evm): remove SmartContractFixture
k-yang 22e0c96
refactor: privatize embed functions
k-yang 2f4966f
refactor: move contract files into subdirectory and recompile
k-yang 9ad2c97
chore: add TestERC20.sol
k-yang 7d5e6f3
test: move TestERC20 contract to embeds test
k-yang b90bd33
refactor: remove embeds FixtureType
k-yang 6c57e5d
fix: embed load function
k-yang 28499b2
refactor: remove HexString
k-yang b18a459
chore: remove parseCompiledJson
k-yang 5525454
test(evm): use TestERC20.sol in integration tests
k-yang 12b3e40
Update CHANGELOG.md
k-yang 944715c
Merge branch 'main' into refactor/evm/embeds
Unique-Divine f523ca9
Merge branch 'main' into refactor/evm/embeds
Unique-Divine e604bce
fix: small import merge conflict
Unique-Divine File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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 |
---|---|---|
@@ -1,13 +1,6 @@ | ||
# Sample Hardhat Project | ||
|
||
This project demonstrates a basic Hardhat use case. It comes with a sample contract, a test for that contract, and a Hardhat Ignition module that deploys that contract. | ||
|
||
Try running some of the following tasks: | ||
# Nibiru Contract Embeds | ||
|
||
```shell | ||
npx hardhat help | ||
npx hardhat test | ||
REPORT_GAS=true npx hardhat test | ||
npx hardhat node | ||
npx hardhat ignition deploy ./ignition/modules/Lock.js | ||
npm install | ||
npx hardhat compile | ||
``` |
12 changes: 6 additions & 6 deletions
12
x/evm/embeds/ERC20MinterCompiled.json → ...ontracts/ERC20Minter.sol/ERC20Minter.json
Large diffs are not rendered by default.
Oops, something went wrong.
File renamed without changes.
286 changes: 286 additions & 0 deletions
286
x/evm/embeds/artifacts/contracts/TestERC20.sol/TestERC20.json
Large diffs are not rendered by default.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
2 changes: 1 addition & 1 deletion
2
x/evm/embeds/ERC20Minter.sol → x/evm/embeds/contracts/ERC20Minter.sol
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
File renamed without changes.
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,16 @@ | ||
// contracts/TestERC20.sol | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity ^0.8.24; | ||
|
||
import { ERC20 } from "@openzeppelin/contracts/token/ERC20/ERC20.sol"; | ||
|
||
contract TestERC20 is ERC20 { | ||
|
||
// Define the supply of TestERC20: 1,000,000 | ||
uint256 constant initialSupply = 1000000 * (10**18); | ||
|
||
// Constructor will be called on contract creation | ||
constructor() ERC20("TestERC20", "FOO") { | ||
_mint(msg.sender, initialSupply); | ||
} | ||
} |
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 |
---|---|---|
@@ -1,22 +1,18 @@ | ||
package embeds_test | ||
|
||
import ( | ||
_ "embed" | ||
"testing" | ||
|
||
"github.com/stretchr/testify/assert" | ||
"github.com/stretchr/testify/require" | ||
|
||
"github.com/NibiruChain/nibiru/x/evm/embeds" | ||
) | ||
|
||
func TestLoadContracts(t *testing.T) { | ||
for _, tc := range []embeds.SmartContractFixture{ | ||
embeds.SmartContract_TestERC20, | ||
embeds.SmartContract_ERC20Minter, | ||
embeds.SmartContract_FunToken, | ||
} { | ||
t.Run(tc.Name, func(t *testing.T) { | ||
_, err := tc.Load() | ||
assert.NoError(t, err) | ||
}) | ||
} | ||
require.NotPanics(t, func() { | ||
embeds.SmartContract_ERC20Minter.MustLoad() | ||
embeds.SmartContract_FunToken.MustLoad() | ||
embeds.SmartContract_TestERC20.MustLoad() | ||
}) | ||
} |
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
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reintroduce error handling for contract data initialization.
Removing the error handling for
contractData
initialization can lead to potential issues if the contract data fails to load correctly. Ensure that the contract data is valid before it is used in subsequent tests.Committable suggestion