diff --git a/.gitignore b/.gitignore index e4b612a7d..de0f01ea7 100644 --- a/.gitignore +++ b/.gitignore @@ -87,6 +87,9 @@ dist # Stores VSCode versions used for testing VSCode extensions .vscode-test +# IDE files +.idea + # yarn v2 .yarn/cache .yarn/unplugged @@ -98,4 +101,4 @@ dist build.ps1 # Data Folder -data \ No newline at end of file +data diff --git a/deploy-web/src/components/sdl/PlacementFormModal.tsx b/deploy-web/src/components/sdl/PlacementFormModal.tsx index 6dd1f6d87..865e3561f 100644 --- a/deploy-web/src/components/sdl/PlacementFormModal.tsx +++ b/deploy-web/src/components/sdl/PlacementFormModal.tsx @@ -10,7 +10,7 @@ import { AttributesFormControl, AttributesRefType } from "./AttributesFormContro import { CustomTooltip } from "../shared/CustomTooltip"; import InfoIcon from "@mui/icons-material/Info"; import { PriceValue } from "../shared/PriceValue"; -import { getAvgCostPerMonth } from "@src/utils/priceUtils"; +import { getAvgCostPerMonth, toReadableDenom } from "@src/utils/priceUtils"; import { uAktDenom } from "@src/utils/constants"; import { useSdlDenoms } from "@src/hooks/useDenom"; import { FormattedNumber } from "react-intl"; @@ -81,7 +81,7 @@ export const PlacementFormModal: React.FunctionComponent = ({ control, se title="Edit placement" actions={[ { - label: "Close", + label: "Done", color: "primary", variant: "text", side: "right", @@ -150,27 +150,6 @@ export const PlacementFormModal: React.FunctionComponent = ({ control, se - Token - { - return ( - - ); - }} - /> - = ({ control, se ({ - formControl: { - marginBottom: theme.spacing(1.5) - } -})); - export const RentGpusForm: React.FunctionComponent = ({}) => { - const theme = useTheme(); - const { classes } = useStyles(); const [error, setError] = useState(null); // const [templateMetadata, setTemplateMetadata] = useState(null); const [isCreatingDeployment, setIsCreatingDeployment] = useState(false); @@ -65,9 +56,8 @@ export const RentGpusForm: React.FunctionComponent = ({}) => { region: { ...defaultAnyRegion } } }); - const { services: _services, region: _region } = watch(); + const { services: _services } = watch(); const router = useRouter(); - const supportedSdlDenoms = useSdlDenoms(); const currentService: Service = _services[0] || ({} as any); const { settings } = useSettings(); const { address, signAndBroadcastTx } = useWallet(); @@ -273,36 +263,7 @@ export const RentGpusForm: React.FunctionComponent = ({}) => { - - Token - { - return ( - - ); - }} - /> - + diff --git a/deploy-web/src/components/sdl/SimpleServiceFormControl.tsx b/deploy-web/src/components/sdl/SimpleServiceFormControl.tsx index bd7f9ffb6..82a0a8534 100644 --- a/deploy-web/src/components/sdl/SimpleServiceFormControl.tsx +++ b/deploy-web/src/components/sdl/SimpleServiceFormControl.tsx @@ -19,7 +19,7 @@ import { PlacementFormModal } from "./PlacementFormModal"; import { udenomToDenom } from "@src/utils/mathHelpers"; import Link from "next/link"; import { PriceValue } from "../shared/PriceValue"; -import { getAvgCostPerMonth } from "@src/utils/priceUtils"; +import { getAvgCostPerMonth, toReadableDenom } from "@src/utils/priceUtils"; import Image from "next/legacy/image"; import { uAktDenom } from "@src/utils/constants"; import { ProviderAttributesSchema } from "@src/types/providerAttributes"; @@ -31,6 +31,7 @@ import { GpuFormControl } from "./GpuFormControl"; import { CpuFormControl } from "./CpuFormControl"; import { MemoryFormControl } from "./MemoryFormControl"; import { StorageFormControl } from "./StorageFormControl"; +import { TokenFormControl } from "./TokenFormControl"; type Props = { _services: Service[]; @@ -391,6 +392,10 @@ export const SimpleServiceFormControl: React.FunctionComponent = ({ )} /> + + + + @@ -434,7 +439,7 @@ export const SimpleServiceFormControl: React.FunctionComponent = ({
Pricing   - Max {udenomToDenom(currentService.placement.pricing.amount, 6)} AKT per block + Max {udenomToDenom(currentService.placement.pricing.amount, 6)} {toReadableDenom(currentService.placement.pricing.denom)} per block = Path> { + name: TName; + defaultValue?: FieldPathValue; + control: Control; +} + +const useStyles = makeStyles()(theme => ({ + formControl: { + marginBottom: theme.spacing(1.5) + } +})); + +export const TokenFormControl = ({ control, name, defaultValue }: Props): ReactElement> => { + const { classes } = useStyles(); + const supportedSdlDenoms = useSdlDenoms(); + + return ( + + Token + { + return ( + + ); + }} + /> + + ); +}; diff --git a/deploy-web/src/utils/constants.ts b/deploy-web/src/utils/constants.ts index 5e7c8244e..660a78c74 100644 --- a/deploy-web/src/utils/constants.ts +++ b/deploy-web/src/utils/constants.ts @@ -56,6 +56,13 @@ export const usdcIbcDenoms = { [mainnetId]: "ibc/170C677610AC31DF0904FFE09CD3B5C657492170E7E52372E48756B71E56F2F1", [sandboxId]: "ibc/12C6A0C374171B595A0A9E18B83FA09D295FB1F2D8C6DAA3AC28683471752D84" }; +const readableAktDenom = "AKT"; +const readableUsdcDenom = "USDC"; +export const readableDenoms = { + [uAktDenom]: readableAktDenom, + [usdcIbcDenoms[mainnetId]]: readableUsdcDenom, + [usdcIbcDenoms[sandboxId]]: readableUsdcDenom +}; // Cloudmos fee export const feePercent = 3; diff --git a/deploy-web/src/utils/priceUtils.ts b/deploy-web/src/utils/priceUtils.ts index ae09a81e1..94d6482ad 100644 --- a/deploy-web/src/utils/priceUtils.ts +++ b/deploy-web/src/utils/priceUtils.ts @@ -4,7 +4,7 @@ import { averageDaysInMonth } from "./dateUtils"; import { Coin } from "@cosmjs/stargate"; import { denomToUdenom } from "./mathHelpers"; import { getUsdcDenom } from "@src/hooks/useDenom"; -import { uAktDenom } from "./constants"; +import { readableDenoms, uAktDenom } from "./constants"; export const averageBlockTime = 6.098; @@ -76,3 +76,7 @@ export function useRealTimeLeft(pricePerBlock: number, balance: number, settledA amountSpent: Math.min(blocksSinceCreation * pricePerBlock, balance) }; } + +export function toReadableDenom(denom: string) { + return readableDenoms[denom]; +} diff --git a/deploy-web/src/utils/sdl/sdlGenerator.ts b/deploy-web/src/utils/sdl/sdlGenerator.ts index c9124835d..4d410787e 100644 --- a/deploy-web/src/utils/sdl/sdlGenerator.ts +++ b/deploy-web/src/utils/sdl/sdlGenerator.ts @@ -128,7 +128,7 @@ export const generateSdl = (services: Service[], region?: string) => { // Placement sdl.profiles.placement[service.placement.name] = sdl.profiles.placement[service.placement.name] || { pricing: {} }; sdl.profiles.placement[service.placement.name].pricing[service.title] = { - denom: "uakt", + denom: service.placement.pricing.denom, amount: service.placement.pricing.amount };