Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

40 add support to interact with 010 rankify interfaces #46

Merged
merged 40 commits into from
Dec 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
d46c39c
added 0.10 rankify contracts basic support
peersky Dec 5, 2024
63bb657
Merge branch 'main' into 40-add-support-to-interact-with-010-rankify-…
peersky Dec 5, 2024
9dbc9ae
Merge branch 'main' into 40-add-support-to-interact-with-010-rankify-…
peersky Dec 5, 2024
d282c74
Merge branch '40-add-support-to-interact-with-010-rankify-interfaces'…
peersky Dec 5, 2024
d5fcc36
updated index file
peersky Dec 5, 2024
59fae3d
moved rank token methods to separate class
peersky Dec 5, 2024
1b8e7d1
Merge branch 'main' into 40-add-support-to-interact-with-010-rankify-…
peersky Dec 5, 2024
39eca72
refactored sdk to use viem (#48)
peersky Dec 9, 2024
406cc1b
Peersky/40 add support 010 rankify/with viem (#49)
peersky Dec 9, 2024
fde1d95
Refactored sdk to accept chainId instead of chain
theKosmoss Dec 9, 2024
918200f
made linter to highlight more issues and fixed those
peersky Dec 12, 2024
04b2c7b
added jest for TDD
peersky Dec 12, 2024
a3f64f7
multipass unit test
peersky Dec 12, 2024
6e91668
updated ci cd
peersky Dec 12, 2024
773c571
upd ci
peersky Dec 12, 2024
e54e361
added tests to player, fixed bug
peersky Dec 12, 2024
3ebcaf1
validate address in distributor constructor
peersky Dec 12, 2024
f23955d
multipass constructor tweaks
peersky Dec 12, 2024
e4700eb
added abi files to index & generator
peersky Dec 12, 2024
648e928
export abis as object
peersky Dec 12, 2024
4255eeb
reexport abis
peersky Dec 12, 2024
cf816da
fix dist import require paths
peersky Dec 12, 2024
e50cc08
Revert "fix dist import require paths"
peersky Dec 12, 2024
8764f90
modified build scipt instead
peersky Dec 12, 2024
d7d9677
up ci
peersky Dec 13, 2024
2a0c31d
upd MAO distributor class getter namings
peersky Dec 13, 2024
1654dab
updated generation scripts and decoupled multipass in base and regist…
peersky Dec 13, 2024
9b730e1
added block range for getEvents
peersky Dec 13, 2024
9b609bf
tests mock deployments, removed console logs
peersky Dec 16, 2024
3c1a6e6
remove console logs
peersky Dec 16, 2024
29437e6
happy linter - happy life
peersky Dec 16, 2024
0c21798
added types node
peersky Dec 16, 2024
6c1392c
lockfile
peersky Dec 16, 2024
4e8d41c
add readme and setup local dev script
peersky Dec 16, 2024
19377dc
env sertup process
peersky Dec 16, 2024
ab04a1f
fix bug
peersky Dec 16, 2024
f49a515
docstrings & readme upd
peersky Dec 16, 2024
76a3586
changeset
peersky Dec 16, 2024
240f538
upodate docs generation
peersky Dec 16, 2024
c83edf5
No need to source env here. Sourcing is inside script
theKosmoss Dec 17, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/fluffy-poems-switch.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"rankify-js": minor
---

added script to locally bring up development enviroment
5 changes: 5 additions & 0 deletions .changeset/serious-suns-do.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"rankify-js": major
---

adapted client library for rankify v0.10.0 release
10 changes: 10 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Environment
NODE_ENV="TEST"

# RPC URLs
FORK_RPC_URL="https://arb1.arbitrum.io/rpc"

# Repository paths - update these to your local paths
RANKIFY_CONTRACTS_PATH="/path/to/rankify/contracts"
EDS_PATH="/path/to/eds"
MULTIPASS_PATH="/path/to/multipass"
9 changes: 5 additions & 4 deletions .github/setup/action.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
name: setup
description: 'Setup the environment for the CI'
runs:
using: 'composite'
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Install pnpm
Expand All @@ -11,15 +12,15 @@ runs:
version: 9
run_install: false
- name: Setup Node.js
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
node-version: 18.17.1
node-version: lts/*
cache: 'pnpm'
- name: Get pnpm store directory
shell: bash
run: |
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV
- uses: actions/cache@v3
- uses: actions/cache@v4
name: Setup pnpm cache
with:
path: ${{ env.STORE_PATH }}
Expand Down
26 changes: 26 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: CI
on:
pull_request:
branches: [main,staging]
types: [opened, reopened, labeled, synchronize]
env:
NODE_ENV: 'TEST'
jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: './.github/setup'
- name: Building
run: pnpm build
- name: Linting
run: pnpm lint:ci

test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: './.github/setup'

- name: Running tests
run: pnpm test:ci
6 changes: 3 additions & 3 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@ jobs:
timeout-minutes: 20
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
- uses: "./.github/setup"
with:
node-version: 18.x
node-version: lts/*
- name: install dependencies
run: pnpm install
- name: build package
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,6 @@ node_modules
.secrets
/.idea/*
.DS_Store
src/abis
.env
docs/
5 changes: 5 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
node_modules
dist
coverage
.changeset
pnpm-lock.yaml
10 changes: 10 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"printWidth": 120,
"tabWidth": 2,
"useTabs": false,
"semi": true,
"singleQuote": false,
"trailingComma": "es5",
"bracketSpacing": true,
"arrowParens": "always"
}
91 changes: 90 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,92 @@
# SDK

This is SDK for use with Rankify game. You can use this to ease interaction with smart contracts
This is SDK for use with Rankify game. You can ease interaction with smart contracts.

## Prerequisites

Before setting up the local development environment, ensure you have the following installed:

1. **Node.js and pnpm**
```bash
# Using homebrew
brew install node
npm install -g pnpm
```

2. **Foundry (for Anvil)**
```bash
curl -L https://foundry.paradigm.xyz | bash
foundryup
```

3. **tmux**
```bash
# Using homebrew
brew install tmux
```

## Local Development Setup

To set up your local development environment:

1. Create your environment file:
```bash
cp .env.example .env
```
Then edit `.env` to set your local repository paths.

2. Set the required environment variables:
```bash
export RANKIFY_CONTRACTS_PATH="/path/to/rankify/contracts"
export EDS_PATH="/path/to/eds"
export MULTIPASS_PATH="/path/to/multipass"
```

3. Make the setup script executable:
```bash
chmod +x scripts/setup-local-dev.sh
```

4. Run the setup script:
```bash
./scripts/setup-local-dev.sh
```

This will:
- Start a local Anvil development network in a tmux session (or use existing one if running)
- Install dependencies for all repositories
- Run local deployment scripts (`playbook/utils/deploy-to-local-anvil.sh`) in each repository
- Set up local pnpm links between packages

The script uses a fixed mnemonic for consistent addresses across runs.

### Managing Anvil

- View Anvil logs: `tmux attach -t anvil`
- Detach from logs: Press `Ctrl+B` then `D`
- Stop Anvil: `tmux kill-session -t anvil`

## Documentation

The SDK comes with comprehensive API documentation generated using TypeDoc. The documentation is automatically generated during the package build process and is included in the npm package.

### Generating Documentation

To generate the documentation locally:

```bash
pnpm run docs
```

This will create a `docs` directory with the generated documentation.

For development, you can use the watch mode:

```bash
pnpm run docs:watch
```

### Accessing Documentation

- **Local Development**: Open `docs/index.html` in your browser after generating the documentation
- **Published Package**: Documentation is available through the npm package page
66 changes: 33 additions & 33 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -1,46 +1,46 @@
import promise from "eslint-plugin-promise";
import globals from "globals";
import tsParser from "@typescript-eslint/parser";
import path from "node:path";
import { fileURLToPath } from "node:url";
import js from "@eslint/js";
import { FlatCompat } from "@eslint/eslintrc";
import prettier from "eslint-plugin-prettier";
import tseslint from "typescript-eslint";
import prettierConfig from "eslint-config-prettier";

const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
const compat = new FlatCompat({
baseDirectory: __dirname,
recommendedConfig: js.configs.recommended,
allConfig: js.configs.all,
});

export default [
export default tseslint.config(
js.configs.recommended,
...tseslint.configs.recommended,
prettierConfig,
{
ignores: ["deployments/", "coverage/**", "docs/templates/", "**/node_modules/"],
// Base configuration for all files
ignores: ["**/node_modules/**", "**/dist/**", "src/abis/*.ts", "scripts", "copyPackageFile.js"],
},
...compat.extends("eslint:recommended", "plugin:promise/recommended", "prettier"),
{
plugins: {
promise,
prettier, // Add Prettier plugin
"@typescript-eslint": tseslint.plugin,
},
// TypeScript files configuration
files: ["**/*.ts"],
languageOptions: {
globals: {
...globals.browser,
...globals.node,
...globals.mocha,
artifacts: "readonly",
contract: "readonly",
assert: "readonly",
web3: "readonly",
parserOptions: {
project: ["./tsconfig.json", "./tsconfig.test.json"],
tsconfigRootDir: ".",
},
parser: tsParser,
},
rules: {
"no-unused-vars": "warn",
"prettier/prettier": "error", // Add Prettier as an ESLint rule
"@typescript-eslint/no-unused-vars": "warn",
"@typescript-eslint/no-unsafe-member-access": "warn",
"@typescript-eslint/no-unsafe-call": "warn",
"@typescript-eslint/await-thenable": "warn",
"@typescript-eslint/no-unsafe-assignment": "warn",
"@typescript-eslint/no-require-imports": "off",
},
files: ["**/*.js", "**/*.jsx", "**/*.ts", "**/*.tsx"],
},
];
{
// JavaScript files configuration
files: ["**/*.js", "**/*.mjs", "**/*.cjs"],
ignores: ["src/**/*.ts", "**/node_modules/**", "**/dist/**"],
extends: [tseslint.configs.disableTypeChecked],
languageOptions: {
sourceType: "module",
},
rules: {
// Add JavaScript-specific rules here if needed
},
}
);
18 changes: 18 additions & 0 deletions jest.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/** @type {import('jest').Config} */
export default {
preset: "ts-jest/presets/default-esm",
testEnvironment: "node",
extensionsToTreatAsEsm: [".ts"],
moduleNameMapper: {
"^(\\.{1,2}/.*)\\.js$": "$1",
},
transform: {
"^.+\\.tsx?$": [
"ts-jest",
{
useESM: true,
},
],
},
moduleFileExtensions: ["ts", "tsx", "js", "jsx", "json", "node"],
};
59 changes: 35 additions & 24 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "@peeramid-labs/sdk",
"name": "rankify-js",
"description": "Peeramid Labs js client library",
"version": "1.1.0",
"private": "true",
Expand All @@ -22,45 +22,56 @@
}
},
"scripts": {
"lint:fix": "prettier --write '**/*.ts' && eslint --fix --no-ignore",
"lint": "eslint",
"prebuild": "jq '.type = \"commonjs\"' package.json > temp.json && mv temp.json package.json",
"lint:fix": "prettier --write 'src/**/*.{ts,js}' && eslint --fix .",
"lint": "eslint .",
"generate-chain-mapping": "node ./scripts/generateChainMapping.mjs",
"prebuild": "pnpm generate-chain-mapping && node scripts/copyAbi.cjs && jq '.type = \"commonjs\"' package.json > temp.json && mv temp.json package.json",
"build-esm": "tsc --project tsconfig.esm.json",
"build-all": "pnpm run build-commonjs && pnpm run build-esm",
"build-commonjs": "tsc --project tsconfig.commonjs.json",
"build": "pnpm build-all && node ./copyPackageFile.js prod",
"build": "pnpm build-all && node ./scripts/copyPackageFile.cjs prod",
"postbuild": "jq '.type = \"module\"' package.json > temp.json && mv temp.json package.json && cp README.md dist && cp -r .changeset ./dist/.changeset && prettier --write \"dist/**/*.{ts,js,json}\" && cd ./dist && pnpm install",
"dist": "changeset && changeset version && pnpm build && cp -r .changeset ./dist && cd dist && pnpm changeset publish",
"version": "changeset version",
"release": "pnpm build && cd ./dist && changeset publish"
"release": "pnpm build && cd ./dist && changeset publish",
"test": "jest",
"test:ci": "pnpm generate-chain-mapping && node scripts/copyAbi.cjs && pnpm jest",
"test:watch": "jest --watch",
"lint:ci": "pnpm generate-chain-mapping && node scripts/copyAbi.cjs && pnpm lint",
"docs": "typedoc",
"docs:watch": "typedoc --watch",
"prepublishOnly": "pnpm run build && pnpm run docs"
},
"dependencies": {
"@ethersproject/abi": "^5.7.0",
"@nomiclabs/hardhat-ethers": "^2.2.3",
"@peeramid-labs/multipass": "^0.3.1",
"@peersky/eth-auth": "^2.0.0",
"@peeramid-labs/eds": "^2.2.0",
"@peeramid-labs/multipass": "^0.3.2",
"crypto-js": "^4.1.1",
"ethers": "^5.0.0",
"lodash": "^4.17.21",
"rankify-contracts": "^0.9.3",
"typescript": "^5.0.4"
"rankify-contracts": "^0.10.1",
"viem": "^2.21.54"
},
"devDependencies": {
"@changesets/changelog-github": "^0.4.8",
"@changesets/cli": "^2.26.2",
"@peersky/eth-auth": "^2.0.0",
"@eslint/js": "^8.56.0",
"@jest/globals": "^29.7.0",
"@types/crypto-js": "^4.1.3",
"globals": "^15.9.0",
"@typescript-eslint/eslint-plugin": "^6.6.0",
"@typescript-eslint/parser": "^8.4.0",
"@eslint/eslintrc": "^3.1.0",
"@eslint/js": "^9.9.1",
"eslint": "^9.9.1",
"eslint-plugin-prettier": "^5.2.1",
"@types/jest": "^29.5.11",
"@types/node": "^20.10.5",
"@typescript-eslint/eslint-plugin": "^8.18.0",
"@typescript-eslint/parser": "^8.18.0",
"eslint": "^8.56.0",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-promise": "^7.1.0",
"eslint-plugin-unused-imports": "^3.0.0",
"eslint-plugin-jest": "^28.9.0",
"globals": "^15.9.0",
"jest": "^29.7.0",
"prettier": "^3.3.3",
"typescript": "^5.0.4"
"ts-jest": "^29.1.1",
"ts-node": "^10.9.2",
"typescript": "^5.7.2",
"typescript-eslint": "^8.18.0",
"typedoc": "^0.25.7",
"typedoc-plugin-markdown": "^3.17.1",
"typedoc-theme-hierarchy": "^4.1.2"
}
}
Loading
Loading