From 6737a0346d69049eecd2b57eef00d729cc98f524 Mon Sep 17 00:00:00 2001 From: Lim Jet <57783762+daoauth@users.noreply.github.com> Date: Wed, 15 Jan 2025 22:21:55 +0900 Subject: [PATCH] fix typo --- src/utilities/aptosAssistant.ts | 2 +- src/utilities/authCode.ts | 2 +- src/utilities/fileWatcher.ts | 4 +-- src/webview/activitybar/src/App.tsx | 8 ++--- .../activitybar/src/components/Account.tsx | 14 ++++---- .../activitybar/src/components/Workspace.tsx | 18 +++++------ .../utilities/{commends.ts => commands.ts} | 2 +- .../activitybar/src/utilities/googleLogin.ts | 4 +-- .../src/utilities/loadPackageData.ts | 6 ++-- .../activitybar/src/utilities/moveView.ts | 6 ++-- .../src/utilities/signAndExcute.ts | 12 +++---- src/webview/activitybarProvider.ts | 32 +++++++++---------- src/webview/panel/src/App.tsx | 12 +++---- .../utilities/{commends.ts => commands.ts} | 2 +- src/webview/panelProvider.ts | 26 +++++++-------- 15 files changed, 75 insertions(+), 75 deletions(-) rename src/webview/activitybar/src/utilities/{commends.ts => commands.ts} (96%) rename src/webview/panel/src/utilities/{commends.ts => commands.ts} (93%) diff --git a/src/utilities/aptosAssistant.ts b/src/utilities/aptosAssistant.ts index 4a4f926..026f025 100644 --- a/src/utilities/aptosAssistant.ts +++ b/src/utilities/aptosAssistant.ts @@ -1,5 +1,5 @@ import * as vscode from 'vscode'; -import { RequestData } from '../webview/panel/src/utilities/commends'; +import { RequestData } from '../webview/panel/src/utilities/commands'; const getContent = (str: string) => { const { choices } = JSON.parse(str); diff --git a/src/utilities/authCode.ts b/src/utilities/authCode.ts index aae0fd6..d1bdd8c 100644 --- a/src/utilities/authCode.ts +++ b/src/utilities/authCode.ts @@ -4,7 +4,7 @@ import { ClientSecret, UrlAuthCode, UrlCallback, -} from '../webview/activitybar/src/utilities/commends'; +} from '../webview/activitybar/src/utilities/commands'; const exchangeAuthCodeForJwt = async ( authCode: string, diff --git a/src/utilities/fileWatcher.ts b/src/utilities/fileWatcher.ts index 591ff34..af1494d 100644 --- a/src/utilities/fileWatcher.ts +++ b/src/utilities/fileWatcher.ts @@ -1,5 +1,5 @@ import * as vscode from 'vscode'; -import { COMMENDS } from '../webview/activitybar/src/utilities/commends'; +import { COMMANDS } from '../webview/activitybar/src/utilities/commands'; import { ByteDump } from '../webview/activitybar/src/utilities/cli'; const MoveToml = 'Move.toml'; @@ -125,7 +125,7 @@ export class FileWathcer { private updateWebview() { this._view.webview.postMessage({ - command: COMMENDS.PackageList, + command: COMMANDS.PackageList, data: this._packages.map(({ path, content }) => { return { path, diff --git a/src/webview/activitybar/src/App.tsx b/src/webview/activitybar/src/App.tsx index fadfa13..dd5c2d4 100644 --- a/src/webview/activitybar/src/App.tsx +++ b/src/webview/activitybar/src/App.tsx @@ -8,7 +8,7 @@ import { vscode } from './utilities/vscode'; import { Account } from './components/Account'; import { ExplorerPackage } from './components/ExplorerPackage'; import { Workspace } from './components/Workspace'; -import { COMMENDS } from './utilities/commends'; +import { COMMANDS } from './utilities/commands'; import { IAccount, STATE } from './recoil'; function App() { @@ -20,7 +20,7 @@ function App() { useEffect(() => { const handleMessage = async ( event: MessageEvent<{ - command: COMMENDS; + command: COMMANDS; data: { hasTerminal: boolean; account?: IAccount; @@ -29,7 +29,7 @@ function App() { ) => { const message = event.data; switch (message.command) { - case COMMENDS.Env: + case COMMANDS.Env: { const { hasTerminal: terminal, account: loaddedAccount } = message.data; @@ -49,7 +49,7 @@ function App() { if (!initialized.current) { initialized.current = true; - vscode.postMessage({ command: COMMENDS.Env }); + vscode.postMessage({ command: COMMANDS.Env }); } return () => { diff --git a/src/webview/activitybar/src/components/Account.tsx b/src/webview/activitybar/src/components/Account.tsx index 254080e..5153c44 100644 --- a/src/webview/activitybar/src/components/Account.tsx +++ b/src/webview/activitybar/src/components/Account.tsx @@ -13,7 +13,7 @@ import { useRecoilState } from 'recoil'; import { createNonce } from '../utilities/createNonce'; import { googleLogin } from '../utilities/googleLogin'; import { vscode } from '../utilities/vscode'; -import { COMMENDS } from '../utilities/commends'; +import { COMMANDS } from '../utilities/commands'; import { getBalance } from '../utilities/getBalance'; import { createProof } from '../utilities/createProof'; import { faucet } from '../utilities/faucet'; @@ -51,7 +51,7 @@ export const Account = ({ client }: { client: Aptos | undefined }) => { const handleLogout = async () => { vscode.postMessage({ - command: COMMENDS.StoreAccount, + command: COMMANDS.StoreAccount, data: undefined, }); setState(() => ({ packages: {} })); @@ -69,7 +69,7 @@ export const Account = ({ client }: { client: Aptos | undefined }) => { } } catch (error) { vscode.postMessage({ - command: COMMENDS.MsgError, + command: COMMANDS.MsgError, data: `${error}`, }); } finally { @@ -87,13 +87,13 @@ export const Account = ({ client }: { client: Aptos | undefined }) => { const handleMessage = async ( event: MessageEvent<{ - command: COMMENDS; + command: COMMANDS; data: string; }>, ) => { const message = event.data; switch (message.command) { - case COMMENDS.LoginJwt: + case COMMANDS.LoginJwt: if (state.account && message.data && !!client) { try { const { address, proof, salt } = await createProof( @@ -114,7 +114,7 @@ export const Account = ({ client }: { client: Aptos | undefined }) => { }, })); vscode.postMessage({ - command: COMMENDS.StoreAccount, + command: COMMANDS.StoreAccount, data: { ...state.account, zkAddress: { @@ -127,7 +127,7 @@ export const Account = ({ client }: { client: Aptos | undefined }) => { }); } catch (error) { vscode.postMessage({ - command: COMMENDS.MsgError, + command: COMMANDS.MsgError, data: `${error}`, }); } finally { diff --git a/src/webview/activitybar/src/components/Workspace.tsx b/src/webview/activitybar/src/components/Workspace.tsx index 79feb86..2201e93 100644 --- a/src/webview/activitybar/src/components/Workspace.tsx +++ b/src/webview/activitybar/src/components/Workspace.tsx @@ -10,7 +10,7 @@ import { } from '@vscode/webview-ui-toolkit/react'; import { Aptos } from '@aptos-labs/ts-sdk'; import { vscode } from '../utilities/vscode'; -import { COMMENDS } from '../utilities/commends'; +import { COMMANDS } from '../utilities/commands'; import { SpinButton } from './SpinButton'; import { STATE } from '../recoil'; import { packagePublish } from '../utilities/packagePublish'; @@ -41,7 +41,7 @@ export const Workspace = ({ const handleMessage = async (event: any) => { const message = event.data; switch (message.command) { - case COMMENDS.PackageList: + case COMMANDS.PackageList: { const temp = ( message.data as { path: string; content: string }[] @@ -69,7 +69,7 @@ export const Workspace = ({ } } break; - case COMMENDS.Deploy: + case COMMANDS.Deploy: try { if (!!state.account?.zkAddress && !!client) { const { packageId } = await packagePublish( @@ -133,7 +133,7 @@ export const Workspace = ({ if (path) { setState((oldState) => ({ ...oldState, ...packageSelect(path) })); vscode.postMessage({ - command: COMMENDS.PackageSelect, + command: COMMANDS.PackageSelect, data: path, }); } @@ -192,7 +192,7 @@ export const Workspace = ({ onClick={() => { state.path && vscode.postMessage({ - command: COMMENDS.CLI, + command: COMMANDS.CLI, data: runBuild(state.path, !!(state as any).move2), }); }} @@ -213,7 +213,7 @@ export const Workspace = ({ onClick={() => { state.path && vscode.postMessage({ - command: COMMENDS.CLI, + command: COMMANDS.CLI, data: runProve(state.path, !!(state as any).move2), }); }} @@ -243,7 +243,7 @@ export const Workspace = ({ onClick={() => { state.path && vscode.postMessage({ - command: COMMENDS.CLI, + command: COMMANDS.CLI, data: runTest(state.path, !!(state as any).move2), }); }} @@ -264,7 +264,7 @@ export const Workspace = ({ onClick={() => { state.path && vscode.postMessage({ - command: COMMENDS.CLI, + command: COMMANDS.CLI, data: runFormatter(state.path), }); }} @@ -290,7 +290,7 @@ export const Workspace = ({ if (selected) { setIsLoading(true); vscode.postMessage({ - command: COMMENDS.Deploy, + command: COMMANDS.Deploy, data: selected.path, }); } diff --git a/src/webview/activitybar/src/utilities/commends.ts b/src/webview/activitybar/src/utilities/commands.ts similarity index 96% rename from src/webview/activitybar/src/utilities/commends.ts rename to src/webview/activitybar/src/utilities/commands.ts index cb2af51..718d603 100644 --- a/src/webview/activitybar/src/utilities/commends.ts +++ b/src/webview/activitybar/src/utilities/commands.ts @@ -1,4 +1,4 @@ -export enum COMMENDS { +export enum COMMANDS { Env = 'env', Login = 'google:login', LoginJwt = 'google:jwt', diff --git a/src/webview/activitybar/src/utilities/googleLogin.ts b/src/webview/activitybar/src/utilities/googleLogin.ts index 37fe927..d40a8de 100644 --- a/src/webview/activitybar/src/utilities/googleLogin.ts +++ b/src/webview/activitybar/src/utilities/googleLogin.ts @@ -3,7 +3,7 @@ import SHA256 from 'crypto-js/sha256'; import Base64 from 'crypto-js/enc-base64'; import * as querystring from 'querystring'; import { vscode } from './vscode'; -import { ClientId, COMMENDS, UrlCallback } from './commends'; +import { ClientId, COMMANDS, UrlCallback } from './commands'; const generateLoginUrl = ( state: string, @@ -33,7 +33,7 @@ export const googleLogin = async (nonce: string) => { .replace(/=+$/, ''); vscode.postMessage({ - command: COMMENDS.Login, + command: COMMANDS.Login, data: { url: generateLoginUrl(state, codeChallenge, nonce), state, diff --git a/src/webview/activitybar/src/utilities/loadPackageData.ts b/src/webview/activitybar/src/utilities/loadPackageData.ts index 966a6b0..1f7c89e 100644 --- a/src/webview/activitybar/src/utilities/loadPackageData.ts +++ b/src/webview/activitybar/src/utilities/loadPackageData.ts @@ -1,6 +1,6 @@ import { Aptos, MoveModuleBytecode } from '@aptos-labs/ts-sdk'; import { vscode } from './vscode'; -import { COMMENDS } from './commends'; +import { COMMANDS } from './commands'; export const loadPackageData = async ( client: Aptos | undefined, @@ -18,14 +18,14 @@ export const loadPackageData = async ( return modules; } catch (error) { vscode.postMessage({ - command: COMMENDS.MsgError, + command: COMMANDS.MsgError, data: `${error}`, }); return undefined; } } vscode.postMessage({ - command: COMMENDS.MsgError, + command: COMMANDS.MsgError, data: 'client is undefined', }); return undefined; diff --git a/src/webview/activitybar/src/utilities/moveView.ts b/src/webview/activitybar/src/utilities/moveView.ts index 150da36..1414c54 100644 --- a/src/webview/activitybar/src/utilities/moveView.ts +++ b/src/webview/activitybar/src/utilities/moveView.ts @@ -6,7 +6,7 @@ import { SimpleEntryFunctionArgumentTypes, } from '@aptos-labs/ts-sdk'; import { vscode } from './vscode'; -import { COMMENDS } from './commends'; +import { COMMANDS } from './commands'; export const moveView = async ( client: Aptos, @@ -23,13 +23,13 @@ export const moveView = async ( }; const res = await client.view({ payload }); vscode.postMessage({ - command: COMMENDS.OutputInfo, + command: COMMANDS.OutputInfo, data: JSON.stringify(res, null, 4), }); return res; } catch (error) { vscode.postMessage({ - command: COMMENDS.OutputError, + command: COMMANDS.OutputError, data: JSON.stringify(error, null, 4), }); throw new Error(`${error}`); diff --git a/src/webview/activitybar/src/utilities/signAndExcute.ts b/src/webview/activitybar/src/utilities/signAndExcute.ts index 173da14..3594190 100644 --- a/src/webview/activitybar/src/utilities/signAndExcute.ts +++ b/src/webview/activitybar/src/utilities/signAndExcute.ts @@ -7,7 +7,7 @@ import { } from '@aptos-labs/ts-sdk'; import { IAccount } from '../recoil'; import { vscode } from './vscode'; -import { COMMENDS } from './commends'; +import { COMMANDS } from './commands'; export const signAndExcute = async ( account: IAccount, @@ -32,27 +32,27 @@ export const signAndExcute = async ( const res = await client.waitForTransaction({ transactionHash: hash }); if (!res.success) { vscode.postMessage({ - command: COMMENDS.MsgError, + command: COMMANDS.MsgError, data: `error: ${res.hash}`, }); vscode.postMessage({ - command: COMMENDS.OutputError, + command: COMMANDS.OutputError, data: JSON.stringify(res, null, 4), }); throw new Error(`error: ${res.hash}`); } vscode.postMessage({ - command: COMMENDS.MsgInfo, + command: COMMANDS.MsgInfo, data: `success: ${account.nonce.network}:${res.hash}`, }); vscode.postMessage({ - command: COMMENDS.OutputInfo, + command: COMMANDS.OutputInfo, data: JSON.stringify(res, null, 4), }); return res; } catch (error) { vscode.postMessage({ - command: COMMENDS.MsgError, + command: COMMANDS.MsgError, data: `${error}`, }); throw new Error(`${error}`); diff --git a/src/webview/activitybarProvider.ts b/src/webview/activitybarProvider.ts index 6227fba..17693f4 100644 --- a/src/webview/activitybarProvider.ts +++ b/src/webview/activitybarProvider.ts @@ -2,7 +2,7 @@ import * as vscode from 'vscode'; import { getUri } from '../utilities/getUri'; import { getNonce } from '../utilities/getNonce'; import { hasTerminal } from '../utilities/hasTerminal'; -import { COMMENDS } from './activitybar/src/utilities/commends'; +import { COMMANDS } from './activitybar/src/utilities/commands'; import { FileWathcer } from '../utilities/fileWatcher'; import { accountLoad, accountStore } from '../utilities/account'; import { printOutputChannel } from '../utilities/printOutputChannel'; @@ -60,9 +60,9 @@ class ActivitybarProvider implements vscode.WebviewViewProvider { webviewView.webview.html = this._getHtmlForWebview(webviewView.webview); webviewView.webview.onDidReceiveMessage( - async ({ command, data }: { command: COMMENDS; data: any }) => { + async ({ command, data }: { command: COMMANDS; data: any }) => { switch (command) { - case COMMENDS.Env: + case COMMANDS.Env: { this._view?.webview.postMessage({ command, @@ -74,7 +74,7 @@ class ActivitybarProvider implements vscode.WebviewViewProvider { await this._fileWatcher?.initializePackageList(); } break; - case COMMENDS.Login: + case COMMANDS.Login: { const { url, @@ -94,29 +94,29 @@ class ActivitybarProvider implements vscode.WebviewViewProvider { codeVerifier, (data) => { this._view?.webview.postMessage({ - command: COMMENDS.LoginJwt, + command: COMMANDS.LoginJwt, data, }); }, () => { this._view?.webview.postMessage({ - command: COMMENDS.LoginJwt, + command: COMMANDS.LoginJwt, data: '', }); }, ); } else { this._view?.webview.postMessage({ - command: COMMENDS.LoginJwt, + command: COMMANDS.LoginJwt, data: '', }); } } break; - case COMMENDS.StoreAccount: + case COMMANDS.StoreAccount: await accountStore(this._context, data); break; - case COMMENDS.CLI: + case COMMANDS.CLI: if (!hasTerminal()) { vscode.window.showErrorMessage( 'This environment does not support terminal operations.', @@ -125,28 +125,28 @@ class ActivitybarProvider implements vscode.WebviewViewProvider { this.runTerminal(data); } break; - case COMMENDS.Deploy: + case COMMANDS.Deploy: { const dumpByte = await this._fileWatcher?.getByteCodeDump(data); this._view?.webview.postMessage({ - command: COMMENDS.Deploy, + command: COMMANDS.Deploy, data: dumpByte || '', }); } break; - case COMMENDS.PackageSelect: + case COMMANDS.PackageSelect: // TODO break; - case COMMENDS.MsgInfo: + case COMMANDS.MsgInfo: vscode.window.showInformationMessage(data); break; - case COMMENDS.MsgError: + case COMMANDS.MsgError: vscode.window.showErrorMessage(data); break; - case COMMENDS.OutputInfo: + case COMMANDS.OutputInfo: printOutputChannel(data); break; - case COMMENDS.OutputError: + case COMMANDS.OutputError: printOutputChannel(`[ERROR]\n${data}`); break; default: diff --git a/src/webview/panel/src/App.tsx b/src/webview/panel/src/App.tsx index 5ef35e5..fd03845 100644 --- a/src/webview/panel/src/App.tsx +++ b/src/webview/panel/src/App.tsx @@ -3,7 +3,7 @@ import { VSCodeTextField } from '@vscode/webview-ui-toolkit/react'; import './App.css'; -import { COMMENDS, RequestData } from './utilities/commends'; +import { COMMANDS, RequestData } from './utilities/commands'; import { vscode } from './utilities/vscode'; import { User } from './components/User'; import { Bot } from './components/Bot'; @@ -36,7 +36,7 @@ function App() { '', ]); break; - case COMMENDS.AiHistory: + case COMMANDS.AiHistory: const temp: (string | RequestData)[] = []; message.data.forEach((item: { user: RequestData; bot: string }) => { temp.push(item.user, item.bot); @@ -50,10 +50,10 @@ function App() { } initialized.current = true; break; - case COMMENDS.AiStream: + case COMMANDS.AiStream: setHtmlHistory((old) => [...old.slice(0, -1), message.data]); break; - case COMMENDS.AiStreamEnd: + case COMMANDS.AiStreamEnd: setIsLoading(() => false); break; default: @@ -62,7 +62,7 @@ function App() { }; if (!initialized.current) { - vscode.postMessage({ command: COMMENDS.Env }); + vscode.postMessage({ command: COMMANDS.Env }); } window.addEventListener('message', handleMessage); @@ -137,7 +137,7 @@ function App() { const value = (event.target as any)?.value || ''; if (event.key === 'Enter' && value && !isLoading) { vscode.postMessage({ - command: COMMENDS.AiQuestion, + command: COMMANDS.AiQuestion, data: value, }); setInput(''); diff --git a/src/webview/panel/src/utilities/commends.ts b/src/webview/panel/src/utilities/commands.ts similarity index 93% rename from src/webview/panel/src/utilities/commends.ts rename to src/webview/panel/src/utilities/commands.ts index b3cc805..ae2f6fe 100644 --- a/src/webview/panel/src/utilities/commends.ts +++ b/src/webview/panel/src/utilities/commands.ts @@ -1,4 +1,4 @@ -export enum COMMENDS { +export enum COMMANDS { Env = 'env', AiHistory = 'ai:history', AiQuestion = 'ai:question', diff --git a/src/webview/panelProvider.ts b/src/webview/panelProvider.ts index cb129e1..c97222b 100644 --- a/src/webview/panelProvider.ts +++ b/src/webview/panelProvider.ts @@ -3,7 +3,7 @@ import { getUri } from '../utilities/getUri'; import { getNonce } from '../utilities/getNonce'; import { getMoveFilesFromFolder } from '../utilities/getMoveFilesFromFolder'; import { printOutputChannel } from '../utilities/printOutputChannel'; -import { COMMENDS } from './panel/src/utilities/commends'; +import { COMMANDS } from './panel/src/utilities/commands'; import { aptosAssistant, getHistory } from '../utilities/aptosAssistant'; const AuditPrompt = @@ -37,40 +37,40 @@ class PanelProvider implements vscode.WebviewViewProvider { webviewView.webview.html = this._getHtmlForWebview(webviewView.webview); webviewView.webview.onDidReceiveMessage( - async ({ command, data }: { command: COMMENDS; data: any }) => { + async ({ command, data }: { command: COMMANDS; data: any }) => { switch (command) { - case COMMENDS.Env: + case COMMANDS.Env: this._view?.webview.postMessage({ - command: COMMENDS.AiHistory, + command: COMMANDS.AiHistory, data: getHistory(), }); break; - case COMMENDS.AiQuestion: + case COMMANDS.AiQuestion: aptosAssistant( { code: false, content: data }, (stream) => { this._view?.webview.postMessage({ - command: COMMENDS.AiStream, + command: COMMANDS.AiStream, data: stream, }); }, () => { this._view?.webview.postMessage({ - command: COMMENDS.AiStreamEnd, + command: COMMANDS.AiStreamEnd, }); }, ); break; - case COMMENDS.MsgInfo: + case COMMANDS.MsgInfo: vscode.window.showInformationMessage(data); break; - case COMMENDS.MsgError: + case COMMANDS.MsgError: vscode.window.showErrorMessage(data); break; - case COMMENDS.OutputInfo: + case COMMANDS.OutputInfo: printOutputChannel(data); break; - case COMMENDS.OutputError: + case COMMANDS.OutputError: printOutputChannel(`[ERROR]\n${data}`); break; default: @@ -95,13 +95,13 @@ class PanelProvider implements vscode.WebviewViewProvider { { code: true, content: message.data }, (stream) => { this._view?.webview.postMessage({ - command: COMMENDS.AiStream, + command: COMMANDS.AiStream, data: stream, }); }, () => { this._view?.webview.postMessage({ - command: COMMENDS.AiStreamEnd, + command: COMMANDS.AiStreamEnd, }); }, );