Skip to content

Commit

Permalink
Merge pull request #303 from oasisprotocol/CedarMist/client-refactor
Browse files Browse the repository at this point in the history
Add Viem v2 & Wagmi v2 packages, and remove Ethers dependency
  • Loading branch information
aefhm authored Jul 30, 2024
2 parents ff1b8f9 + d956ad7 commit 2f4ce26
Show file tree
Hide file tree
Showing 174 changed files with 17,366 additions and 13,720 deletions.
39 changes: 0 additions & 39 deletions .github/workflows/ci-lint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -123,42 +123,3 @@ jobs:
working-directory: ./clients/go
# Always run this step so that all linting errors can be seen at once.
if: always()

type-test-client-js:
name: type-test-client-js
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Install Node.js
uses: actions/setup-node@v4
with:
node-version: 18

- uses: pnpm/action-setup@v4
name: Install pnpm
id: pnpm-install
with:
version: 8
run_install: false

- name: Get pnpm store directory
id: pnpm-cache
run: |
echo "::set-output name=pnpm_cache_dir::$(pnpm store path)"
- uses: actions/cache@v4
name: Setup pnpm cache
with:
path: ${{ steps.pnpm-cache.outputs.pnpm_cache_dir }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-
- name: Install dependencies
run: pnpm --filter '@oasisprotocol/sapphire-paratime*' install

- name: Test type-only-test
run: pnpm test
working-directory: ./clients/js/type-only-test
165 changes: 2 additions & 163 deletions .github/workflows/ci-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -81,101 +81,11 @@ jobs:
version: 8
run_install: false

- name: Get pnpm store directory
id: pnpm-cache
shell: bash
run: |
echo "STORE_PATH=$(pnpm store path)" >> $GITHUB_OUTPUT
- uses: actions/cache@v4
name: Setup pnpm cache
with:
path: ${{ steps.pnpm-cache.outputs.STORE_PATH }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-
- name: Install dependencies
run: pnpm --filter @oasisprotocol/sapphire-paratime install

- name: Build JS client
run: pnpm build

- name: Build typedoc
run: pnpm typedoc

- name: Upload client-js build
uses: actions/upload-artifact@v4
with:
name: client-js
retention-days: 1
if-no-files-found: error
path: |
clients/js/lib
run: pnpm install

- name: Test JS client
env:
NODE_OPTIONS: "--no-experimental-fetch" # https://github.com/nock/nock/issues/2397
run: pnpm test

test-integration-hardhat:
name: test-integration-hardhat
runs-on: ubuntu-latest
needs: [test-client-js]
defaults:
run:
working-directory: ./integrations/hardhat
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Install Node.js
uses: actions/setup-node@v4
with:
node-version: 18

- uses: pnpm/action-setup@v4
name: Install pnpm
id: pnpm-install
with:
version: 8
run_install: false

- name: Get pnpm store directory
id: pnpm-cache
shell: bash
run: |
echo "STORE_PATH=$(pnpm store path)" >> $GITHUB_OUTPUT
- uses: actions/cache@v4
name: Setup pnpm cache
with:
path: ${{ steps.pnpm-cache.outputs.STORE_PATH }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-
- name: Download client-js build
uses: actions/download-artifact@v4
with:
name: client-js
path: clients/js/lib

- name: Install dependencies
run: |
pnpm install
- name: Build Integration Hardhat
run: pnpm build

- name: Upload integration-hardhat build
uses: actions/upload-artifact@v4
with:
name: integration-hardhat
retention-days: 1
if-no-files-found: error
path: |
integrations/hardhat/dist
run: pnpm test:unit

test-client-go:
name: test-client-go
Expand All @@ -193,74 +103,3 @@ jobs:

- name: Test
run: go test -v ./...

test-examples:
name: test-examples
runs-on: ubuntu-latest
needs: [test-client-js, test-integration-hardhat]
strategy:
matrix:
example: [hardhat, hardhat-boilerplate, onchain-signer]
defaults:
run:
working-directory: examples/${{ matrix.example }}
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Install Node.js
uses: actions/setup-node@v4
with:
node-version: 18

- uses: pnpm/action-setup@v4
name: Install pnpm
id: pnpm-install
with:
version: 8
run_install: false

- name: Get pnpm store directory
id: pnpm-cache
shell: bash
run: |
echo "STORE_PATH=$(pnpm store path)" >> $GITHUB_OUTPUT
- uses: actions/cache@v4
name: Setup pnpm cache
with:
path: ${{ steps.pnpm-cache.outputs.STORE_PATH }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-
- name: Download client-js build
uses: actions/download-artifact@v4
with:
name: client-js
path: clients/js/lib

- name: Download integration-hardhat build
uses: actions/download-artifact@v4
with:
name: integration-hardhat
path: integrations/hardhat/dist

- name: Install dependencies
run: |
pnpm install
- name: Build
run: |
! grep -q '"build":' package.json || pnpm run build
- name: Test
run: |
! grep -q '"test":' package.json || pnpm test
- name: Test Frontend
if: matrix.example == 'hardhat-boilerplate'
run: |
npx hardhat run scripts/deploy.js
cd frontend
pnpm build
50 changes: 25 additions & 25 deletions .github/workflows/contracts-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ jobs:
--rm
--health-cmd="/oasis-node debug control wait-ready -a unix:/serverdir/node/net-runner/network/client-0/internal.sock"
--health-start-period=90s
env:
SAPPHIRE_LOCALNET_HTTP_PROXY_PORT: 3001
steps:
- name: Checkout code
uses: actions/checkout@v4
Expand Down Expand Up @@ -54,35 +56,33 @@ jobs:
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-
- name: Install dependencies
run: pnpm install
- name: Build
run: make -C clients/js build
- uses: JarvusInnovations/background-action@v1
name: RPC proxy will error if non-encrypted calls are made
with:
run: pnpm run proxy &
wait-on: http://127.0.0.1:${{ env.SAPPHIRE_LOCALNET_HTTP_PROXY_PORT }}
tail: true
log-output-resume: true
wait-for: 31sec
log-output: true
log-output-if: true
working-directory: clients/js
- name: Test JS client
run: make -C clients/js test lint
- name: Build & Test integrations
run: make -C integrations
- name: Build & Test Examples
run: make -C examples
- name: Build & Test sapphire-contracts package
run: make -C contracts
- name: Install Foundry
uses: foundry-rs/foundry-toolchain@v1
- name: Install forge doc deps
run: cargo install mdbook-pagetoc
- name: Install dependencies
run: pnpm install
- name: Build JS client
working-directory: clients/js
run: pnpm build
- name: Build hardhat integration
working-directory: integrations/hardhat
run: pnpm build
- name: Test contracts with Hardhat
working-directory: contracts
run: pnpm hardhat test --network sapphire-localnet-ci
- name: Build docs
working-directory: contracts
run: pnpm doc
- name: hardhat test examples/hardhat
working-directory: examples/hardhat
run: pnpm hardhat run --network sapphire-localnet scripts/run-vigil.ts
env:
PRIVATE_KEY: '0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80'
- name: hardhat test examples/onchain-signer
working-directory: examples/onchain-signer
run: pnpm run test --network sapphire-localnet
- name: ethersv5-ts-esm
working-directory: examples/ethersv5-ts-esm
run: pnpm run test
- name: ethersv6-ts-esm
working-directory: examples/ethersv6-ts-esm
run: pnpm run test
26 changes: 22 additions & 4 deletions .github/workflows/publish.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,12 @@ name: publish
on:
push:
tags:
- clients/js/v[0-9].[0-9]+.[0-9]+
- contracts/v[0-9].[0-9]+.[0-9]+
- integrations/hardhat/v[0-9].[0-9]+.[0-9]+
- clients/js/v[0-9]\.[0-9]+\.[0-9]+(-(alpha|beta|rc)(\.[0-9]+)?)?
- contracts/v[0-9]\.[0-9]+\.[0-9]+(-(alpha|beta|rc)(\.[0-9]+)?)?
- integrations/ethers-v6/v[0-9]\.[0-9]+\.[0-9]+(-(alpha|beta|rc)(\.[0-9]+)?)?
- integrations/hardhat/v[0-9]\.[0-9]+\.[0-9]+(-(alpha|beta|rc)(\.[0-9]+)?)?
- integrations/viem-v2/v[0-9]\.[0-9]+\.[0-9]+(-(alpha|beta|rc)(\.[0-9]+)?)?
- integrations/wagmi-v2/v[0-9]\.[0-9]+\.[0-9]+(-(alpha|beta|rc)(\.[0-9]+)?)?

jobs:
publish:
Expand All @@ -21,10 +24,25 @@ jobs:
with:
version: 8
run_install: true
- name: Build JS client
working-directory: clients/js
run: pnpm build
- name: Build ethers-v6 integration
working-directory: integrations/ethers-v6
run: pnpm build
- name: Build hardhat integration
working-directory: integrations/hardhat
run: pnpm build
- name: Build Viem integration
working-directory: integrations/viem-v2
run: pnpm build
- name: Build Wagmi integration
working-directory: integrations/wagmi-v2
run: pnpm build
- name: Extract package from tag
id: extract-tag
run: |
echo "NPM_PACKAGE=$(echo ${{ github.ref_name }} | grep -oE '(clients/js|contracts|integrations/hardhat)')" >> $GITHUB_OUTPUT
echo "NPM_PACKAGE=$(echo ${{ github.ref_name }} | grep -oE '(clients/js|contracts|integrations/(hardhat|wagmi-v2|viem-v2))')" >> $GITHUB_OUTPUT
- name: Publish ${{ github.ref_name }} to NPM
uses: JS-DevTools/npm-publish@v3
with:
Expand Down
16 changes: 16 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
NPM ?= pnpm

subdirs = runtime clients integrations contracts

all:
@echo ...

clean distclean build lint::
for sd in $(subdirs); do $(MAKE) -C $$sd $@; done

$(subdirs)::
$(MAKE) -C $@

full: clean build

.PHONY: full all
Loading

0 comments on commit 2f4ce26

Please sign in to comment.