Skip to content

Commit 5f06e29

Browse files
authored
Merge pull request #51 from axieinfinity/release/v0.1.2
chore: merge all features from 'release/v0.1.2'
2 parents f177e3b + a8d8ba0 commit 5f06e29

20 files changed

+548
-41
lines changed
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
name: Create PR Deploy to Release
2+
3+
on:
4+
push:
5+
branches:
6+
- deploy/*
7+
pull_request:
8+
branches:
9+
- deploy/*
10+
11+
env:
12+
HEAD_BRANCH: ${{ github.head_ref || github.ref_name }}
13+
14+
permissions:
15+
contents: write
16+
pull-requests: write
17+
18+
jobs:
19+
build:
20+
runs-on: ubuntu-latest
21+
steps:
22+
- name: Set Env
23+
run: |
24+
echo "PR_BRANCH=merge/${HEAD_BRANCH}" >> $GITHUB_ENV
25+
echo "VERSION=$(echo -n ${{ env.HEAD_BRANCH }} | sed 's/.*deploy\///' | cut -d'-' -f1)" >> $GITHUB_ENV
26+
echo "NETWORK=$(echo -n ${{ env.HEAD_BRANCH }} | sed 's/.*deploy\/v[0-9\.]*-\(.*\)/\1/')" >> $GITHUB_ENV
27+
- name: Checkout code
28+
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
29+
with:
30+
ref: 'release/${{ env.VERSION }}'
31+
fetch-depth: 0
32+
fetch-tags: 'true'
33+
34+
- name: Get Testnet Latest Tag
35+
if: ${{ env.NETWORK == 'testnet' }}
36+
run: |
37+
echo "LATESTTAG=$(git describe --tags --match "*testnet*" --abbrev=0)" >> $GITHUB_ENV
38+
39+
- name: Get Mainnet Latest Tag
40+
if: ${{ env.NETWORK == 'mainnet' }}
41+
run: |
42+
echo "LATESTTAG=$(git describe --tags --match "*mainnet*" --abbrev=0)" >> $GITHUB_ENV
43+
44+
- name: Reset promotion branch
45+
run: |
46+
git fetch origin ${HEAD_BRANCH}:${HEAD_BRANCH}
47+
git reset --hard ${HEAD_BRANCH}
48+
49+
- name: Generate Release note
50+
id: template
51+
run: |
52+
echo "VERSION=${{ env.VERSION }} - SHA: ${{ github.sha }}" > CHANGELOG.md
53+
54+
- name: Create Pull Request
55+
id: cpr
56+
uses: peter-evans/[email protected]
57+
with:
58+
labels: automated PR
59+
delete-branch: true
60+
title: 'chore(`release/${{ env.VERSION }}`): merge from `${{ env.HEAD_BRANCH}}`'
61+
body: ${{ steps.template.outputs.result }}
62+
branch: ${{ env.PR_BRANCH }}

.github/workflows/create-PR-implement.yml renamed to .github/workflows/create-PR-implement-to-feature.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ jobs:
4141
toBranch: ${{ env.FEATURE_BRANCH }}
4242
4343
- name: Create Pull Request
44-
uses: peter-evans/create-pull-request@v5
44+
uses: peter-evans/create-pull-request@v6.0.1
4545
with:
4646
branch: ${{ env.HEAD_BRANCH }}
4747
base: ${{env.FEATURE_BRANCH}}

.github/workflows/create-PR-release.yml renamed to .github/workflows/create-PR-release-to-feature.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ jobs:
7575
toBranch: ${{matrix.branch_name}}
7676
7777
- name: Create Pull Request
78-
uses: peter-evans/create-pull-request@v5
78+
uses: peter-evans/create-pull-request@v6.0.1
7979
with:
8080
labels: automated PR
8181
delete-branch: true
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
name: Create PR from release to network
2+
3+
on:
4+
pull_request:
5+
branches:
6+
- release/*
7+
types:
8+
- closed
9+
10+
permissions:
11+
contents: write
12+
pull-requests: write
13+
14+
env:
15+
HEAD_BRANCH: ${{ github.head_ref || github.ref_name }}
16+
RELEASE_BRANCH: ${{ github.event.pull_request.base.ref}}
17+
18+
jobs:
19+
merge-release-to-network:
20+
runs-on: ubuntu-latest
21+
if: ${{ (github.event.pull_request.merged == true) && (contains(github.head_ref, 'deploy') || contains(github.ref_name, 'deploy')) }}
22+
steps:
23+
- name: Set Env
24+
run: |
25+
echo "PR_BRANCH=merge/${HEAD_BRANCH}" >> $GITHUB_ENV
26+
echo "VERSION=$(echo -n ${{ env.HEAD_BRANCH }} | sed 's/.*deploy\///' | cut -d'-' -f1)" >> $GITHUB_ENV
27+
echo "NETWORK=$(echo -n ${{ env.HEAD_BRANCH }} | sed 's/.*deploy\/v[0-9\.]*-\(.*\)/\1/')" >> $GITHUB_ENV
28+
29+
- name: Checkout code
30+
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
31+
with:
32+
ref: ${{ env.NETWORK }}
33+
34+
- name: Reset promotion branch
35+
run: |
36+
git fetch origin ${RELEASE_BRANCH}:${RELEASE_BRANCH}
37+
git reset --hard ${RELEASE_BRANCH}
38+
39+
- name: Create Pull Request
40+
id: cpr
41+
uses: peter-evans/[email protected]
42+
with:
43+
labels: automated PR
44+
delete-branch: true
45+
title: 'chore(`${{ env.NETWORK }}`): merge from `${{ env.HEAD_BRANCH}}`'
46+
body: ${{ steps.template.outputs.result }}
47+
branch: ${{env.PR_BRANCH}}
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
name: Create Release Tag
2+
3+
on:
4+
pull_request:
5+
types: [closed]
6+
branches:
7+
- mainnet
8+
- testnet
9+
10+
env:
11+
HEAD_BRANCH: ${{ github.head_ref || github.ref_name }}
12+
13+
permissions:
14+
contents: write
15+
pull-requests: write
16+
17+
jobs:
18+
create-release-tag:
19+
runs-on: ubuntu-latest
20+
if: github.event.pull_request.merged == true
21+
steps:
22+
- name: Set Env
23+
run: |
24+
echo "VERSION=$(echo -n ${{ env.HEAD_BRANCH }} | sed 's/.*deploy\///' | cut -d'-' -f1)" >> $GITHUB_ENV
25+
echo "NETWORK=$(echo -n ${{ env.HEAD_BRANCH }} | sed 's/.*deploy\/v[0-9\.]*-\(.*\)/\1/')" >> $GITHUB_ENV
26+
27+
- name: Checkout code
28+
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
29+
with:
30+
ref: ${{ env.NETWORK }}
31+
fetch-depth: 0
32+
fetch-tags: 'true'
33+
34+
- name: Set Mainnet Tag
35+
if: ${{ env.NETWORK == 'mainnet' }}
36+
run: |
37+
echo "TAG=${{ env.VERSION }}" >> $GITHUB_ENV
38+
39+
- name: Set Testnet Tag
40+
if: ${{ env.NETWORK == 'testnet' }}
41+
run: |
42+
echo "TAG=${{ env.VERSION }}-testnet" >> $GITHUB_ENV
43+
44+
- name: Get Testnet Latest Tag
45+
if: ${{ env.NETWORK == 'testnet' }}
46+
run: |
47+
echo "LATESTTAG=$(git describe --tags --match "*testnet*" --abbrev=0)" >> $GITHUB_ENV
48+
49+
- name: Get Mainnet Latest Tag
50+
if: ${{ env.NETWORK == 'mainnet' }}
51+
run: |
52+
echo "LATESTTAG=$(git describe --tags --match "*mainnet*" --abbrev=0)" >> $GITHUB_ENV
53+
54+
- name: Create release
55+
env:
56+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
57+
tag: ${{ env.TAG }}
58+
run: |
59+
gh release create "$tag" \
60+
--repo "$GITHUB_REPOSITORY" \
61+
--title "${{ env.NETWORK }} release ${{ env.VERSION }}" \
62+
--target "${{ env.NETWORK }}" \
63+
--notes-start-tag "${{ env.LATESTTAG }}" \
64+
--generate-notes

.gitmodules

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
[submodule "lib/forge-std"]
22
path = lib/forge-std
33
url = https://github.com/foundry-rs/forge-std
4+
shallow = true
45
[submodule "lib/openzeppelin-contracts"]
56
path = lib/openzeppelin-contracts
67
url = https://github.com/OpenZeppelin/openzeppelin-contracts
8+
[submodule "lib/lib/openzeppelin-contracts"]
9+
shallow = true

.husky/generate-layout.sh

100644100755
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@
33
rm -rf logs/storage/*
44
dirOutputs=$(ls out | grep '^[^.]*\.sol$') # assuming the out dir is at 'out'
55
while IFS= read -r contractDir; do
6-
innerdirOutputs=$(ls out/$contractDir)
6+
innerdirOutputs=$(ls out/"$contractDir")
77

88
while IFS= read -r jsonFile; do
9-
fileIn=out/$contractDir/$jsonFile
10-
fileOut=logs/storage/$contractDir:${jsonFile%.json}.log
11-
node .husky/storage-logger.js $fileIn $fileOut &
9+
fileIn=out/"$contractDir"/$jsonFile
10+
fileOut=logs/storage/"$contractDir":${jsonFile%.json}.log
11+
node .husky/storage-logger.js "$fileIn" "$fileOut" &
1212
done <<< "$innerdirOutputs"
1313
done <<< "$dirOutputs"
1414

.husky/pre-push

100644100755
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ forge build --sizes 2>&1 | sed -n '/Contract/,$p' > logs/contract-code-sizes.log
1616
git add logs
1717

1818
output=$(git status -s)
19-
line_count=$(echo "$output" | wc -l)
20-
if [ "$line_count" -gt 1 ]; then
19+
word_count=$(echo "$output" | wc -w)
20+
if [ "$word_count" -gt 0 ]; then
2121
git commit -m "chore: storage layout"
2222
fi
2323

.husky/storage-logger.js

Lines changed: 36 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -3,44 +3,49 @@ const fileIn = process.argv[2];
33
const fileOut = process.argv[3];
44

55
if (!fileIn) {
6-
console.error('Invalid input');
6+
console.error('Invalid input');
77
}
88

99
fs.readFile(fileIn, 'utf8', (err, data) => {
10-
if (err) {
11-
console.error('Error reading file:', err);
12-
return;
10+
if (err) {
11+
console.error('Error reading file:', err);
12+
return;
13+
}
14+
15+
try {
16+
const jsonData = JSON.parse(data);
17+
if (typeof jsonData.storageLayout == 'undefined' || jsonData.ast.absolutePath == 'undefined') {
18+
return;
1319
}
1420

15-
try {
16-
const jsonData = JSON.parse(data);
17-
if (typeof jsonData.storageLayout == 'undefined') {
18-
return;
19-
}
21+
if (jsonData.storageLayout.storage.length == 0) {
22+
return;
23+
}
2024

21-
if (jsonData.storageLayout.storage.length == 0) {
22-
return;
23-
}
25+
// Skip generating storage layout for files locate in the directory "src"
26+
if (!jsonData.ast.absolutePath.startsWith('src')) {
27+
return;
28+
}
2429

25-
const outputData = jsonData.storageLayout.storage
26-
.map(({ contract, label, offset, slot, type: typeId }) => {
27-
const typeObj = jsonData.storageLayout.types[typeId];
28-
const typeLabel = typeObj.label;
29-
const numberOfBytes = typeObj.numberOfBytes;
30-
return `${contract}:${label} (storage_slot: ${slot}) (offset: ${offset}) (type: ${typeLabel}) (numberOfBytes: ${numberOfBytes})`;
31-
})
32-
.join('\n');
33-
if (!fileOut) {
34-
console.log(outputData);
35-
} else {
36-
fs.writeFile(fileOut, outputData, 'utf-8', err => {
37-
if (err) {
38-
console.error('Error writing file:', err);
39-
return;
40-
}
41-
});
30+
const outputData = jsonData.storageLayout.storage
31+
.map(({ contract, label, offset, slot, type: typeId }) => {
32+
const typeObj = jsonData.storageLayout.types[typeId];
33+
const typeLabel = typeObj.label;
34+
const numberOfBytes = typeObj.numberOfBytes;
35+
return `${contract}:${label} (storage_slot: ${slot}) (offset: ${offset}) (type: ${typeLabel}) (numberOfBytes: ${numberOfBytes})`;
36+
})
37+
.join('\n');
38+
if (!fileOut) {
39+
console.log(outputData);
40+
} else {
41+
fs.writeFile(fileOut, outputData, 'utf-8', err => {
42+
if (err) {
43+
console.error('Error writing file:', err);
44+
return;
4245
}
43-
} catch (err) {
44-
console.error('Error parsing JSON:', err);
46+
});
4547
}
48+
} catch (err) {
49+
console.error('Error parsing JSON:', err);
50+
}
4651
});

0 commit comments

Comments
 (0)