Skip to content

Commit 9d6a2b8

Browse files
committed
fix: treeshakability issues
1 parent 79300c9 commit 9d6a2b8

16 files changed

+138
-1682
lines changed

examples/node-redis/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
"@solana/web3.js": "^1.98.2",
3434
"esrun": "^3.2.26",
3535
"h3": "^1.15.1",
36-
"helius-sdk": "^1.4.2",
36+
"helius-sdk": "^1.5.1",
3737
"ioredis": "^5.5.0",
3838
"listhen": "^1.9.0",
3939
"picocolors": "^1.1.1",

examples/node-redis/src/commands/command-resolver-sync-all.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import { resolve } from './resolve'
99

1010
export const commandResolverSyncAll: Command = {
1111
action: async () => {
12-
const { resolvers, verbose, heliusApiKey } = getConfig()
12+
const { resolvers, heliusApiKey } = getConfig()
1313
const context = getContext()
1414
const startTime = new Date().getTime()
1515
const results: string[] = []

packages/resolver/package.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -74,16 +74,16 @@
7474
"maintained node versions"
7575
],
7676
"dependencies": {
77-
"@solana/kit": "^2.1.0",
78-
"gill": "^0.9.0",
79-
"zod": "^3.24.3"
77+
"valibot": "^1.1.0"
8078
},
8179
"devDependencies": {
82-
"helius-sdk": "^1.4.2",
80+
"helius-sdk": "^1.5.1",
8381
"unstorage": "^1.15.0"
8482
},
8583
"peerDependencies": {
86-
"helius-sdk": "^1.4.2",
84+
"@solana/kit": "^2.1.0",
85+
"gill": "^0.9.0",
86+
"helius-sdk": "^1.5.1",
8787
"typescript": ">=5",
8888
"unstorage": "^1.15.0"
8989
},

packages/resolver/src/__tests__/create-resolver-context-helius-instance-test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { Helius } from 'helius-sdk';
22

33
import { createResolverContextHelius } from '../resolvers/helius/create-resolver-context-helius';
44
import { createResolverContextHeliusInstance } from '../resolvers/helius/create-resolver-context-helius-instance';
5-
import { type ResolverContextHelius } from '../resolvers/helius/types/resolver-context-helius';
5+
import { ResolverContextHelius } from '../resolvers/helius/types/resolver-context-helius';
66

77
describe('create-resolver-context-helius-instance', () => {
88
const heliusApiKey = '00000000-0000-0000-0000-000000000000';

packages/resolver/src/__tests__/create-resolver-context-helius-test.ts

Lines changed: 6 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -68,18 +68,9 @@ describe('create-resolver-context-helius', () => {
6868
const config: ResolverConfigHeliusInput = { heliusApiKey: '00000000000000000000000000000000' };
6969

7070
// ASSERT
71-
expect(() => createResolverContextHelius(config)).toThrowErrorMatchingInlineSnapshot(`
72-
"[
73-
{
74-
"validation": "uuid",
75-
"code": "invalid_string",
76-
"message": "Invalid uuid",
77-
"path": [
78-
"heliusApiKey"
79-
]
80-
}
81-
]"
82-
`);
71+
expect(() => createResolverContextHelius(config)).toThrowErrorMatchingInlineSnapshot(
72+
`"Invalid UUID: Received "00000000000000000000000000000000""`,
73+
);
8374
});
8475

8576
it('should thrown an error with an invalid cluster', () => {
@@ -92,22 +83,9 @@ describe('create-resolver-context-helius', () => {
9283
};
9384

9485
// ASSERT
95-
expect(() => createResolverContextHelius(config)).toThrowErrorMatchingInlineSnapshot(`
96-
"[
97-
{
98-
"received": "testnet",
99-
"code": "invalid_enum_value",
100-
"options": [
101-
"mainnet-beta",
102-
"devnet"
103-
],
104-
"path": [
105-
"heliusCluster"
106-
],
107-
"message": "Invalid enum value. Expected 'mainnet-beta' | 'devnet', received 'testnet'"
108-
}
109-
]"
110-
`);
86+
expect(() => createResolverContextHelius(config)).toThrowErrorMatchingInlineSnapshot(
87+
`"Invalid type: Expected ("mainnet-beta" | "devnet") but received "testnet""`,
88+
);
11189
});
11290
});
11391
});

packages/resolver/src/__tests__/create-resolver-context-solana-client-test.ts

Lines changed: 9 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -69,45 +69,19 @@ describe('create-resolver-context-solana-client', () => {
6969
const config: ResolverConfigSolanaClientInput = { endpoint: 'this is not a url' };
7070

7171
// ASSERT
72-
expect(() => createResolverContextSolanaClient(config)).toThrowErrorMatchingInlineSnapshot(`
73-
"[
74-
{
75-
"validation": "url",
76-
"code": "invalid_string",
77-
"message": "Invalid url",
78-
"path": [
79-
"endpoint"
80-
]
81-
},
82-
{
83-
"validation": "url",
84-
"code": "invalid_string",
85-
"message": "Invalid url",
86-
"path": [
87-
"endpointWs"
88-
]
89-
}
90-
]"
91-
`);
72+
expect(() => createResolverContextSolanaClient(config)).toThrowErrorMatchingInlineSnapshot(
73+
`"Invalid URL: Received "this is not a url""`,
74+
);
9275
});
9376
it('should thrown an error with an invalid endpointWs', () => {
9477
expect.assertions(1);
9578
// ARRANGE
9679
const config: ResolverConfigSolanaClientInput = { endpoint, endpointWs: 'not a ws endpoint' };
9780

9881
// ASSERT
99-
expect(() => createResolverContextSolanaClient(config)).toThrowErrorMatchingInlineSnapshot(`
100-
"[
101-
{
102-
"validation": "url",
103-
"code": "invalid_string",
104-
"message": "Invalid url",
105-
"path": [
106-
"endpointWs"
107-
]
108-
}
109-
]"
110-
`);
82+
expect(() => createResolverContextSolanaClient(config)).toThrowErrorMatchingInlineSnapshot(
83+
`"Invalid URL: Received "not a ws endpoint""`,
84+
);
11185
});
11286

11387
it('should thrown an error with an invalid cluster', () => {
@@ -120,24 +94,9 @@ describe('create-resolver-context-solana-client', () => {
12094
};
12195

12296
// ASSERT
123-
expect(() => createResolverContextSolanaClient(config)).toThrowErrorMatchingInlineSnapshot(`
124-
"[
125-
{
126-
"received": "random",
127-
"code": "invalid_enum_value",
128-
"options": [
129-
"mainnet",
130-
"devnet",
131-
"testnet",
132-
"localnet"
133-
],
134-
"path": [
135-
"cluster"
136-
],
137-
"message": "Invalid enum value. Expected 'mainnet' | 'devnet' | 'testnet' | 'localnet', received 'random'"
138-
}
139-
]"
140-
`);
97+
expect(() => createResolverContextSolanaClient(config)).toThrowErrorMatchingInlineSnapshot(
98+
`"Invalid type: Expected ("mainnet" | "devnet" | "testnet" | "localnet") but received "random""`,
99+
);
141100
});
142101
});
143102
});
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import * as v from 'valibot';
2+
3+
import { ResolverConfigType } from '../../types/resolver-config-type';
4+
5+
export function getResolverConfigHeliusSchema() {
6+
return v.object({
7+
heliusApiKey: v.pipe(v.string(), v.uuid()),
8+
heliusCluster: v.optional(v.union([v.literal('mainnet-beta'), v.literal('devnet')]), 'mainnet-beta'),
9+
type: v.optional(v.literal(ResolverConfigType.Helius), ResolverConfigType.Helius),
10+
});
11+
}

packages/resolver/src/resolvers/helius/resolver-config-helius-schema.ts

Lines changed: 0 additions & 9 deletions
This file was deleted.
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import { z } from 'zod';
1+
import * as v from 'valibot';
22

3-
import { ResolverConfigHeliusSchema } from '../resolver-config-helius-schema';
3+
import { getResolverConfigHeliusSchema } from '../get-resolver-config-helius-schema';
44

5-
export type ResolverConfigHeliusType = z.infer<typeof ResolverConfigHeliusSchema>;
5+
export type ResolverConfigHeliusType = v.InferOutput<ReturnType<typeof getResolverConfigHeliusSchema>>;
Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
1-
import { ResolverConfigHeliusSchema } from './resolver-config-helius-schema';
1+
import * as v from 'valibot';
2+
3+
import { getResolverConfigHeliusSchema } from './get-resolver-config-helius-schema';
24
import { ResolverConfigHelius } from './types/resolver-config-helius';
35
import { ResolverConfigHeliusInput } from './types/resolver-config-helius-input';
46

57
export function validateResolverConfigHelius(input: ResolverConfigHeliusInput): ResolverConfigHelius {
6-
return ResolverConfigHeliusSchema.parse(input);
8+
return v.parse(getResolverConfigHeliusSchema(), input);
79
}

0 commit comments

Comments
 (0)