Skip to content

Commit

Permalink
Merge pull request #130 from hirosystems/develop
Browse files Browse the repository at this point in the history
release 1.0.0-beta
  • Loading branch information
rafaelcr committed Jul 6, 2023
2 parents 8fad46e + ee66f93 commit 82ae8e0
Show file tree
Hide file tree
Showing 38 changed files with 1,142 additions and 846 deletions.
5 changes: 4 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,10 @@ jobs:
npm run testenv:logs -- --no-color &> docker-compose-logs.txt &
- name: Run tests
run: npm run test
run: npm run test -- --coverage

- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3

- name: Print integration environment logs
run: cat docker-compose-logs.txt
Expand Down
2 changes: 1 addition & 1 deletion docker/docker-compose.dev.postgres.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
version: '3.7'
services:
postgres:
image: "postgres:14"
image: "postgres:15"
ports:
- "5432:5432"
environment:
Expand Down
24 changes: 15 additions & 9 deletions jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,19 @@ module.exports = {
// collectCoverage: false,

// An array of glob patterns indicating a set of files for which coverage information should be collected
// collectCoverageFrom: undefined,
collectCoverageFrom: [
"src/**/*.ts",
"migrations/*.ts",
],

// The directory where Jest should output its coverage files
// coverageDirectory: undefined,

// An array of regexp pattern strings used to skip coverage collection
// coveragePathIgnorePatterns: [
// "/node_modules/"
// ],
coveragePathIgnorePatterns: [
"/node_modules/",
"/src/@types/"
],

// Indicates which provider should be used to instrument code for coverage
coverageProvider: "v8",
Expand Down Expand Up @@ -59,7 +63,7 @@ module.exports = {
// forceCoverageMatch: [],

// A path to a module which exports an async function that is triggered once before all test suites
globalSetup: './setup.ts',
globalSetup: './tests/setup.ts',

// A path to a module which exports an async function that is triggered once after all test suites
// globalTeardown: undefined,
Expand Down Expand Up @@ -121,7 +125,7 @@ module.exports = {
// restoreMocks: false,

// The root directory that Jest should scan for tests and modules within
rootDir: 'tests',
rootDir: '',

// A list of paths to directories that Jest should use to search for files in
// roots: [
Expand Down Expand Up @@ -159,9 +163,11 @@ module.exports = {
// ],

// An array of regexp pattern strings that are matched against all test paths, matched tests are skipped
// testPathIgnorePatterns: [
// "/node_modules/"
// ],
testPathIgnorePatterns: [
"/node_modules/",
"/client/",
"/dist/"
],

// The regexp pattern or array of patterns that Jest uses to detect test files
// testRegex: [],
Expand Down
24 changes: 21 additions & 3 deletions migrations/1676395230930_inscriptions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,27 @@ export const shorthands: ColumnDefinitions | undefined = undefined;
export function up(pgm: MigrationBuilder): void {
pgm.createTable('inscriptions', {
id: {
type: 'serial',
type: 'bigserial',
primaryKey: true,
},
genesis_id: {
type: 'text',
notNull: true,
},
number: {
type: 'int',
type: 'bigint',
notNull: true,
},
sat_ordinal: {
type: 'numeric',
notNull: true,
},
sat_rarity: {
type: 'text',
notNull: true,
},
sat_coinbase_height: {
type: 'bigint',
notNull: true,
},
mime_type: {
Expand All @@ -26,7 +38,7 @@ export function up(pgm: MigrationBuilder): void {
notNull: true,
},
content_length: {
type: 'int',
type: 'bigint',
notNull: true,
},
content: {
Expand All @@ -37,8 +49,14 @@ export function up(pgm: MigrationBuilder): void {
type: 'numeric',
notNull: true,
},
curse_type: {
type: 'text',
},
});
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']);
}
34 changes: 15 additions & 19 deletions migrations/1677284495299_locations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,18 @@ export const shorthands: ColumnDefinitions | undefined = undefined;
export function up(pgm: MigrationBuilder): void {
pgm.createTable('locations', {
id: {
type: 'serial',
type: 'bigserial',
primaryKey: true,
},
inscription_id: {
type: 'int',
type: 'bigint',
},
genesis_id: {
type: 'text',
notNull: true,
},
block_height: {
type: 'int',
type: 'bigint',
notNull: true,
},
block_hash: {
Expand All @@ -35,20 +38,14 @@ export function up(pgm: MigrationBuilder): void {
offset: {
type: 'numeric',
},
value: {
type: 'numeric',
prev_output: {
type: 'text',
},
sat_ordinal: {
prev_offset: {
type: 'numeric',
notNull: true,
},
sat_rarity: {
type: 'text',
notNull: true,
},
sat_coinbase_height: {
type: 'int',
notNull: true,
value: {
type: 'numeric',
},
timestamp: {
type: 'timestamptz',
Expand All @@ -72,15 +69,14 @@ export function up(pgm: MigrationBuilder): void {
);
pgm.createConstraint(
'locations',
'locations_inscription_id_block_height_unique',
'UNIQUE(inscription_id, block_height)'
'locations_genesis_id_block_height_unique',
'UNIQUE(genesis_id, block_height)'
);
pgm.createIndex('locations', ['genesis_id']);
pgm.createIndex('locations', ['block_height']);
pgm.createIndex('locations', ['block_hash']);
pgm.createIndex('locations', ['address']);
pgm.createIndex('locations', ['output']);
pgm.createIndex('locations', ['sat_ordinal']);
pgm.createIndex('locations', ['sat_rarity']);
pgm.createIndex('locations', ['sat_coinbase_height']);
pgm.createIndex('locations', ['timestamp']);
pgm.createIndex('locations', ['prev_output']);
}
27 changes: 7 additions & 20 deletions migrations/1677360299810_chain-tip.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,11 @@ import { MigrationBuilder, ColumnDefinitions } from 'node-pg-migrate';
export const shorthands: ColumnDefinitions | undefined = undefined;

export function up(pgm: MigrationBuilder): void {
pgm.createTable('chain_tip', {
id: {
type: 'bool',
primaryKey: true,
default: true,
},
block_height: {
type: 'int',
notNull: true,
default: 767430, // First inscription block height
},
});
// Ensure only a single row can exist
pgm.addConstraint('chain_tip', 'chain_tip_one_row', 'CHECK(id)');
// Create the single row
pgm.sql('INSERT INTO chain_tip VALUES(DEFAULT)');
}

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 });
}
4 changes: 2 additions & 2 deletions migrations/1679686636818_json-contents.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ export const shorthands: ColumnDefinitions | undefined = undefined;
export function up(pgm: MigrationBuilder): void {
pgm.createTable('json_contents', {
id: {
type: 'serial',
type: 'bigserial',
primaryKey: true,
},
inscription_id: {
type: 'int',
type: 'bigint',
notNull: true,
},
p: {
Expand Down
14 changes: 0 additions & 14 deletions migrations/1682654536767_chain-tip-inscription-count.ts

This file was deleted.

32 changes: 0 additions & 32 deletions migrations/1683042840697_expand-int-sizes.ts

This file was deleted.

1 change: 1 addition & 0 deletions migrations/1683047918926_mime-type-counts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,5 @@ export function up(pgm: MigrationBuilder): void {
{ data: true },
`SELECT mime_type, COUNT(*) AS count FROM inscriptions GROUP BY mime_type`
);
pgm.createIndex('mime_type_counts', ['mime_type'], { unique: true });
}
3 changes: 1 addition & 2 deletions migrations/1683061444855_sat-rarity-counts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,8 @@ export function up(pgm: MigrationBuilder): void {
`
SELECT sat_rarity, COUNT(*) AS count
FROM inscriptions AS i
INNER JOIN locations AS loc ON loc.inscription_id = i.id
WHERE loc.current = TRUE
GROUP BY sat_rarity
`
);
pgm.createIndex('sat_rarity_counts', ['sat_rarity'], { unique: true });
}
1 change: 1 addition & 0 deletions migrations/1683130423352_inscription-count.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,5 @@ export function up(pgm: MigrationBuilder): void {
{ data: true },
`SELECT COUNT(*) AS count FROM inscriptions`
);
pgm.createIndex('inscription_count', ['count'], { unique: true });
}
39 changes: 0 additions & 39 deletions migrations/1683130430977_chain-tip-view.ts

This file was deleted.

16 changes: 0 additions & 16 deletions migrations/1685378650151_prev-location.ts

This file was deleted.

12 changes: 0 additions & 12 deletions migrations/1686170300438_curse-type.ts

This file was deleted.

Loading

0 comments on commit 82ae8e0

Please sign in to comment.