Skip to content

Commit

Permalink
Merge pull request #361 from hirosystems/beta
Browse files Browse the repository at this point in the history
release 4.0.0
  • Loading branch information
rafaelcr committed Jun 11, 2024
2 parents c96336f + d6acea7 commit 3948f87
Show file tree
Hide file tree
Showing 80 changed files with 4,138 additions and 6,649 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@ jobs:
- name: Lint Prettier
run: npm run lint:prettier

- name: Lint Unused Exports
run: npm run lint:unused-exports

test:
strategy:
fail-fast: false
Expand Down
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
26 changes: 26 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,29 @@
## [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
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@ Before you start, you'll need to have access to:

1. An [Ordhook node](https://github.com/hirosystems/ordhook) with a fully
indexed Ordinals database.
1. A local writeable Postgres database for data storage
1. A local writeable Postgres database for data storage.
* We recommended a 1TB volume size here.

## Running the API

Expand Down
22 changes: 22 additions & 0 deletions migrations/1676395230925_satoshis.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/* 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.createTable('satoshis', {
ordinal_number: {
type: 'numeric',
primaryKey: true,
},
rarity: {
type: 'text',
notNull: true,
},
coinbase_height: {
type: 'bigint',
notNull: true,
},
});
pgm.createIndex('satoshis', ['rarity']);
}
47 changes: 34 additions & 13 deletions migrations/1676395230930_inscriptions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,30 +5,34 @@ export const shorthands: ColumnDefinitions | undefined = undefined;

export function up(pgm: MigrationBuilder): void {
pgm.createTable('inscriptions', {
id: {
type: 'bigserial',
primaryKey: true,
},
genesis_id: {
type: 'text',
primaryKey: true,
},
ordinal_number: {
type: 'numeric',
notNull: true,
},
number: {
type: 'bigint',
notNull: true,
},
sat_ordinal: {
type: 'numeric',
classic_number: {
type: 'bigint',
notNull: true,
},
sat_rarity: {
type: 'text',
block_height: {
type: 'bigint',
notNull: true,
},
sat_coinbase_height: {
tx_index: {
type: 'bigint',
notNull: true,
},
address: {
type: 'text',
notNull: true,
},
mime_type: {
type: 'text',
notNull: true,
Expand All @@ -52,17 +56,34 @@ export function up(pgm: MigrationBuilder): void {
curse_type: {
type: 'text',
},
recursive: {
type: 'boolean',
default: false,
},
metadata: {
type: 'text',
},
parent: {
type: 'text',
},
timestamp: {
type: 'timestamptz',
notNull: true,
},
updated_at: {
type: 'timestamptz',
default: pgm.func('(NOW())'),
notNull: true,
},
});
pgm.createConstraint('inscriptions', 'inscriptions_number_unique', 'UNIQUE(number)');
pgm.createIndex('inscriptions', ['genesis_id']);
pgm.createIndex('inscriptions', ['mime_type']);
pgm.createIndex('inscriptions', ['sat_ordinal']);
pgm.createIndex('inscriptions', ['sat_rarity']);
pgm.createIndex('inscriptions', ['sat_coinbase_height']);
pgm.createIndex('inscriptions', ['recursive']);
pgm.createIndex('inscriptions', [
{ name: 'block_height', sort: 'DESC' },
{ name: 'tx_index', sort: 'DESC' },
]);
pgm.createIndex('inscriptions', ['address']);
pgm.createIndex('inscriptions', [{ name: 'updated_at', sort: 'DESC' }]);
pgm.createIndex('inscriptions', ['ordinal_number']);
}
43 changes: 17 additions & 26 deletions migrations/1677284495299_locations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,36 +4,31 @@ import { MigrationBuilder, ColumnDefinitions } from 'node-pg-migrate';
export const shorthands: ColumnDefinitions | undefined = undefined;

export function up(pgm: MigrationBuilder): void {
pgm.createType('transfer_type', ['transferred', 'spent_in_fees', 'burnt']);
pgm.createTable('locations', {
id: {
type: 'bigserial',
primaryKey: true,
},
inscription_id: {
type: 'bigint',
},
genesis_id: {
type: 'text',
ordinal_number: {
type: 'numeric',
notNull: true,
},
block_height: {
type: 'bigint',
notNull: true,
},
block_hash: {
type: 'text',
tx_index: {
type: 'bigint',
notNull: true,
},
tx_id: {
type: 'text',
notNull: true,
},
tx_index: {
type: 'bigint',
block_hash: {
type: 'text',
notNull: true,
},
address: {
type: 'text',
notNull: true,
},
output: {
type: 'text',
Expand All @@ -51,26 +46,22 @@ export function up(pgm: MigrationBuilder): void {
value: {
type: 'numeric',
},
transfer_type: {
type: 'transfer_type',
notNull: true,
},
timestamp: {
type: 'timestamptz',
notNull: true,
},
});
pgm.createConstraint(
'locations',
'locations_inscription_id_fk',
'FOREIGN KEY(inscription_id) REFERENCES inscriptions(id) ON DELETE CASCADE'
);
pgm.createConstraint('locations', 'locations_output_offset_unique', 'UNIQUE(output, "offset")');
pgm.createIndex('locations', ['inscription_id']);
pgm.createConstraint('locations', 'locations_pkey', {
primaryKey: ['ordinal_number', 'block_height', 'tx_index'],
});
pgm.createIndex('locations', ['output', 'offset']);
pgm.createIndex('locations', ['timestamp']);
pgm.createIndex('locations', [
'genesis_id',
{ name: 'block_height', sort: 'DESC' },
{ name: 'tx_index', sort: 'DESC' },
]);
pgm.createIndex('locations', ['block_height']);
pgm.createIndex('locations', ['block_hash']);
pgm.createIndex('locations', ['address']);
pgm.createIndex('locations', ['timestamp']);
pgm.createIndex('locations', ['prev_output']);
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,8 @@ export const shorthands: ColumnDefinitions | undefined = undefined;

export function up(pgm: MigrationBuilder): void {
pgm.createTable('current_locations', {
inscription_id: {
type: 'bigint',
notNull: true,
},
location_id: {
type: 'bigint',
ordinal_number: {
type: 'numeric',
notNull: true,
},
block_height: {
Expand All @@ -23,14 +19,10 @@ export function up(pgm: MigrationBuilder): void {
},
address: {
type: 'text',
notNull: true,
},
});
pgm.createConstraint(
'current_locations',
'current_locations_inscription_id_unique',
'UNIQUE(inscription_id)'
);
pgm.createIndex('current_locations', ['location_id']);
pgm.createIndex('current_locations', ['block_height']);
pgm.createIndex('current_locations', ['ordinal_number'], { unique: true });
pgm.createIndex('current_locations', ['address']);
pgm.createIndex('current_locations', ['block_height', 'tx_index']);
}
42 changes: 42 additions & 0 deletions migrations/1677284495501_inscription-transfers.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/* 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.createTable('inscription_transfers', {
genesis_id: {
type: 'text',
notNull: true,
},
number: {
type: 'bigint',
notNull: true,
},
ordinal_number: {
type: 'numeric',
notNull: true,
},
block_height: {
type: 'bigint',
notNull: true,
},
tx_index: {
type: 'bigint',
notNull: true,
},
block_hash: {
type: 'text',
notNull: true,
},
block_transfer_index: {
type: 'int',
notNull: true,
},
});
pgm.createConstraint('inscription_transfers', 'inscription_transfers_pkey', {
primaryKey: ['block_height', 'block_transfer_index'],
});
pgm.createIndex('inscription_transfers', ['genesis_id']);
pgm.createIndex('inscription_transfers', ['number']);
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import { MigrationBuilder, ColumnDefinitions } from 'node-pg-migrate';
export const shorthands: ColumnDefinitions | undefined = undefined;

export function up(pgm: MigrationBuilder): void {
pgm.dropMaterializedView('chain_tip');
pgm.createTable('chain_tip', {
id: {
type: 'bool',
Expand All @@ -19,20 +18,9 @@ export function up(pgm: MigrationBuilder): void {
},
});
pgm.addConstraint('chain_tip', 'chain_tip_one_row', 'CHECK(id)');
pgm.sql(`
INSERT INTO chain_tip (block_height) (
SELECT GREATEST(MAX(block_height), 767430) AS block_height FROM locations
)
`);
pgm.sql(`INSERT INTO chain_tip DEFAULT VALUES`);
}

export function down(pgm: MigrationBuilder): void {
pgm.dropTable('chain_tip');
pgm.createMaterializedView(
'chain_tip',
{ data: true },
// Set block height 767430 (inscription #0 genesis) as default.
`SELECT GREATEST(MAX(block_height), 767430) AS block_height FROM locations`
);
pgm.createIndex('chain_tip', ['block_height'], { unique: true });
}
Loading

0 comments on commit 3948f87

Please sign in to comment.