Skip to content

Commit

Permalink
fix: remove unused var
Browse files Browse the repository at this point in the history
  • Loading branch information
markjung96 committed Oct 15, 2024
1 parent b00237d commit 8350957
Show file tree
Hide file tree
Showing 8 changed files with 41 additions and 255 deletions.
25 changes: 3 additions & 22 deletions src/components/project/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import { Button, Form, InputGroup } from "react-bootstrap";
import { useShallow } from "zustand/react/shallow";

import { useStore } from "../../zustand";
import wrapPromise from "../../utils/wrap-promise";
import { log } from "../../utils/logger";
import { sendCustomEvent } from "../../utils/send-custom-event";
import { CustomTooltip } from "../common/custom-tooltip";
Expand Down Expand Up @@ -192,15 +191,13 @@ const NewProject = () => {
}
};

const wrappedIsExists = (dir: string) => wrapPromise(isExists(dir), client);

const createProject = async () => {
if (!client || !name) return;
sendCustomEvent("new_project", {
event_category: "arbitrum",
method: "new_project",
});
if (await wrappedIsExists(name)) {
if (await isExists(name)) {
await client.terminal.log({
type: "error",
value: 'The folder "arbitrum/' + name + '" already exists',
Expand All @@ -221,8 +218,6 @@ const NewProject = () => {
}
};

const wrappedCreateProject = () => wrapPromise(createProject(), client);

const handleNameOnChange = (event: React.ChangeEvent<HTMLInputElement>) => {
setName(event.target.value);
};
Expand All @@ -241,13 +236,7 @@ const NewProject = () => {
if (event.key === "Enter") event.preventDefault();
}}
/>
<Button
className="relative border-0"
variant="success"
size="sm"
disabled={isLoading}
onClick={wrappedCreateProject}
>
<Button className="relative border-0" variant="success" size="sm" disabled={isLoading} onClick={createProject}>
<small>Create</small>
<LoaderWrapper loading={isLoading} />
</Button>
Expand Down Expand Up @@ -330,8 +319,6 @@ const Template = () => {
}
};

const wrappedCreateTemplate = () => wrapPromise(createTemplate(), client);

const handleTemplateOnChange = (event: React.ChangeEvent<HTMLInputElement>) => {
setTemplate(event.target.value);
};
Expand All @@ -356,13 +343,7 @@ const Template = () => {
);
})}
</Form.Control>
<Button
className="relative border-0"
variant="success"
size="sm"
disabled={isLoading}
onClick={wrappedCreateTemplate}
>
<Button className="relative border-0" variant="success" size="sm" disabled={isLoading} onClick={createTemplate}>
<small>Create</small>
<LoaderWrapper loading={isLoading} />
</Button>
Expand Down
7 changes: 1 addition & 6 deletions src/const/chain.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
export const CHAIN_NAME = {
aptos: 'aptos',
arbitrum: 'arbitrum',
sui: 'sui',
neutron: 'neutron',
juno: 'juno',
injective: 'injective',
arbitrum: "arbitrum",
};
85 changes: 11 additions & 74 deletions src/const/endpoint.ts
Original file line number Diff line number Diff line change
@@ -1,86 +1,23 @@
import { STAGE } from './stage';
import { STAGE } from "./stage";

const COMPILER_API_ENDPOINT_POOL = {
local: 'http://localhost:8000',
dev: 'https://dev.compiler.welldonestudio.io',
prod: 'https://verify.welldonestudio.io',
local: "http://localhost:8000",
dev: "https://dev.compiler.welldonestudio.io",
prod: "https://verify.welldonestudio.io",
};
export const COMPILER_API_ENDPOINT = COMPILER_API_ENDPOINT_POOL[STAGE];

const NEAR_COMPILER_CONSUMER_ENDPOINT_POOL = {
local: 'ws://localhost:8000',
dev: 'wss://dev.compiler.welldonestudio.io',
prod: 'wss://prod.near.compiler.welldonestudio.io',
};
export const NEAR_COMPILER_CONSUMER_ENDPOINT = NEAR_COMPILER_CONSUMER_ENDPOINT_POOL[STAGE];

const JUNO_COMPILER_CONSUMER_ENDPOINT_POOL = {
local: 'ws://localhost:8000',
dev: 'wss://dev.neutron.compiler.welldonestudio.io',
prod: 'wss://prod.neutron.compiler.welldonestudio.io',
};
export const JUNO_COMPILER_CONSUMER_ENDPOINT = JUNO_COMPILER_CONSUMER_ENDPOINT_POOL[STAGE];

const APTOS_COMPILER_CONSUMER_ENDPOINT_POOL = {
local: 'ws://localhost:8000',
dev: 'wss://dev.compiler.welldonestudio.io',
// prod: 'wss://prod.aptos.compiler.welldonestudio.io',
prod: 'wss://prod.near.compiler.welldonestudio.io',
};
export const APTOS_COMPILER_CONSUMER_ENDPOINT = APTOS_COMPILER_CONSUMER_ENDPOINT_POOL[STAGE];

const SUI_COMPILER_CONSUMER_ENDPOINT_POOL = {
local: 'ws://localhost:8000',
dev: 'wss://dev.compiler.welldonestudio.io',
// prod: 'wss://prod.aptos.compiler.welldonestudio.io',
prod: 'wss://prod.near.compiler.welldonestudio.io',
};
export const SUI_COMPILER_CONSUMER_ENDPOINT = SUI_COMPILER_CONSUMER_ENDPOINT_POOL[STAGE];

const NEUTRON_COMPILER_CONSUMER_ENDPOINT_POOL = {
local: 'ws://localhost:8000',
dev: 'wss://dev.neutron.compiler.welldonestudio.io',
prod: 'wss://prod.neutron.compiler.welldonestudio.io',
};
export const NEUTRON_COMPILER_CONSUMER_ENDPOINT = NEUTRON_COMPILER_CONSUMER_ENDPOINT_POOL[STAGE];

const NEUTRON_COMPILER_CONSUMER_API_ENDPOINT_POOL = {
local: 'http://localhost:8000',
dev: 'https://dev.neutron.compiler.welldonestudio.io',
prod: 'https://prod.neutron.compiler.welldonestudio.io',
};

export const NEUTRON_COMPILER_CONSUMER_API_ENDPOINT =
NEUTRON_COMPILER_CONSUMER_API_ENDPOINT_POOL[STAGE];
// ---
const INJECTIVE_COMPILER_CONSUMER_ENDPOINT_POOL = {
local: 'ws://localhost:8000',
dev: 'wss://dev.compiler.welldonestudio.io',
prod: 'wss://prod.compiler.welldonestudio.io',
};
export const INJECTIVE_COMPILER_CONSUMER_ENDPOINT = INJECTIVE_COMPILER_CONSUMER_ENDPOINT_POOL[STAGE];

const INJECTIVE_COMPILER_CONSUMER_API_ENDPOINT_POOL = {
local: 'http://localhost:8000',
dev: 'https://dev.compiler.welldonestudio.io',
prod: 'https://prod.compiler.welldonestudio.io/',
};

export const INJECTIVE_COMPILER_CONSUMER_API_ENDPOINT =
INJECTIVE_COMPILER_CONSUMER_API_ENDPOINT_POOL[STAGE];

const ARBITRUM_COMPILER_CONSUMER_ENDPOINT_POOL = {
local: 'ws://localhost:8000',
dev: 'wss://dev.compiler.welldonestudio.io',
prod: 'wss://prod.near.compiler.welldonestudio.io',
local: "ws://localhost:8000",
dev: "wss://dev.compiler.welldonestudio.io",
prod: "wss://prod.near.compiler.welldonestudio.io",
};
export const ARBITRUM_COMPILER_CONSUMER_ENDPOINT = ARBITRUM_COMPILER_CONSUMER_ENDPOINT_POOL[STAGE];

const ARBITRUM_COMPILER_CONSUMER_API_ENDPOINT_POOL = {
local: 'http://localhost:8000',
dev: 'https://dev.compiler.welldonestudio.io',
prod: 'https://verify.welldonestudio.io',
local: "http://localhost:8000",
dev: "https://dev.compiler.welldonestudio.io",
prod: "https://verify.welldonestudio.io",
};

export const ARBITRUM_COMPILER_CONSUMER_API_ENDPOINT =
ARBITRUM_COMPILER_CONSUMER_API_ENDPOINT_POOL[STAGE];
export const ARBITRUM_COMPILER_CONSUMER_API_ENDPOINT = ARBITRUM_COMPILER_CONSUMER_API_ENDPOINT_POOL[STAGE];
14 changes: 3 additions & 11 deletions src/const/helper.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { Annotation, HighlightPosition } from "@remixproject/plugin-api";
import { PROD, STAGE } from "../const/stage";
import { log } from "../utils/logger";

export interface PositionDetails {
Expand Down Expand Up @@ -55,9 +54,7 @@ export const getPositionDetails = (msg: string): PositionDetails => {
};
};

export const isRealError = (pos: Annotation) => {
return pos.row !== -1 && pos.column !== -1;
};
export const isRealError = (pos: Annotation) => pos.row !== -1 && pos.column !== -1;

export const readFile = (file: File): Promise<string> => {
return new Promise((resolve, reject) => {
Expand All @@ -76,13 +73,8 @@ export const readFile = (file: File): Promise<string> => {
});
};

export const stringify = (data: any) => {
return JSON.stringify(data, null, 2);
};
export const stringify = (data: any) => JSON.stringify(data, null, 2);

export const shortenHexString = (address: string, first: number, last: number) => {
return address === "" ? "" : `${address.slice(0, first)}...${address.slice(-last)}`;
};

export const enableAptosProve = () => STAGE !== PROD;
export const enableJuno = () => STAGE !== PROD;
export const enableSui = () => STAGE !== PROD;
47 changes: 18 additions & 29 deletions src/utils/editor.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Client } from '@remixproject/plugin';
import { HighlightPosition, Annotation, IRemixApi } from '@remixproject/plugin-api';
import { Api } from '@remixproject/plugin-utils';
import { log } from './logger';
import { Client } from "@remixproject/plugin";
import { HighlightPosition, Annotation, IRemixApi } from "@remixproject/plugin-api";
import { Api } from "@remixproject/plugin-utils";
import { log } from "./logger";

export class EditorClient {
client;
Expand All @@ -12,75 +12,64 @@ export class EditorClient {
}

getFile = async (name: string) => {
let path = name.startsWith('./') ? name.substr(2) : name;
return this.client.call('fileManager', 'getFile', this.getBrowserPath(path));
let path = name.startsWith("./") ? name.substr(2) : name;
return this.client.call("fileManager", "getFile", this.getBrowserPath(path));
};

getFolder = async () => {
return this.client.call('fileManager', 'getFolder', '/browser');
return this.client.call("fileManager", "getFolder", "/browser");
};

getCurrentFile = async () => {
return this.client.call('fileManager', 'getCurrentFile');
return this.client.call("fileManager", "getCurrentFile");
};

createFile = async (name: string, content: string) => {
try {
await this.client.call('fileManager', 'setFile', name, content);
await this.client.call('fileManager', 'switchFile', name);
await this.client.call("fileManager", "setFile", name, content);
await this.client.call("fileManager", "switchFile", name);
} catch (err) {
log.error(err);
}
};

currentFileChanged = async () => {
this.client.on('fileManager', 'currentFileChanged', (file) => {
this.client.on("fileManager", "currentFileChanged", (file) => {
// this.discardHighlight();
// this.clearAnnotations();
});
};

highlight = async (position: HighlightPosition, file: string, color: string) => {
await this.client.call('editor', 'highlight', position, this.getBrowserPath(file), color, {
await this.client.call("editor", "highlight", position, this.getBrowserPath(file), color, {
focus: true,
});
};

discardHighlight = async () => {
await this.client.call('editor', 'discardHighlight');
await this.client.call("editor", "discardHighlight");
};

gotoLine = async (row: number, col: number) => {
await this.client.call('editor', 'gotoLine', row, col);
await this.client.call("editor", "gotoLine", row, col);
};

addAnnotation = async (annotatioin: Annotation) => {
await this.client.call('editor', 'addAnnotation', annotatioin);
await this.client.call("editor", "addAnnotation", annotatioin);
};

clearAnnotations = async () => {
await this.client.call('editor', 'clearAnnotations');
await this.client.call("editor", "clearAnnotations");
};

switchFile = async (file: string) => {
await this.client.call('fileManager', 'switchFile', this.getBrowserPath(file));
await this.client.call("fileManager", "switchFile", this.getBrowserPath(file));
};

private getBrowserPath = (path: string) => {
if (path.startsWith('browser')) {
if (path.startsWith("browser")) {
return path;
}
return `browser/${path}`;
};
}

export const addErrorNotation = async (
annotation: Annotation,
highlightPosition: HighlightPosition,
positionDetail: Record<string, number | number>,
client: any,
) => {
await client.editor.gotoLine(positionDetail.row, positionDetail.col);
await client.editor.addAnnotation(annotation);
await client.editor.highlightPosition(highlightPosition);
};
63 changes: 5 additions & 58 deletions src/utils/socket.ts
Original file line number Diff line number Diff line change
@@ -1,68 +1,15 @@
import { Socket } from 'socket.io-client';
import { Socket } from "socket.io-client";
import {
COMPILER_ARBITRUM_COMPILE_COMPLETED_V1,
COMPILER_ARBITRUM_COMPILE_ERROR_OCCURRED_V1,
COMPILER_ARBITRUM_COMPILE_LOGGED_V1,
COMPILER_INJECTIVE_COMPILE_COMPLETED_V1,
COMPILER_INJECTIVE_COMPILE_ERROR_OCCURRED_V1,
COMPILER_INJECTIVE_COMPILE_LOGGED_V1,
COMPILER_JUNO_COMPILE_COMPLETED_V1,
COMPILER_JUNO_COMPILE_ERROR_OCCURRED_V1,
COMPILER_JUNO_COMPILE_LOGGED_V1,
COMPILER_NEUTRON_COMPILE_COMPLETED_V1,
COMPILER_NEUTRON_COMPILE_ERROR_OCCURRED_V1,
COMPILER_NEUTRON_COMPILE_LOGGED_V1,
} from 'wds-event';

export function cleanupSocketJuno(socketJuno: Socket) {
const events = [
'connect',
'disconnect',
'connect_error',
COMPILER_JUNO_COMPILE_ERROR_OCCURRED_V1,
COMPILER_JUNO_COMPILE_LOGGED_V1,
COMPILER_JUNO_COMPILE_COMPLETED_V1,
];

for (const event of events) {
socketJuno.off(event);
}
}

export function cleanupSocketNeutron(socketNeutron: Socket) {
const events = [
'connect',
'disconnect',
'connect_error',
COMPILER_NEUTRON_COMPILE_ERROR_OCCURRED_V1,
COMPILER_NEUTRON_COMPILE_LOGGED_V1,
COMPILER_NEUTRON_COMPILE_COMPLETED_V1,
];

for (const event of events) {
socketNeutron.off(event);
}
}

export function cleanupSocketInjective(socketInjective: Socket) {
const events = [
'connect',
'disconnect',
'connect_error',
COMPILER_INJECTIVE_COMPILE_ERROR_OCCURRED_V1,
COMPILER_INJECTIVE_COMPILE_LOGGED_V1,
COMPILER_INJECTIVE_COMPILE_COMPLETED_V1,
];
for (const event of events) {
socketInjective.off(event);
}
}
} from "wds-event";

export function cleanupSocketArbitrum(socketNeutron: Socket) {
const events = [
'connect',
'disconnect',
'connect_error',
"connect",
"disconnect",
"connect_error",
COMPILER_ARBITRUM_COMPILE_ERROR_OCCURRED_V1,
COMPILER_ARBITRUM_COMPILE_LOGGED_V1,
COMPILER_ARBITRUM_COMPILE_COMPLETED_V1,
Expand Down
Loading

0 comments on commit 8350957

Please sign in to comment.