Skip to content

Commit cb2a274

Browse files
committed
refactor: use default argument
1 parent 09ba5a1 commit cb2a274

File tree

4 files changed

+16
-21
lines changed

4 files changed

+16
-21
lines changed

src/helpers/spaceValidation.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ const DEFAULT_SNAPSHOT_ENV: string = 'testnet';
66

77
export async function validateSpaceSettings(
88
originalSpace: any,
9-
snapshotEnv = DEFAULT_SNAPSHOT_ENV
9+
snapshotEnv = process.env.NETWORK ?? DEFAULT_SNAPSHOT_ENV
1010
): Promise<void> {
1111
const spaceType = originalSpace.turbo ? 'turbo' : 'default';
1212
const space = snapshot.utils.clone(originalSpace);

src/writer/proposal.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ async function validateSpace(space: any) {
6565
return Promise.reject('space hibernated');
6666
}
6767

68-
await validateSpaceSettings(space, process.env.NETWORK);
68+
await validateSpaceSettings(space);
6969
}
7070

7171
export async function verify(body): Promise<any> {

src/writer/settings.ts

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -23,15 +23,12 @@ export async function verify(body): Promise<any> {
2323
const space = await getSpace(msg.space, true);
2424

2525
try {
26-
await validateSpaceSettings(
27-
{
28-
...msg.payload,
29-
id: msg.space,
30-
deleted: space?.deleted,
31-
turbo: space?.turbo
32-
},
33-
process.env.NETWORK
34-
);
26+
await validateSpaceSettings({
27+
...msg.payload,
28+
id: msg.space,
29+
deleted: space?.deleted,
30+
turbo: space?.turbo
31+
});
3532
} catch (e) {
3633
return Promise.reject(e);
3734
}

test/unit/writer/settings.test.ts

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,8 @@ const LIMITS = {
5656
};
5757
const ECOSYSTEM_LIST = ['test.eth', 'snapshot.eth'];
5858

59-
const mockGetSpaceType = jest.fn(async (space: any): Promise<string> => {
59+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
60+
const mockGetSpaceType = jest.fn(async (_space: any): Promise<string> => {
6061
return 'default';
6162
});
6263
jest.mock('../../../src/helpers/options', () => {
@@ -234,15 +235,12 @@ describe('writer/settings', () => {
234235
it('calls validateSpaceSettings with correct parameters', async () => {
235236
await verify(input);
236237

237-
expect(mockValidateSpaceSettings).toHaveBeenCalledWith(
238-
{
239-
...JSON.parse(input.msg).payload,
240-
id: JSON.parse(input.msg).space,
241-
deleted: spacesGetSpaceFixtures.deleted,
242-
turbo: spacesGetSpaceFixtures.turbo
243-
},
244-
'mainnet'
245-
);
238+
expect(mockValidateSpaceSettings).toHaveBeenCalledWith({
239+
...JSON.parse(input.msg).payload,
240+
id: JSON.parse(input.msg).space,
241+
deleted: spacesGetSpaceFixtures.deleted,
242+
turbo: spacesGetSpaceFixtures.turbo
243+
});
246244
});
247245

248246
it('passes when validateSpaceSettings succeeds and strategy count is valid', async () => {

0 commit comments

Comments
 (0)