-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #125 from embrio-tech/main
20230327 Sprint 29
- Loading branch information
Showing
24 changed files
with
547 additions
and
328 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,9 @@ | ||
export COMPOSE_PROFILES=subql-cfg | ||
export COMPOSE_PROFILES=subql-eth | ||
export DB_USER=postgres | ||
export DB_PASS=postgres | ||
export DB_DATABASE=postgres | ||
export DB_HOST=localhost | ||
export DB_PORT=5432 | ||
export SUBQL_DB_USER=$DB_USER | ||
export SUBQL_DB_PASS=$DB_PASS | ||
export CHAIN_ID="demo" | ||
export CHAIN_ID="centrifuge" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,12 @@ | ||
FROM postgres:12-alpine | ||
FROM postgres:16-alpine | ||
|
||
# Variables needed at runtime to configure postgres and run the initdb scripts | ||
ENV POSTGRES_DB 'postgres' | ||
ENV POSTGRES_USER 'postgres' | ||
ENV POSTGRES_PASSWORD 'postgres' | ||
|
||
# Copy in the load-extensions script | ||
COPY docker/load-extensions.sh /docker-entrypoint-initdb.d/ | ||
COPY docker/load-extensions.sh /docker-entrypoint-initdb.d/ | ||
|
||
# Convert line endings to LF | ||
RUN sed -i 's/\r$//' /docker-entrypoint-initdb.d/load-extensions.sh && chmod +x /docker-entrypoint-initdb.d/load-extensions.sh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import { IPFS_NODE } from '../config' | ||
|
||
export const cid = new RegExp( | ||
'(Qm[1-9A-HJ-NP-Za-km-z]{44,}|b[A-Za-z2-7]{58,}|B[A-Z2-7]{58,}|z[1-9A-HJ-NP-Za-km-z]{48,}|F[0-9A-F]{50,})$' | ||
) | ||
|
||
export async function readIpfs<T extends Record<string, unknown>>(ipfsId: string): Promise<T> { | ||
const uri = `${IPFS_NODE}/ipfs/${ipfsId}` | ||
logger.info(`Fetching ${uri}`) | ||
const response = await fetch(uri, { method: 'GET' }) | ||
return await response.json() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,20 @@ | ||
import { errorHandler } from './errorHandler' | ||
import type { Entity } from '@subql/types-core' | ||
import type { Entity, FieldsExpression } from '@subql/types-core' | ||
|
||
type StoreArgs = Parameters<typeof store.getByField> | ||
|
||
async function _paginatedGetter(entity: StoreArgs[0], field: StoreArgs[1], value: StoreArgs[2]): Promise<Entity[]> { | ||
let results: Entity[] = [] | ||
export async function paginatedGetter<T extends Entity>( | ||
entity: T['_name'], | ||
filter: FieldsExpression<T>[] | ||
): Promise<T[]> { | ||
const results: T[] = [] | ||
const batch = 100 | ||
let amount = 0 | ||
let entities: Entity[] | ||
let entities: T[] | ||
do { | ||
entities = (await store.getByField(entity, field, value, { | ||
entities = (await store.getByField(entity, filter[0][0] as string, filter[0][2], { | ||
// TODO: Revert back to getByFields | ||
offset: amount, | ||
limit: batch, | ||
})) as Entity[] | ||
results = results.concat(entities) | ||
amount += entities.length | ||
} while (entities.length > 0) | ||
return results | ||
})) as T[] | ||
amount = results.push(...entities) | ||
} while (entities.length === batch) | ||
return filter.length > 1 ? results.filter( entity => entity[filter[1][0]] === filter[1][2]) : results | ||
} | ||
export const paginatedGetter = errorHandler(_paginatedGetter) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.