Skip to content

Commit c01cb0f

Browse files
authored
Merge pull request #66 from BootNodeDev/typechain-build
Build for genarating types
2 parents b392772 + 4bfea23 commit c01cb0f

File tree

14 files changed

+3763
-1461
lines changed

14 files changed

+3763
-1461
lines changed

.changeset/README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# Changesets
2+
3+
Hello and welcome! This folder has been automatically generated by `@changesets/cli`, a build tool that works
4+
with multi-package repos, or single-package repos to help you version and publish your code. You can
5+
find the full documentation for it [in our repository](https://github.com/changesets/changesets)
6+
7+
We have a quick list of common questions to get you started engaging with this project in
8+
[our documentation](https://github.com/changesets/changesets/blob/main/docs/common-questions.md)

.changeset/config.json

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"$schema": "https://unpkg.com/@changesets/config@3.0.5/schema.json",
3+
"changelog": "@changesets/cli/changelog",
4+
"commit": false,
5+
"fixed": [],
6+
"linked": [],
7+
"access": "public",
8+
"baseBranch": "main",
9+
"updateInternalDependencies": "patch",
10+
"ignore": []
11+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
diff --git a/dist/codegen/createBarrelFiles.js b/dist/codegen/createBarrelFiles.js
2+
index 4bf574d7f6701bc5a8fcb2c281b5c63f31923e79..7f9cbdbd0491d4fa6338a10b23d06c2665c9d968 100644
3+
--- a/dist/codegen/createBarrelFiles.js
4+
+++ b/dist/codegen/createBarrelFiles.js
5+
@@ -38,15 +38,13 @@ function createBarrelFiles(paths, { typeOnly, postfix = '', moduleSuffix = '' })
6+
const namespacesExports = nestedDirs
7+
.map((p) => {
8+
const namespaceIdentifier = (0, normalizeDirName_1.normalizeDirName)(p);
9+
+ const fromFilePath = moduleSuffix ? `'./${p}/index${moduleSuffix}'` : `'./${p}'`
10+
if (typeOnly)
11+
return [
12+
- `import type * as ${namespaceIdentifier} from './${p}';`,
13+
+ `import type * as ${namespaceIdentifier} from ${fromFilePath};`,
14+
`export type { ${namespaceIdentifier} };`,
15+
].join('\n');
16+
- if (moduleSuffix) {
17+
- return `export * as ${namespaceIdentifier} from './${p}/index${moduleSuffix}';`;
18+
- }
19+
- return `export * as ${namespaceIdentifier} from './${p}';`;
20+
+ return `export * as ${namespaceIdentifier} from ${fromFilePath};`;
21+
})
22+
.join('\n');
23+
const contracts = (fileReexports[path] || []).sort();

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,12 @@ docker exec -it <container-id> pm2 reload all
6262

6363
For the versions available, see the tags on this repository.
6464

65+
### Releasing packages to NPM
66+
67+
We use [changesets](https://github.com/changesets/changesets) to release to NPM. You can use the `release` script in `package.json` to publish.
68+
69+
Currently the only workspace being released as an NPM package is the one in `solidity`, which contains the contracts and typechain artifacts.
70+
6571
### License
6672

6773
This project is licensed under the Apache 2.0 License - see the LICENSE.md file for details.

package.json

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
{
2-
"name": "intents-framework",
2+
"name": "@bootnodedev/intents-framework",
33
"version": "0.1.0",
44
"scripts": {
5-
"build:solver": "yarn workspace solver build"
5+
"build": "yarn workspaces foreach --all --parallel --topological run build",
6+
"build:solver": "yarn workspace solver build",
7+
"release": "yarn build && yarn changeset publish"
68
},
79
"repository": {
810
"type": "git",
@@ -19,5 +21,8 @@
1921
"typescript/solver",
2022
"solidity"
2123
],
22-
"packageManager": "yarn@4.5.1"
24+
"packageManager": "yarn@4.5.1",
25+
"devDependencies": {
26+
"@changesets/cli": "^2.27.12"
27+
}
2328
}

solidity/.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
# directories
22
cache
3+
cache_hardhat
4+
artifacts
5+
types
36
coverage
47
node_modules
58
out

solidity/exportBuildArtifact.sh

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
#!/bin/sh
2+
3+
# set script location as working directory
4+
cd "$(dirname "$0")"
5+
6+
# Define the artifacts directory
7+
artifactsDir="./artifacts/build-info"
8+
# Define the output file
9+
outputFileJson="./dist/buildArtifact.json"
10+
outputFileJs="./dist/buildArtifact.js"
11+
outputFileTsd="./dist/buildArtifact.d.ts"
12+
13+
# log that we're in the script
14+
echo 'Finding and processing hardhat build artifact...'
15+
16+
# Find most recently modified JSON build artifact
17+
if [ "$(uname)" = "Darwin" ]; then
18+
# for local flow
19+
jsonFiles=$(find "$artifactsDir" -type f -name "*.json" -exec stat -f "%m %N" {} \; | sort -rn | head -n 1 | cut -d' ' -f2-)
20+
else
21+
# for CI flow
22+
jsonFiles=$(find "$artifactsDir" -type f -name "*.json" -exec stat -c "%Y %n" {} \; | sort -rn | head -n 1 | cut -d' ' -f2-)
23+
fi
24+
25+
if [ ! -f "$jsonFiles" ]; then
26+
echo 'Failed to find build artifact'
27+
exit 1
28+
fi
29+
30+
# Extract required keys and write to outputFile
31+
if jq -c '{input, solcLongVersion}' "$jsonFiles" > "$outputFileJson"; then
32+
echo "export const buildArtifact = " > "$outputFileJs"
33+
cat "$outputFileJson" >> "$outputFileJs"
34+
echo "export const buildArtifact: any" > "$outputFileTsd"
35+
echo 'Finished processing build artifact.'
36+
else
37+
echo 'Failed to process build artifact with jq'
38+
exit 1
39+
fi

solidity/foundry.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@
1414
solc = "0.8.25"
1515
src = "src"
1616
test = "test"
17-
allow_paths = ["../node_modules"]
17+
allow_paths = ["node_modules"]
18+
libs = ['node_modules', '../node_modules']
1819

1920
[profile.ci]
2021
fuzz = { runs = 10_000 }

solidity/hardhat.config.cts

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import "@nomicfoundation/hardhat-foundry";
2+
import '@nomiclabs/hardhat-ethers';
3+
import '@typechain/hardhat';
4+
5+
/**
6+
* @type import('hardhat/config').HardhatUserConfig
7+
*/
8+
module.exports = {
9+
solidity: {
10+
version: '0.8.25',
11+
settings: {
12+
optimizer: {
13+
enabled: true,
14+
runs: 10_000,
15+
},
16+
},
17+
},
18+
typechain: {
19+
outDir: './types',
20+
target: 'ethers-v5',
21+
alwaysGenerateOverloads: true,
22+
node16Modules: true,
23+
},
24+
};

solidity/package.json

Lines changed: 38 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
2-
"name": "7683-router",
3-
"description": "A reference ERC7683 implementation",
4-
"version": "1.0.0",
2+
"name": "@bootnodedev/intents-framework-core",
3+
"description": "Core solidity contracts for the Intent Framework",
4+
"version": "0.1.0",
55
"author": {
66
"name": "BootNode"
77
},
@@ -12,15 +12,46 @@
1212
"dotenv-run-script": "^0.4.1"
1313
},
1414
"devDependencies": {
15+
"@nomicfoundation/hardhat-foundry": "^1.1.3",
16+
"@nomicfoundation/hardhat-toolbox": "^5.0.0",
17+
"@nomiclabs/hardhat-ethers": "^2.2.3",
18+
"@typechain/ethers-v5": "^11.1.2",
19+
"@typechain/ethers-v6": "^0.5.1",
20+
"@typechain/hardhat": "^9.1.0",
21+
"@types/node": "^22.10.7",
22+
"ethers": "^5.7.2",
1523
"forge-std": "github:foundry-rs/forge-std#v1.8.1",
24+
"hardhat": "^2.22.18",
1625
"prettier": "^3.0.0",
17-
"solhint": "^3.6.2"
26+
"solhint": "^3.6.2",
27+
"ts-generator": "^0.1.1",
28+
"ts-node": "^10.8.0",
29+
"tsx": "^4.19.1",
30+
"typechain": "patch:typechain@npm%3A8.3.2#~/.yarn/patches/typechain-npm-8.3.2-b02e27439e.patch",
31+
"typescript": "5.3.3"
1832
},
33+
"type": "module",
34+
"exports": {
35+
".": "./dist/index.js",
36+
"./mailbox": "./dist/contracts/Mailbox.js",
37+
"./buildArtifact.js": "./dist/buildArtifact.js",
38+
"./buildArtifact.json": "./dist/buildArtifact.json",
39+
"./contracts": "./contracts"
40+
},
41+
"types": "./dist/index.d.ts",
42+
"files": [
43+
"/dist",
44+
"/contracts"
45+
],
1946
"keywords": [],
20-
"private": true,
47+
"installConfig": {
48+
"hoistingLimits": "workspaces"
49+
},
2150
"scripts": {
22-
"clean": "rm -rf cache out && forge clean",
23-
"build": "forge build",
51+
"clean": "yarn hardhat-esm clean && rm -rf ./dist ./cache ./cache_hardhat ./types ./coverage ./out ./forge-cache ./fixtures && forge clean",
52+
"build": "yarn hardhat-esm compile && tsc && ./exportBuildArtifact.sh",
53+
"hardhat-esm": "NODE_OPTIONS='--experimental-loader ts-node/esm/transpile-only --no-warnings=ExperimentalWarning' hardhat --config hardhat.config.cts",
54+
"forge:build": "forge build",
2455
"lint": "yarn lint:sol && yarn prettier:check",
2556
"lint:sol": "forge fmt --check && solhint \"{script,src,test}/**/*.sol\"",
2657
"sol:fmt": "forge fmt",

0 commit comments

Comments
 (0)