Skip to content

Commit

Permalink
style: resolve style guide violations
Browse files Browse the repository at this point in the history
  • Loading branch information
oXtxNt9U authored and github-actions[bot] committed Nov 25, 2024
1 parent 94258b3 commit cfc16fd
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 29 deletions.
2 changes: 1 addition & 1 deletion packages/api-database/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,4 @@
"engines": {
"node": ">=20.x"
}
}
}
10 changes: 5 additions & 5 deletions packages/snapshot-legacy/bin/run.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ import path from "path";
import { makeApplication } from "../distribution/application-factory.js";
import { Identifiers } from "../distribution/identifiers.js";

process.env.CORE_DB_HOST="localhost";
process.env.CORE_DB_PORT="5432";
process.env.CORE_DB_DATABASE="test_db";
process.env.CORE_DB_USERNAME="test_db";
process.env.CORE_DB_PASSWORD="password";
process.env.CORE_DB_HOST = "localhost";
process.env.CORE_DB_PORT = "5432";
process.env.CORE_DB_DATABASE = "test_db";
process.env.CORE_DB_USERNAME = "test_db";
process.env.CORE_DB_PASSWORD = "password";

async function run() {
const paths = envPaths("mainsail", { suffix: "" });
Expand Down
12 changes: 6 additions & 6 deletions packages/snapshot-legacy/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,17 +27,17 @@
"@mainsail/kernel": "workspace:*",
"@mainsail/utils": "workspace:*",
"dayjs": "1.11.10",
"pg": "8.13.1",
"typeorm": "0.3.20",
"fs-extra": "11.2.0",
"tmp": "0.2.3"
"pg": "8.13.1",
"tmp": "0.2.3",
"typeorm": "0.3.20"
},
"devDependencies": {
"@types/env-paths": "2.1.0",
"@types/fs-extra": "11.0.4",
"@types/pumpify": "1.4.4",
"@types/pg": "8.11.10",
"@types/pumpify": "1.4.4",
"@types/tmp": "0.2.6",
"@types/env-paths": "2.1.0",
"env-paths": "3.0.0",
"sinon": "^17.0.1",
"uvu": "^0.5.6"
Expand All @@ -50,4 +50,4 @@
"alias": "state"
}
}
}
}
4 changes: 2 additions & 2 deletions packages/snapshot-legacy/source/defaults.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ export const defaults = {
Environment.get(Constants.EnvironmentVariables.CORE_TOKEN),

v3: {
user: "test_db",
password: "test_db",
database: "ark_devnet",
password: "test_db",
user: "test_db",
},
},
};
2 changes: 1 addition & 1 deletion packages/snapshot-legacy/source/identifiers.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
export const Identifiers = {
Application: Symbol.for("Configuration<Application>"),
LogService: Symbol.for("Configuration<Logger>"),
Snapshot: {
Generator: Symbol.for("Snapshot<Generator>"),
},
LogService: Symbol.for("Configuration<Logger>"),
};
2 changes: 1 addition & 1 deletion packages/snapshot-legacy/source/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
export { Generator } from "./snapshot/generator.js";
export * as Interfaces from "./interfaces.js";
export { Generator } from "./snapshot/generator.js";
24 changes: 11 additions & 13 deletions packages/snapshot-legacy/source/snapshot/generator.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import { createHash } from "node:crypto";
import { writeFile } from "node:fs/promises";

import { inject, injectable } from "@mainsail/container";
import { Application, Providers, Utils } from "@mainsail/kernel";
import { Identifiers as InternalIdentifiers } from "../identifiers.js";
import { LegacySnapshot, LegacyWallet } from "../interfaces.js";
import { DataSource } from "typeorm";
import { PostgresConnectionOptions } from "typeorm/driver/postgres/PostgresConnectionOptions.js";

import { createHash } from "node:crypto";
import { writeFile } from "node:fs/promises";
import { Identifiers as InternalIdentifiers } from "../identifiers.js";
import { LegacySnapshot, LegacyWallet } from "../interfaces.js";

interface DatabaseOptions extends PostgresConnectionOptions {
readonly v3: {
Expand Down Expand Up @@ -55,19 +56,16 @@ export class Generator {

const hash = createHash("sha256");

const chainTip = (
await dataSource.query(
"SELECT * FROM dblink('v3_db', 'SELECT id, height FROM blocks ORDER BY height DESC LIMIT 1') AS blocks(id varchar, height bigint);",
)
)[0];

const [chainTip] = await dataSource.query(
"SELECT * FROM dblink('v3_db', 'SELECT id, height FROM blocks ORDER BY height DESC LIMIT 1') AS blocks(id varchar, height bigint);",
);
hash.update(JSON.stringify(chainTip));

// Loop all wallets
const limit = 1000;
let offset = 0;

let wallets: LegacyWallet[] = [];
const wallets: LegacyWallet[] = [];
for (;;) {
const chunk: LegacyWallet[] = await dataSource.query(`
SELECT * FROM dblink(
Expand Down Expand Up @@ -99,15 +97,15 @@ export class Generator {

offset += limit;

if (!chunk.length) {
if (chunk.length === 0) {
break;
}
}

// Write snapshot
const snapshot: LegacySnapshot = {
hash: hash.digest("hex"),
chainTip,
hash: hash.digest("hex"),
wallets,
};

Expand Down

0 comments on commit cfc16fd

Please sign in to comment.