Skip to content

Commit 5022812

Browse files
committed
chore: passing curated sources as json string instead of tmp file
1 parent 55103e3 commit 5022812

File tree

1 file changed

+4
-31
lines changed

1 file changed

+4
-31
lines changed

src/configuration.ts

Lines changed: 4 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -58,15 +58,11 @@ export class AvmDebugConfigProvider implements vscode.DebugConfigurationProvider
5858
await this.persistSources(folder, programSourcesDescriptionFile, sources)
5959
}
6060

61-
const curatedProgramSourcesPath = await this.createCuratedProgramSources(sources, uniqueHashes, programSourcesDescriptionFile)
62-
return { ...config, programSourcesDescriptionFile: curatedProgramSourcesPath.fsPath }
61+
const curatedProgramSourcesPath = await this.createCuratedProgramSources(sources, uniqueHashes)
62+
return { ...config, programSources: curatedProgramSourcesPath }
6363
}
6464

65-
private async createCuratedProgramSources(
66-
sources: SourcesFile,
67-
uniqueHashes: string[],
68-
programSourcesDescriptionFile: string,
69-
): Promise<vscode.Uri> {
65+
private async createCuratedProgramSources(sources: SourcesFile, uniqueHashes: string[]): Promise<string> {
7066
const PRIORITY_MAP: Record<string, number> = {
7167
'.puya.map': 3,
7268
'.teal.map': 2,
@@ -88,30 +84,7 @@ export class AvmDebugConfigProvider implements vscode.DebugConfigurationProvider
8884
return acc
8985
}, [])
9086

91-
const curatedProgramSourcesPath = vscode.Uri.joinPath(
92-
vscode.Uri.file(programSourcesDescriptionFile),
93-
'..',
94-
`${Date.now()}.sources.avm.json`,
95-
)
96-
97-
// Write curated sources to the temporary file
98-
await vscode.workspace.fs.writeFile(
99-
curatedProgramSourcesPath,
100-
Buffer.from(JSON.stringify({ 'txn-group-sources': curatedProgramSources }, null, 2)),
101-
)
102-
103-
// Register cleanup function
104-
this.disposables.push(
105-
vscode.debug.onDidTerminateDebugSession(async () => {
106-
try {
107-
await vscode.workspace.fs.delete(curatedProgramSourcesPath, { recursive: true })
108-
} catch (error) {
109-
console.error('Failed to delete curated sources file:', error)
110-
}
111-
}),
112-
)
113-
114-
return curatedProgramSourcesPath
87+
return JSON.stringify({ 'txn-group-sources': curatedProgramSources }, null, 2)
11588
}
11689

11790
private async getProgramSourcesDescriptionFile(folder: WorkspaceFolder, config: DebugConfiguration): Promise<string> {

0 commit comments

Comments
 (0)