-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
21 changed files
with
343 additions
and
96 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 |
---|---|---|
@@ -0,0 +1,2 @@ | ||
### Description | ||
PR to merge from [{{ .fromBranch }}](/axieinfinity/smart-contracts-core/tree/{{ .fromBranch }}) to [{{ .toBranch }}](/axieinfinity/smart-contracts-core/tree/{{ .toBranch }}). |
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,50 @@ | ||
name: Create Pull Request From Implement To Feature | ||
on: | ||
push: | ||
branches: | ||
- 'implement-feature/**' | ||
- 'implement-feature/**/**' | ||
|
||
concurrency: | ||
group: ${{ github.workflow }}-${{ github.ref || github.run_id }} | ||
cancel-in-progress: true | ||
|
||
env: | ||
HEAD_BRANCH: ${{ github.head_ref || github.ref_name }} | ||
|
||
jobs: | ||
createPullRequest: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Set env | ||
run: | | ||
echo "FEATURE_NAME=$(echo ${HEAD_BRANCH} | cut -d'/' -f2)" >> $GITHUB_ENV | ||
echo "FEATURE_BRANCH=feature/$(echo ${HEAD_BRANCH} | cut -d'/' -f2)" >> $GITHUB_ENV | ||
echo "IMPLEMENT_NAME=$(echo ${HEAD_BRANCH} | cut -d'/' -f3)" >> $GITHUB_ENV | ||
- uses: actions/checkout@v3 | ||
with: | ||
ref: ${{env.FEATURE_BRANCH}} | ||
|
||
- name: Reset promotion branch | ||
run: | | ||
git fetch origin ${HEAD_BRANCH}:${HEAD_BRANCH} | ||
git reset --hard ${HEAD_BRANCH} | ||
- name: Render template | ||
id: template | ||
uses: chuhlomin/[email protected] | ||
with: | ||
template: .github/template/create-pull-request.md | ||
vars: | | ||
fromBranch: ${{env.HEAD_BRANCH}} | ||
toBranch: ${{ env.FEATURE_BRANCH }} | ||
- name: Create Pull Request | ||
uses: peter-evans/create-pull-request@v5 | ||
with: | ||
branch: ${{ env.HEAD_BRANCH }} | ||
base: ${{env.FEATURE_BRANCH}} | ||
labels: automated PR | ||
title: 'feat(${{env.FEATURE_NAME}}): implement `${{env.IMPLEMENT_NAME}}`' | ||
body: ${{ steps.template.outputs.result }} |
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,84 @@ | ||
name: Create Pull Request From Release to Feature | ||
on: | ||
push: | ||
branches: | ||
- 'release/*' | ||
- 'release*/*' | ||
|
||
concurrency: | ||
group: ${{ github.workflow }}-${{ github.ref || github.run_id }} | ||
cancel-in-progress: true | ||
|
||
env: | ||
HEAD_BRANCH: ${{ github.head_ref || github.ref_name }} | ||
|
||
jobs: | ||
fetchAllFeatureBranches: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- id: step1 | ||
name: Checkout code | ||
uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 | ||
|
||
- id: step2 | ||
name: List all the remote feature branches | ||
run: | | ||
branches=$(git branch -r | grep -E '.*origin\/feature\/.*' | sed -e "s/.*origin\///" | tr "\n" " ") | ||
JSON="[" | ||
for branch in ${branches[@]}; do | ||
echo $branch | ||
JSONline="\"$branch\"," | ||
# we don't need to iterate on the same branch over and over, so | ||
# onnly include it when it wasn't included | ||
if [[ "$JSON" != *"$JSONline"* ]]; then | ||
JSON="$JSON$JSONline" | ||
fi | ||
done | ||
# Remove last "," and add the closing bracket | ||
if [[ $JSON == *, ]]; then | ||
JSON="${JSON%?}" | ||
fi | ||
JSON="$JSON]" | ||
echo $JSON | ||
echo "BRANCHES={\"branch_name\": $( echo "$JSON" )}" >> "$GITHUB_OUTPUT" | ||
outputs: | ||
BRANCHES: ${{ steps.step2.outputs.BRANCHES }} | ||
|
||
mergeRelease2FeatureRepo: | ||
runs-on: ubuntu-latest | ||
needs: fetchAllFeatureBranches | ||
strategy: | ||
matrix: ${{ fromJSON(needs.fetchAllFeatureBranches.outputs.BRANCHES) }} | ||
steps: | ||
- name: Set env | ||
run: | | ||
echo "PR_BRANCH=merge/${HEAD_BRANCH}-${{matrix.branch_name}}" >> $GITHUB_ENV | ||
echo "FEATURE_NAME=$(echo ${{matrix.branch_name}} | cut -d'/' -f2)" >> $GITHUB_ENV | ||
- uses: actions/checkout@v3 | ||
with: | ||
ref: ${{matrix.branch_name}} | ||
- name: Reset promotion branch | ||
run: | | ||
git fetch origin ${HEAD_BRANCH}:${HEAD_BRANCH} | ||
git reset --hard ${HEAD_BRANCH} | ||
- name: Render template | ||
id: template | ||
uses: chuhlomin/[email protected] | ||
with: | ||
template: .github/template/create-pull-request.md | ||
vars: | | ||
fromBranch: ${{env.HEAD_BRANCH}} | ||
toBranch: ${{matrix.branch_name}} | ||
- name: Create Pull Request | ||
uses: peter-evans/create-pull-request@v5 | ||
with: | ||
labels: automated PR | ||
delete-branch: true | ||
title: 'chore(`${{env.FEATURE_NAME}}`): merge from `${{env.HEAD_BRANCH}}`' | ||
body: ${{ steps.template.outputs.result }} | ||
branch: ${{env.PR_BRANCH}} |
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 |
---|---|---|
|
@@ -12,3 +12,5 @@ docs/ | |
|
||
# Dotenv file | ||
.env | ||
node_modules | ||
.yarn |
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 @@ | ||
_ |
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 @@ | ||
#!/bin/sh | ||
|
||
rm -rf logs/storage/* | ||
dirOutputs=$(ls out | grep '^[^.]*\.sol$') # assuming the out dir is at 'out' | ||
while IFS= read -r contractDir; do | ||
innerdirOutputs=$(ls out/$contractDir) | ||
|
||
while IFS= read -r jsonFile; do | ||
fileIn=out/$contractDir/$jsonFile | ||
fileOut=logs/storage/$contractDir:${jsonFile%.json}.log | ||
node .husky/storage-logger.js $fileIn $fileOut & | ||
done <<< "$innerdirOutputs" | ||
done <<< "$dirOutputs" | ||
|
||
# Wait for all background jobs to finish | ||
wait |
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,5 @@ | ||
#!/usr/bin/env sh | ||
. "$(dirname -- "$0")/_/husky.sh" | ||
|
||
forge build | ||
npx lint-staged |
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,26 @@ | ||
#!/bin/sh | ||
. "$(dirname "$0")/_/husky.sh" | ||
|
||
set -ex | ||
|
||
# Workaround: git stash no changes doesn't cause failure but git stash pop cause | ||
output=$(git stash) | ||
stashed=true | ||
if [[ $output == *"No local changes to save"* ]]; then | ||
stashed=false | ||
fi | ||
|
||
forge build --sizes 2>&1 | sed -n '/Contract/,$p' > logs/contract-code-sizes.log | ||
.husky/generate-layout.sh | ||
|
||
git add logs | ||
|
||
output=$(git status -s) | ||
line_count=$(echo "$output" | wc -l) | ||
if [ "$line_count" -gt 1 ]; then | ||
git commit -m "chore: storage layout" | ||
fi | ||
|
||
if $stashed; then | ||
git stash pop | ||
fi |
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,46 @@ | ||
const fs = require('fs'); | ||
const fileIn = process.argv[2]; | ||
const fileOut = process.argv[3]; | ||
|
||
if (!fileIn) { | ||
console.error('Invalid input'); | ||
} | ||
|
||
fs.readFile(fileIn, 'utf8', (err, data) => { | ||
if (err) { | ||
console.error('Error reading file:', err); | ||
return; | ||
} | ||
|
||
try { | ||
const jsonData = JSON.parse(data); | ||
if (typeof jsonData.storageLayout == 'undefined') { | ||
return; | ||
} | ||
|
||
if (jsonData.storageLayout.storage.length == 0) { | ||
return; | ||
} | ||
|
||
const outputData = jsonData.storageLayout.storage | ||
.map(({ contract, label, offset, slot, type: typeId }) => { | ||
const typeObj = jsonData.storageLayout.types[typeId]; | ||
const typeLabel = typeObj.label; | ||
const numberOfBytes = typeObj.numberOfBytes; | ||
return `${contract}:${label} (storage_slot: ${slot}) (offset: ${offset}) (type: ${typeLabel}) (numberOfBytes: ${numberOfBytes})`; | ||
}) | ||
.join('\n'); | ||
if (!fileOut) { | ||
console.log(outputData); | ||
} else { | ||
fs.writeFile(fileOut, outputData, 'utf-8', err => { | ||
if (err) { | ||
console.error('Error writing file:', err); | ||
return; | ||
} | ||
}); | ||
} | ||
} catch (err) { | ||
console.error('Error parsing JSON:', err); | ||
} | ||
}); |
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 @@ | ||
nodeLinker: node-modules |
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,66 +1,35 @@ | ||
## Foundry | ||
# smart-contracts-core | ||
|
||
**Foundry is a blazing fast, portable and modular toolkit for Ethereum application development written in Rust.** | ||
The collections of smart contracts that power the Axie Land Delegation. | ||
|
||
Foundry consists of: | ||
## Development | ||
|
||
- **Forge**: Ethereum testing framework (like Truffle, Hardhat and DappTools). | ||
- **Cast**: Swiss army knife for interacting with EVM smart contracts, sending transactions and getting chain data. | ||
- **Anvil**: Local Ethereum node, akin to Ganache, Hardhat Network. | ||
- **Chisel**: Fast, utilitarian, and verbose solidity REPL. | ||
### Requirement | ||
|
||
## Documentation | ||
- [Foundry forge@^0.2.0](https://book.getfoundry.sh/) | ||
|
||
https://book.getfoundry.sh/ | ||
### Build & Test | ||
|
||
## Usage | ||
|
||
### Build | ||
|
||
```shell | ||
$ forge build | ||
``` | ||
|
||
### Test | ||
|
||
```shell | ||
$ forge test | ||
``` | ||
|
||
### Format | ||
- Install packages | ||
|
||
```shell | ||
$ forge fmt | ||
$ forge install | ||
``` | ||
|
||
### Gas Snapshots | ||
- Build contracts | ||
|
||
```shell | ||
$ forge snapshot | ||
$ forge build | ||
``` | ||
|
||
### Anvil | ||
- Run test | ||
|
||
```shell | ||
$ anvil | ||
$ forge test | ||
``` | ||
|
||
### Deploy | ||
|
||
```shell | ||
$ forge script script/Counter.s.sol:CounterScript --rpc-url <your_rpc_url> --private-key <your_private_key> | ||
``` | ||
|
||
### Cast | ||
|
||
```shell | ||
$ cast <subcommand> | ||
``` | ||
|
||
### Help | ||
|
||
```shell | ||
$ forge --help | ||
$ anvil --help | ||
$ cast --help | ||
$ forge script <path/to/file.s.sol> -f --private-key <your_private_key> | ||
``` |
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
Empty file.
Empty file.
Oops, something went wrong.