Skip to content

Commit 6151e30

Browse files
authored
Merge pull request #41 from 0xsequence/refactor/devx_improvements
sidekick improvements + linting
2 parents 71fe288 + b4266d1 commit 6151e30

File tree

128 files changed

+24488
-11409
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

128 files changed

+24488
-11409
lines changed

.env.example

Lines changed: 37 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,53 @@
1-
# Required env variables
2-
PORT=3000
3-
HOST=0.0.0.0
4-
DATABASE_URL="postgresql://dev:sequence@localhost:5432/sequence_sidekick?schema=public" # Created by docker
5-
REDIS_HOST=localhost
6-
REDIS_PORT=6379
7-
REDIS_PASSWORD=sequence
8-
PROJECT_ACCESS_KEY= # Take it from Sequence Builder
9-
SECRET_KEY= # Set your own secret key for Sidekick, use it when making requests to the API
10-
SEQUENCE_RPC_URL= # Take it from Sequence Builder
11-
BUILDER_API_SECRET_KEY= # Take it from Sequence Builder
12-
INDEXER_URL= # Take it from Sequence Builder
1+
### =====[ Required Configuration ]=====
2+
3+
### Go to https://sequence.build, login or signup, create a project, go to "Embedded Wallet" and copy your own "Project Access Key"
4+
### We provide this project access key but we recommend using your own, especially for production.
5+
SEQUENCE_PROJECT_ACCESS_KEY="AQAAAAAAAJbd_5JOcE50AqglZCtvu51YlGI"
6+
7+
### By default, the signer type is "local", which requires an EVM private key to be set. This will be your backend wallet.
8+
### Note that Sidekick creates a Sequence Smart Account Wallet for this private key and the backend wallet itself is
9+
### a Sequence Smart Account Wallet, not an EOA.
10+
EVM_PRIVATE_KEY="0x"
1311

1412
# =====[ Optional Configuration ]=====
1513

14+
### By default we use these values if none is provided in .env
15+
# PORT=7500
16+
# HOST=0.0.0.0
17+
# REDIS_HOST=localhost
18+
# REDIS_PORT=6379
19+
20+
### You can opt to use a database or not but some routes won't be available if you don't have a database.
21+
# DATABASE_URL="postgres://postgres:postgres@localhost:5432/sidekick"
22+
23+
### Set your own secret key for Sidekick, use it when making requests to the API.
24+
### If some bad actor gets access to your API internally, they will still have to know this secret key to write to the API.
25+
# SIDEKICK_API_SECRET_KEY="secret"
26+
27+
# REDIS_PASSWORD=""
28+
29+
### We recommend setting these two variables, it will enable automatic contract verification on deployment through Sidekick.
1630
# ETHERSCAN_API_KEY=
1731
# VERIFY_CONTRACT_ON_DEPLOY=
1832

19-
# DEBUG=true (enables debug logs)
33+
# DEBUG="true"
2034

21-
# If using Google KMS
35+
### If using local signer (EVM private key)
36+
### Note: This is enabled by default
37+
# SIGNER_TYPE=local=
38+
# EVM_PRIVATE_KEY=
39+
40+
### If using Google KMS
41+
# SIGNER_TYPE=google_kms
2242
# PROJECT=
2343
# LOCATION=
2444
# KEY_RING=
2545
# CRYPTO_KEY=
2646
# CRYPTO_KEY_VERSION=
2747

28-
# If using AWS KMS
48+
### If using AWS KMS
49+
# SIGNER_TYPE=aws_kms
2950
# AWS_REGION=
3051
# AWS_ACCESS_KEY_ID=
3152
# AWS_SECRET_ACCESS_KEY=
32-
# AWS_KMS_KEY_ID=
33-
34-
# If using local signer (EVM private key)
35-
# SIGNER_TYPE=local (defaults to this if no SIGNER_TYPE is found in env)
36-
# EVM_PRIVATE_KEY= (required if SIGNER_TYPE=local)
37-
38-
# If using Google KMS
39-
# SIGNER_TYPE=google_kms
40-
41-
# If using AWS KMS
42-
# SIGNER_TYPE=aws_kms
53+
# AWS_KMS_KEY_ID=

Dockerfile

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Use an official Node.js runtime as the base image
2-
FROM node:18-alpine
2+
FROM node:24-alpine
33

44
# Set the working directory in the container
55
WORKDIR /app
@@ -18,9 +18,6 @@ COPY prisma ./prisma/
1818
# Install dependencies
1919
RUN pnpm install --frozen-lockfile
2020

21-
# Generate Prisma Client
22-
RUN pnpm prisma generate
23-
2421
# Copy the rest of the application code
2522
COPY . .
2623

@@ -31,11 +28,11 @@ RUN pnpm run build
3128
RUN chmod +x scripts/start.sh
3229

3330
# Expose the port the app runs on
34-
EXPOSE 3000
31+
EXPOSE 7500
3532

3633
# Set environment variables
3734
ENV HOST=0.0.0.0
38-
ENV PORT=3000
35+
ENV PORT=7500
3936

4037
# Command to run the application
4138
CMD ["/app/scripts/start.sh"]

README.md

Lines changed: 42 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -5,42 +5,49 @@ Sidekick is a companion service, fully open source,that simplifies blockchain in
55
When executing any transaction with Sidekick, the caller will not be the EOA of the PRIVATE KEY you're using for Sidekick, but a Sequence Smart Wallet created for your EOA.
66
You can get the address by making a GET request to the `/sidekick/wallet-address` endpoint.
77

8-
## Setup
8+
## Run remotely with docker
99

10-
- Copy `.env.example` to `.env`: `cp .env.example .env`
11-
- Set up your environment variables in `.env`:
10+
These commands will get you started with the simplest version of Sidekick. It will allow you to test some of the features like deploying a contract, reading from a contract and executing transactions.
1211

13-
## Using Docker (Recommended)
12+
```
13+
docker pull ghcr.io/0xsequence/sidekick:latest
14+
docker run -e EVM_PRIVATE_KEY=your_private_key_here -p 7500:7500 ghcr.io/0xsequence/sidekick:latest
15+
```
1416

15-
Quickstart locally with Docker with only one command:
16-
`pnpm docker:start` (Will start Redis, PostgreSQL, and the server)
17-
`curl http://127.0.0.1:3000` should return {"status":"ok"}
17+
## Run locally with Docker Compose
1818

19-
Instructions to stop and restart the sidekick with Docker:
20-
`pnpm docker:stop` (Will stop all the services)
21-
`pnpm docker:restart` (Will stop and start all the services)
19+
You can use the docker-compose.yml to run Sidekick with all the features like Redis, PostgreSQL, Grafana, Prometheus, Blackbox Exporter, etc.
2220

23-
### Run the sidekick without Docker, locally for development:
24-
1. Install dependencies: `pnpm install`
25-
2. Generate Prisma client: `pnpm prisma generate`
26-
3. Create database tables: `pnpm prisma migrate dev`
27-
4. Start Redis: `pnpm start:redis`
28-
5. Start the server: `pnpm start`
21+
```
22+
cp .env.example .env
23+
```
2924

30-
Instructions to stop Redis:
31-
`pnpm stop:redis` (Will stop Redis)
25+
This will start all the services.
26+
```
27+
pnpm docker:start
28+
```
3229

33-
Instructions to start Redis:
34-
`pnpm start:redis` (Will start Redis)
30+
## Dev mode
3531

36-
Instructions to test the sidekick:
37-
`pnpm run test` (Will run the tests)
38-
`pnpm run test:watch` (Will run the tests in watch mode)
39-
`pnpm run test:coverage` (Will run the tests and generate a coverage report)
32+
You can also run Sidekick locally without docker.
33+
34+
```
35+
cp .env.example .env
36+
```
4037

41-
Instructions to run the sidekick in development mode:
42-
`pnpm run dev` (Will start the server in development mode)
43-
`pnpm run dev:withRedis` (Will start the server and Redis in development mode)
38+
Run without a database
39+
```
40+
pnpm install
41+
pnpm dev:withRedis
42+
```
43+
44+
Run with a database
45+
```
46+
pnpm install
47+
pnpm prisma generate
48+
pnpm prisma migrate dev
49+
pnpm dev:withRedis
50+
```
4451

4552
## Analytics & Monitoring 📊
4653

@@ -78,14 +85,20 @@ Sidekick provides several tools for monitoring, metrics, and alerting. Here's wh
7885

7986
Sidekick provides a DEBUG mode that will give you detailed logs so you can see what's happening under the hood, add DEBUG="true" as an environment variable to your .env file to turn it on.
8087

88+
```
89+
DEBUG=true
90+
```
91+
8192
### Tenderly 🔍
8293

8394
Sidekick is integrated with Tenderly, you can use it to simulate transactions, deployments, or get a transaction simulation URL and debug directly from the Tenderly UI with just one click. For the best results, we recommend that your contracts are verified.
8495
To use Tenderly, you need to add the following environment variables to your .env file:
8596

97+
```
8698
TENDERLY_ACCESS_KEY=...
8799
TENDERLY_ACCOUNT_SLUG=..
88100
TENDERLY_PROJECT_SLUG=..
101+
```
89102

90103
### Contract Verification ✅
91104

@@ -98,15 +111,9 @@ For now, this only works for the following contracts:
98111

99112
To turn automatic verification on you need the following environment variables:
100113

101-
VERIFY_CONTRACT_ON_DEPLOY=true
102-
ETHERSCAN_API_KEY=...
103-
104-
### Public Docker Image on Github Container Registry 🐳
105-
106-
You can pull the latest version of Sidekick from the Github Container Registry:
107-
108114
```
109-
docker pull ghcr.io/0xsequence/sidekick:latest
115+
VERIFY_CONTRACT_ON_DEPLOY=true
116+
ETHERSCAN_API_KEY=.. .
110117
```
111118

112119
Verification for other contract templates will be added soon.

biome.json

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
{
2+
"$schema": "https://biomejs.dev/schemas/1.9.4/schema.json",
3+
"vcs": {
4+
"enabled": false,
5+
"clientKind": "git",
6+
"useIgnoreFile": false
7+
},
8+
"files": {
9+
"ignoreUnknown": false,
10+
"ignore": [
11+
"pnpm-lock.yaml",
12+
"node_modules",
13+
"package.json",
14+
"src/lib/generated"
15+
]
16+
},
17+
"formatter": {
18+
"enabled": true,
19+
"indentStyle": "tab",
20+
"formatWithErrors": true,
21+
"lineWidth": 80,
22+
"indentWidth": 2
23+
},
24+
"organizeImports": {
25+
"enabled": true
26+
},
27+
"linter": {
28+
"enabled": true,
29+
"rules": {
30+
"recommended": true,
31+
"suspicious": {
32+
"noExplicitAny": "warn"
33+
},
34+
"style": {
35+
"noUnusedTemplateLiteral": "warn",
36+
"noNonNullAssertion": "off"
37+
}
38+
}
39+
},
40+
"javascript": {
41+
"formatter": {
42+
"semicolons": "asNeeded",
43+
"trailingCommas": "none",
44+
"quoteStyle": "single"
45+
}
46+
}
47+
}

docker-compose.yml

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,55 +1,53 @@
11
services:
22
postgres:
33
image: postgres:17
4-
container_name: sidekick_postgres
4+
container_name: sidekick-postgres
55
restart: always
66
healthcheck:
77
test: ["CMD-SHELL", "pg_isready -U dev -d sequence_sidekick"]
88
interval: 5s
99
timeout: 5s
1010
retries: 5
1111
environment:
12-
POSTGRES_USER: dev
13-
POSTGRES_PASSWORD: sequence
12+
POSTGRES_USER: postgres
13+
POSTGRES_PASSWORD: postgres
1414
POSTGRES_DB: sequence_sidekick
1515
ports:
1616
- "5432:5432"
1717
volumes:
1818
- postgres_data:/var/lib/postgresql/data
1919

2020
redis:
21-
container_name: sidekick_redis
21+
container_name: sidekick-redis
2222
image: redis:7.2
2323
restart: always
24-
command: redis-server --requirepass ${REDIS_PASSWORD:-sequence}
24+
command: redis-server
2525
ports:
2626
- "6380"
2727
volumes:
2828
- redis_data:/data
2929

3030
sequence_sidekick:
3131
build: .
32-
container_name: server
32+
container_name: sequence-sidekick
3333
restart: always
3434
depends_on:
3535
postgres:
3636
condition: service_healthy
3737
redis:
3838
condition: service_started
3939
ports:
40-
- "${PORT:-3000}:3000"
40+
- "${PORT:-7500}:7500"
4141
environment:
42-
- PORT=${PORT:-3000}
42+
- PORT=${PORT:-7500}
4343
- HOST=${HOST:-0.0.0.0}
44-
- PROJECT_ACCESS_KEY=${PROJECT_ACCESS_KEY}
45-
- SECRET_KEY=${SECRET_KEY}
46-
- DATABASE_URL=postgresql://dev:sequence@postgres:5432/sequence_sidekick?schema=public
44+
- SEQUENCE_PROJECT_ACCESS_KEY=${SEQUENCE_PROJECT_ACCESS_KEY}
45+
- API_SECRET_KEY=${API_SECRET_KEY}
46+
- DATABASE_URL=postgresql://postgres:postgres@postgres:5432/sequence_sidekick?schema=public
4747
- REDIS_HOST=redis
4848
- REDIS_PORT=${REDIS_PORT:-6379}
4949
- REDIS_PASSWORD=${REDIS_PASSWORD}
50-
- SEQUENCE_RPC_URL=${SEQUENCE_RPC_URL}
5150
- BUILDER_API_SECRET_KEY=${BUILDER_API_SECRET_KEY}
52-
- INDEXER_URL=${INDEXER_URL}
5351
- SIGNER_TYPE=${SIGNER_TYPE}
5452
- DEBUG=${DEBUG}
5553
# AWS KMS configs

0 commit comments

Comments
 (0)