Skip to content

Commit

Permalink
feat(experimental): invoker instances (#2171)
Browse files Browse the repository at this point in the history
* wip

* wip: getInvoker abstraction

* wip: self invoke

* fix: test

* ci

* up

* wip

* wip

* wip

* wip: docs

* wip: docs

* wip: up docker

* chore: remove changeset

* wip: docs

* wip: exports

* lockfile

* tests: update

* chore: format

* Create smart-suns-fail.md

---------

Co-authored-by: jxom <jxom@users.noreply.github.com>
  • Loading branch information
jxom and jxom committed May 2, 2024
1 parent dfa9d7f commit 6311259
Show file tree
Hide file tree
Showing 34 changed files with 1,802 additions and 59 deletions.
5 changes: 5 additions & 0 deletions .changeset/smart-suns-fail.md
@@ -0,0 +1,5 @@
---
"viem": patch
---

**Experimental:** Added EIP-3074 Invoker Instances API.
6 changes: 5 additions & 1 deletion .github/actions/install-dependencies/action.yml
Expand Up @@ -14,9 +14,13 @@ runs:
with:
node-version: 21

- name: Set up foundry
- name: Set up Foundry
uses: foundry-rs/foundry-toolchain@v1

# TODO(3074): Remove this when 3074 supported natively in Anvil.
- name: Set up Docker
uses: docker-practice/actions-setup-docker@master

- name: Install dependencies
shell: bash
run: bun install
2 changes: 2 additions & 0 deletions .github/workflows/pull-request.yml
Expand Up @@ -20,6 +20,8 @@ jobs:
steps:
- name: Clone repository
uses: actions/checkout@v4
with:
submodules: 'recursive'

- name: Install dependencies
uses: ./.github/actions/install-dependencies
Expand Down
14 changes: 14 additions & 0 deletions .github/workflows/verify.yml
Expand Up @@ -12,6 +12,8 @@ jobs:
steps:
- name: Clone repository
uses: actions/checkout@v4
with:
submodules: 'recursive'

- name: Install dependencies
uses: ./.github/actions/install-dependencies
Expand All @@ -36,6 +38,8 @@ jobs:
steps:
- name: Clone repository
uses: actions/checkout@v4
with:
submodules: 'recursive'

- name: Install dependencies
uses: ./.github/actions/install-dependencies
Expand All @@ -55,6 +59,8 @@ jobs:
steps:
- name: Clone repository
uses: actions/checkout@v4
with:
submodules: 'recursive'

- name: Install dependencies
uses: ./.github/actions/install-dependencies
Expand Down Expand Up @@ -86,6 +92,8 @@ jobs:
steps:
- name: Clone repository
uses: actions/checkout@v4
with:
submodules: 'recursive'

- name: Install dependencies
uses: ./.github/actions/install-dependencies
Expand Down Expand Up @@ -149,6 +157,8 @@ jobs:
steps:
- name: Clone repository
uses: actions/checkout@v4
with:
submodules: 'recursive'

- name: Set up Bun
if: ${{ matrix.runtime == 'bun' }}
Expand Down Expand Up @@ -184,6 +194,8 @@ jobs:
steps:
- name: Clone repository
uses: actions/checkout@v4
with:
submodules: 'recursive'

- name: Install dependencies
uses: ./.github/actions/install-dependencies
Expand All @@ -205,6 +217,8 @@ jobs:
steps:
- name: Clone repository
uses: actions/checkout@v4
with:
submodules: 'recursive'

- name: Install dependencies
uses: ./.github/actions/install-dependencies
Expand Down
3 changes: 3 additions & 0 deletions .gitmodules
@@ -1,3 +1,6 @@
[submodule "contracts/lib/forge-std"]
path = contracts/lib/forge-std
url = https://github.com/foundry-rs/forge-std
[submodule "test/invokers"]
path = test/invokers
url = git@github.com:anton-rs/3074-invokers.git
1 change: 1 addition & 0 deletions biome.json
Expand Up @@ -13,6 +13,7 @@
"cache",
"test/contracts",
"test/chains",
"test/invokers",
"test/kzg/*.json",
"test/kzg/*.txt",
"coverage",
Expand Down
Binary file modified bun.lockb
Binary file not shown.
7 changes: 4 additions & 3 deletions package.json
Expand Up @@ -14,14 +14,15 @@
"changeset:publish": "bun scripts/updateVersion.ts && bun run prepublishOnly && bun run build && changeset publish",
"changeset:version": "changeset version && bun install --lockfile-only && bun scripts/updateVersion.ts",
"clean": "rimraf src/_esm src/_cjs src/_types",
"contracts:build": "forge build --config-path ./test/foundry.toml && bun ./scripts/generateTypedArtifacts.ts",
"contracts:build": "forge build --config-path ./test/foundry.toml && bun run contracts:build:invoker && bun ./scripts/generateTypedArtifacts.ts",
"contracts:build:invoker": "cd test/invokers && docker run --rm -v $(pwd):/app/foundry -u $(id -u):$(id -g) ghcr.io/paradigmxyz/foundry-alphanet:latest --foundry-directory /app/foundry --foundry-command 'forge build'",
"docs:dev": "cd site && bun run dev",
"docs:build": "cd site && bun run build",
"docs:preview": "cd site && bun run preview",
"format": "biome format . --write",
"lint": "biome check .",
"lint:fix": "bun run lint --apply",
"postinstall": "bun run contracts:build",
"postinstall": "git submodule init && git submodule update --recursive && bun run contracts:build",
"prepare": "bun x simple-git-hooks",
"prepublishOnly": "bun scripts/prepublishOnly.ts",
"size": "size-limit",
Expand Down Expand Up @@ -50,7 +51,7 @@
"@ethereumjs/rlp": "^5.0.0",
"@size-limit/preset-big-lib": "^11.1.2",
"@types/fs-extra": "^9.0.13",
"@viem/anvil": "0.0.5",
"@viem/anvil": "0.0.10",
"@vitest/coverage-v8": "^1.0.4",
"@vitest/ui": "^1.0.4",
"bun-types": "^1.0.1",
Expand Down
33 changes: 20 additions & 13 deletions scripts/generateTypedArtifacts.ts
Expand Up @@ -9,20 +9,27 @@ const writer = generated.writer()

const paths = await globby([
join(import.meta.dir, '../test/contracts/out/**/*.json'),
join(import.meta.dir, '../test/invokers/out/**/*.json'),
])

await Promise.all(
paths.map(async (path) => {
const fileName = path.split('/').pop()?.replace('.json', '')
const json = await Bun.file(path, { type: 'application/json' }).json()
writer.write(
`export const ${fileName} = ${JSON.stringify(
json,
null,
2,
)} as const;\n\n`,
)
}),
)
const fileNames = []

for (const path of paths) {
const fileName = path.split('/').pop()?.replace('.json', '')
if (fileNames.includes(fileName)) continue

const { abi, bytecode } = await Bun.file(path, {
type: 'application/json',
}).json()
fileNames.push(fileName)

writer.write(
`export const ${fileName} = ${JSON.stringify(
{ abi, bytecode },
null,
2,
)} as const;\n\n`,
)
}

writer.end()

0 comments on commit 6311259

Please sign in to comment.