diff --git a/src/routes/[network]/(account)/resources/components/renting.svelte b/src/routes/[network]/(account)/resources/components/renting.svelte index b6140b23..2412647e 100644 --- a/src/routes/[network]/(account)/resources/components/renting.svelte +++ b/src/routes/[network]/(account)/resources/components/renting.svelte @@ -16,11 +16,15 @@ import { ResourceType } from '../types'; import type { PowerUpState } from '@wharfkit/resources'; + import { getSetting } from '$lib/state/settings.svelte.js'; + import { getContext } from 'svelte'; import type { UnicoveContext } from '$lib/state/client.svelte'; const context = getContext('state'); + const debugMode = getSetting('debug-mode', true); + interface Props { rentType: RentType; network: NetworkState; @@ -41,7 +45,6 @@ if (account && network) { if (account.name) { rentState.payer = account.name; - rentState.receiver = account.name; } const stateType = rentType === RentType.POWERUP @@ -73,9 +76,6 @@ } }); - let rentingForSelf = $state(true); - let receiverInputValid = $state(false); - let receiverInput: NameInput | undefined = $state(); const rentState: RentState = $state(new RentState(network.chain, RentType.STAKE)); @@ -98,24 +98,6 @@
-
-

test info

-

receiver: {rentState.receiver}

-

cpuPricePerMs: {rentState.cpuPricePerMs}, netPricePerKb: {rentState.netPricePerKb}

-

liquid: {rentState.balance}

- -

valid

-

rentingForSelf: {rentingForSelf}

-

receiverInputValid: {receiverInputValid}

- -

Cost

-

cpuAmount: {rentState.cpuAmount}, netAmount: {rentState.netAmount}

-

cpu: {rentState.cpuQuantity} net: {rentState.netQuantity}

-

cost: {rentState.cost}

- {#if rentType === RentType.POWERUP} -

cpuFrac: {rentState.cpuFrac}, netFrac: {rentState.netFrac}

- {/if} -
- +
-
+
@@ -185,6 +167,29 @@ - + + + {#if debugMode} +
+

Test Info:

+

receiver: {rentState.receiver}

+

rentingForSelf: {rentState.rentingForSelf}

+

thirdReceiver: {rentState.thirdReceiver}

+

cpuPricePerMs: {rentState.cpuPricePerMs}, netPricePerKb: {rentState.netPricePerKb}

+

liquid: {rentState.balance}

+ +

valid:

+

Valid: {rentState.valid}

+

ReceiverInputValid: {rentState.thirdReceiverValid}

+ +

Cost

+

cpuAmount: {rentState.cpuAmount}, netAmount: {rentState.netAmount}

+

cpu: {rentState.cpuQuantity} net: {rentState.netQuantity}

+

cost: {rentState.cost}

+ {#if rentType === RentType.POWERUP} +

cpuFrac: {rentState.cpuFrac}, netFrac: {rentState.netFrac}

+ {/if} +
+ {/if}
diff --git a/src/routes/[network]/(account)/resources/components/state.svelte.ts b/src/routes/[network]/(account)/resources/components/state.svelte.ts index c6ae4c48..d08725d5 100644 --- a/src/routes/[network]/(account)/resources/components/state.svelte.ts +++ b/src/routes/[network]/(account)/resources/components/state.svelte.ts @@ -11,8 +11,14 @@ export class RentState { public chain: ChainDefinition; public rentType: RentType; + public rentingForSelf = $state(true); + public thirdReceiver: Name = $state(defaultName); + public thirdReceiverValid = $state(false); + public payer: Name = $state(defaultName); - public receiver: Name = $state(defaultName); + public receiver: Name = $derived( + this.rentingForSelf ? this.payer : this.thirdReceiverValid ? this.thirdReceiver : defaultName + ); public balance: Asset = $state(defaultQuantity); @@ -81,7 +87,6 @@ export class RentState { reset() { this.payer = defaultName; - this.receiver = defaultName; this.balance = defaultQuantity; this.cpuAmount = undefined; this.netAmount = undefined;