Skip to content

Commit

Permalink
fix: min 5 akt
Browse files Browse the repository at this point in the history
  • Loading branch information
jigar-arc10 committed Jan 20, 2025
1 parent 90e7e12 commit 520fcca
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 36 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ export const ServerAccess: React.FC<ServerAccessProps> = ({ onComplete }) => {
const [showNodeDistribution, setShowNodeDistribution] = useState(false);

const { walletBalances } = useWallet();
const hasEnoughBalance = (walletBalances?.uakt || 0) >= 30000000;
const MIN_BALANCE = 5_000_000;
const hasEnoughBalance = (walletBalances?.uakt || 0) >= MIN_BALANCE;

React.useEffect(() => {
if (!hasEnoughBalance) {
Expand Down Expand Up @@ -57,7 +58,7 @@ export const ServerAccess: React.FC<ServerAccessProps> = ({ onComplete }) => {

const baseControlPlane = 3;
const additionalPairs = Math.floor((totalNodes - 1) / 50);
const controlPlane = Math.min(baseControlPlane + (additionalPairs * 2), 11); // Cap at 11 control plane nodes
const controlPlane = Math.min(baseControlPlane + additionalPairs * 2, 11); // Cap at 11 control plane nodes
return { controlPlane, workerNodes: totalNodes - controlPlane };
}, []);

Expand All @@ -78,21 +79,24 @@ export const ServerAccess: React.FC<ServerAccessProps> = ({ onComplete }) => {
setShowBalancePopup(false);
}, []);

const getCurrentServerType = useCallback((serverIndex: number): ServerTypeInfo => {
const { controlPlane, workerNodes } = calculateNodeDistribution(numberOfServers);
const getCurrentServerType = useCallback(
(serverIndex: number): ServerTypeInfo => {
const { controlPlane } = calculateNodeDistribution(numberOfServers);

if (serverIndex < controlPlane) {
return {
isControlPlane: true,
nodeNumber: serverIndex + 1
};
}

if (serverIndex < controlPlane) {
return {
isControlPlane: true,
nodeNumber: serverIndex + 1
isControlPlane: false,
nodeNumber: serverIndex - controlPlane + 1
};
}

return {
isControlPlane: false,
nodeNumber: serverIndex - controlPlane + 1
};
}, [calculateNodeDistribution, numberOfServers]);
},
[calculateNodeDistribution, numberOfServers]
);

return (
<div className="flex flex-col items-center pt-10">
Expand Down Expand Up @@ -127,29 +131,25 @@ export const ServerAccess: React.FC<ServerAccessProps> = ({ onComplete }) => {
<div className="space-y-6">
<div className="flex gap-6">
<div className="rounded-lg border p-6 text-center">
<p className="text-3xl font-bold mb-4">{calculateNodeDistribution(numberOfServers).controlPlane}</p>
<h3 className="text-xl font-bold mb-2">Control Plane Nodes</h3>
<p className="mb-4 text-3xl font-bold">{calculateNodeDistribution(numberOfServers).controlPlane}</p>
<h3 className="mb-2 text-xl font-bold">Control Plane Nodes</h3>
<p className="text-sm">Manages the cluster operations & run your workloads</p>
</div>
<div className="rounded-lg border p-6 text-center">
<p className="text-3xl font-bold mb-4">{calculateNodeDistribution(numberOfServers).workerNodes}</p>
<h3 className="text-xl font-bold mb-2">Worker Nodes</h3>
<p className="mb-4 text-3xl font-bold">{calculateNodeDistribution(numberOfServers).workerNodes}</p>
<h3 className="mb-2 text-xl font-bold">Worker Nodes</h3>
<p className="text-sm">Runs your workloads</p>
</div>
</div>
<div className="flex w-full justify-between">
<Button variant="ghost" onClick={() => setShowNodeDistribution(false)}>Back</Button>
<Button variant="ghost" onClick={() => setShowNodeDistribution(false)}>
Back
</Button>
<Button onClick={handleDistributionNext}>Next</Button>
</div>
</div>
) : (
<ServerForm
key={currentServer}
currentServerNumber={currentServer}
onComplete={handleServerFormSubmit}
isControlPlane={getCurrentServerType(currentServer).isControlPlane}
nodeNumber={getCurrentServerType(currentServer).nodeNumber}
/>
<ServerForm key={currentServer} currentServerNumber={currentServer} onComplete={handleServerFormSubmit} {...getCurrentServerType(currentServer)} />
)}

<Popup
Expand All @@ -173,7 +173,7 @@ export const ServerAccess: React.FC<ServerAccessProps> = ({ onComplete }) => {
<div>
<div className="pb-2">
<p>
You need at least <strong>30 AKT</strong> to become a provider.
You need at least <strong>5 AKT</strong> to become a provider.
<br />
Every lease created on the Akash network requires <strong>0.5 AKT</strong> to be locked in escrow.
<br />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,14 +64,7 @@ interface ServerFormProps {
nodeNumber?: number;
}

export const ServerForm: React.FC<ServerFormProps> = ({
currentServerNumber,
onComplete,
editMode = false,
controlMachine,
isControlPlane,
nodeNumber
}) => {
export const ServerForm: React.FC<ServerFormProps> = ({ currentServerNumber, onComplete, editMode = false, controlMachine, isControlPlane, nodeNumber }) => {
const [providerProcess, setProviderProcess] = useAtom(providerProcessStore.providerProcessAtom);
const [selectedFile, setSelectedFile] = useState<File | null>(null);
const [storedFileContent, setStoredFileContent] = useState<string | null>(null);
Expand Down Expand Up @@ -305,7 +298,7 @@ export const ServerForm: React.FC<ServerFormProps> = ({
<FormControl>
<Input placeholder="Input your SSH username" {...field} />
</FormControl>
<FormDescription>The username must be "root" for proper setup.</FormDescription>
<FormDescription>The username must be &quot;root&quot; for proper setup.</FormDescription>
<FormMessage />
</FormItem>
)}
Expand Down

0 comments on commit 520fcca

Please sign in to comment.