Skip to content

Commit

Permalink
Merge branch 'develop' into refactor/cleanup-tables
Browse files Browse the repository at this point in the history
  • Loading branch information
jeeanribeiro committed Aug 30, 2023
2 parents fe959e7 + 2e7da50 commit 9b10340
Show file tree
Hide file tree
Showing 58 changed files with 537 additions and 352 deletions.
2 changes: 1 addition & 1 deletion packages/desktop/components/NetworkCard.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import { Button, CopyableButton, IconName } from '@bloomwalletio/ui'
import { selectedAccount } from '@core/account/stores'
import { localize } from '@core/i18n'
import { generateAndStoreEvmAddressForAccount } from '@core/layer-2'
import { generateAndStoreEvmAddressForAccount } from '@core/layer-2/actions'
import { LedgerAppName } from '@core/ledger'
import {
IChain,
Expand Down
112 changes: 56 additions & 56 deletions packages/desktop/components/popups/ActivityDetailsPopup.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
import { getNftByIdFromAllAccountNfts } from '@core/nfts/actions'
import { ownedNfts, selectedNftId } from '@core/nfts/stores'
import { checkActiveProfileAuth } from '@core/profile/actions'
import { activeProfile } from '@core/profile/stores'
import { CollectiblesRoute, DashboardRoute, collectiblesRouter, dashboardRouter } from '@core/router'
import { setClipboard, truncateString } from '@core/utils'
import { claimActivity, rejectActivity } from '@core/wallet'
Expand All @@ -35,8 +34,6 @@
export let activityId: string
export let _onMount: (..._: any[]) => Promise<void> = async () => {}
const explorerUrl = getDefaultExplorerUrl($activeProfile?.network?.id)
$: activity = $selectedAccountActivities.find((_activity) => _activity.id === activityId)
$: isTimelocked = activity?.asyncData?.asyncStatus === ActivityAsyncStatus.Timelocked
$: isActivityIncomingAndUnclaimed =
Expand All @@ -50,6 +47,7 @@
? getNftByIdFromAllAccountNfts($selectedAccountIndex, activity.nftId)
: undefined
$: nftIsOwned = nft ? $ownedNfts.some((_onMountnft) => _onMountnft.id === nft?.id) : false
$: explorerUrl = getDefaultExplorerUrl(activity?.sourceNetworkId, ExplorerEndpoint.Transaction)
let title: string | undefined = localize('popups.activityDetails.title.fallback')
$: void setTitle(activity)
Expand All @@ -65,18 +63,18 @@
$collectiblesRouter.goTo(CollectiblesRoute.Details)
}
function onExplorerClick(): void {
openUrlInBrowser(`${explorerUrl}/${ExplorerEndpoint.Transaction}/${activity?.transactionId}`)
function onExplorerClick(_activity: Activity): void {
openUrlInBrowser(`${explorerUrl}/${_activity.transactionId}`)
}
function onTransactionIdClick(): void {
setClipboard(activity?.transactionId)
function onTransactionIdClick(_activity: Activity): void {
setClipboard(_activity.transactionId)
}
async function onClaimClick(): Promise<void> {
async function onClaimClick(_activity: Activity): Promise<void> {
await checkActiveProfileAuth(
async () => {
await claimActivity(activity)
await claimActivity(_activity)
openPopup({
id: PopupId.ActivityDetails,
props: { activityId },
Expand Down Expand Up @@ -118,52 +116,54 @@
})
</script>

<activity-details-popup class="w-full h-full space-y-6 flex flex-auto flex-col shrink-0">
<div class="flex flex-col">
<Text type={TextType.h3} fontWeight={FontWeight.semibold} classes="text-left">
{title}
</Text>
{#if explorerUrl && activity?.transactionId}
<button
class="action w-max flex justify-start text-center font-medium text-14 text-blue-500"
on:click={onExplorerClick}
>
{localize('general.viewOnExplorer')}
</button>
{:else if activity?.transactionId}
<button
class="action w-fit flex justify-start text-center font-medium text-14 text-blue-500"
on:click={onTransactionIdClick}
>
{truncateString(activity.transactionId, 12, 12)}
</button>
{/if}
</div>
<activity-details class="w-full h-full space-y-6 flex flex-auto flex-col shrink-0">
<ActivityStatusPills {activity} />
{#if activity}
<activity-details-popup class="w-full h-full space-y-6 flex flex-auto flex-col shrink-0">
<div class="flex flex-col">
<Text type={TextType.h3} fontWeight={FontWeight.semibold} classes="text-left">
{title}
</Text>
{#if explorerUrl && activity.transactionId}
<button
class="action w-max flex justify-start text-center font-medium text-14 text-blue-500"
on:click={() => onExplorerClick(activity)}
>
{localize('general.viewOnExplorer')}
</button>
{:else if activity.transactionId}
<button
class="action w-fit flex justify-start text-center font-medium text-14 text-blue-500"
on:click={() => onTransactionIdClick(activity)}
>
{truncateString(activity.transactionId, 12, 12)}
</button>
{/if}
</div>
<activity-details class="w-full h-full space-y-6 flex flex-auto flex-col shrink-0">
<ActivityStatusPills {activity} />

<TransactionAssetSection {...transactionAssets} onNftClick={nftIsOwned ? onNftClick : undefined} />
<TransactionAssetSection {...transactionAssets} onNftClick={nftIsOwned ? onNftClick : undefined} />

<ActivityInformation {activity} />
</activity-details>
{#if !isTimelocked && isActivityIncomingAndUnclaimed}
<popup-buttons class="flex flex-row flex-nowrap w-full space-x-4">
<Button
outline
classes="w-full"
disabled={activity.asyncData?.isClaiming || activity.asyncData?.isRejected}
onClick={onRejectClick}
>
{localize('actions.reject')}
</Button>
<Button
classes="w-full"
disabled={activity.asyncData?.isClaiming}
onClick={onClaimClick}
isBusy={activity.asyncData?.isClaiming}
>
{localize('actions.claim')}
</Button>
</popup-buttons>
{/if}
</activity-details-popup>
<ActivityInformation {activity} />
</activity-details>
{#if !isTimelocked && isActivityIncomingAndUnclaimed}
<popup-buttons class="flex flex-row flex-nowrap w-full space-x-4">
<Button
outline
classes="w-full"
disabled={activity.asyncData?.isClaiming || activity.asyncData?.isRejected}
onClick={onRejectClick}
>
{localize('actions.reject')}
</Button>
<Button
classes="w-full"
disabled={activity.asyncData?.isClaiming}
onClick={() => onClaimClick(activity)}
isBusy={activity.asyncData?.isClaiming}
>
{localize('actions.claim')}
</Button>
</popup-buttons>
{/if}
</activity-details-popup>
{/if}
2 changes: 2 additions & 0 deletions packages/desktop/components/popups/Popup.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
import RemoveNode from './RemoveNode.svelte'
import RemoveProposalPopup from './RemoveProposalPopup.svelte'
import RevotePopup from './RevotePopup.svelte'
import SignMessagePopup from './SignMessagePopup.svelte'
import SendFlowPopup from './SendFlowPopup.svelte'
import StopVotingPopup from './StopVotingPopup.svelte'
import BalanceBreakdownPopup from './BalanceBreakdownPopup.svelte'
Expand Down Expand Up @@ -125,6 +126,7 @@
[PopupId.RemoveProposal]: RemoveProposalPopup,
[PopupId.Revote]: RevotePopup,
[PopupId.SendFlow]: SendFlowPopup,
[PopupId.SignMessage]: SignMessagePopup,
[PopupId.StopVoting]: StopVotingPopup,
[PopupId.BalanceBreakdown]: BalanceBreakdownPopup,
[PopupId.TestDeepLinkForm]: TestDeepLinkFormPopup,
Expand Down
103 changes: 103 additions & 0 deletions packages/desktop/components/popups/SignMessagePopup.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
<script lang="ts">
import { Button, Text, TextHint, FontWeight, TextType, AccountLabel } from '@ui'
import { localize } from '@core/i18n'
import { closePopup } from '@desktop/auxiliary/popup'
import { handleError } from '@core/error/handlers'
import { onMount } from 'svelte'
import { selectedAccount } from '@core/account/stores'
import { sleep, truncateString } from '@core/utils'
import { IConnectedDapp } from '@auxiliary/wallet-connect/interface'
import { IAccountState } from '@core/account'
import { IChain } from '@core/network'
import { CallbackParameters } from '@auxiliary/wallet-connect/types'
export let _onMount: (..._: any[]) => Promise<void> = async () => {}
export let message: string
export let account: IAccountState
export let chain: IChain
export let dapp: IConnectedDapp | undefined
export let callback: (params: CallbackParameters) => void
$: address = truncateString(account.evmAddresses[chain.getConfiguration().coinType] ?? '', 8, 8)
let isBusy = false
async function onConfirmClick(): Promise<void> {
isBusy = true
try {
const signedMessage = await sign()
callback({ result: signedMessage })
closePopup()
} finally {
isBusy = false
}
}
async function sign(): Promise<string> {
// TODO: Replace this with the correct signing implementation
await sleep(500)
return '0x3123'
}
function onCancelClick(): void {
callback({ error: 'User rejected' })
closePopup()
}
onMount(async () => {
try {
await _onMount()
} catch (err) {
handleError(err)
}
})
</script>

<div class="w-full h-full space-y-6 flex flex-auto flex-col shrink-0">
<Text type={TextType.h3} fontWeight={FontWeight.semibold} classes="text-left">
{localize('popups.signMessage.title')}
</Text>
<div class="space-y-4">
<section class="relative flex flex-col border border-solid border-gray-200 rounded-xl p-6">
<Text fontWeight={FontWeight.medium} color="gray-600">{localize('popups.signMessage.message')}</Text>
<Text>{message}</Text>
{#if dapp}
<div class="absolute flex flex-row justify-between" style="top: -12px; left: 18px;">
<div class="flex flex-row gap-1 bg-white dark:bg-gray-800 items-center px-2">
<img
style="width: 24px; height: 24px; border-radius: 24px;"
src={dapp.metadata?.icons?.[0]}
alt={dapp.metadata?.name}
/>
<Text fontSize="10" fontWeight={FontWeight.bold}>
{dapp.metadata?.name}
</Text>
</div>
</div>
{/if}
</section>
<section class="flex flex-row justify-between items-center border border-solid border-gray-200 rounded-xl p-4">
<AccountLabel {account} />
<Text color="gray-600" fontWeight={FontWeight.semibold}>
{address}
</Text>
</section>
{#if dapp}
<TextHint info text={localize('popups.signMessage.hint', { dappName: dapp.metadata?.name ?? 'Unkown' })} />
{:else}
<TextHint warning text={localize('popups.signMessage.warning')} />
{/if}
</div>
<popup-buttons class="flex flex-row flex-nowrap w-full space-x-4">
<Button classes="w-full" outline onClick={onCancelClick}>{localize('actions.cancel')}</Button>
<Button
classes="w-full"
disabled={$selectedAccount.isTransferring || isBusy}
isBusy={$selectedAccount.isTransferring || isBusy}
onClick={onConfirmClick}
>
{localize('popups.signMessage.action')}
</Button>
</popup-buttons>
</div>
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ export enum PopupId {
RemoveNode = 'removeNode',
RemoveProposal = 'removeProposal',
Revote = 'revote',
SignMessage = 'signMessage',
SendFlow = 'sendFlow',
StopVoting = 'stopVoting',
BalanceBreakdown = 'balanceBreakdown',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
import { getNftByIdFromAllAccountNfts } from '@core/nfts/actions'
import { allAccountNfts, selectedNftId } from '@core/nfts/stores'
import { getBaseToken } from '@core/profile/actions'
import { activeProfile } from '@core/profile/stores'
import { collectiblesRouter } from '@core/router/routers'
import { formatTokenAmountPrecise } from '@core/token'
import { getTimeDifference } from '@core/utils'
Expand All @@ -28,8 +27,8 @@
let modal: Modal
const explorerUrl = getDefaultExplorerUrl($activeProfile?.network?.id)
const nft: INft = getNftByIdFromAllAccountNfts($selectedAccountIndex, $selectedNftId)
const explorerUrl = getDefaultExplorerUrl(nft?.networkId, ExplorerEndpoint.Nft)
const { id, name, issuer, address, metadata, downloadMetadata, storageDeposit } = nft ?? {}
const { standard, version, type, uri, description, issuerName, collectionName, attributes, soonaverseAttributes } =
Expand Down Expand Up @@ -155,7 +154,7 @@
}
function onExplorerClick(): void {
openUrlInBrowser(`${explorerUrl}/${ExplorerEndpoint.Nft}/${id}`)
openUrlInBrowser(`${explorerUrl}/${id}`)
}
function onSendClick(): void {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<script lang="ts">
import { createEventDispatcher } from 'svelte'
import { DateTimePicker } from '@ui'
import { DateTimePicker } from '@bloomwalletio/ui'
import { localize } from '@core/i18n'
import { isValidExpirationDateTime, MILLISECONDS_PER_SECOND, SECONDS_PER_MINUTE } from '@core/utils'
import { showNotification } from '@auxiliary/notification'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import { selectedAccount } from '@core/account/stores'
import { getStorageDepositFromOutput } from '@core/activity/utils/helper'
import { localize } from '@core/i18n'
import { getGasFeesForLayer1ToLayer2Transaction } from '@core/layer-2'
import { getGasFeesForLayer1ToLayer2Transaction } from '@core/layer-2/actions'
import { getNetwork, isEvmChain } from '@core/network'
import { INft } from '@core/nfts/interfaces'
import { selectedAccountTokens } from '@core/token/stores'
Expand Down
3 changes: 1 addition & 2 deletions packages/shared/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"author": "Charlie Varley <[email protected]>",
"license": "Apache-2.0",
"dependencies": {
"@bloomwalletio/ui": "0.7.10",
"@bloomwalletio/ui": "0.7.12",
"@iota/bundle": "1.0.0-beta.30",
"@iota/converter": "1.0.0-beta.30",
"@iota/crypto.js": "1.8.6",
Expand All @@ -26,7 +26,6 @@
"svelte": "3.58.0",
"svelte-i18n": "3.7.0",
"svelte-markdown": "0.2.3",
"svelty-picker": "3.5.0",
"web3": "1.10.0",
"zxcvbn": "4.4.2"
},
Expand Down
Loading

0 comments on commit 9b10340

Please sign in to comment.