Skip to content

Commit

Permalink
add getDelegates, add example, set up CI
Browse files Browse the repository at this point in the history
  • Loading branch information
talentlessguy committed Nov 6, 2023
1 parent 424caa0 commit bef085c
Show file tree
Hide file tree
Showing 10 changed files with 628 additions and 22 deletions.
63 changes: 63 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
name: CI

on:
push:
branches: [master]
pull_request:
branches: [master]

env:
PNPM_CACHE_FOLDER: .pnpm-store

jobs:
build:
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
runs-on: ${{ matrix.os }}

steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v3

- name: setup caching
uses: actions/cache@v3
with:
path: ${{ env.PNPM_CACHE_FOLDER }}
key: ${{ runner.os }}-pnpm-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-
- name: Setup Node.js environment
uses: actions/setup-node@v2
with:
node-version: 20.x

- name: install pnpm
uses: pnpm/action-setup@v2
with:
version: 8.x

- name: setup pnpm config
run: pnpm config set store-dir $PNPM_CACHE_FOLDER

- name: install dependencies
run: pnpm install

- name: lint code
run: pnpm lint

- name: check formatting
run: pnpm format

- name: build packages
run: pnpm build
- run: pnpm test:coverage
- run: pnpm test:report

# run coverage only on ubuntu
- name: Coveralls
if: ${{ matrix.os == 'ubuntu-latest' }}
uses: coverallsapp/github-action@master
with:
path-to-lcov: ./coverage/lcov.info
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -174,4 +174,6 @@ dist
# Finder (MacOS) folder config
.DS_Store

site/.vitepress/cache
site/.vitepress/cache

lcov.info
15 changes: 15 additions & 0 deletions examples/get-delegates.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { ApiClient } from '../src/api.js'
import { goerli } from 'viem/chains'
import { EIP3770Address } from '../src/types.js'

const safeAddress = process.env.SAFE_ADDRESS as EIP3770Address

const apiClient = new ApiClient({ url: 'https://safe-transaction-goerli.safe.global', safeAddress, chainId: goerli.id })

const response = await apiClient.getDelegates({ limit:'100' })

console.log(`List of delegates for ${safeAddress}:\n`)

for (const delegate of response.results) {
console.log(`${delegate.label}: ${delegate.delegate}`)
}
24 changes: 11 additions & 13 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,30 +25,28 @@
],
"devDependencies": {
"@stylistic/eslint-plugin": "^0.1.2",
"@types/node": "^20.8.7",
"@types/node": "^20.8.10",
"@types/semver": "^7.5.3",
"@typescript-eslint/eslint-plugin": "^6.9.1",
"@typescript-eslint/parser": "^6.9.1",
"bun-types": "latest",
"c8": "^8.0.1",
"eslint": "^8.52.0",
"expect": "^29.7.0",
"globby": "^13.2.2",
"prettier": "^3.0.3",
"tsx": "^3.14.0",
"typescript": "^5.2.2",
"viem": "^1.18.1"
},
"peerDependencies": {
"viem": ">=1.16"
},
"dependencies": {
"semver": "^7.5.4"
},
"peerDependencies": { "viem": ">=1.16" },
"dependencies": { "semver": "^7.5.4" },
"scripts": {
"build": "tsc -p tsconfig.build.json",
"lint": "eslint --ext .ts .",
"prepublishOnly": "pnpm build"
"lint": "eslint --ext .ts",
"prepublishOnly": "pnpm build",
"test": "tsx src/**/*.test.ts",
"test:coverage": "c8 tsx --test src/**/*.test.ts",
"test:report": "c8 report --reporter=text-lcov > lcov.info"
},
"publishConfig": {
"access": "public"
}
"publishConfig": { "access": "public" }
}
Loading

0 comments on commit bef085c

Please sign in to comment.