)[functionName];
+
try {
if (functionToInvoke && typeof functionToInvoke === "function") {
+ const schema = getSchema(message.fn);
+ const parsedArgs = schema.parameters().parse(message.args);
try {
- // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
- const result = await functionToInvoke.apply(object, message.args);
+ const result = await schema
+ .returnType()
+ .parse(functionToInvoke.apply(object, parsedArgs));
+
port.postMessage({
type: RPCMessageType.PARCNET_CLIENT_INVOKE_RESULT,
result,
diff --git a/packages/podspec/src/gpc/proof_request.ts b/packages/podspec/src/gpc/proof_request.ts
index b85008c..2975e21 100644
--- a/packages/podspec/src/gpc/proof_request.ts
+++ b/packages/podspec/src/gpc/proof_request.ts
@@ -28,7 +28,9 @@ export type ProofRequest = {
* A PodspecProofRequest allows us to generate a {@link ProofRequest} from a
* set of Podspecs defining the allowable PODs.
*/
-export interface PodspecProofRequest> {
+export interface PodspecProofRequest<
+ P extends Record = Record>
+> {
pods: Readonly<{
[K in keyof P]: P[K] extends PODSchema
? P[K] & PODSchema
diff --git a/packages/podspec/src/parse/pod.ts b/packages/podspec/src/parse/pod.ts
index e906d1d..04dd958 100644
--- a/packages/podspec/src/parse/pod.ts
+++ b/packages/podspec/src/parse/pod.ts
@@ -54,7 +54,7 @@ export class PodSpec {
*
* @param schema The schema for the POD.
*/
- private constructor(schema: PODSchema>) {
+ private constructor(schema: PODSchema) {
this.schema = Object.freeze(schema);
}
@@ -108,9 +108,14 @@ export class PodSpec {
public query(input: POD[]): { matches: POD[]; matchingIndexes: number[] } {
const matchingIndexes: number[] = [];
const matches: POD[] = [];
+ const signatures = new Set();
for (const [index, pod] of input.entries()) {
const result = this.safeParse(pod, { exitEarly: true });
if (result.isValid) {
+ if (signatures.has(pod.signature)) {
+ continue;
+ }
+ signatures.add(pod.signature);
matchingIndexes.push(index);
matches.push(pod);
}
@@ -142,7 +147,7 @@ export class PodSpec {
* @returns A new PodSpec instance.
*/
public static create(
- schema: PODSchema>
+ schema: PODSchema
): PodSpec {
return new PodSpec(schema);
}
@@ -151,9 +156,8 @@ export class PodSpec {
/**
* Exported version of static create method, for convenience.
*/
-export const pod = (
- schema: PODSchema>
-) => PodSpec.create(schema);
+export const pod = (schema: PODSchema) =>
+ PodSpec.create(schema);
/**
* Parses the POD and its entries, returning a {@link ParseResult}.
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index f9fdaec..3404ec0 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -131,10 +131,7 @@ importers:
version: 18.3.1(react@18.3.1)
vite-plugin-node-polyfills:
specifier: ^0.22.0
- version: 0.22.0(rollup@4.21.2)(vite@5.4.2(@types/node@22.5.4))
- zod:
- specifier: ^3.23.8
- version: 3.23.8
+ version: 0.22.0(rollup@4.21.2)(vite@5.4.4(@types/node@22.5.4))
devDependencies:
'@parcnet/eslint-config':
specifier: workspace:*
@@ -147,7 +144,7 @@ importers:
version: 18.3.0
'@vitejs/plugin-react':
specifier: ^4.3.1
- version: 4.3.1(vite@5.4.2(@types/node@22.5.4))
+ version: 4.3.1(vite@5.4.4(@types/node@22.5.4))
autoprefixer:
specifier: ^10.4.20
version: 10.4.20(postcss@8.4.44)
@@ -167,8 +164,8 @@ importers:
specifier: ^5.5
version: 5.5.4
vite:
- specifier: ^5.4.1
- version: 5.4.2(@types/node@22.5.4)
+ specifier: ^5.4.4
+ version: 5.4.4(@types/node@22.5.4)
examples/test-app:
dependencies:
@@ -3639,8 +3636,8 @@ packages:
peerDependencies:
vite: ^2.0.0 || ^3.0.0 || ^4.0.0 || ^5.0.0
- vite@5.4.2:
- resolution: {integrity: sha512-dDrQTRHp5C1fTFzcSaMxjk6vdpKvT+2/mIdE07Gw2ykehT49O0z/VHS3zZ8iV/Gh8BJJKHWOe5RjaNrW5xf/GA==}
+ vite@5.4.4:
+ resolution: {integrity: sha512-RHFCkULitycHVTtelJ6jQLd+KSAAzOgEYorV32R2q++M6COBjKJR6BxqClwp5sf0XaBDjVMuJ9wnNfyAJwjMkA==}
engines: {node: ^18.0.0 || >=20.0.0}
hasBin: true
peerDependencies:
@@ -4653,14 +4650,14 @@ snapshots:
'@typescript-eslint/types': 8.4.0
eslint-visitor-keys: 3.4.3
- '@vitejs/plugin-react@4.3.1(vite@5.4.2(@types/node@22.5.4))':
+ '@vitejs/plugin-react@4.3.1(vite@5.4.4(@types/node@22.5.4))':
dependencies:
'@babel/core': 7.25.2
'@babel/plugin-transform-react-jsx-self': 7.24.7(@babel/core@7.25.2)
'@babel/plugin-transform-react-jsx-source': 7.24.7(@babel/core@7.25.2)
'@types/babel__core': 7.20.5
react-refresh: 0.14.2
- vite: 5.4.2(@types/node@22.5.4)
+ vite: 5.4.4(@types/node@22.5.4)
transitivePeerDependencies:
- supports-color
@@ -7324,7 +7321,7 @@ snapshots:
debug: 4.3.6
pathe: 1.1.2
tinyrainbow: 1.2.0
- vite: 5.4.2(@types/node@22.5.4)
+ vite: 5.4.4(@types/node@22.5.4)
transitivePeerDependencies:
- '@types/node'
- less
@@ -7336,15 +7333,15 @@ snapshots:
- supports-color
- terser
- vite-plugin-node-polyfills@0.22.0(rollup@4.21.2)(vite@5.4.2(@types/node@22.5.4)):
+ vite-plugin-node-polyfills@0.22.0(rollup@4.21.2)(vite@5.4.4(@types/node@22.5.4)):
dependencies:
'@rollup/plugin-inject': 5.0.5(rollup@4.21.2)
node-stdlib-browser: 1.2.0
- vite: 5.4.2(@types/node@22.5.4)
+ vite: 5.4.4(@types/node@22.5.4)
transitivePeerDependencies:
- rollup
- vite@5.4.2(@types/node@22.5.4):
+ vite@5.4.4(@types/node@22.5.4):
dependencies:
esbuild: 0.21.5
postcss: 8.4.44
@@ -7371,7 +7368,7 @@ snapshots:
tinybench: 2.9.0
tinypool: 1.0.1
tinyrainbow: 1.2.0
- vite: 5.4.2(@types/node@22.5.4)
+ vite: 5.4.4(@types/node@22.5.4)
vite-node: 2.0.5(@types/node@22.5.4)
why-is-node-running: 2.3.0
optionalDependencies: