@@ -9,6 +9,7 @@ import { WidgetPreviewPanel } from "./modules/preview-panel";
99import { preview } from "./commands/preview" ;
1010import { startIDE } from "./commands/start-ide" ;
1111import { updateAllFlags , updateFlags } from "./flags" ;
12+ import { addKeyForContract } from "./commands/add-key" ;
1213
1314let localWorkspace : string = "" ;
1415const FS = vscode . workspace . fs ;
@@ -48,7 +49,14 @@ export function activate(context: vscode.ExtensionContext) {
4849 // Login Account
4950 context . subscriptions . push (
5051 vscode . commands . registerCommand ( "near.login" , ( ) =>
51- loginAccount ( context , 'mainnet' , localWorkspace )
52+ loginAccount ( context , localWorkspace )
53+ )
54+ ) ;
55+
56+ // Login Account
57+ context . subscriptions . push (
58+ vscode . commands . registerCommand ( "near.addKey" , ( ) =>
59+ addKeyForContract ( context , localWorkspace )
5260 )
5361 ) ;
5462
@@ -63,7 +71,7 @@ export function activate(context: vscode.ExtensionContext) {
6371 // Publish Code
6472 context . subscriptions . push (
6573 vscode . commands . registerCommand ( "near.publishWidget" , ( ) =>
66- publishCode ( context , 'mainnet' , localWorkspace )
74+ publishCode ( context , localWorkspace )
6775 )
6876 ) ;
6977
@@ -100,4 +108,13 @@ export async function addToContext(localWorkspace: string | undefined, key: stri
100108 let contextData = JSON . parse ( data ?. toString ( ) || "{}" ) ;
101109 contextData [ key ] = value ;
102110 await FS . writeFile ( contextUri , Buffer . from ( JSON . stringify ( contextData , null , 2 ) ) ) ;
111+ }
112+
113+ export async function getFromContext ( localWorkspace : string | undefined , key : string ) : Promise < string | undefined > {
114+ if ( ! localWorkspace ) { return ; }
115+
116+ const contextUri = vscode . Uri . parse ( path . join ( localWorkspace , `context.json` ) ) ;
117+ let data = await FS . readFile ( contextUri ) ;
118+ let contextData = JSON . parse ( data ?. toString ( ) || "{}" ) ;
119+ return key in contextData ? contextData [ key ] : undefined ;
103120}
0 commit comments