@moneypot/hub 1.14.1 → 1.14.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -43,7 +43,6 @@ export async function getPreimageHash({ hashChainId, }) {
43
43
  }
44
44
  export async function getTerminalHash({ hashChainId, }) {
45
45
  const iterations = config.HASHCHAINSERVER_MAX_ITERATIONS;
46
- console.log(`generating terminal hash with ${iterations} iterations`);
47
46
  const req = {
48
47
  hashchainId: hashChainId,
49
48
  iterations,
@@ -1,8 +1,7 @@
1
- import { withPgClient } from "postgraphile/@dataplan/pg";
2
- import { inhibitOnNull, object } from "postgraphile/grafast";
3
- import { gql, makeExtendSchemaPlugin } from "postgraphile/utils";
4
- import { maybeOneRow } from "../../db/util.js";
5
- export const HubPreimageHashFieldPlugin = makeExtendSchemaPlugin((build) => {
1
+ import { loadOneWithPgClient, } from "postgraphile/@dataplan/pg";
2
+ import { inhibitOnNull } from "postgraphile/grafast";
3
+ import { gql, extendSchema } from "postgraphile/utils";
4
+ export const HubPreimageHashFieldPlugin = extendSchema((build) => {
6
5
  const hashTable = build.input.pgRegistry.pgResources.hub_hash;
7
6
  return {
8
7
  typeDefs: gql `
@@ -14,19 +13,20 @@ export const HubPreimageHashFieldPlugin = makeExtendSchemaPlugin((build) => {
14
13
  HubHashChain: {
15
14
  plans: {
16
15
  preimageHash: ($record) => {
17
- const $preimageHashId = withPgClient(hashTable.executor, object({ hashChainId: $record.get("id") }), async (pgClient, { hashChainId }) => {
18
- const hash = await pgClient
19
- .query({
16
+ const $preimageHashId = loadOneWithPgClient(hashTable.executor, $record.get("id"), async (pgClient, hashChainIds) => {
17
+ const { rows } = await pgClient.query({
20
18
  text: `
21
- select id
22
- from hub.hash
23
- where hash_chain_id = $1
24
- and kind = 'PREIMAGE'
25
- `,
26
- values: [hashChainId],
27
- })
28
- .then(maybeOneRow);
29
- return hash?.id ?? null;
19
+ select id, hash_chain_id
20
+ from hub.hash
21
+ where hash_chain_id = ANY($1)
22
+ and kind = 'PREIMAGE'
23
+ `,
24
+ values: [hashChainIds],
25
+ });
26
+ const lookup = new Map(rows.map((row) => [row.hash_chain_id, row.id]));
27
+ return hashChainIds.map((hashChainId) => {
28
+ return lookup.get(hashChainId) ?? null;
29
+ });
30
30
  });
31
31
  return hashTable.get({ id: inhibitOnNull($preimageHashId) });
32
32
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@moneypot/hub",
3
- "version": "1.14.1",
3
+ "version": "1.14.3",
4
4
  "author": "moneypot.com",
5
5
  "homepage": "https://moneypot.com/hub",
6
6
  "keywords": [
@@ -59,7 +59,7 @@
59
59
  "pg": "^8.12.0",
60
60
  "pg-connection-string": "^2.6.4",
61
61
  "pino": "^9.7.0",
62
- "postgraphile": "^5.0.0-beta.42",
62
+ "postgraphile": "^5.0.0-beta.48",
63
63
  "tsafe": "^1.6.6",
64
64
  "yup": "^1.6.1",
65
65
  "zod": "^3.23.5"