Skip to content

Commit

Permalink
last modifications and readme
Browse files Browse the repository at this point in the history
  • Loading branch information
tolgayayci committed Feb 14, 2024
1 parent bd16bd8 commit 3bf78a4
Show file tree
Hide file tree
Showing 28 changed files with 497 additions and 246 deletions.
75 changes: 74 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,74 @@
# soroban-cli-gui
# SOROBAN CLI GUI

SOROBAN CLI GUI is a cross platform, electron based application designed to streamline the use of the Soroban CLI. It offers a user-friendly interface for managing projects, identities, networks, and contract methods with ease.

---

## Installation

To use this application, you must have soroban cli installed on your operating system.

> This application is compatible with latest soroban v0.23.0, please make sure you have installed this version or newer of soroban!
- To install soroban, follow the instructions in link below:
- [Install Soroban](https://soroban.stellar.org/docs/getting-started/setup)

- To verify that soroban properly installed, run:
```soroban --version```

Now that you have soroban installed, you can install the SOROBAN CLI GUI application by following the instructions below.

###  macOS (Apple Silicon | Intel)

1. Download the latest release for macOS
1. [Apple Silicon]()
2. [Intel]()
2. Open the downloaded file and drag the application to Applications folder.

### 🐧 Linux

1. Download the latest release for Linux
1. [App Image]()
2. [Snap]()

2. Follow the general instructions to install the application on your Linux distribution.
1. [App Image](https://docs.appimage.org/introduction/quickstart.html#ref-quickstart)
2. [Snap](https://snapcraft.io/docs/installing-snapd)

### 💻 Windows (Not Fully Supported)

You can still use the SOROBAN CLI GUI application on Windows by following the instructions below.

1. Install WSL 2 by following the instructions [on microsoft docs](https://learn.microsoft.com/en-us/windows/wsl/install).
2. Once you have WSL installed, you can install soroban cli by following the instructions for Linux.
3. Follow the instructions for Linux to install the SOROBAN CLI GUI application.
---

## Key Features

**Project Management:** This feature allows users to efficiently manage their projects. It includes capabilities to create new projects, add existing ones from your device, and delete projects that are no longer needed.

**Identity Management:** This component focuses on managing user identities. Users can generate new identities, add existing ones, delete unnecessary identities, and seamlessly switch between different identities.

**Contract Interactions:** This feature is centered around interactions with contracts (project based). Users can interact with them using a variety of contract commands, arguments, and flags through a user-friendly interface.

**Network Management:** Network management is facilitated through the ability to add and remove networks. Users can also display the list of networks.

> **P.S:** Review the [latest release notes](https://github.com/tolgayayci/soroban-cli-gui/releases/tag/v0.1.0) for more information about the features and capabilities of the SOROBAN CLI GUI application.
## Contributing

Contributions are welcomed! If you have feature requests, bug notifications or want to contribute some code, please follow the instructions below.
- **Feature Requests:** Use the [feature requests issue](https://github.com/tolgayayci/soroban-cli-gui/issues/new?assignees=tolgayayci&labels=enhancement&projects=&template=feature_request.md&title=%5BFEAT%5D) template.
- **Bug Reports:** Use the [bug reports issue](https://github.com/tolgayayci/soroban-cli-gui/issues/new?assignees=tolgayayci&labels=bug&projects=&template=bug_report.md&title=%5BBUG%5D) template.
- **Code Contributions**
- Fork this repository
- Create a new branch
- Make your changes
- Commit your changes
- Push to the branch that you opened
- Create a new pull request with some details about your changes

## License

SOROBAN CLI GUI is released under the **MIT**. See ([LICENSE](https://github.com/tolgayayci/soroban-cli-gui/blob/main/LICENSE)) for more details.
4 changes: 2 additions & 2 deletions electron-builder.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
appId: com.example.nextron
productName: My Nextron App
copyright: Copyright © 2018 Yoshihide Shiono
productName: soroban-cli-gui
copyright: Copyright © 2024 Tolga Yaycı
directories:
output: dist
buildResources: resources
Expand Down
12 changes: 6 additions & 6 deletions main/background.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// const fixPath = require("fix-path");
// fixPath();
const fixPath = require("fix-path");
fixPath();

import { app, ipcMain, dialog } from "electron";
import serve from "electron-serve";
Expand Down Expand Up @@ -171,13 +171,13 @@ if (isProd) {
try {
if (mainWindow) {
const result = await executeSorobanCommand("--version");
const isDfxInstalled = result.trim().startsWith("soroban");
return isDfxInstalled;
const isSorobanInstalled = result.trim().startsWith("soroban");
return isSorobanInstalled;
} else {
console.error("Main window not found");
}
} catch (error) {
console.error(`Error while checking for Dfinity installation: ${error}`);
console.error(`Error while checking for Soroban installation: ${error}`);
return false;
}
});
Expand Down Expand Up @@ -243,7 +243,7 @@ if (isProd) {
const envVars = retrieveAndStoreIdentities();
return envVars;
} catch (error) {
console.error("Failed to read identities from dfx:", error);
console.error("Failed to read identities from soroban:", error);
return { error };
}
});
Expand Down
19 changes: 19 additions & 0 deletions main/helpers/manage-identities.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,25 @@ export function handleIdentities(store, action, identity, newIdentity?) {
};
break;

case "setActive":
// First, reset the active state for all identities
identities = identities.map((i) => ({
...i,
active: false,
}));

// Then, find and set the specified identity as active
const index = identities.findIndex((i) => i.name === identity.name);
if (index !== -1) {
identities[index].active = true;
} else {
throw new Error("Identity not found");
}

// Persist the updated identities list back to the store
store.set("identities", identities);
break;

case "delete":
const keyToDelete = identity.isInternetIdentity
? "internetIdentityPrincipal"
Expand Down
9 changes: 7 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,17 @@
"private": true,
"name": "soroban-cli-gui",
"description": "Soroban Cli Cross Platform Desktop Application",
"version": "0.0.1",
"version": "0.1.0",
"author": "Tolga Yaycı <tolgayayci@protonmail.com>",
"main": "app/background.js",
"scripts": {
"dev": "nextron",
"build": "nextron build",
"build:mac": "nextron build --mac",
"build:mac:universal": "nextron build --mac --universal",
"build:linux": "nextron build --linux",
"build:win32": "nextron build --win --ia32",
"build:win64": "nextron build --win --x64",
"postinstall": "electron-builder install-app-deps"
},
"dependencies": {
Expand Down Expand Up @@ -35,7 +40,7 @@
"cmdk": "^0.2.1",
"electron-serve": "^1.3.0",
"electron-store": "^8.1.0",
"fix-path": "^4.0.0",
"fix-path": "3.0.0",
"lucide-react": "^0.323.0",
"next-themes": "^0.2.1",
"react-hook-form": "^7.50.0",
Expand Down
2 changes: 1 addition & 1 deletion renderer/components/contracts/Contracts.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { useEffect, useState } from "react";
import useProjects from "hooks/useProjects";
import { useProjects } from "hooks/useProjects";

import { createContractsColumns } from "components/contracts/contracts-columns";
import { ContractsDataTable } from "components/contracts/contracts-data-table";
Expand Down
10 changes: 7 additions & 3 deletions renderer/components/contracts/command-selector.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ const CliCommandSelector = ({
const [commandArgs, setCommandArgs] = useState({});
const [commandOptions, setCommandOptions] = useState({});
const [isRunningCommand, setIsRunningCommand] = useState(false);
const [latestCommand, setLatestCommand] = useState(""); // State to hold the latest command
const [latestCommand, setLatestCommand] = useState("");

const updateLatestCommand = () => {
const selectedCommandDetails = commands.find(
Expand Down Expand Up @@ -127,7 +127,6 @@ const CliCommandSelector = ({
try {
await runCli(selectedCommand, Object.values(commandArgs)).then(() => {
// toast success message
console.log("Command executed successfully");
});
} catch (error) {
// toast error message
Expand Down Expand Up @@ -164,6 +163,10 @@ const CliCommandSelector = ({
isNaN(arg) ? arg : parseInt(arg, 10)
);

console.log(
command + " " + processedArgs + " " + optionsArray + " " + path
);

const result = await window.sorobanApi.runSorobanCommand(
"contract",
command,
Expand All @@ -172,14 +175,15 @@ const CliCommandSelector = ({
path
);

console.log("Command executed successfully:", result);
console.log("Result:", result);

setCommandError("");
setCommandOutput(result);
}
} catch (error) {
setCommandError(`${error.message}`);
setCommandOutput(""); // Clear any previous output
throw error;
}
};

Expand Down
107 changes: 107 additions & 0 deletions renderer/components/contracts/command-status-config.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
import dynamic from "next/dynamic";
import { useEffect, useState } from "react";
import Link from "next/link";

import {
Accordion,
AccordionContent,
AccordionItem,
AccordionTrigger,
} from "components/ui/accordion";
import { Button } from "components/ui/button";
import { Alert, AlertDescription, AlertTitle } from "components/ui/alert";
import { AlertCircle, ThumbsUpIcon, ThumbsDownIcon } from "lucide-react";
import { ScrollArea, ScrollBar } from "components/ui/scroll-area";

export default function CommandStatusConfig({
canister,
projectPath,
commandOutput,
commandError,
}: {
canister: any;
projectPath: string;
commandOutput: string;
commandError: string;
}) {
const [canisterStatus, setCanisterStatus] = useState<any>(null);
const [accordionValue, setAccordionValue] = useState<string>("status");

useEffect(() => {
// Set the accordion to open the last item if there is command output or an error
if (commandOutput || commandError) {
setAccordionValue("output");
} else {
setAccordionValue("status");
}
}, [commandOutput, commandError]);

function parseCliOutput(output) {
const result = {};
// Replace multiple spaces with a single space and then split the string into parts.
const parts = output.replace(/\s+/g, " ").trim().split(" ");

let currentKey = "";
let currentValue = "";

parts.forEach((part) => {
if (part.endsWith(":")) {
// If the current part ends with a colon, it's a key.
if (currentKey && currentValue) {
// Save the previous key-value pair.
result[currentKey] = currentValue.trim();
}
// Start a new key-value pair.
currentKey = part.slice(0, -1); // Remove the colon from the key.
currentValue = "";
} else {
// Otherwise, it's part of the value.
currentValue += part + " ";
}
});

// Don't forget to add the last key-value pair.
if (currentKey && currentValue) {
result[currentKey] = currentValue.trim();
}

return result;
}

return (
<ScrollArea className="h-[calc(100vh-200px)] overflow-y-auto">
<Accordion
type="single"
value={accordionValue}
onValueChange={setAccordionValue}
collapsible
className="w-full space-y-4"
>
<AccordionItem value="output" className="border px-3 rounded-lg">
<AccordionTrigger className="text-sm">
Canister Output
</AccordionTrigger>
<AccordionContent>
<div>
{commandOutput && (
<Alert>
<ThumbsUpIcon className="h-4 w-4 text-green-600" />
<AlertTitle>Command Output</AlertTitle>
<AlertDescription>{commandOutput}</AlertDescription>
</Alert>
)}
{commandError && (
<Alert variant="destructive">
<AlertCircle className="h-4 w-4" />
<AlertTitle>Error</AlertTitle>
<AlertDescription>{commandError}</AlertDescription>
</Alert>
)}
</div>
</AccordionContent>
</AccordionItem>
</Accordion>
<ScrollBar />
</ScrollArea>
);
}
Loading

0 comments on commit 3bf78a4

Please sign in to comment.