Skip to content

Commit b80e49f

Browse files
Merge branch 'develop-iota2.0' into fix/show-real-total-mana-in-balance-breakdown
2 parents 3b65e2c + d805b5a commit b80e49f

29 files changed

+138
-128
lines changed

packages/desktop/components/popups/MintNativeTokenConfirmationPopup.svelte

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,12 @@
3232
3333
async function prepareFoundryOutput(): Promise<void> {
3434
if ($mintTokenDetails && $selectedWallet && metadata) {
35-
const { totalSupply, circulatingSupply, accountId } = $mintTokenDetails
35+
const { totalSupply, circulatingSupply, accountAddress } = $mintTokenDetails
3636
const outputData = await buildFoundryOutputData(
3737
Number(totalSupply),
3838
Number(circulatingSupply),
3939
metadata,
40-
accountId
40+
accountAddress
4141
)
4242
const client = await getClient()
4343
const preparedOutput = await client.buildFoundryOutput(outputData)
@@ -61,10 +61,10 @@
6161
details: IMintTokenDetails | undefined
6262
): { [key: string]: { data: string; tooltipText?: string; isCopyable?: boolean } } | undefined {
6363
if (details) {
64-
const { name: tokenName, symbol, accountId, url, logoUrl, decimals, totalSupply } = details
64+
const { name: tokenName, symbol, accountAddress, url, logoUrl, decimals, totalSupply } = details
6565
return {
66-
...(accountId && {
67-
account: { data: accountId, isCopyable: true },
66+
...(accountAddress && {
67+
account: { data: accountAddress, isCopyable: true },
6868
}),
6969
...(storageDeposit && {
7070
storageDeposit: { data: storageDeposit },

packages/desktop/components/popups/MintNativeTokenFormPopup.svelte

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import { localize } from '@core/i18n'
44
import { setMintTokenDetails, mintTokenDetails, IMintTokenDetails } from '@core/wallet'
55
import { closePopup, openPopup, PopupId } from '@auxiliary/popup'
6-
import { Button, Error, NumberInput, Text, TextInput, OptionalInput, FontWeight, AccountInput } from '@ui'
6+
import { Button, Error, NumberInput, Text, TextInput, OptionalInput, FontWeight, AccountInput, TextType } from '@ui'
77
import { onMount } from 'svelte'
88
import { MAX_SUPPORTED_DECIMALS } from '@core/wallet/constants/max-supported-decimals.constants'
99
import { handleError } from '@core/error/handlers/handleError'
@@ -19,7 +19,7 @@
1919
description: undefined,
2020
url: undefined,
2121
logoUrl: undefined,
22-
accountId: undefined,
22+
accountAddress: undefined,
2323
}
2424
2525
let {
@@ -31,7 +31,7 @@
3131
description,
3232
url,
3333
logoUrl,
34-
accountId,
34+
accountAddress,
3535
} = $mintTokenDetails ?? DEFAULT
3636
3737
let nameError: string = ''
@@ -42,8 +42,8 @@
4242
$: circulatingSupply, (circulatingSupplyError = '')
4343
let symbolError: string
4444
$: symbol, (symbolError = '')
45-
let accountIdError: string
46-
$: accountId, (accountIdError = '')
45+
let accountAddressError: string
46+
$: accountAddress, (accountAddressError = '')
4747
4848
let error: BaseError
4949
let decimalsInput: OptionalInput
@@ -64,7 +64,7 @@
6464
description,
6565
url,
6666
logoUrl,
67-
accountId,
67+
accountAddress,
6868
}
6969
if (valid && isEverythingDefined(tokenDetailsForm)) {
7070
setMintTokenDetails(tokenDetailsForm)
@@ -82,7 +82,7 @@
8282
form.circulatingSupply !== undefined &&
8383
form.decimals !== undefined &&
8484
form.symbol !== undefined &&
85-
form.accountId !== undefined
85+
form.accountAddress !== undefined
8686
)
8787
}
8888
@@ -170,12 +170,12 @@
170170
</script>
171171

172172
<div class="space-y-6">
173-
<Text type="h4" fontSize="18" lineHeight="6" fontWeight={FontWeight.semibold}>
173+
<Text type={TextType.h4} fontSize="18" lineHeight="6" fontWeight={FontWeight.semibold}>
174174
{localize('popups.nativeToken.formTitle')}
175175
</Text>
176176

177177
<div class="space-y-4 max-h-100 scrollable-y flex-1">
178-
<AccountInput bind:this={accountInput} bind:account={accountId} bind:error={accountIdError} />
178+
<AccountInput bind:this={accountInput} bind:account={accountAddress} bind:error={accountAddressError} />
179179
<TextInput
180180
bind:value={tokenName}
181181
label={localize('popups.nativeToken.property.tokenName')}
@@ -212,25 +212,25 @@
212212
maxlength={MAX_SUPPORTED_DECIMALS}
213213
label={localize('popups.nativeToken.property.decimals')}
214214
description={localize('tooltips.mintNativeToken.decimals')}
215-
fontSize="14"
215+
fontSize={14}
216216
/>
217217
<OptionalInput
218218
bind:value={description}
219219
label={localize('popups.nativeToken.property.description')}
220220
description={localize('tooltips.mintNativeToken.description')}
221-
fontSize="14"
221+
fontSize={14}
222222
/>
223223
<OptionalInput
224224
bind:value={url}
225225
label={localize('popups.nativeToken.property.url')}
226226
description={localize('tooltips.mintNativeToken.url')}
227-
fontSize="14"
227+
fontSize={14}
228228
/>
229229
<OptionalInput
230230
bind:value={logoUrl}
231231
label={localize('popups.nativeToken.property.logoUrl')}
232232
description={localize('tooltips.mintNativeToken.logoUrl')}
233-
fontSize="14"
233+
fontSize={14}
234234
/>
235235
</optional-inputs>
236236
{#if error}

packages/desktop/features/developer-tools.features.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ const developerToolsFeatures: IDeveloperFeatures = {
99
enabled: true,
1010
},
1111
mintNativeTokens: {
12-
enabled: false,
12+
enabled: true,
1313
},
1414
account: {
1515
enabled: false,

packages/desktop/views/dashboard/Dashboard.svelte

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
import { onDestroy, onMount } from 'svelte'
1919
import Sidebar from './Sidebar.svelte'
2020
import TopNavigation from './TopNavigation.svelte'
21-
2221
import {
2322
addNftsToDownloadQueue,
2423
downloadingNftId,
@@ -28,12 +27,11 @@
2827
resetNftDownloadQueue,
2928
selectedWalletNfts,
3029
} from '@core/nfts'
31-
import { selectedWalletId } from '@core/wallet'
30+
import { clearBalanceSyncPoll, selectedWalletId, syncBalancePoll } from '@core/wallet'
3231
import { get } from 'svelte/store'
3332
import features from '@features/features'
34-
import { isAwareOfMetricSystemDrop } from '@contexts/dashboard/stores'
33+
import { isAwareOfMetricSystemDrop, showBalanceOverviewPopup } from '@contexts/dashboard/stores'
3534
import { openPopup, PopupId } from '@auxiliary/popup'
36-
import { showBalanceOverviewPopup } from '@contexts/dashboard/stores'
3735
3836
const tabs = {
3937
wallet: Wallet,
@@ -83,6 +81,7 @@
8381
}
8482
8583
onMount(() => {
84+
syncBalancePoll($selectedWalletId, true)
8685
Platform.onEvent('menu-logout', () => {
8786
void logout()
8887
})
@@ -126,6 +125,7 @@
126125
})
127126
128127
onDestroy(() => {
128+
clearBalanceSyncPoll()
129129
Platform.DeepLinkManager.clearDeepLinkRequest()
130130
Platform.removeListenersForEvent('deep-link-params')
131131

packages/desktop/views/dashboard/Sidebar.svelte

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@
7676
...(features?.delegation?.enabled
7777
? [
7878
{
79-
icon: IconEnum.Sync,
79+
icon: IconEnum.Staking,
8080
label: localize('tabs.delegation'),
8181
route: DashboardRoute.Delegation,
8282
onClick: openDelegation,

packages/desktop/views/dashboard/wallet/views/implicit-account-creation-multistep/FundConfirmationView.svelte

Lines changed: 35 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -6,28 +6,31 @@
66
ITransactionInfoToCalculateManaCost,
77
getManaBalance,
88
getPassiveManaForOutput,
9+
DEFAULT_SECONDS_PER_SLOT,
910
} from '@core/network'
1011
import { activeProfile } from '@core/profile'
1112
import { implicitAccountCreationRouter } from '@core/router'
13+
import { MILLISECONDS_PER_SECOND, SECONDS_PER_MINUTE, getBestTimeDuration } from '@core/utils'
1214
import { IWalletState, formatTokenAmountBestMatch, selectedWallet, selectedWalletAssets } from '@core/wallet'
1315
import { OutputData } from '@iota/sdk/out/types'
1416
import { Button, FontWeight, KeyValueBox, Text, TextType, TextHint, TextHintVariant, CopyableBox } from '@ui'
1517
import { onDestroy, onMount } from 'svelte'
1618
1719
export let outputId: string | undefined
1820
19-
// TODO: update when mana generation is available
20-
const isLowManaGeneration = false
21+
const LOW_MANA_GENERATION_SECONDS = 10 * SECONDS_PER_MINUTE
22+
2123
let walletAddress: string = ''
2224
const transactionInfo: ITransactionInfoToCalculateManaCost = {}
2325
let hasEnoughMana = false
26+
let isLowManaGeneration = false
2427
2528
$: baseCoin = $selectedWalletAssets?.[$activeProfile?.network?.id]?.baseCoin
2629
2730
$: selectedOutput = getSelectedOutput($selectedWallet, outputId)
2831
2932
let totalAvailableMana: number
30-
$: $selectedWallet, seconds, (totalAvailableMana = getTotalAvailableMana())
33+
$: $selectedWallet, (totalAvailableMana = getTotalAvailableMana()), prepareTransaction(selectedOutput?.outputId)
3134
3235
let formattedSelectedOutputBlance: string
3336
$: selectedOutput,
@@ -53,14 +56,14 @@
5356
function getTotalAvailableMana(): number {
5457
return (
5558
getManaBalance($selectedWallet?.balances?.mana?.available) +
56-
$selectedWallet?.balances.totalWalletBic -
57-
getImplicitAccountsMana($selectedWallet?.implicitAccountOutputs, [outputId])
59+
($selectedWallet?.balances.totalWalletBic ?? 0) -
60+
getImplicitAccountsMana($selectedWallet?.implicitAccountOutputs, outputId ? [outputId] : [])
5861
)
5962
}
6063
61-
function getImplicitAccountsMana(implicitAccountOutputs: OutputData[], excludeIds: string[] | undefined): number {
64+
function getImplicitAccountsMana(implicitAccountOutputs: OutputData[], excludeIds: string[]): number {
6265
return implicitAccountOutputs?.reduce((acc: number, outputData: OutputData) => {
63-
if (excludeIds && excludeIds.includes(outputData.outputId)) {
66+
if (excludeIds.length > 1 && !excludeIds.includes(outputData.outputId)) {
6467
const totalMana = getPassiveManaForOutput(outputData)
6568
return totalMana ? acc + totalMana : acc
6669
} else {
@@ -69,28 +72,40 @@
6972
}, 0)
7073
}
7174
72-
// TODO: Replace this with proper time remaining
75+
async function prepareTransaction(outputId: string): Promise<void> {
76+
if (!outputId) return
77+
try {
78+
transactionInfo.preparedTransaction = await $selectedWallet?.prepareImplicitAccountTransition(outputId)
79+
seconds = 0 // If we don't get an error, it's because we can follow on to the next step
80+
} catch (error) {
81+
console.error(error.message)
82+
if (error.message?.includes('slots remaining until enough mana')) {
83+
transactionInfo.preparedTransactionError = error.message
84+
const slotsRemaining = Number(error.message?.split(' ').reverse()[0].replace('`', ''))
85+
seconds = slotsRemaining * DEFAULT_SECONDS_PER_SLOT
86+
isLowManaGeneration = seconds >= LOW_MANA_GENERATION_SECONDS
87+
}
88+
}
89+
}
90+
7391
// ----------------------------------------------------------------
7492
let seconds: number = 10
7593
let countdownInterval: NodeJS.Timeout
7694
let timeRemaining: string
7795
78-
$: timeRemaining = `${seconds}s remaining`
96+
$: timeRemaining = `${getBestTimeDuration(seconds * MILLISECONDS_PER_SECOND)} remaining`
7997
8098
onMount(async () => {
81-
walletAddress = await $selectedWallet?.address()
82-
$selectedWallet
83-
.prepareImplicitAccountTransition(selectedOutput.outputId)
84-
.then((prepareTx) => (transactionInfo.preparedTransaction = prepareTx))
85-
.catch((error) => (transactionInfo.preparedTransactionError = error))
99+
$selectedWallet?.address().then((address) => (walletAddress = address))
100+
await prepareTransaction(selectedOutput.outputId)
101+
if (seconds === 0) onTimeout()
86102
countdownInterval = setInterval(() => {
87103
seconds -= 1
88-
89104
if (seconds <= 0) {
90105
clearInterval(countdownInterval)
91106
onTimeout()
92107
}
93-
}, 1000)
108+
}, MILLISECONDS_PER_SECOND)
94109
})
95110
96111
onDestroy(() => {
@@ -103,10 +118,10 @@
103118
// ----------------------------------------------------------------
104119
</script>
105120

106-
<step-content class="flex flex-col items-center justify-between h-full pt-20">
107-
<div class="flex flex-col h-full justify-between space-y-8 items-center">
121+
<step-content class={`flex flex-col items-center justify-between h-full ${isLowManaGeneration ? 'pt-8' : 'pt-20'}`}>
122+
<div class="flex flex-col h-full justify-between space-y-4 items-center">
108123
<div class="flex flex-col text-center space-y-4 max-w-md">
109-
<div class="flex items-center justify-center mb-7">
124+
<div class={`flex items-center justify-center ${isLowManaGeneration ? 'mb-2' : 'mb-7'}`}>
110125
<img
111126
src="assets/illustrations/implicit-account-creation/step2.svg"
112127
alt={localize('views.implicit-account-creation.steps.step2.title')}
@@ -140,7 +155,7 @@
140155
</div>
141156
</div>
142157
{#if isLowManaGeneration}
143-
<div class="flex flex-col space-y-4 w-2/3">
158+
<div class="flex flex-col space-y-2 w-2/3">
144159
<TextHint
145160
variant={TextHintVariant.Warning}
146161
text={localize('views.implicit-account-creation.steps.step2.view.walletAddress.description')}

packages/shared/components/inputs/AccountInput.svelte

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@
1313
let modal: Modal = undefined
1414
1515
const accountOptions: IOption[] =
16-
$selectedWallet.balances?.accounts.map((hexAccountId: string, index: number) => {
17-
const accountId = AddressConverter.addressToBech32(new AccountAddress(hexAccountId))
18-
return { key: 'Account' + (index + 1), value: accountId }
16+
$selectedWallet?.balances?.accounts.map((hexAccountId: string, index: number) => {
17+
const accountAddress = AddressConverter.addressToBech32(new AccountAddress(hexAccountId))
18+
return { key: 'Account ' + (index + 1), value: accountAddress }
1919
}) ?? []
2020
2121
let selected: IOption = accountOptions.find((option) => option.value === account)

packages/shared/components/inputs/OptionalInput.svelte

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
88
export let label: string = ''
99
export let description: string = ''
10-
export let value: string | undefined = undefined
10+
export let value: string | number | undefined = undefined
1111
export let fontSize: number = 15
1212
export let error: string = ''
1313
export let classes: string = null

packages/shared/components/tiles/tileContents/TransactionActivityTileContent.svelte

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
activity.direction === ActivityDirection.SelfTransaction
2222
? localize('general.internalTransaction')
2323
: localize(isIncoming ? 'general.fromAddress' : 'general.toAddress', {
24-
values: { account: getSubjectLocaleFromActivity(activity) },
24+
values: { address: getSubjectLocaleFromActivity(activity) },
2525
})
2626
2727
$: amount = getFormattedAmountFromActivity(activity)

packages/shared/lib/core/nfts/constants/default-nft-feature-entry-key.constant.ts

Lines changed: 0 additions & 1 deletion
This file was deleted.

packages/shared/lib/core/nfts/constants/index.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,3 @@ export * from './default-max-nft-downloading-time-in-seconds.constant'
44
export * from './default-max-nft-size-in-megabytes.constant'
55
export * from './nft-id-byte-length.constant'
66
export * from './nft-media-file-name.constant'
7-
export * from './default-nft-feature-entry-key.constant'

packages/shared/lib/core/nfts/tests/buildNftFromNftOutput.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { plainToInstance } from 'class-transformer'
22
import { IWrappedOutput } from '../../wallet/interfaces'
3+
import { DEFAULT_METADATA_FEATURE_ENTRY_KEY } from '../../wallet/constants'
34
import { buildNftFromNftOutput } from '../utils/buildNftFromNftOutput'
45
import {
56
AddressUnlockCondition,
@@ -10,7 +11,6 @@ import {
1011
TimelockUnlockCondition,
1112
} from '@iota/sdk/out/types'
1213
import { Address, AddressType, NftOutput } from '@iota/sdk/out/types'
13-
import { DEFAULT_NFT_FEATURE_ENTRY_KEY } from '../constants'
1414

1515
const accountAddress = 'rms1qr47ee0fhahukrzec088v9lngv7w5k2sn3jjtwvkcpjfgxhhsazlsurxrx9'
1616

@@ -22,7 +22,7 @@ function buildImmutableFeatures() {
2222
return [
2323
new IssuerFeature(new Ed25519Address('0x20dceb927cfdc2cea642fbf77aed81f42400145b5a4fd906f1aa40af1c31afb1')),
2424
new MetadataFeature({
25-
[DEFAULT_NFT_FEATURE_ENTRY_KEY]:
25+
[DEFAULT_METADATA_FEATURE_ENTRY_KEY]:
2626
'0x7b227374616e64617264223a224952433237222c2276657273696f6e223a2276312e30222c226e616d65223a227364617364222c2274797065223a22696d6167652f706e67222c22757269223a2268747470733a2f2f697066732e696f2f697066732f516d51717a4d546176516754346634543576365057427037584e4b746f506d43396a766e313257505433676b5345227d',
2727
}),
2828
]
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import { DEFAULT_SECONDS_PER_SLOT } from '../../network'
2+
import { MILLISECONDS_PER_SECOND } from '../../utils'
3+
import { syncBalance } from './syncBalance'
4+
5+
let balanceSyncInterval: number
6+
7+
export async function syncBalancePoll(walletId: string, syncCongestion: boolean): Promise<void> {
8+
await syncBalance(walletId, syncCongestion)
9+
balanceSyncInterval = window.setInterval(() => {
10+
void syncBalance(walletId, syncCongestion)
11+
}, DEFAULT_SECONDS_PER_SLOT * MILLISECONDS_PER_SECOND)
12+
}
13+
14+
export function clearBalanceSyncPoll(): void {
15+
clearInterval(balanceSyncInterval)
16+
}

0 commit comments

Comments
 (0)