diff --git a/src/routes/[network]/(account)/resources/+page.svelte b/src/routes/[network]/(account)/resources/+page.svelte index 70fbe1b6..60b7ab79 100644 --- a/src/routes/[network]/(account)/resources/+page.svelte +++ b/src/routes/[network]/(account)/resources/+page.svelte @@ -4,29 +4,19 @@ import CpuIcon from '$lib/assets/resources/cpu.svg'; import NetIcon from '$lib/assets/resources/net.svg'; import RamIcon from '$lib/assets/resources/ram.svg'; - import CpuAndNetOverview from './components/cpunet.svelte'; import RamOverview from './components/ram.svelte'; + import { calAvailableSize } from './utils'; import type { UnicoveContext } from '$lib/state/client.svelte'; import { getContext } from 'svelte'; - import { ResourceType } from './types'; - import { ResourceState } from './state.svelte'; - const { data } = $props(); - const context = getContext('state'); - const ramState = $state(new ResourceState(ResourceType.RAM)); - const cpuState = $state(new ResourceState(ResourceType.CPU)); - const netState = $state(new ResourceState(ResourceType.NET)); - - $effect(() => { - ramState.setResource(context.account?.ram); - cpuState.setResource(context.account?.cpu); - netState.setResource(context.account?.net); - }); + const cpuAvailableSize = $derived(calAvailableSize(context.account?.cpu)); + const netAvailableSize = $derived(calAvailableSize(context.account?.net)); + const ramAvailableSize = $derived(calAvailableSize(context.account?.ram)); const network = String(data.network); const chainName = data.network.chain.name; @@ -80,13 +70,13 @@
{#if data.network.supports('powerup')} @@ -104,7 +94,7 @@ {/if} - + diff --git a/src/routes/[network]/(account)/resources/components/forms/powerup.svelte b/src/routes/[network]/(account)/resources/components/forms/powerup.svelte deleted file mode 100644 index cec2d230..00000000 --- a/src/routes/[network]/(account)/resources/components/forms/powerup.svelte +++ /dev/null @@ -1,139 +0,0 @@ - - -{#if transactionId} - -{/if} - -
- - - - {#if rentState.insufficientBalance} -

Insufficient balance. Please enter a smaller amount.

- {/if} - {#if rentState.balance} -

- Available:{rentState.balance} -

- {/if} - {#if rentState.pricePerUnit} -

- Price:{rentState.pricePerUnit} -

- {/if} - - {#if rentState.error} -

- Error: {rentState.error} -

- {/if} - -
-
diff --git a/src/routes/[network]/(account)/resources/components/forms/rex.svelte b/src/routes/[network]/(account)/resources/components/forms/rex.svelte deleted file mode 100644 index 094c038a..00000000 --- a/src/routes/[network]/(account)/resources/components/forms/rex.svelte +++ /dev/null @@ -1,134 +0,0 @@ - - -{#if transactionId} - -{/if} - -
- - - - {#if rentState.insufficientBalance} -

Insufficient balance. Please enter a smaller amount.

- {/if} - {#if rentState.balance} -

- Available:{rentState.balance} -

- {/if} - {#if rentState.pricePerUnit} -

- Price:{rentState.pricePerUnit} -

- {/if} - - {#if rentState.error} -

- Error: {rentState.error} -

- {/if} - -
-
diff --git a/src/routes/[network]/(account)/resources/components/forms/staking.svelte b/src/routes/[network]/(account)/resources/components/forms/staking.svelte deleted file mode 100644 index 53b6f610..00000000 --- a/src/routes/[network]/(account)/resources/components/forms/staking.svelte +++ /dev/null @@ -1,143 +0,0 @@ - - -{#if transactionId} - -{/if} - -
- - - - - {#if !assetValidPrecision} -

Invalid number, too many decimal places.

- {/if} - - - {#if !assetValidMaximum} -

Amount exceeds available balance.

- {/if} - - {#if rentState.balance} -

- Available:{rentState.balance} -

- {/if} - {#if rentState.pricePerUnit} -

- Price:{rentState.pricePerUnit} -

- {/if} - - {#if rentState.error} -

- Error: {rentState.error} -

- {/if} - -
-
diff --git a/src/routes/[network]/(account)/resources/components/forms/state.svelte.ts b/src/routes/[network]/(account)/resources/components/forms/state.svelte.ts deleted file mode 100644 index 55a48483..00000000 --- a/src/routes/[network]/(account)/resources/components/forms/state.svelte.ts +++ /dev/null @@ -1,144 +0,0 @@ -import { Asset, Name } from '@wharfkit/antelope'; -import { ChainDefinition } from '@wharfkit/common'; -import { RentType, ResourceType } from '../../types'; -import type { ActionNames } from '$lib/wharf/contracts/system'; -import { getName, getUnit } from '../../utils'; - -const defaultName = Name.from(''); -const defaultSymbol = Asset.Symbol.from('0,UNKNOWN'); -const defaultQuantity = Asset.fromUnits(0, defaultSymbol); - -export class RentState { - public chain: ChainDefinition; - public resourceType: ResourceType; - public rentType: RentType; - public resourceName; - public resourceUnit; - - public payer: Name = $state(defaultName); - public receiver: Name = $state(defaultName); - - public balance: Asset | undefined = $state(); - public amount: number | undefined = $state(); - public pricePerUnit: Asset | undefined = $state(); - public cost: Asset = $derived.by(() => { - if (this.pricePerUnit && this.amount != undefined) { - return Asset.from( - Number(this.pricePerUnit.value) * Number(this.amount), - this.pricePerUnit.symbol - ); - } - return Asset.from(0, this.chain.systemToken!.symbol); - }); - - //set for staking - public quantity: Asset = $state(defaultQuantity); - //set for powerup - public frac: number = $state(0); - - //transaction error - public error: string = $state(''); - - public min: number | undefined = $derived( - this.balance ? Asset.fromUnits(1, this.balance.symbol).value : undefined - ); - public max: number | undefined = $derived(this.balance ? this.balance.value : undefined); - - public insufficientBalance: boolean = $derived.by(() => { - if (this.cost && this.balance) return this.cost.value > this.balance.value; - return false; - }); - - constructor(chain: ChainDefinition, resource: ResourceType, rent: RentType) { - this.chain = chain; - this.resourceType = resource; - this.rentType = rent; - this.resourceName = getName(resource); - this.resourceUnit = getUnit(resource); - this.quantity = Asset.fromUnits(0, this.chain.systemToken!.symbol); - } - - reset() { - this.payer = defaultName; - this.receiver = defaultName; - this.balance = undefined; - this.amount = undefined; - this.pricePerUnit = undefined; - this.quantity = Asset.from(0, this.chain.systemToken!.symbol); - this.frac = 0; - this.error = ''; - } - - resetBeforeTransction() { - this.error = ''; - } - - resetAfterTransction() { - this.quantity = Asset.from(0, this.chain.systemToken!.symbol); - this.amount = undefined; - this.error = ''; - } - - getActionName(): ActionNames { - switch (this.rentType) { - case RentType.REX: - if (this.resourceType == ResourceType.CPU) { - return 'rentcpu'; - } else { - return 'rentnet'; - } - case RentType.STAKE: - return 'delegatebw'; - case RentType.POWERUP: - return 'powerup'; - } - } - - getDepositData() { - return { - owner: this.payer, - amount: this.cost - }; - } - - getActionData() { - switch (this.rentType) { - case RentType.REX: - return { - from: this.payer, - receiver: this.receiver, - loan_payment: this.cost, - loan_fund: Asset.fromUnits(0, this.chain.systemToken!.symbol) - }; - case RentType.STAKE: { - const cpuQuantity = - this.resourceType == ResourceType.CPU - ? this.quantity - : Asset.fromUnits(0, this.chain.systemToken!.symbol); - const netQuantity = - this.resourceType == ResourceType.CPU - ? Asset.fromUnits(0, this.chain.systemToken!.symbol) - : this.quantity; - return { - from: this.payer, - receiver: this.receiver, - stake_cpu_quantity: cpuQuantity, - stake_net_quantity: netQuantity, - transfer: false - }; - } - case RentType.POWERUP: { - const cpuFrac = this.resourceType == ResourceType.CPU ? this.frac : 0; - const netFrac = this.resourceType == ResourceType.CPU ? 0 : this.frac; - return { - payer: this.payer, - receiver: this.receiver, - days: 1, - net_frac: netFrac, - cpu_frac: cpuFrac, - max_payment: this.cost - }; - } - } - } -} diff --git a/src/routes/[network]/(account)/resources/components/overview/resources.svelte b/src/routes/[network]/(account)/resources/components/overview/resources.svelte deleted file mode 100644 index 24db2bd7..00000000 --- a/src/routes/[network]/(account)/resources/components/overview/resources.svelte +++ /dev/null @@ -1,28 +0,0 @@ - - -
-
- -
{resourceState.name}
-
-
-

{resourceState.name}

-

{resourceState.usedSize} {resourceState.unit}

-

{resourceState.usagePerc}% Quota used

-
-
- {#if children} -
{@render children()}
- {/if} -
diff --git a/src/routes/[network]/(account)/resources/components/renting.svelte b/src/routes/[network]/(account)/resources/components/renting.svelte index 4d9a49d4..ce5f7e9f 100644 --- a/src/routes/[network]/(account)/resources/components/renting.svelte +++ b/src/routes/[network]/(account)/resources/components/renting.svelte @@ -6,25 +6,23 @@ import AssetText from '$lib/components/elements/asset.svelte'; import Checkbox from '$lib/components/input/checkbox.svelte'; import Button from '$lib/components/button/button.svelte'; + import Transaction from '$lib/components/transaction.svelte'; import CpuAndNetOverview from './cpunet.svelte'; - import { preventDefault } from '$lib/utils'; - import { RentState } from './state.svelte'; - import { getCpuAndNetPrice, getPowerupFrac, RentType } from '../utils'; - import type { NetworkState } from '$lib/state/network.svelte'; - import type { AccountState } from '$lib/state/client/account.svelte'; - import { ResourceState } from '../state.svelte'; - import { ResourceType } from '../types'; - import type { PowerUpState } from '@wharfkit/resources'; - import { getSetting } from '$lib/state/settings.svelte.js'; + import { Checksum256, type TransactResult } from '@wharfkit/session'; import { getContext } from 'svelte'; + import { getSetting } from '$lib/state/settings.svelte.js'; import type { UnicoveContext } from '$lib/state/client.svelte'; - import { Checksum256, type TransactResult } from '@wharfkit/session'; - import Transaction from '$lib/components/transaction.svelte'; + import type { NetworkState } from '$lib/state/network.svelte'; + import type { AccountState } from '$lib/state/client/account.svelte'; + import type { PowerUpState } from '@wharfkit/resources'; - const context = getContext('state'); + import { preventDefault } from '$lib/utils'; + import { RentState } from './state.svelte'; + import { calAvailableSize, getCpuAndNetPrice, getPowerupFrac, type RentType } from '../utils'; + const context = getContext('state'); const debugMode = getSetting('debug-mode', true); interface Props { @@ -35,12 +33,12 @@ const { rentType, network, account }: Props = $props(); - const cpuState = $state(new ResourceState(ResourceType.CPU)); - const netState = $state(new ResourceState(ResourceType.NET)); - - $effect(() => { - cpuState.setResource(account?.cpu); - netState.setResource(account?.net); + const cpuAvailableSize = $derived(calAvailableSize(context.account?.cpu)); + const netAvailableSize = $derived(calAvailableSize(context.account?.net)); + const usableTime = $derived.by(() => { + if (rentType === 'POWERUP') return '24 Hours'; + if (rentType === 'REX') return '30 Days'; + return 'Until Unstaked'; }); $effect(() => { @@ -49,13 +47,13 @@ rentState.payer = account.name; } const stateType = - rentType === RentType.POWERUP + rentType === 'POWERUP' ? network.powerupstate - : rentType === RentType.REX + : rentType === 'REX' ? network.rexstate : network.sampledUsage?.account; if (stateType && network.sampledUsage && network.chain.systemToken) { - if (rentType === RentType.POWERUP) { + if (rentType === 'POWERUP') { const fracs = getPowerupFrac(stateType as PowerUpState, network.sampledUsage, { cpuAmout: Number(rentState.cpuAmount || 0), netAmount: Number(rentState.netAmount || 0) @@ -125,11 +123,7 @@ {/if}
- +
@@ -191,12 +185,7 @@ Usable for - {#if rentType === RentType.POWERUP}24 Hours - {:else if rentType === RentType.REX}30 Days - {:else}Until Unstaked - {/if} - + {usableTime} Total cost @@ -258,7 +247,7 @@ NetQuantity {rentState.netQuantity} - {#if rentType === RentType.POWERUP} + {#if rentType === 'POWERUP'} CpuFrac {rentState.cpuFrac} diff --git a/src/routes/[network]/(account)/resources/components/state.svelte.ts b/src/routes/[network]/(account)/resources/components/state.svelte.ts index 859b7067..d34561cc 100644 --- a/src/routes/[network]/(account)/resources/components/state.svelte.ts +++ b/src/routes/[network]/(account)/resources/components/state.svelte.ts @@ -1,8 +1,9 @@ import { type Action, Asset, Name } from '@wharfkit/antelope'; import { ChainDefinition } from '@wharfkit/common'; -import { RentType } from '../types'; import type { Contract } from '@wharfkit/contract'; +import type { RentType } from '../utils'; + const defaultName = Name.from(''); const defaultSymbol = Asset.Symbol.from('0,UNKNOWN'); const defaultQuantity = Asset.fromUnits(0, defaultSymbol); @@ -109,11 +110,11 @@ export class RentState { getActions(contract: Contract): Action[] { switch (this.rentType) { - case RentType.POWERUP: + case 'POWERUP': return this.getPowerUpActions(contract); - case RentType.REX: + case 'REX': return this.getRexActions(contract); - case RentType.STAKE: + case 'STAKE': return this.getStakeActions(contract); } } @@ -132,8 +133,7 @@ export class RentState { } private getRexActions(contract: Contract) { - let actions = []; - + const actions = []; if (this.cpuQuantity.value) { const cpuDepositAction = contract.action('deposit', { owner: this.payer, diff --git a/src/routes/[network]/(account)/resources/components/state/prices.svelte b/src/routes/[network]/(account)/resources/components/state/prices.svelte deleted file mode 100644 index 700165b3..00000000 --- a/src/routes/[network]/(account)/resources/components/state/prices.svelte +++ /dev/null @@ -1,123 +0,0 @@ - - -
-

- Resource Provider Costs for {resourceName} -

-

- Select a Resource Provider from the choices below to increase your {resourceName}. -

- - - {#if context.network?.supports('powerup')} -
-
Power up
-
- {#if powerupPrice} - {powerupPrice.quantity} - {/if} -
-
- {#if powerupPrice} - {powerupPrice.symbol.code} per {resourceUnit.toUpperCase()} - {/if} -
-
Usable for up to
24 hours.
- -
- {/if} - {#if context.network?.supports('rentrex')} -
-
REX
-
- {#if rexPrice} - {rexPrice.quantity} - {/if} -
-
- {#if rexPrice} - {rexPrice.symbol.code} per {resourceUnit.toUpperCase()} - {/if} -
-
Usable each day for
the next 30 days.
- -
- {/if} - {#if context.network?.supports('stakeresource')} -
-
Staking
-
- {#if stakingPrice} - {stakingPrice.quantity} - {/if} -
-
- {#if stakingPrice} - {stakingPrice.symbol.code} per {resourceUnit.toUpperCase()} - {/if} -
-
Usable each day until
they are unstaked.
- -
- {/if} -
-
diff --git a/src/routes/[network]/(account)/resources/components/state/state.svelte b/src/routes/[network]/(account)/resources/components/state/state.svelte deleted file mode 100644 index acceff3e..00000000 --- a/src/routes/[network]/(account)/resources/components/state/state.svelte +++ /dev/null @@ -1,57 +0,0 @@ - - -
-
- {resourceState.usagePerc}% -
-
-

{resourceState.name}

-

Resource Statistics

-
    -
  • - Available: - {resourceState.availableSize} {resourceState.unit} -
  • -
  • - Used: - {resourceState.usedSize} {resourceState.unit} -
  • -
  • - Maximum: - {resourceState.maxSize} {resourceState.unit} -
  • -
-
-
diff --git a/src/routes/[network]/(account)/resources/cpu/+page.svelte b/src/routes/[network]/(account)/resources/cpu/+page.svelte deleted file mode 100644 index 47a43d05..00000000 --- a/src/routes/[network]/(account)/resources/cpu/+page.svelte +++ /dev/null @@ -1,23 +0,0 @@ - - - - - - - diff --git a/src/routes/[network]/(account)/resources/cpu/powerup/+page.svelte b/src/routes/[network]/(account)/resources/cpu/powerup/+page.svelte deleted file mode 100644 index 16e665d5..00000000 --- a/src/routes/[network]/(account)/resources/cpu/powerup/+page.svelte +++ /dev/null @@ -1,17 +0,0 @@ - - - - - - - - diff --git a/src/routes/[network]/(account)/resources/cpu/rex/+page.svelte b/src/routes/[network]/(account)/resources/cpu/rex/+page.svelte deleted file mode 100644 index 8a0cbaa3..00000000 --- a/src/routes/[network]/(account)/resources/cpu/rex/+page.svelte +++ /dev/null @@ -1,17 +0,0 @@ - - - - - - - - diff --git a/src/routes/[network]/(account)/resources/cpu/stake/+page.svelte b/src/routes/[network]/(account)/resources/cpu/stake/+page.svelte deleted file mode 100644 index 9a47b9c4..00000000 --- a/src/routes/[network]/(account)/resources/cpu/stake/+page.svelte +++ /dev/null @@ -1,17 +0,0 @@ - - - - - - - - diff --git a/src/routes/[network]/(account)/resources/net/+page.svelte b/src/routes/[network]/(account)/resources/net/+page.svelte deleted file mode 100644 index a203ccb6..00000000 --- a/src/routes/[network]/(account)/resources/net/+page.svelte +++ /dev/null @@ -1,22 +0,0 @@ - - - - - - - diff --git a/src/routes/[network]/(account)/resources/net/powerup/+page.svelte b/src/routes/[network]/(account)/resources/net/powerup/+page.svelte deleted file mode 100644 index 031a3bab..00000000 --- a/src/routes/[network]/(account)/resources/net/powerup/+page.svelte +++ /dev/null @@ -1,17 +0,0 @@ - - - - - - - - diff --git a/src/routes/[network]/(account)/resources/net/rex/+page.svelte b/src/routes/[network]/(account)/resources/net/rex/+page.svelte deleted file mode 100644 index bc2d1596..00000000 --- a/src/routes/[network]/(account)/resources/net/rex/+page.svelte +++ /dev/null @@ -1,17 +0,0 @@ - - - - - - - - diff --git a/src/routes/[network]/(account)/resources/net/stake/+page.svelte b/src/routes/[network]/(account)/resources/net/stake/+page.svelte deleted file mode 100644 index 1bb07fa6..00000000 --- a/src/routes/[network]/(account)/resources/net/stake/+page.svelte +++ /dev/null @@ -1,17 +0,0 @@ - - - - - - - - diff --git a/src/routes/[network]/(account)/resources/powerup/+page.svelte b/src/routes/[network]/(account)/resources/powerup/+page.svelte index 7c7f24de..8474efbf 100644 --- a/src/routes/[network]/(account)/resources/powerup/+page.svelte +++ b/src/routes/[network]/(account)/resources/powerup/+page.svelte @@ -4,18 +4,14 @@ import type { UnicoveContext } from '$lib/state/client.svelte'; import { getContext } from 'svelte'; - import { RentType } from '../types'; - const { data } = $props(); const context = getContext('state'); const network = data.network; const account = $derived(context.account); - - function handleRent() {}
- +
diff --git a/src/routes/[network]/(account)/resources/rex/+page.svelte b/src/routes/[network]/(account)/resources/rex/+page.svelte index 46e8a435..24b6ca0b 100644 --- a/src/routes/[network]/(account)/resources/rex/+page.svelte +++ b/src/routes/[network]/(account)/resources/rex/+page.svelte @@ -4,18 +4,13 @@ import type { UnicoveContext } from '$lib/state/client.svelte'; import { getContext } from 'svelte'; - import { RentType } from '../types'; - const { data } = $props(); - const context = getContext('state'); const network = data.network; const account = $derived(context.account); - - function handleRent() {}
- +
diff --git a/src/routes/[network]/(account)/resources/stake/+page.svelte b/src/routes/[network]/(account)/resources/stake/+page.svelte index b51d7e4b..ffe28f67 100644 --- a/src/routes/[network]/(account)/resources/stake/+page.svelte +++ b/src/routes/[network]/(account)/resources/stake/+page.svelte @@ -4,16 +4,13 @@ import type { UnicoveContext } from '$lib/state/client.svelte'; import { getContext } from 'svelte'; - import { RentType } from '../types'; - const { data } = $props(); - const context = getContext('state'); const network = data.network; const account = $derived(context.account); -
- +
+
diff --git a/src/routes/[network]/(account)/resources/state.svelte.ts b/src/routes/[network]/(account)/resources/state.svelte.ts deleted file mode 100644 index 4d3dded4..00000000 --- a/src/routes/[network]/(account)/resources/state.svelte.ts +++ /dev/null @@ -1,33 +0,0 @@ -import { Resource } from '@wharfkit/account'; -import { ResourceType } from './types'; -import { calSize, calUsagePer, getName, getUnit } from './utils'; - -export class ResourceState { - private resourceType: ResourceType; - public name: string; - public unit: string; - public availableSize = $state(0); - public usedSize = $state(0); - public maxSize = $state(0); - public usagePerc = $state(100); - - constructor(type: ResourceType) { - this.resourceType = type; - this.name = getName(type); - this.unit = getUnit(type); - } - - setResource(resource: Resource | undefined) { - if (resource) { - this.availableSize = calSize(Number(resource.available)); - this.usedSize = calSize(Number(resource.used)); - this.maxSize = calSize(Number(resource.max)); - this.usagePerc = calUsagePer(Number(resource.used), Number(resource.max)); - } else { - this.availableSize = 0; - this.usedSize = 0; - this.maxSize = 0; - this.usagePerc = 100; - } - } -} diff --git a/src/routes/[network]/(account)/resources/types.ts b/src/routes/[network]/(account)/resources/types.ts deleted file mode 100644 index 1812d21f..00000000 --- a/src/routes/[network]/(account)/resources/types.ts +++ /dev/null @@ -1,11 +0,0 @@ -export enum RentType { - POWERUP, - REX, - STAKE -} - -export enum ResourceType { - RAM, - CPU, - NET -} diff --git a/src/routes/[network]/(account)/resources/utils.ts b/src/routes/[network]/(account)/resources/utils.ts index 1ef0f9b3..9a6d9aca 100644 --- a/src/routes/[network]/(account)/resources/utils.ts +++ b/src/routes/[network]/(account)/resources/utils.ts @@ -1,14 +1,10 @@ -import { ResourceType } from './types'; import { PowerUpState } from '@wharfkit/resources'; import type { REXState } from '@wharfkit/resources'; import { API, Asset } from '@wharfkit/antelope'; import type { SampledUsage } from '$lib/types'; +import type { Resource } from '@wharfkit/account'; -export enum RentType { - POWERUP, - REX, - STAKE -} +export type RentType = 'POWERUP' | 'REX' | 'STAKE'; export interface PricePair { cpuPrice: Asset; @@ -17,46 +13,11 @@ export interface PricePair { type ResourceStateType = PowerUpState | REXState | API.v1.AccountObject; -export const calSize = (available: number) => { +export const calAvailableSize = (resource?: Resource) => { let size = 0; + const available = Number(resource?.available); if (!isNaN(available)) size = available / 1000; - return Number(size.toFixed(2)); -}; - -export const calUsagePer = (used: number, max: number) => { - let percentage = 100; - if (isNaN(max) || isNaN(used)) { - percentage = 0; - } else if (max === 0) { - percentage = 100; - } else { - percentage = (used / max) * 100; - if (percentage > 100) { - percentage = 100; - } - } - return Number(percentage.toFixed(1)); -}; - -export const getName = (resourceType: ResourceType) => { - switch (resourceType) { - case ResourceType.RAM: - return 'RAM'; - case ResourceType.CPU: - return 'CPU'; - case ResourceType.NET: - return 'NET'; - } -}; - -export const getUnit = (resourceType: ResourceType) => { - switch (resourceType) { - case ResourceType.RAM: - case ResourceType.NET: - return 'kb'; - case ResourceType.CPU: - return 'ms'; - } + return size; }; export const getCpuAndNetPrice = ( @@ -66,7 +27,7 @@ export const getCpuAndNetPrice = ( systemTokenSymbol: Asset.Symbol ): PricePair => { switch (rentType) { - case RentType.POWERUP: { + case 'POWERUP': { const cpuPrice = (stateType as PowerUpState).cpu.price_per_ms(sampleUsage, 1); const netPrice = (stateType as PowerUpState).net.price_per_kb(sampleUsage, 1); return { @@ -74,7 +35,7 @@ export const getCpuAndNetPrice = ( netPrice: compatPriceWithPrecision(netPrice, systemTokenSymbol) }; } - case RentType.REX: { + case 'REX': { const cpuPrice = (stateType as REXState).cpu_price_per_ms(sampleUsage, 30); const netPrice = (stateType as REXState).net_price_per_kb(sampleUsage, 30); return { @@ -82,7 +43,7 @@ export const getCpuAndNetPrice = ( netPrice: compatPriceWithPrecision(netPrice, systemTokenSymbol) }; } - case RentType.STAKE: { + case 'STAKE': { const account = stateType as API.v1.AccountObject; const cpuPrice = account.cpu_weight.multiplying(1000).dividing(account.cpu_limit.max); const netPrice = account.net_weight.multiplying(1000).dividing(account.net_limit.max);