feat: surface stack versions in app footer
This commit is contained in:
parent
beea5f67f9
commit
d8119da65b
13 changed files with 480 additions and 49 deletions
|
|
@ -17,6 +17,8 @@ type Meta {
|
|||
}
|
||||
|
||||
type Query {
|
||||
stackMeta(id: String!): stackMeta
|
||||
stackMetas(where: stackMetaFilter, orderBy: String, orderDirection: String, before: String, after: String, limit: Int): stackMetaPage!
|
||||
stats(id: String!): stats
|
||||
statss(where: statsFilter, orderBy: String, orderDirection: String, before: String, after: String, limit: Int): statsPage!
|
||||
positions(id: String!): positions
|
||||
|
|
@ -24,6 +26,69 @@ type Query {
|
|||
_meta: Meta
|
||||
}
|
||||
|
||||
type stackMeta {
|
||||
id: String!
|
||||
contractVersion: Int!
|
||||
ponderVersion: String!
|
||||
kraikenLibVersion: Int!
|
||||
updatedAt: BigInt!
|
||||
}
|
||||
|
||||
type stackMetaPage {
|
||||
items: [stackMeta!]!
|
||||
pageInfo: PageInfo!
|
||||
totalCount: Int!
|
||||
}
|
||||
|
||||
input stackMetaFilter {
|
||||
AND: [stackMetaFilter]
|
||||
OR: [stackMetaFilter]
|
||||
id: String
|
||||
id_not: String
|
||||
id_in: [String]
|
||||
id_not_in: [String]
|
||||
id_contains: String
|
||||
id_not_contains: String
|
||||
id_starts_with: String
|
||||
id_ends_with: String
|
||||
id_not_starts_with: String
|
||||
id_not_ends_with: String
|
||||
contractVersion: Int
|
||||
contractVersion_not: Int
|
||||
contractVersion_in: [Int]
|
||||
contractVersion_not_in: [Int]
|
||||
contractVersion_gt: Int
|
||||
contractVersion_lt: Int
|
||||
contractVersion_gte: Int
|
||||
contractVersion_lte: Int
|
||||
ponderVersion: String
|
||||
ponderVersion_not: String
|
||||
ponderVersion_in: [String]
|
||||
ponderVersion_not_in: [String]
|
||||
ponderVersion_contains: String
|
||||
ponderVersion_not_contains: String
|
||||
ponderVersion_starts_with: String
|
||||
ponderVersion_ends_with: String
|
||||
ponderVersion_not_starts_with: String
|
||||
ponderVersion_not_ends_with: String
|
||||
kraikenLibVersion: Int
|
||||
kraikenLibVersion_not: Int
|
||||
kraikenLibVersion_in: [Int]
|
||||
kraikenLibVersion_not_in: [Int]
|
||||
kraikenLibVersion_gt: Int
|
||||
kraikenLibVersion_lt: Int
|
||||
kraikenLibVersion_gte: Int
|
||||
kraikenLibVersion_lte: Int
|
||||
updatedAt: BigInt
|
||||
updatedAt_not: BigInt
|
||||
updatedAt_in: [BigInt]
|
||||
updatedAt_not_in: [BigInt]
|
||||
updatedAt_gt: BigInt
|
||||
updatedAt_lt: BigInt
|
||||
updatedAt_gte: BigInt
|
||||
updatedAt_lte: BigInt
|
||||
}
|
||||
|
||||
type stats {
|
||||
id: String!
|
||||
kraikenTotalSupply: BigInt!
|
||||
|
|
@ -428,4 +493,4 @@ input positionsFilter {
|
|||
payout_lt: BigInt
|
||||
payout_gte: BigInt
|
||||
payout_lte: BigInt
|
||||
}
|
||||
}
|
||||
|
|
@ -4,6 +4,26 @@ import { TAX_RATE_OPTIONS } from 'kraiken-lib/taxRates';
|
|||
export const HOURS_IN_RING_BUFFER = 168; // 7 days * 24 hours
|
||||
const RING_BUFFER_SEGMENTS = 4; // ubi, minted, burned, tax
|
||||
|
||||
export const stackMeta = onchainTable('stackMeta', t => ({
|
||||
id: t.text().primaryKey(),
|
||||
contractVersion: t
|
||||
.integer()
|
||||
.notNull()
|
||||
.$default(() => 0),
|
||||
ponderVersion: t
|
||||
.text()
|
||||
.notNull()
|
||||
.$default(() => 'unknown'),
|
||||
kraikenLibVersion: t
|
||||
.integer()
|
||||
.notNull()
|
||||
.$default(() => 0),
|
||||
updatedAt: t
|
||||
.bigint()
|
||||
.notNull()
|
||||
.$default(() => 0n),
|
||||
}));
|
||||
|
||||
// Global protocol stats - singleton with id "0x01"
|
||||
export const stats = onchainTable('stats', t => ({
|
||||
id: t.text().primaryKey(), // Always "0x01"
|
||||
|
|
|
|||
|
|
@ -1,6 +1,11 @@
|
|||
import { isCompatibleVersion, getVersionMismatchError, KRAIKEN_LIB_VERSION } from 'kraiken-lib/version';
|
||||
import { createRequire } from 'node:module';
|
||||
import { isCompatibleVersion, getVersionMismatchError, KRAIKEN_LIB_VERSION, STACK_META_ID } from 'kraiken-lib/version';
|
||||
import { stackMeta } from 'ponder:schema';
|
||||
import type { Context } from 'ponder:registry';
|
||||
|
||||
const require = createRequire(import.meta.url);
|
||||
const { version: PONDER_APP_VERSION } = require('../../package.json') as { version: string };
|
||||
|
||||
/**
|
||||
* Validates that the deployed Kraiken contract version is compatible
|
||||
* with this indexer's kraiken-lib version.
|
||||
|
|
@ -25,6 +30,24 @@ export async function validateContractVersion(context: Context): Promise<void> {
|
|||
process.exit(1);
|
||||
}
|
||||
|
||||
const timestamp = BigInt(Math.floor(Date.now() / 1000));
|
||||
const metaPayload = {
|
||||
contractVersion: versionNumber,
|
||||
ponderVersion: PONDER_APP_VERSION ?? 'dev',
|
||||
kraikenLibVersion: KRAIKEN_LIB_VERSION,
|
||||
updatedAt: timestamp,
|
||||
};
|
||||
|
||||
const existingMeta = await context.db.find(stackMeta, { id: STACK_META_ID });
|
||||
if (existingMeta) {
|
||||
await context.db.update(stackMeta, { id: STACK_META_ID }).set(metaPayload);
|
||||
} else {
|
||||
await context.db.insert(stackMeta).values({
|
||||
id: STACK_META_ID,
|
||||
...metaPayload,
|
||||
});
|
||||
}
|
||||
|
||||
logger.info(`✓ Contract version validated: v${versionNumber} (kraiken-lib v${KRAIKEN_LIB_VERSION})`);
|
||||
} catch (error) {
|
||||
logger.error('Failed to read contract VERSION:', error);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue