Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jobs:
- name: Use Node.js
uses: actions/setup-node@v4
with:
node-version: 24.4.1
node-version: 24.5.0

- name: Enable Corepack
run: corepack enable
Expand Down
56 changes: 33 additions & 23 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,22 @@

This document provides instructions for setting up, running, building with Docker, and deploying the `intmax2-function` project.

## Installing Dependencies
## Setup

First, install the project dependencies, build the project, and set up the environment.
Before running any service, make sure to:

```bash
# install
```sh
# Install dependencies
yarn

# build:shared
yarn build:shared

# build
yarn build

# setup env
# Copy environment variables
cp .env.example .env

# Build shared packages
yarn build:shared
```

## Running the Project
## Development

To start the development mode for each workspace, use the following commands:

Expand Down Expand Up @@ -74,6 +71,9 @@ If your development workflow involves Firestore, you can start a local emulator:

```sh
gcloud emulators firestore start

# Set the FIRESTORE_EMULATOR_HOST variable in the same terminal where you will run your application.
export FIRESTORE_EMULATOR_HOST="HOST:PORT"
export FIRESTORE_EMULATOR_HOST="HOST:PORT" # We will use what is displayed in the console.
```

Expand All @@ -86,6 +86,17 @@ docker build -f docker/Dockerfile -t intmax2-function .
docker run --rm -p 3000:3000 --env-file .env intmax2-function workspace token start
```

## Redis

Run Redis in a Docker container with data persistence enabled.

```sh
docker run -d --rm \
--name redis \
-p 6379:6379 \
-v redis-data:/data \
redis redis-server --appendonly yes
```

## Testing

Expand All @@ -102,22 +113,21 @@ yarn test --watch
yarn coverage
```

## Redis

```sh
docker run -d --rm \
--name redis \
-p 6379:6379 \
-v redis-data:/data \
redis redis-server --appendonly yes
```

## Bootstrap Tasks

Run the following commands to initialize the token map configuration.

```sh
# Bootstrap token map configuration
yarn token-map-bootstrap

# Bootstrap token image assets
yarn token-image-bootstrap
```
```

## Docs

This document explains the overall system design of intmax2-function. It covers the architectural components, interactions between modules, data flow, and the process of generating and verifying ZKPs (Zero-Knowledge Proofs). It is intended to help developers and infrastructure engineers understand the technical foundation of the system.

- [SYSTEM Design](./docs/SYSTEM_DESIGN.md)
- [API Usage](./docs/API.md)
2 changes: 1 addition & 1 deletion biome.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"$schema": "https://biomejs.dev/schemas/2.1.2/schema.json",
"$schema": "https://biomejs.dev/schemas/2.1.3/schema.json",
"formatter": {
"enabled": true,
"formatWithErrors": false,
Expand Down
4 changes: 2 additions & 2 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM node:24.4.1-bookworm-slim AS builder
FROM node:24.5.0-bookworm-slim AS builder

RUN corepack enable && \
corepack prepare yarn@4.9.2 --activate && \
Expand Down Expand Up @@ -36,7 +36,7 @@ RUN mkdir -p /tmp/packages && \
find /tmp/packages/$pkg_name -type d -empty -delete; \
done

FROM node:24.4.1-bookworm-slim AS production
FROM node:24.5.0-bookworm-slim AS production

ENV NODE_ENV=production
ENV NODE_OPTIONS="\
Expand Down
92 changes: 92 additions & 0 deletions docs/API.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
# API

Here are example commands for accessing the INTMAX2 Function APIs using curl.
These services provide various functionalities including indexer services, token management, predicate evaluation, and transaction mapping.

## Services Overview

- **Indexer**: Provides block builder node information and proxy metadata
- **Token**: Manages token prices and token mappings
- **Predicate**: Evaluates anti-money laundering (AML) policies
- **TX-Map**: Temporarily stores and retrieves transaction-related key-value mappings

## API Usage

### Indexer Service

```sh
export INDEXER_ENDPOINT='http://localhost:3000'

# health check
curl "$INDEXER_ENDPOINT/v1/health" | jq

# fetch block builder nodes
curl "$INDEXER_ENDPOINT/v1/indexer/builders" | jq

# fetch block builder metadata
curl "$INDEXER_ENDPOINT/v1/indexer/builders/meta" | jq

# check indexer registration for specific address
curl "$INDEXER_ENDPOINT/v1/indexer/builders/registration/0x..." | jq

# fetch proxy metadata
curl "$INDEXER_ENDPOINT/v1/proxy/meta" | jq
```

### Token Service

```sh
export TOKEN_ENDPOINT='http://localhost:3000'

# health check
curl "$TOKEN_ENDPOINT/v1/health" | jq

# fetch token prices
curl "$TOKEN_ENDPOINT/v1/token-prices/list" | jq

# fetch token prices with filters
curl "$TOKEN_ENDPOINT/v1/token-prices/list?contractAddresses=0x92d6c1e31e14520e676a687f0a93788b716beff5&contractAddresses=0x6e2a43be0b1d33b726f0ca3b8de60b3482b8b050&perPage=2" | jq

# fetch token maps
curl "$TOKEN_ENDPOINT/v1/token-maps/list" | jq

# fetch token maps with filters
curl "$TOKEN_ENDPOINT/v1/token-maps/list?tokenIndexes=1&tokenIndexes=2&perPage=2" | jq
```

### Predicate Service

```sh
export PREDICATE_ENDPOINT='http://localhost:3000'

# health check
curl "$PREDICATE_ENDPOINT/v1/health" | jq

# evaluate policy (AML)
curl -X POST "$PREDICATE_ENDPOINT/v1/predicate/evaluate-policy" \
-H "Content-Type: application/json" \
-d '{
"policy": "sample_policy_data"
}' | jq
```

### TX-Map Service

```sh
export TX_MAP_ENDPOINT='http://localhost:3000'

# health check
curl "$TX_MAP_ENDPOINT/v1/health" | jq

# store a mapping
curl -X POST "$TX_MAP_ENDPOINT/v1/map" \
-H "Content-Type: application/json" \
-d '{
"digest": "sampledigest123",
"data": "sampledata456",
"expiresIn": 300
}' | jq

# retrieve a mapping
curl "$TX_MAP_ENDPOINT/v1/map/sampledigest123" | jq
```
Loading