Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 | 1x 1x 1x 1x 2x 1x 1x 1x 1x 1x 1x 1x 1x | import { DataSource } from 'typeorm';
import {
HandleEntity,
HandleMetadataEntity,
PgConnectionConfig,
createDataSource
} from '@cardano-sdk/projection-typeorm';
import { Observable, firstValueFrom } from 'rxjs';
import { getEntities } from '../../src';
import { logger } from '@cardano-sdk/util-dev';
const queryHandle = (dataSource: DataSource) => dataSource.createQueryBuilder().from(HandleEntity, 'h');
export const createHandleFixtures = async (connectionConfig$: Observable<PgConnectionConfig>) => {
const entities = getEntities(['handle', 'handleMetadata']);
const dataSource = createDataSource({ connectionConfig: await firstValueFrom(connectionConfig$), entities, logger });
await dataSource.initialize();
const cip25HandleEntity = await queryHandle(dataSource)
.innerJoin(HandleMetadataEntity, 'm', 'm.handle=h.handle')
.where('h.cardano_address IS NOT NULL AND m.output_id IS NULL')
.getRawOne<HandleEntity>();
const handleWithProfileAndBackgroundPicsEntity = await queryHandle(dataSource)
.innerJoin(HandleMetadataEntity, 'm', 'm.handle=h.handle')
.where('h.cardano_address IS NOT NULL AND m.background_image IS NOT NULL AND m.profile_pic_image IS NOT NULL')
.getRawOne<HandleEntity>();
await dataSource.destroy();
return {
cip25Handle: cip25HandleEntity!.handle!,
handleWithProfileAndBackgroundPics: handleWithProfileAndBackgroundPicsEntity!.handle!
};
};
type PromiseT<P> = P extends Promise<infer T> ? T : never;
export type HandleFixtures = PromiseT<ReturnType<typeof createHandleFixtures>>;
|