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

Merge develop to main branch (v2.4.0) #198

Merged
merged 55 commits into from
Jul 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
55 commits
Select commit Hold shift + click to select a range
c6da88d
feat: support bitcoin signnet
ahonn Jun 11, 2024
0d51822
fix: fix typo
ahonn Jun 11, 2024
0bcd6e0
Merge pull request #167 from ckb-cell/feat/btc-signet
ahonn Jun 12, 2024
94bb21d
ci: update deploy github action
ahonn Jun 12, 2024
16dcacc
test: update snapshort
ahonn Jun 12, 2024
cd72f80
Merge pull request #171 from ckb-cell/test/update-snapshort
ahonn Jun 12, 2024
94afee3
Merge pull request #170 from ckb-cell/release/v2.3.1
ahonn Jun 12, 2024
5ba9b87
fix: capture unhandled electrs backuper error (#172)
ahonn Jun 12, 2024
61e9a88
feat: show ckb_address in paymaster info, fill paymaster cell queue w…
ahonn Jun 13, 2024
80af748
test: update paymaster route test
ahonn Jun 13, 2024
80756ca
Merge pull request #176 from ckb-cell/feat/fill-paymaster-cell-queue
Flouse Jun 13, 2024
cd27b56
feat: upgrade rgbpp sdk snap version to support signet
ahonn Jun 13, 2024
5544caf
Merge pull request #177 from ckb-cell/feat/rgbpp-sdk-signet
ahonn Jun 13, 2024
6f3f80c
refactor: improve bitcoin client error handle
ahonn Jun 18, 2024
5b40419
feat: add SAENTRY_IGNORE_UTXO_SYNC_ERROR_ADDRESSES env
ahonn Jun 19, 2024
eb987b6
fix: fix typo
ahonn Jun 19, 2024
424f191
feat: check recent confirmed utxos to void missing pending xudt
ahonn Jun 19, 2024
5dabd30
Merge pull request #179 from ckb-cell/feat/improve-sentry
Flouse Jun 19, 2024
242d9a2
Merge pull request #180 from ckb-cell/166-when-the-ckb-transaction-is…
ahonn Jun 21, 2024
a6b2a32
refactor: optimize rgbpp ckb txhash query by batching requests
ahonn Jun 24, 2024
756ff2c
feat: add activity interface response schema
ahonn Jun 24, 2024
8028bfe
feat: add basic activity impl
ahonn Jun 26, 2024
f39de4c
feat: optimize promise
ahonn Jun 26, 2024
a66a30a
refactor: refactor rgbpp address activity
ahonn Jun 28, 2024
fd3174d
test: add rgbpp activity test
ahonn Jun 28, 2024
3004736
fix: fix unit tests
ahonn Jun 28, 2024
76c2e5f
feat: add cursor response
ahonn Jun 28, 2024
e7f73f3
feat: add type_hash to rgbpp assets routes
ahonn Jul 3, 2024
b858a75
test: update test snapshots
ahonn Jul 3, 2024
355debb
test: update rgbpp service test snapshots
ahonn Jul 3, 2024
f686bc1
feat: rename assets response type_hash -> typeHash
ahonn Jul 4, 2024
954bfa9
Merge pull request #184 from ckb-cell/feat/typehash
Flouse Jul 4, 2024
0e48ff8
fix: add missing typeHash response field to rgbpp address assets route
ahonn Jul 4, 2024
1b05157
Merge pull request #186 from ckb-cell/fix/typehash
ahonn Jul 4, 2024
be3d55a
fix: catch bitcoin fallback data provider error
ahonn Jul 5, 2024
1462c09
Merge pull request #187 from ckb-cell/fix/fallback-error
ahonn Jul 5, 2024
0b341f4
fix: remove app listen error exit 1
ahonn Jul 5, 2024
9e97c1e
Merge pull request #188 from ckb-cell/fix/remove-exit-1
ahonn Jul 5, 2024
cb90dd9
fix: check typescript args hex 0x
ahonn Jul 9, 2024
446b6ac
docs: add get started section to readme
ahonn Jul 9, 2024
f70f85f
Merge pull request #189 from ckb-cell/docs/readme
ahonn Jul 9, 2024
2227393
Merge branch 'develop' into feat/rgbpp-activity
ahonn Jul 10, 2024
8e11561
Merge pull request #182 from ckb-cell/feat/rgbpp-activity
ahonn Jul 10, 2024
d5fcaf3
fix: fixed incorrect filter of L2 to L1 transactions and remove the t…
ahonn Jul 11, 2024
0eeda00
test: update snapshots
ahonn Jul 11, 2024
1887175
Merge pull request #190 from ckb-cell/fix/fix-activity-issue
ahonn Jul 11, 2024
50cd25e
refactor: migrate swagger to use openapi@3.1.0, fixing the oneOf/anyO…
ShookLyngs Jul 11, 2024
10d699e
test: update openapi version check
ShookLyngs Jul 11, 2024
a857c78
Merge pull request #192 from ckb-cell/ref/migrate-to-openapi-3.1
ahonn Jul 12, 2024
b35236f
feat: support spore leap transaction
ahonn Jul 18, 2024
11de67b
feat: check spore transaction witnesses length
ahonn Jul 18, 2024
245f4a3
Merge pull request #195 from ckb-cell/feat/spore-leap
ahonn Jul 18, 2024
9331359
fix: fix spore leap transaction witnesses
ahonn Jul 18, 2024
9a4aee4
Merge pull request #196 from ckb-cell/fix/fix-spore-leap
ahonn Jul 18, 2024
2e9609b
fix: fix queryBtcTimeLockTxByBtcTxId and mark activity api unstable (…
ahonn Jul 19, 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
19 changes: 17 additions & 2 deletions .github/workflows/deploy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ on:
- completed

jobs:
deploy:
deploy-testnet:
runs-on: ubuntu-latest

steps:
- name: Deploy
- name: Deploy Testnet
uses: appleboy/ssh-action@v1.0.3
with:
host: ${{ secrets.SSH_HOST }}
Expand All @@ -26,3 +26,18 @@ jobs:
cd ${{ secrets.SSH_WORK_DIR }}
echo ${{ secrets.PACKAGE_TOKEN }} | docker login ghcr.io -u ${{ github.actor }} --password-stdin
bash ./update.sh
deploy-signet:
runs-on: ubuntu-latest

steps:
- name: Deploy Signet
uses: appleboy/ssh-action@v1.0.3
with:
host: ${{ secrets.SSH_HOST_SIGNET }}
username: ${{ secrets.SSH_USERNAME_SIGNET }}
password: ${{ secrets.PASSWORD }}
key: ${{ secrets.SSH_PRIVATE_KEY }}
script: |
cd ${{ secrets.SSH_WORK_DIR_SIGNET }}
echo ${{ secrets.PACKAGE_TOKEN }} | sudo docker login ghcr.io -u ${{ github.actor }} --password-stdin
bash ./update.sh
2 changes: 1 addition & 1 deletion .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,10 @@ jobs:
BITCOIN_MEMPOOL_SPACE_API_URL: ${{ secrets.BITCOIN_MEMPOOL_SPACE_API_URL }}
BITCOIN_ELECTRS_API_URL: ${{ secrets.BITCOIN_ELECTRS_API_URL }}
BITCOIN_SPV_SERVICE_URL: ${{ secrets.BITCOIN_SPV_SERVICE_URL }}
PAYMASTER_PRIVATE_KEY: ${{ secrets.PAYMASTER_PRIVATE_KEY }}
PAYMASTER_RECEIVE_BTC_ADDRESS: ${{ secrets.PAYMASTER_RECEIVE_BTC_ADDRESS }}
CKB_RPC_URL: ${{ secrets.CKB_RPC_URL }}
CKB_INDEXER_URL: ${{ secrets.CKB_INDEXER_URL }}
PAYMASTER_PRIVATE_KEY: ${{ secrets.PAYMASTER_PRIVATE_KEY }}
REDIS_URL: redis://localhost:6379
CI_REDIS_URL: redis://localhost:6379
run: pnpm test
34 changes: 33 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,38 @@ A service for Retrieving BTC/RGB++ information/assets and processing transaction
- Transaction Handling by posting transactions to the /bitcoin/v1/transaction or /rgbpp/v1/transaction/ckb-tx endpoint
- RGB++ CKB transaction Queue simplifies the RGB++ assets workflows by some cron jobs

## Get started

We provide APIs for testnet and signet for use.

- Testnet: [https://api.testnet.rgbpp.io](https://api.testnet.rgbpp.io/docs)
- Signet: [https://api.signet.rgbpp.io](https://api.signet.rgbpp.io/docs)

For mainnet, API is currently limited to verified apps only.
You can also check the [Deployment](#Deployment) section to deploy your own.

### Get an access token

#### Testnet

You can get a testnet access token through the [/token/generate](https://api.testnet.rgbpp.io/docs/static/index.html#/Token/post_token_generate) API directly.

### Signet

And you can get an access token of BTC Signet network through the [/token/generate](https://api.signet.rgbpp.io/docs/static/index.html#/Token/post_token_generate) API directly.

#### Mainnet

The mainnet is currently limited to verified apps only.

When your app development is ready on testnet, and requires a mainnet access token,
please email us at f@cell.studio to request a mainnet JWT token.

In the email, please provide the following information about your app:

- `name`: Your app name, e.g. "rgbpp-app"
- `domain`: Your app domain, e.g. "rgbpp.app" (without protocol prefix and port suffix)

### Deployment

#### Requirements
Expand Down Expand Up @@ -111,4 +143,4 @@ Use the provided `docker-compose.yml` file to run the service:
docker-compose up
```

after the service is running, you can access the API documentation at `http://localhost:3000/docs`
After the service is running, you can access the API documentation at `http://localhost:3000/docs`
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "btc-assets-api",
"version": "2.3.1",
"version": "2.4.0",
"title": "Bitcoin/RGB++ Assets API",
"description": "",
"main": "index.js",
Expand Down Expand Up @@ -42,9 +42,9 @@
"@fastify/swagger-ui": "^3.0.0",
"@immobiliarelabs/fastify-sentry": "^8.0.1",
"@nervosnetwork/ckb-sdk-utils": "^0.109.1",
"@rgbpp-sdk/btc": "^0.1.0",
"@rgbpp-sdk/ckb": "^0.1.0",
"@rgbpp-sdk/service": "^0.1.0",
"@rgbpp-sdk/btc": "^0.4.0",
"@rgbpp-sdk/ckb": "^0.4.0",
"@rgbpp-sdk/service": "^0.4.0",
"@sentry/node": "^7.102.1",
"@sentry/profiling-node": "^7.102.1",
"async-retry": "^1.3.3",
Expand Down
31 changes: 16 additions & 15 deletions pnpm-lock.yaml

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

10 changes: 9 additions & 1 deletion src/constants.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,18 @@
import { isAdminMode } from './env';
import { BTCTestnetType } from '@rgbpp-sdk/ckb';

export enum NetworkType {
mainnet = 'prod',
mainnet = 'mainnet',
testnet = 'testnet',
signet = 'signet',
}

export const TestnetTypeMap: Record<NetworkType, BTCTestnetType | undefined> = {
[NetworkType.mainnet]: undefined,
[NetworkType.testnet]: 'Testnet3',
[NetworkType.signet]: 'Signet',
};

export const CUSTOM_HEADERS = {
ApiCache: 'x-api-cache',
ResponseCacheable: 'x-response-cacheable',
Expand Down
9 changes: 8 additions & 1 deletion src/env.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const envSchema = z
NODE_ENV: z.string().default('development'),
PORT: z.string().optional(),
ADDRESS: z.string().optional(),
NETWORK: z.enum(['mainnet', 'testnet']).default('testnet'),
NETWORK: z.enum(['mainnet', 'testnet', 'signet']).default('testnet'),
LOGGER_LEVEL: z.enum(['debug', 'info', 'warn', 'error']).default('info'),

/**
Expand Down Expand Up @@ -38,6 +38,13 @@ const envSchema = z
SENTRY_DSN_URL: z.string().optional(),
SENTRY_TRACES_SAMPLE_RATE: z.coerce.number().default(0.5),
SENTRY_PROFILES_SAMPLE_RATE: z.coerce.number().default(0.5),
SENTRY_IGNORE_UTXO_SYNC_ERROR_ADDRESSES: z
.string()
.default('')
.transform((value) => {
const addresses = value.split(',');
return addresses.map((address) => address.trim());
}),

/**
* The rate limit per minute for each IP address.
Expand Down
4 changes: 2 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import process from 'node:process';
import { env } from './env';
import { buildFastify } from './app';
import * as Sentry from '@sentry/node';

const port = parseInt(env.PORT || '3000', 10);
const host = env.ADDRESS || '0.0.0.0';
Expand All @@ -10,7 +10,7 @@ const app = buildFastify();
app.listen({ port, host }, (err, address) => {
if (err) {
console.error(err);
process.exit(1);
Sentry.captureException(err);
}

// eslint-disable-next-line no-console
Expand Down
28 changes: 14 additions & 14 deletions src/plugins/swagger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,36 +11,36 @@ export const DOCS_ROUTE_PREFIX = '/docs';
export default fp(async (fastify) => {
fastify.register(swagger, {
hideUntagged: true,
swagger: {
openapi: {
openapi: '3.1.0',
info: {
title: 'Bitcoin/RGB++ Assets API',
version: pkg.version,
},
consumes: ['application/json'],
produces: ['application/json'],
security: [{ apiKey: [] }],
securityDefinitions: {
apiKey: {
type: 'apiKey',
name: 'Authorization',
in: 'header',
description: 'JWT token for authentication. Example: Bearer <token>',
components: {
securitySchemes: {
apiKey: {
type: 'apiKey',
name: 'Authorization',
in: 'header',
description: 'JWT token for authentication. Example: Bearer <token>',
},
},
},
},
transform: jsonSchemaTransform,
transformObject: ({ swaggerObject }) => {
transformObject: ({ openapiObject }) => {
if (env.NODE_ENV === 'production') {
const { paths = {} } = swaggerObject;
const newPaths = Object.entries(paths).reduce((acc, [path, methods]) => {
const { paths = {} } = openapiObject;
openapiObject.paths = Object.entries(paths).reduce((acc, [path, methods]) => {
if (SWAGGER_PROD_IGNORE_URLS.some((ignorePath) => path.startsWith(ignorePath))) {
return acc;
}
return { ...acc, [path]: methods };
}, {});
swaggerObject.paths = newPaths;
}
return swaggerObject;
return openapiObject;
},
});
fastify.register(swaggerUI, {
Expand Down
Loading
Loading