Skip to content

Commit

Permalink
feat: (#39) Add evm contracts
Browse files Browse the repository at this point in the history
  • Loading branch information
OT-kraftchain committed Dec 4, 2024
1 parent 54965f8 commit 778778d
Show file tree
Hide file tree
Showing 16 changed files with 16,173 additions and 3 deletions.
8 changes: 6 additions & 2 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,16 @@ jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
with:
submodules: 'recursive'
- name: Set up JDK 1.8
uses: actions/setup-java@v2
with:
distribution: temurin
java-version: '8'
cache: 'gradle'
- name: Install Foundry
uses: foundry-rs/foundry-toolchain@v1
- name: Unit Tests
run: ./gradlew --info --warning-mode=all clean test
run: ./gradlew --info --warning-mode=all clean test
8 changes: 7 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -176,4 +176,10 @@ gradle.properties
.java-version

*.deploy.properties
!dev.deploy.properties
!dev.deploy.properties

node_modules/
artifacts/
typechain-types/
cache/
cache_hardhat/
9 changes: 9 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
[submodule "lib/solmate"]
path = lib/solmate
url = https://github.com/transmissions11/solmate
[submodule "lib/forge-std"]
path = lib/forge-std
url = https://github.com/foundry-rs/forge-std
[submodule "lib/openzeppelin-contracts"]
path = lib/openzeppelin-contracts
url = https://github.com/OpenZeppelin/openzeppelin-contracts
23 changes: 23 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
plugins {
id 'java'
id 'io.neow3j.gradle-plugin' version '3.21.1'
id "com.github.node-gradle.node" version "7.1.0"
}

sourceCompatibility = JavaVersion.VERSION_1_8
Expand Down Expand Up @@ -38,6 +39,28 @@ tasks.withType(Test) {
useJUnitPlatform()
}

node {
version = '18.20.5'
download = true
}

//task compileSolidity(type: NpxTask) {
// dependsOn('npmInstall')
// command = 'hardhat'
// args = ['compile']
//}
task compileSolidity(type : Exec) {
dependsOn('npmInstall')
commandLine 'forge', 'compile'
}
compileJava.finalizedBy('compileSolidity')

task testSolidity(type : Exec) {
dependsOn('compileSolidity')
commandLine 'forge', 'test'
}
test.dependsOn('testSolidity')

neow3jCompile {
className = "com.axlabs.neo.grantshares.GrantSharesTreasury"
}
7 changes: 7 additions & 0 deletions foundry.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[profile.default]
src = 'src/main/solidity'
test = 'src/test/solidity'
out = 'artifacts'
libs = ['lib']

# See more config options https://github.com/foundry-rs/foundry/tree/master/config
52 changes: 52 additions & 0 deletions hardhat.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
import fs from "fs";
import "@nomiclabs/hardhat-waffle";
import "@typechain/hardhat";
import "hardhat-preprocessor";
import { HardhatUserConfig, task } from "hardhat/config";

import example from "./src/deploy/typescript/example";

function getRemappings() {
return fs
.readFileSync("remappings.txt", "utf8")
.split("\n")
.filter(Boolean)
.map((line) => line.trim().split("="));
}

task("example", "Example task").setAction(example);

const config: HardhatUserConfig = {
solidity: {
version: "0.8.13",
settings: {
optimizer: {
enabled: true,
runs: 200,
},
},
},
paths: {
sources: "./src/main/solidity", // Use ./src rather than ./contracts as Hardhat expects
cache: "./cache_hardhat", // Use a different cache for Hardhat than Foundry
},
// This fully resolves paths for imports in the ./lib directory for Hardhat
//@ts-ignore
preprocess: {
//@ts-ignore
eachLine: (hre) => ({
transform: (line: string) => {
if (line.match(/^\s*import /i)) {
getRemappings().forEach(([find, replace]) => {
if (line.match(find)) {
line = line.replace(find, replace);
}
});
}
return line;
},
}),
},
};

export default config;
1 change: 1 addition & 0 deletions lib/forge-std
Submodule forge-std added at 1eea5b
1 change: 1 addition & 0 deletions lib/openzeppelin-contracts
Submodule openzeppelin-contracts added at 69c8de
1 change: 1 addition & 0 deletions lib/solmate
Submodule solmate added at c93f77
Loading

0 comments on commit 778778d

Please sign in to comment.