Skip to content

Commit

Permalink
chore: merge from master (#380)
Browse files Browse the repository at this point in the history
  • Loading branch information
rafaelcr authored Sep 17, 2024
1 parent ced2cd0 commit 2ea16aa
Show file tree
Hide file tree
Showing 20 changed files with 461 additions and 322 deletions.
22 changes: 22 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
],
"outputCapture": "std",
"internalConsoleOptions": "openOnSessionStart",
"envFile": "${workspaceFolder}/.env",
"env": {
"NODE_ENV": "development",
"TS_NODE_SKIP_IGNORE": "true"
Expand All @@ -33,6 +34,7 @@
],
"outputCapture": "std",
"internalConsoleOptions": "openOnSessionStart",
"envFile": "${workspaceFolder}/.env",
"env": {
"NODE_ENV": "development",
"TS_NODE_SKIP_IGNORE": "true",
Expand All @@ -53,13 +55,33 @@
],
"outputCapture": "std",
"internalConsoleOptions": "openOnSessionStart",
"envFile": "${workspaceFolder}/.env",
"env": {
"NODE_ENV": "development",
"TS_NODE_SKIP_IGNORE": "true",
"RUN_MODE": "writeonly"
},
"killBehavior": "polite",
},
{
"type": "node",
"request": "launch",
"name": "Run: debug server",
"runtimeArgs": [
"-r",
"ts-node/register"
],
"args": [
"${workspaceFolder}/util/debug-server.ts"
],
"outputCapture": "std",
"internalConsoleOptions": "openOnSessionStart",
"env": {
"NODE_ENV": "development",
"TS_NODE_SKIP_IGNORE": "true",
},
"killBehavior": "polite",
},
{
"type": "node",
"request": "launch",
Expand Down
74 changes: 74 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,77 @@
## [4.0.4](https://github.com/hirosystems/ordinals-api/compare/v4.0.3...v4.0.4) (2024-06-17)


### Bug Fixes

* select correct block hash upon migration ([#366](https://github.com/hirosystems/ordinals-api/issues/366)) ([aea1a19](https://github.com/hirosystems/ordinals-api/commit/aea1a19463e82e7fa1f2574df0730a2626eeacc4))

## [4.0.3](https://github.com/hirosystems/ordinals-api/compare/v4.0.2...v4.0.3) (2024-06-17)


### Bug Fixes

* add output to current locations and block_hash to inscriptions ([#365](https://github.com/hirosystems/ordinals-api/issues/365)) ([3d75deb](https://github.com/hirosystems/ordinals-api/commit/3d75deb664906eb1c4392ab18d5c77332047a875))

## [4.0.2](https://github.com/hirosystems/ordinals-api/compare/v4.0.1...v4.0.2) (2024-06-16)


### Bug Fixes

* optimize brc-20 activity query ([#362](https://github.com/hirosystems/ordinals-api/issues/362)) ([e8a4fea](https://github.com/hirosystems/ordinals-api/commit/e8a4fea29a49cf55bd2291c2bf8349a756130028))

## [4.0.1](https://github.com/hirosystems/ordinals-api/compare/v4.0.0...v4.0.1) (2024-06-16)


### Bug Fixes

* optimize base inscriptions query ([#364](https://github.com/hirosystems/ordinals-api/issues/364)) ([cbcc830](https://github.com/hirosystems/ordinals-api/commit/cbcc830a675e5c4dcd29650f1d5e8783ce096989))

## [4.0.0](https://github.com/hirosystems/ordinals-api/compare/v3.1.0...v4.0.0) (2024-06-11)


### ⚠ BREAKING CHANGES

* support reinscription transfers (#348)
* ingest BRC20 data from ordhook (#347)

### Features

* ingest BRC20 data from ordhook ([#347](https://github.com/hirosystems/ordinals-api/issues/347)) ([56a8851](https://github.com/hirosystems/ordinals-api/commit/56a88518b1ffe549524941e4d94d6347d11c98f3))
* return `parent` and `metadata` in inscription responses ([#350](https://github.com/hirosystems/ordinals-api/issues/350)) ([939286e](https://github.com/hirosystems/ordinals-api/commit/939286e3a036063835206c533ce7f9a66cee0ba7))
* support reinscription transfers ([#348](https://github.com/hirosystems/ordinals-api/issues/348)) ([5422156](https://github.com/hirosystems/ordinals-api/commit/5422156e9919f0c5870c9571ea9f591852c98b69))


### Bug Fixes

* detect block gaps when streaming from ordhook ([#349](https://github.com/hirosystems/ordinals-api/issues/349)) ([3c1480f](https://github.com/hirosystems/ordinals-api/commit/3c1480f5bfb8bec4993fffd50245c345d71cdf08))
* ordhook ingestion ([#356](https://github.com/hirosystems/ordinals-api/issues/356)) ([dfc003e](https://github.com/hirosystems/ordinals-api/commit/dfc003ee65198a35bac1e0fc723068bde90c63c4))

## [4.0.0-beta.2](https://github.com/hirosystems/ordinals-api/compare/v4.0.0-beta.1...v4.0.0-beta.2) (2024-06-11)


### Bug Fixes

* ordhook ingestion ([#356](https://github.com/hirosystems/ordinals-api/issues/356)) ([dfc003e](https://github.com/hirosystems/ordinals-api/commit/dfc003ee65198a35bac1e0fc723068bde90c63c4))

## [4.0.0-beta.1](https://github.com/hirosystems/ordinals-api/compare/v3.1.0...v4.0.0-beta.1) (2024-04-26)


### ⚠ BREAKING CHANGES

* support reinscription transfers (#348)
* ingest BRC20 data from ordhook (#347)

### Features

* ingest BRC20 data from ordhook ([#347](https://github.com/hirosystems/ordinals-api/issues/347)) ([56a8851](https://github.com/hirosystems/ordinals-api/commit/56a88518b1ffe549524941e4d94d6347d11c98f3))
* return `parent` and `metadata` in inscription responses ([#350](https://github.com/hirosystems/ordinals-api/issues/350)) ([939286e](https://github.com/hirosystems/ordinals-api/commit/939286e3a036063835206c533ce7f9a66cee0ba7))
* support reinscription transfers ([#348](https://github.com/hirosystems/ordinals-api/issues/348)) ([5422156](https://github.com/hirosystems/ordinals-api/commit/5422156e9919f0c5870c9571ea9f591852c98b69))


### Bug Fixes

* detect block gaps when streaming from ordhook ([#349](https://github.com/hirosystems/ordinals-api/issues/349)) ([3c1480f](https://github.com/hirosystems/ordinals-api/commit/3c1480f5bfb8bec4993fffd50245c345d71cdf08))

## [3.1.0](https://github.com/hirosystems/ordinals-api/compare/v3.0.1...v3.1.0) (2024-04-23)


Expand Down
7 changes: 2 additions & 5 deletions migrations/1676395230930_inscriptions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ export function up(pgm: MigrationBuilder): void {
},
address: {
type: 'text',
notNull: true,
},
mime_type: {
type: 'text',
Expand Down Expand Up @@ -89,11 +90,6 @@ export function up(pgm: MigrationBuilder): void {
},
});
pgm.createConstraint('inscriptions', 'inscriptions_number_unique', 'UNIQUE(number)');
pgm.createConstraint(
'inscriptions',
'inscriptions_ordinal_number_fk',
'FOREIGN KEY(ordinal_number) REFERENCES satoshis(ordinal_number) ON DELETE CASCADE'
);
pgm.createIndex('inscriptions', ['mime_type']);
pgm.createIndex('inscriptions', ['recursive']);
pgm.createIndex('inscriptions', [
Expand All @@ -102,4 +98,5 @@ export function up(pgm: MigrationBuilder): void {
]);
pgm.createIndex('inscriptions', ['address']);
pgm.createIndex('inscriptions', [{ name: 'updated_at', sort: 'DESC' }]);
pgm.createIndex('inscriptions', ['ordinal_number']);
}
6 changes: 1 addition & 5 deletions migrations/1677284495299_locations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ export function up(pgm: MigrationBuilder): void {
},
address: {
type: 'text',
notNull: true,
},
output: {
type: 'text',
Expand Down Expand Up @@ -57,11 +58,6 @@ export function up(pgm: MigrationBuilder): void {
pgm.createConstraint('locations', 'locations_pkey', {
primaryKey: ['ordinal_number', 'block_height', 'tx_index'],
});
pgm.createConstraint(
'locations',
'locations_ordinal_number_fk',
'FOREIGN KEY(ordinal_number) REFERENCES satoshis(ordinal_number) ON DELETE CASCADE'
);
pgm.createIndex('locations', ['output', 'offset']);
pgm.createIndex('locations', ['timestamp']);
pgm.createIndex('locations', [
Expand Down
12 changes: 2 additions & 10 deletions migrations/1677284495500_current-locations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,10 @@ export function up(pgm: MigrationBuilder): void {
},
address: {
type: 'text',
notNull: true,
},
});
pgm.createConstraint(
'current_locations',
'current_locations_locations_fk',
'FOREIGN KEY(ordinal_number, block_height, tx_index) REFERENCES locations(ordinal_number, block_height, tx_index) ON DELETE CASCADE'
);
pgm.createConstraint(
'locations',
'locations_satoshis_fk',
'FOREIGN KEY(ordinal_number) REFERENCES satoshis(ordinal_number) ON DELETE CASCADE'
);
pgm.createIndex('current_locations', ['ordinal_number'], { unique: true });
pgm.createIndex('current_locations', ['address']);
pgm.createIndex('current_locations', ['block_height', 'tx_index']);
}
10 changes: 0 additions & 10 deletions migrations/1677284495501_inscription-transfers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,16 +37,6 @@ export function up(pgm: MigrationBuilder): void {
pgm.createConstraint('inscription_transfers', 'inscription_transfers_pkey', {
primaryKey: ['block_height', 'block_transfer_index'],
});
pgm.createConstraint(
'inscription_transfers',
'inscription_transfers_locations_fk',
'FOREIGN KEY(ordinal_number, block_height, tx_index) REFERENCES locations(ordinal_number, block_height, tx_index) ON DELETE CASCADE'
);
pgm.createConstraint(
'inscription_transfers',
'inscription_transfers_satoshis_fk',
'FOREIGN KEY(ordinal_number) REFERENCES satoshis(ordinal_number) ON DELETE CASCADE'
);
pgm.createIndex('inscription_transfers', ['genesis_id']);
pgm.createIndex('inscription_transfers', ['number']);
}
26 changes: 26 additions & 0 deletions migrations/1718498685557_inscriptions-block-hash.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/* eslint-disable @typescript-eslint/naming-convention */
import { MigrationBuilder, ColumnDefinitions } from 'node-pg-migrate';

export const shorthands: ColumnDefinitions | undefined = undefined;

export function up(pgm: MigrationBuilder): void {
pgm.addColumn('inscriptions', {
block_hash: {
type: 'text',
},
});
pgm.sql(`
UPDATE inscriptions SET block_hash = (
SELECT block_hash FROM locations AS l
WHERE l.ordinal_number = ordinal_number
AND l.block_height = block_height
AND l.tx_index = tx_index
LIMIT 1
)
`);
pgm.alterColumn('inscriptions', 'block_hash', { notNull: true });
}

export function down(pgm: MigrationBuilder): void {
pgm.dropColumn('inscriptions', 'block_hash');
}
26 changes: 26 additions & 0 deletions migrations/1718498703916_current-locations-output.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/* eslint-disable @typescript-eslint/naming-convention */
import { MigrationBuilder, ColumnDefinitions } from 'node-pg-migrate';

export const shorthands: ColumnDefinitions | undefined = undefined;

export function up(pgm: MigrationBuilder): void {
pgm.addColumn('current_locations', {
output: {
type: 'text',
},
});
pgm.sql(`
UPDATE current_locations SET output = (
SELECT output FROM locations AS l
WHERE l.ordinal_number = ordinal_number
AND l.block_height = block_height
AND l.tx_index = tx_index
LIMIT 1
)
`);
pgm.alterColumn('current_locations', 'output', { notNull: true });
}

export function down(pgm: MigrationBuilder): void {
pgm.dropColumn('current_locations', 'output');
}
28 changes: 14 additions & 14 deletions package-lock.json

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

6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"build": "rimraf ./dist && tsc --project tsconfig.build.json",
"start": "node dist/src/index.js",
"start-ts": "ts-node ./src/index.ts",
"start:debug-server": "node dist/util/debug-server.js",
"start:debug-server": "ts-node ./util/debug-server.ts",
"test": "jest --runInBand",
"test:brc-20": "npm run test -- ./tests/brc-20/",
"test:api": "npm run test -- ./tests/api/",
Expand Down Expand Up @@ -56,8 +56,8 @@
"@fastify/multipart": "^7.1.0",
"@fastify/swagger": "^8.3.1",
"@fastify/type-provider-typebox": "^3.2.0",
"@hirosystems/api-toolkit": "^1.7.0",
"@hirosystems/chainhook-client": "^1.8.0",
"@hirosystems/api-toolkit": "^1.7.1",
"@hirosystems/chainhook-client": "^1.12.0",
"@semantic-release/changelog": "^6.0.3",
"@semantic-release/commit-analyzer": "^10.0.4",
"@semantic-release/git": "^10.0.1",
Expand Down
6 changes: 4 additions & 2 deletions src/env.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@ const schema = Type.Object({
ORDHOOK_NODE_RPC_PORT: Type.Number({ default: 20456, minimum: 0, maximum: 65535 }),
/**
* Authorization token that the ordhook node must send with every event to make sure it's
* coming from the valid instance
* coming from the valid instance. Leave it undefined if you wish to avoid header validation.
*/
ORDHOOK_NODE_AUTH_TOKEN: Type.String(),
ORDHOOK_NODE_AUTH_TOKEN: Type.Optional(Type.String()),
/**
* Register ordhook predicates automatically when the API is first launched. Set this to `false`
* if you're configuring your predicates manually for any reason.
Expand All @@ -55,6 +55,8 @@ const schema = Type.Object({
{ default: 'default', replay: 'replay' },
{ default: 'default' }
),
/** If the API should automatically shut down when Ordhook ingestion mode is `replay` */
ORDHOOK_REPLAY_INGESTION_MODE_AUTO_SHUTDOWN: Type.Boolean({ default: true }),

PGHOST: Type.String(),
PGPORT: Type.Number({ default: 5432, minimum: 0, maximum: 65535 }),
Expand Down
Loading

0 comments on commit 2ea16aa

Please sign in to comment.