Skip to content

Commit

Permalink
feat(target_chains/ethereum): add arbirum stylus sdk (#2041)
Browse files Browse the repository at this point in the history
* chore: init stylus project

* chore: added scripts

* chore: created workspace

* chore: docs setup

* chore: pyth contracts init

* chore: docs command setup

* mock: example project

* chore : created test workspace

* chore: changed toml  version

* chore: created  mock pyth  workspace

* chore: renamed project sdk

* chore: refactored files

* chore : helpers functions

* refacor : refactord code

* chore: removed struct type , implemented abstract_pyth

* chore: created storage price and storage price feed

* chore: integrating  storage price and storage price feed

* chore: fixed  error created by storage type

* chore: config changes

* chore: forge init

* forge install: forge-std

v1.9.3

* mock pyth : created mock solidity pyth contract

* chore: Renamed MockPyth Scripts

* chore: started testing

* chore: removed  projects

* feture :completed unit test and stylus contracts

* added initializtion for mock

* examples setup

* chore:fixed imports

* chore:fixed types

* completed contract

* External call and fution call sample

* chore: Changed motsu

* chore: Created Proxy call example

* feture: Example for both type of call

* chore: Added beches

* Lib Changes

* chore:Scripts modifications

* chore : fuction call and proxy call

* chore: added workflow

* chore: doc  pages docs

* chore: doc changes

* smaller chages

* chore: benches and toml changes

* chore: added foundry to e2e  workflow

* chore:set up benchmark

* Added Benches

* chore:added setup mock pyth script to bench and  e2e and logs

* changes

* feture: Added Proxy call to bench

* chore: Removed sol file

* Added deploy scripts

* chore: proxy calls

* chore: removed file

* changes

* chore:added constructor file and worked on bench

* chore: moved Ipyth to pyth-contract file

* chore: added variable to bash scripts

* chore:decode and encode helper

* chore: fixed mock pyth deploy script

* chore: removed dotenv crates

* chore: completed benches functions

* chore: examples and proxy call fixes

* changes

* chore: added create functions

* chore: completed get data benchmarks

* chore:contract changes

* chore:function calls

* chore: Ignore all broadcast

* chore: completed  get benches

* chore:changes

* chore: Added Type Test

* chore: tests

* env and examples

* Update README.md

* Update README.md

* Update README.md

* chore: worked on bench and e2e test

* removed log

* chore: completed e2e test for function call example

* chore : changed pyth script

* chore:completed e2e test

* chore:benches

* Update README.md

* Update README.md

* Update README.md

* Update README.md

* Update README.md

* chore: removed docs

* Update README.md

* Update README.md

* Update CODEOWNERS

* Delete target_chains/ethereum/sdk/stylus/SECURITY.md

* Delete target_chains/ethereum/sdk/stylus/lib/crypto directory

* Delete target_chains/ethereum/sdk/stylus/.linkspector.yml

* Delete target_chains/ethereum/sdk/stylus/netlify.toml

* Update Cargo.toml removed openzepline crypto

* Update README.md

* Delete target_chains/ethereum/sdk/stylus/pyth-solidity/.env.example

* Update gas-bench.yml

* chore:removed a bunch of openzeplin files

* chore: removed workflow

* chore:Added Guidlines

* chore: motsu  changes

* Create Test.md

* Update Test.md

* Rename Test.md to TEST.md

* Update README.md

* Update README.md

* Update README.md

* Delete target_chains/ethereum/sdk/stylus/TEST.md

* chore: removed mostu

* chore: changed Fixedbytes<32> to B256

* chore: removed local  e2e testing library

* chore: changes

* forge install: forge-std

v1.9.4

* forge install: openzeppelin-foundry-upgrades

v0.3.6

* forge install: openzeppelin-contracts

v4.9.6

* chore: formated code

* chore: fixed scripts

* Update target_chains/ethereum/sdk/stylus/README.md

Co-authored-by: Pavel Strakhov <[email protected]>

* Update target_chains/ethereum/sdk/stylus/README.md

Co-authored-by: Pavel Strakhov <[email protected]>

* chore: rustfmt changes

* chore: changed solidity licenses to  Apache 2

* chore: deleted codeowner file and link

* chore: removed comments

* solidity changes

* chore: removed folder

* chore: removed = for version

* forge install: forge-std

v1.9.4

* forge install: openzeppelin-foundry-upgrades

v0.3.6

* forge install: openzeppelin-contracts-upgradeable

v4.9.6

* chore: Remove MIT license

* chore: script changes

* chore: removed dependices

* forge install: forge-std

v1.9.4

* forge install: openzeppelin-foundry-upgrades

v0.3.6

* chore:added description to script

* Update target_chains/ethereum/sdk/stylus/README.md

Co-authored-by: Pavel Strakhov <[email protected]>

* Update target_chains/ethereum/sdk/stylus/README.md

Co-authored-by: Pavel Strakhov <[email protected]>

* Update target_chains/ethereum/sdk/stylus/contracts/src/pyth/mod.rs

Co-authored-by: Pavel Strakhov <[email protected]>

* Update target_chains/ethereum/sdk/stylus/contracts/src/pyth/errors.rs

Co-authored-by: Pavel Strakhov <[email protected]>

* chore: changed // to /// and remove licenses because of root licenese

* chore: Apache-2.0 license

* chore: renamed file name pyth-solidity to pyth-mock-solidity

* chore: removed commented code

* chore: foundry test workflow

* chore: workflows

* chore: changed readme to rust

* chore: fixed description  mock solidity

* chore: fixed zero case

* chore: change all use case of gt and lt to > and <

* chore: workflow

* chore: replaced the file with the link

* chore: refactor and removed unused code

* chore: renamed function for test

* chore: added some sort of path filters

* chore:  add cargo fmt and cargo clippy for  stylus sdk

* chore: package-json.lock moved depencies to pnpm-workspace.yaml

* chore:test attribute

* chore: git workflows

* chore:  removed functions example

* chore: switch for item in update_data

* chore: fixed example

* chore: refactor examples

* cargo changes

* chore: pyth example , and  function call example

* chore: added other example

* chore: install

* chore:installations

* chore: mock pyth

* chore: benches  and test

* smaller changes

* chore: mock

* chore: bench format

* chore: code format

* chore: code format

* chore: removed workflow

* chore: pnpm install

* chore: removed  package-lock.json

* chore: fixed commented out  job

* chore: ran  pre-commit run --all

* chore: pre-commit run --all

* chore:removed space

* Update .github/workflows/cli-foundry-test.yml

Co-authored-by: Pavel Strakhov <[email protected]>

* chore:removed space

chore: vec changes

* chore: data changes

* Update .github/workflows/cli-stylus-nostd.yml

Co-authored-by: Pavel Strakhov <[email protected]>

* Update .github/workflows/cli-stylus-gas-bench.yml

Co-authored-by: Pavel Strakhov <[email protected]>

* Update .github/workflows/cli-stylus-e2e-tests.yml

Co-authored-by: Pavel Strakhov <[email protected]>

* Update .github/workflows/cli-stylus-check.yml

Co-authored-by: Pavel Strakhov <[email protected]>

* Update .github/workflows/cli-stylus-check-wasm.yml

Co-authored-by: Pavel Strakhov <[email protected]>

* Update .github/workflows/cli-foundry-test.yml

Co-authored-by: Pavel Strakhov <[email protected]>

* Update .github/workflows/cli-stylus-e2e-tests.yml

Co-authored-by: Pavel Strakhov <[email protected]>

* Update .github/workflows/cli-stylus-check-wasm.yml

Co-authored-by: Pavel Strakhov <[email protected]>

* Update .github/workflows/cli-stylus-check.yml

Co-authored-by: Pavel Strakhov <[email protected]>

* Update .github/workflows/cli-stylus-nostd.yml

Co-authored-by: Pavel Strakhov <[email protected]>

* Update .github/workflows/cli-stylus-gas-bench.yml

Co-authored-by: Pavel Strakhov <[email protected]>

* chore: added back existing submodule

* chore: data changes

* cl fixes

* cli fixes

* chore: toolchain: nightly-2024-01-01

* chore: version changes

* toolchain

* removed typo workflow

* fixed rust issue

* changed rust version

* added foundry

* chore:  changes

* chore:bench fixes

* chore: changed cli workflow

* chore: format

* ci changes

* chore: added space

* precommit fixes

* added new line

* removed

* removed line

* chore: ci changes

* chore : changes

* changed ci script

* removed if statements for test

* chore: changes

* chore:fixes

* chore: fixes

* chore: fixes

* added evm file

* chore: checking key

* testing keys

* remove comand

* precommit fixes

* chore: removed workflow

* cl changes

* fmt

* fixed verion issue

---------

Co-authored-by: Pavel Strakhov <[email protected]>
  • Loading branch information
Ifechukwudaniel and Riateche authored Feb 7, 2025
1 parent 032f98f commit ee21688
Show file tree
Hide file tree
Showing 64 changed files with 7,851 additions and 0 deletions.
31 changes: 31 additions & 0 deletions .github/workflows/ci-foundry-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: stylus-foundry-test

on:
pull_request:
paths:
- target_chains/ethereum/sdk/stylus/**
push:
branches:
- main
paths:
- target_chains/ethereum/sdk/stylus/**
env:
FOUNDRY_PROFILE: ci
jobs:
check:
name: Foundry project
runs-on: ubuntu-latest
defaults:
run:
working-directory: target_chains/ethereum/sdk/stylus
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
submodules: recursive
- name: Install Foundry
uses: foundry-rs/foundry-toolchain@v1
with:
version: nightly
- name: Show Forge version
run: forge --version
40 changes: 40 additions & 0 deletions .github/workflows/ci-stylus-check-wasm.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: stylus-check-wasm
# This workflow checks that the compiled wasm binary of every example contract
# can be deployed to Arbitrum Stylus.
on:
pull_request:
paths:
- target_chains/ethereum/sdk/stylus/**
push:
branches:
- main
paths:
- target_chains/ethereum/sdk/stylus/**
permissions:
contents: read
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true
env:
CARGO_TERM_COLOR: always
jobs:
check-wasm:
name: Check WASM binary
runs-on: ubuntu-latest
defaults:
run:
working-directory: target_chains/ethereum/sdk/stylus
steps:
- uses: actions/checkout@v4
- name: Install rust
uses: actions-rust-lang/setup-rust-toolchain@v1
with:
rustflags: ""
- name: Install Foundry
uses: foundry-rs/foundry-toolchain@v1
with:
version: nightly
- name: Install cargo-stylus
run: cargo install [email protected]
- name: Run wasm check
run: ./scripts/check-wasm.sh
75 changes: 75 additions & 0 deletions .github/workflows/ci-stylus-check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
name: stylus-check
# This workflow runs whenever a PR is opened or updated, or a commit is pushed
# to main. It runs several checks:
# - fmt: checks that the code is formatted according to `rustfmt`.
# - clippy: checks that the code does not contain any `clippy` warnings.
# - doc: checks that the code can be documented without errors.
# - hack: check combinations of feature flags.
# - typos: checks for typos across the repo.
permissions:
contents: read
# This configuration allows maintainers of this repo to create a branch and
# pull request based on the new branch. Restricting the push trigger to the
# main branch ensures that the PR only gets built once.
on:
pull_request:
paths:
- target_chains/ethereum/sdk/stylus/**
push:
branches:
- main
paths:
- target_chains/ethereum/sdk/stylus/**
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true
env:
CARGO_TERM_COLOR: always
jobs:
fmt:
runs-on: ubuntu-latest
name: nightly / fmt
defaults:
run:
working-directory: target_chains/ethereum/sdk/stylus
steps:
- uses: actions/checkout@v4
with:
submodules: true

- name: Install rust
# We run in nightly to make use of some features only available there.
# Check out `rustfmt.toml` to see which ones.
uses: actions-rust-lang/setup-rust-toolchain@v1
with:
toolchain: nightly
components: rustfmt
rustflags: ""

- name: Check formatting
run: cargo fmt --all --check
clippy:
runs-on: ubuntu-latest
name: ${{ matrix.toolchain }} / clippy
defaults:
run:
working-directory: target_chains/ethereum/sdk/stylus
permissions:
contents: read
checks: write
strategy:
fail-fast: false
matrix:
# Get early warning of new lints which are regularly introduced in beta
# channels.
toolchain: [stable, beta]
steps:
- uses: actions/checkout@v4
with:
submodules: true
- name: Install rust ${{ matrix.toolchain }}
uses: actions-rust-lang/setup-rust-toolchain@v1
with:
toolchain: ${{ matrix.toolchain }}
components: clippy
rustflags: ""
43 changes: 43 additions & 0 deletions .github/workflows/ci-stylus-nostd.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# This workflow checks whether the library is able to run without the std
# library. See `check.yml` for information about how the concurrency
# cancellation and workflow triggering works.
name: stylus-no-std
permissions:
contents: read
on:
pull_request:
paths:
- target_chains/ethereum/sdk/stylus/**
push:
branches:
- main
paths:
- target_chains/ethereum/sdk/stylus/**
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true
env:
CARGO_TERM_COLOR: always
jobs:
nostd:
runs-on: ubuntu-latest
name: ${{ matrix.target }}
defaults:
run:
working-directory: target_chains/ethereum/sdk/stylus
strategy:
matrix:
target: [wasm32-unknown-unknown]
steps:
- uses: actions/checkout@v4
with:
submodules: true
- name: Install rust
uses: actions-rust-lang/setup-rust-toolchain@v1
with:
toolchain: stable
rustflags: ""
- name: Add rust targets ${{ matrix.target }}
run: rustup target add ${{ matrix.target }}
- name: Cargo check
run: cargo check --release --target ${{ matrix.target }} --no-default-features
18 changes: 18 additions & 0 deletions .github/workflows/publish-pythnet-stylus-sdk.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: Publish Pyth Stylus SDK to crates.io

on:
push:
tags:
- pythnet-stylus-sdk-v*
jobs:
publish-pythnet-stylus-sdk:
name: Publish Pythnet Stylus SDK
runs-on: ubuntu-latest
steps:
- name: Checkout sources
uses: actions/checkout@v2

- run: cargo publish --token ${CARGO_REGISTRY_TOKEN}
env:
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
working-directory: target_chains/ethereum/sdk/stylus
18 changes: 18 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,21 @@
[submodule "lazer/contracts/evm/lib/createx"]
path = lazer/contracts/evm/lib/createx
url = https://github.com/pcaversaccio/createx
[submodule "lib/forge-std"]
path = lib/forge-std
url = https://github.com/foundry-rs/forge-std
[submodule "lib/openzeppelin-foundry-upgrades"]
path = lib/openzeppelin-foundry-upgrades
url = https://github.com/OpenZeppelin/openzeppelin-foundry-upgrades
[submodule "lib/openzeppelin-contracts-upgradeable"]
path = lib/openzeppelin-contracts-upgradeable
url = https://github.com/OpenZeppelin/openzeppelin-contracts-upgradeable
[submodule "target_chains/ethereum/sdk/stylus/pyth-mock-solidity/lib/forge-std"]
path = target_chains/ethereum/sdk/stylus/pyth-mock-solidity/lib/forge-std
url = https://github.com/foundry-rs/forge-std
[submodule "target_chains/ethereum/sdk/stylus/pyth-mock-solidity/lib/openzeppelin-foundry-upgrades"]
path = target_chains/ethereum/sdk/stylus/pyth-mock-solidity/lib/openzeppelin-foundry-upgrades
url = https://github.com/OpenZeppelin/openzeppelin-foundry-upgrades
[submodule "target_chains/ethereum/sdk/stylus/pyth-mock-solidity/lib/openzeppelin-contracts-upgradeable"]
path = target_chains/ethereum/sdk/stylus/pyth-mock-solidity/lib/openzeppelin-contracts-upgradeable
url = https://github.com/OpenZeppelin/openzeppelin-contracts-upgradeable
12 changes: 12 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -139,3 +139,15 @@ repos:
entry: cargo +1.82.0 clippy --manifest-path ./lazer/Cargo.toml --all-targets -- --deny warnings
pass_filenames: false
files: lazer
- id: cargo-fmt-stylus-sdk
name: Cargo format for Stylus SDK
language: "rust"
entry: cargo +1.82.0 fmt --manifest-path ./target_chains/ethereum/sdk/stylus/Cargo.toml --all
pass_filenames: false
files: target_chains/ethereum/sdk/stylus
- id: cargo-clippy-stylus-sdk
name: Cargo clippy for Stylus SDK
language: "rust"
entry: cargo +1.82.0 clippy --manifest-path ./target_chains/ethereum/sdk/stylus/Cargo.toml --all-targets -- --deny warnings
pass_filenames: false
files: target_chains/ethereum/sdk/stylus
1 change: 1 addition & 0 deletions lib/forge-std
Submodule forge-std added at 1eea5b
1 change: 1 addition & 0 deletions lib/openzeppelin-contracts-upgradeable
1 change: 1 addition & 0 deletions lib/openzeppelin-foundry-upgrades
11 changes: 11 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions pnpm-workspace.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ packages:
- "target_chains/ethereum/entropy_sdk/solidity"
- "target_chains/ethereum/sdk/js"
- "target_chains/ethereum/sdk/solidity"
- "target_chains/ethereum/sdk/stylus/pyth-mock-solidity"
- "target_chains/ethereum/examples/coin_flip/app"
- "target_chains/fuel/sdk/js"
- "target_chains/starknet/sdk/js"
Expand All @@ -40,6 +41,7 @@ catalog:
"@cprussin/tsconfig": 3.0.1
"@next/third-parties": 15.0.2
"@phosphor-icons/react": 2.1.7
"@pythnetwork/pyth-sdk-solidity": 4.0.0
"@pythnetwork/client": 2.22.1
"@react-hookz/web": 24.0.4
"@solana/web3.js": 1.95.4
Expand Down
8 changes: 8 additions & 0 deletions target_chains/ethereum/sdk/stylus/.cargo/config.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[target.wasm32-unknown-unknown]
rustflags = ["-C", "link-arg=-zstack-size=8192", "-C", "target-cpu=mvp"]

[target.aarch64-apple-darwin]
rustflags = ["-C", "link-arg=-undefined", "-C", "link-arg=dynamic_lookup"]

[target.x86_64-apple-darwin]
rustflags = ["-C", "link-arg=-undefined", "-C", "link-arg=dynamic_lookup"]
11 changes: 11 additions & 0 deletions target_chains/ethereum/sdk/stylus/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/target

.env

**/node_modules/

docs/build/

**/.DS_Store

**/nitro-testnode
Loading

0 comments on commit ee21688

Please sign in to comment.