Skip to content

Commit

Permalink
Revert z.infer to z.input change.
Browse files Browse the repository at this point in the history
  • Loading branch information
jnaviask committed Aug 7, 2024
1 parent d02b724 commit fd53e69
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 19 deletions.
4 changes: 2 additions & 2 deletions libs/core/src/framework/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ export type CommandInput = ZodObject<{
*/
export type CommandContext<Input extends CommandInput> = {
readonly actor: Actor;
readonly payload: z.input<Input>;
readonly payload: z.infer<Input>;
};

/**
Expand All @@ -130,7 +130,7 @@ export type CommandContext<Input extends CommandInput> = {
*/
export type QueryContext<Input extends ZodSchema> = {
readonly actor: Actor;
readonly payload: z.input<Input>;
readonly payload: z.infer<Input>;
};

/**
Expand Down
6 changes: 3 additions & 3 deletions libs/model/src/community/GetMembers.query.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ export function GetMembers(): Query<typeof schemas.GetCommunityMembers> {
order_direction,
} = payload;

const offset = limit! * (cursor! - 1);
const offset = limit * (cursor - 1);
const addresses = allowedAddresses?.split(',').map((a) => a.trim()) ?? [];

const replacements = {
Expand All @@ -129,8 +129,8 @@ export function GetMembers(): Query<typeof schemas.GetCommunityMembers> {

const sql =
search || memberships || addresses.length > 0
? membersSqlWithSearch(cte, orderBy, limit!, offset)
: membersSqlWithoutSearch(orderBy, limit!, offset);
? membersSqlWithSearch(cte, orderBy, limit, offset)
: membersSqlWithoutSearch(orderBy, limit, offset);

const members = await models.sequelize.query<
z.infer<typeof schemas.CommunityMember> & { total?: number }
Expand Down
5 changes: 1 addition & 4 deletions libs/model/src/community/SetCommunityStake.command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,7 @@ export function SetCommunityStake(): Command<typeof schemas.SetCommunityStake> {

// !side effects
const [updated] = await models.CommunityStake.upsert({
stake_id: rest.stake_id,
stake_token: rest.stake_token!,
vote_weight: rest.vote_weight!,
stake_enabled: rest.stake_enabled!,
...rest,
community_id: id.toString(),
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,6 @@ export function CreateContestManagerMetadata(): Command<
const manager = await models.ContestManager.create(
{
...rest,
ticker: rest.ticker!,
decimals: rest.decimals!,
community_id: id.toString(),
created_at: new Date(),
cancelled: false,
Expand Down
4 changes: 2 additions & 2 deletions libs/model/test/community/group-lifecycle.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ describe('Group lifecycle', () => {
test('should fail to query community via has_groups when none exists', async () => {
const communityResults = await query(GetCommunities(), {
actor,
payload: { has_groups: true },
payload: { has_groups: true } as any,
});
expect(communityResults?.results).to.have.length(0);
});
Expand All @@ -71,7 +71,7 @@ describe('Group lifecycle', () => {

const communityResults = await query(GetCommunities(), {
actor,
payload: { has_groups: true },
payload: { has_groups: true } as any,
});
expect(communityResults?.results?.at(0)?.id).to.equal(payload.id);
});
Expand Down
4 changes: 2 additions & 2 deletions libs/model/test/community/stake-lifecycle.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ describe('Stake lifecycle', () => {
test('should query community that has stake enabled', async () => {
const results = await query(GetCommunities(), {
actor,
payload: { stake_enabled: true },
payload: { stake_enabled: true } as any,
});
expect(results?.totalResults).to.eq('1');
expect(results?.results?.at(0)?.id).to.eq(id_with_stake);
Expand Down Expand Up @@ -141,7 +141,7 @@ describe('Stake lifecycle', () => {

const commr = await query(GetCommunities(), {
actor,
payload: { stake_enabled: true },
payload: { stake_enabled: true } as any,
});
expect(commr?.totalResults).to.eq('2');
});
Expand Down
8 changes: 4 additions & 4 deletions libs/model/test/community/tags.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,23 +48,23 @@ describe('Tags', () => {
test('should query all communities when no tag passed', async () => {
const communityResults = await query(GetCommunities(), {
actor,
payload: {},
payload: {} as any,
});
expect(communityResults?.results).to.have.length(3);
});

test('should query both tagged communities with tag 1 provided', async () => {
const communityResults = await query(GetCommunities(), {
actor,
payload: { tag_ids: [tag1Id].join(',') },
payload: { tag_ids: [tag1Id].join(',') } as any,
});
expect(communityResults?.results).to.have.length(2);
});

test('should query single community with tag 1 and 2 provided', async () => {
const communityResults = await query(GetCommunities(), {
actor,
payload: { tag_ids: [tag1Id, tag2Id].join(',') },
payload: { tag_ids: [tag1Id, tag2Id].join(',') } as any,
});
expect(communityResults?.results).to.have.length(1);
});
Expand All @@ -73,7 +73,7 @@ describe('Tags', () => {
try {
await query(GetCommunities(), {
actor,
payload: { tag_ids: 'abkjdgkjsagj,daskgjdsakgjsdg' },
payload: { tag_ids: 'abkjdgkjsagj,daskgjdsakgjsdg' } as any,
});
} catch (e) {
expect((e as Error).message).to.include('Invalid query payload');
Expand Down

0 comments on commit fd53e69

Please sign in to comment.