Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
"@radix-ui/react-tooltip": "^1.1.7",
"@reduxjs/toolkit": "^2.9.0",
"@tanstack/react-virtual": "^3.10.9",
"@typeberry/lib": "^0.1.0",
"@typeberry/lib": "^0.2.0",
"@typeberry/spectool-wasm": "0.23.0",
"@uiw/react-codemirror": "^4.25.1",
"class-variance-authority": "^0.7.1",
Expand Down
46 changes: 30 additions & 16 deletions src/components/PvmSelect/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import {
setSelectedPvms,
} from "@/store/debugger/debuggerSlice.ts";
import { SerializedFile, serializeFile } from "@/lib/utils.ts";
import { logger } from "@/utils/loggerService";

interface WasmMetadata {
name: string;
Expand All @@ -37,6 +38,9 @@ export interface SelectedPvmWithPayload {
label: string;
params?: {
file?: SerializedFile;
/** Metadata url. */
metaUrl?: string;
/** WASM blob url. */
url?: string;
};
removable?: boolean;
Expand Down Expand Up @@ -131,6 +135,7 @@ export const PvmSelect = () => {
id,
type: PvmTypes.WASM_URL,
params: {
metaUrl: url,
url: path.join(url, "../", wasmMetadata.wasmBlobUrl),
},
label: `${id} v${wasmMetadata.version}` as string,
Expand Down Expand Up @@ -167,27 +172,36 @@ export const PvmSelect = () => {
Promise.all(
pvmsWithPayload.map(async (pvm) => {
if (pvm.type === PvmTypes.WASM_URL) {
if (pvm.params?.url) {
const metadata = await fetchWasmMetadata(pvm.params.url);
if (!metadata) {
throw new Error("Invalid metadata");
if (pvm.params?.metaUrl) {
try {
const metadata = await fetchWasmMetadata(pvm.params.metaUrl);
if (!metadata) {
throw new Error("Invalid metadata");
}
return {
...pvm,
id: pvm.id,
type: PvmTypes.WASM_URL,
params: {
...pvmsWithPayload.find((p) => p.id === pvm.id)?.params,
url: path.join(pvm.params.metaUrl, "../", metadata.wasmBlobUrl).replace("https:/", "https://"), // TODO: check why the http protocol path is getting messed up
},
label: `${metadata.name} v${metadata.version}` as string,
};
} catch (e) {
logger.error(`Error while updating ${pvm.id}: ${e}`, { error: e });
}
return {
id: pvm.id,
type: PvmTypes.WASM_URL,
params: {
...pvmsWithPayload.find((p) => p.id === pvm.id)?.params,
url: path.join(pvm.params.url, "../", metadata.wasmBlobUrl).replace("https:/", "https://"), // TODO: check why the http protocol path is getting messed up
},
label: `${metadata.name} v${metadata.version}` as string,
};
}
}
return pvm;
}),
).then((values) => {
dispatch(setPvmOptions(values));
});
)
.then((values) => {
dispatch(setPvmOptions(values));
})
.catch((e) => {
logger.error(`Unable to fetch PVM: ${e}`, { error: e });
});

// eslint-disable-next-line react-hooks/exhaustive-deps
}, []);
Expand Down
4 changes: 2 additions & 2 deletions src/store/debugger/debuggerSlice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,14 +54,14 @@ const initialState: DebuggerState = {
{
id: AvailablePvms.POLKAVM,
type: PvmTypes.WASM_URL,
params: { url: "https://todr.me/polkavm/pvm-metadata.json" },
params: { metaUrl: "https://todr.me/polkavm/pvm-metadata.json" },
label: "PolkaVM",
},
{
id: AvailablePvms.ANANAS,
type: PvmTypes.WASM_URL,
params: {
url: "https://todr.me/anan-as/pvm-metadata.json",
metaUrl: "https://todr.me/anan-as/pvm-metadata.json",
},
label: "Anan-AS",
},
Expand Down
Loading