Skip to content

Commit

Permalink
🦄 Setup CI (#2)
Browse files Browse the repository at this point in the history
  • Loading branch information
MiksuJak authored Apr 26, 2024
1 parent 023bc65 commit 551a57e
Show file tree
Hide file tree
Showing 6 changed files with 121 additions and 66 deletions.
34 changes: 34 additions & 0 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: 👷‍♂️ CI
on:
pull_request:
branches:
- main
push:
branches:
- main
jobs:
test:
name: Test
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
with:
clean: false

- name: Use pnpm
uses: pnpm/action-setup@v2
with:
version: 8.4.0

- name: Use Node.js
uses: actions/setup-node@v3
with:
node-version: 20.9.0
cache: 'pnpm'

- name: Install dependencies
run: pnpm install --frozen-lockfile

- name: Run CI Checks
run: pnpm run checks
24 changes: 24 additions & 0 deletions .github/workflows/PR.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: 🦄 PR Name
on:
pull_request:
types: [opened, edited, synchronize, reopened]
permissions:
pull-requests: read
jobs:
emoji:
name: Starts with emoji
runs-on: ubuntu-latest
steps:
- uses: deepakputhraya/action-pr-title@v1.0.2
with:
# Check if first character is an emoji, regex borrowed from https://medium.com/reactnative/emojis-in-javascript-f693d0eb79fb#.enomgcu63
regex: '^(?:[\u2700-\u27bf]|(?:\ud83c[\udde6-\uddff]){2}|[\ud800-\udbff][\udc00-\udfff]|[\u0023-\u0039]\ufe0f?\u20e3|\u3299|\u3297|\u303d|\u3030|\u24c2|\ud83c[\udd70-\udd71]|\ud83c[\udd7e-\udd7f]|\ud83c\udd8e|\ud83c[\udd91-\udd9a]|\ud83c[\udde6-\uddff]|[\ud83c[\ude01-\ude02]|\ud83c\ude1a|\ud83c\ude2f|[\ud83c[\ude32-\ude3a]|[\ud83c[\ude50-\ude51]|\u203c|\u2049|[\u25aa-\u25ab]|\u25b6|\u25c0|[\u25fb-\u25fe]|\u00a9|\u00ae|\u2122|\u2139|\ud83c\udc04|[\u2600-\u26FF]|\u2b05|\u2b06|\u2b07|\u2b1b|\u2b1c|\u2b50|\u2b55|\u231a|\u231b|\u2328|\u23cf|[\u23e9-\u23f3]|[\u23f8-\u23fa]|\ud83c\udccf|\u2934|\u2935|[\u2190-\u21ff])'
github_token: ${{ github.token }}
capitalised:
name: Starts with space and capital letter
runs-on: ubuntu-latest
steps:
- uses: deepakputhraya/action-pr-title@v1.0.2
with:
regex: '^[^a-zA-Z0-9\s]+ [A-Z]'
github_token: ${{ github.token }}
1 change: 1 addition & 0 deletions .nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
v20.9.0
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
"lint": "pnpm run -r lint",
"test": "pnpm run -r test",
"checks": "pnpm lint && pnpm test"
},
"keywords": [],
"author": "",
Expand Down
116 changes: 58 additions & 58 deletions packages/core/src/createDataForBytecode.ts
Original file line number Diff line number Diff line change
@@ -1,60 +1,60 @@
import { OpCodeBuilder } from "./OpCodeBuilder"
import { OpCodeBuilder } from './OpCodeBuilder'

export function createDataForBytecode(bytecode: string, callData: string) {
bytecode.startsWith('0x') ? (bytecode = bytecode.slice(2)) : bytecode
callData.startsWith('0x') ? (callData = callData.slice(2)) : callData
const dat = bytecode + callData
const opCodeBuilder = new OpCodeBuilder()
const callDataMemPos = bytecode.length / 2
opCodeBuilder
.pushBytesSizeToStack(dat)
.pushBytesSizeToStack(dat)
.addOpCode('CODESIZE')
.addOpCode('SUB')
.pushToStack('00')
.addOpCode('CODECOPY')
// retSize
.pushToStack('00')
// retOffset
.pushToStack('00')
// argsSize
.pushBytesSizeToStack(callData)
// argsOffset
.pushToStack(callDataMemPos)
// value
.pushToStack('00')
// size for create opcode
.pushBytesSizeToStack(bytecode)
// offset for create opcode
.pushToStack('00')
//value for create opcode
.pushToStack('00')
.addOpCode('CREATE')
.pushToStack('FF'.repeat(32))
.addOpCode('CALL')
// get return data size
.addOpCode('RETURNDATASIZE')
// dup return data size
.addOpCode('DUP1')
.pushToStack('00')
.pushToStack('00')
.addOpCode('RETURNDATACOPY')
.pushToStack('00')
.addOpCode('RETURN')
.addBytes(dat)
return opCodeBuilder.toString()
}
bytecode.startsWith('0x') ? (bytecode = bytecode.slice(2)) : bytecode
callData.startsWith('0x') ? (callData = callData.slice(2)) : callData

const dat = bytecode + callData

const opCodeBuilder = new OpCodeBuilder()

const callDataMemPos = bytecode.length / 2

opCodeBuilder
.pushBytesSizeToStack(dat)
.pushBytesSizeToStack(dat)
.addOpCode('CODESIZE')
.addOpCode('SUB')
.pushToStack('00')
.addOpCode('CODECOPY')
// retSize
.pushToStack('00')
// retOffset
.pushToStack('00')

// argsSize
.pushBytesSizeToStack(callData)

// argsOffset
.pushToStack(callDataMemPos)

// value
.pushToStack('00')

// size for create opcode
.pushBytesSizeToStack(bytecode)

// offset for create opcode
.pushToStack('00')

//value for create opcode
.pushToStack('00')
.addOpCode('CREATE')

.pushToStack('FF'.repeat(32))

.addOpCode('CALL')
// get return data size
.addOpCode('RETURNDATASIZE')
// dup return data size
.addOpCode('DUP1')

.pushToStack('00')
.pushToStack('00')
.addOpCode('RETURNDATACOPY')

.pushToStack('00')
.addOpCode('RETURN')
.addBytes(dat)
return opCodeBuilder.toString()
}
8 changes: 1 addition & 7 deletions packages/example-contracts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,8 @@
"version": "1.0.0",
"license": "MIT",
"scripts": {
"install": "forge install || git submodule update --init --recursive",
"build": "forge build",
"test": "forge test --no-match-contract ForkTest",
"test:fork": "forge test --match-contract ForkTest",
"lint:sol": "solhint '{contracts,test}/**/*.sol'",
"lint:fmt": "forge fmt --check",
"lint:fix": "forge fmt",
"lint": "pnpm lint:sol && pnpm lint:fmt"
"lint": "pnpm lint:sol"
},
"devDependencies": {
"solhint": "^4.5.2"
Expand Down

0 comments on commit 551a57e

Please sign in to comment.