Skip to content

Commit

Permalink
update README with all routes
Browse files Browse the repository at this point in the history
  • Loading branch information
0age committed Dec 9, 2024
1 parent 4c7f689 commit c6bfe9a
Showing 1 changed file with 49 additions and 2 deletions.
51 changes: 49 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,20 @@ A minimalistic server-based allocator for [The Compact](https://github.com/Unisw
- 📡 No direct on-chain awareness: Relies entirely on indexer and internal attestation state
- ⏳ Straightforward finalization: Uses a simple, time-based approach per chain for determining transaction finality

## UI Usage

A basic frontend is available at the root path (`GET /`), or at `localhost:3001/` when running locally in dev mode. While the primary intended mechanism of interaction with Smallocator is via the API, the UI serves as a convenient and direct secondary access point.

It supports:
- viewing the health status of the server
- managing session key via EIP-4361 (Sign in with Ethereum)
- depositing Native tokens and ERC20 tokens
- viewing allocatable and allocated balances
- performing allocated transfers and withdrawals
- initiating, executing, and disabling forced withdrawals

Note that the frontend is still relatively unstable (any contributions here are welcome).

## API Usage

### Health Check
Expand Down Expand Up @@ -135,14 +149,14 @@ All authentication endpoints require a valid session ID in the `x-session-id` he

### Compact Operations

All compact operations require a valid session ID in the `x-session-id` header.

1. **Submit Compact**

```http
POST /compact
```

Requires a valid session ID in the `x-session-id` header.

Example request:

```json
Expand Down Expand Up @@ -179,6 +193,8 @@ Note that `nonce` can be provided as `null` in which case the next available val
GET /compacts
```

Requires a valid session ID in the `x-session-id` header.

Example response:

```json
Expand Down Expand Up @@ -208,6 +224,8 @@ Note that `nonce` can be provided as `null` in which case the next available val
GET /compact/:chainId/:claimHash
```

Requires a valid session ID in the `x-session-id` header.

Example response:

```json
Expand Down Expand Up @@ -235,6 +253,8 @@ Note that `nonce` can be provided as `null` in which case the next available val
GET /balance/:chainId/:lockId
```

Requires a valid session ID in the `x-session-id` header.

Returns balance information for a specific resource lock. Example response:

```json
Expand All @@ -246,6 +266,12 @@ Note that `nonce` can be provided as `null` in which case the next available val
}
```

The `allocatableBalance` will be the current balance minus the sum of any unfinalized deposits or inbound transfers. The period after which these are considered finalized is configurable for each chain.

The `allocatedBalance` will be the sum of any submitted compacts that:
- have not been processed (as confirmed by a `Claim` event with the respective claim hash in a finalized block)
- have not expired (as confirmed by a finalized block with a timestamp exceeding the `expires` value)

The `balanceAvailableToAllocate` will be:

- `"0"` if `withdrawalStatus` is non-zero
Expand All @@ -256,7 +282,11 @@ Note that `nonce` can be provided as `null` in which case the next available val
```http
GET /balances
```

Requires a valid session ID in the `x-session-id` header.

Returns balance information for all resource locks managed by this allocator. Example response:

```json
{
"balances": [
Expand All @@ -271,8 +301,25 @@ Note that `nonce` can be provided as `null` in which case the next available val
]
}
```

Each balance entry follows the same rules as the single balance endpoint.

6. **Get Suggested Nonce**
```http
GET /suggested-nonce/:chainId
```

Requires a valid session ID in the `x-session-id` header.

Returns the next available unused nonce for the account on the session for creating new compacts on a specific chain.

Example response:
```json
{
"nonce": "0x70997970C51812dc3A010C7d01b50e0d17dc79C800000000000000000000001"
}
```

## Development

### Prerequisites
Expand Down

0 comments on commit c6bfe9a

Please sign in to comment.