Skip to content

Commit

Permalink
Merge branch 'develop' into 582-all-activities-with-metadata-are-inte…
Browse files Browse the repository at this point in the history
…rpreted-as-smart-contract-calls
  • Loading branch information
nicole-obrien authored Sep 5, 2023
2 parents 9685753 + 611ba5e commit d93663d
Show file tree
Hide file tree
Showing 38 changed files with 220 additions and 264 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import { sumBalanceForAccounts } from '@core/account'
import { selectedAccount } from '@core/account/stores'
import { formatCurrency, localize } from '@core/i18n'
import { getMarketAmountFromTokenValue } from '@core/market/utils'
import { getMarketAmountFromTokenValue } from '@core/market/actions'
import { getBaseToken } from '@core/profile/actions'
import { activeProfile, visibleActiveAccounts } from '@core/profile/stores'
import { formatTokenAmountBestMatch } from '@core/token'
Expand All @@ -15,7 +15,7 @@
export let modal: Modal = undefined
$: totalBalance = sumBalanceForAccounts($visibleActiveAccounts)
$: ({ baseCoin } = $selectedAccountTokens[$activeProfile?.network.id])
$: baseCoin = $selectedAccountTokens[$activeProfile?.network.id]?.baseCoin
async function scrollToSelectedAccount(): Promise<void> {
await tick()
Expand Down Expand Up @@ -55,7 +55,7 @@
{formatTokenAmountBestMatch(totalBalance, getBaseToken())}
</Text>
<Text fontSize="12" fontWeight={FontWeight.semibold} lineHeight="20" color="blue-500">
{formatCurrency(getMarketAmountFromTokenValue(totalBalance, baseCoin))}
{baseCoin ? formatCurrency(getMarketAmountFromTokenValue(totalBalance, baseCoin)) : undefined}
</Text>
</div>
</button>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@
import { handleError } from '@core/error/handlers'
import { localize } from '@core/i18n'
import { checkActiveProfileAuth } from '@core/profile/actions'
import { IToken, formatTokenAmountBestMatch } from '@core/token'
import { ITokenWithBalance, formatTokenAmountBestMatch } from '@core/token'
import { burnToken } from '@core/wallet'
import { PopupId, closePopup, openPopup } from '@desktop/auxiliary/popup'
import { Button, ButtonVariant, FontWeight, Text, TextHint, TextType } from '@ui'
import { onMount } from 'svelte'
export let token: IToken
export let token: ITokenWithBalance
export let rawAmount: string
export let _onMount: (..._: any[]) => Promise<void> = async () => {}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<script lang="ts">
import { Button, Text, TextHint, FontWeight, TextType, TokenAmountWithSliderInput } from '@ui'
import { localize } from '@core/i18n'
import { closePopup, openPopup, PopupId } from '@desktop/auxiliary/popup'
import { IToken } from '@core/token'
import { ITokenWithBalance } from '@core/token'
import { PopupId, closePopup, openPopup } from '@desktop/auxiliary/popup'
import { Button, FontWeight, Text, TextHint, TextType, TokenAmountWithSliderInput } from '@ui'
export let token: IToken
export let token: ITokenWithBalance
export let rawAmount: string = '0'
let tokenAmountInput: TokenAmountWithSliderInput
Expand Down
16 changes: 8 additions & 8 deletions packages/desktop/components/popups/TokenInformationPopup.svelte
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
<script lang="ts">
import { localize } from '@core/i18n'
import { setSendFlowParameters, SendFlowType } from '@core/wallet'
import { TokenStandard, IToken, NotVerifiedStatus, VerifiedStatus, BASE_TOKEN_ID } from '@core/token'
import { openPopup, PopupId, updatePopupProps } from '@desktop/auxiliary/popup'
import { Button, FontWeight, Text, TextHint, TokenActionsButton, TextType, TokenAmountTile, TooltipIcon } from '@ui'
import { Table } from '@bloomwalletio/ui'
import { SendFlowRoute, SendFlowRouter, sendFlowRouter } from '@views/dashboard/send-flow'
import { Icon as IconEnum } from '@lib/auxiliary/icon'
import { localize } from '@core/i18n'
import { BASE_TOKEN_ID, ITokenWithBalance, NotVerifiedStatus, TokenStandard, VerifiedStatus } from '@core/token'
import { unverifyToken, verifyToken } from '@core/token/stores'
import { SendFlowType, setSendFlowParameters } from '@core/wallet'
import { PopupId, openPopup, updatePopupProps } from '@desktop/auxiliary/popup'
import { Icon as IconEnum } from '@lib/auxiliary/icon'
import { Button, FontWeight, Text, TextHint, TextType, TokenActionsButton, TokenAmountTile, TooltipIcon } from '@ui'
import { SendFlowRoute, SendFlowRouter, sendFlowRouter } from '@views/dashboard/send-flow'
export let token: IToken | undefined
export let token: ITokenWithBalance | undefined
export let activityId: string = undefined
function onSkipClick(): void {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
<script lang="ts">
import { localize } from '@core/i18n'
import { IToken, formatTokenAmountDefault, getUnitFromTokenMetadata } from '@core/token'
import { ITokenWithBalance, formatTokenAmountDefault, getUnitFromTokenMetadata } from '@core/token'
import { getTokenBalance } from '@core/token/actions'
import { getTokenFromSelectedAccountTokens } from '@core/token/stores'
import { SendFlowType, sendFlowParameters, updateSendFlowParameters } from '@core/wallet'
import { TokenAmountInput, TokenAvailableBalanceTile } from '@ui'
import { sendFlowRouter } from '../send-flow.router'
import SendFlowTemplate from './SendFlowTemplate.svelte'
let tokenAmountInput: TokenAmountInput
let token: IToken
let token: ITokenWithBalance
let rawAmount: string
let amount: string
let unit: string
Expand All @@ -17,18 +19,21 @@
$sendFlowParameters.type === SendFlowType.BaseCoinTransfer ||
$sendFlowParameters.type === SendFlowType.TokenTransfer
) {
token = $sendFlowParameters[tokenKey].token
token = getTokenFromSelectedAccountTokens(
$sendFlowParameters[tokenKey].token?.id,
$sendFlowParameters[tokenKey].token?.networkId
)
rawAmount = $sendFlowParameters[tokenKey].rawAmount
unit = $sendFlowParameters[tokenKey].unit || getUnitFromTokenMetadata(token?.metadata)
}
$: availableBalance = token?.balance?.available
$: tokenBalance = getTokenBalance(token?.id, token?.networkId)
function setToMax(): void {
if (token?.metadata?.decimals) {
amount = formatTokenAmountDefault(availableBalance, token?.metadata, unit, false)
amount = formatTokenAmountDefault(tokenBalance?.available, token?.metadata, unit, false)
} else {
amount = availableBalance.toString() ?? '0'
amount = tokenBalance?.available?.toString() ?? '0'
}
}
Expand All @@ -39,7 +44,7 @@
updateSendFlowParameters({
type: $sendFlowParameters.type,
[tokenKey]: {
token,
token: $sendFlowParameters[tokenKey].token,
rawAmount,
unit,
},
Expand All @@ -54,7 +59,7 @@
updateSendFlowParameters({
type: $sendFlowParameters.type,
[tokenKey]: {
token,
token: $sendFlowParameters[tokenKey].token,
rawAmount: undefined,
unit,
},
Expand All @@ -76,7 +81,10 @@
bind:rawAmount
bind:inputtedAmount={amount}
{unit}
{availableBalance}
availableBalance={tokenBalance?.available}
/>
<TokenAvailableBalanceTile
token={getTokenFromSelectedAccountTokens(token.id, token.networkId)}
onMaxClick={setToMax}
/>
<TokenAvailableBalanceTile {token} onMaxClick={setToMax} />
</SendFlowTemplate>
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
import { canAccountMakeEvmTransaction } from '@core/layer-2/actions'
import { marketCoinPrices } from '@core/market/stores'
import { getNetwork } from '@core/network'
import { AccountTokens, BASE_TOKEN_ID, IToken, TokenStandard } from '@core/token'
import { getAccountTokensForSelectedAccount } from '@core/token/actions'
import { AccountTokens, BASE_TOKEN_ID, IToken, ITokenWithBalance, TokenStandard } from '@core/token'
import { getAccountTokensForSelectedAccount, getTokenBalance } from '@core/token/actions'
import { selectedAccountTokens } from '@core/token/stores'
import { SendFlowType, sendFlowParameters, setSendFlowParameters } from '@core/wallet'
import { closePopup } from '@desktop/auxiliary/popup'
Expand All @@ -27,10 +27,11 @@
let accountTokens: AccountTokens
$: accountTokens = getAccountTokensForSelectedAccount($marketCoinPrices)
$: accountTokens, searchValue, setFilteredTokenList()
$: tokenBalance = getTokenBalance(selectedToken.id, selectedToken.networkId)
let hasTokenError: boolean = false
let tokenList: IToken[]
function getTokenList(): IToken[] {
let tokenList: ITokenWithBalance[]
function getTokenList(): ITokenWithBalance[] {
const list = []
for (const tokensPerNetwork of Object.values(accountTokens)) {
if (tokensPerNetwork?.baseCoin) {
Expand All @@ -50,7 +51,7 @@
}
}
function isVisibleToken(token: IToken): boolean {
function isVisibleToken(token: ITokenWithBalance): boolean {
const _searchValue = searchValue.toLowerCase()
const name = token?.metadata?.name
const ticker =
Expand All @@ -62,7 +63,7 @@
)
}
async function onTokenClick(token: IToken): Promise<void> {
async function onTokenClick(token: ITokenWithBalance): Promise<void> {
try {
selectedToken = token
hasTokenError =
Expand Down Expand Up @@ -129,8 +130,8 @@
{#each tokenList as token}
<TokenAmountTile
{token}
amount={tokenBalance?.available}
hasError={token === selectedToken && hasTokenError}
amount={token.balance.available}
onClick={() => onTokenClick(token)}
selected={selectedToken?.id === token.id && selectedToken?.networkId === token?.networkId}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@
export let destinationNetworkId: NetworkId
export let storageDeposit: number
export let estimatedGasFee: BigIntLike | undefined = undefined
export let maxGasFee: BigIntLike | undefined = undefined
export let transactionFee: BigIntLike | undefined = undefined
export let giftStorageDeposit: boolean
export let expirationDate: Date
export let selectedExpirationPeriod: TimePeriod
Expand All @@ -23,6 +22,7 @@
export let disableChangeTimelock: boolean
export let disableGiftStorageDeposit: boolean
export let disableAll: boolean
export let isToLayer2: boolean = false
$: destinationNetwork = getNameFromNetworkId(destinationNetworkId)
</script>
Expand All @@ -37,7 +37,7 @@
</div>
</section>
{/if}
{#if storageDeposit || giftStorageDeposit}
{#if storageDeposit || (giftStorageDeposit && !isToLayer2)}
<section class="key-value-box border-gray-200 dark:border-gray-700">
<div class="flex flex-row">
<Text>{localize('general.storageDeposit')}</Text>
Expand All @@ -56,20 +56,12 @@
/>
</section>
{/if}
{#if estimatedGasFee}
{#if transactionFee}
<section class="key-value-box border-gray-200 dark:border-gray-700">
<div class="flex flex-row">
<Text>{localize('general.estimatedFee')}</Text>
<Text>{localize('general.transactionFee')}</Text>
</div>
<Text color="gray-600">{formatTokenAmountBestMatch(Number(estimatedGasFee), getBaseToken())}</Text>
</section>
{/if}
{#if maxGasFee}
<section class="key-value-box border-gray-200 dark:border-gray-700">
<div class="flex flex-row">
<Text>{localize('general.maxFees')}</Text>
</div>
<Text color="gray-600">{formatTokenAmountBestMatch(Number(maxGasFee), getBaseToken())}</Text>
<Text color="gray-600">{formatTokenAmountBestMatch(Number(transactionFee), getBaseToken())}</Text>
</section>
{/if}
{#if selectedExpirationPeriod}
Expand Down
Loading

0 comments on commit d93663d

Please sign in to comment.