Skip to content

Commit

Permalink
Merge pull request #37 from hirosystems/beta
Browse files Browse the repository at this point in the history
release beta to main
  • Loading branch information
rafaelcr authored Jul 29, 2024
2 parents 4badd21 + e900500 commit e78c35e
Show file tree
Hide file tree
Showing 51 changed files with 2,819 additions and 1,123 deletions.
2 changes: 0 additions & 2 deletions .cargo/config

This file was deleted.

6 changes: 6 additions & 0 deletions .cargo/config.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[alias]
runehook-install = "install --path . --locked --force"

[env]
# Run tests in one thread so we can support postgres migrations correctly.
RUST_TEST_THREADS = "1"
18 changes: 15 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ on:
push:
branches:
- main
- beta
- develop
paths-ignore:
- "**/CHANGELOG.md"
Expand Down Expand Up @@ -141,10 +142,14 @@ jobs:
docker-compose -f docker/docker-compose.dev.postgres.yml up -d
docker-compose -f docker/docker-compose.dev.postgres.yml logs -t -f --no-color &> docker-compose-logs.txt &
- name: Cargo test
- name: Update Rust
run: |
rustup update
RUST_BACKTRACE=1 cargo test --all -- --test-threads=1
- name: Run tests
run: |
cargo install --force cargo-tarpaulin
cargo tarpaulin --out lcov -- --test-threads=1
- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v4
Expand Down Expand Up @@ -248,6 +253,13 @@ jobs:
fetch-depth: 0
persist-credentials: false

- name: Checkout tag
if: needs.semantic-release.outputs.new_release_version != ''
uses: actions/checkout@v4
with:
persist-credentials: false
ref: v${{ needs.semantic-release.outputs.new_release_version }}

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

Expand Down Expand Up @@ -277,4 +289,4 @@ jobs:
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
# Only push if (there's a new release on main branch, or if building a non-main branch) and (Only run on non-PR events or only PRs that aren't from forks)
push: ${{ (github.ref != 'refs/heads/master' || needs.semantic-release.outputs.new_release_version != '') && (github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository) }}
push: ${{ (github.ref != 'refs/heads/main' || needs.semantic-release.outputs.new_release_version != '') && (github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository) }}
23 changes: 22 additions & 1 deletion .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,27 @@
"TS_NODE_SKIP_IGNORE": "true"
},
"killBehavior": "polite"
}
},
{
"type": "node",
"request": "launch",
"name": "Jest",
"program": "${workspaceFolder}/api/node_modules/jest/bin/jest",
"cwd": "${workspaceFolder}/api/",
"args": [
"--testTimeout=3600000",
"--runInBand",
"--no-cache",
],
"outputCapture": "std",
"console": "integratedTerminal",
"preLaunchTask": "npm: testenv:run",
"postDebugTask": "npm: testenv:stop",
"env": {
"PGHOST": "localhost",
"PGUSER": "postgres",
"PGPASSWORD": "postgres",
},
},
]
}
43 changes: 43 additions & 0 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
{
"version": "2.0.0",
"tasks": [
{
"label": "npm: testenv:run",
"type": "shell",
"command": "npm run testenv:run -- -d",
"isBackground": true,
"options": {
"cwd": "${workspaceFolder}/api/",
},
"problemMatcher": {
"pattern": {
"regexp": ".",
"file": 1,
"location": 2,
"message": 3
},
"background": {
"activeOnStart": true,
"beginsPattern": ".",
"endsPattern": "."
}
}
},
{
"label": "npm: testenv:stop",
"type": "shell",
"command": "npm run testenv:stop",
"options": {
"cwd": "${workspaceFolder}/api/",
},
"presentation": {
"echo": true,
"reveal": "silent",
"focus": false,
"panel": "shared",
"showReuseMessage": true,
"clear": false
}
}
]
}
39 changes: 39 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,42 @@
## [0.3.0-beta.5](https://github.com/hirosystems/runehook/compare/v0.3.0-beta.4...v0.3.0-beta.5) (2024-07-29)


### Features

* number field in rune response ([#35](https://github.com/hirosystems/runehook/issues/35)) ([4485057](https://github.com/hirosystems/runehook/commit/4485057825dcf22bd4bb4bd667da0d9d2886e1ab))

## [0.3.0-beta.4](https://github.com/hirosystems/runehook/compare/v0.3.0-beta.3...v0.3.0-beta.4) (2024-07-08)


### Bug Fixes

* default output selection without a runestone ([#23](https://github.com/hirosystems/runehook/issues/23)) ([016583c](https://github.com/hirosystems/runehook/commit/016583c69d559ff6eaa4ae525be06ada9cd6a146))
* move unallocated without need for a runestone ([#22](https://github.com/hirosystems/runehook/issues/22)) ([69559e0](https://github.com/hirosystems/runehook/commit/69559e0b70f49197f0ae645820960e4cfd8852e2))
* register receive operations correctly on edicts ([#21](https://github.com/hirosystems/runehook/issues/21)) ([de48a59](https://github.com/hirosystems/runehook/commit/de48a593426c422d5554f7bbd99b133baaca5ae3))

## [0.3.0-beta.3](https://github.com/hirosystems/runehook/compare/v0.3.0-beta.2...v0.3.0-beta.3) (2024-07-06)


### Features

* address activity endpoint ([#18](https://github.com/hirosystems/runehook/issues/18)) ([c6b8bbe](https://github.com/hirosystems/runehook/commit/c6b8bbe683d1433a44147a474c389d9380959c23))

## [0.3.0-beta.2](https://github.com/hirosystems/runehook/compare/v0.3.0-beta.1...v0.3.0-beta.2) (2024-07-05)


### Bug Fixes

* cached output balance retrieval ([#16](https://github.com/hirosystems/runehook/issues/16)) ([b87b921](https://github.com/hirosystems/runehook/commit/b87b9212ec1e4addd394dc7af8e3e94c447d4487))
* increase activity count when etching ([#14](https://github.com/hirosystems/runehook/issues/14)) ([e797fc3](https://github.com/hirosystems/runehook/commit/e797fc3bc023777ad38c9a5b1f9a0cd5672607c1))
* open and close pg connections for each chainhook message ([#15](https://github.com/hirosystems/runehook/issues/15)) ([3c93671](https://github.com/hirosystems/runehook/commit/3c936719681b102cc0c2afa5e06b9ffb6d3672ce))

## [0.3.0-beta.1](https://github.com/hirosystems/runehook/compare/v0.2.2...v0.3.0-beta.1) (2024-07-04)


### Features

* add zeromq streaming and rollback support ([#8](https://github.com/hirosystems/runehook/issues/8)) ([c201bb5](https://github.com/hirosystems/runehook/commit/c201bb521b2fb30e4983d4f601ac7719907c2d26))

## [0.2.2](https://github.com/hirosystems/runehook/compare/v0.2.1...v0.2.2) (2024-07-02)


Expand Down
9 changes: 8 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "runehook"
version = "0.2.2"
version = "0.3.0-beta.5"
edition = "2021"

[[bin]]
Expand Down Expand Up @@ -32,6 +32,7 @@ tokio-postgres = "0.7.10"
tokio = { version = "1.38.0", features = ["rt-multi-thread", "macros"] }
refinery = { version = "0.8", features = ["tokio-postgres"] }
num-traits = "0.2.14"
maplit = "1.0.2"

[dev-dependencies]
test-case = "3.1.0"
Expand Down
4 changes: 2 additions & 2 deletions api/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 5 additions & 2 deletions api/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@hirosystems/runes-api",
"version": "0.2.2",
"version": "0.3.0-beta.5",
"description": "",
"main": "index.js",
"scripts": {
Expand All @@ -14,7 +14,10 @@
"generate:vercel": "npm run generate:git-info && npm run generate:openapi && npm run generate:docs",
"lint:eslint": "eslint . --ext .ts,.tsx -f unix",
"lint:prettier": "prettier --check src/**/*.ts tests/**/*.ts",
"lint:unused-exports": "ts-unused-exports tsconfig.json --showLineNumber --excludePathsFromReport=util/*"
"lint:unused-exports": "ts-unused-exports tsconfig.json --showLineNumber --excludePathsFromReport=util/*",
"testenv:run": "docker-compose -f ../docker/docker-compose.dev.postgres.yml up",
"testenv:stop": "docker-compose -f ../docker/docker-compose.dev.postgres.yml down -v -t 0",
"testenv:logs": "docker-compose -f ../docker/docker-compose.dev.postgres.yml logs -t -f"
},
"author": "Hiro Systems PBC <[email protected]> (https://hiro.so)",
"license": "Apache 2.0",
Expand Down
43 changes: 41 additions & 2 deletions api/src/api/routes/addresses.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,14 @@ import { TypeBoxTypeProvider } from '@fastify/type-provider-typebox';
import { Type } from '@sinclair/typebox';
import { FastifyPluginCallback } from 'fastify';
import { Server } from 'http';
import { AddressSchema, LimitSchema, OffsetSchema, BalanceResponseSchema } from '../schemas';
import { parseBalanceResponse } from '../util/helpers';
import {
AddressSchema,
LimitSchema,
OffsetSchema,
BalanceResponseSchema,
ActivityResponseSchema,
} from '../schemas';
import { parseActivityResponse, parseBalanceResponse } from '../util/helpers';
import { Optional, PaginatedResponse } from '@hirosystems/api-toolkit';
import { handleCache } from '../util/cache';

Expand Down Expand Up @@ -47,5 +53,38 @@ export const AddressRoutes: FastifyPluginCallback<
}
);

fastify.get(
'/addresses/:address/activity',
{
schema: {
operationId: 'getAddressActivity',
summary: 'Address activity',
description: 'Retrieves a paginated list of rune activity for an address',
tags: ['Activity'],
params: Type.Object({
address: AddressSchema,
}),
querystring: Type.Object({
offset: Optional(OffsetSchema),
limit: Optional(LimitSchema),
}),
response: {
200: PaginatedResponse(ActivityResponseSchema, 'Paginated activity response'),
},
},
},
async (request, reply) => {
const offset = request.query.offset ?? 0;
const limit = request.query.limit ?? 20;
const results = await fastify.db.getAddressActivity(request.params.address, offset, limit);
await reply.send({
limit,
offset,
total: results.total,
results: results.results.map(r => parseActivityResponse(r)),
});
}
);

done();
};
2 changes: 1 addition & 1 deletion api/src/api/routes/blocks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export const BlockRoutes: FastifyPluginCallback<
operationId: 'getBlockActivity',
summary: 'Block activity',
description: 'Retrieves a paginated list of rune activity for a block',
tags: ['Activities'],
tags: ['Activity'],
params: Type.Object({
block: BlockSchema,
}),
Expand Down
8 changes: 4 additions & 4 deletions api/src/api/routes/etchings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export const EtchingRoutes: FastifyPluginCallback<
async (request, reply) => {
const offset = request.query.offset ?? 0;
const limit = request.query.limit ?? 20;
const results = await fastify.db.getEtchings(offset, limit);
const results = await fastify.db.getRuneEtchings(offset, limit);
await reply.send({
limit,
offset,
Expand Down Expand Up @@ -72,7 +72,7 @@ export const EtchingRoutes: FastifyPluginCallback<
},
},
async (request, reply) => {
const rune = await fastify.db.getEtching(request.params.etching);
const rune = await fastify.db.getRuneEtching(request.params.etching);
if (!rune) {
await reply.code(404).send(Value.Create(NotFoundResponse));
} else {
Expand All @@ -88,7 +88,7 @@ export const EtchingRoutes: FastifyPluginCallback<
operationId: 'getRuneActivity',
summary: 'Rune activity',
description: 'Retrieves all activity for a Rune',
tags: ['Activities'],
tags: ['Activity'],
params: Type.Object({
etching: RuneSchema,
}),
Expand Down Expand Up @@ -121,7 +121,7 @@ export const EtchingRoutes: FastifyPluginCallback<
operationId: 'getRuneAddressActivity',
summary: 'Rune activity for address',
description: 'Retrieves all activity for a Rune address',
tags: ['Activities'],
tags: ['Activity'],
params: Type.Object({
etching: RuneSchema,
address: AddressSchema,
Expand Down
2 changes: 1 addition & 1 deletion api/src/api/routes/transactions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export const TransactionRoutes: FastifyPluginCallback<
operationId: 'getTransactionActivity',
summary: 'Transaction activity',
description: 'Retrieves a paginated list of rune activity for a transaction',
tags: ['Activities'],
tags: ['Activity'],
params: Type.Object({
tx_id: TransactionIdSchema,
}),
Expand Down
9 changes: 6 additions & 3 deletions api/src/api/schemas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ export const OpenApiSchemaOptions: SwaggerOptions = {
description: 'Rune etchings',
},
{
name: 'Activities',
description: 'Rune activities',
name: 'Activity',
description: 'Rune activity',
},
{
name: 'Balances',
Expand Down Expand Up @@ -61,7 +61,9 @@ const RuneNumberSchema = Type.RegEx(/^[0-9]+$/, { title: 'Rune number' });
export const RuneNumberSchemaCType = TypeCompiler.Compile(RuneNumberSchema);
const RuneNameSchema = Type.RegEx(/^[A-Z]+$/, { title: 'Rune name' });
export const RuneNameSchemaCType = TypeCompiler.Compile(RuneNameSchema);
const RuneSpacedNameSchema = Type.RegEx(/^[A-Z](•[A-Z]+)+$/, { title: 'Rune name with spacers' });
const RuneSpacedNameSchema = Type.RegEx(/^[A-Za-z]+(•[A-Za-z]+)+$/, {
title: 'Rune name with spacers',
});
export const RuneSpacedNameSchemaCType = TypeCompiler.Compile(RuneSpacedNameSchema);

export const RuneSchema = Type.Union([
Expand Down Expand Up @@ -306,6 +308,7 @@ const RuneDetailResponseSchema = Type.Object({
rune: Type.Object(
{
id: RuneIdResponseSchema,
number: RuneNumberResponseSchema,
name: RuneNameResponseSchema,
spaced_name: RuneSpacedNameResponseSchema,
},
Expand Down
Loading

0 comments on commit e78c35e

Please sign in to comment.